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

155 lines 5.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: Google Maps CP
4 Text Domain: codepeople-post-map
5 Version: 1.1.8
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 require (CPM_PLUGIN_DIR.'/include/functions.php');
21 add_filter('option_sbp_settings', array('CPM', 'troubleshoot'));
22
23 // Redirecting the user to the settings page of the plugin
24 add_action( 'activated_plugin', 'cpm_redirect_to_settings', 10, 2 );
25 if(!function_exists('cpm_redirect_to_settings'))
26 {
27 function cpm_redirect_to_settings($plugin, $network_activation)
28 {
29 if(
30 empty( $_REQUEST['_ajax_nonce'] ) &&
31 $plugin == plugin_basename( __FILE__ ) &&
32 (!isset($_POST["action"]) || $_POST["action"] != 'activate-selected') &&
33 (!isset($_POST["action2"]) || $_POST["action2"] != 'activate-selected')
34 )
35 {
36 exit( wp_redirect( admin_url( 'options-general.php?page=codepeople-post-map.php' ) ) );
37 }
38 }
39 }
40
41 // Create a CPM object that contain main plugin logic
42 add_action( 'init', 'cpm_init');
43 add_action( 'admin_init', 'cpm_admin_init' );
44
45 register_activation_hook(__FILE__, 'codepeople_post_map_regiter');
46
47 if(!function_exists('codepeople_post_map_regiter')){
48 function codepeople_post_map_regiter(){
49 $cpm_master_obj = new CPM;
50 $cpm_master_obj->set_default_configuration();
51 }
52 }
53
54 function cpm_admin_init(){
55 global $cpm_master_obj;
56
57 // Insert the map's insertion form below the posts and pages editor
58 $form_title = __('Associate an address to the post for Google Maps association', 'codepeople-post-map');
59 add_meta_box('codepeople_post_map_form', $form_title, array($cpm_master_obj, 'insert_form'), 'post', 'normal');
60 add_meta_box('codepeople_post_map_form', $form_title, array($cpm_master_obj, 'insert_form'), 'page', 'normal');
61
62 add_action('save_post', array(&$cpm_master_obj, 'save_map'));
63
64 $plugin = plugin_basename(__FILE__);
65 add_filter('plugin_action_links_'.$plugin, array(&$cpm_master_obj, 'customizationLink'));
66
67 }
68
69 function cpm_init(){
70 load_plugin_textdomain( 'codepeople-post-map', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
71 global $cpm_master_obj, $cpm_objs;
72 $cpm_master_obj = new CPM;
73 $cpm_objs = array();
74
75 if(!is_admin())
76 {
77 add_shortcode('codepeople-post-map', array(&$cpm_master_obj, 'replace_shortcode'));
78 add_action('the_post', 'cpm_populate_points' );
79 add_action( 'wp_footer', 'cpm_print_points' );
80 add_action( 'loop_start', 'cpm_loop_start' );
81 add_action( 'loop_end', 'cpm_loop_end' );
82
83 add_filter('widget_text', 'do_shortcode');
84
85 $cpm_master_obj->preview();
86 }
87 }
88
89 if( !function_exists( 'cpm_loop_start' ) )
90 {
91 function cpm_loop_start()
92 {
93 global $cpm_in_loop;
94 $cpm_in_loop = true;
95 }
96 }
97 if( !function_exists( 'cpm_loop_end' ) )
98 {
99 function cpm_loop_end()
100 {
101 global $cpm_in_loop;
102 $cpm_in_loop = false;
103 }
104 }
105
106 if( !function_exists( 'cpm_populate_points' ) ){
107 function cpm_populate_points( $post ){
108 global $cpm_master_obj;
109 $cpm_master_obj->populate_points( $post->ID );
110 }
111 }
112
113 if( !function_exists( 'cpm_print_points' ) ){
114 function cpm_print_points(){
115 global $cpm_objs, $cpm_master_obj;
116
117 foreach( $cpm_objs as $cpm_obj ){
118 if( !empty( $cpm_obj->multiple ) )
119 {
120 $cpm_obj->points = $cpm_master_obj->points;
121 }
122 $cpm_obj->print_points();
123 }
124 }
125 }
126
127 if (!function_exists("cpm_settings")) {
128 function cpm_settings() {
129 global $cpm_master_obj;
130
131 if (!isset($cpm_master_obj)) {
132 return;
133 }
134
135 if (function_exists('add_options_page')) {
136 $slug = basename(__FILE__);
137 add_options_page('Google Maps CP', 'Google Maps CP', 'manage_options', $slug, array(&$cpm_master_obj, 'settings_page'));
138
139 add_menu_page( 'Google Maps CP', 'Google Maps CP', 'manage_options', $slug, array(&$cpm_master_obj, 'settings_page'));
140
141 add_submenu_page( $slug, 'Online Help', 'Online Help', 'read', 'google_maps_cp_help', array(&$cpm_master_obj, 'settings_page') );
142
143 add_submenu_page( $slug, 'I\'ve a Question', 'I\'ve a Question', 'read', 'google_maps_cp_question', array(&$cpm_master_obj, 'settings_page') );
144
145 add_submenu_page( $slug, 'Upgrade', 'Upgrade', 'read', 'google_maps_cp_upgrade', array(&$cpm_master_obj, 'settings_page') );
146 }
147 }
148 }
149
150 add_action('admin_enqueue_scripts', array(&$cpm_master_obj, 'load_admin_resources'), 1);
151 add_action('enqueue_block_editor_assets', array(&$cpm_master_obj, 'load_gutenberg_code'));
152 add_action('wp_head', array(&$cpm_master_obj, 'load_header_resources'), 10);
153 add_action('admin_menu', 'cpm_settings');
154
155 ?>