SLP_Power_Category_Manager
extends SLPlus_BaseClass_Object
in package
Manage categories for admin, UI, CRON, AJAX, REST.
Table of Contents
Properties
- $addon : SLPPower
- $category_data : SLP_Power_Category_Data
- $location_categories : array<string|int, int>
- $slplus : SLPlus
- $uses_slplus : bool
- $wp_categories : array<string|int, WP_Term>
- $slplus : mixed
- $uses_slplus : mixed
- $cache : array<string|int, object>
- $category_names : array<string|int, string>
- $checklist_cache : array<string|int, object>
- $wp_category_count : int
Methods
- __construct() : mixed
- __get() : SLPlus_BaseClass_Object
- __isset() : bool
- add_location_counts_to_terms() : array<string|int, mixed>
- Add location counts to terms returned by WP get_term
- add_single_quotes() : string
- Add single quotes to a string.
- convert_category_name_list_to_id_list() : string
- Return an comma-separated_string of category IDs by parsing a comma-separated string.
- create_categories_from_location_data() : array<string|int, string>
- Additional processing of CSV records during an import.
- get_categories_from_input() : mixed
- Set the location categories based on the $_REQUEST['tax_input'] values and returns that array of category IDs.
- get_category_count() : int
- Return the number of WP categories available for locations.
- get_category_names() : array<string|int, mixed>
- Get category names.
- get_check_list() : string
- Generate the categories check list.
- get_instance() : SLPlus_BaseClass_Object
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- get_locations_in_category() : WP_Term
- Return location counts in a category.
- get_taxonomy() : array<string|int, mixed>
- Return the categories array, the location_categories property, in a SLP taxonomy notation for WordPress.
- get_taxonomy_from_input() : mixed
- Add the location_categories into a named array with key 'stores' for WP taxonomy processing.
- getCategoryChecklistForVue() : mixed
- Get a list of all categories in a Vue checklist.
- initialize() : mixed
- Things we do at the start.
- render_ExtraCategoryFields() : mixed
- Render the extended category fields on the WordPress add/edit category forms for store_page categories.
- set_categories_from_input() : mixed
- Set the location_categories property from $_REQUEST input.
- set_page_taxonomy() : array<string|int, mixed>
- Set the store page taxonomy (category)
- set_properties() : mixed
- Set our properties.
- update_location_category() : mixed
- Attach category data to the current location.
- add_RecordIfNeeded() : null
- Add a record to the plugin info table if it does not exist.
- create_store_category() : null
- Create the store categories from the CSV data.
- delete_detached_categories() : mixed
- Remove any categories no longer attached to a location from the mapping table.
- get_all_categories() : mixed
- Get all of the SLPlus::locationTaxonomy terms available.
- get_category_by_id() : WP_Term
- Get category by term id.
- map_categories_to_locations() : mixed
- Map categories to their locations in the categories data table.
- reset_current_location_categories() : mixed
- Reset the current location store categories attributes.
Properties
$addon
public
SLPPower
$addon
$category_data
public
SLP_Power_Category_Data
$category_data
The category table database interface.
$location_categories
public
array<string|int, int>
$location_categories
= []
The current location category ID array.
Only set via a $_REQUEST input or CSV file import process.
$slplus
public
SLPlus
$slplus
$uses_slplus
public
bool
$uses_slplus
Set to true (default) if the object needs access to the SLPlus plugin object.
$wp_categories
public
array<string|int, WP_Term>
$wp_categories
$slplus
protected
mixed
$slplus
$uses_slplus
protected
mixed
$uses_slplus
= \true
$cache
private
array<string|int, object>
$cache
= array('categoryChecklistForVue' => '')
$category_names
private
array<string|int, string>
$category_names
The category names, index is the term ID.
$checklist_cache
private
array<string|int, object>
$checklist_cache
$wp_category_count
private
int
$wp_category_count
Count of active categories. Fetch with get_category_count()
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_location_counts_to_terms()
Add location counts to terms returned by WP get_term
public
add_location_counts_to_terms(array<string|int, mixed> $terms, array<string|int, mixed> $taxonomies, array<string|int, mixed> $args[, WP_Term_Query|null $term_query = null ]) : array<string|int, mixed>
Parameters
- $terms : array<string|int, mixed>
-
Array of found terms.
- $taxonomies : array<string|int, mixed>
-
An array of taxonomies.
- $args : array<string|int, mixed>
-
An array of get_terms() arguments.
- $term_query : WP_Term_Query|null = null
-
The WP_Term_Query object. (Only available in WP 4.6+, null otherwise)
Return values
array<string|int, mixed>add_single_quotes()
Add single quotes to a string.
public
add_single_quotes(string $string) : string
Parameters
- $string : string
Tags
Return values
stringconvert_category_name_list_to_id_list()
Return an comma-separated_string of category IDs by parsing a comma-separated string.
public
convert_category_name_list_to_id_list(string $category_name_list) : string
This Cat, That Cat becomes 12,13
Parameters
- $category_name_list : string
-
A string of category names in plain text
Return values
string —A string of category IDs that match those names
create_categories_from_location_data()
Additional processing of CSV records during an import.
public
create_categories_from_location_data(array<string|int, string> $locationData) : array<string|int, string>
Parameters
- $locationData : array<string|int, string>
Tags
Return values
array<string|int, string>get_categories_from_input()
Set the location categories based on the $_REQUEST['tax_input'] values and returns that array of category IDs.
public
get_categories_from_input() : mixed
get_category_count()
Return the number of WP categories available for locations.
public
get_category_count() : int
Return values
intget_category_names()
Get category names.
public
get_category_names() : array<string|int, mixed>
Return values
array<string|int, mixed>get_check_list()
Generate the categories check list.
public
get_check_list(int $post_id) : string
This builds the HTML of
- ... which contains the checklist input elements, it is not the functional checked/unchecked just the DOM interface for it.
Parameters
- $post_id : int
-
the ID for the store page related to the location.
Tags
Return values
string —HTML of the checklist.
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_locations_in_category()
Return location counts in a category.
public get_locations_in_category(int $term_id) : WP_Term
Parameters
- $term_id : int
Return values
WP_Termget_taxonomy()
Return the categories array, the location_categories property, in a SLP taxonomy notation for WordPress.
public get_taxonomy() : array<string|int, mixed>
Return values
array<string|int, mixed>get_taxonomy_from_input()
Add the location_categories into a named array with key 'stores' for WP taxonomy processing.
public get_taxonomy_from_input() : mixed
getCategoryChecklistForVue()
Get a list of all categories in a Vue checklist.
public getCategoryChecklistForVue() : mixed
Tags
initialize()
Things we do at the start.
public initialize() : mixed
render_ExtraCategoryFields()
Render the extended category fields on the WordPress add/edit category forms for store_page categories.
public render_ExtraCategoryFields([int $term_id = null ][, array<string|int, mixed> $category_data = null ]) : mixed
Parameters
- $term_id : int = null
-
the category id.
- $category_data : array<string|int, mixed> = null
-
tagalong data for this category.
set_categories_from_input()
Set the location_categories property from $_REQUEST input.
public set_categories_from_input() : mixed
This is an array of location category IDs passed in from $_REQUEST['tax_input']['stores']. Only sets this if location_categories is empty.
set_page_taxonomy()
Set the store page taxonomy (category)
public set_page_taxonomy(array<string|int, mixed> $page_attributes) : array<string|int, mixed>
Parameters
- $page_attributes : array<string|int, mixed>
Return values
array<string|int, mixed>set_properties()
Set our properties.
public set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
update_location_category()
Attach category data to the current location.
public update_location_category() : mixed
Tags
add_RecordIfNeeded()
Add a record to the plugin info table if it does not exist.
private add_RecordIfNeeded([string $location_id = null ][, string $category_id = null ]) : null
Parameters
- $location_id : string = null
- $category_id : string = null
Return values
nullcreate_store_category()
Create the store categories from the CSV data.
private create_store_category(array<string|int, string> $categoryData) : null
categoryData elements include:
- category
the category name with :: to separate parents and children - description
description of the category - slug
which slug to use - medium_icon
the URL to the icon file - map_marker
the URL for the map marker file
Parameters
- $categoryData : array<string|int, string>
Tags
Return values
nulldelete_detached_categories()
Remove any categories no longer attached to a location from the mapping table.
private delete_detached_categories() : mixed
Tags
get_all_categories()
Get all of the SLPlus::locationTaxonomy terms available.
private get_all_categories() : mixed
get_category_by_id()
Get category by term id.
private get_category_by_id(int $term_id) : WP_Term
Parameters
- $term_id : int
Return values
WP_Termmap_categories_to_locations()
Map categories to their locations in the categories data table.
private map_categories_to_locations() : mixed
$this->location_categories property should already be set.
Does NOT update the currentLocation (wp_store_locator table) attributes.
reset_current_location_categories()
Reset the current location store categories attributes.
private reset_current_location_categories() : mixed