Plugin install from DD32. see #6015

git-svn-id: http://svn.automattic.com/wordpress/trunk@9141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-13 23:39:56 +00:00
parent 82be75124d
commit 01ee36d7c8
5 changed files with 329 additions and 153 deletions

View File

@ -125,8 +125,13 @@ div.star img {
#plugin-information #section-screenshots li img {
vertical-align: text-top;
}
#plugin-information #section-screenshots li p {
font-style: italic;
padding-left: 20px;
padding-bottom: 2em;
}
#plugin-information .updated {
margin-right: 215px;
}

View File

@ -39,7 +39,7 @@ function plugins_api($action, $args = null) {
$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );
$res = unserialize($request['body']);
if ( ! $res )
wp_die($request['body']);
$res = new WP_Error('plugins_api_failed', __('An unknown error occured'), $request['body']);
}
return apply_filters('plugins_api_result', $res, $action, $args);
@ -69,7 +69,6 @@ function install_popular_tags( $args = array() ) {
return $tags;
}
add_action('install_plugins_search', 'install_search', 10, 1);
/**
@ -83,44 +82,55 @@ function install_search($page) {
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
$term = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
if( ! empty($term) ){
$args = array();
$args = array();
switch( $type ){
case 'tag':
$args['tag'] = sanitize_title_with_dashes($term);
break;
case 'term':
$args['search'] = $term;
break;
case 'author':
$args['author'] = $term;
break;
}
$args['page'] = $page;
$api = plugins_api('query_plugins', $args);
add_action('install_plugins_table_header', 'install_search_form');
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
return;
switch( $type ){
case 'tag':
$args['tag'] = sanitize_title_with_dashes($term);
break;
case 'term':
$args['search'] = $term;
break;
case 'author':
$args['author'] = $term;
break;
}
?>
<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>
$args['page'] = $page;
$api = plugins_api('query_plugins', $args);
add_action('install_plugins_table_header', 'install_search_form');
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
return;
}
add_action('install_plugins_dashboard', 'install_dashboard');
function install_dashboard() {
?>
<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>
<h4><?php _e('Search') ?></h4>
<?php install_search_form() ?>
<?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>') ?>
<div id="search-help" style="display: <?php echo isset($_REQUEST['show-help']) ? 'block' : 'none'; ?>;">
<p> <?php _e('You may search based on 3 criteria:') ?><br />
<?php _e('<strong>Term:</strong> Searches plugins names and descriptions for the specified term') ?><br />
<?php _e('<strong>Tag:</strong> Searches for plugins tagged as such') ?><br />
<?php _e('<strong>Author:</strong> Searches for plugins created by the Author, or which the Author contributed to.') ?></p>
</div>
<h4><?php _e('Install a plugin in .zip format') ?></h4>
<p><?php _e('If you have a plugin in a .zip format, You may install it by uploading it here.') ?></p>
<form method="post" enctype="multipart/form-data" action="<?php echo admin_url('plugin-install.php?tab=upload') ?>">
<?php wp_nonce_field( 'plugin-upload') ?>
<input type="file" name="pluginzip" />
<input type="submit" value="<?php _e('Install Now') ?>" />
</form>
<h4><?php _e('Popular tags') ?></h4>
<p><?php _e('You may also search based on these popular tags, These are tags which are most popular on WordPress.org') ?></p>
<p><?php _e('You may also browse based on the most popular tags on wordpress.org') ?></p>
<?php
$api_tags = install_popular_tags();
@ -131,32 +141,28 @@ function install_search($page) {
$tags[ $tag['name'] ] = (object) array(
'link' => clean_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ),
'name' => $tag['name'],
'id' => sanitize_title_with_dashes($tag['name']),
'count' => $tag['count'] );
echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) );
}
/**
* Display search form for searching plugins.
*
* @since 2.7.0
*/
function install_search_form(){
function install_search_form($after_submit = '') {
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
$term = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
?><form id="search-plugins" method="post" action="<?php echo admin_url('plugin-install.php?tab=search') ?>">
<select name="type" id="typeselector">
<option value="term"<?php selected('term', $type) ?>><?php _e('Term') ?></option>
<option value="tag"<?php selected('tag', $type) ?>><?php _e('Tag') ?></option>
<option value="author"<?php selected('author', $type) ?>><?php _e('Author') ?></option>
<option value="tag"<?php selected('tag', $type) ?>><?php _e('Tag') ?></option>
</select>
<input type="text" name="s" id="search-field" value="<?php echo attribute_escape($term) ?>" />
<input type="submit" name="search" value="<?php echo attribute_escape(__('Search')) ?>" class="button" />
<?php echo $after_submit ?>
</form><?php
}
add_action('install_plugins_featured', 'install_featured', 10, 1);
/**
* Display featured plugins.
*
@ -164,13 +170,13 @@ add_action('install_plugins_featured', 'install_featured', 10, 1);
*
* @param string $page
*/
function install_featured($page){
function install_featured($page = 1) {
$args = array('browse' => 'featured', 'page' => $page);
$api = plugins_api('query_plugins', $args);
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
}
add_action('install_plugins_popular', 'install_popular', 10, 1);
add_action('install_plugins_popular', 'install_popular', 10, 1);
/**
* Display popular plugins.
*
@ -178,13 +184,13 @@ add_action('install_plugins_popular', 'install_popular', 10, 1);
*
* @param string $page
*/
function install_popular($page){
function install_popular($page = 1) {
$args = array('browse' => 'popular', 'page' => $page);
$api = plugins_api('query_plugins', $args);
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
}
add_action('install_plugins_new', 'install_new', 10, 1);
add_action('install_plugins_new', 'install_new', 10, 1);
/**
* Display new plugins.
*
@ -192,13 +198,14 @@ add_action('install_plugins_new', 'install_new', 10, 1);
*
* @param string $page
*/
function install_new($page){
function install_new($page = 1) {
$args = array('browse' => 'new', 'page' => $page);
$api = plugins_api('query_plugins', $args);
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
}
add_action('install_plugins_updated', 'install_updated', 10, 1);
/**
* Display recently updated plugins.
*
@ -206,26 +213,11 @@ add_action('install_plugins_updated', 'install_updated', 10, 1);
*
* @param string $page
*/
function install_updated($page){
function install_updated($page = 1) {
$args = array('browse' => 'updated', 'page' => $page);
$api = plugins_api('query_plugins', $args);
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
}
add_action('install_plugins_upload', 'install_upload_custom', 10, 1);
/**
* Display upload plugin form for adding plugins by uploading them manually.
*
* @since 2.7.0
*
* @param string $page
*/
function install_upload_custom($page){
//$args = array('browse' => 'updated', 'page' => $page);
//$api = plugins_api('query_plugins', $args);
//display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
echo '<h1>Not Implemented</h1> <p>Will utilise SwfUpload(if available) & unzip .zip plugin packages</p>';
}
/**
* Display plugin content based on plugin list.
@ -250,7 +242,7 @@ function display_plugins_table($plugins, $page = 1, $totalpages = 1){
<?php do_action('install_plugins_table_header'); ?>
</div>
<?php
$url = $_SERVER['REQUEST_URI'];
$url = clean_url($_SERVER['REQUEST_URI']);
if ( ! empty($term) )
$url = add_query_arg('s', $term, $url);
if ( ! empty($type) )
@ -266,8 +258,8 @@ function display_plugins_table($plugins, $page = 1, $totalpages = 1){
if ( $page_links )
echo "\t\t<div class='tablenav-pages'>$page_links</div>";
?>
<br class="clear" />
</div>
<br class="clear" />
<table class="widefat" id="install-plugins">
<thead>
<tr>
@ -311,7 +303,7 @@ function display_plugins_table($plugins, $page = 1, $totalpages = 1){
$author = wp_kses($author, $plugins_allowedtags);
if( isset($plugin['homepage']) )
$title = '<a target="_blank" href="' . $plugin['homepage'] . '">' . $title . '</a>';
$title = '<a target="_blank" href="' . attribute_escape($plugin['homepage']) . '">' . $title . '</a>';
$action_links = array();
$action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
@ -345,62 +337,12 @@ function display_plugins_table($plugins, $page = 1, $totalpages = 1){
<div class="tablenav">
<?php if ( $page_links )
echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?>
<br class="clear" />
</div>
<br class="clear" />
<?php
}
/**
* Display iframe header.
*
* @since 2.7.0
*
* @param string $title Title for iframe.
*/
function install_iframe_header($title = '') {
if( empty($title) )
$title = __('Plugin Install &#8212; WordPress');
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
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?></title>
<?php
wp_enqueue_style( 'global' );
wp_enqueue_style( 'wp-admin' );
wp_enqueue_style( 'colors' );
?>
<script type="text/javascript">
//<![CDATA[
function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
//]]>
</script>
<?php
do_action('admin_print_styles');
do_action('admin_print_scripts');
do_action('admin_head');
?>
</head>
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
<?php
}
/**
* Display iframe footer.
*
* @since 2.7.0
*/
function install_iframe_footer() {
echo '
</body>
</html>';
}
add_action('install_plugins_pre_plugin-information', 'install_plugin_information');
/**
@ -417,14 +359,13 @@ function install_plugin_information() {
if( empty($section) || ! isset($api->sections[ $section ]) )
$section = array_shift( $section_titles = array_keys((array)$api->sections) );
install_iframe_header();
iframe_header( __('Plugin Install') );
echo "<div id='$tab-header'>\n";
echo "<ul id='sidemenu'>\n";
foreach ( (array)$api->sections as $section_name => $content ) {
$title = $section_name;
$title[0] = strtoupper($title[0]); //Capitalize first character.
$title = str_replace('_', ' ', $title);
$title = ucwords(str_replace('_', ' ', $title));
$class = ( $section_name == $section ) ? ' class="current"' : '';
$href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
@ -434,7 +375,6 @@ function install_plugin_information() {
}
echo "</ul>\n";
echo "</div>\n";
?>
<div class="alignright fyi">
<?php if ( ! empty($api->download_link) ) : ?>
@ -458,12 +398,12 @@ function install_plugin_information() {
default:
case 'install':
if ( current_user_can('install_plugins') ) :
?><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
?><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
endif;
break;
case 'update_available':
if ( current_user_can('update_plugins') ) :
?><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
?><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
endif;
break;
case 'latest_installed':
@ -507,7 +447,11 @@ function install_plugin_information() {
<small><?php printf(__('(based on %d ratings)'), $api->num_ratings) ?></small>
</div>
<div id="section-holder" class="wrap">
<?php
<?php
if ( version_compare($GLOBALS['wp_version'], $api->tested, '>') )
echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
else if ( version_compare($GLOBALS['wp_version'], $api->requires, '<') )
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>';
foreach ( (array)$api->sections as $section_name => $content ) {
$title = $section_name;
$title[0] = strtoupper($title[0]);
@ -520,17 +464,51 @@ function install_plugin_information() {
$display = ( $section_name == $section ) ? 'block' : 'none';
echo "\t<div id='section-{$san_title}' style='display: {$display};'>\n";
echo "\t<div id='section-{$san_title}' class='section' style='display: {$display};'>\n";
echo "\t\t<h2 class='long-header'>$title</h2>";
echo $content;
echo "\t</div>\n";
}
echo "</div>\n";
iframe_footer();
exit;
}
add_action('install_plugins_pre_install', 'install_plugin');
add_action('install_plugins_upload', 'upload_plugin');
function upload_plugin() {
if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
wp_die($uploads['error']);
if ( !empty($_FILES) )
$filename = $_FILES['pluginzip']['name'];
else if ( isset($_GET['package']) )
$filename = $_GET['package'];
check_admin_referer('plugin-upload');
echo '<div class="wrap">';
echo '<h2>', sprintf( __('Installing Plugin from file: %s'), basename($filename) ), '</h2>';
//Handle a newly uploaded file, Else assume it was
if ( !empty($_FILES) ) {
$filename = wp_unique_filename( $uploads['basedir'], $filename );
$local_file = $uploads['basedir'] . '/' . $filename;
// Move the file to the uploads dir
if ( false === @ move_uploaded_file( $_FILES['pluginzip']['tmp_name'], $local_file) )
wp_die( sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path']));
} else {
$local_file = $uploads['basedir'] . '/' . $filename;
}
do_plugin_install_local_package($local_file, $filename);
echo '</div>';
}
add_action('install_plugins_install', 'install_plugin');
/**
* Display plugin link and execute install.
@ -542,9 +520,6 @@ function install_plugin() {
$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
check_admin_referer('install-plugin_' . $plugin);
install_iframe_header();
$api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
echo '<div class="wrap">';
@ -553,7 +528,6 @@ function install_plugin() {
do_plugin_install($api->download_link, $api);
echo '</div>';
exit;
}
/**
@ -561,10 +535,10 @@ function install_plugin() {
*
* @since 2.7.0
*
* @param string $download_url Optional. Download URL.
* @param string $download_url Download URL.
* @param object $plugin_information Optional. Plugin information
*/
function do_plugin_install($download_url = '', $plugin_information = null) {
function do_plugin_install($download_url, $plugin_information = null) {
global $wp_filesystem;
if ( empty($download_url) ) {
@ -602,12 +576,67 @@ function do_plugin_install($download_url = '', $plugin_information = null) {
$plugin_file = $result;
$install_actions = apply_filters('install_plugin_complete_actions', array(
'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>',
'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . __('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
'dismiss_dialog' => '<a href="' . admin_url('plugin-installer.php') . '" onclick="window.parent.tb_remove(); return false;" title="' . __('Dismiss Dialog') . '" target="_parent">' . __('Dismiss Dialog') . '</a>'
'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>',
'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . attribute_escape(__('Goto plugins page')) . '" target="_parent">' . __('Return to Plugins page') . '</a>'
), $plugin_information, $plugin_file);
if ( ! empty($install_actions) )
show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions));
}
}
echo '<p><strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions) . '</p>';
/**
* Install a plugin from a local file.
*
* @since 2.7.0
*
* @param string $package Local Plugin zip
* @param string $filename Optional. Original filename
* @param object $plugin_information Optional. Plugin information
*/
function do_plugin_install_local_package($package, $filename = '') {
global $wp_filesystem;
if ( empty($package) ) {
show_message( __('No plugin Specified') );
return;
}
if ( empty($filename) )
$filename = basename($package);
$url = 'plugin-install.php?tab=upload';
$url = add_query_arg(array('package' => $filename), $url);
$url = wp_nonce_url($url, 'plugin-upload');
if ( false === ($credentials = request_filesystem_credentials($url)) )
return;
if ( ! WP_Filesystem($credentials) ) {
request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
return;
}
if ( $wp_filesystem->errors->get_error_code() ) {
foreach ( $wp_filesystem->errors->get_error_messages() as $message )
show_message($message);
return;
}
$result = wp_install_plugin_local_package( $package, 'show_message' );
if ( is_wp_error($result) ) {
show_message($result);
show_message( __('Installation Failed') );
} else {
show_message( __('Successfully installed the plugin.') );
$plugin_file = $result;
$install_actions = apply_filters('install_plugin_complete_actions', array(
'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>',
'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . __('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
), $plugin_information, $plugin_file);
if ( ! empty($install_actions) )
show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions));
}
}
@ -670,7 +699,102 @@ function wp_install_plugin($package, $feedback = '') {
$result = unzip_file($download_file, $working_dir);
// Once extracted, delete the package
unlink($download_file);
@unlink($download_file);
if ( is_wp_error($result) ) {
$wp_filesystem->delete($working_dir, true);
return $result;
}
//Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
$filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) {
$wp_filesystem->delete($working_dir, true);
return new WP_Error('install_folder_exists', __('Folder allready exists.'), $filelist[0] );
}
apply_filters('install_feedback', __('Installing the plugin'));
// Copy new version of plugin into place.
$result = copy_dir($working_dir, $plugins_dir);
if ( is_wp_error($result) ) {
$wp_filesystem->delete($working_dir, true);
return $result;
}
//Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
$filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
// Remove working directory
$wp_filesystem->delete($working_dir, true);
if( empty($filelist) )
return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
$folder = $filelist[0];
$plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
$pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
//Return the plugin files name.
return $folder . '/' . $pluginfiles[0];
}
/**
* Install plugin from local package
*
* @since 2.7.0
*
* @param string $package
* @param string $feedback Optional.
* @return mixed.
*/
function wp_install_plugin_local_package($package, $feedback = '') {
global $wp_filesystem;
if ( !empty($feedback) )
add_filter('install_feedback', $feedback);
// Is a filesystem accessor setup?
if ( ! $wp_filesystem || ! is_object($wp_filesystem) )
WP_Filesystem();
if ( ! is_object($wp_filesystem) )
return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
if ( $wp_filesystem->errors->get_error_code() )
return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
//Get the base plugin folder
$plugins_dir = $wp_filesystem->wp_plugins_dir();
if ( empty($plugins_dir) )
return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
//And the same for the Content directory.
$content_dir = $wp_filesystem->wp_content_dir();
if( empty($content_dir) )
return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).'));
$plugins_dir = trailingslashit( $plugins_dir );
$content_dir = trailingslashit( $content_dir );
if ( empty($package) )
return new WP_Error('no_package', __('Install package not available.'));
if ( is_wp_error($download_file) )
return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message());
$working_dir = $content_dir . 'upgrade/' . basename($package, '.zip');
// Clean up working directory
if ( $wp_filesystem->is_dir($working_dir) )
$wp_filesystem->delete($working_dir, true);
apply_filters('install_feedback', __('Unpacking the plugin package'));
// Unzip package to working directory
$result = unzip_file($package, $working_dir);
// Once extracted, delete the package
unlink($package);
if ( is_wp_error($result) ) {
$wp_filesystem->delete($working_dir, true);
@ -711,4 +835,5 @@ function wp_install_plugin($package, $feedback = '') {
}
?>
?>

View File

@ -3064,7 +3064,54 @@ function _draft_or_post_title($post_id = 0)
*
*/
function _admin_search_query() {
echo ( isset($_GET['s']) ) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
}
/**
* Generic Iframe header for use with Thickbox
*
* @since 2.7.0
* @param string $title Title of the Iframe page.
* @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
*
*/
function iframe_header( $title = '', $limit_styles = false) {
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
<?php
wp_enqueue_style( 'global' );
wp_enqueue_style( 'colors' );
if ( ! $limit_styles )
wp_enqueue_style( 'wp-admin' );
?>
<script type="text/javascript">
//<![CDATA[
function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
//]]>
</script>
<?php
do_action('admin_print_styles');
do_action('admin_print_scripts');
do_action('admin_head');
?>
</head>
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
<?php
}
/**
* Generic Iframe footer for use with Thickbox
*
* @since 2.7.0
*
*/
function iframe_footer() {
echo '
</body>
</html>';
}
?>

View File

@ -46,7 +46,7 @@ jQuery(function($) {
$('#plugin-information-header a.current').removeClass('current');
$(this).addClass('current');
//Flip the content.
$('#section-holder div').hide(); //Hide 'em all
$('#section-holder div.section').hide(); //Hide 'em all
$('#section-' + tab).show();
return false;
});

View File

@ -49,14 +49,24 @@ function do_plugin_upgrade($plugin) {
if ( is_wp_error($result) ) {
show_message($result);
show_message( __('Installation Failed') );
show_message( __('Plugin upgrade Failed') );
} else {
//Result is the new plugin file relative to WP_PLUGIN_DIR
$plugin_file = $result;
show_message( __('Plugin upgraded successfully') );
if( $result && $was_activated ){
show_message(__('Attempting reactivation of the plugin'));
echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>';
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>';
}
$update_actions = array(
'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>',
'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . attribute_escape(__('Goto plugins page')) . '" target="_parent">' . __('Return to Plugins page') . '</a>'
);
if ( $was_activated )
unset( $update_actions['activate_plugin'] );
$update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $plugin_file);
if ( ! empty($update_actions) )
show_message('<strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$update_actions));
}
echo '</div>';
}
@ -207,7 +217,7 @@ if ( isset($_GET['action']) ) {
if ( 'upgrade-plugin' == $action ) {
check_admin_referer('upgrade-plugin_' . $plugin);
$title = __('Upgrade Plugin');
$parent_file = 'plugins.php';
$parent_file = 'index.php';
require_once('admin-header.php');
do_plugin_upgrade($plugin);
include('admin-footer.php');
@ -219,18 +229,7 @@ if ( isset($_GET['action']) ) {
wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
die();
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php _e('Plugin Reactivation'); ?> &#8212; <?php _e('WordPress'); ?></title>
<?php
wp_admin_css( 'global', true );
wp_admin_css( 'colors', true );
?>
</head>
<body>
<?php
iframe_header( __('Plugin Reactivation'), true );
if( isset($_GET['success']) )
echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
@ -240,7 +239,7 @@ wp_admin_css( 'colors', true );
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
include(WP_PLUGIN_DIR . '/' . $plugin);
}
echo "</body></html>";
iframe_footer();
} elseif ( 'upgrade-core' == $action ) {
$title = __('Upgrade WordPress');
$parent_file = 'index.php';