| [ Index ] |
PHP Cross Reference of Wordpress 2.9.1 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Update/Install Plugin/Theme administration panel. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once ('admin.php'); 11 12 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 13 14 if ( isset($_GET['action']) ) { 15 $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : ''; 16 $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : ''; 17 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; 18 19 if ( 'upgrade-plugin' == $action ) { 20 if ( ! current_user_can('update_plugins') ) 21 wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); 22 23 check_admin_referer('upgrade-plugin_' . $plugin); 24 25 $title = __('Upgrade Plugin'); 26 $parent_file = 'plugins.php'; 27 $submenu_file = 'plugins.php'; 28 require_once ('admin-header.php'); 29 30 $nonce = 'upgrade-plugin_' . $plugin; 31 $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin; 32 33 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); 34 $upgrader->upgrade($plugin); 35 36 include ('admin-footer.php'); 37 38 } elseif ('activate-plugin' == $action ) { 39 if ( ! current_user_can('update_plugins') ) 40 wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); 41 42 check_admin_referer('activate-plugin_' . $plugin); 43 if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { 44 wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); 45 activate_plugin($plugin); 46 wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); 47 die(); 48 } 49 iframe_header( __('Plugin Reactivation'), true ); 50 if( isset($_GET['success']) ) 51 echo '<p>' . __('Plugin reactivated successfully.') . '</p>'; 52 53 if( isset($_GET['failure']) ){ 54 echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; 55 56 if ( defined('E_RECOVERABLE_ERROR') ) 57 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); 58 else 59 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING); 60 61 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. 62 include(WP_PLUGIN_DIR . '/' . $plugin); 63 } 64 iframe_footer(); 65 } elseif ( 'install-plugin' == $action ) { 66 67 if ( ! current_user_can('install_plugins') ) 68 wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); 69 70 include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. 71 72 check_admin_referer('install-plugin_' . $plugin); 73 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 74 75 if ( is_wp_error($api) ) 76 wp_die($api); 77 78 $title = __('Plugin Install'); 79 $parent_file = 'plugins.php'; 80 $submenu_file = 'plugin-install.php'; 81 require_once ('admin-header.php'); 82 83 $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ); 84 $nonce = 'install-plugin_' . $plugin; 85 $url = 'update.php?action=install-plugin&plugin=' . $plugin; 86 $type = 'web'; //Install plugin type, From Web or an Upload. 87 88 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); 89 $upgrader->install($api->download_link); 90 91 include ('admin-footer.php'); 92 93 } elseif ( 'upload-plugin' == $action ) { 94 95 if ( ! current_user_can('install_plugins') ) 96 wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); 97 98 check_admin_referer('plugin-upload'); 99 100 $file_upload = new File_Upload_Upgrader('pluginzip', 'package'); 101 102 $title = __('Upload Plugin'); 103 $parent_file = 'plugins.php'; 104 $submenu_file = 'plugin-install.php'; 105 require_once ('admin-header.php'); 106 107 $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); 108 $nonce = 'plugin-upload'; 109 $url = add_query_arg(array('package' => $file_upload->filename ), 'update.php?action=upload-plugin'); 110 $type = 'upload'; //Install plugin type, From Web or an Upload. 111 112 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); 113 $upgrader->install( $file_upload->package ); 114 115 include ('admin-footer.php'); 116 117 } elseif ( 'upgrade-theme' == $action ) { 118 119 if ( ! current_user_can('update_themes') ) 120 wp_die(__('You do not have sufficient permissions to update themes for this blog.')); 121 122 check_admin_referer('upgrade-theme_' . $theme); 123 124 add_thickbox(); 125 wp_enqueue_script('theme-preview'); 126 $title = __('Upgrade Theme'); 127 $parent_file = 'themes.php'; 128 $submenu_file = 'themes.php'; 129 require_once ('admin-header.php'); 130 131 $nonce = 'upgrade-theme_' . $theme; 132 $url = 'update.php?action=upgrade-theme&theme=' . $theme; 133 134 $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) ); 135 $upgrader->upgrade($theme); 136 137 include ('admin-footer.php'); 138 139 } elseif ( 'install-theme' == $action ) { 140 141 if ( ! current_user_can('install_themes') ) 142 wp_die(__('You do not have sufficient permissions to install themes for this blog.')); 143 144 include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api.. 145 146 check_admin_referer('install-theme_' . $theme); 147 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 148 149 if ( is_wp_error($api) ) 150 wp_die($api); 151 152 add_thickbox(); 153 wp_enqueue_script('theme-preview'); 154 $title = __('Install Themes'); 155 $parent_file = 'themes.php'; 156 $submenu_file = 'theme-install.php'; 157 require_once ('admin-header.php'); 158 159 $title = sprintf( __('Installing theme: %s'), $api->name . ' ' . $api->version ); 160 $nonce = 'install-theme_' . $theme; 161 $url = 'update.php?action=install-theme&theme=' . $theme; 162 $type = 'web'; //Install theme type, From Web or an Upload. 163 164 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); 165 $upgrader->install($api->download_link); 166 167 include ('admin-footer.php'); 168 169 } elseif ( 'upload-theme' == $action ) { 170 171 if ( ! current_user_can('install_themes') ) 172 wp_die(__('You do not have sufficient permissions to install themes for this blog.')); 173 174 check_admin_referer('theme-upload'); 175 176 $file_upload = new File_Upload_Upgrader('themezip', 'package'); 177 178 $title = __('Upload Theme'); 179 $parent_file = 'themes.php'; 180 $submenu_file = 'theme-install.php'; 181 add_thickbox(); 182 wp_enqueue_script('theme-preview'); 183 require_once ('admin-header.php'); 184 185 $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); 186 $nonce = 'theme-upload'; 187 $url = add_query_arg(array('package' => $file_upload->filename), 'update.php?action=upload-theme'); 188 $type = 'upload'; //Install plugin type, From Web or an Upload. 189 190 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); 191 $upgrader->install( $file_upload->package ); 192 193 include ('admin-footer.php'); 194 195 } else { 196 do_action('update-custom_' . $action); 197 } 198 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 8 00:19:48 2010 | Cross-referenced by PHPXref 0.7 |