Bug report

The Label for RESULTS PHONE is not appearing in front end

Recreation on QC

Set style on QC to “Default”.

Settings | Results | Results Layout:

<div id=”slp_results_[slp_location id]” class=”results_entry location_primary [slp_location featured]”> <div class=”results_row_left_column” id=”slp_left_cell_[slp_location id]” > [slp_addon section=primary position=first] <span class=”location_name”>[slp_location name] [slp_location uml_buttons] [slp_location gfi_buttons]</span> <span class=”location_distance”>[slp_location distance_1] [slp_location distance_unit]</span> [slp_addon section=primary position=last] </div> <div class=”results_row_center_column location_secondary” id=”slp_center_cell_[slp_location id]” > [slp_addon section=secondary position=first] <span class=”slp_result_address slp_result_street”>[slp_location address]</span> <span class=”slp_result_address slp_result_street2″>[slp_location address2]</span> <span class=”slp_result_address slp_result_citystatezip”>[slp_location city_state_zip]</span> <span class=”slp_result_address slp_result_country”>[slp_location country]</span> <div class=”contact_info”> <span class=”slp_result_address slp_result_phone”>[slp_location phone]</span> <span class=”slp_result_address slp_result_fax”>[slp_location fax]</span> </div> [slp_addon section=secondary position=last] </div> <div class=”results_row_right_column location_tertiary” id=”slp_right_cell_[slp_location id]” > [slp_addon section=tertiary position=first] <div class=”online_info”> <span class=”slp_result_contact slp_result_website”>[slp_location web_link]</span> <span class=”slp_result_contact slp_result_email”>[slp_location email_link]</span> <span class=”slp_result_contact slp_result_directions”><a href=”https://[slp_option map_domain]/maps?saddr=[slp_location search_address]&daddr=[slp_location location_address]” target=”_blank” class=”storelocatorlink”>[slp_location directions_text]</a></span> </div> <span class=”slp_result_contact slp_result_hours textblock”>[slp_location hours]</span> [slp_location pro_tags] [slp_location iconarray wrap=”fullspan”] [slp_location eventiconarray wrap=”fullspan”] [slp_location socialiconarray wrap=”fullspan”] [slp_addon section=tertiary position=last] </div> </div>

Settings | Results | Labels | Phone

Phone

Front End Output

Runtime Processing

The PHP-side preparation when loading the page…

This is what gets the JavaScript setup with proper variables like the results layout that will be processed when data comes back on future AJAX/REST calls.

\SLP_UI::set_ResultsLayout()
Set the results layout string.
--> \SLP_UI_Shortcode_slp_location::check_formatting()
evaluates/tweaks shortcode
<--
...
--> \SLP_UI_Shortcode_slp_location::stop_checking_format()
---> \SLP_UI_Shortcode::activate() 
activates the shortcode
In this case adds [slp_location] processing to point to 
---> \SLP_UI_Shortcode_slp_location::process()
When WordPress is ready to process that shortcode via the do_shortcode() call (we do not use the protected callback for the process() method that lives in SLP_UI_Shortcode for the [slp_location] shortcode

When this is done it is basically crafting a string that is the results layout with shortcodes, completely tweaked for modifiers. This gets passed to JavaScript via \SLP_UI::add_to_js_options() for processing in the core JS. This is invoked when localizing the scripts via the WordPress filter slp_js_options which is invoked via \SLP_UI::localize_script() which happens when [slplus…] shortcodes are rendered.

The shortcode render function is set here: \SLP_UI::initialize()

User Interaction Processing

This is managed via JavaScript when a user adds an address or when the page first loads (if show results automatically is enabled).

slp_core.js : front end shortcode processor

slp_Map.createSidebar()
manages results layout processing, it is called for each location returned from the backend via a JavaScript AJAX (or REST) call.
--> String.replace_shortcodes()
This string prototype is what parses the results.

The JavaScript replace_shortcodes() will manage output using this array to determine what goes where (this is post string manipulation and right before output):

Example "current location" data: 

{
  "name": "Desiree",
  "address": "",
  "address2": "",
  "city": "Kansas City ",
  "state": "KS",
  "zip": "",
  "country": "",
  "lat": "39.115531",
  "lng": "-94.626787",
  "description": "",
  "url": "",
  "sl_pages_url": "",
  "email": "",
  "email_link": "",
  "hours": "",
  "phone": "(888) 555-1212",
  "fax": "",
  "image": "",
  "distance": "151.8893462669",
  "tags": "",
  "option_value": "",
  "attributes": "",
  "id": "253",
  "linked_postid": "209",
  "neat_title": "",
  "data": {
    "sl_id": "253",
    "sl_store": "Desiree",
    "sl_address": "",
    "sl_address2": "",
    "sl_city": "Kansas City ",
    "sl_state": "KS",
    "sl_zip": "",
    "sl_country": "",
    "sl_latitude": "39.115531",
    "sl_longitude": "-94.626787",
    "sl_tags": "",
    "sl_description": "",
    "sl_email": "",
    "sl_url": "",
    "sl_hours": "",
    "sl_phone": "(888) 555-1212",
    "sl_fax": "",
    "sl_image": "",
    "sl_private": "0",
    "sl_neat_title": "",
    "sl_linked_postid": "209",
    "sl_pages_url": "http://localhost:3000/?post_type=store_page&p=209",
    "sl_pages_on": "",
    "sl_option_value": "",
    "sl_initial_distance": "151.8893462669",
    "sl_lastupdated": "2022-08-29 20:27:09",
    "id": "226",
    "featured": "0",
    "rank": null,
    "marker": null,
    "sl_distance": "151.8893462669"
  },
  "city_state_zip": "Kansas City , KS",
  "zip_state_city": "<span class=\"slp_state\">KS</span> <span class=\"slp_city\">Kansas City </span>",
  "web_link": "",
  "url_link": "",
  "contact_image_html": "",
  "categories": [],
  "category_count": 0,
  "category_names": "",
  "icon": "",
  "iconarray": "",
  "exdata": {
    "featured": "0"
  },
  "featured": "0",
  "rank": "",
  "position": {
    "lat": 39.115531,
    "lng": -94.626787
  },
  "pro_tags": "",
  "phone_with_label": "Phone(888) 555-1212",
  "fax_with_label": "",
  "location_address": "%2C%20Kansas%20City%20%2C%20KS",
  "search_address": "United%20States",
  "hours_sanitized": ""
}

Results: Working As Intended

Currently the phone output will NOT output the label with the shortcode:

[slp_location phone]

Instead you need to replace that with shortcode:

[slp_location phone_with_label]

See…