Changeset 5117
- Timestamp:
- 10/03/2013 05:13:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/common/template.php
r5105 r5117 1331 1331 * - tab: Tabindex value. False or integer 1332 1332 * - options_only: Show only <options>? No <select>? 1333 * - show_none: False or something like __( '(No Forum)', 'bbpress' ), 1334 * will have value="" 1335 * - none_found: False or something like 1336 * __( 'No forums to post to!', 'bbpress' ) 1333 * - show_none: Boolean or String __( '(No Forum)', 'bbpress' ) 1337 1334 * - disable_categories: Disable forum categories and closed forums? 1338 1335 * Defaults to true. Only for forums and when … … 1371 1368 'options_only' => false, 1372 1369 'show_none' => false, 1373 'none_found' => false,1374 1370 'disable_categories' => true, 1375 1371 'disabled' => '' … … 1408 1404 /** Drop Down *********************************************************/ 1409 1405 1410 // Items found 1406 // Build the opening tag for the select element 1407 if ( empty( $r['options_only'] ) ) { 1408 1409 // Should this select appear disabled? 1410 $disabled = disabled( isset( bbpress()->options[ $r['disabled'] ] ), true, false ); 1411 1412 // Setup the tab index attribute 1413 $tab = !empty( $r['tab'] ) ? ' tabindex="' . intval( $r['tab'] ) . '"' : ''; 1414 1415 // Open the select tag 1416 $retval .= '<select name="' . esc_attr( $r['select_id'] ) . '" id="' . esc_attr( $r['select_id'] ) . '"' . $disabled . $tab . '>' . "\n"; 1417 } 1418 1419 // Display a leading 'no-value' option, with or without custom text 1420 if ( !empty( $r['show_none'] ) || !empty( $r['none_found'] ) ) { 1421 1422 // Open the 'no-value' option tag 1423 $retval .= "\t<option value=\"\" class=\"level-0\">"; 1424 1425 // Use deprecated 'none_found' first for backpat 1426 if ( ! empty( $r['none_found'] ) && is_string( $r['none_found'] ) ) { 1427 $retval .= esc_html( $r['none_found'] ); 1428 1429 // Use 'show_none' second 1430 } elseif ( ! empty( $r['show_none'] ) && is_string( $r['show_none'] ) ) { 1431 $retval .= esc_html( $r['show_none'] ); 1432 1433 // Otherwise, make some educated guesses 1434 } else { 1435 1436 // Switch the response based on post type 1437 switch ( $r['post_type'] ) { 1438 1439 // Topics 1440 case bbp_get_topic_post_type() : 1441 $retval .= esc_html__( 'No topics available', 'bbpress' ); 1442 break; 1443 1444 // Forums 1445 case bbp_get_forum_post_type() : 1446 $retval .= esc_html__( 'No forums available', 'bbpress' ); 1447 break; 1448 1449 // Any other 1450 default : 1451 $retval .= esc_html__( 'None available', 'bbpress' ); 1452 break; 1453 } 1454 } 1455 1456 // Close the 'no-value' option tag 1457 $retval .= '</option>'; 1458 } 1459 1460 // Items found so walk the tree 1411 1461 if ( !empty( $posts ) ) { 1412 1413 // Build the opening tag for the select element1414 if ( empty( $r['options_only'] ) ) {1415 1416 // Should this select appear disabled?1417 $disabled = disabled( isset( bbpress()->options[ $r['disabled'] ] ), true, false );1418 1419 // Setup the tab index attribute1420 $tab = !empty( $r['tab'] ) ? ' tabindex="' . intval( $r['tab'] ) . '"' : '';1421 1422 // Build the opening tag1423 $retval .= '<select name="' . esc_attr( $r['select_id'] ) . '" id="' . esc_attr( $r['select_id'] ) . '"' . $disabled . $tab . '>' . "\n";1424 }1425 1426 // Get the options1427 $retval .= !empty( $r['show_none'] ) ? "\t<option value=\"\" class=\"level-0\">" . esc_html( $r['show_none'] ) . '</option>' : '';1428 1462 $retval .= walk_page_dropdown_tree( $posts, 0, $r ); 1429 1430 // Build the closing tag for the select element 1431 if ( empty( $r['options_only'] ) ) { 1432 $retval .= '</select>'; 1433 } 1434 1435 // No items found - Display feedback if no custom message was passed 1436 } elseif ( empty( $r['none_found'] ) ) { 1437 1438 // Switch the response based on post type 1439 switch ( $r['post_type'] ) { 1440 1441 // Topics 1442 case bbp_get_topic_post_type() : 1443 $retval = __( 'No topics available', 'bbpress' ); 1444 break; 1445 1446 // Forums 1447 case bbp_get_forum_post_type() : 1448 $retval = __( 'No forums available', 'bbpress' ); 1449 break; 1450 1451 // Any other 1452 default : 1453 $retval = __( 'None available', 'bbpress' ); 1454 break; 1455 } 1463 } 1464 1465 // Close the selecet tag 1466 if ( empty( $r['options_only'] ) ) { 1467 $retval .= '</select>'; 1456 1468 } 1457 1469
Note: See TracChangeset
for help on using the changeset viewer.