function cgmp_render_shortcode_builder_form() { $settings = array(); $json_string = file_get_contents(CGMP_PLUGIN_DATA_DIR . "/" . CGMP_JSON_DATA_HTML_ELEMENTS_FORM_PARAMS); $parsed_json = json_decode($json_string, true); if (is_array($parsed_json)) { foreach ($parsed_json as $data_chunk) { cgmp_set_values_for_html_rendering($settings, $data_chunk); } } $template_values = cgmp_build_template_values($settings); $template_values['SHORTCODEBUILDER_FORM_TITLE'] = ""; $template_values['SHORTCODEBUILDER_HTML_FORM'] = ""; $map_configuration_template = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM); $tokens_with_values = array("MAP_CONFIGURATION_FORM_TOKEN" => $map_configuration_template); echo cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_MAP_SHORTCODE_BUILDER_METABOX); }
public function form($instance) { $settings = array(); $json_html_elems = cgmp_fetch_json_data_file(CGMP_JSON_DATA_HTML_ELEMENTS_FORM_PARAMS); $json_default_values = cgmp_fetch_json_data_file(CGMP_JSON_DATA_DEFAULT_WIDGET_PARAM_VALUES); if (is_array($json_html_elems)) { $legacy_params = array("latitude" => "", "longitude" => "", "addresscontent" => "", "addmarkerlisthidden" => ""); foreach ($json_html_elems as $data_chunk) { $id = $data_chunk['dbParameterId']; $value = isset($instance[$id]) && trim($instance[$id]) != "" ? trim($instance[$id]) : ""; $value = !isset($value) || empty($value) ? isset($json_default_values[$id]) ? $json_default_values[$id] : esc_attr(strip_tags($value)) : esc_attr(strip_tags($value)); if (array_key_exists($id, $legacy_params)) { $legacy_params[$id] = $value; } if ($id == "addmarkerlisthidden") { extract($legacy_params); $addmarkerlisthidden = update_markerlist_from_legacy_locations($latitude, $longitude, $addresscontent, $addmarkerlisthidden); $value = $addmarkerlisthidden; } $data_chunk['dbParameterValue'] = $value; $data_chunk['dbParameterId'] = $this->get_field_id($id); $data_chunk['dbParameterName'] = $this->get_field_name($id); cgmp_set_values_for_html_rendering($settings, $data_chunk); } } $template_values = cgmp_build_template_values($settings); $template_values['SHORTCODEBUILDER_FORM_TITLE'] = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_WIDGET_FORM_TITLE); $template_values['SHORTCODEBUILDER_HTML_FORM'] = ""; $tokens_with_values = array(); $tokens_with_values['WIDGET_ID_TOKEN'] = $this->id; $tokens_with_values['MAP_CONFIGURATION_FORM_TEMPLATE_TOKEN'] = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM); echo cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_WIDGET); }
function cgmp_shortcodebuilder_callback() { if (!current_user_can('activate_plugins')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if (isset($_POST['hidden-shortcode-code'])) { $bad_entities = array(""", "'", "'"); $title = str_replace($bad_entities, "", $_POST['hidden-shortcode-title']); $title = preg_replace('/\\s+/', ' ', trim($title)); $code = str_replace($bad_entities, "", $_POST['hidden-shortcode-code']); $shortcodes = array(); $persisted_shortcodes_json = get_option(CGMP_PERSISTED_SHORTCODES); if (isset($persisted_shortcodes_json) && trim($persisted_shortcodes_json) != "") { $persisted_shortcodes = json_decode($persisted_shortcodes_json, true); if (is_array($persisted_shortcodes)) { $persisted_shortcodes[$title] = array("title" => $title, "code" => $code); $shortcodes = $persisted_shortcodes; } } else { $shortcodes[$title] = array("title" => $title, "code" => $code); } update_option(CGMP_PERSISTED_SHORTCODES, json_encode($shortcodes)); cgmp_show_message("Shortcode save successfully!"); //cgmp_show_message("Look for the map icon <img src='".CGMP_PLUGIN_IMAGES."/google_map.png' border='0' valign='middle' /> in WordPress page/post WYSIWYG editor or check <a href='admin.php?page=cgmp-saved-shortcodes'>Saved Shortcodes</a> page"); } $settings = array(); $json_string = file_get_contents(CGMP_PLUGIN_DATA_DIR . "/" . CGMP_JSON_DATA_HTML_ELEMENTS_FORM_PARAMS); $parsed_json = json_decode($json_string, true); if (is_array($parsed_json)) { foreach ($parsed_json as $data_chunk) { cgmp_set_values_for_html_rendering($settings, $data_chunk); } } $template_values = cgmp_build_template_values($settings); $template_values['SHORTCODEBUILDER_FORM_TITLE'] = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_SHORTCODE_BUILDER_FORM_TITLE); $template_values['SHORTCODEBUILDER_HTML_FORM'] = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_SHORTCODE_BUILDER_HTML_FORM); $map_configuration_template = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM); echo cgmp_render_template_with_values(array("CGMP_PLUGIN_IMAGES" => CGMP_PLUGIN_IMAGES, "SHORTCODEBUILDER_TOKEN" => $map_configuration_template), CGMP_HTML_TEMPLATE_MAP_SHORTCODE_BUILDER_PAGE); }
<?php /* Copyright (C) 2011 Alexander Zagniotov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ $settings = array(); $json_string = file_get_contents(CGMP_PLUGIN_DATA_DIR . "/" . CGMP_JSON_DATA_HTML_ELEMENTS_FORM_PARAMS); $parsed_json = json_decode($json_string, true); if (is_array($parsed_json)) { foreach ($parsed_json as $data_chunk) { cgmp_set_values_for_html_rendering($settings, $data_chunk); } } $template_values = cgmp_build_template_values($settings); $map_configuration_template = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM);