User Profile (MySLP_User class)

Account Creation

\MySLP_DSRA::add_account()

Calls \MySLP_Recurring_Payments::add_payment_data()

Params include the user_id and the new payment data array:

Array
(
    [customer_details] => Array
        (
            [id] => cus_RcHfOPMYNHRgo7
            [object] => customer
            [address] => 
            [balance] => 0
            [created] => 1737310780
            [currency] => 
            [default_source] => 
            [delinquent] => 
            [description] => 
            [discount] => 
            [email] => test14@lancecleveland.com
            [invoice_prefix] => 2FDC81BB
            [invoice_settings] => Array
                (
                    [custom_fields] => 
                    [default_payment_method] => 
                    [footer] => 
                    [rendering_options] => 
                )

            [livemode] => 
            [metadata] => Array
                (
                )

            [name] => Lance Cleveland
            [next_invoice_sequence] => 1
            [phone] => 
            [preferred_locales] => Array
                (
                )

            [shipping] => 
            [tax_exempt] => none
            [test_clock] => 
        )

    [latest_response_code] => 200
    [coupon_code] => 
    [PROCESSOR] => stripe
    [PROFILEID] => sub_1Qj360BvHKfBw2LG0LkOaHbg
    [STATUS] => active
    [PROFILESTARTDATE] => 19 January 2025 18:19:40
    [NEXTBILLINGDATE] => 19 February 2025 18:19:40
    [LASTPAYMENTDATE] => 19 January 2025 18:19:40
    [LASTPAYMENTAMT] => 35
    [DESC] => Professional plan billed $35.00 per month
    [PLAN] => Professional
    [AMT] => 35
    [PERIOD] => month
    [IS_GOOD] => 1
    [status] => succeeded
    [referring_site] => 
)

Subscription Creation

\stripe\MySLP_Stripe_Payments::create_subscription()

Creates a Stripe Customer.
Creates a Stripe Subscription.

Returns a subscription data array

Array
(
    [customer_details] => Array
        (
            [id] => cus_RcHfOPMYNHRgo7
            [object] => customer
            [address] => 
            [balance] => 0
            [created] => 1737310780
            [currency] => 
            [default_source] => 
            [delinquent] => 
            [description] => 
            [discount] => 
            [email] => test14@lancecleveland.com
            [invoice_prefix] => 2FDC81BB
            [invoice_settings] => Array
                (
                    [custom_fields] => 
                    [default_payment_method] => 
                    [footer] => 
                    [rendering_options] => 
                )

            [livemode] => 
            [metadata] => Array
                (
                )

            [name] => Lance Cleveland
            [next_invoice_sequence] => 1
            [phone] => 
            [preferred_locales] => Array
                (
                )

            [shipping] => 
            [tax_exempt] => none
            [test_clock] => 
        )

    [latest_response_code] => 200
    [coupon_code] => 
    [PROCESSOR] => stripe
    [PROFILEID] => sub_1Qj360BvHKfBw2LG0LkOaHbg
    [STATUS] => active
    [PROFILESTARTDATE] => 19 January 2025 18:19:40
    [NEXTBILLINGDATE] => 19 February 2025 18:19:40
    [LASTPAYMENTDATE] => 19 January 2025 18:19:40
    [LASTPAYMENTAMT] => 35
    [DESC] => Professional plan billed $35.00 per month
    [PLAN] => Professional
    [AMT] => 35
    [PERIOD] => month
    [IS_GOOD] => 1
    [status] => succeeded
)

Subscription Details

Map Views

These are coming from $myslp->User->mapview_count.

This is coming from \MySLP_User::mapview_count which is managed with magic method setters and getters. The data is stored in the user_meta object within \MySLP_User in a key names “mapview_count”.

Incrementing Map View Counts

This count is updated whenever \MySLP_REST_API::get_map_options() is called (theoretically/assumed to be whenever the map is rendered).

Resetting Map View Count

This is reset to 0 via \myslp_extend_plan() within the myslp-dashboard-helpers module.

