Changeset 8600 for trunk/wp-admin/includes/plugin-install.php
- Timestamp:
- 08/09/2008 05:36:14 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin-install.php
r8550 r8600 9 9 $args = apply_filters('plugins_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter. 10 10 $res = apply_filters('plugins_api', false, $action, $args); //NOTE: Allows a plugin to completely override the builtin WordPress.org API. 11 11 12 12 if ( ! $res ) { 13 13 $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array(), array(), array('action' => $action, 'request' => serialize($args)) ); … … 68 68 } 69 69 ?> 70 70 71 71 <p><?php _e('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> via this page.') ?></p> 72 72 73 73 <h4><?php _e('Search') ?></h4> 74 74 <?php install_search_form() ?> … … 77 77 <?php _e('<strong>Tag:</strong> Searches for plugins tagged as such') ?><br /> 78 78 <?php _e('<strong>Author:</strong> Searches for plugins created by the Author, or which the Author contributed to.') ?></p> 79 79 80 80 <h4><?php _e('Popular tags') ?></h4> 81 81 <p><?php _e('You may also search based on these popular tags, These are tags which are most popular on WordPress.org') ?></p> … … 143 143 function display_plugins_table($plugins, $page = 1, $totalpages = 1){ 144 144 global $tab; 145 145 146 146 $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : ''; 147 147 $term = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; … … 167 167 'current' => $page 168 168 )); 169 169 170 170 if ( $page_links ) 171 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; 171 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; 172 172 ?> 173 173 </div> … … 187 187 if( empty($plugins) ) 188 188 echo '<tr><td colspan="5">', __('No plugins match your request.'), '</td></tr>'; 189 189 190 190 foreach( (array) $plugins as $plugin ){ 191 191 if ( is_object($plugin) ) … … 195 195 $description = wp_kses($plugin['description'], $plugins_allowedtags); 196 196 $version = wp_kses($plugin['version'], $plugins_allowedtags); 197 197 198 198 $name = strip_tags($title . ' ' . $version); 199 199 200 200 $author = $plugin['author']; 201 201 if( ! empty($plugin['author']) ) … … 203 203 204 204 $author = wp_kses($author, $plugins_allowedtags); 205 205 206 206 if( isset($plugin['homepage']) ) 207 207 $title = '<a target="_blank" href="' . $plugin['homepage'] . '">' . $title . '</a>'; 208 208 209 209 $action_links = array(); 210 210 $action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . 211 211 '&TB_iframe=true&width=600&height=800') . '" class="thickbox onclick" title="' . 212 212 attribute_escape($name) . '">' . __('Install') . '</a>'; 213 213 214 214 $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin); 215 215 ?> … … 279 279 function install_plugin_information() { 280 280 global $tab; 281 281 282 282 $api = plugins_api('plugin_information', array('slug' => $_REQUEST['plugin'])); 283 283 … … 285 285 if( empty($section) || ! isset($api->sections[ $section ]) ) 286 286 $section = array_shift( $section_titles = array_keys((array)$api->sections) ); 287 287 288 288 install_iframe_header(); 289 289 echo "<div id='$tab-header'>\n"; 290 290 echo "<ul id='sidemenu'>\n"; 291 291 foreach ( (array)$api->sections as $section_name => $content ) { 292 292 293 293 $title = $section_name; 294 294 $title[0] = strtoupper($title[0]); //Capitalize first character. … … 303 303 echo "</ul>\n"; 304 304 echo "</div>\n"; 305 305 306 306 ?> 307 307 <div class="alignright fyi"> … … 350 350 <li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li> 351 351 <?php endif; if ( ! empty($api->last_updated) ) : ?> 352 <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php 352 <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php 353 353 printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li> 354 354 <?php endif; if ( ! empty($api->requires) ) : ?> … … 381 381 $title[0] = strtoupper($title[0]); 382 382 $title = str_replace('_', ' ', $title); 383 383 384 384 $content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/'); 385 385 $content = links_add_target($content, '_blank'); 386 386 387 387 $san_title = attribute_escape(sanitize_title_with_dashes($title)); 388 388 389 389 $display = ( $section_name == $section ) ? 'block' : 'none'; 390 390 391 391 echo "\t<div id='section-{$san_title}' style='display: {$display};'>\n"; 392 392 echo "\t\t<h2 class='long-header'>$title</h2>"; … … 407 407 408 408 install_iframe_header(); 409 409 410 410 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 411 411 412 412 echo '<div class="wrap">'; 413 413 echo '<h2>', sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ), '</h2>'; … … 420 420 function do_plugin_install($download_url = '', $plugin_information = NULL) { 421 421 global $wp_filesystem; 422 422 423 423 if ( empty($download_url) ) { 424 424 show_message( __('No plugin Specified') ); 425 425 return; 426 426 } 427 427 428 428 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : ''; 429 429 430 430 $url = 'plugin-install.php?tab=install'; 431 431 $url = add_query_arg(array('plugin' => $plugin, 'plugin_name' => $_REQUEST['plugin_name'], 'download_url' => $_REQUEST['download_url']), $url); … … 447 447 448 448 $result = wp_install_plugin( $download_url, 'show_message' ); 449 449 450 450 if ( is_wp_error($result) ) { 451 451 show_message($result); … … 490 490 if( empty($content_dir) ) 491 491 return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); 492 492 493 493 $plugins_dir = trailingslashit( $plugins_dir ); 494 494 $content_dir = trailingslashit( $content_dir ); … … 513 513 // Unzip package to working directory 514 514 $result = unzip_file($download_file, $working_dir); 515 515 516 516 // Once extracted, delete the package 517 517 unlink($download_file); 518 518 519 519 if ( is_wp_error($result) ) { 520 520 $wp_filesystem->delete($working_dir, true); 521 521 return $result; 522 522 } 523 523 524 524 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 525 525 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 526 526 527 527 if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) { 528 528 $wp_filesystem->delete($working_dir, true); 529 529 return new WP_Error('install_folder_exists', __('Folder allready exists.'), $filelist[0] ); 530 530 } 531 531 532 532 apply_filters('install_feedback', __('Installing the plugin')); 533 533 // Copy new version of plugin into place. … … 543 543 // Remove working directory 544 544 $wp_filesystem->delete($working_dir, true); 545 545 546 546 if( empty($filelist) ) 547 547 return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. 548 548 549 549 $folder = $filelist[0]; 550 550 $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
Note: See TracChangeset
for help on using the changeset viewer.