/** * This is called whenever the WordPress wp_enqueue_scripts action is called. */ function wp_enqueue_scripts() { $this->slplus->debugMP('slp.main', 'msg', 'SLPlus_Actions:' . __FUNCTION__); $this->slplus->debugMP('slp.main', 'msg', '', $this->slplus->javascript_is_forced ? 'force load' : 'late loading'); //------------------------ // Register our scripts for later enqueue when needed // if (!$this->slplus->is_CheckTrue(get_option(SLPLUS_PREFIX . '-no_google_js', '0'))) { // Google Maps API for Work client ID // $client_id = !empty($this->slplus->options_nojs['google_client_id']) ? '&client=' . $this->slplus->options_nojs['google_client_id'] . '&v=3' : ''; // Set the map language // $language = '&language=' . $this->slplus->helper->getData('map_language', 'get_item', null, 'en'); // Base Google API URL // $google_api_url = 'http' . (is_ssl() ? 's' : '') . '://' . $this->slplus->options['map_domain'] . '/maps/api/' . 'js' . '?sensor=false'; // Enqueue the script // wp_enqueue_script('google_maps', $google_api_url . $client_id . $language, array(), SLPLUS_VERSION, !$this->slplus->javascript_is_forced); } $sslURL = is_ssl() ? preg_replace('/http:/', 'https:', SLPLUS_PLUGINURL) : SLPLUS_PLUGINURL; // Force load? Enqueue and localize. // if ($this->slplus->javascript_is_forced) { wp_enqueue_script('csl_script', $sslURL . '/js/slp.js', array('jquery'), SLPLUS_VERSION, !$this->slplus->javascript_is_forced); $this->slplus->UI->localize_script(); $this->slplus->UI->setup_stylesheet_for_slplus(); // No force load? Register only. // Localize happens when rendering a shortcode. // } else { wp_register_script('csl_script', $sslURL . '/js/slp.js', array('jquery'), SLPLUS_VERSION, !$this->slplus->javascript_is_forced); } }
/** * Return true if the database is extended and has an extended data table. * * @return boolean */ public function has_ExtendedData() { if ($this->slplus->is_CheckTrue($this->slplus->options_nojs['extended_data_tested'])) { return $this->slplus->is_CheckTrue($this->slplus->options_nojs['has_extended_data']); } return $this->set_extended_data_tested(); }
/** * Add the left column to the add/edit locations form. * * @param string the html of the base form. * @return string HTML of the form inputs */ function filter_EditLocationLeft_Address($starting_html) { $HTML = $this->slplus->helper->create_SubheadingLabel(__('Address', 'csa-slplus')) . $this->createstring_InputElement('store', __('Name', 'csa-slplus'), $this->slplus->currentLocation->store) . $this->createstring_InputElement('address', __('Street - Line 1', 'csa-slplus'), $this->slplus->currentLocation->address) . $this->createstring_InputElement('address2', __('Street - Line 2', 'csa-slplus'), $this->slplus->currentLocation->address2) . $this->createstring_InputElement('city', __('City, State, ZIP', 'csa-slplus'), $this->slplus->currentLocation->city, 'mediumfield', true) . $this->createstring_InputElement('state', '', $this->slplus->currentLocation->state, 'shortfield', true) . $this->createstring_InputElement('zip', '', $this->slplus->currentLocation->zip, 'shortfield') . $this->createstring_InputElement('country', __('Country', 'csa-slplus'), $this->slplus->currentLocation->country) . $this->createstring_InputElement('latitude', __('Latitude (N/S)', 'csa-slplus'), $this->slplus->currentLocation->latitude, '', false, 'input', __('Leave blank to have Google look up the latitude.', 'csa-slplus')) . $this->createstring_InputElement('longitude', __('Longitude (E/W)', 'csa-slplus'), $this->slplus->currentLocation->longitude, '', false, 'input', __('Leave blank to have Google look up the longitude.', 'csa-slplus')); $HTML .= $this->slplus->helper->CreateCheckboxDiv("private-{$this->slplus->currentLocation->id}", __('Private Entry', 'csa-slplus'), __('If checked the listing will not show up in location search results.', 'csa-slplus'), '', false, 0, $this->slplus->is_CheckTrue($this->slplus->currentLocation->private)); $HTML .= '<p class="text_info">' . sprintf('<a href="%s" target="csa" alt="%s" title="%s">%s</a>', 'http://www.latlong.net', __('Latitude/Longitude lookup.', 'csa-slplus'), __('Latitude/Longitude lookup.', 'csa-slplus'), __('The LatLong.net website can help you locate an exact latitude/longitude.', 'csa-slplus')) . '</p>'; return $HTML . $starting_html; }
/** * Build the admin settings panel. */ function build_AdminSettingsPanel() { $panel_name = __('Admin', 'csa-slplus'); $section_name = __('Settings', 'csa-slplus'); $this->settings->add_section(array('name' => $panel_name)); $this->settings->add_ItemToGroup(array('section' => $panel_name, 'group' => $section_name, 'label' => __('Turn off rate notification', 'csa-slplus'), 'setting' => 'thisbox', 'type' => 'checkbox', 'description' => __('This will disable the notification asking you to rate our product.', 'csa-slplus'))); $this->settings->add_ItemToGroup(array('section' => $panel_name, 'group' => $section_name, 'type' => 'checkbox', 'use_prefix' => false, 'label' => __('Extended Admin Messages', 'csa-slplus'), 'setting' => 'extended_admin_messages', 'value' => $this->plugin->is_CheckTrue($this->plugin->options_nojs['extended_admin_messages']), 'description' => __('Show extended messages on the admin panel.', 'csa-slplus'))); // ACTION: slp_generalsettings_modify_adminpanel // params: settings object, section name do_action('slp_generalsettings_modify_adminpanel', $this->settings, $panel_name); }
/** * Build the User Settings Panel */ function build_UserSettingsPanel() { $sectName = __('User Interface', 'csa-slplus'); $this->settings->add_section(array('name' => $sectName)); $groupName = __('JavaScript', 'csa-slplus'); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'label' => '', 'type' => 'subheader', 'show_label' => false, 'description' => __('These settings change how JavaScript behaves on your site. ', 'csa-slplus') . ($this->slplus->javascript_is_forced ? '<br/><em>*' . sprintf(__('You have <a href="%s" target="csa">Force Load JavaScript</a> ON. ', 'csa-slplus'), $this->slplus->support_url . 'general-settings/user-interface/javascript/') . __('Themes that follow WordPress best practices and employ wp_footer() properly do not need this. ', 'csa-slplus') . __('Leaving it on slows down your site and disables a lot of extra features with the plugin and add-on packs. ', 'csa-slplus') . '</em>' : ''))); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'type' => 'checkbox', 'use_prefix' => false, 'label' => __('Force Load JavaScript', 'csa-slplus'), 'setting' => 'force_load_js', 'value' => $this->slplus->is_CheckTrue($this->slplus->options_nojs['force_load_js']), 'description' => __('Force the JavaScript for Store Locator Plus to load on every page with early loading. ', 'csa-slplus') . __('This can slow down your site, but is compatible with more themes and plugins. ', 'csa-slplus') . __('If you need to do this to make SLP work you should ask your theme author to add proper wp_footer() support to their code. ', 'csa-slplus'))); // Map Interface // $groupName = __('Map Interface', 'csa-slplus'); $this->settings->add_ItemToGroup(array('section' => $sectName, 'group' => $groupName, 'label' => __('Turn Off SLP Maps', 'csa-slplus'), 'setting' => 'no_google_js', 'type' => 'checkbox', 'description' => __('Check this box if your Theme or another plugin is providing Google Maps and generating warning messages. ' . 'THIS MAY BREAK THIS PLUGIN.', 'csa-slplus'))); // ACTION: slp_generalsettings_modify_userpanel // params: settings object, section name do_action('slp_generalsettings_modify_userpanel', $this->settings, $sectName); }
/** * Format the result data into a named array. * * We will later use this to build our JSONP response. * * @param null mixed[] $row * @return mixed[] */ function slp_add_marker($row = null) { if ($row == null) { return ''; } $this->slplus->currentLocation->set_PropertiesViaArray($row); $marker = array('name' => esc_attr($row['sl_store']), 'address' => esc_attr($row['sl_address']), 'address2' => esc_attr($row['sl_address2']), 'city' => esc_attr($row['sl_city']), 'state' => esc_attr($row['sl_state']), 'zip' => esc_attr($row['sl_zip']), 'country' => esc_attr($row['sl_country']), 'lat' => $row['sl_latitude'], 'lng' => $row['sl_longitude'], 'description' => html_entity_decode($row['sl_description']), 'url' => esc_url($row['sl_url']), 'sl_pages_url' => esc_url($row['sl_pages_url']), 'email' => esc_attr($row['sl_email']), 'email_link' => esc_attr($row['sl_email']), 'hours' => esc_attr($row['sl_hours']), 'phone' => esc_attr($row['sl_phone']), 'fax' => esc_attr($row['sl_fax']), 'image' => esc_attr($row['sl_image']), 'distance' => $row['sl_distance'], 'tags' => esc_attr($row['sl_tags']), 'option_value' => esc_js($row['sl_option_value']), 'attributes' => maybe_unserialize($row['sl_option_value']), 'id' => $row['sl_id'], 'linked_postid' => $row['sl_linked_postid'], 'neat_title' => esc_attr($row['sl_neat_title'])); $web_link = isset($this->slplus->options['use_pages_links']) && $this->slplus->is_CheckTrue($this->slplus->options['use_pages_links']) ? $marker['sl_pages_url'] : $marker['url']; if (!empty($web_link)) { $marker['web_link'] = sprintf("<a href='%s' target='%s' class='storelocatorlink'><nobr>%s</nobr></a><br/>", $web_link, isset($this->slplus->options['use_same_window']) && $this->slplus->is_CheckTrue($this->slplus->options['use_same_window']) ? '_self' : '_blank', $this->slplus->options['label_website']); } else { $marker['web_link'] = ''; } // FILTER: slp_results_marker_data // Modify the map marker object that is sent back to the UI in the JSONP response. // $marker = apply_filters('slp_results_marker_data', $marker); return $marker; }
/** * Set the plugin data radius options. */ function set_RadiusOptions() { $radiusSelections = get_option('sl_map_radii', '1,5,10,(25),50,100,200,500'); // Hide Radius, set the only (or default) radius if ($this->slplus->is_CheckTrue(get_option(SLPLUS_PREFIX . '_hide_radius_selections', 0))) { preg_match('/\\((.*?)\\)/', $radiusSelections, $selectedRadius); $selectedRadius = preg_replace('/[^0-9]/', '', isset($selectedRadius[1]) ? $selectedRadius[1] : $radiusSelections); if (empty($selectedRadius) || $selectedRadius <= 0) { $selectedRadius = '2500'; } $this->slplus->data['radius_options'] = "<input type='hidden' id='radiusSelect' name='radiusSelect' value='{$selectedRadius}'>"; // Build Pulldown } else { $radiusSelectionArray = explode(",", $radiusSelections); $this->slplus->data['radius_options'] = ''; foreach ($radiusSelectionArray as $radius) { $selected = preg_match('/\\(.*\\)/', $radius) ? " selected='selected' " : ""; $radius = preg_replace('/[^0-9\\.]/', '', $radius); $this->slplus->data['radius_options'] .= "<option value='{$radius}' {$selected}>{$radius} " . $this->slplus->options['distance_unit'] . "</option>"; } } }
/** * Build the content of the manage locations table. * * TODO: convert this to a proper WP_List_Table query and items configuration. * * @return string */ private function createstring_PanelManageTableLocations() { $this->debugMP('msg', __FUNCTION__); // Set the data query // $dataQuery = $this->slplus->database->get_SQL('selectall') . $this->db_where . " ORDER BY {$this->db_orderbyfield} {$this->db_orderbydir} " . " LIMIT {$this->start}," . $this->slplus->data['sl_admin_locations_per_page'] . ' '; $this->debugMP('msg', '', "SQL Query: {$dataQuery}"); // Get the locations into the array // if ($slpLocations = $this->slplus->db->get_results($dataQuery, ARRAY_A)) { $this->set_Columns(); $content['pagination_block'] = $this->createstring_PaginationBlock($this->totalLocations, $this->slplus->data['sl_admin_locations_per_page'], $this->start); // Get the manage locations table header // $tableHeaderString = $this->createstring_TableHeader($this->columns, $this->db_orderbyfield, $this->db_orderbydir); // Manage // $content['locationstable'] = "<table id='manage_locations_table' " . "class='slplus wp-list-table widefat posts' cellspacing=0>" . $tableHeaderString; $colorClass = ''; // FILTER: slp_locations_manage_cssclass // add_filter('slp_locations_manage_cssclass', array($this, 'filter_InvalidHighlight')); // Loop through the locations list and render table rows. // foreach ($slpLocations as $sl_value) { // Set current location // $this->slplus->currentLocation->set_PropertiesViaArray($sl_value); // Row color // $colorClass = $colorClass === 'alternate' ? '' : 'alternate'; // FILTER: slp_locations_manage_cssclass // $extraCSSClasses = apply_filters('slp_locations_manage_cssclass', ''); // Clean Up Data with trim() // $locID = $this->slplus->currentLocation->id; $sl_value = array_map("trim", $sl_value); // Custom Filters to set the links on special data like URLs and Email // $sl_value['sl_url'] = !$this->url_test($sl_value['sl_url']) && trim($sl_value['sl_url']) != "" ? "http://" . $sl_value['sl_url'] : $sl_value['sl_url']; $sl_value['sl_url'] = $sl_value['sl_url'] != "" ? "<a href='{$sl_value['sl_url']}' target='blank' " . "alt='{$sl_value['sl_url']}' title='{$sl_value['sl_url']}'>" . __("View", 'csa-slplus') . '</a>' : ''; $sl_value['sl_email'] = $sl_value['sl_email'] != "" ? "<a href='mailto:{$sl_value['sl_email']}' target='blank' " . "alt='{$sl_value['sl_email']}' title='{$sl_value['sl_email']}'>" . __('Email', 'csa-slplus') . '</a>' : ''; $sl_value['sl_description'] = $sl_value['sl_description'] != "" ? "<a onclick='alert(\"" . $this->slp_escape($sl_value['sl_description']) . "\")' href='#'>" . __("View", 'csa-slplus') . "</a>" : ""; // create Action Buttons $actionButtonsHTML = "<a class='action_icon edit_icon' alt='" . __('edit', 'csa-slplus') . "' title='" . __('edit', 'csa-slplus') . "'\n href='" . $this->hangoverURL . "&act=edit&id={$locID}'></a>" . " " . "<a class='action_icon delete_icon' alt='" . __('delete', 'csa-slplus') . "' title='" . __('delete', 'csa-slplus') . "'\n href='" . $this->hangoverURL . "&act=delete&sl_id={$locID}' " . "onclick=\"AdminUI.confirmClick('" . sprintf(__('Delete %s?', 'csa-slplus'), $sl_value['sl_store']) . "', this.href); return false;\"></a>"; $actionButtonsHTML = apply_filters('slp_manage_locations_actionbuttons', $actionButtonsHTML, $sl_value); $cleanName = urlencode($this->slplus->currentLocation->store); $content['locationstable'] .= "<tr " . "id='location-{$this->slplus->currentLocation->id}' " . "name='{$cleanName}' " . "class='slp_managelocations_row {$colorClass} {$extraCSSClasses}' " . ">" . "<th class='th_checkbox'>" . "<input type='checkbox' class='slp_checkbox' name='sl_id[]' value='{$locID}'>" . "<span class='infoid'>{$this->slplus->currentLocation->id}</span>" . '</th>' . "<th class='thnowrap'><div class='action_buttons'>" . $actionButtonsHTML . "</div></th>"; // Create Address Block // $sl_value['address'] = ''; $newData = false; foreach (array('address', 'address2', 'city', 'state', 'zip', 'country') as $property) { // Added something and need formatting? // if ($newData) { switch ($property) { case 'address2': case 'city': case 'country': $sl_value['address'] .= '<br/>'; break; case 'state': $sl_value['address'] .= ' , '; break; case 'zip': $sl_value['address'] .= ' '; break; default: break; } $newData = false; } // Location property is not empty // $propVal = $this->slplus->currentLocation->{$property}; if (!empty($propVal)) { $sl_value['address'] .= $this->slplus->currentLocation->{$property}; $newData = true; } } // Data Columns // FILTER: slp_column_data // foreach ($this->columns as $slpField => $slpLabel) { $labelAsClass = sanitize_title($slpLabel); if (!isset($sl_value[$slpField])) { $sl_value[$slpField] = ''; } $content['locationstable'] .= "<td class='slp_manage_locations_cell {$labelAsClass}'>" . apply_filters('slp_column_data', stripslashes($sl_value[$slpField]), $slpField, $slpLabel) . '</td>'; } // Lat/Long Columns // $commaOrSpace = $sl_value['sl_latitude'] . $sl_value['sl_longitude'] !== '' ? ',' : ' '; $content['locationstable'] .= "<td>{$sl_value['sl_latitude']}{$commaOrSpace}{$sl_value['sl_longitude']}</td>" . '</tr>'; } // Close Out Table // $content['locationstable'] .= $tableHeaderString . '</table>'; // No Locations Found // } else { $content['pagination_block'] = ''; $content['locationstable'] = "<div class='csa_info_msg' id='manage_locations_msg'>" . (empty($_REQUEST['searchfor']) ? __("No locations have been created yet.", 'csa-slplus') : __("Search Locations returned no matches.", 'csa-slplus')) . ($this->slplus->is_CheckTrue($this->slplus->options_nojs['extended_admin_messages']) ? '<br/><br/>' . __('Where: ', 'csa-slplus') . $this->db_where : '') . "</div>"; } return $content['locationstable']; }
/** * Add the left column to the add/edit locations form. * * @return string HTML of the form inputs */ function filter_EditLocationLeft_Address() { $HTML = $this->createstring_InputElement('store', __('Name', 'store-locator-le'), $this->slplus->currentLocation->store) . $this->createstring_InputElement('address', __('Street - Line 1', 'store-locator-le'), $this->slplus->currentLocation->address) . $this->createstring_InputElement('address2', __('Street - Line 2', 'store-locator-le'), $this->slplus->currentLocation->address2) . $this->createstring_InputElement('city', __('City', 'store-locator-le'), $this->slplus->currentLocation->city) . $this->createstring_InputElement('state', __('State', 'store-locator-le'), $this->slplus->currentLocation->state) . $this->createstring_InputElement('zip', __('ZIP / Postal Code', 'store-locator-le'), $this->slplus->currentLocation->zip) . $this->createstring_InputElement('country', __('Country', 'store-locator-le'), $this->slplus->currentLocation->country) . $this->createstring_InputElement('latitude', __('Latitude (N/S)', 'store-locator-le'), $this->slplus->currentLocation->latitude, '', false, 'input', __('Leave blank to have Google look up the latitude.', 'store-locator-le')) . $this->createstring_InputElement('longitude', __('Longitude (E/W)', 'store-locator-le'), $this->slplus->currentLocation->longitude, '', false, 'input', __('Leave blank to have Google look up the longitude.', 'store-locator-le')); $HTML .= $this->slplus->helper->CreateCheckboxDiv("private-{$this->slplus->currentLocation->id}", __('Private Entry', 'store-locator-le'), __('If checked the listing will not show up in location search results.', 'store-locator-le'), '', false, 0, $this->slplus->is_CheckTrue($this->slplus->currentLocation->private)); return $HTML; }