/**
  * Generate the HTML for an input settings interface element.
  *
  * @param string $boxname
  * @param string $label
  * @param string $msg
  * @param string $prefix
  * @param string $default
  * @param string $value - forced value
  * @return string HTML for the div box.
  */
 function CreateInputDiv($boxname, $label = '', $msg = '', $prefix = SLPLUS_PREFIX, $default = '', $value = null)
 {
     $this->slplus->debugMP('slp.main', 'msg', 'SLPlus_AdminUI_MapSettings:' . __FUNCTION__);
     $whichbox = $prefix . $boxname;
     if ($value === null) {
         $value = $this->getCompoundOption($whichbox, $default);
     }
     return "<div class='form_entry'>" . "<div class='wpcsl-input wpcsl-list'>" . "<label for='{$whichbox}'>{$label}:</label>" . "<input  name='{$whichbox}' value='{$value}'>" . "</div>" . $this->slplus->helper->CreateHelpDiv($boxname, $msg) . "</div>";
 }
 /**
  * Enqueue the admin stylesheet when needed.
  */
 function enqueue_admin_stylesheet($hook)
 {
     $this->slplus->debugMP('slp.main', 'msg', 'SLPlus_AdminUI::' . __FUNCTION__);
     if ($this->slplus->check_isOurAdminPage()) {
         wp_enqueue_style($this->styleHandle);
     }
 }
 /**
  * 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);
     }
 }
 /**
  * Take an array of checkbox names and set all the form POSTS if not set and load into equivalent option_array key.
  *
  * $_POST['blah'] gets loaded into $option_array['blah'] whether on or off (1 or 0)
  *
  * @param $option_array
  * @param $checkbox_list
  */
 function load_checkboxes_into_options(&$option_array, $checkbox_list)
 {
     $this->slplus->debugMP('msg', get_class() . '::' . __FUNCTION__);
     foreach ($checkbox_list as $checkbox_name) {
         $this->create_checkbox_post($checkbox_name);
         $option_array[$checkbox_name] = $_POST[$checkbox_name];
     }
 }
 /**
  * Execute the save settings action.
  *
  * Called when a $_POST is set when doing render_adminpage.
  */
 function save_settings()
 {
     $sl_google_map_arr = explode(":", $_POST['google_map_domain']);
     update_option('sl_google_map_country', $sl_google_map_arr[0]);
     update_option('sl_google_map_domain', $sl_google_map_arr[1]);
     // Set height uint to blank, if height is "auto !important"
     if ($_POST['sl_map_height'] === "auto !important" && $_POST['sl_map_height_units'] != "") {
         $_POST['sl_map_height_units'] = "";
         array_push($this->update_info, __("Auto set height unit to blank when height is 'auto !important'", 'csa-slplus'));
     }
     // Set weight uint to blank, if height is "auto !important"
     if ($_POST['sl_map_width'] === "auto !important" && $_POST['sl_map_width_units'] != "") {
         $_POST['sl_map_width_units'] = "";
         array_push($this->update_info, __("Auto set width unit to blank when width is 'auto !important'", 'csa-slplus'));
     }
     // Height, strip non-digits, if % set range 0..100
     if (in_array($_POST['sl_map_height_units'], array('%', 'px', 'pt', 'em'))) {
         $_POST['sl_map_height'] = preg_replace('/[^0-9]/', '', $_POST['sl_map_height']);
         if ($_POST['sl_map_height_units'] == '%') {
             $_POST['sl_map_height'] = max(0, min($_POST['sl_map_height'], 100));
         }
     }
     // Width, strip non-digtis, if % set range 0..100
     if (in_array($_POST['sl_map_width_units'], array('%', 'px', 'pt', 'em'))) {
         $_POST['sl_map_width'] = preg_replace('/[^0-9]/', '', $_POST['sl_map_width']);
         if ($_POST['sl_map_width_units'] == '%') {
             $_POST['sl_map_width'] = max(0, min($_POST['sl_map_width'], 100));
         }
     }
     // Standard Input Saves
     //
     $BoxesToHit = apply_filters('slp_save_map_settings_inputs', array('sl_language', 'sl_map_radii', 'sl_instruction_message', 'sl_zoom_level', 'sl_zoom_tweak', 'sl_map_height_units', 'sl_map_height', 'sl_map_width_units', 'sl_map_width', 'sl_map_home_icon', 'sl_map_end_icon', 'sl_map_type', 'sl_distance_unit', 'sl_radius_label', 'sl_search_label', 'sl_website_label', SLPLUS_PREFIX . '_label_directions', SLPLUS_PREFIX . '_label_fax', SLPLUS_PREFIX . '_label_hours', SLPLUS_PREFIX . '_label_phone', SLPLUS_PREFIX . '_map_center', SLPLUS_PREFIX . '-map_language', SLPLUS_PREFIX . '-theme'));
     foreach ($BoxesToHit as $JustAnotherBox) {
         $this->plugin->helper->SavePostToOptionsTable($JustAnotherBox);
     }
     // Register need translate text to WPML
     //
     $BoxesToHit = apply_filters('slp_regwpml_map_settings_inputs', array('sl_radius_label', 'sl_search_label'));
     foreach ($BoxesToHit as $JustAnotherBox) {
         $this->plugin->AdminWPML->regPostOptions($JustAnotherBox);
     }
     // Checkboxes
     //
     $BoxesToHit = apply_filters('slp_save_map_settings_checkboxes', array(SLPLUS_PREFIX . '_use_email_form', SLPLUS_PREFIX . '_email_form', SLPLUS_PREFIX . '_disable_find_image', SLPLUS_PREFIX . '-force_load_js', 'sl_load_locations_default', 'sl_remove_credits'));
     $this->plugin->debugMP('slp.mapsettings', 'pr', 'save_settings() Checkboxes', $BoxesToHit, NULL, NULL, true);
     foreach ($BoxesToHit as $JustAnotherBox) {
         $this->plugin->helper->SaveCheckBoxToDB($JustAnotherBox, '', '');
     }
     // Serialized Options Setting
     // This should be used for ALL new options.
     // Serialized options = ONE data I/O call, MUCH FASTER!!!
     //
     array_walk($_REQUEST, array($this->plugin, 'set_ValidOptions'));
     update_option(SLPLUS_PREFIX . '-options', $this->plugin->options);
     array_walk($_REQUEST, array($this->plugin, 'set_ValidOptionsNoJS'));
     update_option(SLPLUS_PREFIX . '-options_nojs', $this->plugin->options_nojs);
 }
 /**
  * Tell people if the extended data contains a field identified by slug.
  *
  * @param string $slug the field slug
  * @return boolean true if the field exists, false if not.
  */
 function has_field($slug)
 {
     if (!isset($this->metatable['records'][$slug])) {
         $slug_data = $this->slplus->database->get_Record(array('select_all_from_extendo', 'where_slugis'), $slug, 0, OBJECT);
         if (is_object($slug_data) && $slug_data->slug == $slug) {
             $this->metatable['records'][$slug] = $slug_data;
         }
     }
     $this->slplus->debugMP('slp.main', 'pr', 'SLPlus_Data_Extension::' . __FUNCTION__ . ' ' . $slug, $this->metatable);
     return isset($this->metatable['records'][$slug]);
 }
