2008-02-11 06:45:54 +01:00
|
|
|
<?php
|
2008-08-16 09:27:34 +02:00
|
|
|
/**
|
2009-04-19 21:36:28 +02:00
|
|
|
* Update/Install Plugin/Theme administration panel.
|
2008-08-16 09:27:34 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
2010-12-08 00:05:27 +01:00
|
|
|
if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
|
|
|
|
define('IFRAME_REQUEST' , true);
|
2010-10-18 19:58:36 +02:00
|
|
|
|
2008-08-16 09:27:34 +02:00
|
|
|
/** WordPress Administration Bootstrap */
|
2010-04-18 08:14:45 +02:00
|
|
|
require_once('./admin.php');
|
2008-02-11 06:45:54 +01:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
2008-09-26 08:43:53 +02:00
|
|
|
|
2008-02-11 06:45:54 +01:00
|
|
|
if ( isset($_GET['action']) ) {
|
2009-04-19 21:36:28 +02:00
|
|
|
$plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
|
2008-09-26 08:43:53 +02:00
|
|
|
$theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
|
2009-04-19 21:36:28 +02:00
|
|
|
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
|
2008-12-09 19:03:31 +01:00
|
|
|
|
2010-03-06 09:39:50 +01:00
|
|
|
if ( 'update-selected' == $action ) {
|
|
|
|
if ( ! current_user_can( 'update_plugins' ) )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die( __( 'You do not have sufficient permissions to update plugins for this site.' ) );
|
2010-03-06 09:39:50 +01:00
|
|
|
|
|
|
|
check_admin_referer( 'bulk-update-plugins' );
|
|
|
|
|
|
|
|
if ( isset( $_GET['plugins'] ) )
|
|
|
|
$plugins = explode( ',', stripslashes($_GET['plugins']) );
|
|
|
|
elseif ( isset( $_POST['checked'] ) )
|
|
|
|
$plugins = (array) $_POST['checked'];
|
|
|
|
else
|
|
|
|
$plugins = array();
|
|
|
|
|
|
|
|
$plugins = array_map('urldecode', $plugins);
|
|
|
|
|
|
|
|
$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
|
|
|
|
$nonce = 'bulk-update-plugins';
|
|
|
|
|
|
|
|
wp_enqueue_script('jquery');
|
|
|
|
iframe_header();
|
|
|
|
|
|
|
|
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
|
|
|
|
$upgrader->bulk_upgrade( $plugins );
|
|
|
|
|
|
|
|
iframe_footer();
|
2010-03-17 17:27:25 +01:00
|
|
|
|
2010-03-06 09:39:50 +01:00
|
|
|
} elseif ( 'upgrade-plugin' == $action ) {
|
2009-04-19 21:36:28 +02:00
|
|
|
if ( ! current_user_can('update_plugins') )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
|
2009-04-19 21:36:28 +02:00
|
|
|
|
2008-03-11 17:37:44 +01:00
|
|
|
check_admin_referer('upgrade-plugin_' . $plugin);
|
2009-04-19 21:36:28 +02:00
|
|
|
|
2010-12-03 10:16:28 +01:00
|
|
|
$title = __('Update Plugin');
|
2008-11-29 19:09:09 +01:00
|
|
|
$parent_file = 'plugins.php';
|
2009-04-19 21:36:28 +02:00
|
|
|
$submenu_file = 'plugins.php';
|
2010-10-20 16:16:03 +02:00
|
|
|
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
$nonce = 'upgrade-plugin_' . $plugin;
|
|
|
|
$url = 'update.php?action=upgrade-plugin&plugin=' . $plugin;
|
|
|
|
|
|
|
|
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
|
|
|
|
$upgrader->upgrade($plugin);
|
|
|
|
|
2010-10-20 16:16:03 +02:00
|
|
|
include(ABSPATH . 'wp-admin/admin-footer.php');
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2008-09-26 08:43:53 +02:00
|
|
|
} elseif ('activate-plugin' == $action ) {
|
2009-04-19 21:36:28 +02:00
|
|
|
if ( ! current_user_can('update_plugins') )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
|
2009-04-19 21:36:28 +02:00
|
|
|
|
2008-03-22 00:02:00 +01:00
|
|
|
check_admin_referer('activate-plugin_' . $plugin);
|
2010-01-18 21:34:48 +01:00
|
|
|
if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
|
2010-10-27 12:43:43 +02:00
|
|
|
wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
|
2010-10-27 15:40:14 +02:00
|
|
|
activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
|
2010-10-27 12:43:43 +02:00
|
|
|
wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
|
2008-03-22 00:02:00 +01:00
|
|
|
die();
|
|
|
|
}
|
2008-10-14 01:39:56 +02:00
|
|
|
iframe_header( __('Plugin Reactivation'), true );
|
2010-01-18 21:34:48 +01:00
|
|
|
if ( isset($_GET['success']) )
|
2008-03-22 00:02:00 +01:00
|
|
|
echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
|
|
|
|
|
2010-01-18 21:34:48 +01:00
|
|
|
if ( isset($_GET['failure']) ){
|
2008-03-22 00:02:00 +01:00
|
|
|
echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
|
2009-12-12 10:20:07 +01:00
|
|
|
|
|
|
|
if ( defined('E_RECOVERABLE_ERROR') )
|
2010-02-28 13:19:09 +01:00
|
|
|
error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
|
2009-12-12 10:20:07 +01:00
|
|
|
else
|
2010-02-28 13:19:09 +01:00
|
|
|
error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
|
2009-12-12 10:20:07 +01:00
|
|
|
|
2008-03-22 00:02:00 +01:00
|
|
|
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
|
2008-05-27 19:55:24 +02:00
|
|
|
include(WP_PLUGIN_DIR . '/' . $plugin);
|
2008-03-22 00:02:00 +01:00
|
|
|
}
|
2008-10-14 01:39:56 +02:00
|
|
|
iframe_footer();
|
2009-04-19 21:36:28 +02:00
|
|
|
} elseif ( 'install-plugin' == $action ) {
|
|
|
|
|
|
|
|
if ( ! current_user_can('install_plugins') )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die(__('You do not have sufficient permissions to install plugins for this site.'));
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api..
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
check_admin_referer('install-plugin_' . $plugin);
|
|
|
|
$api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
if ( is_wp_error($api) )
|
|
|
|
wp_die($api);
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
$title = __('Plugin Install');
|
|
|
|
$parent_file = 'plugins.php';
|
|
|
|
$submenu_file = 'plugin-install.php';
|
2010-10-20 16:16:03 +02:00
|
|
|
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
$title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
|
|
|
|
$nonce = 'install-plugin_' . $plugin;
|
2009-04-20 20:15:08 +02:00
|
|
|
$url = 'update.php?action=install-plugin&plugin=' . $plugin;
|
2010-05-27 13:04:08 +02:00
|
|
|
if ( isset($_GET['from']) )
|
|
|
|
$url .= '&from=' . urlencode(stripslashes($_GET['from']));
|
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
$type = 'web'; //Install plugin type, From Web or an Upload.
|
|
|
|
|
|
|
|
$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
|
|
|
|
$upgrader->install($api->download_link);
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2010-10-20 16:16:03 +02:00
|
|
|
include(ABSPATH . 'wp-admin/admin-footer.php');
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
} elseif ( 'upload-plugin' == $action ) {
|
|
|
|
|
|
|
|
if ( ! current_user_can('install_plugins') )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die(__('You do not have sufficient permissions to install plugins for this site.'));
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
check_admin_referer('plugin-upload');
|
|
|
|
|
|
|
|
$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
|
|
|
|
|
|
|
|
$title = __('Upload Plugin');
|
|
|
|
$parent_file = 'plugins.php';
|
|
|
|
$submenu_file = 'plugin-install.php';
|
2010-10-20 16:16:03 +02:00
|
|
|
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
$title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) );
|
|
|
|
$nonce = 'plugin-upload';
|
|
|
|
$url = add_query_arg(array('package' => $file_upload->filename ), 'update.php?action=upload-plugin');
|
|
|
|
$type = 'upload'; //Install plugin type, From Web or an Upload.
|
|
|
|
|
|
|
|
$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
|
|
|
|
$upgrader->install( $file_upload->package );
|
|
|
|
|
2010-10-20 16:16:03 +02:00
|
|
|
include(ABSPATH . 'wp-admin/admin-footer.php');
|
2009-04-19 21:36:28 +02:00
|
|
|
|
2008-12-09 19:03:31 +01:00
|
|
|
} elseif ( 'upgrade-theme' == $action ) {
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
if ( ! current_user_can('update_themes') )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die(__('You do not have sufficient permissions to update themes for this site.'));
|
2009-04-19 21:36:28 +02:00
|
|
|
|
2008-09-26 08:43:53 +02:00
|
|
|
check_admin_referer('upgrade-theme_' . $theme);
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
add_thickbox();
|
|
|
|
wp_enqueue_script('theme-preview');
|
2010-12-03 10:16:28 +01:00
|
|
|
$title = __('Update Theme');
|
2008-09-26 08:43:53 +02:00
|
|
|
$parent_file = 'themes.php';
|
2009-04-19 21:36:28 +02:00
|
|
|
$submenu_file = 'themes.php';
|
2010-10-20 16:16:03 +02:00
|
|
|
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
$nonce = 'upgrade-theme_' . $theme;
|
|
|
|
$url = 'update.php?action=upgrade-theme&theme=' . $theme;
|
|
|
|
|
|
|
|
$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
|
|
|
|
$upgrader->upgrade($theme);
|
|
|
|
|
2010-10-20 16:16:03 +02:00
|
|
|
include(ABSPATH . 'wp-admin/admin-footer.php');
|
2010-03-13 04:59:40 +01:00
|
|
|
} elseif ( 'update-selected-themes' == $action ) {
|
|
|
|
if ( ! current_user_can( 'update_themes' ) )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die( __( 'You do not have sufficient permissions to update themes for this site.' ) );
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2010-03-13 04:59:40 +01:00
|
|
|
check_admin_referer( 'bulk-update-themes' );
|
|
|
|
|
|
|
|
if ( isset( $_GET['themes'] ) )
|
|
|
|
$themes = explode( ',', stripslashes($_GET['themes']) );
|
|
|
|
elseif ( isset( $_POST['checked'] ) )
|
|
|
|
$themes = (array) $_POST['checked'];
|
|
|
|
else
|
|
|
|
$themes = array();
|
|
|
|
|
|
|
|
$themes = array_map('urldecode', $themes);
|
|
|
|
|
2010-04-06 13:28:55 +02:00
|
|
|
$url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
|
2010-03-13 04:59:40 +01:00
|
|
|
$nonce = 'bulk-update-themes';
|
|
|
|
|
|
|
|
wp_enqueue_script('jquery');
|
|
|
|
iframe_header();
|
|
|
|
|
|
|
|
$upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
|
|
|
|
$upgrader->bulk_upgrade( $themes );
|
|
|
|
|
|
|
|
iframe_footer();
|
2009-04-19 21:36:28 +02:00
|
|
|
} elseif ( 'install-theme' == $action ) {
|
|
|
|
|
|
|
|
if ( ! current_user_can('install_themes') )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die(__('You do not have sufficient permissions to install themes for this site.'));
|
2008-02-11 06:45:54 +01:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api..
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
check_admin_referer('install-theme_' . $theme);
|
|
|
|
$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
|
|
|
|
|
|
|
|
if ( is_wp_error($api) )
|
|
|
|
wp_die($api);
|
|
|
|
|
|
|
|
add_thickbox();
|
|
|
|
wp_enqueue_script('theme-preview');
|
|
|
|
$title = __('Install Themes');
|
|
|
|
$parent_file = 'themes.php';
|
2010-03-19 09:03:52 +01:00
|
|
|
$submenu_file = 'themes.php';
|
2010-10-20 16:16:03 +02:00
|
|
|
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2010-01-21 22:37:43 +01:00
|
|
|
$title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version );
|
2009-04-19 21:36:28 +02:00
|
|
|
$nonce = 'install-theme_' . $theme;
|
2009-04-20 20:15:08 +02:00
|
|
|
$url = 'update.php?action=install-theme&theme=' . $theme;
|
2009-04-19 21:36:28 +02:00
|
|
|
$type = 'web'; //Install theme type, From Web or an Upload.
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
|
|
|
|
$upgrader->install($api->download_link);
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2010-10-20 16:16:03 +02:00
|
|
|
include(ABSPATH . 'wp-admin/admin-footer.php');
|
2009-04-20 20:18:39 +02:00
|
|
|
|
2009-04-19 21:36:28 +02:00
|
|
|
} elseif ( 'upload-theme' == $action ) {
|
|
|
|
|
|
|
|
if ( ! current_user_can('install_themes') )
|
2010-04-30 03:54:32 +02:00
|
|
|
wp_die(__('You do not have sufficient permissions to install themes for this site.'));
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
check_admin_referer('theme-upload');
|
|
|
|
|
|
|
|
$file_upload = new File_Upload_Upgrader('themezip', 'package');
|
|
|
|
|
|
|
|
$title = __('Upload Theme');
|
|
|
|
$parent_file = 'themes.php';
|
|
|
|
$submenu_file = 'theme-install.php';
|
|
|
|
add_thickbox();
|
|
|
|
wp_enqueue_script('theme-preview');
|
2010-10-20 16:16:03 +02:00
|
|
|
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
$title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) );
|
|
|
|
$nonce = 'theme-upload';
|
|
|
|
$url = add_query_arg(array('package' => $file_upload->filename), 'update.php?action=upload-theme');
|
|
|
|
$type = 'upload'; //Install plugin type, From Web or an Upload.
|
|
|
|
|
|
|
|
$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
|
|
|
|
$upgrader->install( $file_upload->package );
|
|
|
|
|
2010-10-20 16:16:03 +02:00
|
|
|
include(ABSPATH . 'wp-admin/admin-footer.php');
|
2009-04-19 21:36:28 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
do_action('update-custom_' . $action);
|
|
|
|
}
|
2010-04-30 03:54:32 +02:00
|
|
|
}
|