Store Locator Plus®

SLP_SmartOptions extends SLPlus_BaseClass_Object

Smart Options setup defines user settings and manages event triggers.

The Smart Options is an object that defines the user settings for Store Locator Plus. It helps define properties that are used to render the administrative UI, default values, and the behavior of the setting throughout the application.

Does things like execute functions when a value changes, set defaults.

The options management for the base plugin (replaces SLPlus->options / SLPlus->options_nojs)

Table of Contents

Properties

$active_style_css  : SLP_Option
$add_tel_to_phone  : SLP_Option
$address_placeholder  : SLP_Option
$admin_notice_dismissed  : mixed
$ajax_orderby_catcount  : SLP_Option
$allow_tag_in_url  : SLP_Option
$append_to_search  : SLP_Option
$block_ip_limit  : SLP_Option
$block_ip_period  : SLP_Option
$block_ip_release_after  : SLP_Option
$change_callbacks  : array<string|int, mixed>
$current_checkboxes  : array<string|int, string>
$db_loading  : bool
$default_country  : string
$default_country  : mixed
$default_icons  : SLP_Option
$distance_unit  : mixed
$dropdown_style  : string
$force_load_js  : SLP_Option
$google_map_style  : SLP_Option
$google_server_key  : mixed
$has_been_setup  : mixed
$hide_address_entry  : SLP_Option
$hide_address_entry  : mixed
$hide_empty  : SLP_Option
$hide_radius_selections  : SLP_Option
$hide_radius_selector  : SLP_Option
$hide_search_form  : SLP_Option
$highlight_uncoded  : SLP_Option
$initial_distance_already_calculated  : bool
$initial_radius  : mixed
$initial_results_returned  : mixed
$instructions  : mixed
$invalid_query_message  : mixed
$ip_whitelist  : SLP_Option
$label_category  : SLP_Option
$label_directions  : mixed
$label_email  : mixed
$label_fax  : mixed
$label_hours  : mixed
$label_image  : mixed
$label_phone  : mixed
$label_radius  : mixed
$label_search  : mixed
$label_website  : mixed
$loading_indicator  : SLP_Option
$log_schedule_messages  : mixed
$map_center  : mixed
$map_center_lat  : mixed
$map_center_lng  : mixed
$map_end_icon  : string
$map_home_icon  : string
$map_initial_display  : SLP_Option
$message_no_results  : SLP_Option
$message_no_results  : mixed
$no_autozoom  : SLP_Option
$no_homeicon_at_start  : SLP_Option
$no_results_gf_id  : SLP_Option
$no_results_interface  : SLP_Option
$page_layout  : array<string|int, mixed>
$page_layout  : mixed
$permalink_flush_needed  : SLP_Option
$premium_subscription_id  : string
$premium_subscription_id  : mixed
$premium_user_id  : string
$premium_user_id  : mixed
$radii  : string
$remove_credits  : mixed
$reporting_enabled  : SLP_Option
$results_box_title  : SLP_Option
$show_cats_on_search  : SLP_Option
$show_icon_array  : SLP_Option
$show_legend_text  : SLP_Option
$show_option_all  : SLP_Option
$slplus  : SLPlus
$smart_properties  : array<string|int, string>
$starting_image  : SLP_Option
$style_id  : int
$style_id  : mixed
$text_options  : array<string|int, string>
$text_options  : mixed
$time_callbacks  : array<string|int, mixed>
$url_allow_address  : SLP_Option
$use_contact_fields  : SLP_Option
$use_nonces  : SLP_Option
$use_pages  : SLP_Option
$use_sensor  : SLP_Option
$uses_slplus  : bool
$zoom_tweak  : mixed
$change_callbacks  : mixed
$slplus  : mixed
$time_callbacks  : mixed
$uses_slplus  : mixed
$current_callback  : mixed
$current_checkboxes  : mixed
$db_loading  : mixed
$initial_distance_already_calculated  : mixed
$initialized  : mixed
$page_options  : mixed
$smart_properties  : mixed

Methods

