When testing generate embed for “Freshy” the JS dev tools throws a warning:

[Log] (location.js, line 190)
Warning: foreach() argument must be of type array|object, null given in /var/www/html/wp-content/mu-plugins/store-locator-plus/include/module/ui/SLP_UI_Shortcode_slp_option.php on line 94

As per Foreach loop in SLP_UI_Shortcode_slp_option.php#69

Summary

The Premier and Experience plugins before the 2601.22.01 release were both stripping out any attributes passed into the slp_option shortcode, causing map rendering to not always match what the customer intended.

For the Freshy site, for example, the “search box title” in the display settings for the style selected would always revert to default. Any settings for the search box title would be ignored since Experience and Premier were both stripping out all options.

Findings

Error is coming from \SLP_UI_Shortcode_slp_option::process when processing the incoming $attributes param.

Incoming $attributes param
After the wp_parse_args against the $defaults param

After apply_filters( ‘shortcode_slp_option’, $attributes );

The Junie AI Workaround

		$attributes = apply_filters( 'shortcode_slp_option', $attributes );
		if ( is_null( $attributes ) ) {
			$attributes = array();
		}

SLP filter shortcode_slp_option references

The places shortcode_slp_option are processed…

\SLP_Experience_UI::process_hook_ShortCodeSLPOption

	/**
	 * Processes the SLP shortcode option hook.
	 *
	 * @param array $attributes
	 *
	 * @return void
	 * @uses SLP_UI_Shortcode_slp_option::modify
	 */
    public function process_hook_ShortCodeSLPOption( array $attributes ): void {
		SLP_UI_Shortcode_slp_option::get_instance()->modify( $attributes );
	}

That doesn’t look right… it is not returning the modified options.

The patch…

	/**
	 * Processes the SLP shortcode option hook.
	 *
	 * @uses SLP_UI_Shortcode_slp_option::modify
	 *
	 * @param array $attributes
	 *
	 * @return array
	 */
    public function process_hook_ShortCodeSLPOption( array $attributes ): array {
	    $SLP_UI_Shortcode_slp_option = SLP_UI_Shortcode_slp_option::get_instance();
		return $SLP_UI_Shortcode_slp_option->modify( $attributes );
	}

Leave a Reply