Ticket #11160: 11160-2.patch
| File 11160-2.patch, 5.1 KB (added by , 17 years ago) |
|---|
-
wp-includes/widgets.php
381 381 /** 382 382 * Private 383 383 */ 384 $_wp_deprecated_widgets_callbacks = array(385 'wp_widget_pages',384 $_wp_deprecated_widgets_callbacks = array( 385 'wp_widget_pages', 386 386 'wp_widget_pages_control', 387 387 'wp_widget_calendar', 388 388 'wp_widget_calendar_control', … … 404 404 'wp_widget_rss_control', 405 405 'wp_widget_recent_comments', 406 406 'wp_widget_recent_comments_control' 407 );407 ); 408 408 409 409 /* Template tags & API functions */ 410 410 … … 448 448 } 449 449 450 450 /** 451 * Return the registered ID of a sidebar given it's name or registration ID. 452 * 453 * Since register_sidebar() supports it, this function will look for sidebars 454 * named as integers or as a default id (like 2 or 'sidebar-13') first and check 455 * those as IDs if the name fails (and those IDs exist). 456 * ie: $id = wp_get_sidebar_id(1); 457 * $id = wp_get_sidebar_id('Sidebar Top'); 458 * 459 * wp_get_sidebar_id() will also take an array of arguments. The array should have 460 * keys 'name', 'id' or both: $id = wp_get_sidebar_id( array('id' => 'sidebar-1') ); 461 * 462 * @since 2.9.0 463 * 464 * @param int|string|array $args The name or id of the sidebar as registered with 465 * register_sidebar(s) functions. If an array, use the register_sidebar() syntax. 466 * 467 * @return mixed returns false if id not found or returns sidebar id. 468 */ 469 function wp_get_sidebar_id($args) { 470 global $wp_registered_sidebars; 471 472 if ( is_array($args) ) { 473 // $args is an array holding a name, an id or both. 474 if ( !empty($args['id']) ) 475 $args = $args['id']; 476 elseif ( !empty($args['name']) ) 477 $args = $args['name']; 478 else 479 return false; 480 } 481 482 if ( is_int($args) ) { 483 return "sidebar-$args"; 484 } elseif ( is_string($args) ) { 485 $name = sanitize_title($args); 486 487 foreach ( (array) $wp_registered_sidebars as $id => $value ) { 488 if ( sanitize_title($value['name']) == $name || $id == $name ) 489 return $id; 490 } 491 } 492 493 return false; 494 } 495 496 497 /** 451 498 * Creates multiple sidebars. 452 499 * 453 500 * If you wanted to quickly create multiple sidebars for a theme or internally. … … 565 612 * 566 613 * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID. 567 614 * 568 * @param string $name The ID of the sidebar when it was added. 615 * @param int|string|array $name The name or id of the sidebar as registered with 616 * register_sidebar(s) functions. If an array, use the register_sidebar() syntax 617 * including keys 'name', 'id' or both. 569 618 */ 570 function unregister_sidebar( $name) {619 function unregister_sidebar($name) { 571 620 global $wp_registered_sidebars; 621 $name = wp_get_sidebar_id($name); 572 622 573 623 if ( isset( $wp_registered_sidebars[$name] ) ) 574 624 unset( $wp_registered_sidebars[$name] ); … … 825 875 * 826 876 * @since 2.2.0 827 877 * 828 * @param int|string $index Optional, default is 1. Name or ID of dynamic sidebar. 878 * @param int|string|array $args Optional, default is 1. The name or id of the wigdet 879 * specified by register_sidebar(s) functions. As an array use the register_sidebar() 880 * syntax identifying sidebar by name or id or both. 829 881 * @return bool True, if widget sidebar was found and called. False if not found or not called. 830 882 */ 831 function dynamic_sidebar($ index= 1) {883 function dynamic_sidebar($name = 1) { 832 884 global $wp_registered_sidebars, $wp_registered_widgets; 833 885 834 if ( is_int($index) ) { 835 $index = "sidebar-$index"; 836 } else { 837 $index = sanitize_title($index); 838 foreach ( (array) $wp_registered_sidebars as $key => $value ) { 839 if ( sanitize_title($value['name']) == $index ) { 840 $index = $key; 841 break; 842 } 843 } 844 } 886 $name = wp_get_sidebar_id($name); 845 887 846 888 $sidebars_widgets = wp_get_sidebars_widgets(); 847 889 848 if ( empty($wp_registered_sidebars[$ index]) || !array_key_exists($index, $sidebars_widgets) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) )890 if ( empty($wp_registered_sidebars[$name]) || !array_key_exists($name, $sidebars_widgets) || !is_array($sidebars_widgets[$name]) || empty($sidebars_widgets[$name]) ) 849 891 return false; 850 892 851 $sidebar = $wp_registered_sidebars[$ index];893 $sidebar = $wp_registered_sidebars[$name]; 852 894 853 895 $did_one = false; 854 foreach ( (array) $sidebars_widgets[$ index] as $id ) {896 foreach ( (array) $sidebars_widgets[$name] as $id ) { 855 897 856 898 if ( !isset($wp_registered_widgets[$id]) ) continue; 857 899 … … 953 995 * 954 996 * @since 2.8 955 997 * 956 * @param mixed $index, sidebar name, id or number to check. 998 * @param int|string|array $name The name or id of the sidebar as registered with 999 * register_sidebar(s) functions. If an array, use the register_sidebar() syntax 1000 * including keys 'name' or 'id' or both. 1001 * 957 1002 * @return bool true if the sidebar is in use, false otherwise. 958 1003 */ 959 function is_active_sidebar( $index) {960 $ index = ( is_int($index) ) ? "sidebar-$index" : sanitize_title($index);1004 function is_active_sidebar($name) { 1005 $name = wp_get_sidebar_id($name); 961 1006 $sidebars_widgets = wp_get_sidebars_widgets(); 962 if ( isset($sidebars_widgets[$index]) && !empty($sidebars_widgets[$index]) ) 963 return true; 964 965 return false; 1007 1008 return !empty($sidebars_widgets[$name]); 966 1009 } 967 1010 968 1011 /* Internal Functions */
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)