2004-03-25 02:05:52 -05:00
< ? php
2004-10-18 23:03:06 -04:00
require_once ( 'admin.php' );
2004-03-25 02:05:52 -05:00
2004-08-09 03:17:54 -04:00
if ( isset ( $_GET [ 'action' ]) ) {
2004-03-25 16:04:36 -05:00
if ( 'activate' == $_GET [ 'action' ]) {
2006-05-26 19:08:05 -04:00
check_admin_referer ( 'activate-plugin_' . $_GET [ 'plugin' ]);
2004-08-09 03:17:54 -04:00
$current = get_settings ( 'active_plugins' );
2004-09-26 14:12:12 -04:00
if ( ! in_array ( $_GET [ 'plugin' ], $current )) {
$current [] = trim ( $_GET [ 'plugin' ] );
2005-07-04 17:53:26 -04:00
sort ( $current );
update_option ( 'active_plugins' , $current );
include ( ABSPATH . 'wp-content/plugins/' . trim ( $_GET [ 'plugin' ] ));
do_action ( 'activate_' . trim ( $_GET [ 'plugin' ] ));
2004-09-26 14:12:12 -04:00
}
2004-04-14 15:04:14 -04:00
header ( 'Location: plugins.php?activate=true' );
2005-07-04 17:53:26 -04:00
} else if ( 'deactivate' == $_GET [ 'action' ]) {
2006-05-26 19:08:05 -04:00
check_admin_referer ( 'deactivate-plugin_' . $_GET [ 'plugin' ]);
2004-08-09 03:17:54 -04:00
$current = get_settings ( 'active_plugins' );
array_splice ( $current , array_search ( $_GET [ 'plugin' ], $current ), 1 ); // Array-fu!
update_option ( 'active_plugins' , $current );
2005-07-04 17:53:26 -04:00
do_action ( 'deactivate_' . trim ( $_GET [ 'plugin' ] ));
2004-04-14 15:04:14 -04:00
header ( 'Location: plugins.php?deactivate=true' );
2004-03-25 16:04:36 -05:00
}
2005-12-27 19:16:40 -05:00
exit ;
2004-03-25 16:04:36 -05:00
}
2004-04-25 19:10:07 -04:00
$title = __ ( 'Manage Plugins' );
2004-03-25 02:05:52 -05:00
require_once ( 'admin-header.php' );
2004-03-25 03:10:26 -05:00
// Clean up options
2004-08-09 03:17:54 -04:00
// If any plugins don't exist, axe 'em
2004-03-25 03:10:26 -05:00
2004-08-09 03:17:54 -04:00
$check_plugins = get_settings ( 'active_plugins' );
2005-04-03 22:48:18 -04:00
// Sanity check. If the active plugin list is not an array, make it an
// empty array.
if ( ! is_array ( $check_plugins ) ) {
$check_plugins = array ();
2006-02-12 02:53:23 -05:00
update_option ( 'active_plugins' , $check_plugins );
2005-04-03 22:48:18 -04:00
}
// If a plugin file does not exist, remove it from the list of active
// plugins.
2004-03-25 03:10:26 -05:00
foreach ( $check_plugins as $check_plugin ) {
if ( ! file_exists ( ABSPATH . 'wp-content/plugins/' . $check_plugin )) {
2004-08-09 03:17:54 -04:00
$current = get_settings ( 'active_plugins' );
2005-10-05 19:19:48 -04:00
$key = array_search ( $check_plugin , $current );
if ( false !== $key && NULL !== $key ) {
unset ( $current [ $key ]);
update_option ( 'active_plugins' , $current );
}
2004-03-25 03:10:26 -05:00
}
}
2004-03-25 02:05:52 -05:00
?>
2004-04-14 15:04:14 -04:00
2004-05-07 19:56:33 -04:00
< ? php if ( isset ( $_GET [ 'activate' ])) : ?>
2005-08-07 21:13:22 -04:00
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Plugin <strong>activated</strong>.' ) ?> </p>
2004-04-14 15:04:14 -04:00
</ div >
< ? php endif ; ?>
2004-05-07 19:56:33 -04:00
< ? php if ( isset ( $_GET [ 'deactivate' ])) : ?>
2005-08-07 21:13:22 -04:00
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Plugin <strong>deactivated</strong>.' ) ?> </p>
2004-04-14 15:04:14 -04:00
</ div >
< ? php endif ; ?>
2004-03-25 02:05:52 -05:00
< div class = " wrap " >
2004-04-24 15:46:11 -04:00
< h2 >< ? php _e ( 'Plugin Management' ); ?> </h2>
2005-08-07 06:45:06 -04:00
< 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>
2004-03-25 02:05:52 -05:00
< ? php
2004-08-09 03:17:54 -04:00
if ( get_settings ( 'active_plugins' ) )
$current_plugins = get_settings ( 'active_plugins' );
2004-03-25 02:05:52 -05:00
2004-11-25 21:29:45 -05:00
$plugins = get_plugins ();
if ( empty ( $plugins )) {
2005-12-12 17:48:30 -05:00
echo '<p>' ;
_e ( " Couldn't open plugins directory or there are no plugins available. " ); // TODO: make more helpful
echo '</p>' ;
2004-03-25 02:05:52 -05:00
} else {
?>
2006-05-10 16:35:10 -04:00
< table class = " widefat " >
< thead >
2004-03-25 02:05:52 -05:00
< tr >
2006-05-10 16:35:10 -04:00
< th style = " text-align: left " >< ? php _e ( 'Plugin' ); ?> </th>
2004-04-24 15:46:11 -04:00
< th >< ? php _e ( 'Version' ); ?> </th>
2006-05-10 16:35:10 -04:00
< th style = " text-align: left " >< ? php _e ( 'Description' ); ?> </th>
2004-04-24 15:46:11 -04:00
< th >< ? php _e ( 'Action' ); ?> </th>
2004-03-25 02:05:52 -05:00
</ tr >
2006-05-10 16:35:10 -04:00
</ thead >
2004-03-25 02:05:52 -05:00
< ? php
2004-05-07 19:56:33 -04:00
$style = '' ;
2006-01-24 02:48:21 -05:00
function sort_plugins ( $plug1 , $plug2 ) {
return strnatcasecmp ( $plug1 [ 'Name' ], $plug2 [ 'Name' ]);
}
2006-02-12 02:53:23 -05:00
2006-01-24 04:44:17 -05:00
uksort ( $plugins , 'sort_plugins' );
2006-01-24 02:48:21 -05:00
2004-11-25 21:29:45 -05:00
foreach ( $plugins as $plugin_file => $plugin_data ) {
2005-03-11 11:53:16 -05:00
$style = ( 'class="alternate"' == $style || 'class="alternate active"' == $style ) ? '' : 'alternate' ;
2004-03-25 03:10:26 -05:00
if ( ! empty ( $current_plugins ) && in_array ( $plugin_file , $current_plugins )) {
2006-05-26 19:08:05 -04:00
$action = " <a href=' " . wp_nonce_url ( " plugins.php?action=deactivate&plugin= $plugin_file " , 'deactivate-plugin_' . $plugin_file ) . " ' title=' " . __ ( 'Deactivate this plugin' ) . " ' class='delete'> " . __ ( 'Deactivate' ) . " </a> " ;
2005-01-14 15:20:29 -05:00
$plugin_data [ 'Title' ] = " <strong> { $plugin_data [ 'Title' ] } </strong> " ;
2005-03-11 11:53:16 -05:00
$style .= $style == 'alternate' ? ' active' : 'active' ;
2004-03-25 03:10:26 -05:00
} else {
2006-05-26 19:08:05 -04:00
$action = " <a href=' " . wp_nonce_url ( " plugins.php?action=activate&plugin= $plugin_file " , 'activate-plugin_' . $plugin_file ) . " ' title=' " . __ ( 'Activate this plugin' ) . " ' class='edit'> " . __ ( 'Activate' ) . " </a> " ;
2004-03-25 03:10:26 -05:00
}
2004-12-15 18:09:46 -05:00
$plugin_data [ 'Description' ] = wp_kses ( $plugin_data [ 'Description' ], array ( 'a' => array ( 'href' => array (), 'title' => array ()), 'abbr' => array ( 'title' => array ()), 'acronym' => array ( 'title' => array ()), 'code' => array (), 'em' => array (), 'strong' => array ()) ); ;
2005-03-11 11:53:16 -05:00
if ( $style != '' ) $style = 'class="' . $style . '"' ;
2004-03-25 02:05:52 -05:00
echo "
< tr $style >
2005-08-07 06:45:06 -04:00
< td class = 'name' > { $plugin_data [ 'Title' ]} </ td >
< td class = 'vers' > { $plugin_data [ 'Version' ]} </ td >
2005-12-12 17:48:30 -05:00
< td class = 'desc' > { $plugin_data [ 'Description' ]} < cite > " .sprintf(__('By %s'), $plugin_data['Author'] ). " .</ cite ></ td >
2005-08-07 06:45:06 -04:00
< td class = 'togl' > $action </ td >
2004-03-25 02:05:52 -05:00
</ tr > " ;
}
?>
</ table >
< ? php
}
?>
2005-05-09 07:37:36 -04:00
2005-08-07 06:45:06 -04:00
< p >< ? php _e ( 'If something goes wrong with a plugin and you can’t use WordPress, delete or rename that file in the <code>wp-content/plugins</code> directory and it will be automatically deactivated.' ); ?> </p>
2005-05-09 07:37:36 -04:00
< h2 >< ? php _e ( 'Get More Plugins' ); ?> </h2>
< p >< ? php _e ( 'You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>. To install a plugin you generally just need to upload the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is uploaded, you may activate it here.' ); ?> </p>
2004-03-25 02:05:52 -05:00
</ div >
< ? php
include ( 'admin-footer.php' );
2004-11-29 12:28:53 -05:00
?>