WordPress 3.0 beta 1 documentation kindly provided to you by Hay Kranen
| [ Index ] |
PHP Cross Reference of WordPress 3.0 beta 1 |
|
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[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 ( 'update-selected' == $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( 'bulk-update-plugins' ); 24 25 if ( isset( $_GET['plugins'] ) ) 26 $plugins = explode( ',', stripslashes($_GET['plugins']) ); 27 elseif ( isset( $_POST['checked'] ) ) 28 $plugins = (array) $_POST['checked']; 29 else 30 $plugins = array(); 31 32 $plugins = array_map('urldecode', $plugins); 33 34 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); 35 $nonce = 'bulk-update-plugins'; 36 37 require_once ( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 38 wp_enqueue_script('jquery'); 39 iframe_header(); 40 41 $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); 42 $upgrader->bulk_upgrade( $plugins ); 43 44 iframe_footer(); 45 46 } elseif ( 'upgrade-plugin' == $action ) { 47 if ( ! current_user_can('update_plugins') ) 48 wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); 49 50 check_admin_referer('upgrade-plugin_' . $plugin); 51 52 $title = __('Upgrade Plugin'); 53 $parent_file = 'plugins.php'; 54 $submenu_file = 'plugins.php'; 55 require_once ('admin-header.php'); 56 57 $nonce = 'upgrade-plugin_' . $plugin; 58 $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin; 59 60 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); 61 $upgrader->upgrade($plugin); 62 63 include ('admin-footer.php'); 64 65 } elseif ('activate-plugin' == $action ) { 66 if ( ! current_user_can('update_plugins') ) 67 wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); 68 69 check_admin_referer('activate-plugin_' . $plugin); 70 if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { 71 wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); 72 activate_plugin($plugin); 73 wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); 74 die(); 75 } 76 iframe_header( __('Plugin Reactivation'), true ); 77 if ( isset($_GET['success']) ) 78 echo '<p>' . __('Plugin reactivated successfully.') . '</p>'; 79 80 if ( isset($_GET['failure']) ){ 81 echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; 82 83 if ( defined('E_RECOVERABLE_ERROR') ) 84 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); 85 else 86 error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING); 87 88 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. 89 include(WP_PLUGIN_DIR . '/' . $plugin); 90 } 91 iframe_footer(); 92 } elseif ( 'install-plugin' == $action ) { 93 94 if ( ! current_user_can('install_plugins') ) 95 wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); 96 97 include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. 98 99 check_admin_referer('install-plugin_' . $plugin); 100 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 101 102 if ( is_wp_error($api) ) 103 wp_die($api); 104 105 $title = __('Plugin Install'); 106 $parent_file = 'plugins.php'; 107 $submenu_file = 'plugin-install.php'; 108 require_once ('admin-header.php'); 109 110 $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ); 111 $nonce = 'install-plugin_' . $plugin; 112 $url = 'update.php?action=install-plugin&plugin=' . $plugin; 113 $type = 'web'; //Install plugin type, From Web or an Upload. 114 115 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); 116 $upgrader->install($api->download_link); 117 118 include ('admin-footer.php'); 119 120 } elseif ( 'upload-plugin' == $action ) { 121 122 if ( ! current_user_can('install_plugins') ) 123 wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); 124 125 check_admin_referer('plugin-upload'); 126 127 $file_upload = new File_Upload_Upgrader('pluginzip', 'package'); 128 129 $title = __('Upload Plugin'); 130 $parent_file = 'plugins.php'; 131 $submenu_file = 'plugin-install.php'; 132 require_once ('admin-header.php'); 133 134 $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); 135 $nonce = 'plugin-upload'; 136 $url = add_query_arg(array('package' => $file_upload->filename ), 'update.php?action=upload-plugin'); 137 $type = 'upload'; //Install plugin type, From Web or an Upload. 138 139 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); 140 $upgrader->install( $file_upload->package ); 141 142 include ('admin-footer.php'); 143 144 } elseif ( 'upgrade-theme' == $action ) { 145 146 if ( ! current_user_can('update_themes') ) 147 wp_die(__('You do not have sufficient permissions to update themes for this blog.')); 148 149 check_admin_referer('upgrade-theme_' . $theme); 150 151 add_thickbox(); 152 wp_enqueue_script('theme-preview'); 153 $title = __('Upgrade Theme'); 154 $parent_file = 'themes.php'; 155 $submenu_file = 'themes.php'; 156 require_once ('admin-header.php'); 157 158 $nonce = 'upgrade-theme_' . $theme; 159 $url = 'update.php?action=upgrade-theme&theme=' . $theme; 160 161 $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) ); 162 $upgrader->upgrade($theme); 163 164 include ('admin-footer.php'); 165 } elseif ( 'update-selected-themes' == $action ) { 166 if ( ! current_user_can( 'update_themes' ) ) 167 wp_die( __( 'You do not have sufficient permissions to update themes for this blog.' ) ); 168 169 check_admin_referer( 'bulk-update-themes' ); 170 171 if ( isset( $_GET['themes'] ) ) 172 $themes = explode( ',', stripslashes($_GET['themes']) ); 173 elseif ( isset( $_POST['checked'] ) ) 174 $themes = (array) $_POST['checked']; 175 else 176 $themes = array(); 177 178 $themes = array_map('urldecode', $themes); 179 180 $url = 'update.php?action=update-selected-themes&themess=' . urlencode(implode(',', $themes)); 181 $nonce = 'bulk-update-themes'; 182 183 require_once ( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 184 wp_enqueue_script('jquery'); 185 iframe_header(); 186 187 $upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); 188 $upgrader->bulk_upgrade( $themes ); 189 190 iframe_footer(); 191 } elseif ( 'install-theme' == $action ) { 192 193 if ( ! current_user_can('install_themes') ) 194 wp_die(__('You do not have sufficient permissions to install themes for this blog.')); 195 196 include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api.. 197 198 check_admin_referer('install-theme_' . $theme); 199 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 200 201 if ( is_wp_error($api) ) 202 wp_die($api); 203 204 add_thickbox(); 205 wp_enqueue_script('theme-preview'); 206 $title = __('Install Themes'); 207 $parent_file = 'themes.php'; 208 $submenu_file = 'themes.php'; 209 require_once ('admin-header.php'); 210 211 $title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version ); 212 $nonce = 'install-theme_' . $theme; 213 $url = 'update.php?action=install-theme&theme=' . $theme; 214 $type = 'web'; //Install theme type, From Web or an Upload. 215 216 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); 217 $upgrader->install($api->download_link); 218 219 include ('admin-footer.php'); 220 221 } elseif ( 'upload-theme' == $action ) { 222 223 if ( ! current_user_can('install_themes') ) 224 wp_die(__('You do not have sufficient permissions to install themes for this blog.')); 225 226 check_admin_referer('theme-upload'); 227 228 $file_upload = new File_Upload_Upgrader('themezip', 'package'); 229 230 $title = __('Upload Theme'); 231 $parent_file = 'themes.php'; 232 $submenu_file = 'theme-install.php'; 233 add_thickbox(); 234 wp_enqueue_script('theme-preview'); 235 require_once ('admin-header.php'); 236 237 $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); 238 $nonce = 'theme-upload'; 239 $url = add_query_arg(array('package' => $file_upload->filename), 'update.php?action=upload-theme'); 240 $type = 'upload'; //Install plugin type, From Web or an Upload. 241 242 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); 243 $upgrader->install( $file_upload->package ); 244 245 include ('admin-footer.php'); 246 247 } else { 248 do_action('update-custom_' . $action); 249 } 250 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Apr 5 14:26:09 2010 | Cross-referenced by PHPXref 0.7 |