- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-themes-list-table.php
r41219 r42343 19 19 20 20 protected $search_terms = array(); 21 public $features = array();21 public $features = array(); 22 22 23 23 /** … … 31 31 */ 32 32 public function __construct( $args = array() ) { 33 parent::__construct( array( 34 'ajax' => true, 35 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 36 ) ); 37 } 38 39 /** 40 * 33 parent::__construct( 34 array( 35 'ajax' => true, 36 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 37 ) 38 ); 39 } 40 41 /** 41 42 * @return bool 42 43 */ … … 51 52 $themes = wp_get_themes( array( 'allowed' => true ) ); 52 53 53 if ( ! empty( $_REQUEST['s'] ) ) 54 if ( ! empty( $_REQUEST['s'] ) ) { 54 55 $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); 55 56 if ( ! empty( $_REQUEST['features'] ) ) 56 } 57 58 if ( ! empty( $_REQUEST['features'] ) ) { 57 59 $this->features = $_REQUEST['features']; 60 } 58 61 59 62 if ( $this->search_terms || $this->features ) { 60 63 foreach ( $themes as $key => $theme ) { 61 if ( ! $this->search_theme( $theme ) ) 64 if ( ! $this->search_theme( $theme ) ) { 62 65 unset( $themes[ $key ] ); 66 } 63 67 } 64 68 } … … 68 72 69 73 $per_page = 36; 70 $page = $this->get_pagenum();74 $page = $this->get_pagenum(); 71 75 72 76 $start = ( $page - 1 ) * $per_page; … … 74 78 $this->items = array_slice( $themes, $start, $per_page, true ); 75 79 76 $this->set_pagination_args( array( 77 'total_items' => count( $themes ), 78 'per_page' => $per_page, 79 'infinite_scroll' => true, 80 ) ); 80 $this->set_pagination_args( 81 array( 82 'total_items' => count( $themes ), 83 'per_page' => $per_page, 84 'infinite_scroll' => true, 85 ) 86 ); 81 87 } 82 88 … … 116 122 */ 117 123 public function tablenav( $which = 'top' ) { 118 if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) 124 if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) { 119 125 return; 126 } 120 127 ?> 121 128 <div class="tablenav themes <?php echo $which; ?>"> … … 130 137 */ 131 138 public function display() { 132 wp_nonce_field( "fetch-list-". get_class( $this ), '_ajax_fetch_list_nonce' );139 wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' ); 133 140 ?> 134 141 <?php $this->tablenav( 'top' ); ?> … … 143 150 144 151 /** 145 *146 152 * @return array 147 153 */ … … 167 173 $themes = $this->items; 168 174 169 foreach ( $themes as $theme ): 170 ?><div class="available-theme"><?php 175 foreach ( $themes as $theme ) : 176 ?> 177 <div class="available-theme"> 178 <?php 171 179 172 180 $template = $theme->get_template(); 173 181 $stylesheet = $theme->get_stylesheet(); 174 $title = $theme->display( 'Name');175 $version = $theme->display( 'Version');176 $author = $theme->display( 'Author');177 178 $activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=". urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );179 180 $actions = array();182 $title = $theme->display( 'Name' ); 183 $version = $theme->display( 'Version' ); 184 $author = $theme->display( 'Author' ); 185 186 $activate_link = wp_nonce_url( 'themes.php?action=activate&template=' . urlencode( $template ) . '&stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); 187 188 $actions = array(); 181 189 $actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="' 182 190 . esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>'; … … 187 195 } 188 196 189 if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) 197 if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) { 190 198 $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ) 191 199 . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ) 192 200 . "' );" . '">' . __( 'Delete' ) . '</a>'; 201 } 193 202 194 203 /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ 195 $actions 204 $actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' ); 196 205 197 206 /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ … … 217 226 <div class="action-links"> 218 227 <ul> 219 <?php foreach ( $actions as $action ) : ?>228 <?php foreach ( $actions as $action ) : ?> 220 229 <li><?php echo $action; ?></li> 221 230 <?php endforeach; ?> 222 <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details')?></a></li>231 <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details' ); ?></a></li> 223 232 </ul> 224 233 <?php echo $delete_action; ?> … … 228 237 229 238 <div class="themedetaildiv hide-if-js"> 230 <p><strong><?php _e('Version:'); ?></strong> <?php echo $version; ?></p> 231 <p><?php echo $theme->display('Description'); ?></p> 232 <?php if ( $theme->parent() ) { 233 printf( ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>', 239 <p><strong><?php _e( 'Version:' ); ?></strong> <?php echo $version; ?></p> 240 <p><?php echo $theme->display( 'Description' ); ?></p> 241 <?php 242 if ( $theme->parent() ) { 243 printf( 244 ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>', 234 245 __( 'https://codex.wordpress.org/Child_Themes' ), 235 $theme->parent()->display( 'Name' ) ); 236 } ?> 246 $theme->parent()->display( 'Name' ) 247 ); 248 } 249 ?> 237 250 </div> 238 251 … … 249 262 // Search the features 250 263 foreach ( $this->features as $word ) { 251 if ( ! in_array( $word, $theme->get( 'Tags') ) )264 if ( ! in_array( $word, $theme->get( 'Tags' ) ) ) { 252 265 return false; 266 } 253 267 } 254 268 255 269 // Match all phrases 256 270 foreach ( $this->search_terms as $word ) { 257 if ( in_array( $word, $theme->get( 'Tags') ) )271 if ( in_array( $word, $theme->get( 'Tags' ) ) ) { 258 272 continue; 273 } 259 274 260 275 foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { … … 265 280 } 266 281 267 if ( false !== stripos( $theme->get_stylesheet(), $word ) ) 282 if ( false !== stripos( $theme->get_stylesheet(), $word ) ) { 268 283 continue; 269 270 if ( false !== stripos( $theme->get_template(), $word ) ) 284 } 285 286 if ( false !== stripos( $theme->get_template(), $word ) ) { 271 287 continue; 288 } 272 289 273 290 return false; … … 288 305 289 306 $args = array( 290 'search' => $search_string,291 'features' => $this->features,292 'paged' => $this->get_pagenum(),307 'search' => $search_string, 308 'features' => $this->features, 309 'paged' => $this->get_pagenum(), 293 310 'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1, 294 311 ); 295 312 296 if ( is_array( $extra_args ) ) 313 if ( is_array( $extra_args ) ) { 297 314 $args = array_merge( $args, $extra_args ); 315 } 298 316 299 317 printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) );
Note: See TracChangeset
for help on using the changeset viewer.