PluginProbe
CodePeople Post Map for Google Maps / 1.2.9
CodePeople Post Map for Google Maps v1.2.9
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.9, at codepeople-post-map.php

166 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: CodePeople Post Map for Google Maps
4 Text Domain: codepeople-post-map
5 Version: 1.2.9
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: CodePeople Post Map for Google Maps Allows to associate geocode information to posts and display it on map. CodePeople Post Map for Google Maps 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">CodePeople Post Map for Google Maps 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 add_action('admin_enqueue_scripts', array($cpm_master_obj, 'load_admin_resources'), 1);
84 add_action('enqueue_block_editor_assets', array($cpm_master_obj, 'load_gutenberg_code'));
85 add_action('wp_head', array($cpm_master_obj, 'load_header_resources'), 10);
86
87 $cpm_objs = array();
88
89 if(!is_admin())
90 {
91 add_shortcode('codepeople-post-map', array(&$cpm_master_obj, 'replace_shortcode'));
92 add_action('the_post', 'cpm_populate_points' );
93 add_action( 'wp_footer', 'cpm_print_points' );
94 add_action( 'loop_start', 'cpm_loop_start' );
95 add_action( 'loop_end', 'cpm_loop_end' );
96
97 add_filter('widget_text', 'do_shortcode');
98
99 $cpm_master_obj->preview();
100 }
101 }
102
103 if( !function_exists( 'cpm_loop_start' ) )
104 {
105 function cpm_loop_start()
106 {
107 global $cpm_in_loop;
108 $cpm_in_loop = true;
109 }
110 }
111 if( !function_exists( 'cpm_loop_end' ) )
112 {
113 function cpm_loop_end()
114 {
115 global $cpm_in_loop;
116 $cpm_in_loop = false;
117 }
118 }
119
120 if( !function_exists( 'cpm_populate_points' ) ){
121 function cpm_populate_points( $post ){
122 global $cpm_master_obj;
123 $cpm_master_obj->populate_points( $post->ID );
124 }
125 }
126
127 if( !function_exists( 'cpm_print_points' ) ){
128 function cpm_print_points(){
129 global $cpm_objs, $cpm_master_obj;
130
131 foreach( $cpm_objs as $cpm_obj ){
132 if( !empty( $cpm_obj->multiple ) )
133 {
134 $cpm_obj->points = $cpm_master_obj->points;
135 }
136 $cpm_obj->print_points();
137 }
138 }
139 }
140
141 if (!function_exists("cpm_settings")) {
142 function cpm_settings() {
143 global $cpm_master_obj;
144
145 if (!isset($cpm_master_obj)) {
146 return;
147 }
148
149 if (function_exists('add_options_page')) {
150 $slug = basename(__FILE__);
151 add_options_page('CodePeople Post Map for Google Maps', 'CodePeople Post Map for Google Maps', 'manage_options', $slug, array(&$cpm_master_obj, 'settings_page'));
152
153 add_menu_page( 'CodePeople Post Map for Google Maps', 'CodePeople Post Map for Google Maps', 'manage_options', $slug, array(&$cpm_master_obj, 'settings_page'), 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSJjdXJyZW50Q29sb3IiPg0KICA8cGF0aCBkPSJNMTIgMmMzLjE5NiAwIDYgMi42MTggNiA1LjYwMiAwIDMuMDkzLTIuNDkzIDcuMTMyLTYgMTIuNTkxLTMuNTA3LTUuNDU5LTYtOS40OTgtNi0xMi41OTFDNiA0LjYxOCA4LjgwNCAyIDEyIDJ6bTAgNGEyIDIgMCAxIDAgMCA0IDIgMiAwIDAgMCAwLTR6Ii8+DQo8L3N2Zz4=' );
154
155 add_submenu_page( $slug, 'Online Help', 'Online Help', 'read', 'google_maps_cp_help', array(&$cpm_master_obj, 'settings_page') );
156
157 add_submenu_page( $slug, 'I\'ve a Question', 'I\'ve a Question', 'read', 'google_maps_cp_question', array(&$cpm_master_obj, 'settings_page') );
158
159 add_submenu_page( $slug, 'Upgrade', 'Upgrade', 'read', 'google_maps_cp_upgrade', array(&$cpm_master_obj, 'settings_page') );
160 }
161 }
162 }
163
164 add_action('admin_menu', 'cpm_settings');
165
166 ?>