Ticket #25368: widgets.php.patch
File widgets.php.patch, 3.7 KB (added by , 11 years ago) |
---|
-
src/wp-includes/widgets.php
857 857 } 858 858 } 859 859 860 $did_one = false; 860 861 $sidebars_widgets = wp_get_sidebars_widgets(); 861 if ( empty( $sidebars_widgets ) ) 862 return false; 862 $is_empty_sidebar = ( 863 empty( $sidebars_widgets ) 864 || 865 empty( $wp_registered_sidebars[$index] ) 866 || 867 ! array_key_exists( $index, $sidebars_widgets ) 868 || 869 ! is_array( $sidebars_widgets[$index] ) 870 || 871 empty( $sidebars_widgets[$index] ) 872 ); 863 873 864 if ( empty($wp_registered_sidebars[$index]) || !array_key_exists($index, $sidebars_widgets) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) ) 865 return false; 874 do_action( 'temp_before_dynamic_sidebar', $index, $is_empty_sidebar ); 875 if ( ! $is_empty_sidebar ) { 876 $sidebar = $wp_registered_sidebars[$index]; 866 877 867 $sidebar = $wp_registered_sidebars[$index];878 foreach ( (array) $sidebars_widgets[$index] as $id ) { 868 879 869 $did_one = false; 870 foreach ( (array) $sidebars_widgets[$index] as $id ) { 880 if ( !isset($wp_registered_widgets[$id]) ) continue; 871 881 872 if ( !isset($wp_registered_widgets[$id]) ) continue; 882 $params = array_merge( 883 array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ), 884 (array) $wp_registered_widgets[$id]['params'] 885 ); 873 886 874 $params = array_merge( 875 array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ), 876 (array) $wp_registered_widgets[$id]['params'] 877 ); 887 // Substitute HTML id and class attributes into before_widget 888 $classname_ = ''; 889 foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) { 890 if ( is_string($cn) ) 891 $classname_ .= '_' . $cn; 892 elseif ( is_object($cn) ) 893 $classname_ .= '_' . get_class($cn); 894 } 895 $classname_ = ltrim($classname_, '_'); 896 $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_); 878 897 879 // Substitute HTML id and class attributes into before_widget 880 $classname_ = ''; 881 foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) { 882 if ( is_string($cn) ) 883 $classname_ .= '_' . $cn; 884 elseif ( is_object($cn) ) 885 $classname_ .= '_' . get_class($cn); 886 } 887 $classname_ = ltrim($classname_, '_'); 888 $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_); 898 $params = apply_filters( 'dynamic_sidebar_params', $params ); 889 899 890 $params = apply_filters( 'dynamic_sidebar_params', $params );900 $callback = $wp_registered_widgets[$id]['callback']; 891 901 892 $callback = $wp_registered_widgets[$id]['callback'];902 do_action( 'dynamic_sidebar', $wp_registered_widgets[$id] ); 893 903 894 do_action( 'dynamic_sidebar', $wp_registered_widgets[$id] ); 895 896 if ( is_callable($callback) ) { 897 call_user_func_array($callback, $params); 898 $did_one = true; 904 if ( is_callable($callback) ) { 905 call_user_func_array($callback, $params); 906 $did_one = true; 907 } 899 908 } 900 909 } 910 do_action( 'temp_after_dynamic_sidebar', $index, $is_empty_sidebar ); 901 911 902 return $did_one;912 return apply_filters( 'temp_dynamic_sidebar_did_one', $did_one, $index ); 903 913 } 904 914 905 915 /** … … 977 987 function is_active_sidebar( $index ) { 978 988 $index = ( is_int($index) ) ? "sidebar-$index" : sanitize_title($index); 979 989 $sidebars_widgets = wp_get_sidebars_widgets(); 980 if ( !empty($sidebars_widgets[$index]) ) 981 return true; 982 983 return false; 990 $is_active_sidebar = ! empty( $sidebars_widgets[$index] ); 991 $is_active_sidebar = apply_filters( 'temp_is_active_sidebar', $is_active_sidebar, $index ); 992 return $is_active_sidebar; 984 993 } 985 994 986 995 /* Internal Functions */