Changeset 1592
- Timestamp:
- 05/18/2015 05:48:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/admin-edit.php
r1473 r1592 48 48 } 49 49 add_action( 'init', 'wporg_themes_post_status' ); 50 51 /** 52 * Extends repopackage searches in wp-admin to include theme slugs. 53 * 54 * @param string $search Search SQL for WHERE clause. 55 * @param WP_Query $wp_query The current WP_Query object. 56 * @return string 57 */ 58 function wporg_themes_search_slug( $search, $wp_query ) { 59 if ( ! is_admin() || 'repopackage' !== $wp_query->query_vars['post_type'] ) { 60 return $search; 61 } 62 63 global $wpdb; 64 $n = empty( $wp_query->query_vars['exact'] ) ? '%' : ''; 65 $search = $searchand = ''; 66 67 foreach ( $wp_query->query_vars['search_terms'] as $term ) { 68 $like = $n . $wpdb->esc_like( $term ) . $n; 69 $search .= $wpdb->prepare( "{$searchand}(($wpdb->posts.post_title LIKE %s) OR ($wpdb->posts.post_name LIKE %s) OR ($wpdb->posts.post_content LIKE %s))", $like, $like, $like ); 70 $searchand = ' AND '; 71 } 72 73 if ( ! empty( $search ) ) { 74 $search = " AND ({$search}) "; 75 if ( ! is_user_logged_in() ) { 76 $search .= " AND ($wpdb->posts.post_password = '') "; 77 } 78 } 79 80 return $search; 81 } 82 add_filter( 'posts_search', 'wporg_themes_search_slug', 10, 2 ); 50 83 51 84 /**
Note: See TracChangeset
for help on using the changeset viewer.