PluginProbe
CodePeople Post Map for Google Maps / 1.2.4
CodePeople Post Map for Google Maps v1.2.4
1.3.0 1.2.9 1.2.8 1.2.7 1.2.6 trunk 1.0.44 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5
codepeople-post-map / codepeople-post-map.php

codepeople-post-map.php in CodePeople Post Map for Google Maps 1.2.4, at codepeople-post-map.php

165 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Google Maps CP
4 Text Domain: codepeople-post-map
5 Version: 1.2.4
6 Author: CodePeople
7 Author URI: http://wordpress.dwbooster.com/content-tools/codepeople-post-map
8 Plugin URI: http://wordpress.dwbooster.com/content-tools/codepeople-post-map
9 Text Domain: codepeople-post-map
10 Description: Google Maps CP Allows to associate geocode information to posts and display it on map. Google Maps CP display the post list as markers on map. The scale of map is determined by the markers, to display distant points is required to load a map with smaller scales. To get started: 1) Click the "Activate" link to the left of this description. 2) Go to your <a href="options-general.php?page=codepeople-post-map.php">Google Maps CP configuration</a> page and configure the maps settings. 3) Go to post edition page to enter the geolocation information.
11 */
12
13 // Feedback system
14 require_once 'feedback/cp-feedback.php';
15 new CP_FEEDBACK(plugin_basename( dirname(__FILE__) ), __FILE__, 'https://wordpress.dwbooster.com/contact-us');
16
17 define('CPM_PLUGIN_DIR', WP_PLUGIN_DIR."/".dirname(plugin_basename(__FILE__)));
18 define('CPM_PLUGIN_URL', plugins_url()."/".dirname(plugin_basename(__FILE__)));
19
20 add_action( 'init', function(){
21 add_filter( 'get_post_metadata', function( $v, $object_id, $meta_key, $single, $meta_type = '' ){
22 if ( '_elementor_element_cache' == $meta_key ) {
23 global $wpdb;
24 if ( $wpdb->get_var( $wpdb->prepare('SELECT COUNT(*) FROM ' . $wpdb->postmeta . ' WHERE post_id=%d AND meta_key="_elementor_element_cache" AND meta_value LIKE "%cpm_%";', $object_id ) ) ) return false;
25 }
26 return $v;
27 }, 10, 5 );
28 } );
29
30 require (CPM_PLUGIN_DIR.'/include/functions.php');
31 add_filter('option_sbp_settings', array('CPM', 'troubleshoot'));
32
33 // Redirecting the user to the settings page of the plugin
34 add_action( 'activated_plugin', 'cpm_redirect_to_settings', 10, 2 );
35 if(!function_exists('cpm_redirect_to_settings'))
36 {
37 function cpm_redirect_to_settings($plugin, $network_activation)
38 {
39 if(
40 empty( $_REQUEST['_ajax_nonce'] ) &&
41 $plugin == plugin_basename( __FILE__ ) &&
42 (!isset($_POST["action"]) || $_POST["action"] != 'activate-selected') &&
43 (!isset($_POST["action2"]) || $_POST["action2"] != 'activate-selected')
44 )
45 {
46 exit( wp_redirect( admin_url( 'options-general.php?page=codepeople-post-map.php' ) ) );
47 }
48 }
49 }
50
51 // Create a CPM object that contain main plugin logic
52 add_action( 'init', 'cpm_init');
53 add_action( 'admin_init', 'cpm_admin_init' );
54
55 register_activation_hook(__FILE__, 'codepeople_post_map_regiter');
56
57 if(!function_exists('codepeople_post_map_regiter')){
58 function codepeople_post_map_regiter(){
59 $cpm_master_obj = new CPM;
60 $cpm_master_obj->set_default_configuration();
61 }
62 }
63
64 function cpm_admin_init(){
65 global $cpm_master_obj;
66
67 // Insert the map's insertion form below the posts and pages editor
68 $form_title = __('Associate an address to the post for Google Maps association', 'codepeople-post-map');
69 add_meta_box('codepeople_post_map_form', $form_title, array($cpm_master_obj, 'insert_form'), 'post', 'normal');
70 add_meta_box('codepeople_post_map_form', $form_title, array($cpm_master_obj, 'insert_form'), 'page', 'normal');
71
72 add_action('save_post', array(&$cpm_master_obj, 'save_map'));
73
74 $plugin = plugin_basename(__FILE__);
75 add_filter('plugin_action_links_'.$plugin, array(&$cpm_master_obj, 'customizationLink'));
76
77 }
78
79 function cpm_init(){
80 load_plugin_textdomain( 'codepeople-post-map', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
81 global $cpm_master_obj, $cpm_objs;
82 $cpm_master_obj = new CPM;
83 $cpm_objs = array();
84
85 if(!is_admin())
86 {
87 add_shortcode('codepeople-post-map', array(&$cpm_master_obj, 'replace_shortcode'));
88 add_action('the_post', 'cpm_populate_points' );
89 add_action( 'wp_footer', 'cpm_print_points' );
90 add_action( 'loop_start', 'cpm_loop_start' );
91 add_action( 'loop_end', 'cpm_loop_end' );
92
93 add_filter('widget_text', 'do_shortcode');
94
95 $cpm_master_obj->preview();
96 }
97 }
98
99 if( !function_exists( 'cpm_loop_start' ) )
100 {
101 function cpm_loop_start()
102 {
103 global $cpm_in_loop;
104 $cpm_in_loop = true;
105 }
106 }
107 if( !function_exists( 'cpm_loop_end' ) )
108 {
109 function cpm_loop_end()
110 {
111 global $cpm_in_loop;
112 $cpm_in_loop = false;
113 }
114 }
115
116 if( !function_exists( 'cpm_populate_points' ) ){
117 function cpm_populate_points( $post ){
118 global $cpm_master_obj;
119 $cpm_master_obj->populate_points( $post->ID );
120 }
121 }
122
123 if( !function_exists( 'cpm_print_points' ) ){
124 function cpm_print_points(){
125 global $cpm_objs, $cpm_master_obj;
126
127 foreach( $cpm_objs as $cpm_obj ){
128 if( !empty( $cpm_obj->multiple ) )
129 {
130 $cpm_obj->points = $cpm_master_obj->points;
131 }
132 $cpm_obj->print_points();
133 }
134 }
135 }
136
137 if (!function_exists("cpm_settings")) {
138 function cpm_settings() {
139 global $cpm_master_obj;
140
141 if (!isset($cpm_master_obj)) {
142 return;
143 }
144
145 if (function_exists('add_options_page')) {
146 $slug = basename(__FILE__);
147 add_options_page('Google Maps CP', 'Google Maps CP', 'manage_options', $slug, array(&$cpm_master_obj, 'settings_page'));
148
149 add_menu_page( 'Google Maps CP', 'Google Maps CP', 'manage_options', $slug, array(&$cpm_master_obj, 'settings_page'), 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSJjdXJyZW50Q29sb3IiPg0KICA8cGF0aCBkPSJNMTIgMmMzLjE5NiAwIDYgMi42MTggNiA1LjYwMiAwIDMuMDkzLTIuNDkzIDcuMTMyLTYgMTIuNTkxLTMuNTA3LTUuNDU5LTYtOS40OTgtNi0xMi41OTFDNiA0LjYxOCA4LjgwNCAyIDEyIDJ6bTAgNGEyIDIgMCAxIDAgMCA0IDIgMiAwIDAgMCAwLTR6Ii8+DQo8L3N2Zz4=' );
150
151 add_submenu_page( $slug, 'Online Help', 'Online Help', 'read', 'google_maps_cp_help', array(&$cpm_master_obj, 'settings_page') );
152
153 add_submenu_page( $slug, 'I\'ve a Question', 'I\'ve a Question', 'read', 'google_maps_cp_question', array(&$cpm_master_obj, 'settings_page') );
154
155 add_submenu_page( $slug, 'Upgrade', 'Upgrade', 'read', 'google_maps_cp_upgrade', array(&$cpm_master_obj, 'settings_page') );
156 }
157 }
158 }
159
160 add_action('admin_enqueue_scripts', array(&$cpm_master_obj, 'load_admin_resources'), 1);
161 add_action('enqueue_block_editor_assets', array(&$cpm_master_obj, 'load_gutenberg_code'));
162 add_action('wp_head', array(&$cpm_master_obj, 'load_header_resources'), 10);
163 add_action('admin_menu', 'cpm_settings');
164
165 ?>