SLP_Power_Admin
extends SLP_BaseClass_Admin
in package
General Admin methods, manage the "Pages" SEO hookups, category filter setup, add/edit category UX.
This allows the main plugin to only include this file in admin mode via the admin_menu call. Reduces the front-end footprint.
Table of Contents
Properties
- $activation : SLP_BaseClass_Activation
- $addon : mixed
- $addon : SLP_BaseClass_Addon
- $admin_page_slug : string
- $class_prefix : string
- $current_group : mixed
- $current_group : string
- $current_section : mixed
- $current_section : string
- $dir : mixed
- $dir : string
- $edit_tags : SLP_Power_Admin_EditTags
- $js_requirements : mixed
- $js_requirements : array<string|int, string>
- $js_settings : mixed
- $js_settings : array<string|int, string>
- $objects : array<string|int, mixed>
- $ok_to_nq_js : bool
- $pages : SLP_Power_Pages_Admin
- $pages : mixed
- $reports2022_tab : SLP_Power_Admin_Reports2022
- $reports2022_tab : mixed
- $saved_option_state : array<string|int, mixed>
- $settings : SLP_Settings
- $settings : mixed
- $settings_interface : mixed
- $settings_interface : SLP_Settings
- $settings_pages : mixed
- $settings_pages : array<string|int, mixed>
- $slplus : SLPlus
- $slplus : SLPlus
- $uses_slplus : bool
- $activation : mixed
- $admin_page_slug : mixed
- $class_prefix : mixed
- $objects : mixed
- $slplus : mixed
- $uses_slplus : mixed
- $edit_tags : mixed
- $info : mixed
- $ok_to_nq_js : mixed
- $saved_option_state : mixed
- $settings_have_been_saved : mixed
Methods
- __construct() : mixed
- __get() : SLPlus_BaseClass_Object
- __isset() : bool
- add_checkbox() : mixed
- Add a checkbox to the settings.
- add_dropdown() : mixed
- Add a dropdown to the settings.
- add_hooks_and_filters() : mixed
- Add our SLP hooks and Filters for Admin Mode
- add_input() : mixed
- Add a input to the settings.
- add_managed_pages() : array<string|int, mixed>
- Add category view page to those we want to allow SLP to manage (add JS, etc.)
- add_meta_links() : string
- Add meta links.
- add_object() : mixed
- add_slp_settings_to_wp_add_category() : mixed
- Render the extra tagalong category fields for the add form.
- add_slp_settings_to_wp_edit_category() : mixed
- Render the extra tagalong category fields for the edit form.
- add_sublabel() : mixed
- Add sublabel.
- add_textarea() : mixed
- Add a textarea to the settings.
- add_upload_meta() : mixed
- Add upload meta.
- assign_location_categories() : mixed
- Assign categories to a given location via the data relation table.
- create_object_pages() : mixed
- Create and attach the admin processing object.
- createstring_FilterByCategoriesDiv() : string
- Create the filter by categories div.
- createstring_FilterByPropertiesDiv() : string
- Create the filter by properties div for the Admin|Locations|Filters drop down
- customize_location_list_displayed_data() : string
- Render the categories column in the manage locations table.
- data_SaveOptions() : mixed
- Save the Pro Pack options to the database in serialized format.
- do_admin_startup() : mixed
- Execute some admin startup things for this add-on pack.
- enqueue_admin_css() : mixed
- If the file admin.css exists and the page prefix starts with slp_ , enqueue the admin style.
- enqueue_admin_javascript() : mixed
- Enqueues Admin JavaScript for include/admin.js and js/admin.js and js/admin-<tabname>-tab.js (minified if present)
- filter_AddCategoriesHeaderToManageLocations() : array<string|int, mixed>
- Add the categories column header to the manage locations table.
- filter_AddFieldHeadersToManageLocations() : array<string|int, mixed>
- Add the images column header to the manage locations table.
- filter_AddOurAdminSlug() : array<string|int, string>
- Add our admin pages to the valid admin page slugs.
- filter_LocationsFilters() : array<string|int, mixed>
- Add more actions to the Bulk Action drop down on the admin Locations/Manage Locations interface.
- get_instance() : SLPlus_BaseClass_Object
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- get_newer_version() : string
- If there is a newer version get the link.
- get_value() : mixed
- Get the value for a specific add-on option. If empty use add-on option_defaults. If still empty use slplus defaults.
- instantiate() : null|object
- Instantiate an object of the noted class.
- option_changed() : mixed
- Return true if the option named by <slug> change after save_my_settings.
- save_current_option_state() : mixed
- Save the current addon option state.
- save_my_settings() : bool
- Use this to save option settings far earlier in the admin process.
- save_SerializedOption() : array<string|int, mixed>
- Merge existing options and POST options, then save to the wp_options table.
- set_addon_properties() : mixed
- Set base class properties so we can have more cross-add-on methods.
- set_properties() : mixed
- Set our properties.
- set_taxonomy_for_location() : array<string|int, mixed>
- Set the Tagalong categories for the new store page.
- set_ValidOptions() : mixed
- Set valid options from the incoming REQUEST
- at_startup() : mixed
- Things to do at startup after this baby is initialized. Override in your class.
- being_deactivated() : bool
- Is this add-on being deactivated?
- initialize() : mixed
- Do these things when this object is invoked. Override in your class.
- ok_to_enqueue_admin_js() : bool
- Check if it is OK to enqueue the admin JavaScript, assume so if the hook starts with our prefix.
- set_default_object_options() : mixed
- Set default options for objects. Override in your class.
- update_install_info() : mixed
- Update the install info for this add on.
- add_setting() : mixed
- Add setting.
- augment_class() : string
- Augment the class names so we can reference simple property names.
- auto_instantiate() : mixed
- Any object with auto_instantiate set to true is instantiate during initialization.
- get_location_marker_html() : string
- Create the map marker HTML for the location display table.
- get_my_checkboxes() : array<string|int, string>
- Return an array of checkbox names for the current settings page being processed.
- is_legacy_needed_for() : mixed
- Is legacy support needed for any active add-on packs?
- needed_for_addon() : bool
- Determine if any add-on packs are installed that require legacy support.
- nq_this_file() : bool
- Enqueue a CSS file.
- update_prior_installs() : mixed
- Update prior add-on pack installations.
Properties
$activation
public
SLP_BaseClass_Activation
$activation
$addon
public
mixed
$addon
$addon
public
SLP_BaseClass_Addon
$addon
$admin_page_slug
public
string
$admin_page_slug
The slug for the admin page.
$class_prefix
public
string
$class_prefix
the prefix that goes before all our classes
$current_group
public
mixed
$current_group
$current_group
public
string
$current_group
Current settings group.
$current_section
public
mixed
$current_section
$current_section
public
string
$current_section
Current settings section.
$dir
public
mixed
$dir
$dir
public
string
$dir
the root directory for this theme
$edit_tags read-only
public
SLP_Power_Admin_EditTags
$edit_tags
The WP tag editor object.
$js_requirements
public
mixed
$js_requirements
= array('jquery')
$js_requirements
public
array<string|int, string>
$js_requirements
An array of the JavaScript hooks that are needed by the userinterface.js script.
$js_settings
public
mixed
$js_settings
= array()
$js_settings
public
array<string|int, string>
$js_settings
JavaScript settings that are to be localized as a
$objects
public
array<string|int, mixed>
$objects
key = class name, array of attributes() auto_instantiate = true , instantiate the object when this object initializes object = the instantiated object options = default startup options subdir = the subdirectory (from theme root) that contains the class definition
$ok_to_nq_js read-only
public
bool
$ok_to_nq_js
keep track of whether we have looked up this capability before or not.
$pages
public
SLP_Power_Pages_Admin
$pages
The pages admin class.
$pages
public
mixed
$pages
$reports2022_tab
public
SLP_Power_Admin_Reports2022
$reports2022_tab
The reports tab.
$reports2022_tab
public
mixed
$reports2022_tab
$saved_option_state read-only
public
array<string|int, mixed>
$saved_option_state
What the option values where before we did admin save.
$settings
public
SLP_Settings
$settings
The tag list settings object.
$settings
public
mixed
$settings
$settings_interface
public
mixed
$settings_interface
$settings_interface
public
SLP_Settings
$settings_interface
$settings_pages
public
mixed
$settings_pages
= array('slp_manage_locations' => array('csv_skip_geocoding', 'csv_clear_messages_on_import', 'load_data'), 'slp-pages' => array('default_comments', 'default_trackbacks', 'pages_replace_websites', 'prevent_new_window', 'prepend_permalink_blog'))
$settings_pages
public
array<string|int, mixed>
$settings_pages
The settings pages we support and the checkboxes that live there:
$settings_pages[
$slplus
public
SLPlus
$slplus
$slplus
public
SLPlus
$slplus
$uses_slplus
public
bool
$uses_slplus
Set to true (default) if the object needs access to the SLPlus plugin object.
$activation
protected
mixed
$activation
$admin_page_slug
protected
mixed
$admin_page_slug
$class_prefix
protected
mixed
$class_prefix
$objects
protected
mixed
$objects
= array()
$slplus
protected
mixed
$slplus
$uses_slplus
protected
mixed
$uses_slplus
= \true
$edit_tags
private
mixed
$edit_tags
$info
private
mixed
$info
$ok_to_nq_js
private
mixed
$ok_to_nq_js
$saved_option_state
private
mixed
$saved_option_state
= array()
$settings_have_been_saved
private
mixed
$settings_have_been_saved
= \false
Methods
__construct()
public
__construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
__get()
public
__get(string $property) : SLPlus_BaseClass_Object
Parameters
- $property : string
Return values
SLPlus_BaseClass_Object__isset()
public
__isset(string $property) : bool
Parameters
- $property : string
Return values
booladd_checkbox()
Add a checkbox to the settings.
public
add_checkbox(string $label, string $description, string $setting) : mixed
Parameters
- $label : string
- $description : string
- $setting : string
add_dropdown()
Add a dropdown to the settings.
public
add_dropdown(string $label, string $description, array<string|int, mixed> $items, string $setting) : mixed
Parameters
- $label : string
- $description : string
- $items : array<string|int, mixed>
- $setting : string
add_hooks_and_filters()
Add our SLP hooks and Filters for Admin Mode
public
add_hooks_and_filters() : mixed
Tags
add_input()
Add a input to the settings.
public
add_input(string $label, string $description, string $setting) : mixed
Parameters
- $label : string
- $description : string
- $setting : string
add_managed_pages()
Add category view page to those we want to allow SLP to manage (add JS, etc.)
public
add_managed_pages( $page_array) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed>add_meta_links()
Add meta links.
public
add_meta_links(array<string|int, string> $links, string $file) : string
Parameters
- $links : array<string|int, string>
- $file : string
Return values
stringadd_object()
public
add_object( $object) : mixed
Parameters
add_slp_settings_to_wp_add_category()
Render the extra tagalong category fields for the add form.
public
add_slp_settings_to_wp_add_category() : mixed
add_slp_settings_to_wp_edit_category()
Render the extra tagalong category fields for the edit form.
public
add_slp_settings_to_wp_edit_category(WP_Term $tag) : mixed
Parameters
- $tag : WP_Term
add_sublabel()
Add sublabel.
public
add_sublabel(string $label[, string $description = '' ]) : mixed
Parameters
- $label : string
- $description : string = ''
add_textarea()
Add a textarea to the settings.
public
add_textarea(string $label, string $description, string $setting) : mixed
Parameters
- $label : string
- $description : string
- $setting : string
add_upload_meta()
Add upload meta.
public
add_upload_meta(array<string|int, mixed>|bool $data, int $attachment_id) : mixed
Parameters
- $data : array<string|int, mixed>|bool
-
Array of meta data for the given attachment, or false if the object does not exist.
- $attachment_id : int
-
Attachment post ID.
assign_location_categories()
Assign categories to a given location via the data relation table.
public
assign_location_categories() : mixed
create_object_pages()
Create and attach the admin processing object.
public
create_object_pages() : mixed
createstring_FilterByCategoriesDiv()
Create the filter by categories div.
public
createstring_FilterByCategoriesDiv() : string
Tags
Return values
stringcreatestring_FilterByPropertiesDiv()
Create the filter by properties div for the Admin|Locations|Filters drop down
public
createstring_FilterByPropertiesDiv() : string
Tags
Return values
stringcustomize_location_list_displayed_data()
Render the categories column in the manage locations table.
public
customize_location_list_displayed_data(string $data, string $field, string $label) : string
Parameters
- $data : string
-
the option_value field data from the database
- $field : string
-
the name of the field from the database (should be sl_option_value)
- $label : string
-
the column label for this column (should be 'Categories')
Tags
Return values
stringdata_SaveOptions()
Save the Pro Pack options to the database in serialized format.
public
data_SaveOptions(array<string|int, string> $cbArray) : mixed
Make sure the options are valid first.
Parameters
- $cbArray : array<string|int, string>
-
The checkbox array need to handle for the null to false operation
do_admin_startup()
Execute some admin startup things for this add-on pack.
public
do_admin_startup() : mixed
enqueue_admin_css()
If the file admin.css exists and the page prefix starts with slp_ , enqueue the admin style.
public
enqueue_admin_css(mixed $hook) : mixed
Parameters
- $hook : mixed
enqueue_admin_javascript()
Enqueues Admin JavaScript for include/admin.js and js/admin.js and js/admin-<tabname>-tab.js (minified if present)
public
enqueue_admin_javascript(string $hook) : mixed
Parameters
- $hook : string
Tags
filter_AddCategoriesHeaderToManageLocations()
Add the categories column header to the manage locations table.
public
filter_AddCategoriesHeaderToManageLocations(array<string|int, mixed> $currentCols) : array<string|int, mixed>
SLP Filter: slp_manage_location_columns
Parameters
- $currentCols : array<string|int, mixed>
-
column name + column label for existing items
Return values
array<string|int, mixed> —column name + column labels, extended with our categories data
filter_AddFieldHeadersToManageLocations()
Add the images column header to the manage locations table.
public
filter_AddFieldHeadersToManageLocations(array<string|int, mixed> $currentCols) : array<string|int, mixed>
SLP Filter: slp_manage_location_columns
Parameters
- $currentCols : array<string|int, mixed>
-
column name + column label for existing items
Return values
array<string|int, mixed> —column name + column labels, extended with our extra fields data
filter_AddOurAdminSlug()
Add our admin pages to the valid admin page slugs.
public
filter_AddOurAdminSlug(array<string|int, string> $slugs) : array<string|int, string>
Parameters
- $slugs : array<string|int, string>
-
admin page slugs
Tags
Return values
array<string|int, string> —modified list of admin page slugs
filter_LocationsFilters()
Add more actions to the Bulk Action drop down on the admin Locations/Manage Locations interface.
public
filter_LocationsFilters(array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
- $items : array<string|int, mixed>
Return values
array<string|int, mixed>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_Objectget_newer_version()
If there is a newer version get the link.
public
get_newer_version() : string
Return values
stringget_value()
Get the value for a specific add-on option. If empty use add-on option_defaults. If still empty use slplus defaults.
public
get_value(string $setting) : mixed
Parameters
- $setting : string
-
The key name for the setting to retrieve.
Return values
mixed —The value of the add-on options[
instantiate()
Instantiate an object of the noted class.
public
instantiate(string $class[, array<string|int, mixed> $options = array() ]) : null|object
Parameters
- $class : string
- $options : array<string|int, mixed> = array()
Return values
null|objectoption_changed()
Return true if the option named by <slug> change after save_my_settings.
public
option_changed(mixed $slug[, mixed $check_boolean_is_true = false ]) : mixed
Parameters
- $slug : mixed
- $check_boolean_is_true : mixed = false
save_current_option_state()
Save the current addon option state.
public
save_current_option_state() : mixed
Used to know what options were set to before an admin save.
save_my_settings()
Use this to save option settings far earlier in the admin process.
public
save_my_settings() : bool
Necessary if you are going to use your options in localized admin scripts.
TODO: Refactor to save_experience_tab_settings
Make sure you set the settings_pages properties so the right checkboxes end up on the right pages.
Return values
boolsave_SerializedOption()
Merge existing options and POST options, then save to the wp_options table.
public
save_SerializedOption(string $optionName, array<string|int, mixed> $currentOptions[, array<string|int, string> $cbOptionArray = null ]) : array<string|int, mixed>
NOTE: USED BY ADD ON PACKS ONLY
TODO: Rewire calls from add on packs afterwards (ELM, POWER, PRO, SME, UML)
Typically used to merge post options from admin interface changes with existing options in a class.
Parameters
- $optionName : string
-
name of option to update
- $currentOptions : array<string|int, mixed>
-
current options as a named array
- $cbOptionArray : array<string|int, string> = null
-
array of options that are checkboxes
Return values
array<string|int, mixed> —the updated options
set_addon_properties()
Set base class properties so we can have more cross-add-on methods.
public
set_addon_properties() : mixed
set_properties()
Set our properties.
public
set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
set_taxonomy_for_location()
Set the Tagalong categories for the new store page.
public
set_taxonomy_for_location(array<string|int, mixed> $pageAttributes) : array<string|int, mixed>
SLP Filter: slp_location_page_attributes
Parameters
- $pageAttributes : array<string|int, mixed>
-
- the wp_insert_post page attributes
Return values
array<string|int, mixed> —- pageAttributes with tax_input set
set_ValidOptions()
Set valid options from the incoming REQUEST
public
set_ValidOptions(mixed $val, string $key) : mixed
Parameters
- $val : mixed
-
- the value of a form var
- $key : string
-
- the key for that form var
at_startup()
Things to do at startup after this baby is initialized. Override in your class.
protected
at_startup() : mixed
being_deactivated()
Is this add-on being deactivated?
protected
being_deactivated() : bool
Return values
boolinitialize()
Do these things when this object is invoked. Override in your class.
protected
initialize() : mixed
ok_to_enqueue_admin_js()
Check if it is OK to enqueue the admin JavaScript, assume so if the hook starts with our prefix.
protected
ok_to_enqueue_admin_js( $hook) : bool
Parameters
Return values
boolset_default_object_options()
Set default options for objects. Override in your class.
protected
set_default_object_options() : mixed
update_install_info()
Update the install info for this add on.
protected
update_install_info() : mixed
add_setting()
Add setting.
private
add_setting(string $label, string $description, string $setting, string $type) : mixed
Parameters
- $label : string
- $description : string
- $setting : string
- $type : string
augment_class()
Augment the class names so we can reference simple property names.
private
augment_class(string $class) : string
Parameters
- $class : string
Return values
stringauto_instantiate()
Any object with auto_instantiate set to true is instantiate during initialization.
private
auto_instantiate() : mixed
get_location_marker_html()
Create the map marker HTML for the location display table.
private
get_location_marker_html() : string
Return values
stringget_my_checkboxes()
Return an array of checkbox names for the current settings page being processed.
private
get_my_checkboxes() : array<string|int, string>
If settings_pages is in use (and it should be) - return the array of checkbox names for the currently active tab (page slug).
Return values
array<string|int, string>is_legacy_needed_for()
Is legacy support needed for any active add-on packs?
private
is_legacy_needed_for(string $fq_method) : mixed
Some add-on packs break when things are updated in the base plugin.
Parameters
- $fq_method : string
-
The specific method we are checking in ClassName::MethodName format.
Tags
needed_for_addon()
Determine if any add-on packs are installed that require legacy support.
private
needed_for_addon(string $fq_method) : bool
Parameters
- $fq_method : string
-
The specific method we are checking in ClassName::MethodName format.
Return values
bool —Whether or not an add-on is in use that requires legacy support.
nq_this_file()
Enqueue a CSS file.
private
nq_this_file(string $hook, string $css_file[, string $augmentation = '' ]) : bool
Parameters
- $hook : string
- $css_file : string
- $augmentation : string = ''
Return values
bool —true if file exists and we did the enqueue (we think)
update_prior_installs()
Update prior add-on pack installations.
private
update_prior_installs() : mixed