Changeset 15491 for trunk/wp-admin/includes/plugin-install.php
- Timestamp:
- 08/11/2010 09:54:51 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/plugin-install.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin-install.php
r15287 r15491 79 79 return $tags; 80 80 } 81 add_action('install_plugins_search', 'install_search', 10, 1); 82 83 /** 84 * Display search results and display as tag cloud. 85 * 86 * @since 2.7.0 87 * 88 * @param string $page 89 */ 90 function install_search($page) { 91 $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; 92 $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; 93 94 $args = array(); 95 96 switch( $type ){ 97 case 'tag': 98 $args['tag'] = sanitize_title_with_dashes($term); 99 break; 100 case 'term': 101 $args['search'] = $term; 102 break; 103 case 'author': 104 $args['author'] = $term; 105 break; 106 } 107 108 $args['page'] = $page; 109 110 $api = plugins_api('query_plugins', $args); 111 112 if ( is_wp_error($api) ) 113 wp_die($api); 114 115 add_action('install_plugins_table_header', 'install_search_form'); 116 117 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 118 119 return; 120 } 121 122 add_action('install_plugins_dashboard', 'install_dashboard'); 81 123 82 function install_dashboard() { 124 83 ?> … … 151 110 echo '</p><br class="clear" />'; 152 111 } 112 add_action('install_plugins_dashboard', 'install_dashboard'); 153 113 154 114 /** … … 161 121 $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; 162 122 163 ?><form id="search-plugins" method="post" action="<?php echo admin_url('plugin-install.php?tab=search'); ?>"> 123 ?><form id="search-plugins" method="get" action=""> 124 <input type="hidden" name="tab" value="search" /> 164 125 <select name="type" id="typeselector"> 165 126 <option value="term"<?php selected('term', $type) ?>><?php _e('Term'); ?></option> … … 169 130 <input type="text" name="s" value="<?php echo esc_attr($term) ?>" /> 170 131 <label class="screen-reader-text" for="plugin-search-input"><?php _e('Search Plugins'); ?></label> 171 <input type="submit" id="plugin-search-input" name="search"value="<?php esc_attr_e('Search Plugins'); ?>" class="button" />132 <input type="submit" id="plugin-search-input" value="<?php esc_attr_e('Search Plugins'); ?>" class="button" /> 172 133 </form><?php 173 134 } 174 135 175 add_action('install_plugins_featured', 'install_featured', 10, 1);176 /**177 * Display featured plugins.178 *179 * @since 2.7.0180 *181 * @param string $page182 */183 function install_featured($page = 1) {184 $args = array('browse' => 'featured', 'page' => $page);185 $api = plugins_api('query_plugins', $args);186 if ( is_wp_error($api) )187 wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>');188 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);189 }190 191 add_action('install_plugins_popular', 'install_popular', 10, 1);192 /**193 * Display popular plugins.194 *195 * @since 2.7.0196 *197 * @param string $page198 */199 function install_popular($page = 1) {200 $args = array('browse' => 'popular', 'page' => $page);201 $api = plugins_api('query_plugins', $args);202 if ( is_wp_error($api) )203 wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>');204 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);205 }206 207 add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);208 136 /** 209 137 * Upload from zip … … 224 152 <?php 225 153 } 226 227 add_action('install_plugins_new', 'install_new', 10, 1); 228 /** 229 * Display new plugins. 230 * 231 * @since 2.7.0 232 * 233 * @param string $page 234 */ 235 function install_new($page = 1) { 236 $args = array('browse' => 'new', 'page' => $page); 237 $api = plugins_api('query_plugins', $args); 238 if ( is_wp_error($api) ) 239 wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>'); 240 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 241 } 242 add_action('install_plugins_updated', 'install_updated', 10, 1); 243 244 245 /** 246 * Display recently updated plugins. 247 * 248 * @since 2.7.0 249 * 250 * @param string $page 251 */ 252 function install_updated($page = 1) { 253 $args = array('browse' => 'updated', 'page' => $page); 254 $api = plugins_api('query_plugins', $args); 255 if ( is_wp_error($api) ) 256 wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>'); 257 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 258 } 154 add_action('install_plugins_upload', 'install_plugins_upload', 10, 1); 259 155 260 156 /** … … 264 160 * 265 161 * @param array $plugins List of plugins. 266 * @param string $page 267 * @param int $totalpages Number of pages. 268 */ 269 function display_plugins_table($plugins, $page = 1, $totalpages = 1){ 270 $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; 271 $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; 272 273 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array(), 'target' => array()), 274 'abbr' => array('title' => array()),'acronym' => array('title' => array()), 275 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(), 276 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()); 277 278 ?> 279 <div class="tablenav"> 280 <div class="alignleft actions"> 281 <?php do_action('install_plugins_table_header'); ?> 282 </div> 283 <?php 284 $url = esc_url($_SERVER['REQUEST_URI']); 285 if ( ! empty($term) ) 286 $url = add_query_arg('s', $term, $url); 287 if ( ! empty($type) ) 288 $url = add_query_arg('type', $type, $url); 289 290 $page_links = paginate_links( array( 291 'base' => add_query_arg('paged', '%#%', $url), 292 'format' => '', 293 'prev_text' => __('«'), 294 'next_text' => __('»'), 295 'total' => $totalpages, 296 'current' => $page 297 )); 298 299 if ( $page_links ) 300 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; 301 ?> 302 <br class="clear" /> 303 </div> 304 <table class="widefat" id="install-plugins" cellspacing="0"> 305 <thead> 306 <tr> 307 <th scope="col" class="name"><?php _e('Name'); ?></th> 308 <th scope="col" class="num"><?php _e('Version'); ?></th> 309 <th scope="col" class="num"><?php _e('Rating'); ?></th> 310 <th scope="col" class="desc"><?php _e('Description'); ?></th> 311 </tr> 312 </thead> 313 314 <tfoot> 315 <tr> 316 <th scope="col" class="name"><?php _e('Name'); ?></th> 317 <th scope="col" class="num"><?php _e('Version'); ?></th> 318 <th scope="col" class="num"><?php _e('Rating'); ?></th> 319 <th scope="col" class="desc"><?php _e('Description'); ?></th> 320 </tr> 321 </tfoot> 322 323 <tbody class="plugins"> 324 <?php 325 if ( empty($plugins) ) 326 echo '<tr><td colspan="5">', __('No plugins match your request.'), '</td></tr>'; 327 328 foreach ( (array) $plugins as $plugin ){ 329 if ( is_object($plugin) ) 330 $plugin = (array) $plugin; 331 332 $title = wp_kses($plugin['name'], $plugins_allowedtags); 333 //Limit description to 400char, and remove any HTML. 334 $description = strip_tags($plugin['description']); 335 if ( strlen($description) > 400 ) 336 $description = mb_substr($description, 0, 400) . '…'; 337 //remove any trailing entities 338 $description = preg_replace('/&[^;\s]{0,6}$/', '', $description); 339 //strip leading/trailing & multiple consecutive lines 340 $description = trim($description); 341 $description = preg_replace("|(\r?\n)+|", "\n", $description); 342 //\n => <br> 343 $description = nl2br($description); 344 $version = wp_kses($plugin['version'], $plugins_allowedtags); 345 346 $name = strip_tags($title . ' ' . $version); 347 348 $author = $plugin['author']; 349 if ( ! empty($plugin['author']) ) 350 $author = ' <cite>' . sprintf( __('By %s'), $author ) . '.</cite>'; 351 352 $author = wp_kses($author, $plugins_allowedtags); 353 354 $action_links = array(); 355 $action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . 356 '&TB_iframe=true&width=600&height=550') . '" class="thickbox" title="' . 357 esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '">' . __('Details') . '</a>'; 358 359 if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) { 360 $status = install_plugin_install_status($plugin); 361 362 switch ( $status['status'] ) { 363 case 'install': 364 if ( $status['url'] ) 365 $action_links[] = '<a class="install-now" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __('Install Now') . '</a>'; 366 break; 367 case 'update_available': 368 if ( $status['url'] ) 369 $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . sprintf( __('Update Now'), $status['version'] ) . '</a>'; 370 break; 371 case 'latest_installed': 372 case 'newer_installed': 373 $action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . __('Installed') . '</span>'; 374 break; 375 } 376 } 377 378 $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); 379 ?> 380 <tr> 381 <td class="name"><strong><?php echo $title; ?></strong> 382 <div class="action-links"><?php if ( !empty($action_links) ) echo implode(' | ', $action_links); ?></div> 383 </td> 384 <td class="vers"><?php echo $version; ?></td> 385 <td class="vers"> 386 <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings']), number_format_i18n($plugin['num_ratings'])) ?>"> 387 <div class="star star-rating" style="width: <?php echo esc_attr($plugin['rating']) ?>px"></div> 388 <div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div> 389 <div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div> 390 <div class="star star3"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('3 stars') ?>" /></div> 391 <div class="star star2"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('2 stars') ?>" /></div> 392 <div class="star star1"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('1 star') ?>" /></div> 393 </div> 394 </td> 395 <td class="desc"><?php echo $description, $author; ?></td> 396 </tr> 397 <?php 398 } 399 ?> 400 </tbody> 401 </table> 402 403 <div class="tablenav"> 404 <?php if ( $page_links ) 405 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?> 406 <br class="clear" /> 407 </div> 408 409 <?php 410 } 411 412 add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); 162 * @param int $total_plugins Number of plugins. 163 */ 164 function display_plugins_table() { 165 global $table; 166 167 $table->display(); 168 } 169 add_action('install_plugins_search', 'display_plugins_table'); 170 add_action('install_plugins_featured', 'display_plugins_table'); 171 add_action('install_plugins_popular', 'display_plugins_table'); 172 add_action('install_plugins_new', 'display_plugins_table'); 173 add_action('install_plugins_updated', 'display_plugins_table'); 413 174 414 175 /** … … 609 370 exit; 610 371 } 372 add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); 373
Note: See TracChangeset
for help on using the changeset viewer.