Settings_Util
Utility functions for the Plugin settings.
Tags
Table of Contents
- bool_to_checkbox_setting() : string
 - Convert a checkbox bool value to 'yes' or 'no' (used by WooCommerce).
 - checkbox_setting_to_bool() : bool
 - Convert a checkbox 'yes'/'no' value to a bool.
 - get_checkbox_option() : mixed
 - get_custom_attributes() : mixed
 - get_title_description() : string
 - Return the description for the main title of a settings tab/section including the links below the description (as a filterable array of [ 'url', 'label', 'class' ])
 - is_current_settings_page() : bool
 - Check whether the current page, tab and section match the ones the plugin uses
 - is_current_wc_settings_page() : bool
 - A shorthand of is_current_settings_page for WooCommerce plugins
 
Methods
bool_to_checkbox_setting()
Convert a checkbox bool value to 'yes' or 'no' (used by WooCommerce).
    public
            static    bool_to_checkbox_setting(bool $bool) : string
    
        Parameters
- $bool : bool
 - 
                    
A bool value.
 
Return values
string —'yes' if true, 'no' otherwise.
checkbox_setting_to_bool()
Convert a checkbox 'yes'/'no' value to a bool.
    public
            static    checkbox_setting_to_bool(string $value) : bool
    
        Parameters
- $value : string
 - 
                    
'yes' or 'no'
 
Return values
bool —true if 'yes', false otherwise.
get_checkbox_option()
    public
            static    get_checkbox_option(mixed $option[, mixed $default = false ]) : mixed
        
        Parameters
- $option : mixed
 - $default : mixed = false
 
Return values
mixed —get_custom_attributes()
    public
            static    get_custom_attributes(mixed $field) : mixed
        
        Parameters
- $field : mixed
 
Return values
mixed —get_title_description()
Return the description for the main title of a settings tab/section including the links below the description (as a filterable array of [ 'url', 'label', 'class' ])
    public
            static    get_title_description(Plugin $plugin, string $description) : string
    
        Parameters
- $plugin : Plugin
 - $description : string
 - 
                    
The text of the description
 
Return values
string —is_current_settings_page()
Check whether the current page, tab and section match the ones the plugin uses
    public
            static    is_current_settings_page(string $page[, string $tab = '' ][, string $section = '' ]) : bool
    
        Parameters
- $page : string
 - 
                    
The slug of the page for the plugin settings.
 - $tab : string = ''
 - 
                    
The slug of the tab for the plugin settings. Default to an empty string.
 - $section : string = ''
 - 
                    
The slug of the section for the plugin settings. Default to an empty string.
 
Return values
bool —is_current_wc_settings_page()
A shorthand of is_current_settings_page for WooCommerce plugins
    public
            static    is_current_wc_settings_page(string $section[, string $tab = 'products' ]) : bool
    
        Parameters
- $section : string
 - 
                    
The slug of the section for the plugin settings.
 - $tab : string = 'products'
 - 
                    
The slug of the tab for the plugin settings. Default to 'products'.