__construct()  : mixed
__get()  : SLP_Option|null
Get something for non-existent properties.
__isset()  : bool
change_map_center()  : mixed
Things we do when a new map center is set.
change_style_id()  : mixed
Run this when the style ID changes.
create_smart_options()  : mixed
Create smart option objects and set to default_if_empty values.
execute_change_callbacks()  : mixed
Execute the stack of change callbacks.
execute_time_callbacks()  : mixed
Execute the stack of time callbacks.
exists()  : bool
Does the specified slug exist as a smart option?
get_instance()  : SLPlus_BaseClass_Object
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
get_option_name()  : string
Return the property formatted option name.
get_options()  : mixed
Get a list of Smart Options
get_page_options()  : array<string|int, mixed>
Get a list of options that reside on the specified admin page.
get_setting_params()  : array<string|int, mixed>
Get the parameters needed for the SLP_Settings entry.
get_text_options()  : array<string|int, string>
Return a list of option slugs that are text options.
initialize()  : mixed
Things we do at the start.
initialize_after_plugins_loaded()  : mixed
Things we do once after the plugins are loaded.
only_smart_options()  : bool
Return true if the element is an SLP_Option -- call get_options()
recalculate_initial_distance()  : mixed
Recalculate the initial distance for a location from the map center.
save()  : mixed
Save the options for the given admin page.
set()  : bool
Set the smart option value and the legacy options/options_nojs
set_checkboxes()  : mixed
Set incoming REQUEST checkboxes for the current admin page. Only run on admin pages.
set_properties()  : mixed
Set our properties.
set_valid_options()  : bool
Set valid slplus->options and copy to SmartOptions
set_valid_options_nojs()  : bool
Set valid slplus->options_nojs and copy to SmartOptions
slp_specific_setup()  : mixed
Initialize the options properties from the WordPress database.
strip_slashes_if_text()  : mixed
Strip slashes from value if this is a text entry.
trim()  : mixed
Trim the string.
create_general_options()  : mixed
General
create_settings_options()  : mixed
Settings
create_system_wide_options()  : mixed
System Wide Smart Options
experience_map_appearance()  : mixed
Settings / Map / Appearance
experience_map_at_startup()  : mixed
Settings / Map / At Startup
experience_map_functionality()  : mixed
Settings / Map / Functionality
experience_map_markers()  : mixed
Settings / Map / Markers
experience_results_after_search()  : mixed
Settings / Results / After Search
experience_results_at_startup()  : mixed
Settings / Results / At Startup
experience_results_labels()  : mixed
Settings / Results / Labels
experience_search_functionality()  : mixed
Settings / Search / Functionality
experience_search_labels()  : mixed
Settings / Search / Labels
general_admin_addons()  : mixed
General > Admin > Addons
general_admin_messages()  : mixed
General / Admin
general_app_features()  : mixed
General | App | Features
general_app_map_services()  : mixed
General | App | Map Services
general_user_interface()  : mixed
General | User Interface | URL Controls
get_original_value()  : mixed
Remember the original value of a setting before we change it.
get_string_default()  : string
Get string defaults.
results_appearance()  : mixed
Results / Appearance
results_appearance_no_results()  : mixed
Results | Appearance | No Results
set_current_checkboxes()  : mixed
Builds a list of checkboxes for the current admin settings page.
set_text_string_defaults()  : mixed
Set text string defaults.
set_the_val()  : mixed
Set the value of a smart option & legacy option array copy
set_valid_option()  : bool
Set an option in an array only if the key already exists, for empty values set to default.
settings_search_appearance()  : mixed
Settings / Search / Appearance
setup_smart_callback()  : mixed
Set value change callback methods for smart options.
view_appearance()  : mixed
Settings / View / Appearance

Properties

$change_callbacks

public array<string|int, mixed> $change_callbacks

Stack (array) of callbacks in array ( func , params ) format.

$current_checkboxes read-only

public array<string|int, string> $current_checkboxes

Array of smart option checkbox slugs for the current admin screen

$db_loading read-only

public bool $db_loading

True only when processing the option values loaded from the db.

$dropdown_style read-only

public string $dropdown_style

The selected jQuery UI theme for the SLPLUS UI.

$initial_distance_already_calculated read-only

public bool $initial_distance_already_calculated

only do this once per change set.

SLP

$page_layout read-only

public array<string|int, mixed> $page_layout

The page layout array( pages slugs => array( section slugs => array( group_slugs => property slugs ) ) )

$smart_properties read-only

public array<string|int, string> $smart_properties

Array of property names that are smart options.

$style_id read-only

public int $style_id

The active style ID (hidden, works with "style" setting).

$text_options

public array<string|int, string> $text_options

An array of smart option slugs that are text options.

$time_callbacks

public array<string|int, mixed> $time_callbacks

Stack (array) of callbacks for cron jobs in array ( func , params ) format.

$use_sensor

