@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | // If this file is called directly, abort. |
| 18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 18 | +if ( ! defined('ABSPATH')) { |
|
| 19 | 19 | exit; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -23,34 +23,34 @@ discard block |
||
| 23 | 23 | * Define Constants |
| 24 | 24 | */ |
| 25 | 25 | // Plugin Folder Path |
| 26 | -if ( ! defined( 'GMB_PLUGIN_PATH' ) ) { |
|
| 27 | - define( 'GMB_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 26 | +if ( ! defined('GMB_PLUGIN_PATH')) { |
|
| 27 | + define('GMB_PLUGIN_PATH', plugin_dir_path(__FILE__)); |
|
| 28 | 28 | } |
| 29 | 29 | // Plugin Folder URL |
| 30 | -if ( ! defined( 'GMB_PLUGIN_URL' ) ) { |
|
| 31 | - define( 'GMB_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
| 30 | +if ( ! defined('GMB_PLUGIN_URL')) { |
|
| 31 | + define('GMB_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
| 32 | 32 | } |
| 33 | 33 | // Plugin base |
| 34 | -if ( ! defined( 'GMB_PLUGIN_BASE' ) ) { |
|
| 35 | - define( 'GMB_PLUGIN_BASE', plugin_basename( __FILE__ ) ); |
|
| 34 | +if ( ! defined('GMB_PLUGIN_BASE')) { |
|
| 35 | + define('GMB_PLUGIN_BASE', plugin_basename(__FILE__)); |
|
| 36 | 36 | } |
| 37 | 37 | // Plugin version |
| 38 | -if ( ! defined( 'GMB_VERSION' ) ) { |
|
| 39 | - define( 'GMB_VERSION', '2.1.2' ); |
|
| 38 | +if ( ! defined('GMB_VERSION')) { |
|
| 39 | + define('GMB_VERSION', '2.1.2'); |
|
| 40 | 40 | } |
| 41 | 41 | // Plugin Root File |
| 42 | -if ( ! defined( 'GMB_PLUGIN_FILE' ) ) { |
|
| 43 | - define( 'GMB_PLUGIN_FILE', __FILE__ ); |
|
| 42 | +if ( ! defined('GMB_PLUGIN_FILE')) { |
|
| 43 | + define('GMB_PLUGIN_FILE', __FILE__); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
| 47 | -if ( ! class_exists( 'Google_Maps_Builder' ) ) : |
|
| 47 | +if ( ! class_exists('Google_Maps_Builder')) : |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Load plugin if core lib is present |
| 51 | 51 | */ |
| 52 | - if ( ! file_exists( GMB_PLUGIN_PATH . 'vendor/wordimpress/maps-builder-core/core.php' ) ) { |
|
| 53 | - add_action( 'admin_notices', 'gmb_no_core_lib' ); |
|
| 52 | + if ( ! file_exists(GMB_PLUGIN_PATH.'vendor/wordimpress/maps-builder-core/core.php')) { |
|
| 53 | + add_action('admin_notices', 'gmb_no_core_lib'); |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * Print admin notice if no dependencies |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | * @uses "admin_notice" hook |
| 59 | 59 | */ |
| 60 | 60 | function gmb_no_core_lib() { |
| 61 | - printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html__( 'Your install of Maps Builder is missing its Composer dependencies and can not load.', 'maps-builder-pro' ) ); |
|
| 61 | + printf('<div class="notice notice-error"><p>%s</p></div>', esc_html__('Your install of Maps Builder is missing its Composer dependencies and can not load.', 'maps-builder-pro')); |
|
| 62 | 62 | } |
| 63 | 63 | } else { |
| 64 | - require_once GMB_PLUGIN_PATH . 'vendor/wordimpress/maps-builder-core/core.php'; |
|
| 64 | + require_once GMB_PLUGIN_PATH.'vendor/wordimpress/maps-builder-core/core.php'; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Main Maps Builder Class |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | * @return Google_Maps_Builder |
| 110 | 110 | */ |
| 111 | 111 | public static function instance() { |
| 112 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Google_Maps_Builder ) ) { |
|
| 112 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Google_Maps_Builder)) { |
|
| 113 | 113 | |
| 114 | 114 | self::$instance = new Google_Maps_Builder(); |
| 115 | 115 | |
| 116 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
| 116 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); |
|
| 117 | 117 | |
| 118 | 118 | self::$instance->includes(); |
| 119 | 119 | self::$instance->activate = new Google_Maps_Builder_Activate(); |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | // Read plugin meta |
| 126 | 126 | // Check that function get_plugin_data exists |
| 127 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
| 128 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 127 | + if ( ! function_exists('get_plugin_data')) { |
|
| 128 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 129 | 129 | } |
| 130 | - self::$instance->meta = get_plugin_data( GMB_PLUGIN_FILE, false ); |
|
| 130 | + self::$instance->meta = get_plugin_data(GMB_PLUGIN_FILE, false); |
|
| 131 | 131 | |
| 132 | 132 | } |
| 133 | 133 | |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $this->cmb2_load(); |
| 150 | 150 | $this->load_files(); |
| 151 | - require_once GMB_PLUGIN_PATH . 'includes/class-gmb-scripts.php'; |
|
| 152 | - require_once GMB_PLUGIN_PATH . 'includes/class-gmb-html-elements.php'; |
|
| 151 | + require_once GMB_PLUGIN_PATH.'includes/class-gmb-scripts.php'; |
|
| 152 | + require_once GMB_PLUGIN_PATH.'includes/class-gmb-html-elements.php'; |
|
| 153 | 153 | |
| 154 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 154 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 155 | 155 | |
| 156 | 156 | $this->load_admin(); |
| 157 | 157 | //Admin |
@@ -35,22 +35,22 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | parent::__construct(); |
| 37 | 37 | |
| 38 | - add_action( 'cmb2_render_google_maps_preview', array( $this, 'cmb2_render_google_maps_preview' ), 10, 2 ); |
|
| 38 | + add_action('cmb2_render_google_maps_preview', array($this, 'cmb2_render_google_maps_preview'), 10, 2); |
|
| 39 | 39 | // Load admin style sheet and JavaScript. |
| 40 | - add_action( 'wp_ajax_hide_welcome', array( $this, 'hide_welcome_callback' ) ); |
|
| 40 | + add_action('wp_ajax_hide_welcome', array($this, 'hide_welcome_callback')); |
|
| 41 | 41 | |
| 42 | 42 | //Add links/information to plugin row meta |
| 43 | - add_filter( 'cmb2_get_metabox_form_format', array( $this, 'gmb_modify_cmb2_form_output' ), 10, 3 ); |
|
| 43 | + add_filter('cmb2_get_metabox_form_format', array($this, 'gmb_modify_cmb2_form_output'), 10, 3); |
|
| 44 | 44 | |
| 45 | 45 | //Widget upsell |
| 46 | - add_action( 'gmb_after_widget_form', array( $this, 'widget_upsell' ) ); |
|
| 46 | + add_action('gmb_after_widget_form', array($this, 'widget_upsell')); |
|
| 47 | 47 | |
| 48 | 48 | //Useful class for free-only styling |
| 49 | - add_filter( 'admin_body_class', array( $this, 'admin_body_classes' ) ); |
|
| 49 | + add_filter('admin_body_class', array($this, 'admin_body_classes')); |
|
| 50 | 50 | |
| 51 | 51 | // Remove quick edit link and added preview map link. |
| 52 | - add_filter( 'post_row_actions', array( $this, 'remove_row_actions' ), 10, 2 ); |
|
| 53 | - add_action( 'wp_ajax_preview_map_action', array( $this, 'preview_map_action_callback' ) ); |
|
| 52 | + add_filter('post_row_actions', array($this, 'remove_row_actions'), 10, 2); |
|
| 53 | + add_action('wp_ajax_preview_map_action', array($this, 'preview_map_action_callback')); |
|
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
@@ -59,32 +59,32 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @since 1.0.0 |
| 61 | 61 | */ |
| 62 | - function cmb2_render_google_maps_preview( $field, $meta ) { |
|
| 62 | + function cmb2_render_google_maps_preview($field, $meta) { |
|
| 63 | 63 | |
| 64 | 64 | /* @var $post */ |
| 65 | 65 | global $post; |
| 66 | 66 | |
| 67 | - $meta = wp_parse_args( $meta, array() ); |
|
| 68 | - $wh_value = get_post_meta( $post->ID, 'gmb_width_height', true ); |
|
| 69 | - $lat_lng = get_post_meta( $post->ID, 'gmb_lat_lng', true ); |
|
| 67 | + $meta = wp_parse_args($meta, array()); |
|
| 68 | + $wh_value = get_post_meta($post->ID, 'gmb_width_height', true); |
|
| 69 | + $lat_lng = get_post_meta($post->ID, 'gmb_lat_lng', true); |
|
| 70 | 70 | $default_options = $this->get_default_map_options(); |
| 71 | 71 | |
| 72 | - $output = '<div class="places-loading wpgp-loading">' . __( 'Loading Places', 'google-maps-builder' ) . '</div><div id="google-map-wrap">'; |
|
| 72 | + $output = '<div class="places-loading wpgp-loading">'.__('Loading Places', 'google-maps-builder').'</div><div id="google-map-wrap">'; |
|
| 73 | 73 | $output .= '<div id="map" style="height:600px; width:100%;"></div>'; |
| 74 | 74 | |
| 75 | - $output .= '<div class="map-modal-upsell"><p class="upsell-intro">' . __( 'Want more?', 'google-maps-builder' ) . '</p><a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&utm_medium=BANNER&utm_content=MODAL&utm_campaign=MBF%20Modal" class="button button-small upsell-button" target="_blank">' . __( 'Go Pro!', 'google-maps-builder' ) . '</a></div>'; |
|
| 75 | + $output .= '<div class="map-modal-upsell"><p class="upsell-intro">'.__('Want more?', 'google-maps-builder').'</p><a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&utm_medium=BANNER&utm_content=MODAL&utm_campaign=MBF%20Modal" class="button button-small upsell-button" target="_blank">'.__('Go Pro!', 'google-maps-builder').'</a></div>'; |
|
| 76 | 76 | |
| 77 | 77 | //Toolbar |
| 78 | 78 | $output .= '<div id="map-toolbar">'; |
| 79 | - $output .= '<button class="add-location button button-small gmb-magnific-inline" data-target="cmb2-id-gmb-geocoder" data-auto-focus="true"><span class="dashicons dashicons-pressthis"></span>' . __( 'Add Location', 'google-maps-builder' ) . '</button>'; |
|
| 80 | - $output .= '<button class="drop-marker button button-small"><span class="dashicons dashicons-location"></span>' . __( 'Drop a Marker', 'google-maps-builder' ) . '</button>'; |
|
| 81 | - $output .= '<button class="goto-location button button-small gmb-magnific-inline" data-target="map-autocomplete-wrap" data-auto-focus="true"><span class="dashicons dashicons-admin-site"></span>' . __( 'Goto Location', 'google-maps-builder' ) . '</button>'; |
|
| 82 | - $output .= '<button class="edit-title button button-small gmb-magnific-inline" data-target="map-title-wrap" data-auto-focus="true"><span class="dashicons dashicons-edit"></span>' . __( 'Edit Map Title', 'google-maps-builder' ) . '</button>'; |
|
| 79 | + $output .= '<button class="add-location button button-small gmb-magnific-inline" data-target="cmb2-id-gmb-geocoder" data-auto-focus="true"><span class="dashicons dashicons-pressthis"></span>'.__('Add Location', 'google-maps-builder').'</button>'; |
|
| 80 | + $output .= '<button class="drop-marker button button-small"><span class="dashicons dashicons-location"></span>'.__('Drop a Marker', 'google-maps-builder').'</button>'; |
|
| 81 | + $output .= '<button class="goto-location button button-small gmb-magnific-inline" data-target="map-autocomplete-wrap" data-auto-focus="true"><span class="dashicons dashicons-admin-site"></span>'.__('Goto Location', 'google-maps-builder').'</button>'; |
|
| 82 | + $output .= '<button class="edit-title button button-small gmb-magnific-inline" data-target="map-title-wrap" data-auto-focus="true"><span class="dashicons dashicons-edit"></span>'.__('Edit Map Title', 'google-maps-builder').'</button>'; |
|
| 83 | 83 | |
| 84 | 84 | $output .= '<div class="live-lat-lng-wrap clearfix">'; |
| 85 | - $output .= '<button disabled class="update-lat-lng button button-small">' . __( 'Set Lat/Lng', 'google-maps-builder' ) . '</button>'; |
|
| 86 | - $output .= '<div class="live-latitude-wrap"><span class="live-latitude-label">' . __( 'Lat:', 'google-maps-builder' ) . '</span><span class="live-latitude">' . ( isset( $lat_lng['latitude'] ) ? $lat_lng['latitude'] : '' ) . '</span></div>'; |
|
| 87 | - $output .= '<div class="live-longitude-wrap"><span class="live-longitude-label">' . __( 'Lng:', 'google-maps-builder' ) . '</span><span class="live-longitude">' . ( isset( $lat_lng['longitude'] ) ? $lat_lng['longitude'] : '' ) . '</span></div>'; |
|
| 85 | + $output .= '<button disabled class="update-lat-lng button button-small">'.__('Set Lat/Lng', 'google-maps-builder').'</button>'; |
|
| 86 | + $output .= '<div class="live-latitude-wrap"><span class="live-latitude-label">'.__('Lat:', 'google-maps-builder').'</span><span class="live-latitude">'.(isset($lat_lng['latitude']) ? $lat_lng['latitude'] : '').'</span></div>'; |
|
| 87 | + $output .= '<div class="live-longitude-wrap"><span class="live-longitude-label">'.__('Lng:', 'google-maps-builder').'</span><span class="live-longitude">'.(isset($lat_lng['longitude']) ? $lat_lng['longitude'] : '').'</span></div>'; |
|
| 88 | 88 | $output .= '</div>'; //End .live-lat-lng-wrap |
| 89 | 89 | $output .= '</div>'; //End #map-toolbar |
| 90 | 90 | $output .= '</div>'; //End #map |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | $output .= '<div class="inner-modal-wrap">'; |
| 96 | 96 | $output .= '<div class="inner-modal-container">'; |
| 97 | 97 | $output .= '<div class="inner-modal clearfix">'; |
| 98 | - $output .= '<label for="post_title" class="map-title">' . __( 'Map Title', 'google-maps-builder' ) . '</label>'; |
|
| 99 | - $output .= '<p class="cmb2-metabox-description">' . __( 'Give your Map a descriptive title', 'google-maps-builder' ) . '</p>'; |
|
| 100 | - $output .= '<button type="button" class="gmb-modal-close">×</button><input type="text" name="model_post_title" size="30" value="' . get_the_title() . '" id="modal_title" spellcheck="true" autocomplete="off" placeholder="' . __( 'Enter map title', 'google-maps-builder' ) . '">'; |
|
| 98 | + $output .= '<label for="post_title" class="map-title">'.__('Map Title', 'google-maps-builder').'</label>'; |
|
| 99 | + $output .= '<p class="cmb2-metabox-description">'.__('Give your Map a descriptive title', 'google-maps-builder').'</p>'; |
|
| 100 | + $output .= '<button type="button" class="gmb-modal-close">×</button><input type="text" name="model_post_title" size="30" value="'.get_the_title().'" id="modal_title" spellcheck="true" autocomplete="off" placeholder="'.__('Enter map title', 'google-maps-builder').'">'; |
|
| 101 | 101 | $output .= '</div>'; |
| 102 | 102 | $output .= '</div>'; |
| 103 | 103 | $output .= '</div>'; |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | $output .= '<div class="inner-modal-wrap">'; |
| 108 | 108 | $output .= '<div class="inner-modal-container">'; |
| 109 | 109 | $output .= '<div class="inner-modal clearfix">'; |
| 110 | - $output .= '<label for="map-location-autocomplete" class="map-title">' . __( 'Enter a Location', 'google-maps-builder' ) . '</label>'; |
|
| 111 | - $output .= '<p class="cmb2-metabox-description">' . __( 'Type your point of interest below and the map will be re-centered over that location', 'google-maps-builder' ) . '</p>'; |
|
| 110 | + $output .= '<label for="map-location-autocomplete" class="map-title">'.__('Enter a Location', 'google-maps-builder').'</label>'; |
|
| 111 | + $output .= '<p class="cmb2-metabox-description">'.__('Type your point of interest below and the map will be re-centered over that location', 'google-maps-builder').'</p>'; |
|
| 112 | 112 | $output .= '<button type="button" class="gmb-modal-close">×</button>'; |
| 113 | 113 | $output .= '<input type="text" name="" size="30" id="map-location-autocomplete">'; |
| 114 | 114 | $output .= '</div>'; |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | $output .= '<div class="warning-message wpgp-message"></div>'; |
| 120 | 120 | |
| 121 | 121 | //Markers Modal |
| 122 | - gmb_include_view( 'admin/views/markers.php', false, $this->view_data() ); |
|
| 122 | + gmb_include_view('admin/views/markers.php', false, $this->view_data()); |
|
| 123 | 123 | |
| 124 | - echo apply_filters( 'google_maps_preview', $output ); |
|
| 124 | + echo apply_filters('google_maps_preview', $output); |
|
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return string |
| 140 | 140 | */ |
| 141 | - function gmb_modify_cmb2_form_output( $form_format, $object_id, $cmb ) { |
|
| 141 | + function gmb_modify_cmb2_form_output($form_format, $object_id, $cmb) { |
|
| 142 | 142 | |
| 143 | 143 | //only modify the give settings form |
| 144 | - if ( 'gmb_settings' == $object_id && 'plugin_options' == $cmb->cmb_id ) { |
|
| 144 | + if ('gmb_settings' == $object_id && 'plugin_options' == $cmb->cmb_id) { |
|
| 145 | 145 | |
| 146 | - return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="gmb-submit-wrap"><input type="submit" name="submit-cmb" value="' . __( 'Save Settings', 'give' ) . '" class="button-primary"></div></form>'; |
|
| 146 | + return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="gmb-submit-wrap"><input type="submit" name="submit-cmb" value="'.__('Save Settings', 'give').'" class="button-primary"></div></form>'; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return $form_format; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | <div class="gmb-widget-upgrade clear"> |
| 164 | 164 | <span class="powered-by"></span> |
| 165 | 165 | <a href="https://wordimpress.com/plugins/maps-builder-pro?utm_source=MBF&utm_medium=BANNER&utm_content=WIDGET&utm_campaign=MBF%20Widgets" target="_blank" class="button button-small"> |
| 166 | - <?php _e( 'Upgrade to Pro', 'google-maps-builder' ); ?> |
|
| 166 | + <?php _e('Upgrade to Pro', 'google-maps-builder'); ?> |
|
| 167 | 167 | <span class="new-window"></span> |
| 168 | 168 | </a> |
| 169 | 169 | </div> |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return String Altered body classes. |
| 181 | 181 | */ |
| 182 | - function admin_body_classes( $classes ) { |
|
| 182 | + function admin_body_classes($classes) { |
|
| 183 | 183 | |
| 184 | 184 | global $post; |
| 185 | 185 | |
| 186 | - if ( isset( $post->post_type ) && $post->post_type == 'google_maps' ) { |
|
| 186 | + if (isset($post->post_type) && $post->post_type == 'google_maps') { |
|
| 187 | 187 | $classes .= 'maps-builder-free'; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * @return mixed |
| 199 | 199 | */ |
| 200 | 200 | |
| 201 | - function remove_row_actions( $actions, $post ) { |
|
| 201 | + function remove_row_actions($actions, $post) { |
|
| 202 | 202 | global $current_screen; |
| 203 | - if ( $current_screen->post_type != 'google_maps' ) { |
|
| 203 | + if ($current_screen->post_type != 'google_maps') { |
|
| 204 | 204 | return $actions; |
| 205 | 205 | } |
| 206 | 206 | add_thickbox(); |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | <?php |
| 235 | 235 | |
| 236 | 236 | // Remove the Quick Edit link |
| 237 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
| 238 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 239 | - $actions['custom'] = '<a href="#TB_inline?width=1400px&height=600px&inlineId=gmb-preview-map" data-id="' . $post->ID . '" class="thickbox gmb-load-map">' . sprintf( __( 'Preview Map', 'google-maps-builder' ) ) . '</a>'; |
|
| 237 | + if (isset($actions['inline hide-if-no-js'])) { |
|
| 238 | + unset($actions['inline hide-if-no-js']); |
|
| 239 | + $actions['custom'] = '<a href="#TB_inline?width=1400px&height=600px&inlineId=gmb-preview-map" data-id="'.$post->ID.'" class="thickbox gmb-load-map">'.sprintf(__('Preview Map', 'google-maps-builder')).'</a>'; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | return $actions; |
@@ -246,24 +246,24 @@ discard block |
||
| 246 | 246 | * Callback function for preview map. |
| 247 | 247 | */ |
| 248 | 248 | function preview_map_action_callback() { |
| 249 | - $map_id = isset( $_POST['map_id'] ) ? $_POST['map_id'] : ''; |
|
| 249 | + $map_id = isset($_POST['map_id']) ? $_POST['map_id'] : ''; |
|
| 250 | 250 | //gather data for this shortcode |
| 251 | - $post = get_post( $map_id ); |
|
| 252 | - $all_meta = get_post_custom( $map_id ); |
|
| 253 | - $visual_info = maybe_unserialize( $all_meta['gmb_width_height'][0] ); |
|
| 254 | - $lat_lng = maybe_unserialize( $all_meta['gmb_lat_lng'][0] ); |
|
| 251 | + $post = get_post($map_id); |
|
| 252 | + $all_meta = get_post_custom($map_id); |
|
| 253 | + $visual_info = maybe_unserialize($all_meta['gmb_width_height'][0]); |
|
| 254 | + $lat_lng = maybe_unserialize($all_meta['gmb_lat_lng'][0]); |
|
| 255 | 255 | //Put markers into an array for JS usage |
| 256 | 256 | $map_marker_array = array(); |
| 257 | - $markers_repeatable = isset( $all_meta['gmb_markers_group'][0] ) ? maybe_unserialize( $all_meta['gmb_markers_group'][0] ) : ''; |
|
| 258 | - if ( is_array( $markers_repeatable ) ) { |
|
| 259 | - foreach ( $markers_repeatable as $marker ) { |
|
| 260 | - array_push( $map_marker_array, $marker ); |
|
| 257 | + $markers_repeatable = isset($all_meta['gmb_markers_group'][0]) ? maybe_unserialize($all_meta['gmb_markers_group'][0]) : ''; |
|
| 258 | + if (is_array($markers_repeatable)) { |
|
| 259 | + foreach ($markers_repeatable as $marker) { |
|
| 260 | + array_push($map_marker_array, $marker); |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | //Send data for AJAX usage |
| 264 | 264 | //Add params to AJAX for Shortcode Usage |
| 265 | 265 | //@see: http://benjaminrojas.net/using-wp_localize_script-dynamically/ |
| 266 | - $localized_data = apply_filters( 'gmb_localized_data', array( |
|
| 266 | + $localized_data = apply_filters('gmb_localized_data', array( |
|
| 267 | 267 | $post->ID => array( |
| 268 | 268 | 'id' => $post->ID, |
| 269 | 269 | 'map_params' => array( |
@@ -272,39 +272,39 @@ discard block |
||
| 272 | 272 | 'height' => $visual_info['height'], |
| 273 | 273 | 'latitude' => $lat_lng['latitude'], |
| 274 | 274 | 'longitude' => $lat_lng['longitude'], |
| 275 | - 'zoom' => ! empty( $all_meta['gmb_zoom'][0] ) ? $all_meta['gmb_zoom'][0] : '15', |
|
| 276 | - 'default_marker' => apply_filters( 'gmb_default_marker', GMB_PLUGIN_URL . 'assets/img/spotlight-poi.png' ), |
|
| 275 | + 'zoom' => ! empty($all_meta['gmb_zoom'][0]) ? $all_meta['gmb_zoom'][0] : '15', |
|
| 276 | + 'default_marker' => apply_filters('gmb_default_marker', GMB_PLUGIN_URL.'assets/img/spotlight-poi.png'), |
|
| 277 | 277 | ), |
| 278 | 278 | 'map_controls' => array( |
| 279 | - 'zoom_control' => ! empty( $all_meta['gmb_zoom_control'][0] ) ? strtoupper( $all_meta['gmb_zoom_control'][0] ) : 'STANDARD', |
|
| 280 | - 'pan_control' => ! empty( $all_meta['gmb_pan'][0] ) ? $all_meta['gmb_pan'][0] : 'none', |
|
| 281 | - 'map_type_control' => ! empty( $all_meta['gmb_map_type_control'][0] ) ? $all_meta['gmb_map_type_control'][0] : 'none', |
|
| 282 | - 'draggable' => ! empty( $all_meta['gmb_draggable'][0] ) ? $all_meta['gmb_draggable'][0] : 'none', |
|
| 283 | - 'double_click_zoom' => ! empty( $all_meta['gmb_double_click'][0] ) ? $all_meta['gmb_double_click'][0] : 'none', |
|
| 284 | - 'wheel_zoom' => ! empty( $all_meta['gmb_wheel_zoom'][0] ) ? $all_meta['gmb_wheel_zoom'][0] : 'none', |
|
| 285 | - 'street_view' => ! empty( $all_meta['gmb_street_view'][0] ) ? $all_meta['gmb_street_view'][0] : 'none', |
|
| 279 | + 'zoom_control' => ! empty($all_meta['gmb_zoom_control'][0]) ? strtoupper($all_meta['gmb_zoom_control'][0]) : 'STANDARD', |
|
| 280 | + 'pan_control' => ! empty($all_meta['gmb_pan'][0]) ? $all_meta['gmb_pan'][0] : 'none', |
|
| 281 | + 'map_type_control' => ! empty($all_meta['gmb_map_type_control'][0]) ? $all_meta['gmb_map_type_control'][0] : 'none', |
|
| 282 | + 'draggable' => ! empty($all_meta['gmb_draggable'][0]) ? $all_meta['gmb_draggable'][0] : 'none', |
|
| 283 | + 'double_click_zoom' => ! empty($all_meta['gmb_double_click'][0]) ? $all_meta['gmb_double_click'][0] : 'none', |
|
| 284 | + 'wheel_zoom' => ! empty($all_meta['gmb_wheel_zoom'][0]) ? $all_meta['gmb_wheel_zoom'][0] : 'none', |
|
| 285 | + 'street_view' => ! empty($all_meta['gmb_street_view'][0]) ? $all_meta['gmb_street_view'][0] : 'none', |
|
| 286 | 286 | ), |
| 287 | 287 | 'map_theme' => array( |
| 288 | - 'map_type' => ! empty( $all_meta['gmb_type'][0] ) ? $all_meta['gmb_type'][0] : 'RoadMap', |
|
| 289 | - 'map_theme_json' => ! empty( $all_meta['gmb_theme_json'][0] ) ? $all_meta['gmb_theme_json'][0] : 'none', |
|
| 288 | + 'map_type' => ! empty($all_meta['gmb_type'][0]) ? $all_meta['gmb_type'][0] : 'RoadMap', |
|
| 289 | + 'map_theme_json' => ! empty($all_meta['gmb_theme_json'][0]) ? $all_meta['gmb_theme_json'][0] : 'none', |
|
| 290 | 290 | |
| 291 | 291 | ), |
| 292 | 292 | 'map_markers' => $map_marker_array, |
| 293 | 293 | 'plugin_url' => GMB_PLUGIN_URL, |
| 294 | 294 | 'places_api' => array( |
| 295 | - 'show_places' => ! empty( $all_meta['gmb_show_places'][0] ) ? $all_meta['gmb_show_places'][0] : 'no', |
|
| 296 | - 'search_radius' => ! empty( $all_meta['gmb_search_radius'][0] ) ? $all_meta['gmb_search_radius'][0] : '3000', |
|
| 297 | - 'search_places' => ! empty( $all_meta['gmb_places_search_multicheckbox'][0] ) ? maybe_unserialize( $all_meta['gmb_places_search_multicheckbox'][0] ) : '', |
|
| 295 | + 'show_places' => ! empty($all_meta['gmb_show_places'][0]) ? $all_meta['gmb_show_places'][0] : 'no', |
|
| 296 | + 'search_radius' => ! empty($all_meta['gmb_search_radius'][0]) ? $all_meta['gmb_search_radius'][0] : '3000', |
|
| 297 | + 'search_places' => ! empty($all_meta['gmb_places_search_multicheckbox'][0]) ? maybe_unserialize($all_meta['gmb_places_search_multicheckbox'][0]) : '', |
|
| 298 | 298 | ), |
| 299 | - 'map_markers_icon' => ! empty( $all_meta['gmb_map_marker'] ) ? $all_meta['gmb_map_marker'][0] : 'none', |
|
| 299 | + 'map_markers_icon' => ! empty($all_meta['gmb_map_marker']) ? $all_meta['gmb_map_marker'][0] : 'none', |
|
| 300 | 300 | ), |
| 301 | - ) ); |
|
| 301 | + )); |
|
| 302 | 302 | |
| 303 | - $maphtml = '<div class="google-maps-builder-wrap"> <div id="google-maps-builder-' . $map_id . '" class="google-maps-builder" data-map-id="' . $map_id . '" style="width: 1400px; height:600px;"></div></div>'; |
|
| 303 | + $maphtml = '<div class="google-maps-builder-wrap"> <div id="google-maps-builder-'.$map_id.'" class="google-maps-builder" data-map-id="'.$map_id.'" style="width: 1400px; height:600px;"></div></div>'; |
|
| 304 | 304 | $responseArray = array(); |
| 305 | 305 | $responseArray['localized'] = $localized_data; |
| 306 | 306 | $responseArray['maphtml'] = $maphtml; |
| 307 | - echo wp_send_json( $responseArray ); |
|
| 307 | + echo wp_send_json($responseArray); |
|
| 308 | 308 | wp_die(); |
| 309 | 309 | } |
| 310 | 310 | |