In WP_Themes_List_Table, don't perform unnecessary sanitization on search terms or filter features. We only use these for case-insensitive comparison. see #19815.
git-svn-id: https://develop.svn.wordpress.org/trunk@20048 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5e9b785d5d
commit
cc503e4315
|
@ -9,7 +9,7 @@
|
||||||
*/
|
*/
|
||||||
class WP_Themes_List_Table extends WP_List_Table {
|
class WP_Themes_List_Table extends WP_List_Table {
|
||||||
|
|
||||||
var $search = array();
|
protected $search_terms = array();
|
||||||
var $features = array();
|
var $features = array();
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
|
@ -26,20 +26,15 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||||
function prepare_items() {
|
function prepare_items() {
|
||||||
$themes = wp_get_themes( array( 'allowed' => true ) );
|
$themes = wp_get_themes( array( 'allowed' => true ) );
|
||||||
|
|
||||||
if ( ! empty( $_REQUEST['s'] ) ) {
|
if ( ! empty( $_REQUEST['s'] ) )
|
||||||
$search = strtolower( stripslashes( $_REQUEST['s'] ) );
|
$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( stripslashes( $_REQUEST['s'] ) ) ) ) ) );
|
||||||
$this->search = array_merge( $this->search, array_filter( array_map( 'trim', explode( ',', $search ) ) ) );
|
|
||||||
$this->search = array_unique( $this->search );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !empty( $_REQUEST['features'] ) ) {
|
if ( ! empty( $_REQUEST['features'] ) ) {
|
||||||
|
var_dump( $_REQUEST['features'] );
|
||||||
$this->features = $_REQUEST['features'];
|
$this->features = $_REQUEST['features'];
|
||||||
$this->features = array_map( 'trim', $this->features );
|
|
||||||
$this->features = array_map( 'sanitize_title_with_dashes', $this->features );
|
|
||||||
$this->features = array_unique( $this->features );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->search || $this->features ) {
|
if ( $this->search_terms || $this->features ) {
|
||||||
foreach ( $themes as $key => $theme ) {
|
foreach ( $themes as $key => $theme ) {
|
||||||
if ( ! $this->search_theme( $theme ) )
|
if ( ! $this->search_theme( $theme ) )
|
||||||
unset( $themes[ $key ] );
|
unset( $themes[ $key ] );
|
||||||
|
@ -63,7 +58,7 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
function no_items() {
|
function no_items() {
|
||||||
if ( $this->search || $this->features ) {
|
if ( $this->search_terms || $this->features ) {
|
||||||
_e( 'No items found.' );
|
_e( 'No items found.' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -186,33 +181,29 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||||
|
|
||||||
function search_theme( $theme ) {
|
function search_theme( $theme ) {
|
||||||
// Search the features
|
// Search the features
|
||||||
if ( $this->features ) {
|
foreach ( $this->features as $word ) {
|
||||||
foreach ( $this->features as $word ) {
|
if ( ! in_array( $word, $theme->get('Tags') ) )
|
||||||
if ( ! in_array( $word, $theme->get('Tags') ) )
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match all phrases
|
// Match all phrases
|
||||||
if ( $this->search ) {
|
foreach ( $this->search_terms as $word ) {
|
||||||
foreach ( $this->search as $word ) {
|
if ( in_array( $word, $theme->get('Tags') ) )
|
||||||
if ( in_array( $word, $theme->get('Tags') ) )
|
continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) {
|
foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) {
|
||||||
// Don't mark up; Do translate.
|
// Don't mark up; Do translate.
|
||||||
if ( false !== stripos( $theme->display( $header, false, true ), $word ) )
|
if ( false !== stripos( $theme->display( $header, false, true ), $word ) )
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
|
||||||
|
|
||||||
if ( false !== stripos( $theme->get_stylesheet(), $word ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( false !== stripos( $theme->get_template(), $word ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( false !== stripos( $theme->get_stylesheet(), $word ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( false !== stripos( $theme->get_template(), $word ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue