Changeset 15491 for trunk/wp-admin/includes/theme-install.php
- Timestamp:
- 08/11/2010 09:54:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/theme-install.php
r14818 r15491 89 89 } 90 90 91 add_action('install_themes_search', 'install_theme_search', 10, 1);92 /**93 * Display theme search results94 *95 * @since 2.8.096 *97 * @param string $page98 */99 function install_theme_search($page) {100 global $theme_field_defaults;101 102 $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';103 $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';104 105 $args = array();106 107 switch( $type ){108 case 'tag':109 $terms = explode(',', $term);110 $terms = array_map('trim', $terms);111 $terms = array_map('sanitize_title_with_dashes', $terms);112 $args['tag'] = $terms;113 break;114 case 'term':115 $args['search'] = $term;116 break;117 case 'author':118 $args['author'] = $term;119 break;120 }121 122 $args['page'] = $page;123 $args['fields'] = $theme_field_defaults;124 125 if ( !empty( $_POST['features'] ) ) {126 $terms = $_POST['features'];127 $terms = array_map( 'trim', $terms );128 $terms = array_map( 'sanitize_title_with_dashes', $terms );129 $args['tag'] = $terms;130 $_REQUEST['s'] = implode( ',', $terms );131 $_REQUEST['type'] = 'tag';132 }133 134 $api = themes_api('query_themes', $args);135 136 if ( is_wp_error($api) )137 wp_die($api);138 139 add_action('install_themes_table_header', 'install_theme_search_form');140 141 display_themes($api->themes, $api->info['page'], $api->info['pages']);142 }143 144 91 /** 145 92 * Display search form for searching themes. … … 153 100 <p class="install-help"><?php _e('Search for themes by keyword, author, or tag.') ?></p> 154 101 155 <form id="search-themes" method="post" action="<?php echo admin_url( 'theme-install.php?tab=search' ); ?>"> 102 <form id="search-themes" method="get" action=""> 103 <input type="hidden" name="tab" value="search" /> 156 104 <select name="type" id="typeselector"> 157 105 <option value="term" <?php selected('term', $type) ?>><?php _e('Term'); ?></option> … … 165 113 } 166 114 167 add_action('install_themes_dashboard', 'install_themes_dashboard');168 115 /** 169 116 * Display tags filter for themes. … … 223 170 <?php 224 171 } 225 226 add_action('install_themes_featured', 'install_themes_featured', 10, 1); 227 /** 228 * Display featured themes. 229 * 230 * @since 2.8.0 231 * 232 * @param string $page 233 */ 234 function install_themes_featured($page = 1) { 235 global $theme_field_defaults; 236 $args = array('browse' => 'featured', 'page' => $page, 'fields' => $theme_field_defaults); 237 $api = themes_api('query_themes', $args); 238 if ( is_wp_error($api) ) 239 wp_die($api); 240 display_themes($api->themes, $api->info['page'], $api->info['pages']); 241 } 242 243 add_action('install_themes_new', 'install_themes_new', 10, 1); 244 /** 245 * Display new themes/ 246 * 247 * @since 2.8.0 248 * 249 * @param string $page 250 */ 251 function install_themes_new($page = 1) { 252 global $theme_field_defaults; 253 $args = array('browse' => 'new', 'page' => $page, 'fields' => $theme_field_defaults); 254 $api = themes_api('query_themes', $args); 255 if ( is_wp_error($api) ) 256 wp_die($api); 257 display_themes($api->themes, $api->info['page'], $api->info['pages']); 258 } 259 260 add_action('install_themes_updated', 'install_themes_updated', 10, 1); 261 /** 262 * Display recently updated themes. 263 * 264 * @since 2.8.0 265 * 266 * @param string $page 267 */ 268 function install_themes_updated($page = 1) { 269 global $theme_field_defaults; 270 $args = array('browse' => 'updated', 'page' => $page, 'fields' => $theme_field_defaults); 271 $api = themes_api('query_themes', $args); 272 display_themes($api->themes, $api->info['page'], $api->info['pages']); 273 } 274 275 add_action('install_themes_upload', 'install_themes_upload', 10, 1); 172 add_action('install_themes_dashboard', 'install_themes_dashboard'); 173 276 174 function install_themes_upload($page = 1) { 277 175 ?> … … 286 184 <?php 287 185 } 186 add_action('install_themes_upload', 'install_themes_upload', 10, 1); 288 187 289 188 function display_theme($theme, $actions = null, $show_details = true) { … … 361 260 * 362 261 * @since 2.8.0 363 * 364 * @param array $themes List of themes. 365 * @param string $page 366 * @param int $totalpages Number of pages. 367 */ 368 function display_themes($themes, $page = 1, $totalpages = 1) { 369 $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; 370 $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; 371 ?> 372 <div class="tablenav"> 373 <div class="alignleft actions"><?php do_action('install_themes_table_header'); ?></div> 374 <?php 375 $url = esc_url($_SERVER['REQUEST_URI']); 376 if ( ! empty($term) ) 377 $url = add_query_arg('s', $term, $url); 378 if ( ! empty($type) ) 379 $url = add_query_arg('type', $type, $url); 380 381 $page_links = paginate_links( array( 382 'base' => add_query_arg('paged', '%#%', $url), 383 'format' => '', 384 'prev_text' => __('«'), 385 'next_text' => __('»'), 386 'total' => $totalpages, 387 'current' => $page 388 )); 389 390 if ( $page_links ) 391 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; 392 ?> 393 </div> 394 <br class="clear" /> 395 <?php 396 if ( empty($themes) ) { 397 _e('No themes found'); 398 return; 399 } 400 ?> 401 <table id="availablethemes" cellspacing="0" cellpadding="0"> 402 <?php 403 $rows = ceil(count($themes) / 3); 404 $table = array(); 405 $theme_keys = array_keys($themes); 406 for ( $row = 1; $row <= $rows; $row++ ) 407 for ( $col = 1; $col <= 3; $col++ ) 408 $table[$row][$col] = array_shift($theme_keys); 409 410 foreach ( $table as $row => $cols ) { 411 ?> 412 <tr> 413 <?php 414 415 foreach ( $cols as $col => $theme_index ) { 416 $class = array('available-theme'); 417 if ( $row == 1 ) $class[] = 'top'; 418 if ( $col == 1 ) $class[] = 'left'; 419 if ( $row == $rows ) $class[] = 'bottom'; 420 if ( $col == 3 ) $class[] = 'right'; 421 ?> 422 <td class="<?php echo join(' ', $class); ?>"><?php 423 if ( isset($themes[$theme_index]) ) 424 display_theme($themes[$theme_index]); 425 ?></td> 426 <?php } // end foreach $cols ?> 427 </tr> 428 <?php } // end foreach $table ?> 429 </table> 430 431 <div class="tablenav"><?php if ( $page_links ) 432 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?> <br 433 class="clear" /> 434 </div> 435 436 <?php 437 } 438 439 add_action('install_themes_pre_theme-information', 'install_theme_information'); 262 */ 263 function display_themes() { 264 global $table; 265 266 $table->display(); 267 } 268 add_action('install_themes_search', 'display_themes'); 269 add_action('install_themes_featured', 'display_themes'); 270 add_action('install_themes_new', 'display_themes'); 271 add_action('install_themes_updated', 'display_themes'); 440 272 441 273 /** … … 547 379 exit; 548 380 } 381 add_action('install_themes_pre_theme-information', 'install_theme_information'); 382
Note: See TracChangeset
for help on using the changeset viewer.