Ticket #6015: 6015.patch
File 6015.patch, 28.8 KB (added by , 16 years ago) |
---|
-
wp-admin/css/plugin-install.css
125 125 #plugin-information #section-screenshots li img { 126 126 vertical-align: text-top; 127 127 } 128 128 129 #plugin-information #section-screenshots li p { 129 130 font-style: italic; 130 131 padding-left: 20px; 131 132 padding-bottom: 2em; 133 } 134 135 #plugin-information .updated { 136 margin-right: 215px; 132 137 } 138 No newline at end of file -
wp-admin/includes/plugin-install.php
39 39 $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) ); 40 40 $res = unserialize($request['body']); 41 41 if ( ! $res ) 42 wp_die($request['body']);42 $res = new WP_Error('plugins_api_failed', __('An unknown error occured'), $request['body']); 43 43 } 44 44 45 45 return apply_filters('plugins_api_result', $res, $action, $args); … … 69 69 70 70 return $tags; 71 71 } 72 73 72 add_action('install_plugins_search', 'install_search', 10, 1); 74 73 75 74 /** … … 83 82 $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : ''; 84 83 $term = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 85 84 86 if( ! empty($term) ){ 87 $args = array(); 85 $args = array(); 88 86 89 90 91 92 93 94 95 96 97 98 99 87 switch( $type ){ 88 case 'tag': 89 $args['tag'] = sanitize_title_with_dashes($term); 90 break; 91 case 'term': 92 $args['search'] = $term; 93 break; 94 case 'author': 95 $args['author'] = $term; 96 break; 97 } 100 98 101 99 $args['page'] = $page; 102 100 103 101 $api = plugins_api('query_plugins', $args); 104 102 105 103 add_action('install_plugins_table_header', 'install_search_form'); 106 104 107 105 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 108 106 109 return; 110 } 107 return; 108 } 109 110 add_action('install_plugins_dashboard', 'install_dashboard'); 111 function install_dashboard() { 111 112 ?> 113 <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> or upload a plugin in .zip format via this page.') ?></p> 112 114 113 <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>114 115 115 <h4><?php _e('Search') ?></h4> 116 <?php install_search_form() ?> 116 <?php install_search_form('<a href="' . add_query_arg('show-help', !isset($_REQUEST['show-help'])) .'" onclick="jQuery(\'#search-help\').toggle(); return false;">' . __('[need help?]') . '</a>') ?> 117 <div id="search-help" style="display: <?php echo isset($_REQUEST['show-help']) ? 'block' : 'none'; ?>;"> 117 118 <p> <?php _e('You may search based on 3 criteria:') ?><br /> 118 119 <?php _e('<strong>Term:</strong> Searches plugins names and descriptions for the specified term') ?><br /> 119 120 <?php _e('<strong>Tag:</strong> Searches for plugins tagged as such') ?><br /> 120 121 <?php _e('<strong>Author:</strong> Searches for plugins created by the Author, or which the Author contributed to.') ?></p> 121 122 </div> 123 124 <h4><?php _e('Install a plugin in .zip format') ?></h4> 125 <p><?php _e('If you have a plugin in a .zip format, You may install it by uploading it here.') ?></p> 126 <form method="post" enctype="multipart/form-data" action="<?php echo admin_url('plugin-install.php?tab=upload') ?>"> 127 <?php wp_nonce_field( 'plugin-upload') ?> 128 <input type="file" name="pluginzip" /> 129 <input type="submit" value="<?php _e('Install Now') ?>" /> 130 </form> 131 122 132 <h4><?php _e('Popular tags') ?></h4> 123 <p><?php _e('You may also search based on these popular tags, These are tags which are most popular on WordPress.org') ?></p>133 <p><?php _e('You may also browse based on the most popular tags on wordpress.org') ?></p> 124 134 <?php 125 135 126 136 $api_tags = install_popular_tags(); … … 131 141 $tags[ $tag['name'] ] = (object) array( 132 142 'link' => clean_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), 133 143 'name' => $tag['name'], 144 'id' => sanitize_title_with_dashes($tag['name']), 134 145 'count' => $tag['count'] ); 135 146 echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) ); 136 147 } 137 148 138 /** 139 * Display search form for searching plugins. 140 * 141 * @since 2.7.0 142 */ 143 function install_search_form(){ 149 function install_search_form($after_submit = '') { 144 150 $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : ''; 145 151 $term = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 146 152 147 153 ?><form id="search-plugins" method="post" action="<?php echo admin_url('plugin-install.php?tab=search') ?>"> 148 154 <select name="type" id="typeselector"> 149 155 <option value="term"<?php selected('term', $type) ?>><?php _e('Term') ?></option> 156 <option value="author"<?php selected('author', $type) ?>><?php _e('Author') ?></option> 150 157 <option value="tag"<?php selected('tag', $type) ?>><?php _e('Tag') ?></option> 151 <option value="author"<?php selected('author', $type) ?>><?php _e('Author') ?></option>152 158 </select> 153 159 <input type="text" name="s" id="search-field" value="<?php echo attribute_escape($term) ?>" /> 154 160 <input type="submit" name="search" value="<?php echo attribute_escape(__('Search')) ?>" class="button" /> 161 <?php echo $after_submit ?> 155 162 </form><?php 156 163 } 157 164 158 165 add_action('install_plugins_featured', 'install_featured', 10, 1); 159 160 166 /** 161 167 * Display featured plugins. 162 168 * … … 164 170 * 165 171 * @param string $page 166 172 */ 167 function install_featured($page ){173 function install_featured($page = 1) { 168 174 $args = array('browse' => 'featured', 'page' => $page); 169 175 $api = plugins_api('query_plugins', $args); 170 176 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 171 177 } 178 172 179 add_action('install_plugins_popular', 'install_popular', 10, 1); 173 174 180 /** 175 181 * Display popular plugins. 176 182 * … … 178 184 * 179 185 * @param string $page 180 186 */ 181 function install_popular($page ){187 function install_popular($page = 1) { 182 188 $args = array('browse' => 'popular', 'page' => $page); 183 189 $api = plugins_api('query_plugins', $args); 184 190 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 185 191 } 192 186 193 add_action('install_plugins_new', 'install_new', 10, 1); 187 188 194 /** 189 195 * Display new plugins. 190 196 * … … 192 198 * 193 199 * @param string $page 194 200 */ 195 function install_new($page ){201 function install_new($page = 1) { 196 202 $args = array('browse' => 'new', 'page' => $page); 197 203 $api = plugins_api('query_plugins', $args); 198 204 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 199 205 } 200 206 add_action('install_plugins_updated', 'install_updated', 10, 1); 201 207 208 202 209 /** 203 210 * Display recently updated plugins. 204 211 * … … 206 213 * 207 214 * @param string $page 208 215 */ 209 function install_updated($page ){216 function install_updated($page = 1) { 210 217 $args = array('browse' => 'updated', 'page' => $page); 211 218 $api = plugins_api('query_plugins', $args); 212 219 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 213 220 } 214 add_action('install_plugins_upload', 'install_upload_custom', 10, 1);215 221 216 222 /** 217 * Display upload plugin form for adding plugins by uploading them manually.218 *219 * @since 2.7.0220 *221 * @param string $page222 */223 function install_upload_custom($page){224 //$args = array('browse' => 'updated', 'page' => $page);225 //$api = plugins_api('query_plugins', $args);226 //display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);227 echo '<h1>Not Implemented</h1> <p>Will utilise SwfUpload(if available) & unzip .zip plugin packages</p>';228 }229 230 /**231 223 * Display plugin content based on plugin list. 232 224 * 233 225 * @since 2.7.0 … … 250 242 <?php do_action('install_plugins_table_header'); ?> 251 243 </div> 252 244 <?php 253 $url = $_SERVER['REQUEST_URI'];245 $url = clean_url($_SERVER['REQUEST_URI']); 254 246 if ( ! empty($term) ) 255 247 $url = add_query_arg('s', $term, $url); 256 248 if ( ! empty($type) ) … … 266 258 if ( $page_links ) 267 259 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; 268 260 ?> 261 <br class="clear" /> 269 262 </div> 270 <br class="clear" />271 263 <table class="widefat" id="install-plugins"> 272 264 <thead> 273 265 <tr> … … 311 303 $author = wp_kses($author, $plugins_allowedtags); 312 304 313 305 if( isset($plugin['homepage']) ) 314 $title = '<a target="_blank" href="' . $plugin['homepage']. '">' . $title . '</a>';306 $title = '<a target="_blank" href="' . attribute_escape($plugin['homepage']) . '">' . $title . '</a>'; 315 307 316 308 $action_links = array(); 317 309 $action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . … … 345 337 <div class="tablenav"> 346 338 <?php if ( $page_links ) 347 339 echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?> 340 <br class="clear" /> 348 341 </div> 349 <br class="clear" />350 342 351 343 <?php 352 344 } 353 345 354 /**355 * Display iframe header.356 *357 * @since 2.7.0358 *359 * @param string $title Title for iframe.360 */361 function install_iframe_header($title = '') {362 if( empty($title) )363 $title = __('Plugin Install — WordPress');364 365 register_shutdown_function('install_iframe_footer'); //Do footer after content, Allows us to simply die or return at any point as may happen with error handlers366 367 ?>368 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">369 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>370 <head>371 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />372 <title><?php bloginfo('name') ?> › <?php echo $title ?></title>373 <?php374 wp_enqueue_style( 'global' );375 wp_enqueue_style( 'wp-admin' );376 wp_enqueue_style( 'colors' );377 ?>378 <script type="text/javascript">379 //<![CDATA[380 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}381 //]]>382 </script>383 <?php384 do_action('admin_print_styles');385 do_action('admin_print_scripts');386 do_action('admin_head');387 ?>388 </head>389 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>390 <?php391 }392 393 /**394 * Display iframe footer.395 *396 * @since 2.7.0397 */398 function install_iframe_footer() {399 echo '400 </body>401 </html>';402 }403 404 346 add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); 405 347 406 348 /** … … 417 359 if( empty($section) || ! isset($api->sections[ $section ]) ) 418 360 $section = array_shift( $section_titles = array_keys((array)$api->sections) ); 419 361 420 i nstall_iframe_header();362 iframe_header( __('Plugin Install') ); 421 363 echo "<div id='$tab-header'>\n"; 422 364 echo "<ul id='sidemenu'>\n"; 423 365 foreach ( (array)$api->sections as $section_name => $content ) { 424 366 425 367 $title = $section_name; 426 $title[0] = strtoupper($title[0]); //Capitalize first character. 427 $title = str_replace('_', ' ', $title); 368 $title = ucwords(str_replace('_', ' ', $title)); 428 369 429 370 $class = ( $section_name == $section ) ? ' class="current"' : ''; 430 371 $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) ); … … 434 375 } 435 376 echo "</ul>\n"; 436 377 echo "</div>\n"; 437 438 378 ?> 439 379 <div class="alignright fyi"> 440 380 <?php if ( ! empty($api->download_link) ) : ?> … … 458 398 default: 459 399 case 'install': 460 400 if ( current_user_can('install_plugins') ) : 461 ?><a href="<?php echo wp_nonce_url(admin_url('plugin-install.php?tab=install&plugin=' . $api->slug), 'install-plugin_' . $api->slug) ?>" ><?php _e('Install Now') ?></a><?php401 ?><a href="<?php echo wp_nonce_url(admin_url('plugin-install.php?tab=install&plugin=' . $api->slug), 'install-plugin_' . $api->slug) ?>" target="_parent"><?php _e('Install Now') ?></a><?php 462 402 endif; 463 403 break; 464 404 case 'update_available': 465 405 if ( current_user_can('update_plugins') ) : 466 ?><a href="<?php echo wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file) ?>" ><?php _e('Install Update Now') ?></a><?php406 ?><a href="<?php echo wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file) ?>" target="_parent"><?php _e('Install Update Now') ?></a><?php 467 407 endif; 468 408 break; 469 409 case 'latest_installed': … … 507 447 <small><?php printf(__('(based on %d ratings)'), $api->num_ratings) ?></small> 508 448 </div> 509 449 <div id="section-holder" class="wrap"> 510 <?php 450 <?php 451 if ( version_compare($GLOBALS['wp_version'], $api->tested, '>') ) 452 echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>'; 453 else if ( version_compare($GLOBALS['wp_version'], $api->requires, '<') ) 454 echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has not been marked as being <strong>not compatible</strong> with your version of WordPress.') . '</p></div>'; 511 455 foreach ( (array)$api->sections as $section_name => $content ) { 512 456 $title = $section_name; 513 457 $title[0] = strtoupper($title[0]); … … 520 464 521 465 $display = ( $section_name == $section ) ? 'block' : 'none'; 522 466 523 echo "\t<div id='section-{$san_title}' style='display: {$display};'>\n";467 echo "\t<div id='section-{$san_title}' class='section' style='display: {$display};'>\n"; 524 468 echo "\t\t<h2 class='long-header'>$title</h2>"; 525 469 echo $content; 526 470 echo "\t</div>\n"; 527 471 } 528 472 echo "</div>\n"; 529 473 474 iframe_footer(); 530 475 exit; 531 476 } 532 477 533 add_action('install_plugins_pre_install', 'install_plugin');534 478 479 add_action('install_plugins_upload', 'upload_plugin'); 480 function upload_plugin() { 481 482 if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) 483 wp_die($uploads['error']); 484 485 if ( !empty($_FILES) ) 486 $filename = $_FILES['pluginzip']['name']; 487 else if ( isset($_GET['package']) ) 488 $filename = $_GET['package']; 489 490 check_admin_referer('plugin-upload'); 491 492 echo '<div class="wrap">'; 493 echo '<h2>', sprintf( __('Installing Plugin from file: %s'), basename($filename) ), '</h2>'; 494 495 //Handle a newly uploaded file, Else assume it was 496 if ( !empty($_FILES) ) { 497 $filename = wp_unique_filename( $uploads['basedir'], $filename ); 498 $local_file = $uploads['basedir'] . '/' . $filename; 499 500 // Move the file to the uploads dir 501 if ( false === @ move_uploaded_file( $_FILES['pluginzip']['tmp_name'], $local_file) ) 502 wp_die( sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'])); 503 } else { 504 $local_file = $uploads['basedir'] . '/' . $filename; 505 } 506 507 do_plugin_install_local_package($local_file, $filename); 508 echo '</div>'; 509 } 510 511 add_action('install_plugins_install', 'install_plugin'); 512 535 513 /** 536 514 * Display plugin link and execute install. 537 515 * … … 542 520 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : ''; 543 521 544 522 check_admin_referer('install-plugin_' . $plugin); 545 546 install_iframe_header();547 548 523 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 549 524 550 525 echo '<div class="wrap">'; … … 553 528 do_plugin_install($api->download_link, $api); 554 529 echo '</div>'; 555 530 556 exit;557 531 } 558 532 559 533 /** … … 561 535 * 562 536 * @since 2.7.0 563 537 * 564 * @param string $download_url Optional.Download URL.538 * @param string $download_url Download URL. 565 539 * @param object $plugin_information Optional. Plugin information 566 540 */ 567 function do_plugin_install($download_url = '', $plugin_information = null) {541 function do_plugin_install($download_url, $plugin_information = null) { 568 542 global $wp_filesystem; 569 543 570 544 if ( empty($download_url) ) { … … 602 576 $plugin_file = $result; 603 577 604 578 $install_actions = apply_filters('install_plugin_complete_actions', array( 605 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>', 606 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . __('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>', 607 'dismiss_dialog' => '<a href="' . admin_url('plugin-installer.php') . '" onclick="window.parent.tb_remove(); return false;" title="' . __('Dismiss Dialog') . '" target="_parent">' . __('Dismiss Dialog') . '</a>' 579 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . attribute_escape(__('Activate this plugin')) . '" target="_parent">' . __('Activate Plugin') . '</a>', 580 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . attribute_escape(__('Goto plugins page')) . '" target="_parent">' . __('Return to Plugins page') . '</a>' 608 581 ), $plugin_information, $plugin_file); 582 if ( ! empty($install_actions) ) 583 show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions)); 584 } 585 } 609 586 610 echo '<p><strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions) . '</p>'; 587 /** 588 * Install a plugin from a local file. 589 * 590 * @since 2.7.0 591 * 592 * @param string $package Local Plugin zip 593 * @param string $filename Optional. Original filename 594 * @param object $plugin_information Optional. Plugin information 595 */ 596 function do_plugin_install_local_package($package, $filename = '') { 597 global $wp_filesystem; 598 599 if ( empty($package) ) { 600 show_message( __('No plugin Specified') ); 601 return; 611 602 } 603 604 if ( empty($filename) ) 605 $filename = basename($package); 606 607 $url = 'plugin-install.php?tab=upload'; 608 $url = add_query_arg(array('package' => $filename), $url); 609 610 $url = wp_nonce_url($url, 'plugin-upload'); 611 if ( false === ($credentials = request_filesystem_credentials($url)) ) 612 return; 613 614 if ( ! WP_Filesystem($credentials) ) { 615 request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again 616 return; 617 } 618 619 if ( $wp_filesystem->errors->get_error_code() ) { 620 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) 621 show_message($message); 622 return; 623 } 624 625 $result = wp_install_plugin_local_package( $package, 'show_message' ); 626 627 if ( is_wp_error($result) ) { 628 show_message($result); 629 show_message( __('Installation Failed') ); 630 } else { 631 show_message( __('Successfully installed the plugin.') ); 632 $plugin_file = $result; 633 634 $install_actions = apply_filters('install_plugin_complete_actions', array( 635 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>', 636 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . __('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>' 637 ), $plugin_information, $plugin_file); 638 if ( ! empty($install_actions) ) 639 show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions)); 640 } 612 641 } 613 642 614 643 /** … … 670 699 $result = unzip_file($download_file, $working_dir); 671 700 672 701 // Once extracted, delete the package 673 unlink($download_file);702 @unlink($download_file); 674 703 675 704 if ( is_wp_error($result) ) { 676 705 $wp_filesystem->delete($working_dir, true); … … 710 739 return $folder . '/' . $pluginfiles[0]; 711 740 } 712 741 742 /** 743 * Install plugin from local package 744 * 745 * @since 2.7.0 746 * 747 * @param string $package 748 * @param string $feedback Optional. 749 * @return mixed. 750 */ 751 function wp_install_plugin_local_package($package, $feedback = '') { 752 global $wp_filesystem; 713 753 714 ?> 715 No newline at end of file 754 if ( !empty($feedback) ) 755 add_filter('install_feedback', $feedback); 756 757 // Is a filesystem accessor setup? 758 if ( ! $wp_filesystem || ! is_object($wp_filesystem) ) 759 WP_Filesystem(); 760 761 if ( ! is_object($wp_filesystem) ) 762 return new WP_Error('fs_unavailable', __('Could not access filesystem.')); 763 764 if ( $wp_filesystem->errors->get_error_code() ) 765 return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); 766 767 //Get the base plugin folder 768 $plugins_dir = $wp_filesystem->wp_plugins_dir(); 769 if ( empty($plugins_dir) ) 770 return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.')); 771 772 //And the same for the Content directory. 773 $content_dir = $wp_filesystem->wp_content_dir(); 774 if( empty($content_dir) ) 775 return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); 776 777 $plugins_dir = trailingslashit( $plugins_dir ); 778 $content_dir = trailingslashit( $content_dir ); 779 780 if ( empty($package) ) 781 return new WP_Error('no_package', __('Install package not available.')); 782 783 if ( is_wp_error($download_file) ) 784 return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); 785 786 $working_dir = $content_dir . 'upgrade/' . basename($package, '.zip'); 787 788 // Clean up working directory 789 if ( $wp_filesystem->is_dir($working_dir) ) 790 $wp_filesystem->delete($working_dir, true); 791 792 apply_filters('install_feedback', __('Unpacking the plugin package')); 793 // Unzip package to working directory 794 $result = unzip_file($package, $working_dir); 795 796 // Once extracted, delete the package 797 unlink($package); 798 799 if ( is_wp_error($result) ) { 800 $wp_filesystem->delete($working_dir, true); 801 return $result; 802 } 803 804 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 805 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 806 807 if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) { 808 $wp_filesystem->delete($working_dir, true); 809 return new WP_Error('install_folder_exists', __('Folder allready exists.'), $filelist[0] ); 810 } 811 812 apply_filters('install_feedback', __('Installing the plugin')); 813 // Copy new version of plugin into place. 814 $result = copy_dir($working_dir, $plugins_dir); 815 if ( is_wp_error($result) ) { 816 $wp_filesystem->delete($working_dir, true); 817 return $result; 818 } 819 820 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 821 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 822 823 // Remove working directory 824 $wp_filesystem->delete($working_dir, true); 825 826 if( empty($filelist) ) 827 return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. 828 829 $folder = $filelist[0]; 830 $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash 831 $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list 832 833 //Return the plugin files name. 834 return $folder . '/' . $pluginfiles[0]; 835 } 836 837 838 839 ?> -
wp-admin/includes/template.php
3048 3048 * 3049 3049 */ 3050 3050 function _admin_search_query() { 3051 echo ( isset($_GET['s'])) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';3051 echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : ''; 3052 3052 } 3053 3053 3054 /** 3055 * Generic Iframe header for use with Thickbox 3056 * 3057 * @since 2.7.0 3058 * @param string $title Title of the Iframe page. 3059 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued). 3060 * 3061 */ 3062 function iframe_header( $title = '', $limit_styles = false) { 3063 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3064 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 3065 <head> 3066 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 3067 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title> 3068 <?php 3069 wp_enqueue_style( 'global' ); 3070 wp_enqueue_style( 'colors' ); 3071 if ( ! $limit_styles ) 3072 wp_enqueue_style( 'wp-admin' ); 3054 3073 ?> 3074 <script type="text/javascript"> 3075 //<![CDATA[ 3076 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}} 3077 //]]> 3078 </script> 3079 <?php 3080 do_action('admin_print_styles'); 3081 do_action('admin_print_scripts'); 3082 do_action('admin_head'); 3083 ?> 3084 </head> 3085 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>> 3086 <?php 3087 } 3088 3089 /** 3090 * Generic Iframe footer for use with Thickbox 3091 * 3092 * @since 2.7.0 3093 * 3094 */ 3095 function iframe_footer() { 3096 echo ' 3097 </body> 3098 </html>'; 3099 } 3100 3101 ?> -
wp-admin/js/plugin-install.js
46 46 $('#plugin-information-header a.current').removeClass('current'); 47 47 $(this).addClass('current'); 48 48 //Flip the content. 49 $('#section-holder div ').hide(); //Hide 'em all49 $('#section-holder div.section').hide(); //Hide 'em all 50 50 $('#section-' + tab).show(); 51 51 return false; 52 52 }); -
wp-admin/update.php
49 49 50 50 if ( is_wp_error($result) ) { 51 51 show_message($result); 52 show_message( __(' InstallationFailed') );52 show_message( __('Plugin upgrade Failed') ); 53 53 } else { 54 //Result is the new plugin file relative to WP_PLUGIN_DIR54 $plugin_file = $result; 55 55 show_message( __('Plugin upgraded successfully') ); 56 56 if( $result && $was_activated ){ 57 57 show_message(__('Attempting reactivation of the plugin')); 58 echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $ result, 'activate-plugin_' . $result) .'"></iframe>';58 echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) .'"></iframe>'; 59 59 } 60 $update_actions = array( 61 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . attribute_escape(__('Activate this plugin')) . '" target="_parent">' . __('Activate Plugin') . '</a>', 62 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . attribute_escape(__('Goto plugins page')) . '" target="_parent">' . __('Return to Plugins page') . '</a>' 63 ); 64 if ( $was_activated ) 65 unset( $update_actions['activate_plugin'] ); 66 67 $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $plugin_file); 68 if ( ! empty($update_actions) ) 69 show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$update_actions)); 60 70 } 61 71 echo '</div>'; 62 72 } … … 207 217 if ( 'upgrade-plugin' == $action ) { 208 218 check_admin_referer('upgrade-plugin_' . $plugin); 209 219 $title = __('Upgrade Plugin'); 210 $parent_file = ' plugins.php';220 $parent_file = 'index.php'; 211 221 require_once('admin-header.php'); 212 222 do_plugin_upgrade($plugin); 213 223 include('admin-footer.php'); … … 219 229 wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); 220 230 die(); 221 231 } 222 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 223 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 224 <head> 225 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 226 <title><?php bloginfo('name') ?> › <?php _e('Plugin Reactivation'); ?> — <?php _e('WordPress'); ?></title> 227 <?php 228 wp_admin_css( 'global', true ); 229 wp_admin_css( 'colors', true ); 230 ?> 231 </head> 232 <body> 233 <?php 232 iframe_header( __('Plugin Reactivation'), true ); 234 233 if( isset($_GET['success']) ) 235 234 echo '<p>' . __('Plugin reactivated successfully.') . '</p>'; 236 235 … … 240 239 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. 241 240 include(WP_PLUGIN_DIR . '/' . $plugin); 242 241 } 243 echo "</body></html>";242 iframe_footer(); 244 243 } elseif ( 'upgrade-core' == $action ) { 245 244 $title = __('Upgrade WordPress'); 246 245 $parent_file = 'index.php';