Settings_API
Settings API wrapper class
Namespace: WebberZone\WFP\Admin\Settings
Source: includes/admin/settings/class-settings-api.php line 23
Methods
__construct()
Main constructor class.
Line: 148
public function __construct( $settings_key, $prefix, $args );
| Type | Name | Description |
|---|---|---|
string | $settings_key | Settings key. |
string | $prefix | Prefix. Used for actions and filters. |
mixed | $args | { |
hooks()
Adds the functions to the appropriate WordPress hooks.
Line: 177
public function hooks( );
admin_body_class()
Filters the CSS classes for the body tag in the admin.
Line: 191
public function admin_body_class( $classes ): string;
| Type | Name | Description |
|---|---|---|
string | $classes | Space-separated list of CSS classes. |
Returns: string — Space-separated list of CSS classes.
set_props()
Sets properties.
Line: 213
public function set_props( $args );
| Type | Name | Description |
|---|---|---|
array|string | $args | { |
set_translation_strings()
Sets translation strings.
Line: 249
public function set_translation_strings( $strings ): void;
| Type | Name | Description |
|---|---|---|
array | $strings | { |
Returns: void
set_sections()
Set settings sections
Line: 278
public function set_sections( $sections ): object;
| Type | Name | Description |
|---|---|---|
array | $sections | Setting sections array in the format of: id => Title. |
Returns: object — Class object.
add_section()
Add a single section
Line: 290
public function add_section( $section ): object;
| Type | Name | Description |
|---|---|---|
array | $section | New Section. |
Returns: object — Object of the class instance.
set_registered_settings()
Set the settings fields for registered settings.
Line: 320
public function set_registered_settings( $registered_settings ): object;
| Type | Name | Description |
|---|---|---|
array | $registered_settings | { |
Returns: object — Object of the class instance.
set_upgraded_settings()
Set the settings fields for settings to upgrade.
Line: 332
public function set_upgraded_settings( $upgraded_settings = ... ): object;
| Type | Name | Description |
|---|---|---|
array | $upgraded_settings | Settings array. |
Returns: object — Object of the class instance.
add_custom_menu_page()
Add a menu page to the WordPress admin area.
Line: 345
public function add_custom_menu_page( $menu ): string|false;
| Type | Name | Description |
|---|---|---|
array | $menu | Array of settings for the menu page. |
Returns: string|false — The resulting page’s hook_suffix, or false if the user does not have the capability required.
admin_menu()
Add admin menu.
Line: 423
public function admin_menu( );
get_capability_for_menu() static
Get the appropriate capability for the menu based on the user’s roles and settings.
Line: 446
static public function get_capability_for_menu( $roles = ..., $base_capability = ..., $current_user = ..., $role_capabilities = ... ): string;
| Type | Name | Description |
|---|---|---|
array | $roles | Array of roles to check. |
string | $base_capability | The default capability. |
\WP_User | $current_user | The current user object. |
array | $role_capabilities | Array of role capabilities. |
Returns: string — The capability to use for the menu.
admin_enqueue_scripts()
Enqueue scripts and styles.
Line: 478
public function admin_enqueue_scripts( $hook );
| Type | Name | Description |
|---|---|---|
string | $hook | The current admin page. |
enqueue_scripts_styles() static
Enqueues all scripts, styles, settings, and templates necessary to use the Settings API.
Line: 557
static public function enqueue_scripts_styles( $prefix, $args = ... );
| Type | Name | Description |
|---|---|---|
string | $prefix | Prefix which is used for creating the unique filters and actions. |
array | $args | Array of arguments. |
admin_init()
Initialize and registers the settings sections and fields to WordPress
Usually this should be called at admin_init hook.
This public function gets the initiated settings sections and fields. Then registers them to WordPress and ready for use.
Line: 607
public function admin_init( );
get_registered_settings_types()
Flattens $this->registered_settings into $setting[id] => $setting[type] format.
Line: 668
public function get_registered_settings_types( ): array;
Returns: array — Default settings
settings_defaults()
Default settings.
Line: 693
public function settings_defaults( ): array;
Returns: array — Default settings
get_default_option()
Get the default option for a specific key
Line: 748
public function get_default_option( $key = ... ): mixed;
| Type | Name | Description |
|---|---|---|
string | $key | Key of the option to fetch. |
Returns: mixed
settings_reset()
Reset settings.
Line: 765
public function settings_reset( ): void;
Returns: void
get_sanitize_callback()
Get sanitization callback for given Settings key.
Line: 776
public function get_sanitize_callback( $key = ... ): mixed;
| Type | Name | Description |
|---|---|---|
string | $key | Settings key. |
Returns: mixed — Callback function or false if callback isn’t found.
settings_sanitize()
Sanitize the form data being submitted.
Line: 827
public function settings_sanitize( $input ): array;
| Type | Name | Description |
|---|---|---|
array | $input | Input unclean array. |
Returns: array — Sanitized array
plugin_settings()
Render the settings page.
Line: 919
public function plugin_settings( );
show_navigation()
Show navigations as tab
Shows all the settings section labels as tab
Line: 970
public function show_navigation( );
show_form()
Show the section settings forms
This public function displays every sections in a different form
Line: 1006
public function show_form( );
admin_footer_text()
Add rating links to the admin dashboard
Line: 1072
public function admin_footer_text( $footer_text ): string;
| Type | Name | Description |
|---|---|---|
string | $footer_text | The existing footer text. |
Returns: string — Updated Footer text
settings_help()
Function to add the contextual help in the settings page.
Line: 1087
public function settings_help( );
parse_field_args() static
Parse field arguments with defaults.
Line: 1109
static public function parse_field_args( $field, $section = ... ): array;
| Type | Name | Description |
|---|---|---|
array | $field | Field arguments. |
string | $section | Section name. |
Returns: array — Parsed field arguments.
get_encryption_key() static
Get the encryption key for API key encryption/decryption.
Line: 1147
static public function get_encryption_key( $prefix = ... ): string;
| Type | Name | Description |
|---|---|---|
string | $prefix | Optional prefix for fallback key. |
Returns: string — The encryption key.
encrypt_api_key() static
Encrypts an API key using either OpenSSL or Sodium, if available.
Line: 1159
static public function encrypt_api_key( $key, $prefix = ... ): string;
| Type | Name | Description |
|---|---|---|
string | $key | The API key to encrypt. |
string | $prefix | Optional prefix for fallback key. |
Returns: string — The encrypted API key, or the plain text key if no secure method is available.
decrypt_api_key() static
Decrypts an API key using either OpenSSL or Sodium, if available.
Line: 1193
static public function decrypt_api_key( $encrypted_key, $prefix = ... ): string;
| Type | Name | Description |
|---|---|---|
string | $encrypted_key | The encrypted API key to decrypt. |
string | $prefix | Optional prefix for fallback key. |
Returns: string — The decrypted API key, or the encrypted key if no secure method is available.