/** * Process the store locator plus shortcode. * * Variables this function uses and passes to the template * we need a better way to pass vars to the template parser so we don't * carry around the weight of these global definitions. * the other option is to unset($GLOBAL['<varname>']) at then end of this * function call. * * We now use $this->plugin->data to hold attribute data. * * @link https://docs.google.com/drawings/d/10HCyJ8vSx8ew59TbP3zrTcv2fVZcedG-eHzY78xyWSA/edit?usp=sharing Flowchart for render_shortcode * @param type $attributes * @param type $content * @return string HTML the shortcode will render */ function render_shortcode($attributes, $content = null) { if (!is_object($this->slplus)) { return sprintf(__('%s is not ready', 'store-locator-le'), __('Store Locator Plus', 'store-locator-le')); } // Force some plugin data properties // $this->slplus->data['radius_options'] = isset($this->slplus->data['radius_options']) ? $this->slplus->data['radius_options'] : ''; // Setup the base plugin allowed attributes // add_filter('slp_shortcode_atts', array($this, 'filter_SetAllowedShortcodes'), 80, 3); /** * FILTER: slp_shortcode_atts * Apply the filter of allowed attributes. * * @param array list of allowed attributes and their defaults * @param array the attribute key=>value pairs from the shortcode being processed [slplus att='val'] * @param array content between the start and end shortcode block, always empty for slplus. */ $attributes = shortcode_atts(apply_filters('slp_shortcode_atts', array(), $attributes, $content), $attributes, 'slplus'); do_action('slp_before_render_shortcode', $attributes); // Set plugin data and options to include the attributes. // TODO: data needs to go away and become part of options. // $this->slplus->data = array_merge($this->slplus->data, (array) $attributes); $this->slplus->options = array_merge($this->slplus->options, (array) $attributes); // If Force Load JavaScript is NOT checked... // Localize the CSL Script - modifies the CSLScript with any shortcode attributes. // Setup the style sheets // if (!$this->slplus->javascript_is_forced) { $this->localize_script(); wp_enqueue_script('csl_script'); $this->setup_stylesheet_for_slplus($attributes['theme']); } $this->set_RadiusOptions(); // Map Actions // add_action('slp_render_map', array($this, 'create_DefaultMap')); // Shortcodes for SLPLUS layouts // add_shortcode('slp_option', array($this, 'create_string_slp_option_value')); add_shortcode('slp_search', array($this, 'createstring_SearchForm')); add_shortcode('slp_map', array($this, 'create_Map')); add_shortcode('slp_mapcontent', array($this, 'create_MapContent')); add_shortcode('slp_maptagline', array($this, 'create_MapTagline')); add_shortcode('slp_results', array($this, 'create_Results')); // Placeholders // $this->slplus->createobject_AddOnManager(); if (!$this->slplus->is_AddOnActive('slp-tagalong')) { add_shortcode('tagalong', array($this, 'createstring_TagalongPlaceholder')); } // Set our flag for later processing // of JavaScript files // if (!defined('SLPLUS_SHORTCODE_RENDERED')) { define('SLPLUS_SHORTCODE_RENDERED', true); } $this->slplus->shortcode_was_rendered = true; // FILTER: slp_layout // $this->slplus->debugMP('slp.main', 'pr', '', $this->slplus->options); $HTML = do_shortcode(apply_filters('slp_layout', $this->slplus->defaults['layout'])); // Remove Shortcodes Not Used Outside Of Here // remove_shortcode('slp_search'); remove_shortcode('slp_map'); remove_shortcode('slp_mapcontent'); remove_shortcode('slp_maptagline'); remove_shortcode('slp_results'); remove_shortcode('tagalong'); do_action('slp_after_render_shortcode', $attributes); return $HTML; }