14
14
* must not have any newlines or only parts of the description will be displayed
15
15
* and the same goes for the plugin data. The below is formatted for printing.
19
* Plugin Name: Name of Plugin
20
* Plugin URI: Link to plugin information
21
* Description: Plugin Description
22
* Author: Plugin author's name
23
* Author URI: Link to the author's web site
24
* Version: Must be set in the plugin for WordPress 2.3+
25
* Text Domain: Optional. Unique identifier, should be same as the one used in
26
* plugin_text_domain()
27
* Domain Path: Optional. Only useful if the translations are located in a
28
* folder above the plugin's base path. For example, if .mo files are
29
* located in the locale folder then Domain Path will be "/locale/" and
30
* must have the first slash. Defaults to the base folder the plugin is
32
* Network: Optional. Specify "Network: true" to require that a plugin is activated
33
* across all sites in an installation. This will prevent a plugin from being
34
* activated on a single site when Multisite is enabled.
35
* * / # Remove the space to close comment
18
* Plugin Name: Name of Plugin
19
* Plugin URI: Link to plugin information
20
* Description: Plugin Description
21
* Author: Plugin author's name
22
* Author URI: Link to the author's web site
23
* Version: Must be set in the plugin for WordPress 2.3+
24
* Text Domain: Optional. Unique identifier, should be same as the one used in
25
* plugin_text_domain()
26
* Domain Path: Optional. Only useful if the translations are located in a
27
* folder above the plugin's base path. For example, if .mo files are
28
* located in the locale folder then Domain Path will be "/locale/" and
29
* must have the first slash. Defaults to the base folder the plugin is
31
* Network: Optional. Specify "Network: true" to require that a plugin is activated
32
* across all sites in an installation. This will prevent a plugin from being
33
* activated on a single site when Multisite is enabled.
34
* * / # Remove the space to close comment
38
36
* Plugin data returned array contains the following:
39
* 'Name' - Name of the plugin, must be unique.
40
* 'Title' - Title of the plugin and the link to the plugin's web site.
41
* 'Description' - Description of what the plugin does and/or notes
43
* 'Author' - The author's name
44
* 'AuthorURI' - The authors web site address.
45
* 'Version' - The plugin version number.
46
* 'PluginURI' - Plugin web site address.
47
* 'TextDomain' - Plugin's text domain for localization.
48
* 'DomainPath' - Plugin's relative directory path to .mo files.
49
* 'Network' - Boolean. Whether the plugin can only be activated network wide.
38
* - 'Name' - Name of the plugin, must be unique.
39
* - 'Title' - Title of the plugin and the link to the plugin's web site.
40
* - 'Description' - Description of what the plugin does and/or notes
42
* - 'Author' - The author's name
43
* - 'AuthorURI' - The authors web site address.
44
* - 'Version' - The plugin version number.
45
* - 'PluginURI' - Plugin web site address.
46
* - 'TextDomain' - Plugin's text domain for localization.
47
* - 'DomainPath' - Plugin's relative directory path to .mo files.
48
* - 'Network' - Boolean. Whether the plugin can only be activated network wide.
51
50
* Some users have issues with opening large files and manipulating the contents
52
51
* for want is usually the first 1kiB or 2kiB. This function stops pulling in
558
558
do_action( 'activate_plugin', $plugin, $network_wide );
561
* Fires as a specific plugin is being deactivated.
561
* Fires as a specific plugin is being activated.
563
* This hook is the "deactivation" hook used internally by
564
* register_deactivation_hook(). The dynamic portion of the
565
* hook name, $plugin. refers to the plugin basename.
563
* This hook is the "activation" hook used internally by
564
* {@see register_activation_hook()}. The dynamic portion of the
565
* hook name, `$plugin`, refers to the plugin basename.
567
567
* If a plugin is silently activated (such as during an update),
568
568
* this hook does not fire.
674
674
* Fires as a specific plugin is being deactivated.
676
676
* This hook is the "deactivation" hook used internally by
677
* register_deactivation_hook(). The dynamic portion of the
678
* hook name, $plugin. refers to the plugin basename.
677
* {@see register_deactivation_hook()}. The dynamic portion of the
678
* hook name, `$plugin`, refers to the plugin basename.
680
680
* If a plugin is silently deactivated (such as during an update),
681
681
* this hook does not fire.
797
797
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
798
798
return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
800
//Get the base plugin folder
800
// Get the base plugin folder.
801
801
$plugins_dir = $wp_filesystem->wp_plugins_dir();
802
if ( empty($plugins_dir) )
803
return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
802
if ( empty( $plugins_dir ) ) {
803
return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress Plugin directory.' ) );
805
806
$plugins_dir = trailingslashit( $plugins_dir );
808
$translations_dir = $wp_filesystem->wp_lang_dir();
809
$translations_dir = trailingslashit( $translations_dir );
811
$plugin_translations = wp_get_installed_translations( 'plugins' );
807
813
$errors = array();
809
815
foreach( $plugins as $plugin_file ) {
810
// Run Uninstall hook
811
if ( is_uninstallable_plugin( $plugin_file ) )
816
// Run Uninstall hook.
817
if ( is_uninstallable_plugin( $plugin_file ) ) {
812
818
uninstall_plugin($plugin_file);
814
$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) );
821
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
815
822
// If plugin is in its own directory, recursively delete the directory.
816
if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder
817
$deleted = $wp_filesystem->delete($this_plugin_dir, true);
819
$deleted = $wp_filesystem->delete($plugins_dir . $plugin_file);
823
if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder
824
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
826
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file );
822
830
$errors[] = $plugin_file;
834
// Remove language files, silently.
835
$plugin_slug = dirname( $plugin_file );
836
if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) {
837
$translations = $plugin_translations[ $plugin_slug ];
839
foreach ( $translations as $translation => $data ) {
840
$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' );
841
$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' );
825
846
// Remove deleted plugins from the plugin updates list.
1098
1119
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1099
1120
* @param callback $function The function to be called to output the content for this page.
1101
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1122
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1103
1124
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1104
1125
global $submenu;
1168
1189
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1169
1190
* @param callback $function The function to be called to output the content for this page.
1171
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1192
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1173
1194
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1174
1195
return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1189
1210
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1190
1211
* @param callback $function The function to be called to output the content for this page.
1192
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1213
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1194
1215
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1195
1216
return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1210
1231
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1211
1232
* @param callback $function The function to be called to output the content for this page.
1213
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1234
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1215
1236
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1216
1237
return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1231
1252
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1232
1253
* @param callback $function The function to be called to output the content for this page.
1234
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1255
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1236
1257
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1237
1258
return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1252
1273
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1253
1274
* @param callback $function The function to be called to output the content for this page.
1255
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1276
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1257
1278
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1258
1279
if ( current_user_can('edit_users') )
1276
1297
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1277
1298
* @param callback $function The function to be called to output the content for this page.
1279
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1300
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1281
1302
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1282
1303
return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1297
1318
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1298
1319
* @param callback $function The function to be called to output the content for this page.
1300
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1321
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1302
1323
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1303
1324
return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1318
1339
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1319
1340
* @param callback $function The function to be called to output the content for this page.
1321
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1342
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1323
1344
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1324
1345
return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1339
1360
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1340
1361
* @param callback $function The function to be called to output the content for this page.
1342
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1363
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1344
1365
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1345
1366
return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1360
1381
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1361
1382
* @param callback $function The function to be called to output the content for this page.
1363
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1384
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1365
1386
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1366
1387
return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function );
1381
1402
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
1382
1403
* @param callback $function The function to be called to output the content for this page.
1384
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
1405
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
1386
1407
function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
1387
1408
return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
1723
1744
* @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
1724
1745
* Default whitelisted option key names include "general," "discussion," and "reading," among others.
1725
1746
* @param string $option_name The name of an option to sanitize and save.
1726
* @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
1747
* @param callable $sanitize_callback A callback function that sanitizes the option's value.
1729
1749
function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
1730
1750
global $new_whitelist_options;