[44] | 1 | <?php
|
---|
| 2 | /**
|
---|
| 3 | * Plugins administration panel.
|
---|
| 4 | *
|
---|
| 5 | * @package WordPress
|
---|
| 6 | * @subpackage Administration
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | /** WordPress Administration Bootstrap */
|
---|
| 10 | require_once('admin.php');
|
---|
| 11 |
|
---|
| 12 | if ( isset($_POST['clear-recent-list']) )
|
---|
| 13 | $action = 'clear-recent-list';
|
---|
| 14 | elseif ( !empty($_REQUEST['action']) )
|
---|
| 15 | $action = $_REQUEST['action'];
|
---|
| 16 | elseif ( !empty($_REQUEST['action2']) )
|
---|
| 17 | $action = $_REQUEST['action2'];
|
---|
| 18 | else
|
---|
| 19 | $action = false;
|
---|
| 20 |
|
---|
| 21 | $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
|
---|
| 22 |
|
---|
| 23 | $default_status = get_user_option('plugins_last_view');
|
---|
| 24 | if ( empty($default_status) )
|
---|
| 25 | $default_status = 'all';
|
---|
| 26 | $status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status;
|
---|
| 27 | if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search')) )
|
---|
| 28 | $status = 'all';
|
---|
| 29 | if ( $status != $default_status && 'search' != $status )
|
---|
| 30 | update_usermeta($current_user->ID, 'plugins_last_view', $status);
|
---|
| 31 |
|
---|
| 32 | $page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
|
---|
| 33 |
|
---|
| 34 | //Clean up request URI from temporary args for screen options/paging uri's to work as expected.
|
---|
| 35 | $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
|
---|
| 36 |
|
---|
| 37 | if ( !empty($action) ) {
|
---|
| 38 | switch ( $action ) {
|
---|
| 39 | case 'activate':
|
---|
| 40 | check_admin_referer('activate-plugin_' . $plugin);
|
---|
| 41 |
|
---|
| 42 | $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
|
---|
| 43 | if ( is_wp_error( $result ) )
|
---|
| 44 | wp_die($result);
|
---|
| 45 |
|
---|
| 46 | $recent = (array)get_option('recently_activated');
|
---|
| 47 | if ( isset($recent[ $plugin ]) ) {
|
---|
| 48 | unset($recent[ $plugin ]);
|
---|
| 49 | update_option('recently_activated', $recent);
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above
|
---|
| 53 | exit;
|
---|
| 54 | break;
|
---|
| 55 | case 'activate-selected':
|
---|
| 56 | check_admin_referer('bulk-manage-plugins');
|
---|
| 57 |
|
---|
| 58 | $plugins = (array) $_POST['checked'];
|
---|
| 59 | $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active.
|
---|
| 60 | if ( empty($plugins) ) {
|
---|
| 61 | wp_redirect("plugins.php?plugin_status=$status&paged=$page");
|
---|
| 62 | exit;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | activate_plugins($plugins, 'plugins.php?error=true');
|
---|
| 66 |
|
---|
| 67 | $recent = (array)get_option('recently_activated');
|
---|
| 68 | foreach ( $plugins as $plugin => $time)
|
---|
| 69 | if ( isset($recent[ $plugin ]) )
|
---|
| 70 | unset($recent[ $plugin ]);
|
---|
| 71 |
|
---|
| 72 | update_option('recently_activated', $recent);
|
---|
| 73 |
|
---|
| 74 | wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page");
|
---|
| 75 | exit;
|
---|
| 76 | break;
|
---|
| 77 | case 'error_scrape':
|
---|
| 78 | check_admin_referer('plugin-activation-error_' . $plugin);
|
---|
| 79 |
|
---|
| 80 | $valid = validate_plugin($plugin);
|
---|
| 81 | if ( is_wp_error($valid) )
|
---|
| 82 | wp_die($valid);
|
---|
| 83 |
|
---|
| 84 | error_reporting( E_ALL ^ E_NOTICE );
|
---|
| 85 | @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
|
---|
| 86 | include(WP_PLUGIN_DIR . '/' . $plugin);
|
---|
| 87 | do_action('activate_' . $plugin);
|
---|
| 88 | exit;
|
---|
| 89 | break;
|
---|
| 90 | case 'deactivate':
|
---|
| 91 | check_admin_referer('deactivate-plugin_' . $plugin);
|
---|
| 92 | deactivate_plugins($plugin);
|
---|
| 93 | update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
|
---|
| 94 | wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page");
|
---|
| 95 | exit;
|
---|
| 96 | break;
|
---|
| 97 | case 'deactivate-selected':
|
---|
| 98 | check_admin_referer('bulk-manage-plugins');
|
---|
| 99 |
|
---|
| 100 | $plugins = (array) $_POST['checked'];
|
---|
| 101 | $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
|
---|
| 102 | if ( empty($plugins) ) {
|
---|
| 103 | wp_redirect("plugins.php?plugin_status=$status&paged=$page");
|
---|
| 104 | exit;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | deactivate_plugins($plugins);
|
---|
| 108 |
|
---|
| 109 | $deactivated = array();
|
---|
| 110 | foreach ( $plugins as $plugin )
|
---|
| 111 | $deactivated[ $plugin ] = time();
|
---|
| 112 |
|
---|
| 113 | update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
|
---|
| 114 | wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page");
|
---|
| 115 | exit;
|
---|
| 116 | break;
|
---|
| 117 | case 'delete-selected':
|
---|
| 118 | if ( ! current_user_can('delete_plugins') )
|
---|
| 119 | wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
|
---|
| 120 |
|
---|
| 121 | check_admin_referer('bulk-manage-plugins');
|
---|
| 122 |
|
---|
| 123 | $plugins = (array) $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen.
|
---|
| 124 | $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
|
---|
| 125 | if ( empty($plugins) ) {
|
---|
| 126 | wp_redirect("plugins.php?plugin_status=$status&paged=$page");
|
---|
| 127 | exit;
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | include(ABSPATH . 'wp-admin/update.php');
|
---|
| 131 |
|
---|
| 132 | $parent_file = 'plugins.php';
|
---|
| 133 |
|
---|
| 134 | if ( ! isset($_REQUEST['verify-delete']) ) {
|
---|
| 135 | wp_enqueue_script('jquery');
|
---|
| 136 | require_once('admin-header.php');
|
---|
| 137 | ?>
|
---|
| 138 | <div class="wrap">
|
---|
| 139 | <h2><?php _e('Delete Plugin(s)'); ?></h2>
|
---|
| 140 | <?php
|
---|
| 141 | $files_to_delete = $plugin_info = array();
|
---|
| 142 | foreach ( (array) $plugins as $plugin ) {
|
---|
| 143 | if ( '.' == dirname($plugin) ) {
|
---|
| 144 | $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
|
---|
| 145 | if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) )
|
---|
| 146 | $plugin_info[ $plugin ] = $data;
|
---|
| 147 | } else {
|
---|
| 148 | //Locate all the files in that folder:
|
---|
| 149 | $files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) );
|
---|
| 150 | if( $files ) {
|
---|
| 151 | $files_to_delete = array_merge($files_to_delete, $files);
|
---|
| 152 | }
|
---|
| 153 | //Get plugins list from that folder
|
---|
| 154 | if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) )
|
---|
| 155 | $plugin_info = array_merge($plugin_info, $folder_plugins);
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 | ?>
|
---|
| 159 | <p><?php _e('Deleting the selected plugins will remove the following plugin(s) and their files:'); ?></p>
|
---|
| 160 | <ul class="ul-disc">
|
---|
| 161 | <?php
|
---|
| 162 | foreach ( $plugin_info as $plugin )
|
---|
| 163 | echo '<li>', sprintf(__('<strong>%s</strong> by <em>%s</em>'), $plugin['Name'], $plugin['Author']), '</li>';
|
---|
| 164 | ?>
|
---|
| 165 | </ul>
|
---|
| 166 | <p><?php _e('Are you sure you wish to delete these files?') ?></p>
|
---|
| 167 | <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
|
---|
| 168 | <input type="hidden" name="verify-delete" value="1" />
|
---|
| 169 | <input type="hidden" name="action" value="delete-selected" />
|
---|
| 170 | <?php
|
---|
| 171 | foreach ( (array)$plugins as $plugin )
|
---|
| 172 | echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
|
---|
| 173 | ?>
|
---|
| 174 | <?php wp_nonce_field('bulk-manage-plugins') ?>
|
---|
| 175 | <input type="submit" name="submit" value="<?php esc_attr_e('Yes, Delete these files') ?>" class="button" />
|
---|
| 176 | </form>
|
---|
| 177 | <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
|
---|
| 178 | <input type="submit" name="submit" value="<?php esc_attr_e('No, Return me to the plugin list') ?>" class="button" />
|
---|
| 179 | </form>
|
---|
| 180 |
|
---|
| 181 | <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>
|
---|
| 182 | <div id="files-list" style="display:none;">
|
---|
| 183 | <ul class="code">
|
---|
| 184 | <?php
|
---|
| 185 | foreach ( (array)$files_to_delete as $file )
|
---|
| 186 | echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';
|
---|
| 187 | ?>
|
---|
| 188 | </ul>
|
---|
| 189 | </div>
|
---|
| 190 | </div>
|
---|
| 191 | <?php
|
---|
| 192 | require_once('admin-footer.php');
|
---|
| 193 | exit;
|
---|
| 194 | } //Endif verify-delete
|
---|
| 195 | $delete_result = delete_plugins($plugins);
|
---|
| 196 |
|
---|
| 197 | 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
|
---|
| 198 | wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page");
|
---|
| 199 | exit;
|
---|
| 200 | break;
|
---|
| 201 | case 'clear-recent-list':
|
---|
| 202 | update_option('recently_activated', array());
|
---|
| 203 | break;
|
---|
| 204 | }
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | wp_enqueue_script('plugin-install');
|
---|
| 208 | add_thickbox();
|
---|
| 209 |
|
---|
| 210 | $help = '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>';
|
---|
| 211 | $help .= '<p>' . sprintf(__('If something goes wrong with a plugin and you can’t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR) . '</p>';
|
---|
| 212 | $help .= '<p>' . sprintf(__('You can find additional plugins for your site by using the new <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> directly and installing manually. To <em>manually</em> install a plugin you generally just need to upload the plugin file into your <code>%2$s</code> directory. Once a plugin has been installed, you may activate it here.'), 'plugin-install.php', WP_PLUGIN_DIR) . '</p>';
|
---|
| 213 |
|
---|
| 214 | add_contextual_help('plugins', $help);
|
---|
| 215 |
|
---|
| 216 | $title = __('Manage Plugins');
|
---|
| 217 | require_once('admin-header.php');
|
---|
| 218 |
|
---|
| 219 | $invalid = validate_active_plugins();
|
---|
| 220 | if ( !empty($invalid) )
|
---|
| 221 | foreach ( $invalid as $plugin_file => $error )
|
---|
| 222 | echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>';
|
---|
| 223 | ?>
|
---|
| 224 |
|
---|
| 225 | <?php if ( isset($_GET['error']) ) : ?>
|
---|
| 226 | <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
|
---|
| 227 | <?php
|
---|
| 228 | if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
|
---|
| 229 | <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . esc_attr($plugin) . '&_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>
|
---|
| 230 | <?php
|
---|
| 231 | }
|
---|
| 232 | ?>
|
---|
| 233 | </div>
|
---|
| 234 | <?php elseif ( isset($_GET['deleted']) ) :
|
---|
| 235 | $delete_result = get_transient('plugins_delete_result_'.$user_ID);
|
---|
| 236 | delete_transient('plugins_delete_result'); //Delete it once we're done.
|
---|
| 237 |
|
---|
| 238 | if ( is_wp_error($delete_result) ) : ?>
|
---|
| 239 | <div id="message" class="updated fade"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
|
---|
| 240 | <?php else : ?>
|
---|
| 241 | <div id="message" class="updated fade"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div>
|
---|
| 242 | <?php endif; ?>
|
---|
| 243 | <?php elseif ( isset($_GET['activate']) ) : ?>
|
---|
| 244 | <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
|
---|
| 245 | <?php elseif (isset($_GET['activate-multi'])) : ?>
|
---|
| 246 | <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
|
---|
| 247 | <?php elseif ( isset($_GET['deactivate']) ) : ?>
|
---|
| 248 | <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
|
---|
| 249 | <?php elseif (isset($_GET['deactivate-multi'])) : ?>
|
---|
| 250 | <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
|
---|
| 251 | <?php endif; ?>
|
---|
| 252 |
|
---|
| 253 | <div class="wrap">
|
---|
| 254 | <?php screen_icon(); ?>
|
---|
| 255 | <h2><?php echo esc_html( $title ); ?></h2>
|
---|
| 256 |
|
---|
| 257 | <?php
|
---|
| 258 |
|
---|
| 259 | $all_plugins = get_plugins();
|
---|
| 260 | $search_plugins = array();
|
---|
| 261 | $active_plugins = array();
|
---|
| 262 | $inactive_plugins = array();
|
---|
| 263 | $recent_plugins = array();
|
---|
| 264 | $recently_activated = get_option('recently_activated', array());
|
---|
| 265 | $upgrade_plugins = array();
|
---|
| 266 |
|
---|
| 267 | set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
|
---|
| 268 |
|
---|
| 269 | // Clean out any plugins which were deactivated over a week ago.
|
---|
| 270 | foreach ( $recently_activated as $key => $time )
|
---|
| 271 | if ( $time + (7*24*60*60) < time() ) //1 week
|
---|
| 272 | unset($recently_activated[ $key ]);
|
---|
| 273 | if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
|
---|
| 274 | update_option('recently_activated', $recently_activated);
|
---|
| 275 | $current = get_transient( 'update_plugins' );
|
---|
| 276 |
|
---|
| 277 | foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
|
---|
| 278 |
|
---|
| 279 | //Translate, Apply Markup, Sanitize HTML
|
---|
| 280 | $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
|
---|
| 281 | $all_plugins[ $plugin_file ] = $plugin_data;
|
---|
| 282 |
|
---|
| 283 | //Filter into individual sections
|
---|
| 284 | if ( is_plugin_active($plugin_file) ) {
|
---|
| 285 | $active_plugins[ $plugin_file ] = $plugin_data;
|
---|
| 286 | } else {
|
---|
| 287 | if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
|
---|
| 288 | $recent_plugins[ $plugin_file ] = $plugin_data;
|
---|
| 289 | $inactive_plugins[ $plugin_file ] = $plugin_data;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | if ( isset( $current->response[ $plugin_file ] ) )
|
---|
| 293 | $upgrade_plugins[ $plugin_file ] = $plugin_data;
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 | $total_all_plugins = count($all_plugins);
|
---|
| 297 | $total_inactive_plugins = count($inactive_plugins);
|
---|
| 298 | $total_active_plugins = count($active_plugins);
|
---|
| 299 | $total_recent_plugins = count($recent_plugins);
|
---|
| 300 | $total_upgrade_plugins = count($upgrade_plugins);
|
---|
| 301 |
|
---|
| 302 | //Searching.
|
---|
| 303 | if ( isset($_GET['s']) ) {
|
---|
| 304 | function _search_plugins_filter_callback($plugin) {
|
---|
| 305 | static $term;
|
---|
| 306 | if ( is_null($term) )
|
---|
| 307 | $term = stripslashes($_GET['s']);
|
---|
| 308 | if ( stripos($plugin['Name'], $term) !== false ||
|
---|
| 309 | stripos($plugin['Description'], $term) !== false ||
|
---|
| 310 | stripos($plugin['Author'], $term) !== false ||
|
---|
| 311 | stripos($plugin['PluginURI'], $term) !== false ||
|
---|
| 312 | stripos($plugin['AuthorURI'], $term) !== false ||
|
---|
| 313 | stripos($plugin['Version'], $term) !== false )
|
---|
| 314 | return true;
|
---|
| 315 | else
|
---|
| 316 | return false;
|
---|
| 317 | }
|
---|
| 318 | $status = 'search';
|
---|
| 319 | $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback');
|
---|
| 320 | $total_search_plugins = count($search_plugins);
|
---|
| 321 | }
|
---|
| 322 |
|
---|
| 323 | $plugin_array_name = "${status}_plugins";
|
---|
| 324 | if ( empty($$plugin_array_name) && $status != 'all' ) {
|
---|
| 325 | $status = 'all';
|
---|
| 326 | $plugin_array_name = "${status}_plugins";
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | $plugins = &$$plugin_array_name;
|
---|
| 330 |
|
---|
| 331 | //Paging.
|
---|
| 332 | $total_this_page = "total_{$status}_plugins";
|
---|
| 333 | $total_this_page = $$total_this_page;
|
---|
| 334 | $plugins_per_page = get_user_option('plugins_per_page');
|
---|
| 335 | if ( empty($plugins_per_page) )
|
---|
| 336 | $plugins_per_page = 999;
|
---|
| 337 | $plugins_per_page = apply_filters('plugins_per_page', $plugins_per_page);
|
---|
| 338 |
|
---|
| 339 | $start = ($page - 1) * $plugins_per_page;
|
---|
| 340 |
|
---|
| 341 | $page_links = paginate_links( array(
|
---|
| 342 | 'base' => add_query_arg( 'paged', '%#%' ),
|
---|
| 343 | 'format' => '',
|
---|
| 344 | 'prev_text' => __('«'),
|
---|
| 345 | 'next_text' => __('»'),
|
---|
| 346 | 'total' => ceil($total_this_page / $plugins_per_page),
|
---|
| 347 | 'current' => $page
|
---|
| 348 | ));
|
---|
| 349 | $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
---|
| 350 | number_format_i18n( $start + 1 ),
|
---|
| 351 | number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ),
|
---|
| 352 | '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>',
|
---|
| 353 | $page_links
|
---|
| 354 | );
|
---|
| 355 |
|
---|
| 356 | /**
|
---|
| 357 | * @ignore
|
---|
| 358 | *
|
---|
| 359 | * @param array $plugins
|
---|
| 360 | * @param string $context
|
---|
| 361 | */
|
---|
| 362 | function print_plugins_table($plugins, $context = '') {
|
---|
| 363 | global $page;
|
---|
| 364 | ?>
|
---|
| 365 | <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
|
---|
| 366 | <thead>
|
---|
| 367 | <tr>
|
---|
| 368 | <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
|
---|
| 369 | <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
|
---|
| 370 | <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
|
---|
| 371 | </tr>
|
---|
| 372 | </thead>
|
---|
| 373 |
|
---|
| 374 | <tfoot>
|
---|
| 375 | <tr>
|
---|
| 376 | <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
|
---|
| 377 | <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
|
---|
| 378 | <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
|
---|
| 379 | </tr>
|
---|
| 380 | </tfoot>
|
---|
| 381 |
|
---|
| 382 | <tbody class="plugins">
|
---|
| 383 | <?php
|
---|
| 384 |
|
---|
| 385 | if ( empty($plugins) ) {
|
---|
| 386 | echo '<tr>
|
---|
| 387 | <td colspan="3">' . __('No plugins to show') . '</td>
|
---|
| 388 | </tr>';
|
---|
| 389 | }
|
---|
| 390 | foreach ( (array)$plugins as $plugin_file => $plugin_data) {
|
---|
| 391 | $actions = array();
|
---|
| 392 | $is_active = is_plugin_active($plugin_file);
|
---|
| 393 |
|
---|
| 394 | if ( $is_active )
|
---|
| 395 | $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
|
---|
| 396 | else
|
---|
| 397 | $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
|
---|
| 398 |
|
---|
| 399 | if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
|
---|
| 400 | $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
|
---|
| 401 |
|
---|
| 402 | if ( ! $is_active && current_user_can('delete_plugins') )
|
---|
| 403 | $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
|
---|
| 404 |
|
---|
| 405 | $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context );
|
---|
| 406 | $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
|
---|
| 407 | $action_count = count($actions);
|
---|
| 408 | $class = $is_active ? 'active' : 'inactive';
|
---|
| 409 | echo "
|
---|
| 410 | <tr class='$class'>
|
---|
| 411 | <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
|
---|
| 412 | <td class='plugin-title'><strong>{$plugin_data['Name']}</strong></td>
|
---|
| 413 | <td class='desc'><p>{$plugin_data['Description']}</p></td>
|
---|
| 414 | </tr>
|
---|
| 415 | <tr class='$class second'>
|
---|
| 416 | <td></td>
|
---|
| 417 | <td class='plugin-title'>";
|
---|
| 418 | echo '<div class="row-actions-visible">';
|
---|
| 419 | foreach ( $actions as $action => $link ) {
|
---|
| 420 | $sep = end($actions) == $link ? '' : ' | ';
|
---|
| 421 | echo "<span class='$action'>$link$sep</span>";
|
---|
| 422 | }
|
---|
| 423 | echo "</div></td>
|
---|
| 424 | <td class='desc'>";
|
---|
| 425 | $plugin_meta = array();
|
---|
| 426 | if ( !empty($plugin_data['Version']) )
|
---|
| 427 | $plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']);
|
---|
| 428 | if ( !empty($plugin_data['Author']) ) {
|
---|
| 429 | $author = $plugin_data['Author'];
|
---|
| 430 | if ( !empty($plugin_data['AuthorURI']) )
|
---|
| 431 | $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
|
---|
| 432 | $plugin_meta[] = sprintf( __('By %s'), $author );
|
---|
| 433 | }
|
---|
| 434 | if ( ! empty($plugin_data['PluginURI']) )
|
---|
| 435 | $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>';
|
---|
| 436 |
|
---|
| 437 | $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
|
---|
| 438 | echo implode(' | ', $plugin_meta);
|
---|
| 439 | echo "</td>
|
---|
| 440 | </tr>\n";
|
---|
| 441 |
|
---|
| 442 | do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context );
|
---|
| 443 | do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context );
|
---|
| 444 | }
|
---|
| 445 | ?>
|
---|
| 446 | </tbody>
|
---|
| 447 | </table>
|
---|
| 448 | <?php
|
---|
| 449 | } //End print_plugins_table()
|
---|
| 450 |
|
---|
| 451 | /**
|
---|
| 452 | * @ignore
|
---|
| 453 | *
|
---|
| 454 | * @param string $context
|
---|
| 455 | */
|
---|
| 456 | function print_plugin_actions($context, $field_name = 'action' ) {
|
---|
| 457 | ?>
|
---|
| 458 | <div class="alignleft actions">
|
---|
| 459 | <select name="<?php echo $field_name; ?>">
|
---|
| 460 | <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
---|
| 461 | <?php if ( 'active' != $context ) : ?>
|
---|
| 462 | <option value="activate-selected"><?php _e('Activate'); ?></option>
|
---|
| 463 | <?php endif; ?>
|
---|
| 464 | <?php if ( 'inactive' != $context && 'recent' != $context ) : ?>
|
---|
| 465 | <option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
|
---|
| 466 | <?php endif; ?>
|
---|
| 467 | <?php if ( current_user_can('delete_plugins') && ( 'active' != $context ) ) : ?>
|
---|
| 468 | <option value="delete-selected"><?php _e('Delete'); ?></option>
|
---|
| 469 | <?php endif; ?>
|
---|
| 470 | </select>
|
---|
| 471 | <input type="submit" name="doaction_active" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary action" />
|
---|
| 472 | <?php if( 'recent' == $context ) : ?>
|
---|
| 473 | <input type="submit" name="clear-recent-list" value="<?php esc_attr_e('Clear List') ?>" class="button-secondary" />
|
---|
| 474 | <?php endif; ?>
|
---|
| 475 | </div>
|
---|
| 476 | <?php
|
---|
| 477 | }
|
---|
| 478 | ?>
|
---|
| 479 |
|
---|
| 480 | <form method="get" action="">
|
---|
| 481 | <p class="search-box">
|
---|
| 482 | <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label>
|
---|
| 483 | <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" />
|
---|
| 484 | <input type="submit" value="<?php esc_attr_e( 'Search Plugins' ); ?>" class="button" />
|
---|
| 485 | </p>
|
---|
| 486 | </form>
|
---|
| 487 |
|
---|
| 488 | <form method="post" action="<?php echo admin_url('plugins.php') ?>">
|
---|
| 489 | <?php wp_nonce_field('bulk-manage-plugins') ?>
|
---|
| 490 | <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
|
---|
| 491 | <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
|
---|
| 492 |
|
---|
| 493 | <ul class="subsubsub">
|
---|
| 494 | <?php
|
---|
| 495 | $status_links = array();
|
---|
| 496 | $class = ( 'all' == $status ) ? ' class="current"' : '';
|
---|
| 497 | $status_links[] = "<li><a href='plugins.php?plugin_status=all' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_all_plugins, 'plugins' ), number_format_i18n( $total_all_plugins ) ) . '</a>';
|
---|
| 498 | if ( ! empty($active_plugins) ) {
|
---|
| 499 | $class = ( 'active' == $status ) ? ' class="current"' : '';
|
---|
| 500 | $status_links[] = "<li><a href='plugins.php?plugin_status=active' $class>" . sprintf( _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $total_active_plugins ), number_format_i18n( $total_active_plugins ) ) . '</a>';
|
---|
| 501 | }
|
---|
| 502 | if ( ! empty($recent_plugins) ) {
|
---|
| 503 | $class = ( 'recent' == $status ) ? ' class="current"' : '';
|
---|
| 504 | $status_links[] = "<li><a href='plugins.php?plugin_status=recent' $class>" . sprintf( _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $total_recent_plugins ), number_format_i18n( $total_recent_plugins ) ) . '</a>';
|
---|
| 505 | }
|
---|
| 506 | if ( ! empty($inactive_plugins) ) {
|
---|
| 507 | $class = ( 'inactive' == $status ) ? ' class="current"' : '';
|
---|
| 508 | $status_links[] = "<li><a href='plugins.php?plugin_status=inactive' $class>" . sprintf( _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $total_inactive_plugins ), number_format_i18n( $total_inactive_plugins ) ) . '</a>';
|
---|
| 509 | }
|
---|
| 510 | if ( ! empty($upgrade_plugins) ) {
|
---|
| 511 | $class = ( 'upgrade' == $status ) ? ' class="current"' : '';
|
---|
| 512 | $status_links[] = "<li><a href='plugins.php?plugin_status=upgrade' $class>" . sprintf( _n( 'Upgrade Available <span class="count">(%s)</span>', 'Upgrade Available <span class="count">(%s)</span>', $total_upgrade_plugins ), number_format_i18n( $total_upgrade_plugins ) ) . '</a>';
|
---|
| 513 | }
|
---|
| 514 | if ( ! empty($search_plugins) ) {
|
---|
| 515 | $class = ( 'search' == $status ) ? ' class="current"' : '';
|
---|
| 516 | $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : '';
|
---|
| 517 | $status_links[] = "<li><a href='plugins.php?s=$term' $class>" . sprintf( _n( 'Search Results <span class="count">(%s)</span>', 'Search Results <span class="count">(%s)</span>', $total_search_plugins ), number_format_i18n( $total_search_plugins ) ) . '</a>';
|
---|
| 518 | }
|
---|
| 519 | echo implode( " |</li>\n", $status_links ) . '</li>';
|
---|
| 520 | unset( $status_links );
|
---|
| 521 | ?>
|
---|
| 522 | </ul>
|
---|
| 523 |
|
---|
| 524 | <div class="tablenav">
|
---|
| 525 | <?php
|
---|
| 526 | if ( $page_links )
|
---|
| 527 | echo '<div class="tablenav-pages">', $page_links_text, '</div>';
|
---|
| 528 |
|
---|
| 529 | print_plugin_actions($status);
|
---|
| 530 | ?>
|
---|
| 531 | </div>
|
---|
| 532 | <div class="clear"></div>
|
---|
| 533 | <?php
|
---|
| 534 | if ( $total_this_page > $plugins_per_page )
|
---|
| 535 | $plugins = array_slice($plugins, $start, $plugins_per_page);
|
---|
| 536 |
|
---|
| 537 | print_plugins_table($plugins, $status);
|
---|
| 538 | ?>
|
---|
| 539 | <div class="tablenav">
|
---|
| 540 | <?php
|
---|
| 541 | if ( $page_links )
|
---|
| 542 | echo "<div class='tablenav-pages'>$page_links_text</div>";
|
---|
| 543 |
|
---|
| 544 | print_plugin_actions($status, "action2");
|
---|
| 545 | ?>
|
---|
| 546 | </div>
|
---|
| 547 | </form>
|
---|
| 548 |
|
---|
| 549 | <?php if ( empty($all_plugins) ) : ?>
|
---|
| 550 | <p><?php _e('You do not appear to have any plugins available at this time.') ?></p>
|
---|
| 551 | <?php endif; ?>
|
---|
| 552 |
|
---|
| 553 | </div>
|
---|
| 554 |
|
---|
| 555 | <?php
|
---|
| 556 | include('admin-footer.php');
|
---|
| 557 | ?>
|
---|