Called By
  • \MySLP_Dashboard_Controller::check_subscription()
    Runs when a subscription status is checked, has expired, and is renewed automatically.
    • \myslp_extend_plan()
  • \MySLP_Recurring_Payments::initialize()
    ONLY if payment type is PayPal…
    • \MySLP_Recurring_Payments::get_paypal_checkout_details()
      • \myslp_extend_plan()
  • WPSLP Hook personal_options_update or WPSLP Hook : edit_user_profile_update
    • \MySLP_Customer_Maintenance::update_myslp_profile_management()
      • \myslp_extend_plan()

Payment Info : \MySLP_User::recurring_payments

Your Sites

These are coming from the user meta “user_subscription_status” key as a subarray named “referer_urls”.

\MySLP_User::log_referer()

This adds to the list of referring URLs any time a map URL is requested.

If you look through the documentation (or code) for the slp_rest_geocode_invalid_referer hook, you will see that this is only called when running a geocoding request.

This means that up to the current 2501.XX.YY release of MySLP, the list of sites only shows sites where a geocoding request was called from. This is NOT necessarily all the sites that have requested that a map be displayed.

Used By

\SLP_BaseClass_Admin::enqueue_admin_javascript()

	/**
	 * Enqueues Admin JavaScript for include/admin.js and js/admin.js and js/admin-<tabname>-tab.js (minified if present)
	 *
	 * @used-by \SLP_BaseClass_Admin::add_hooks_and_filters     for WP Hook: admin_enqueue_scripts [10]
	 *
	 * @see https://docs.storelocatorplus.com/development/2022/07/13/debugging-add-locations-w-power-uncaught-syntaxerror-redeclaration-of-const-wp_data/
	 *
	 * @param string $hook
	 */

Generic admin.js script loading

Admin Tab Specific script loading

This loads up javascript files , if they exist, for specific tabs such as “info” or “experience”.

The tab name is simplified by stripping SLP_ADMIN_PAGEPRE . ‘slp_’ from the hook name for the page.

SLP_ADMIN_PAGEPRE is set in the main Store Locator Plus plugin loader.php file as

defined( 'SLP_ADMIN_PAGEPRE' ) || define( 'SLP_ADMIN_PAGEPRE', 'store-locator-plus_page_' );

As of 2501.06.01 this will also check and strip “toplevel_page_slp_” from the hook name to decide it is should enqueue a tab-specific script.

\SLP_BaseClass_Admin::ok_to_enqueue_admin_js()

	/**
	 * Check if it is OK to enqueue the admin JavaScript, assume so if the hook starts with our prefix.
	 *
	 * @param $hook
	 *
	 * @return boolean
	 */

Loops over the \SLP_Admin_UI::menu_items[] array which is an array of arrays where the key is the page key and the subarray contains the dislpay class, the hook name, label, etc. like this:

Called By

\SLP_BaseClass_Admin::enqueue_admin_javascript()

Saving/Changing Style ID

Saving/changing the Style ID (Smart Option: style_id) is what applies the pre-made styles from the Style Server (running on the main SLP site at the moment).

\SLP_SmartOptions::view_appearance()

This method defines the Smart Option for style_id.
It is a hidden field (changed with JS on the old Settings | View interface).
When changed it calls \SLP_SmartOptions::change_style_id() which directly calls \SLP_Style_Manager->change_style() to load the style changes from the style server.

This also sets up related style Smart Option which displays the “style_vision_list” vue based listing.

The now-defunct theme Smart Option is also set, but this is for legacy support and no longer used.

			$smart_options['theme']    = array(
				'type'    => 'hidden',
				'default' => 'a_gallery_style',
			);
			$smart_options['style_id'] = array(
				'type'              => 'hidden',
				'call_when_changed' => array( $this, 'change_style_id' ),
			);
			$smart_options['style']    = array(
				'type'       => 'style_vision_list',
				'show_label' => true,
				'wrapper'    => false,
				'vue'        => true,
			);
			$smart_

\SLP_Style_Manager::change_style_id()

Call stack when clicking “select style” on the legacy “style vision list”:

SLP_SmartOptions.php:320, SLP_SmartOptions->change_style_id()
SLP_SmartOptions.php:539, SLP_SmartOptions->execute_change_callbacks()
SLP_Admin_Settings.php:409, SLP_Admin_Settings->save_options()
SLP_Admin_UI.php:538, SLP_Admin_UI->setup_admin_screen()
class-wp-hook.php:324, WP_Hook->apply_filters()
class-wp-hook.php:348, WP_Hook->do_action()
plugin.php:517, do_action()
class-wp-screen.php:424, WP_Screen->set_current_screen()
screen.php:243, set_current_screen()
admin.php:212, {main}()

Call stack when clicking “activate” on the new style manager (React based) interface:

SLP_SmartOptions.php:320, SLP_SmartOptions->change_style_id()
SLP_SmartOptions.php:539, SLP_SmartOptions->execute_change_callbacks()
SLP_REST_Handler.php:719, SLP_REST_Handler->update_smart_option()
MySLP.php:266, MySLP->rest_dispatch_request_filter()
class-wp-hook.php:324, WP_Hook->apply_filters()
plugin.php:205, apply_filters()
class-wp-rest-server.php:1187, WP_REST_Server->respond_to_request()
class-wp-rest-server.php:1041, WP_REST_Server->dispatch()
class-wp-rest-server.php:431, WP_REST_Server->serve_request()
rest-api.php:424, rest_api_loaded()
class-wp-hook.php:324, WP_Hook->apply_filters()
class-wp-hook.php:348, WP_Hook->do_action()
plugin.php:565, do_action_ref_array()
class-wp.php:418, WP->parse_request()
class-wp.php:813, WP->main()
functions.php:1336, wp()
wp-blog-header.php:16, require()
index.php:17, {main}()

Style Caching

Only the Style Vision list currently caches style info by setting a transient via \SLP_Style_Manager::cache_style(), it does this as it renders each style response returned from the style server while rendering the vision list.

The cache is kept for one week.

The current style comes from a transient that caches the style server responses.

An example entry:

stdClass Object
(
    [id] => 67
    [date] => 2023-02-21T13:38:51
    [date_gmt] => 2023-02-21T18:38:51
    [guid] => stdClass Object
        (
            [rendered] => http://3.211.25.112/?post_type=slp_style_gallery&#038;p=67
        )

    [modified] => 2024-12-21T13:25:44
    [modified_gmt] => 2024-12-21T18:25:44
    [slug] => basic
    [status] => publish
    [type] => slp_style_gallery
    [link] => https://storelocatorplus.com/slp_style_gallery/basic/
    ...

\SLP_SmartOptions::style

This is the style vision list rendering.

This is also used to cache the style settings from the server by comparing \SLP_Style_Manager::current_style->slug versus the \SLP_SmartOptions::style value

Used By

  • \SLP_Style_Manager::style_matches_slug()
    • which is used by \SLP_Style_Manager::set_active_style()
      • which is used by \SLP_Style_Manager::apply_style()

\SLP_SmartOptions::style_id

The actual selected style_id.

WordPress / SaaS Menu Ordering

WordPress

add_menu_page()


add_menu_page( 
string $page_title, 
string $menu_title, 
string $capability, 
string $menu_slug, 
callable $callback = ”, 
string $icon_url = ”, 
int|float $position = null 
): string
WordPress Default Admin Menu Positions
StandardNetwork Admin
2 – Dashboard2 – Dashboard
4 – Separator4 – Separator
5 – Posts5 – Sites
10 – Media10 – Users
15 – Links15 – Themes
20 – Pages20 – Plugins
25 – Comments25 – Settings
30 – Updates
59 – Separator
60 – Appearance
65 – Plugins
70 – Users
75 – Tools
80 – Settings
99 – Separator99 – Separator

add_submenu_page()

SaaS Menu Positions

Standard / UserNetwork Admin
1.10 – MySLP
myslp-dashboard
1.10 – Manage
MYSLP_MANAGE_MENU_SLUG
‘myslp-manage-menu’

10 – Customers
30 – History Log
50 – Cron : System
51 – Cron : User
80 – Database
70 – Addressess
1.20 – Store Locator Plus®
csl-slplus
1.30 – Config
MYSLP_CONFIG_MENU_SLUG
‘myslp-config-menu’

10 – Plans
15 – Plan Limits
20 – Plugins
25 – Email Settings
30 – Payments
70 – System Settings
80- Cache
2 – Dashboard2 – Dashboard
4 – Separator4 – Separator
5 – Posts5 – Sites
10 – Media10 – Users
15 – Links15 – Themes
20 – Pages20 – Plugins
25 – Comments25 – Settings
30 – Updates
59 – Separator
60 – Appearance
65 – Plugins
70 – Users
75 – Tools
80 – Settings
99 – Separator99 – Separator

SITE_ID_CURRENT_SITE vs BLOG_ID_CURRENT_SITE

This is a code consistency/standard thing.

SITE_ID_CURRENT_SITE vs BLOG_ID_CURRENT_SITE vs BLOGID_CURRENT_SITE

Why different options?

MySLP uses a lot of SITE_ID_CURRENT_SITE.
looks to be related to get_network_option() calls.

Some places use BLOG_ID_CURRENT_SITE.
Mostly, but not exclusively, for swith_to_blog() calls.

Both are defined in the Docker composer and both are set to 1.

Looks to be a legacy thing where there was (is?) a plan to have a network (the SITE ID) of blogs (the blog ID). In our case they will be one and the same.

MySLP/v2/locations REST Route Registration Incorrect

Resolved in MySLP Dashboard 2502.05.01

[14-Nov-2024 19:52:23 UTC] PHP Notice:  Function register_rest_route was called incorrectly. 

The REST API route definition for myslp/v2/locations/(?P\d+) is missing the required permission_callback argument.

For REST API routes that are intended to be public, use __return_true as the permission callback.

MySLP_REST_API->register_routes(class WP_REST_Server { protected $namespaces = ['oembed/1.0' => [...], 'myslp/v2' => [...]]; protected $endpoints = ['/' => [...], '/batch/v1' => [...], '/oembed/1.0' => [...], '/oembed/1.0/embed' => [...], '/oembed/1.0/proxy' => [...], '/myslp/v2' => [...], '/myslp/v2/locations' => [...], '/myslp/v2/locations-limit' => [...]]; protected $route_options = []; protected $embed_cache = [] })
/var/www/html/wp-includes/class-wp-hook.php:324

register_rest_route($route_namespace = 'myslp/v2', $route = '/locations/(?P<id>\\d+)', $args = [0 => ['methods' => 'GET', 'callback' => [...], 'permission_callback' => class Closure { ... }], 1 => ['methods' => 'POST, PUT, PATCH', 'callback' => [...]], 2 => ['methods' => 'DELETE', 'callback' => [...], 'args' => [...]]], $override = *uninitialized*)
/var/www/html/wp-content/mu-plugins/myslp-dashboard/include/class.myslp.rest.api.php:110

Google Maps Dequeue/Deregister Incorrect Call

[14-Nov-2024 19:25:43 UTC] PHP Notice:  Function wp_dequeue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the google_maps handle. Please see <a>Debugging in WordPress</a> for more information. (This message was added in version 3.3.0.) in /var/www/html/wp-includes/functions.php on line 6031

[14-Nov-2024 19:25:43 UTC] PHP Notice: Function wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the google_maps handle. Please see <a>Debugging in WordPress</a> for more information. (This message was added in version 3.3.0.) in /var/www/html/wp-includes/functions.php on line 6031

Select STYLE or Make Changes Deprecated Error

If you change settings in Staging , Under Map or View get errors , example:

Deprecated: Calling get_class() without arguments is deprecated in
mu-plugins/store-locator-plus/include/module/admin_tabs/SLP_BaseClass_Admin.php on line 592 

Reproduction

  • Login or switch to Feeding America San Diego on local develop (or staging)
  • Select a new Locator Style (“Feeding America”)
  • Click Select

Dev Notes

Added get_class($this) to the method in SLP_BaseClass_Admin on line 592 as required by PHP 8.