public SLP_Option $use_sensor

TODO: Options for drop downs needs to be hooked to a load_dropdowns method - to offload this overhead so we don't carry around huge arrays for every SLPlus instantiation note: should be called only when rendering the admin page, the option values should go in the include/module/admin_tabs directory in an SLP_Admin_Experience_Dropdown class

$uses_slplus

public bool $uses_slplus

Set to true (default) if the object needs access to the SLPlus plugin object.

$initial_distance_already_calculated

private mixed $initial_distance_already_calculated = \false

Methods

__construct()

public __construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

__isset()

public __isset(string $property) : bool
Parameters
$property : string
Return values
bool

change_map_center()

Things we do when a new map center is set.

public change_map_center() : mixed

TODO: look up the address and set the lat/long.

change_style_id()

Run this when the style ID changes.

public change_style_id( $key,  $old_val,  $new_val) : mixed
Parameters
$key :
$old_val :
$new_val :

create_smart_options()

Create smart option objects and set to default_if_empty values.

public create_smart_options(array<string|int, mixed> $smart_option_params[, array<string|int, mixed> $defaults = array() ]) : mixed
Parameters
$smart_option_params : array<string|int, mixed>

An array of smart option attributes.

$defaults : array<string|int, mixed> = array()

If not empty, set this as the default for every smart_option_params entry.

execute_change_callbacks()

Execute the stack of change callbacks.

public execute_change_callbacks() : mixed

Use this to run callbacks after all options have been updated.

Tags
used-by

\SLP_SmartOptions::save

used-by

\SLP_Admin_General::save_options

used-by

\SLP_Admin_Settings::save_options

used-by

\SLP_AJAX::slp_change_option

used-by

\SLP_SmartOptions::set

used-by

\SLP_UI::localize_script

used-by

\SLP_BaseClass_Activation::convert_to_smartoptions

execute_time_callbacks()

Execute the stack of time callbacks.

public execute_time_callbacks() : mixed

Use this to run callbacks after all options have been updated.

exists()

Does the specified slug exist as a smart option?

public exists(string $property) : bool
Parameters
$property : string
Return values
bool

get_instance()

Return an instance of the object which is also registered to the slplus global less the SLP_ part.

public static get_instance([bool $no_global = false ][, mixed $params = array() ]) : SLPlus_BaseClass_Object

TODO: PHP7.4 and PHP8.0 the static instance variable returns an object matching $class TODO: PHP8.1 the static instance continually returns the FIRST object (SLP_Admin_Helper) every time -- it is like PHP8.1 static instance is bound to base_class-object versus the calling class object

Parameters
$no_global : bool = false

set to true to skip assigning object to SLP global as a property.

$params : mixed = array()

object init params

Return values
SLPlus_BaseClass_Object

get_option_name()

Return the property formatted option name.

public get_option_name( $property) : string
Parameters
$property :
Return values
string

get_options()

Get a list of Smart Options

public get_options() : mixed
Tags
uses
SLP_SmartOptions::only_smart_options

get_page_options()

Get a list of options that reside on the specified admin page.

public get_page_options(string $admin_page) : array<string|int, mixed>
Parameters
$admin_page : string
Return values
array<string|int, mixed>

get_setting_params()

Get the parameters needed for the SLP_Settings entry.

