wp/wp-admin/plugins.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    20 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
    20 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
    21 $s = isset($_REQUEST['s']) ? urlencode($_REQUEST['s']) : '';
    21 $s = isset($_REQUEST['s']) ? urlencode($_REQUEST['s']) : '';
    22 
    22 
    23 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    23 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    24 $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
    24 $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
       
    25 
       
    26 wp_enqueue_script( 'updates' );
    25 
    27 
    26 if ( $action ) {
    28 if ( $action ) {
    27 
    29 
    28 	switch ( $action ) {
    30 	switch ( $action ) {
    29 		case 'activate':
    31 		case 'activate':
    58 				wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
    60 				wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
    59 			} else {
    61 			} else {
    60 				wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
    62 				wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
    61 			}
    63 			}
    62 			exit;
    64 			exit;
    63 			break;
    65 
    64 		case 'activate-selected':
    66 		case 'activate-selected':
    65 			if ( ! current_user_can('activate_plugins') )
    67 			if ( ! current_user_can('activate_plugins') )
    66 				wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
    68 				wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
    67 
    69 
    68 			check_admin_referer('bulk-plugins');
    70 			check_admin_referer('bulk-plugins');
    69 
    71 
    70 			$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    72 			$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    71 
    73 
    72 			// Only activate plugins which are not already active.
       
    73 			if ( is_network_admin() ) {
    74 			if ( is_network_admin() ) {
    74 				foreach ( $plugins as $i => $plugin ) {
    75 				foreach ( $plugins as $i => $plugin ) {
    75 					if ( is_plugin_active_for_network( $plugin ) )
    76 					// Only activate plugins which are not already network activated.
       
    77 					if ( is_plugin_active_for_network( $plugin ) ) {
    76 						unset( $plugins[ $i ] );
    78 						unset( $plugins[ $i ] );
       
    79 					}
    77 				}
    80 				}
    78 			} else {
    81 			} else {
    79 				foreach ( $plugins as $i => $plugin ) {
    82 				foreach ( $plugins as $i => $plugin ) {
    80 					if ( is_plugin_active( $plugin ) || is_network_only_plugin( $plugin ) )
    83 					// Only activate plugins which are not already active and are not network-only when on Multisite.
       
    84 					if ( is_plugin_active( $plugin ) || ( is_multisite() && is_network_only_plugin( $plugin ) ) ) {
    81 						unset( $plugins[ $i ] );
    85 						unset( $plugins[ $i ] );
       
    86 					}
    82 				}
    87 				}
    83 			}
    88 			}
    84 
    89 
    85 			if ( empty($plugins) ) {
    90 			if ( empty($plugins) ) {
    86 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    91 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    96 				update_option( 'recently_activated', $recent );
   101 				update_option( 'recently_activated', $recent );
    97 			}
   102 			}
    98 
   103 
    99 			wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
   104 			wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
   100 			exit;
   105 			exit;
   101 			break;
   106 
   102 		case 'update-selected' :
   107 		case 'update-selected' :
   103 
   108 
   104 			check_admin_referer( 'bulk-plugins' );
   109 			check_admin_referer( 'bulk-plugins' );
   105 
   110 
   106 			if ( isset( $_GET['plugins'] ) )
   111 			if ( isset( $_GET['plugins'] ) )
   111 				$plugins = array();
   116 				$plugins = array();
   112 
   117 
   113 			$title = __( 'Update Plugins' );
   118 			$title = __( 'Update Plugins' );
   114 			$parent_file = 'plugins.php';
   119 			$parent_file = 'plugins.php';
   115 
   120 
       
   121 			wp_enqueue_script( 'updates' );
   116 			require_once(ABSPATH . 'wp-admin/admin-header.php');
   122 			require_once(ABSPATH . 'wp-admin/admin-header.php');
   117 
   123 
   118 			echo '<div class="wrap">';
   124 			echo '<div class="wrap">';
   119 			screen_icon();
       
   120 			echo '<h2>' . esc_html( $title ) . '</h2>';
   125 			echo '<h2>' . esc_html( $title ) . '</h2>';
   121 
   126 
   122 			$url = self_admin_url('update.php?action=update-selected&amp;plugins=' . urlencode( join(',', $plugins) ));
   127 			$url = self_admin_url('update.php?action=update-selected&amp;plugins=' . urlencode( join(',', $plugins) ));
   123 			$url = wp_nonce_url($url, 'bulk-update-plugins');
   128 			$url = wp_nonce_url($url, 'bulk-update-plugins');
   124 
   129 
   125 			echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
   130 			echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
   126 			echo '</div>';
   131 			echo '</div>';
   127 			require_once(ABSPATH . 'wp-admin/admin-footer.php');
   132 			require_once(ABSPATH . 'wp-admin/admin-footer.php');
   128 			exit;
   133 			exit;
   129 			break;
   134 
   130 		case 'error_scrape':
   135 		case 'error_scrape':
   131 			if ( ! current_user_can('activate_plugins') )
   136 			if ( ! current_user_can('activate_plugins') )
   132 				wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
   137 				wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
   133 
   138 
   134 			check_admin_referer('plugin-activation-error_' . $plugin);
   139 			check_admin_referer('plugin-activation-error_' . $plugin);
   142 			}
   147 			}
   143 
   148 
   144 			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
   149 			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
   145 			// Go back to "sandbox" scope so we get the same errors as before
   150 			// Go back to "sandbox" scope so we get the same errors as before
   146 			function plugin_sandbox_scrape( $plugin ) {
   151 			function plugin_sandbox_scrape( $plugin ) {
       
   152 				wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
   147 				include( WP_PLUGIN_DIR . '/' . $plugin );
   153 				include( WP_PLUGIN_DIR . '/' . $plugin );
   148 			}
   154 			}
   149 			plugin_sandbox_scrape( $plugin );
   155 			plugin_sandbox_scrape( $plugin );
   150 			do_action('activate_' . $plugin);
   156 			/** This action is documented in wp-admin/includes/plugin.php */
   151 			exit;
   157 			do_action( "activate_{$plugin}" );
   152 			break;
   158 			exit;
       
   159 
   153 		case 'deactivate':
   160 		case 'deactivate':
   154 			if ( ! current_user_can('activate_plugins') )
   161 			if ( ! current_user_can('activate_plugins') )
   155 				wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
   162 				wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
   156 
   163 
   157 			check_admin_referer('deactivate-plugin_' . $plugin);
   164 			check_admin_referer('deactivate-plugin_' . $plugin);
   167 			if ( headers_sent() )
   174 			if ( headers_sent() )
   168 				echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
   175 				echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
   169 			else
   176 			else
   170 				wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") );
   177 				wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") );
   171 			exit;
   178 			exit;
   172 			break;
   179 
   173 		case 'deactivate-selected':
   180 		case 'deactivate-selected':
   174 			if ( ! current_user_can('activate_plugins') )
   181 			if ( ! current_user_can('activate_plugins') )
   175 				wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
   182 				wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
   176 
   183 
   177 			check_admin_referer('bulk-plugins');
   184 			check_admin_referer('bulk-plugins');
   198 				update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
   205 				update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
   199 			}
   206 			}
   200 
   207 
   201 			wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
   208 			wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
   202 			exit;
   209 			exit;
   203 			break;
   210 
   204 		case 'delete-selected':
   211 		case 'delete-selected':
   205 			if ( ! current_user_can('delete_plugins') )
   212 			if ( ! current_user_can('delete_plugins') ) {
   206 				wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
   213 				wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
       
   214 			}
   207 
   215 
   208 			check_admin_referer('bulk-plugins');
   216 			check_admin_referer('bulk-plugins');
   209 
   217 
   210 			//$_POST = from the plugin form; $_GET = from the FTP details screen.
   218 			//$_POST = from the plugin form; $_GET = from the FTP details screen.
   211 			$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
   219 			$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
   230 				?>
   238 				?>
   231 			<div class="wrap">
   239 			<div class="wrap">
   232 				<?php
   240 				<?php
   233 					$files_to_delete = $plugin_info = array();
   241 					$files_to_delete = $plugin_info = array();
   234 					$have_non_network_plugins = false;
   242 					$have_non_network_plugins = false;
       
   243 					$plugin_translations = wp_get_installed_translations( 'plugins' );
   235 					foreach ( (array) $plugins as $plugin ) {
   244 					foreach ( (array) $plugins as $plugin ) {
   236 						if ( '.' == dirname($plugin) ) {
   245 						$plugin_slug = dirname( $plugin );
       
   246 
       
   247 						if ( '.' == $plugin_slug ) {
   237 							$files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
   248 							$files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
   238 							if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) {
   249 							if ( $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ) {
   239 								$plugin_info[ $plugin ] = $data;
   250 								$plugin_info[ $plugin ] = $data;
   240 								$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
   251 								$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
   241 								if ( ! $plugin_info[ $plugin ]['Network'] )
   252 								if ( ! $plugin_info[ $plugin ]['Network'] ) {
   242 									$have_non_network_plugins = true;
   253 									$have_non_network_plugins = true;
       
   254 								}
   243 							}
   255 							}
   244 						} else {
   256 						} else {
   245 							// Locate all the files in that folder
   257 							// Locate all the files in that folder.
   246 							$files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) );
   258 							$files = list_files( WP_PLUGIN_DIR . '/' . $plugin_slug );
   247 							if ( $files ) {
   259 							if ( $files ) {
   248 								$files_to_delete = array_merge($files_to_delete, $files);
   260 								$files_to_delete = array_merge( $files_to_delete, $files );
   249 							}
   261 							}
   250 							// Get plugins list from that folder
   262 
   251 							if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
   263 							// Get plugins list from that folder.
       
   264 							if ( $folder_plugins = get_plugins( '/' . $plugin_slug ) ) {
   252 								foreach( $folder_plugins as $plugin_file => $data ) {
   265 								foreach( $folder_plugins as $plugin_file => $data ) {
   253 									$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
   266 									$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
   254 									$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
   267 									$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
   255 									if ( ! $plugin_info[ $plugin_file ]['Network'] )
   268 									if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
   256 										$have_non_network_plugins = true;
   269 										$have_non_network_plugins = true;
       
   270 									}
       
   271 								}
       
   272 							}
       
   273 
       
   274 							// Add translation files.
       
   275 							if ( ! empty( $plugin_translations[ $plugin_slug ] ) ) {
       
   276 								$translations = $plugin_translations[ $plugin_slug ];
       
   277 
       
   278 								foreach ( $translations as $translation => $data ) {
       
   279 									$files_to_delete[] = $plugin_slug . '-' . $translation . '.po';
       
   280 									$files_to_delete[] = $plugin_slug . '-' . $translation . '.mo';
   257 								}
   281 								}
   258 							}
   282 							}
   259 						}
   283 						}
   260 					}
   284 					}
   261 					screen_icon();
       
   262 					$plugins_to_delete = count( $plugin_info );
   285 					$plugins_to_delete = count( $plugin_info );
   263 					echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>';
       
   264 				?>
   286 				?>
   265 				<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
   287 				<?php if ( 1 == $plugins_to_delete ) : ?>
   266 				<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This plugin may be active on other sites in the network.', 'These plugins may be active on other sites in the network.', $plugins_to_delete ); ?></p></div>
   288 					<h2><?php _e( 'Delete Plugin' ); ?></h2>
       
   289 					<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
       
   290 						<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div>
       
   291 					<?php endif; ?>
       
   292 					<p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
       
   293 				<?php else: ?>
       
   294 					<h2><?php _e( 'Delete Plugins' ); ?></h2>
       
   295 					<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
       
   296 						<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div>
       
   297 					<?php endif; ?>
       
   298 					<p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
   267 				<?php endif; ?>
   299 				<?php endif; ?>
   268 				<p><?php echo _n( 'You are about to remove the following plugin:', 'You are about to remove the following plugins:', $plugins_to_delete ); ?></p>
       
   269 					<ul class="ul-disc">
   300 					<ul class="ul-disc">
   270 						<?php
   301 						<?php
   271 						$data_to_delete = false;
   302 						$data_to_delete = false;
   272 						foreach ( $plugin_info as $plugin ) {
   303 						foreach ( $plugin_info as $plugin ) {
   273 							if ( $plugin['is_uninstallable'] ) {
   304 							if ( $plugin['is_uninstallable'] ) {
   289 				?></p>
   320 				?></p>
   290 				<form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
   321 				<form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
   291 					<input type="hidden" name="verify-delete" value="1" />
   322 					<input type="hidden" name="verify-delete" value="1" />
   292 					<input type="hidden" name="action" value="delete-selected" />
   323 					<input type="hidden" name="action" value="delete-selected" />
   293 					<?php
   324 					<?php
   294 						foreach ( (array) $plugins as $plugin )
   325 						foreach ( (array) $plugins as $plugin ) {
   295 							echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
   326 							echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
       
   327 						}
   296 					?>
   328 					?>
   297 					<?php wp_nonce_field('bulk-plugins') ?>
   329 					<?php wp_nonce_field('bulk-plugins') ?>
   298 					<?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>
   330 					<?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>
   299 				</form>
   331 				</form>
   300 				<form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
   332 				<?php
       
   333 				$referer = wp_get_referer();
       
   334 				?>
       
   335 				<form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
   301 					<?php submit_button( __( 'No, Return me to the plugin list' ), 'button', 'submit', false ); ?>
   336 					<?php submit_button( __( 'No, Return me to the plugin list' ), 'button', 'submit', false ); ?>
   302 				</form>
   337 				</form>
   303 
   338 
   304 				<p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
   339 				<p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
   305 				<div id="files-list" style="display:none;">
   340 				<div id="files-list" style="display:none;">
   306 					<ul class="code">
   341 					<ul class="code">
   307 					<?php
   342 					<?php
   308 						foreach ( (array)$files_to_delete as $file )
   343 						foreach ( (array) $files_to_delete as $file ) {
   309 							echo '<li>' . esc_html(str_replace(WP_PLUGIN_DIR, '', $file)) . '</li>';
   344 							echo '<li>' . esc_html( str_replace( WP_PLUGIN_DIR, '', $file ) ) . '</li>';
       
   345 						}
   310 					?>
   346 					?>
   311 					</ul>
   347 					</ul>
   312 				</div>
   348 				</div>
   313 			</div>
   349 			</div>
   314 				<?php
   350 				<?php
   318 			$delete_result = delete_plugins($plugins);
   354 			$delete_result = delete_plugins($plugins);
   319 
   355 
   320 			set_transient('plugins_delete_result_' . $user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
   356 			set_transient('plugins_delete_result_' . $user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
   321 			wp_redirect( self_admin_url("plugins.php?deleted=true&plugin_status=$status&paged=$page&s=$s") );
   357 			wp_redirect( self_admin_url("plugins.php?deleted=true&plugin_status=$status&paged=$page&s=$s") );
   322 			exit;
   358 			exit;
   323 			break;
   359 
   324 		case 'clear-recent-list':
   360 		case 'clear-recent-list':
   325 			if ( ! is_network_admin() )
   361 			if ( ! is_network_admin() )
   326 				update_option( 'recently_activated', array() );
   362 				update_option( 'recently_activated', array() );
   327 			break;
   363 			break;
   328 	}
   364 	}
   331 $wp_list_table->prepare_items();
   367 $wp_list_table->prepare_items();
   332 
   368 
   333 wp_enqueue_script('plugin-install');
   369 wp_enqueue_script('plugin-install');
   334 add_thickbox();
   370 add_thickbox();
   335 
   371 
   336 add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999 ) );
   372 add_screen_option( 'per_page', array( 'default' => 999 ) );
   337 
   373 
   338 get_current_screen()->add_help_tab( array(
   374 get_current_screen()->add_help_tab( array(
   339 'id'		=> 'overview',
   375 'id'		=> 'overview',
   340 'title'		=> __('Overview'),
   376 'title'		=> __('Overview'),
   341 'content'	=>
   377 'content'	=>
   342 	'<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
   378 	'<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
   343 	'<p>' . sprintf(__('You can find additional plugins for your site by using the <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="%2$s" target="_blank">WordPress Plugin Directory</a> directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your <code>/wp-content/plugins</code> directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/plugins/') . '</p>'
   379 	'<p>' . sprintf(__('You can find additional plugins for your site by using the <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="%2$s" target="_blank">WordPress Plugin Directory</a> directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your <code>/wp-content/plugins</code> directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'https://wordpress.org/plugins/') . '</p>'
   344 ) );
   380 ) );
   345 get_current_screen()->add_help_tab( array(
   381 get_current_screen()->add_help_tab( array(
   346 'id'		=> 'compatibility-problems',
   382 'id'		=> 'compatibility-problems',
   347 'title'		=> __('Troubleshooting'),
   383 'title'		=> __('Troubleshooting'),
   348 'content'	=>
   384 'content'	=>
   350 	'<p>' . sprintf( __('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR) . '</p>'
   386 	'<p>' . sprintf( __('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR) . '</p>'
   351 ) );
   387 ) );
   352 
   388 
   353 get_current_screen()->set_help_sidebar(
   389 get_current_screen()->set_help_sidebar(
   354 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   390 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   355 	'<p>' . __('<a href="http://codex.wordpress.org/Managing_Plugins#Plugin_Management" target="_blank">Documentation on Managing Plugins</a>') . '</p>' .
   391 	'<p>' . __('<a href="https://codex.wordpress.org/Managing_Plugins#Plugin_Management" target="_blank">Documentation on Managing Plugins</a>') . '</p>' .
   356 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   392 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   357 );
   393 );
   358 
   394 
   359 $title = __('Plugins');
   395 $title = __('Plugins');
   360 $parent_file = 'plugins.php';
   396 $parent_file = 'plugins.php';
   361 
   397 
   374 	elseif ( isset($_GET['charsout']) )
   410 	elseif ( isset($_GET['charsout']) )
   375 		$errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
   411 		$errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
   376 	else
   412 	else
   377 		$errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
   413 		$errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
   378 	?>
   414 	?>
   379 	<div id="message" class="updated"><p><?php echo $errmsg; ?></p>
   415 	<div id="message" class="error"><p><?php echo $errmsg; ?></p>
   380 	<?php
   416 	<?php
   381 		if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
   417 		if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
   382 	<iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>
   418 	<iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>
   383 	<?php
   419 	<?php
   384 		}
   420 		}
   385 	?>
   421 	?>
   386 	</div>
   422 	</div>
   387 <?php elseif ( isset($_GET['deleted']) ) :
   423 <?php elseif ( isset($_GET['deleted']) ) :
   388 		$delete_result = get_transient('plugins_delete_result_'.$user_ID);
   424 		$delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
   389 		delete_transient('plugins_delete_result'); //Delete it once we're done.
   425 		// Delete it once we're done.
       
   426 		delete_transient( 'plugins_delete_result_' . $user_ID );
   390 
   427 
   391 		if ( is_wp_error($delete_result) ) : ?>
   428 		if ( is_wp_error($delete_result) ) : ?>
   392 		<div id="message" class="updated"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
   429 		<div id="message" class="error notice is-dismissible"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
   393 		<?php else : ?>
   430 		<?php else : ?>
   394 		<div id="message" class="updated"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div>
   431 		<div id="message" class="updated notice is-dismissible"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div>
   395 		<?php endif; ?>
   432 		<?php endif; ?>
   396 <?php elseif ( isset($_GET['activate']) ) : ?>
   433 <?php elseif ( isset($_GET['activate']) ) : ?>
   397 	<div id="message" class="updated"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
   434 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
   398 <?php elseif (isset($_GET['activate-multi'])) : ?>
   435 <?php elseif (isset($_GET['activate-multi'])) : ?>
   399 	<div id="message" class="updated"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
   436 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
   400 <?php elseif ( isset($_GET['deactivate']) ) : ?>
   437 <?php elseif ( isset($_GET['deactivate']) ) : ?>
   401 	<div id="message" class="updated"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
   438 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
   402 <?php elseif (isset($_GET['deactivate-multi'])) : ?>
   439 <?php elseif (isset($_GET['deactivate-multi'])) : ?>
   403 	<div id="message" class="updated"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
   440 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
   404 <?php elseif ( 'update-selected' == $action ) : ?>
   441 <?php elseif ( 'update-selected' == $action ) : ?>
   405 	<div id="message" class="updated"><p><?php _e('No out of date plugins were selected.'); ?></p></div>
   442 	<div id="message" class="updated notice is-dismissible"><p><?php _e('No out of date plugins were selected.'); ?></p></div>
   406 <?php endif; ?>
   443 <?php endif; ?>
   407 
   444 
   408 <div class="wrap">
   445 <div class="wrap">
   409 <?php screen_icon(); ?>
       
   410 <h2><?php echo esc_html( $title );
   446 <h2><?php echo esc_html( $title );
   411 if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
   447 if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
   412  <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a>
   448  <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a>
   413 <?php }
   449 <?php }
   414 if ( $s )
   450 if ( $s )
   415 	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
   451 	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
   416 </h2>
   452 </h2>
   417 
   453 
   418 <?php do_action( 'pre_current_active_plugins', $plugins['all'] ) ?>
   454 <?php
       
   455 /**
       
   456  * Fires before the plugins list table is rendered.
       
   457  *
       
   458  * This hook also fires before the plugins list table is rendered in the Network Admin.
       
   459  *
       
   460  * Please note: The 'active' portion of the hook name does not refer to whether the current
       
   461  * view is for active plugins, but rather all plugins actively-installed.
       
   462  *
       
   463  * @since 3.0.0
       
   464  *
       
   465  * @param array $plugins_all An array containing all installed plugins.
       
   466  */
       
   467 do_action( 'pre_current_active_plugins', $plugins['all'] );
       
   468 ?>
   419 
   469 
   420 <?php $wp_list_table->views(); ?>
   470 <?php $wp_list_table->views(); ?>
   421 
   471 
   422 <form method="get" action="">
   472 <form method="get">
   423 <?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?>
   473 <?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?>
   424 </form>
   474 </form>
   425 
   475 
   426 <form method="post" action="">
   476 <form method="post" id="bulk-action-form">
   427 
   477 
   428 <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
   478 <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
   429 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
   479 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
   430 
   480 
   431 <?php $wp_list_table->display(); ?>
   481 <?php $wp_list_table->display(); ?>
   432 </form>
   482 </form>
   433 
   483 
   434 </div>
   484 </div>
   435 
   485 
   436 <?php
   486 <?php
       
   487 wp_print_request_filesystem_credentials_modal();
       
   488 
   437 include(ABSPATH . 'wp-admin/admin-footer.php');
   489 include(ABSPATH . 'wp-admin/admin-footer.php');