/** * Dectivate a plugin * * @param string $plugin Plugin filename (full relative to plugins directory) * @return mixed string if error or true if success */ function yourls_deactivate_plugin($plugin) { $plugin = yourls_plugin_basename($plugin); // Check plugin is active if (!yourls_is_active_plugin($plugin)) { return 'Plugin not active'; } // Deactivate the plugin global $ydb; $key = array_search($plugin, $ydb->plugins); if ($key !== false) { array_splice($ydb->plugins, $key, 1); } yourls_update_option('active_plugins', $ydb->plugins); yourls_do_action('deactivated_plugin', $plugin); yourls_do_action('deactivated_' . $plugin); return true; }
<?php $nonce = yourls_create_nonce('manage_plugins'); foreach ($plugins as $file => $plugin) { // default fields to read from the plugin header $fields = array('name' => 'Plugin Name', 'uri' => 'Plugin URI', 'desc' => 'Description', 'version' => 'Version', 'author' => 'Author', 'author_uri' => 'Author URI'); // Loop through all default fields, get value if any and reset it foreach ($fields as $field => $value) { if ($plugin[$value]) { $data[$field] = $plugin[$value]; } else { $data[$field] = '(no info)'; } unset($plugin[$value]); } $plugindir = trim(dirname($file), '/'); if (yourls_is_active_plugin($file)) { $class = 'active'; $action_url = yourls_nonce_url('manage_plugins', yourls_add_query_arg(array('action' => 'deactivate', 'plugin' => $plugindir))); $action_anchor = 'Deactivate'; } else { $class = 'inactive'; $action_url = yourls_nonce_url('manage_plugins', yourls_add_query_arg(array('action' => 'activate', 'plugin' => $plugindir))); $action_anchor = 'Activate'; } // Other "Fields: Value" in the header? Get them too if ($plugin) { foreach ($plugin as $extra_field => $extra_value) { $data['desc'] .= "<br/>\n<em>{$extra_field}</em>: {$extra_value}"; unset($plugin[$extra_value]); } }