public get_setting_params(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>
Return values
array<string|int, mixed>

get_text_options()

Return a list of option slugs that are text options.

public get_text_options() : array<string|int, string>
Return values
array<string|int, string>

initialize_after_plugins_loaded()

Things we do once after the plugins are loaded.

public initialize_after_plugins_loaded() : mixed

only_smart_options()

Return true if the element is an SLP_Option -- call get_options()

public static only_smart_options(mixed $element) : bool
Parameters
$element : mixed
Tags
used-by

\SLP_SmartOptions::get_options

Return values
bool

recalculate_initial_distance()

Recalculate the initial distance for a location from the map center.

public recalculate_initial_distance() : mixed

Called if 'distance_unit' changes.

call_when_changed alway gets 3 params whether or not they are used...

save()

Save the options for the given admin page.

public save([string $admin_page = '' ]) : mixed
Parameters
$admin_page : string = ''

set()

Set the smart option value and the legacy options/options_nojs

public set( $property,  $value[, bool $writeToDB = false ]) : bool
Parameters
$property :
$value :
$writeToDB : bool = false
Return values
bool

set_checkboxes()

Set incoming REQUEST checkboxes for the current admin page. Only run on admin pages.

public set_checkboxes(string $admin_page) : mixed
Parameters
$admin_page : string

set_properties()

Set our properties.

public set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

set_valid_options()

Set valid slplus->options and copy to SmartOptions

public set_valid_options( $val,  $key) : bool
Parameters
$val :
$key :
Return values
bool

set_valid_options_nojs()

Set valid slplus->options_nojs and copy to SmartOptions

public set_valid_options_nojs( $val,  $key) : bool
Parameters
$val :
$key :
Return values
bool

slp_specific_setup()

Initialize the options properties from the WordPress database.

public slp_specific_setup() : mixed

Called by MySLP Dashboard.

strip_slashes_if_text()

Strip slashes from value if this is a text entry.

public strip_slashes_if_text(string &$val, string $key) : mixed
Parameters
$val : string
$key : string

trim()

Trim the string.

public trim(string $key, string $old_val, string $new_val) : mixed
Parameters
$key : string
$old_val : string
$new_val : string

create_general_options()

General

private create_general_options() : mixed

create_settings_options()

Settings

private create_settings_options() : mixed

create_system_wide_options()

System Wide Smart Options

private create_system_wide_options() : mixed

experience_map_appearance()

Settings / Map / Appearance

private experience_map_appearance() : mixed

experience_map_at_startup()

Settings / Map / At Startup

private experience_map_at_startup() : mixed

experience_map_functionality()

Settings / Map / Functionality

private experience_map_functionality() : mixed

experience_map_markers()

Settings / Map / Markers

private experience_map_markers() : mixed

Settings / Results / After Search

private experience_results_after_search() : mixed

experience_results_at_startup()

Settings / Results / At Startup

private experience_results_at_startup() : mixed

experience_results_labels()

Settings / Results / Labels

private experience_results_labels() : mixed

experience_search_functionality()

Settings / Search / Functionality

private experience_search_functionality() : mixed

experience_search_labels()

Settings / Search / Labels

private experience_search_labels() : mixed

general_admin_addons()

General > Admin > Addons

private general_admin_addons() : mixed

general_admin_messages()

General / Admin

private general_admin_messages() : mixed

general_app_features()

General | App | Features

private general_app_features() : mixed

general_app_map_services()

General | App | Map Services

private general_app_map_services() : mixed

general_user_interface()

General | User Interface | URL Controls

private general_user_interface() : mixed

get_original_value()

Remember the original value of a setting before we change it.

private get_original_value( $new_value,  $key,  &$option_array,  $is_smart_option,  $valid_legacy_option) : mixed
Parameters
$new_value :
$key :
$option_array :
$is_smart_option :
$valid_legacy_option :

get_string_default()

Get string defaults.

private get_string_default(string $key) : string
Parameters
$key : string

key name for string to translate

Return values
string

results_appearance()

Results / Appearance

private results_appearance() : mixed

results_appearance_no_results()

Results | Appearance | No Results

private results_appearance_no_results() : mixed

set_current_checkboxes()

Builds a list of checkboxes for the current admin settings page.

private set_current_checkboxes(string $admin_page) : mixed
Parameters
$admin_page : string

set_text_string_defaults()

Set text string defaults.

private set_text_string_defaults() : mixed

set_the_val()

Set the value of a smart option & legacy option array copy

private set_the_val( $value,  $key,  &$option_array,  $is_smart_option,  $valid_legacy_option) : mixed
Parameters
$value :
$key :
$option_array :
$is_smart_option :
$valid_legacy_option :

set_valid_option()

Set an option in an array only if the key already exists, for empty values set to default.

private set_valid_option(mixed $val, string $key, string $which_option) : bool

External classes should use set_valid_options / set_valid_options_nojs.

Parameters
$val : mixed

the value of a form var

$key : string

the key for that form var

$which_option : string

which array to use

Return values
bool

settings_search_appearance()

Settings / Search / Appearance

private settings_search_appearance() : mixed

setup_smart_callback()

Set value change callback methods for smart options.

private setup_smart_callback( $key,  $original_value) : mixed

That are defined as on this page (or the page is not defined) Whose original value from slplus->options or slplus->options_nojs DOES NOT match the new value (from the DB usually) ... reset the original value temp var to the smart option default value (if provided , null if not provided) ... and set the smart option to the new value if not empty or the smart option default if the new value was empty

Parameters
$key :
$original_value :

view_appearance()

Settings / View / Appearance

private view_appearance() : mixed

        
On this page

Search results