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-05-17 16:16:54 -04:00
check_admin_referer ();
2004-03-25 16:04:36 -05:00
if ( 'activate' == $_GET [ 'action' ]) {
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' ] );
}
2004-08-09 03:17:54 -04:00
sort ( $current );
2004-03-25 16:04:36 -05:00
update_option ( 'active_plugins' , $current );
2004-04-14 15:04:14 -04:00
header ( 'Location: plugins.php?activate=true' );
2004-03-25 16:04:36 -05:00
}
if ( 'deactivate' == $_GET [ 'action' ]) {
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 );
2004-04-14 15:04:14 -04:00
header ( 'Location: plugins.php?deactivate=true' );
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' );
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' );
unset ( $current [ $_GET [ 'plugin' ]]);
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' ])) : ?>
2004-04-25 19:10:07 -04:00
< div class = " updated " >< 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' ])) : ?>
2004-04-25 19:10:07 -04:00
< div class = " updated " >< 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>
2004-08-09 03:17:54 -04:00
< p >< ? php _e ( 'Plugins are files you usually download separately from WordPress that add functionality. To install a plugin you generally just need to put the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is installed, you may activate it or deactivate it here. If something goes wrong with a plugin and you can’t use WordPress, delete that plugin from the <code>wp-content/plugins</code> directory and it will be automatically deactivated.' ); ?> </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 )) {
2004-04-24 15:46:11 -04:00
_e ( " <p>Couldn't open plugins directory or there are no plugins available.</p> " ); // TODO: make more helpful
2004-03-25 02:05:52 -05:00
} else {
?>
< table width = " 100% " cellpadding = " 3 " cellspacing = " 3 " >
< tr >
2004-04-24 15:46:11 -04:00
< th >< ? php _e ( 'Plugin' ); ?> </th>
< th >< ? php _e ( 'Version' ); ?> </th>
< th >< ? php _e ( 'Author' ); ?> </th>
< th >< ? php _e ( 'Description' ); ?> </th>
< th >< ? php _e ( 'Action' ); ?> </th>
2004-03-25 02:05:52 -05:00
</ tr >
< ? php
2004-05-07 19:56:33 -04:00
$style = '' ;
2004-11-25 21:29:45 -05:00
foreach ( $plugins as $plugin_file => $plugin_data ) {
2004-03-25 02:05:52 -05:00
$style = ( 'class="alternate"' == $style ) ? '' : 'class="alternate"' ;
2004-03-25 03:10:26 -05:00
if ( ! empty ( $current_plugins ) && in_array ( $plugin_file , $current_plugins )) {
2004-11-29 12:28:53 -05:00
$action = " <a href='plugins.php?action=deactivate&plugin= $plugin_file ' title=' " . __ ( 'Deactivate this plugin' ) . " ' class='delete'> " . __ ( 'Deactivate' ) . " </a> " ;
$plugin = " <strong> $plugin </strong> " ;
2004-03-25 03:10:26 -05:00
} else {
2004-11-29 12:28:53 -05:00
$action = " <a href='plugins.php?action=activate&plugin= $plugin_file ' title=' " . __ ( 'Activate this plugin' ) . " ' class='edit'> " . __ ( 'Activate' ) . " </a> " ;
2004-03-25 03:10:26 -05:00
}
2004-03-25 02:05:52 -05:00
echo "
< tr $style >
2004-11-25 21:29:45 -05:00
< td > { $plugin_data [ 'Title' ]} </ td >
< td > { $plugin_data [ 'Version' ]} </ td >
< td > { $plugin_data [ 'Author' ]} </ td >
< td > { $plugin_data [ 'Description' ]} </ td >
2004-03-25 03:10:26 -05:00
< td > $action </ td >
2004-03-25 02:05:52 -05:00
</ tr > " ;
}
?>
</ table >
< ? php
}
?>
</ div >
< ? php
include ( 'admin-footer.php' );
2004-11-29 12:28:53 -05:00
?>