wp/wp-admin/update.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    19 	$theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
    19 	$theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
    20 	$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    20 	$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    21 
    21 
    22 	if ( 'update-selected' == $action ) {
    22 	if ( 'update-selected' == $action ) {
    23 		if ( ! current_user_can( 'update_plugins' ) )
    23 		if ( ! current_user_can( 'update_plugins' ) )
    24 			wp_die( __( 'You do not have sufficient permissions to update plugins for this site.' ) );
    24 			wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
    25 
    25 
    26 		check_admin_referer( 'bulk-update-plugins' );
    26 		check_admin_referer( 'bulk-update-plugins' );
    27 
    27 
    28 		if ( isset( $_GET['plugins'] ) )
    28 		if ( isset( $_GET['plugins'] ) )
    29 			$plugins = explode( ',', stripslashes($_GET['plugins']) );
    29 			$plugins = explode( ',', stripslashes($_GET['plugins']) );
    45 
    45 
    46 		iframe_footer();
    46 		iframe_footer();
    47 
    47 
    48 	} elseif ( 'upgrade-plugin' == $action ) {
    48 	} elseif ( 'upgrade-plugin' == $action ) {
    49 		if ( ! current_user_can('update_plugins') )
    49 		if ( ! current_user_can('update_plugins') )
    50 			wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
    50 			wp_die(__('Sorry, you are not allowed to update plugins for this site.'));
    51 
    51 
    52 		check_admin_referer('upgrade-plugin_' . $plugin);
    52 		check_admin_referer('upgrade-plugin_' . $plugin);
    53 
    53 
    54 		$title = __('Update Plugin');
    54 		$title = __('Update Plugin');
    55 		$parent_file = 'plugins.php';
    55 		$parent_file = 'plugins.php';
    66 
    66 
    67 		include(ABSPATH . 'wp-admin/admin-footer.php');
    67 		include(ABSPATH . 'wp-admin/admin-footer.php');
    68 
    68 
    69 	} elseif ('activate-plugin' == $action ) {
    69 	} elseif ('activate-plugin' == $action ) {
    70 		if ( ! current_user_can('update_plugins') )
    70 		if ( ! current_user_can('update_plugins') )
    71 			wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
    71 			wp_die(__('Sorry, you are not allowed to update plugins for this site.'));
    72 
    72 
    73 		check_admin_referer('activate-plugin_' . $plugin);
    73 		check_admin_referer('activate-plugin_' . $plugin);
    74 		if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
    74 		if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
    75 			wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
    75 			wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
    76 			activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
    76 			activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
    91 		}
    91 		}
    92 		iframe_footer();
    92 		iframe_footer();
    93 	} elseif ( 'install-plugin' == $action ) {
    93 	} elseif ( 'install-plugin' == $action ) {
    94 
    94 
    95 		if ( ! current_user_can('install_plugins') )
    95 		if ( ! current_user_can('install_plugins') )
    96 			wp_die( __( 'You do not have sufficient permissions to install plugins on this site.' ) );
    96 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
    97 
    97 
    98 		include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
    98 		include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
    99 
    99 
   100 		check_admin_referer('install-plugin_' . $plugin);
   100 		check_admin_referer( 'install-plugin_' . $plugin );
   101 		$api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
   101 		$api = plugins_api( 'plugin_information', array(
   102 
   102 			'slug' => $plugin,
   103 		if ( is_wp_error($api) )
   103 			'fields' => array(
   104 	 		wp_die($api);
   104 				'short_description' => false,
   105 
   105 				'sections' => false,
   106 		$title = __('Plugin Install');
   106 				'requires' => false,
       
   107 				'rating' => false,
       
   108 				'ratings' => false,
       
   109 				'downloaded' => false,
       
   110 				'last_updated' => false,
       
   111 				'added' => false,
       
   112 				'tags' => false,
       
   113 				'compatibility' => false,
       
   114 				'homepage' => false,
       
   115 				'donate_link' => false,
       
   116 			),
       
   117 		) );
       
   118 
       
   119 		if ( is_wp_error( $api ) ) {
       
   120 	 		wp_die( $api );
       
   121 		}
       
   122 
       
   123 		$title = __('Plugin Installation');
   107 		$parent_file = 'plugins.php';
   124 		$parent_file = 'plugins.php';
   108 		$submenu_file = 'plugin-install.php';
   125 		$submenu_file = 'plugin-install.php';
   109 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   126 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   110 
   127 
   111 		$title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
   128 		$title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
   122 		include(ABSPATH . 'wp-admin/admin-footer.php');
   139 		include(ABSPATH . 'wp-admin/admin-footer.php');
   123 
   140 
   124 	} elseif ( 'upload-plugin' == $action ) {
   141 	} elseif ( 'upload-plugin' == $action ) {
   125 
   142 
   126 		if ( ! current_user_can( 'upload_plugins' ) ) {
   143 		if ( ! current_user_can( 'upload_plugins' ) ) {
   127 			wp_die( __( 'You do not have sufficient permissions to install plugins on this site.' ) );
   144 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   128 		}
   145 		}
   129 
   146 
   130 		check_admin_referer('plugin-upload');
   147 		check_admin_referer('plugin-upload');
   131 
   148 
   132 		$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
   149 		$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
   150 		include(ABSPATH . 'wp-admin/admin-footer.php');
   167 		include(ABSPATH . 'wp-admin/admin-footer.php');
   151 
   168 
   152 	} elseif ( 'upgrade-theme' == $action ) {
   169 	} elseif ( 'upgrade-theme' == $action ) {
   153 
   170 
   154 		if ( ! current_user_can('update_themes') )
   171 		if ( ! current_user_can('update_themes') )
   155 			wp_die(__('You do not have sufficient permissions to update themes for this site.'));
   172 			wp_die(__('Sorry, you are not allowed to update themes for this site.'));
   156 
   173 
   157 		check_admin_referer('upgrade-theme_' . $theme);
   174 		check_admin_referer('upgrade-theme_' . $theme);
   158 
   175 
   159 		wp_enqueue_script( 'customize-loader' );
       
   160 		wp_enqueue_script( 'updates' );
   176 		wp_enqueue_script( 'updates' );
   161 
   177 
   162 		$title = __('Update Theme');
   178 		$title = __('Update Theme');
   163 		$parent_file = 'themes.php';
   179 		$parent_file = 'themes.php';
   164 		$submenu_file = 'themes.php';
   180 		$submenu_file = 'themes.php';
   171 		$upgrader->upgrade($theme);
   187 		$upgrader->upgrade($theme);
   172 
   188 
   173 		include(ABSPATH . 'wp-admin/admin-footer.php');
   189 		include(ABSPATH . 'wp-admin/admin-footer.php');
   174 	} elseif ( 'update-selected-themes' == $action ) {
   190 	} elseif ( 'update-selected-themes' == $action ) {
   175 		if ( ! current_user_can( 'update_themes' ) )
   191 		if ( ! current_user_can( 'update_themes' ) )
   176 			wp_die( __( 'You do not have sufficient permissions to update themes for this site.' ) );
   192 			wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) );
   177 
   193 
   178 		check_admin_referer( 'bulk-update-themes' );
   194 		check_admin_referer( 'bulk-update-themes' );
   179 
   195 
   180 		if ( isset( $_GET['themes'] ) )
   196 		if ( isset( $_GET['themes'] ) )
   181 			$themes = explode( ',', stripslashes($_GET['themes']) );
   197 			$themes = explode( ',', stripslashes($_GET['themes']) );
   197 
   213 
   198 		iframe_footer();
   214 		iframe_footer();
   199 	} elseif ( 'install-theme' == $action ) {
   215 	} elseif ( 'install-theme' == $action ) {
   200 
   216 
   201 		if ( ! current_user_can('install_themes') )
   217 		if ( ! current_user_can('install_themes') )
   202 			wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
   218 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   203 
   219 
   204 		include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); //for themes_api..
   220 		include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); //for themes_api..
   205 
   221 
   206 		check_admin_referer( 'install-theme_' . $theme );
   222 		check_admin_referer( 'install-theme_' . $theme );
   207 		$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
   223 		$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
   208 
   224 
   209 		if ( is_wp_error($api) )
   225 		if ( is_wp_error( $api ) ) {
   210 	 		wp_die($api);
   226 			wp_die( $api );
   211 
   227 		}
   212 		wp_enqueue_script( 'customize-loader' );
       
   213 
   228 
   214 		$title = __('Install Themes');
   229 		$title = __('Install Themes');
   215 		$parent_file = 'themes.php';
   230 		$parent_file = 'themes.php';
   216 		$submenu_file = 'themes.php';
   231 		$submenu_file = 'themes.php';
   217 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   232 		require_once(ABSPATH . 'wp-admin/admin-header.php');
   227 		include(ABSPATH . 'wp-admin/admin-footer.php');
   242 		include(ABSPATH . 'wp-admin/admin-footer.php');
   228 
   243 
   229 	} elseif ( 'upload-theme' == $action ) {
   244 	} elseif ( 'upload-theme' == $action ) {
   230 
   245 
   231 		if ( ! current_user_can( 'upload_themes' ) ) {
   246 		if ( ! current_user_can( 'upload_themes' ) ) {
   232 			wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
   247 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   233 		}
   248 		}
   234 
   249 
   235 		check_admin_referer('theme-upload');
   250 		check_admin_referer('theme-upload');
   236 
   251 
   237 		$file_upload = new File_Upload_Upgrader('themezip', 'package');
   252 		$file_upload = new File_Upload_Upgrader('themezip', 'package');
   238 
       
   239 		wp_enqueue_script( 'customize-loader' );
       
   240 
   253 
   241 		$title = __('Upload Theme');
   254 		$title = __('Upload Theme');
   242 		$parent_file = 'themes.php';
   255 		$parent_file = 'themes.php';
   243 		$submenu_file = 'theme-install.php';
   256 		$submenu_file = 'theme-install.php';
   244 
   257