Developer Documentation
No Nonsense includes hooks to allow developers to extend or modify its functionality.
Terminology
No Nonsense works with functions in two ways:
Settings are functions that use existing hooks (actions and filters) in WordPress core (or optionally in your theme or other plugins), and are executed whenever those hooks are called.
Utilities are functions that appear in the list at the top of the No Nonsense admin page, and that are executed manually when selected.
Filters
The filters available in No Nonsense include:
r34nono_define_ settings_array
This filter allows you to manipulate the array of Settings functions defined by No Nonsense. You can add your own functions or remove built-in functions that you do not want to make available.
Removing a Setting
To remove a setting, unset it in the array. The array keys are the names of the functions, listed under Built-in Setting Names below.
Example:
add_filter('r34nono_define_settings_array', function($settings) {
unset($settings['r34nono_remove_wp_emoji']);
return $settings;
});
Adding a Setting
To add your own setting, append information about it to the settings array. This is done by adding a subarray whose key is the name of your function, containing the following:
title
(string) — The title to display on the admin page.description
(string) — Descriptive text to display under the help icon.hook_type
(string) — Eitheraction
orfilter
depending on how your function should run.hook
(string) — The name of an existing hook (action or filter) on which your function should run, e.g.init
.options
(array) — Optional. An array of sub-options to create a set of checkboxes on the admin page. If you use this, the data stored inwp_options
for this setting will be an array of the keys from this array, with boolean values for whether or not the box is checked. (By default, the data stored is a simple boolean.) Your function will need to iterate through the array to handle each sub-option appropriately. Examine ther34nono_remove_head_tags()
function for example usage.priority
(integer) — The priority number for the hook, e.g.10
.pn
(integer) — The number of input parameters your function accepts. (Since these functions are being handled by hooks, the input parameters of your function should match what the hook expects.)cb
(string) — Optional. The name of an existing function to run instead of using this node's key as the name of the function. Example:r34nono_remove_admin_
andemail_check_interval r34nono_remove_front_
use the built-inend_edit_links __return_false
function, rather than having functions of their own.group
(string) — The group (heading) on the admin page that this function should appear under. You can use one of the existing headings or create your own.show_in_admin
(boolean) — Whether or not this setting should appear on the admin page. If you intend to hardcode a value for any of the settings, you'll want to set this tofalse
.
Example:
add_filter('r34nono_define_settings_array', function($settings) {
$settings['my_function_name'] = array(
'title' => 'My function',
'description' => 'This is what my function does.',
'hook_type' => 'action',
'hook' => 'init',
'priority' => 10,
'pn' => 0,
'group' => 'My Custom Heading',
'show_in_admin' => true,
);
return $settings;
});
Hardcoding a Setting
If you want to hardcode a setting, simply set its value first, and then use this filter to change its show_in_admin
value to false
.
The value can be set in one of three ways:
- On the No Nonsense admin page, before creating your filter that hides it
- On the hidden options.php admin page
- Using the
update_option()
function in your theme or plugin
For optimal performance, your code should be written to avoid running update_option()
more often than necessary, e.g. by placing the code inside an activation hook.
Built-in Setting Names
The following is a list of the built-in Settings function names, which are also their keys in the wp_options
table. The stored values are booleans indicating whether or not the option is turned on. Their names closely match their titles on the admin screen.
Note: Settings that have an options
sub-array result in two records being written to wp_options
: the setting name itself is stored as a boolean (for whether or not the main option is turned on), and a second record with _options
appended to the key contains an array of the sub-options (each of which is a boolean). This second record is stored regardless of whether or not the main record's boolean is true or false; however, if the main record is false (i.e. the option is turned off), none of the sub-array options will be active on the site. However, since they are stored in wp_options
, they will automatically be applied again if the main option is turned back on.
r34nono_admin_bar_logout_link
r34nono_auto_core_update_send_email_only_on_error
r34nono_core_upgrade_skip_new_bundled
(Omitted ifCORE_UPGRADE_SKIP_NEW_BUNDLED
constant is already set.)r34nono_disable_site_search
r34nono_disallow_file_edit
(Omitted ifDISALLOW_FILE_EDIT
constant is already set.)r34nono_disallow_full_site_editing
r34nono_hide_admin_bar_for_logged_in_non_editors
r34nono_limit_admin_elements_for_logged_in_non_editors
r34nono_login_replace_wp_logo_link
r34nono_prevent_block_directory_access
r34nono_redirect_admin_to_homepage_for_logged_in_non_editors
(+r34nono_redirect_admin_to_homepage_for_logged_in_non_editors_options
array)r34nono_remove_admin_color_scheme_picker
r34nono_remove_admin_email_check_interval
r34nono_remove_admin_wp_logo
r34nono_remove_attachment_pages
r34nono_remove_comments_from_admin
r34nono_remove_comments_from_front_end
r34nono_remove_dashboard_widgets
(+r34nono_remove_dashboard_widgets_options
array)r34nono_remove_default_block_patterns
r34nono_remove_duotone_svg_filters
r34nono_remove_edit_site
r34nono_remove_front_end_edit_links
r34nono_remove_global_styles
r34nono_remove_head_tags
(+r34nono_remove_head_tags_options
array)r34nono_remove_howdy
r34nono_remove_posts_from_admin
r34nono_remove_widgets_block_editor
r34nono_remove_wp_emoji
r34nono_xmlrpc_disabled
(+r34nono_xmlrpc_disabled_options
array)
r34nono_define_ utilities_array
This filter allows you to manipulate the array of Utilities functions defined by No Nonsense. You can add your own utilities or remove built-in utilities that you do not want to make available.
Removing a Utility
To remove a utility, unset it in the array. The array keys are the names of the functions, listed under Built-in Utility Names below.
Example:
add_filter('r34nono_define_utilities_array', function($utilities) {
unset($utilities['r34nono_set_permalink_structure_to_postname']);
return $utilities;
});
Adding a Utility
To add your own utility, append information about it to the utilities array. This is done by adding a subarray whose key is the name of your function, containing the following:
title
(string) — The title to display on the admin page.description
(string) — Descriptive text to display under the help icon.show_in_admin
(boolean) — Whether or not this utility should appear on the admin page. (Note: At present, creating a utility that has this value set tofalse
serves no functional purpose.)
Note: At present this feature does not accommodate functions that have any input parameters.
Example:
add_filter('r34nono_define_utilities_array', function($utilities) {
$settings['my_function_name'] = array(
'title' => 'My function',
'description' => 'This is what my function does.',
'show_in_admin' => true,
);
return $utilities;
});
Built-in Utility Names
The following is a list of the built-in Utilities function names. Unlike the Settings functions, since these functions are only executed manually on the admin page, they do not have any corresponding data stored in the wp_options
table.
r34nono_deactivate_and_delete_akismet
r34nono_deactivate_and_delete_hello_dolly
r34nono_delete_inactive_themes
(Omitted ifWP_ALLOW_MULTISITE
constant is set to true.)r34nono_delete_sample_content
r34nono_remove_default_tagline
r34nono_set_permalink_structure_to_postname