Exemple #7
0
 /**
  * This is called whenever the WordPress wp_enqueue_scripts action is called.
  */
 function wp_enqueue_scripts()
 {
     $this->plugin->debugMP('slp.main', 'msg', 'SLPlus_Actions:' . __FUNCTION__);
     $force_load = $this->plugin->settings->get_item('force_load_js', true);
     //------------------------
     // Register our scripts for later enqueue when needed
     //
     if (get_option(SLPLUS_PREFIX . '-no_google_js', 'off') != 'on') {
         $dbAPIKey = trim(get_option(SLPLUS_PREFIX . '-api_key', ''));
         $api_key = empty($dbAPIKey) ? '' : '&key=' . $dbAPIKey;
         $language = '&language=' . $this->plugin->helper->getData('map_language', 'get_item', null, 'en');
         wp_enqueue_script('google_maps', 'http' . (is_ssl() ? 's' : '') . '://' . get_option('sl_google_map_domain', 'maps.google.com') . '/maps/api/js?sensor=false' . $api_key . $language, array(), SLPLUS_VERSION, !$force_load);
     }
     $sslURL = is_ssl() ? preg_replace('/http:/', 'https:', SLPLUS_PLUGINURL) : SLPLUS_PLUGINURL;
     wp_enqueue_script('csl_script', $sslURL . '/js/slp.js', array('jquery'), SLPLUS_VERSION, !$force_load);
     $this->plugin->UI->localizeSLPScript();
 }
 /**
  * Render the manage locations admin page.
  *
  */
 function render_adminpage()
 {
     $this->slplus->debugMP('slp.managelocs', 'msg', __FUNCTION__);
     $this->slplus->helper->loadPluginData();
     $this->slplus->AdminUI->initialize_variables();
     $this->process_Actions();
     //------------------------------------------------------------------------
     // CHANGE UPDATER
     // Changing Updater
     //------------------------------------------------------------------------
     if (isset($_GET['changeUpdater']) && $_GET['changeUpdater'] == 1) {
         if (get_option('sl_location_updater_type') == "Tagging") {
             update_option('sl_location_updater_type', 'Multiple Fields');
             $updaterTypeText = "Multiple Fields";
         } else {
             update_option('sl_location_updater_type', 'Tagging');
             $updaterTypeText = "Tagging";
         }
         $_SERVER['REQUEST_URI'] = preg_replace('/&changeUpdater=1/', '', $_SERVER['REQUEST_URI']);
         print "<script>location.replace('" . $_SERVER['REQUEST_URI'] . "');</script>";
     }
     //------------------------------------------------------------------------
     // Reload Variables - anything that my have changed
     //------------------------------------------------------------------------
     $this->slplus->helper->getData('sl_admin_locations_per_page', 'get_option', null, '10', true, true);
     //--------------------------------------
     // Setup the Location panel navigation
     //--------------------------------------
     $subtabs = apply_filters('slp_locations_subtabs', array(__('Manage', 'csa-slplus'), __('Add', 'csa-slplus')));
     //------------------------------------
     // Create Location Panels
     //
     add_action('slp_build_locations_panels', array($this, 'create_settings_section_Manage'), 10);
     add_action('slp_build_locations_panels', array($this, 'create_settings_section_Add'), 20);
     //-------------------------
     // Setup Navigation Bar
     //
     $this->settings->add_section(array('name' => 'Navigation', 'div_id' => 'navbar_wrapper', 'description' => $this->slplus->AdminUI->create_Navbar(), 'innerdiv' => false, 'is_topmenu' => true, 'auto' => false, 'headerbar' => false));
     //------------------------------------
     // Render It
     //
     do_action('slp_build_locations_panels');
     $this->settings->render_settings_page();
 }
 /**
  * Handle any IconAttributes optionally set using the shortcode in combination with the Pro Pack.
  *
  * Uses data['sl_map_home_icon'] by default.
  */
 function handleIconAttributes($data_element, $attribute_element)
 {
     $this->slplus->debugMP('slp.main', 'pr', get_class() . '::' . __FUNCTION__ . ' Checking attribute[' . $attribute_element . '] with data:', $this->slplus->data);
     // Check Settings for $attribute_element
     //
     if (isset($this->slplus->data[$attribute_element]) && !empty($this->slplus->data[$attribute_element])) {
         // Start with attribute_element value
         $icon_url = $this->slplus->data[$attribute_element];
         // Prepends value with SLPLUS_ICONURL when it is not a url (could use url_test() )
         //  Try WordPress is_valid_url() from the common.php library.
         //
         if (!$this->slplus->is_valid_url($icon_url)) {
             $icon_url = SLPLUS_ICONURL . $icon_url;
             // If file doesn't exist, try to make relative url into absolute url
             $icon_file = str_replace(SLPLUS_ICONURL, SLPLUS_ICONDIR, $icon_url);
             if (!file_exists($icon_file)) {
                 $icon_url = get_site_url() . $this->slplus->data[$attribute_element];
             }
         }
         // Store value found in data_element
         $this->slplus->data[$data_element] = $icon_url;
     }
 }
 /**
  * Simplify the plugin debugMP interface.
  *
  * @param string $type
  * @param string $hdr
  * @param string $msg
  */
 function debugMP($type, $hdr, $msg = '')
 {
     $this->slplus->debugMP('slp.location', $type, $hdr, $msg, NULL, NULL, true);
 }
 /**
  * Call parent DebugMP only if parent has been set.
  * 
  *
  * @param string $panel - panel name
  * @param string $type - what type of debugging (msg = simple string, pr = print_r of variable)
  * @param string $header - the header
  * @param string $message - what you want to say
  * @param string $file - file of the call (__FILE__)
  * @param int $line - line number of the call (__LINE__)
  * @param boolean $notime - show time? default true = yes.
  * @return null
  */
 function debugMP($panel = 'main', $type = 'msg', $header = 'wpCSL DMP', $message = '', $file = null, $line = null, $notime = false)
 {
     if (is_object($this->parent)) {
         $this->parent->debugMP($panel, $type, $header, $message, $file, $line, $notime);
     }
 }