/** * Build an HTML string to show under the theme selection box. * * @return string */ private function createstring_ThemeDetails() { $HTML = "<div id='{$this->current_slug}_details' class='theme_details'>"; // Description // $HTML .= $this->slplus->helper->create_SubheadingLabel(__('About This Theme', 'csa-slplus')); if (empty($this->themeDetails[$this->current_slug]['description'])) { $HTML .= __('No description has been set for this theme.', 'csa-slplus'); } else { $HTML .= $this->themeDetails[$this->current_slug]['description']; } $HTML .= '<p>' . __('Learn more about changing the Store Locator Plus interface via the ', 'csa-slplus') . sprintf('<a href="%s" target="csa">%s</a>', $this->support_url . 'user-experience/view/themes-custom-css/', __('Custom Themes documentation.', 'csa-slplus')) . '</p>'; // Add On Packs // if (!empty($this->themeDetails[$this->current_slug]['add-ons'])) { // List The Add On Packs Wanted // $HTML .= $this->slplus->helper->create_SubheadingLabel(__('Add On Packs', 'csa-slplus')); $active_HTML = ''; $inactive_HTML = ''; $this->slplus->createobject_AddOnManager(); $addon_list = explode(',', $this->themeDetails[$this->current_slug]['add-ons']); foreach ($addon_list as $slug) { $slug = trim(strtolower($slug)); if (isset($this->slplus->add_ons->available[$slug])) { // Show Active Add Ons // if ($this->slplus->add_ons->is_active($slug)) { $active_HTML .= "<li class='product active'>" . $this->slplus->add_ons->get_product_url($slug) . '</li>'; // Add to inactive HTML string // } else { $inactive_HTML .= "<li class='product inactive'>" . $this->slplus->add_ons->get_product_url($slug) . '</li>'; } } } $HTML .= '</ul>'; // Add active add on pack list // if (!empty($active_HTML)) { $HTML .= __('This theme will make use of these add-on packs:', 'csa-slplus') . '<ul>' . $active_HTML . '</ul>'; } // Add inactive add on pack list // if (!empty($inactive_HTML)) { $HTML .= __('This theme works best if you activate the following add-on packs:', 'csa-slplus') . '<ul>' . $inactive_HTML . '</ul>'; } // Add the options section // $HTML .= $this->createstring_ThemeOptions(); } $HTML .= '</div>'; return $HTML; }
/** * Build the Google settings panel. */ function build_ServerSection() { $this->slplus->createobject_AddOnManager(); $sectName = __('Server', 'csa-slplus'); $this->settings->add_section(array('name' => $sectName)); $groupName = __('Geocoding', 'csa-slplus'); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'label' => __('Server-To-Server Speed', 'csa-slplus'), 'setting' => 'http_timeout', 'use_prefix' => false, 'type' => 'list', 'value' => $this->slplus->options_nojs['http_timeout'], 'custom' => array('Slow' => '30', 'Normal' => '10', 'Fast' => '3'), 'description' => __('How fast is your server when communicating with other servers like Google? ', 'csa-slplus') . __('Set this to slow if you get frequent geocoding errors but geocoding works sometimes. ', 'csa-slplus') . __('Set this to fast if you never have geocoding errors and are bulk loading more than 100 locations at a time. ', 'csa-slplus'))); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'label' => __('Geocode Retries', 'csa-slplus'), 'setting' => 'geocode_retries', 'type' => 'list', 'value' => get_option(SLPLUS_PREFIX . '-geocode_retries', '3'), 'custom' => array('None' => 0, '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10'), 'description' => __('How many times should we try to set the latitude/longitude for a new address? ', 'csa-slplus') . __('Higher numbers mean slower bulk uploads. ', 'csa-slplus') . __('Lower numbers make it more likely the location will not be set during bulk uploads. ', 'csa-slplus') . sprintf(__('Bulk import or re-geocoding is a %s feature.', 'csa-slplus'), $this->slplus->add_ons->available['slp-pro']['link']))); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'label' => __('Maximum Retry Delay', 'csa-slplus'), 'setting' => 'retry_maximum_delay', 'use_prefix' => false, 'value' => $this->slplus->options_nojs['retry_maximum_delay'], 'description' => __('Maximum time to wait between retries, in seconds. ', 'csa-slplus') . __('Use multiples of 1. ', 'csa-slplus') . __('Recommended value is 5. ', 'csa-slplus') . sprintf(__('Bulk import or re-geocoding is a %s feature.', 'csa-slplus'), $this->slplus->add_ons->available['slp-pro']['link']))); // Google License // $groupName = __('Google Business License', 'csa-slplus'); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'label' => __('Google Client ID', 'csa-slplus'), 'setting' => 'google_client_id', 'use_prefix' => false, 'value' => $this->slplus->options_nojs['google_client_id'], 'description' => __('If you have a Google Maps for Work client ID, enter it here. ', 'csa-slplus') . __('All Google API requests will go through your account at Google. ', 'csa-slplus') . __('You will receive higher quotas and faster maps I/O performance. ', 'csa-slplus'))); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'label' => __('Google Private Key', 'csa-slplus'), 'setting' => 'google_private_key', 'use_prefix' => false, 'value' => $this->slplus->options_nojs['google_private_key'], 'description' => __('Your Google private key (Crypto Key) for signing Geocoding requests. ', 'csa-slplus') . __('Do NOT share this with anyone and take extra measures to keep it private. ', 'csa-slplus'))); // ACTION: slp_generalsettings_modify_googlepanel // params: settings object, section name do_action('slp_generalsettings_modify_googlepanel', $this->settings, $sectName); }
/** * Localize the CSL Script */ public function localize_script() { $this->slplus->debugMP('slp.main', 'msg', 'SLPlus_UI:' . __FUNCTION__); // Handle any IconAttributes optionally set using the shortcode in combination with the Pro Pack $this->handleIconAttributes('map_home_icon', 'homeicon'); $this->handleIconAttributes('map_end_icon', 'endicon'); $slplus_home_icon_file = str_replace(SLPLUS_ICONURL, SLPLUS_ICONDIR, $this->slplus->options['map_home_icon']); $slplus_end_icon_file = str_replace(SLPLUS_ICONURL, SLPLUS_ICONDIR, $this->slplus->options['map_end_icon']); $this->slplus->data['home_size'] = function_exists('getimagesize') && file_exists($slplus_home_icon_file) ? getimagesize($slplus_home_icon_file) : array(0 => 20, 1 => 34); $this->slplus->data['end_size'] = function_exists('getimagesize') && file_exists($slplus_end_icon_file) ? getimagesize($slplus_end_icon_file) : array(0 => 20, 1 => 34); add_shortcode('slp_location', array($this, 'process_slp_location_Shortcode')); // Load up some basic options. // This can probably be handled better. // $this->slplus->options['use_sensor'] = get_option(SLPLUS_PREFIX . '_use_location_sensor', 0) == 1; // Set starting map center // $this->slplus->options['map_center'] = $this->set_MapCenter(); // Environment // $this->slplus->createobject_AddOnManager(); $environment['addons'] = $this->slplus->add_ons->get_versions(); // Lets get some variables into our script. // "Higher Level" JS Options are those noted below. // // TODO: ALL of these options should go inside the options property other than plugin_url, core_url. // $scriptData = array('plugin_url' => SLPLUS_PLUGINURL, 'disable_scroll' => get_option(SLPLUS_PREFIX . '_disable_scrollwheel') == 1, 'map_3dcontrol' => get_option(SLPLUS_PREFIX . '_disable_largemapcontrol3d') == 0, 'map_home_sizew' => $this->slplus->data['home_size'][0], 'map_home_sizeh' => $this->slplus->data['home_size'][1], 'map_end_sizew' => $this->slplus->data['end_size'][0], 'map_end_sizeh' => $this->slplus->data['end_size'][1], 'map_scalectrl' => get_option(SLPLUS_PREFIX . '_disable_scalecontrol') == 0, 'map_typectrl' => get_option(SLPLUS_PREFIX . '_disable_maptypecontrol') == 0, 'msg_noresults' => $this->slplus->settings->get_item('message_noresultsfound', 'No results found.', '_'), 'results_string' => $this->set_ResultsLayout(false), 'overview_ctrl' => get_option('sl_map_overview_control', 0), 'zoom_tweak' => get_option('sl_zoom_tweak', 1), 'environment' => apply_filters('slp_js_environment', $environment), 'options' => apply_filters('slp_js_options', $this->slplus->options)); $this->slplus->debugMP('slp.main', 'pr', 'Script Data', $scriptData); remove_shortcode('slp_location'); // AJAX URL Stuff // $scriptData['ajaxurl'] = admin_url('admin-ajax.php'); $scriptData['nonce'] = wp_create_nonce('em'); wp_localize_script('csl_script', 'slplus', $scriptData); }
/** * Register an add-on pack. * * @param string $slug * @param object $object */ private function register_addon($slug, $object) { $this->slplus->createobject_AddOnManager(); $this->slplus->add_ons->register($slug, $object); // TODO: remove this when all add-on packs reference $this->slplus->add_ons->instances vs. $this->slplus->addons (GFI, MMap) // $this->slplus->addons[$slug] = $object; }
/** * 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', 'csa-slplus'), __('Store Locator Plus', 'csa-slplus')); } $this->slplus->debugMP('msg', get_class() . '::' . __FUNCTION__); // Force some plugin data properties // $this->slplus->data['radius_options'] = isset($this->slplus->data['radius_options']) ? $this->slplus->data['radius_options'] : ''; // Load from plugin object data table first, // attributes trump options // $this->slplus->loadPluginData(); // 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. // $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->localizeSLPScript(); wp_enqueue_script('csl_script'); $this->setup_stylesheet_for_slplus(); } $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->add_ons->is_active('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; }