Make WordPress Core

Changeset 9141


Ignore:
Timestamp:
10/13/2008 11:39:56 PM (16 years ago)
Author:
ryan
Message:

Plugin install from DD32. see #6015

Location:
trunk/wp-admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/plugin-install.css

    r8884 r9141  
    126126    vertical-align: text-top;
    127127}
     128
    128129#plugin-information #section-screenshots li p {
    129130    font-style: italic;
     
    131132    padding-bottom: 2em;
    132133}
     134
     135#plugin-information .updated {
     136    margin-right: 215px;
     137}
  • trunk/wp-admin/includes/plugin-install.php

    r9119 r9141  
    4040        $res = unserialize($request['body']);
    4141        if ( ! $res )
    42             wp_die($request['body']);
     42            $res = new WP_Error('plugins_api_failed', __('An unknown error occured'), $request['body']);
    4343    }
    4444
     
    7070    return $tags;
    7171}
    72 
    7372add_action('install_plugins_search', 'install_search', 10, 1);
    7473
     
    8483    $term = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
    8584
    86     if( ! empty($term) ){
    87         $args = array();
    88 
    89         switch( $type ){
    90             case 'tag':
    91                 $args['tag'] = sanitize_title_with_dashes($term);
    92                 break;
    93             case 'term':
    94                 $args['search'] = $term;
    95                 break;
    96             case 'author':
    97                 $args['author'] = $term;
    98                 break;
    99         }
    100 
    101         $args['page'] = $page;
    102 
    103         $api = plugins_api('query_plugins', $args);
    104 
    105         add_action('install_plugins_table_header', 'install_search_form');
    106 
    107         display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
    108 
    109         return;
    110     }
     85    $args = array();
     86
     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    }
     98
     99    $args['page'] = $page;
     100
     101    $api = plugins_api('query_plugins', $args);
     102
     103    add_action('install_plugins_table_header', 'install_search_form');
     104
     105    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
     106
     107    return;
     108}
     109
     110add_action('install_plugins_dashboard', 'install_dashboard');
     111function install_dashboard() {
    111112    ?>
    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> via this page.') ?></p>
     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>
    114114
    115115    <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'; ?>;">
    117118    <p> <?php _e('You may search based on 3 criteria:') ?><br />
    118119        <?php _e('<strong>Term:</strong> Searches plugins names and descriptions for the specified term') ?><br />
    119120        <?php _e('<strong>Tag:</strong> Searches for plugins tagged as such') ?><br />
    120121        <?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   
    122132    <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>
    124134    <?php
    125135
     
    132142                                'link' => clean_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ),
    133143                                'name' => $tag['name'],
     144                                'id' => sanitize_title_with_dashes($tag['name']),
    134145                                'count' => $tag['count'] );
    135146    echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) );
    136147}
    137148
    138 /**
    139  * Display search form for searching plugins.
    140  *
    141  * @since 2.7.0
    142  */
    143 function install_search_form(){
     149function install_search_form($after_submit = '') {
    144150    $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
    145151    $term = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     
    148154        <select name="type" id="typeselector">
    149155            <option value="term"<?php selected('term', $type) ?>><?php _e('Term') ?></option>
     156            <option value="author"<?php selected('author', $type) ?>><?php _e('Author') ?></option>
    150157            <option value="tag"<?php selected('tag', $type) ?>><?php _e('Tag') ?></option>
    151             <option value="author"<?php selected('author', $type) ?>><?php _e('Author') ?></option>
    152158        </select>
    153159        <input type="text" name="s" id="search-field" value="<?php echo attribute_escape($term) ?>" />
    154160        <input type="submit" name="search" value="<?php echo attribute_escape(__('Search')) ?>" class="button" />
     161        <?php echo $after_submit ?>
    155162    </form><?php
    156163}
    157164
    158165add_action('install_plugins_featured', 'install_featured', 10, 1);
    159 
    160166/**
    161167 * Display featured plugins.
     
    165171 * @param string $page
    166172 */
    167 function install_featured($page){
     173function install_featured($page = 1) {
    168174    $args = array('browse' => 'featured', 'page' => $page);
    169175    $api = plugins_api('query_plugins', $args);
    170176    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
    171177}
     178
    172179add_action('install_plugins_popular', 'install_popular', 10, 1);
    173 
    174180/**
    175181 * Display popular plugins.
     
    179185 * @param string $page
    180186 */
    181 function install_popular($page){
     187function install_popular($page = 1) {
    182188    $args = array('browse' => 'popular', 'page' => $page);
    183189    $api = plugins_api('query_plugins', $args);
    184190    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
    185191}
     192
    186193add_action('install_plugins_new', 'install_new', 10, 1);
    187 
    188194/**
    189195 * Display new plugins.
     
    193199 * @param string $page
    194200 */
    195 function install_new($page){
     201function install_new($page = 1) {
    196202    $args = array('browse' => 'new', 'page' => $page);
    197203    $api = plugins_api('query_plugins', $args);
     
    200206add_action('install_plugins_updated', 'install_updated', 10, 1);
    201207
     208
    202209/**
    203210 * Display recently updated plugins.
     
    207214 * @param string $page
    208215 */
    209 function install_updated($page){
     216function install_updated($page = 1) {
    210217    $args = array('browse' => 'updated', 'page' => $page);
    211218    $api = plugins_api('query_plugins', $args);
    212219    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
    213 }
    214 add_action('install_plugins_upload', 'install_upload_custom', 10, 1);
    215 
    216 /**
    217  * Display upload plugin form for adding plugins by uploading them manually.
    218  *
    219  * @since 2.7.0
    220  *
    221  * @param string $page
    222  */
    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>';
    228220}
    229221
     
    251243        </div>
    252244        <?php
    253             $url = $_SERVER['REQUEST_URI'];
     245            $url = clean_url($_SERVER['REQUEST_URI']);
    254246            if ( ! empty($term) )
    255247                $url = add_query_arg('s', $term, $url);
     
    267259                echo "\t\t<div class='tablenav-pages'>$page_links</div>";
    268260?>
     261        <br class="clear" />
    269262    </div>
    270     <br class="clear" />
    271263    <table class="widefat" id="install-plugins">
    272264        <thead>
     
    312304
    313305                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>';
    315307
    316308                $action_links = array();
     
    346338        <?php if ( $page_links )
    347339                echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?>
     340        <br class="clear" />
    348341    </div>
    349     <br class="clear" />
    350342
    351343<?php
    352 }
    353 
    354 /**
    355  * Display iframe header.
    356  *
    357  * @since 2.7.0
    358  *
    359  * @param string $title Title for iframe.
    360  */
    361 function install_iframe_header($title = '') {
    362 if( empty($title) )
    363     $title = __('Plugin Install &#8212; 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 handlers
    366 
    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') ?> &rsaquo; <?php echo $title ?></title>
    373 <?php
    374 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 <?php
    384 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 <?php
    391 }
    392 
    393 /**
    394  * Display iframe footer.
    395  *
    396  * @since 2.7.0
    397  */
    398 function install_iframe_footer() {
    399 echo '
    400 </body>
    401 </html>';
    402344}
    403345
     
    418360        $section = array_shift( $section_titles = array_keys((array)$api->sections) );
    419361
    420     install_iframe_header();
     362    iframe_header( __('Plugin Install') ); 
    421363    echo "<div id='$tab-header'>\n";
    422364    echo "<ul id='sidemenu'>\n";
     
    424366
    425367        $title = $section_name;
    426         $title[0] = strtoupper($title[0]); //Capitalize first character.
    427         $title = str_replace('_', ' ', $title);
     368        $title = ucwords(str_replace('_', ' ', $title));
    428369
    429370        $class = ( $section_name == $section ) ? ' class="current"' : '';
     
    435376    echo "</ul>\n";
    436377    echo "</div>\n";
    437 
    438378    ?>
    439379    <div class="alignright fyi">
     
    459399                case 'install':
    460400                    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><?php
     401                ?><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
    462402                    endif;
    463403                break;
    464404                case 'update_available':
    465405                    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><?php
     406                        ?><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
    467407                    endif;
    468408                break;
     
    508448    </div>
    509449    <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>';
    511455        foreach ( (array)$api->sections as $section_name => $content ) {
    512456            $title = $section_name;
     
    521465            $display = ( $section_name == $section ) ? 'block' : 'none';
    522466
    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";
    524468            echo "\t\t<h2 class='long-header'>$title</h2>";
    525469            echo $content;
     
    528472    echo "</div>\n";
    529473
     474    iframe_footer();
    530475    exit;
    531476}
    532477
    533 add_action('install_plugins_pre_install', 'install_plugin');
     478
     479add_action('install_plugins_upload', 'upload_plugin');
     480function 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
     511add_action('install_plugins_install', 'install_plugin');
    534512
    535513/**
     
    543521
    544522    check_admin_referer('install-plugin_' . $plugin);
    545 
    546     install_iframe_header();
    547 
    548523    $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
    549524
     
    554529    echo '</div>';
    555530
    556     exit;
    557531}
    558532
     
    562536 * @since 2.7.0
    563537 *
    564  * @param string $download_url Optional. Download URL.
     538 * @param string $download_url Download URL.
    565539 * @param object $plugin_information Optional. Plugin information
    566540 */
    567 function do_plugin_install($download_url = '', $plugin_information = null) {
     541function do_plugin_install($download_url, $plugin_information = null) {
    568542    global $wp_filesystem;
    569543
     
    603577
    604578        $install_actions = apply_filters('install_plugin_complete_actions', array(
     579            'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;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>'
     581                            ), $plugin_information, $plugin_file);
     582        if ( ! empty($install_actions) )
     583            show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions));
     584    }
     585}
     586
     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 */
     596function do_plugin_install_local_package($package, $filename = '') {
     597    global $wp_filesystem;
     598
     599    if ( empty($package) ) {
     600        show_message( __('No plugin Specified') );
     601        return;
     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(
    605635                            'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;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>'
     636                            'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . __('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
    608637                            ), $plugin_information, $plugin_file);
    609 
    610         echo '<p><strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions) . '</p>';
     638        if ( ! empty($install_actions) )
     639            show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions));
    611640    }
    612641}
     
    671700
    672701    // Once extracted, delete the package
    673     unlink($download_file);
     702    @unlink($download_file);
    674703
    675704    if ( is_wp_error($result) ) {
     
    711740}
    712741
     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 */
     751function wp_install_plugin_local_package($package, $feedback = '') {
     752    global $wp_filesystem;
     753
     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
    713838
    714839?>
  • trunk/wp-admin/includes/template.php

    r9134 r9141  
    30653065 */
    30663066function _admin_search_query() {
    3067     echo ( isset($_GET['s']) ) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
    3068 }
    3069 
     3067    echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
     3068}
     3069
     3070/**
     3071 * Generic Iframe header for use with Thickbox
     3072 *
     3073 * @since 2.7.0
     3074 * @param string $title Title of the Iframe page.
     3075 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
     3076 *
     3077 */
     3078function iframe_header( $title = '', $limit_styles = false) {
     3079?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     3080<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
     3081<head>
     3082<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
     3083<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
     3084<?php
     3085wp_enqueue_style( 'global' );
     3086wp_enqueue_style( 'colors' );
     3087if ( ! $limit_styles )
     3088    wp_enqueue_style( 'wp-admin' );
    30703089?>
     3090<script type="text/javascript">
     3091//<![CDATA[
     3092function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
     3093//]]>
     3094</script>
     3095<?php
     3096do_action('admin_print_styles');
     3097do_action('admin_print_scripts');
     3098do_action('admin_head');
     3099?>
     3100</head>
     3101<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
     3102<?php
     3103}
     3104
     3105/**
     3106 * Generic Iframe footer for use with Thickbox
     3107 *
     3108 * @since 2.7.0
     3109 *
     3110 */
     3111function iframe_footer() {
     3112    echo '
     3113    </body>
     3114</html>';
     3115}
     3116
     3117?>
  • trunk/wp-admin/js/plugin-install.js

    r8541 r9141  
    4747        $(this).addClass('current');
    4848        //Flip the content.
    49         $('#section-holder div').hide(); //Hide 'em all
     49        $('#section-holder div.section').hide(); //Hide 'em all
    5050        $('#section-' + tab).show();
    5151        return false;
  • trunk/wp-admin/update.php

    r9034 r9141  
    5050    if ( is_wp_error($result) ) {
    5151        show_message($result);
    52         show_message( __('Installation Failed') );
    53     } else {
    54         //Result is the new plugin file relative to WP_PLUGIN_DIR
     52        show_message( __('Plugin upgrade Failed') );
     53    } else {
     54        $plugin_file = $result;
    5555        show_message( __('Plugin upgraded successfully') );
    5656        if( $result && $was_activated ){
    5757            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>';
    59         }
     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        }
     60        $update_actions =  array(
     61            'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;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));
    6070    }
    6171    echo '</div>';
     
    208218        check_admin_referer('upgrade-plugin_' . $plugin);
    209219        $title = __('Upgrade Plugin');
    210         $parent_file = 'plugins.php';
     220        $parent_file = 'index.php';
    211221        require_once('admin-header.php');
    212222        do_plugin_upgrade($plugin);
     
    220230            die();
    221231        }
    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') ?> &rsaquo; <?php _e('Plugin Reactivation'); ?> &#8212; <?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 );
    234233        if( isset($_GET['success']) )
    235234            echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
     
    241240            include(WP_PLUGIN_DIR . '/' . $plugin);
    242241        }
    243         echo "</body></html>";
     242        iframe_footer();
    244243    } elseif ( 'upgrade-core' == $action ) {
    245244        $title = __('Upgrade WordPress');
Note: See TracChangeset for help on using the changeset viewer.