Remove remnants from widgets search, see #9511
git-svn-id: https://develop.svn.wordpress.org/trunk@11041 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3c2fd1ca40
commit
e3830feb21
|
@ -16,52 +16,20 @@
|
|||
* @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'.
|
||||
* @param string $_search Optional. Search for widgets. Should be unsanitized.
|
||||
*/
|
||||
function wp_list_widgets( $show = 'all', $_search = false ) {
|
||||
function wp_list_widgets() {
|
||||
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
|
||||
|
||||
if ( $_search ) {
|
||||
// sanitize
|
||||
$search = preg_replace( '/[^\w\s]/', '', $_search );
|
||||
// array of terms
|
||||
$search_terms = preg_split( '/[\s]/', $search, -1, PREG_SPLIT_NO_EMPTY );
|
||||
} else {
|
||||
$search_terms = array();
|
||||
}
|
||||
|
||||
if ( !in_array( $show, array( 'all', 'unused', 'used' ) ) )
|
||||
$show = 'all';
|
||||
?>
|
||||
$no_widgets_shown = true;
|
||||
$already_shown = array(); ?>
|
||||
|
||||
<ul id="widget-list">
|
||||
<?php
|
||||
$no_widgets_shown = true;
|
||||
$already_shown = array();
|
||||
foreach ( $wp_registered_widgets as $name => $widget ) {
|
||||
if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
|
||||
if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
|
||||
continue;
|
||||
|
||||
if ( $search_terms ) {
|
||||
$hit = false;
|
||||
// Simple case-insensitive search. Boolean OR.
|
||||
$search_text = preg_replace( '/[^\w]/', '', $widget['name'] );
|
||||
if ( isset($widget['description']) )
|
||||
$search_text .= preg_replace( '/[^\w]/', '', $widget['description'] );
|
||||
|
||||
foreach ( $search_terms as $search_term ) {
|
||||
if ( stristr( $search_text, $search_term ) ) {
|
||||
$hit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !$hit )
|
||||
continue;
|
||||
}
|
||||
|
||||
$sidebar = is_active_widget( $widget['callback'], $widget['id'] );
|
||||
|
||||
if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) )
|
||||
continue;
|
||||
|
||||
if ( ! isset( $widget['params'][0] ) )
|
||||
$widget['params'][0] = array();
|
||||
|
||||
|
@ -86,8 +54,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
|
|||
}
|
||||
|
||||
if ( $no_widgets_shown )
|
||||
echo '<li>' . __( 'No matching widgets' ) . "</li>\n";
|
||||
?>
|
||||
echo '<li>' . __( 'No matching widgets' ) . "</li>\n"; ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -311,20 +311,6 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
// Unsanitized!
|
||||
$widget_search = isset($_GET['s']) ? $_GET['s'] : false;
|
||||
|
||||
// Not entirely sure what all should be here
|
||||
$show_values = array(
|
||||
'' => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ),
|
||||
'unused' => __( 'Show unused widgets' ),
|
||||
'used' => __( 'Show used widgets' )
|
||||
);
|
||||
|
||||
$show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false;
|
||||
*/
|
||||
|
||||
$messages = array(
|
||||
__('Changes saved.')
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue