mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Plugins administration panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 $action = '';
mp-wp_remove-all-... 13 foreach( array('activate-selected', 'deactivate-selected', 'clear-recent-list') as $action_key ) {
mp-wp_genesis 14 if( isset($_POST[$action_key]) ) {
mp-wp_genesis 15 $action = $action_key;
mp-wp_genesis 16 break;
mp-wp_genesis 17 }
mp-wp_genesis 18 }
mp-wp_genesis 19
mp-wp_genesis 20 if( isset($_REQUEST['action']) && !empty($_REQUEST['action']) )
mp-wp_genesis 21 $action = $_REQUEST['action'];
mp-wp_genesis 22
mp-wp_genesis 23 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
mp-wp_genesis 24
mp-wp_genesis 25 if( !empty($action) ) {
mp-wp_genesis 26 switch( $action ) {
mp-wp_genesis 27 case 'activate':
mp-wp_genesis 28 check_admin_referer('activate-plugin_' . $plugin);
mp-wp_genesis 29 $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
mp-wp_genesis 30 if ( is_wp_error( $result ) )
mp-wp_genesis 31 wp_die($result);
mp-wp_genesis 32 $recent = (array)get_option('recently_activated');
mp-wp_genesis 33 if ( isset($recent[ $plugin ]) ) {
mp-wp_genesis 34 unset($recent[ $plugin ]);
mp-wp_genesis 35 update_option('recently_activated', $recent);
mp-wp_genesis 36 }
mp-wp_genesis 37 wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
mp-wp_genesis 38 exit;
mp-wp_genesis 39 break;
mp-wp_genesis 40 case 'activate-selected':
mp-wp_genesis 41 check_admin_referer('bulk-manage-plugins');
mp-wp_genesis 42 activate_plugins($_POST['checked'], 'plugins.php?error=true');
mp-wp_genesis 43
mp-wp_genesis 44 $recent = (array)get_option('recently_activated');
mp-wp_genesis 45 foreach( (array)$_POST['checked'] as $plugin => $time) {
mp-wp_genesis 46 if ( isset($recent[ $plugin ]) )
mp-wp_genesis 47 unset($recent[ $plugin ]);
mp-wp_genesis 48 }
mp-wp_genesis 49 if( $recent != get_option('recently_activated') ) //If array changed, update it.
mp-wp_genesis 50 update_option('recently_activated', $recent);
mp-wp_genesis 51
mp-wp_genesis 52 wp_redirect('plugins.php?activate-multi=true');
mp-wp_genesis 53 exit;
mp-wp_genesis 54 break;
mp-wp_genesis 55 case 'error_scrape':
mp-wp_genesis 56 check_admin_referer('plugin-activation-error_' . $plugin);
mp-wp_genesis 57 $valid = validate_plugin($plugin);
mp-wp_genesis 58 if ( is_wp_error($valid) )
mp-wp_genesis 59 wp_die($valid);
mp-wp_genesis 60 error_reporting( E_ALL ^ E_NOTICE );
mp-wp_genesis 61 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
mp-wp_genesis 62 include(WP_PLUGIN_DIR . '/' . $plugin);
mp-wp_genesis 63 do_action('activate_' . $plugin);
mp-wp_genesis 64 exit;
mp-wp_genesis 65 break;
mp-wp_genesis 66 case 'deactivate':
mp-wp_genesis 67 check_admin_referer('deactivate-plugin_' . $plugin);
mp-wp_genesis 68 deactivate_plugins($plugin);
mp-wp_genesis 69 update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
mp-wp_genesis 70 wp_redirect('plugins.php?deactivate=true');
mp-wp_genesis 71 exit;
mp-wp_genesis 72 break;
mp-wp_genesis 73 case 'deactivate-selected':
mp-wp_genesis 74 check_admin_referer('bulk-manage-plugins');
mp-wp_genesis 75 deactivate_plugins($_POST['checked']);
mp-wp_genesis 76 $deactivated = array();
mp-wp_genesis 77 foreach ( (array)$_POST['checked'] as $plugin )
mp-wp_genesis 78 $deactivated[ $plugin ] = time();
mp-wp_genesis 79 update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
mp-wp_genesis 80 wp_redirect('plugins.php?deactivate-multi=true');
mp-wp_genesis 81 exit;
mp-wp_genesis 82 break;
mp-wp_genesis 83 case 'clear-recent-list':
mp-wp_genesis 84 update_option('recently_activated', array());
mp-wp_genesis 85 break;
mp-wp_genesis 86 }
mp-wp_genesis 87 }
mp-wp_genesis 88
mp-wp_genesis 89 $title = __('Manage Plugins');
mp-wp_genesis 90 require_once('admin-header.php');
mp-wp_genesis 91
mp-wp_genesis 92 $invalid = validate_active_plugins();
mp-wp_genesis 93 if ( !empty($invalid) )
mp-wp_genesis 94 foreach ( $invalid as $plugin_file => $error )
mp-wp_genesis 95 echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), wp_specialchars($plugin_file), $error->get_error_message()) . '</p></div>';
mp-wp_genesis 96 ?>
mp-wp_genesis 97
mp-wp_genesis 98 <?php if ( isset($_GET['error']) ) : ?>
mp-wp_genesis 99 <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
mp-wp_genesis 100 <?php
mp-wp_genesis 101 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
mp-wp_genesis 102 <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . attribute_escape($plugin) . '&_wpnonce=' . attribute_escape($_GET['_error_nonce'])); ?>"></iframe>
mp-wp_genesis 103 <?php
mp-wp_genesis 104 }
mp-wp_genesis 105 ?>
mp-wp_genesis 106 </div>
mp-wp_genesis 107 <?php elseif ( isset($_GET['activate']) ) : ?>
mp-wp_genesis 108 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
mp-wp_genesis 109 <?php elseif (isset($_GET['activate-multi'])) : ?>
mp-wp_genesis 110 <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
mp-wp_genesis 111 <?php elseif ( isset($_GET['deactivate']) ) : ?>
mp-wp_genesis 112 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
mp-wp_genesis 113 <?php elseif (isset($_GET['deactivate-multi'])) : ?>
mp-wp_genesis 114 <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
mp-wp_genesis 115 <?php endif; ?>
mp-wp_genesis 116
mp-wp_genesis 117 <div class="wrap">
mp-wp_genesis 118 <?php screen_icon(); ?>
mp-wp_genesis 119 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 120
mp-wp_genesis 121 <p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?></p>
mp-wp_genesis 122 <?php
mp-wp_genesis 123
mp-wp_genesis 124 $all_plugins = get_plugins();
mp-wp_genesis 125 $active_plugins = array();
mp-wp_genesis 126 $inactive_plugins = array();
mp-wp_genesis 127 $recent_plugins = array();
mp-wp_genesis 128 $recently_activated = (array) get_option('recently_activated');
mp-wp_genesis 129
mp-wp_genesis 130 //Clean out any plugins which were deactivated over a week ago.
mp-wp_genesis 131 foreach ( $recently_activated as $key => $time )
mp-wp_genesis 132 if ( $time + (7*24*60*60) < time() ) //1 week
mp-wp_genesis 133 unset($recently_activated[ $key ]);
mp-wp_genesis 134 if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
mp-wp_genesis 135 update_option('recently_activated', $recently_activated);
mp-wp_genesis 136
mp-wp_genesis 137 foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
mp-wp_genesis 138
mp-wp_genesis 139 //Translate, Apply Markup, Sanitize HTML
mp-wp_genesis 140 $plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true);
mp-wp_genesis 141
mp-wp_genesis 142 //Filter into individual sections
mp-wp_genesis 143 if ( is_plugin_active($plugin_file) ) {
mp-wp_genesis 144 $active_plugins[ $plugin_file ] = $plugin_data;
mp-wp_genesis 145 } else {
mp-wp_genesis 146 if ( isset( $recently_activated[ $plugin_file ] ) ) //Was the plugin recently activated?
mp-wp_genesis 147 $recent_plugins[ $plugin_file ] = $plugin_data;
mp-wp_genesis 148 else
mp-wp_genesis 149 $inactive_plugins[ $plugin_file ] = $plugin_data;
mp-wp_genesis 150 }
mp-wp_genesis 151 }
mp-wp_genesis 152
mp-wp_genesis 153 ?>
mp-wp_genesis 154
mp-wp_genesis 155 <?php
mp-wp_genesis 156 /**
mp-wp_genesis 157 * @ignore
mp-wp_genesis 158 *
mp-wp_genesis 159 * @param array $plugins
mp-wp_genesis 160 * @param string $context
mp-wp_genesis 161 */
mp-wp_genesis 162 function print_plugins_table($plugins, $context = '') {
mp-wp_genesis 163 ?>
mp-wp_genesis 164 <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
mp-wp_genesis 165 <thead>
mp-wp_genesis 166 <tr>
mp-wp_remove-all-... 167 <th scope="col" class="check-column"> </th>
mp-wp_genesis 168 <th scope="col"><?php _e('Plugin'); ?></th>
mp-wp_genesis 169 <th scope="col" class="num"><?php _e('Version'); ?></th>
mp-wp_genesis 170 <th scope="col"><?php _e('Description'); ?></th>
mp-wp_genesis 171 <th scope="col" class="action-links"><?php _e('Action'); ?></th>
mp-wp_genesis 172 </tr>
mp-wp_genesis 173 </thead>
mp-wp_genesis 174 <tbody class="plugins">
mp-wp_genesis 175 <?php
mp-wp_genesis 176
mp-wp_genesis 177 if ( empty($plugins) ) {
mp-wp_genesis 178 echo '<tr>
mp-wp_genesis 179 <td colspan="6">' . __('No plugins to show') . '</td>
mp-wp_genesis 180 </tr>';
mp-wp_genesis 181 }
mp-wp_genesis 182 foreach ( (array)$plugins as $plugin_file => $plugin_data) {
mp-wp_genesis 183 $action_links = array();
mp-wp_genesis 184
mp-wp_genesis 185 if ( 'active' == $context )
mp-wp_genesis 186 $action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
mp-wp_genesis 187 else //Inactive or Recently deactivated
mp-wp_genesis 188 $action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
mp-wp_genesis 189
mp-wp_genesis 190 $action_links = apply_filters( 'plugin_action_links', $action_links, $plugin_file, $plugin_data, $context );
mp-wp_genesis 191 $action_links = apply_filters( "plugin_action_links_$plugin_file", $action_links, $plugin_file, $plugin_data, $context );
mp-wp_genesis 192
mp-wp_genesis 193 echo "
mp-wp_genesis 194 <tr class='$context'>
mp-wp_remove-all-... 195 <td scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . attribute_escape($plugin_file) . "' /></td>
mp-wp_genesis 196 <td class='name'>{$plugin_data['Title']}</td>
mp-wp_genesis 197 <td class='vers'>{$plugin_data['Version']}</td>
mp-wp_genesis 198 <td class='desc'><p>{$plugin_data['Description']}</p></td>
mp-wp_genesis 199 <td class='togl action-links'>";
mp-wp_genesis 200 if ( !empty($action_links) )
mp-wp_genesis 201 echo implode(' | ', $action_links);
mp-wp_genesis 202 echo '</td>
mp-wp_genesis 203 </tr>';
mp-wp_genesis 204 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context );
mp-wp_genesis 205 do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context );
mp-wp_genesis 206 }
mp-wp_genesis 207 ?>
mp-wp_genesis 208 </tbody>
mp-wp_genesis 209 </table>
mp-wp_genesis 210 <?php
mp-wp_genesis 211 } //End print_plugins_table()
mp-wp_genesis 212
mp-wp_genesis 213 /**
mp-wp_genesis 214 * @ignore
mp-wp_genesis 215 *
mp-wp_genesis 216 * @param string $context
mp-wp_genesis 217 */
mp-wp_genesis 218 function print_plugin_actions($context) {
mp-wp_genesis 219 ?>
mp-wp_genesis 220 <div class="alignleft actions">
mp-wp_genesis 221 <select name="action">
mp-wp_genesis 222 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 223 <?php if( 'active' != $context ) : ?>
mp-wp_genesis 224 <option value="activate-selected"><?php _e('Activate'); ?></option>
mp-wp_genesis 225 <?php endif; ?>
mp-wp_genesis 226 <?php if ( 'active' == $context ) : ?>
mp-wp_genesis 227 <option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
mp-wp_genesis 228 <?php endif; ?>
mp-wp_genesis 229 </select>
mp-wp_genesis 230 <input type="submit" name="doaction_active" value="<?php _e('Apply'); ?>" class="button-secondary action" />
mp-wp_genesis 231 <?php if( 'recent' == $context ) : ?>
mp-wp_genesis 232 <input type="submit" name="clear-recent-list" value="<?php _e('Clear List') ?>" class="button-secondary" />
mp-wp_genesis 233 <?php endif; ?>
mp-wp_genesis 234 </div>
mp-wp_genesis 235 <?php
mp-wp_genesis 236 }
mp-wp_genesis 237 ?>
mp-wp_genesis 238
mp-wp_genesis 239 <?php if ( ! empty($active_plugins) ) : ?>
mp-wp_genesis 240 <h3 id="currently-active"><?php _e('Currently Active Plugins') ?></h3>
mp-wp_genesis 241 <form method="post" action="<?php echo admin_url('plugins.php') ?>">
mp-wp_genesis 242 <?php wp_nonce_field('bulk-manage-plugins') ?>
mp-wp_genesis 243
mp-wp_genesis 244 <div class="tablenav">
mp-wp_genesis 245 <?php print_plugin_actions('active') ?>
mp-wp_genesis 246 </div>
mp-wp_genesis 247 <div class="clear"></div>
mp-wp_genesis 248 <?php print_plugins_table($active_plugins, 'active') ?>
mp-wp_genesis 249 </form>
mp-wp_genesis 250
mp-wp_genesis 251 <p><?php printf(__('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>
mp-wp_genesis 252 <?php endif; ?>
mp-wp_genesis 253
mp-wp_genesis 254 <?php if ( ! empty($recent_plugins) ) : ?>
mp-wp_genesis 255 <h3 id="recent-plugins"><?php _e('Recently Active Plugins') ?></h3>
mp-wp_genesis 256 <p><?php _e('The following plugins were recently active. When a plugin has been inactive for more than 7 days it will be moved to the Inactive plugin list.') ?></p>
mp-wp_genesis 257 <form method="post" action="<?php echo admin_url('plugins.php') ?>">
mp-wp_genesis 258 <?php wp_nonce_field('bulk-manage-plugins') ?>
mp-wp_genesis 259
mp-wp_genesis 260 <div class="tablenav">
mp-wp_genesis 261 <?php print_plugin_actions('recent') ?>
mp-wp_genesis 262 </div>
mp-wp_genesis 263 <div class="clear"></div>
mp-wp_genesis 264 <?php print_plugins_table($recent_plugins, 'recent') ?>
mp-wp_genesis 265 </form>
mp-wp_genesis 266 <?php endif; ?>
mp-wp_genesis 267
mp-wp_genesis 268 <?php if ( ! empty($inactive_plugins) ) : ?>
mp-wp_genesis 269 <h3 id="inactive-plugins"><?php _e('Inactive Plugins') ?></h3>
mp-wp_genesis 270 <form method="post" action="<?php echo admin_url('plugins.php') ?>">
mp-wp_genesis 271 <?php wp_nonce_field('bulk-manage-plugins') ?>
mp-wp_genesis 272
mp-wp_genesis 273 <div class="tablenav">
mp-wp_genesis 274 <?php print_plugin_actions('inactive') ?>
mp-wp_genesis 275 </div>
mp-wp_genesis 276 <div class="clear"></div>
mp-wp_genesis 277 <?php print_plugins_table($inactive_plugins, 'inactive') ?>
mp-wp_genesis 278 </form>
mp-wp_genesis 279 <?php endif; ?>
mp-wp_genesis 280
mp-wp_genesis 281 <?php if ( empty($all_plugins) ) : ?>
mp-wp_genesis 282 <p><?php _e('You do not appear to have any plugins available at this time.') ?></p>
mp-wp_genesis 283 <?php endif; ?>
mp-wp_genesis 284
mp-wp_genesis 285 </div>
mp-wp_genesis 286
mp-wp_genesis 287 <?php
mp-wp_genesis 288 include('admin-footer.php');
mp-wp_genesis 289 ?>