Faster theme searching. Only calculate what is necessary -- if the theme doesn't have all of the features, bail. If a word matches a tag or header, jump to the next word, we don't care how many times it matches. see #20103.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20027 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2a15b783aa
commit
7959828e48
|
@ -190,38 +190,29 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
function search_theme( $theme ) {
|
function search_theme( $theme ) {
|
||||||
$matched = 0;
|
// Search the features
|
||||||
|
if ( $this->features ) {
|
||||||
|
foreach ( $this->features as $word ) {
|
||||||
|
if ( ! in_array( $word, $theme['Tags'] ) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Match all phrases
|
// Match all phrases
|
||||||
if ( count( $this->search ) > 0 ) {
|
if ( $this->search ) {
|
||||||
foreach ( $this->search as $word ) {
|
foreach ( $this->search as $word ) {
|
||||||
$matched = 0;
|
|
||||||
|
|
||||||
// In a tag?
|
|
||||||
if ( in_array( $word, $theme['Tags'] ) )
|
if ( in_array( $word, $theme['Tags'] ) )
|
||||||
$matched = 1;
|
continue;
|
||||||
|
|
||||||
// In one of the fields?
|
|
||||||
foreach ( array( 'Name', 'Title', 'Description', 'Author', 'Template', 'Stylesheet' ) AS $field ) {
|
|
||||||
if ( stripos( $theme[$field], $word ) !== false )
|
|
||||||
$matched++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $matched == 0 )
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ( array( 'Name', 'Title', 'Description', 'Author', 'Template', 'Stylesheet' ) as $header ) {
|
||||||
|
if ( false !== stripos( $theme[ $header ], $word ) )
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now search the features
|
|
||||||
if ( count( $this->features ) > 0 ) {
|
|
||||||
foreach ( $this->features as $word ) {
|
|
||||||
// In a tag?
|
|
||||||
if ( !in_array( $word, $theme['Tags'] ) )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only get here if each word exists in the tags or one of the fields
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue