PluginProbe
Image Hotspot – Map Image Annotation / 3.7
Image Hotspot – Map Image Annotation v3.7
3.8 3.7 3.6 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 All 30 releases
image-map-hotspots / index.php

index.php in Image Hotspot – Map Image Annotation 3.7, at index.php

232 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Image Hotspot - Map Image Annotation
4 Plugin URI: https://wordpress.org/plugins/image-map-hotspots/
5 Description: Image hotspot lets you easily add custom tooltips to your images and add hotspot when highlighting them. Furthermore, you have the option of setting customized tooltip content, position, animation, and more.
6 Author: Sk Abul Hasan
7 Author URI: https://www.wpmart.org/
8 Version: 3.7
9 */
10
11 if (!defined('ABSPATH'))
12 exit;
13
14 define('imh_6310_plugin_url', plugin_dir_path(__FILE__));
15 define('imh_6310_plugin_dir_url', plugin_dir_url(__FILE__));
16 define('imh_6310_PLUGIN_CURRENT_VERSION', 3.7);
17
18 add_shortcode('imh_6310_image_map', 'imh_6310_image_map_shortcode');
19
20 function imh_6310_image_map_shortcode($atts)
21 {
22 extract(shortcode_atts(array('id' => ' ',), $atts));
23 $ids = (int) $atts['id'];
24
25 ob_start();
26 include(imh_6310_plugin_url . 'shortcode.php');
27 return ob_get_clean();
28 }
29
30
31 add_action('admin_menu', 'imh_6310_image_map_menu');
32
33 function imh_6310_image_map_menu()
34 {
35 $options = imh_6310_get_user_roles();
36 add_menu_page('Image Map Hotspot', 'Image Map Hotspot', $options, 'imh-6310-image-map-hotspot', 'imh_6310_home', 'dashicons-format-image', 20);
37 add_submenu_page('imh-6310-image-map-hotspot', 'Image Map Hotspot', 'All Image Map Hotspot', $options, 'imh-6310-image-map-hotspot', 'imh_6310_home');
38 add_submenu_page('imh-6310-image-map-hotspot', 'Settings', 'Settings', $options, 'imh-6310-image-map-hotspot-setting', 'imh_6310_image_map_hotspot_setting');
39 add_submenu_page('imh-6310-image-map-hotspot', 'Import / Export Plugin', 'Import/Export Plugin', $options, 'imh-6310-image-map-hotspot-import-export', 'imh_6310_image_map_hotspot_import_export');
40 add_submenu_page('imh-6310-image-map-hotspot', 'License', 'License', $options, 'imh-6310-image-map-hotspot-license', 'imh_6310_image_map_hotspot_lincense');
41 add_submenu_page('imh-6310-image-map-hotspot', 'How to use', 'Help', $options, 'imh-6310-image-map-hotspot-use', 'imh_6310_image_map_hotspot_how_to_use');
42 add_submenu_page('imh-6310-image-map-hotspot', 'WpMart Plugins', 'WpMart Plugins', $options, 'imh-6310-wpmart-plugins', 'imh_6310_wpmart_plugins');
43 }
44
45 include imh_6310_plugin_url . 'template-menu.php';
46
47 register_activation_hook(__FILE__, 'imh_6310_image_map_install');
48 include_once(imh_6310_plugin_url . 'functions.php');
49
50 function imh_6310_activation_redirect($plugin)
51 {
52 if ($plugin == plugin_basename(__FILE__)) {
53 exit(wp_redirect(admin_url('admin.php?page=imh-6310-image-map-hotspot-use')));
54 }
55 }
56 add_action('activated_plugin', 'imh_6310_activation_redirect');
57
58 add_action('admin_enqueue_scripts', 'imh_6310_link_css_js');
59
60
61 function imh_6310_plugin_update_check()
62 {
63 imh_6310_version_status();
64 imh_6310_check_field_exists();
65 }
66 add_action('plugins_loaded', 'imh_6310_plugin_update_check');
67
68 function imh_6310_head_css()
69 {
70 $custom_css = ".imh-6310-point-icons{display: none}";
71 wp_register_style('imh-6310-head-css', "");
72 wp_enqueue_style('imh-6310-head-css');
73 wp_add_inline_style('imh-6310-head-css', $custom_css);
74 }
75 add_action('wp_enqueue_scripts', 'imh_6310_head_css', 999);
76
77 //Deactivate code start from here
78 add_action('admin_enqueue_scripts', 'imh_6310_myplugin_enqueue_assets');
79
80 function imh_6310_myplugin_enqueue_assets($hook)
81 {
82 if ($hook !== 'plugins.php') {
83 return;
84 }
85
86 wp_enqueue_script(
87 'imh-6310-myplugin-deactivation',
88 imh_6310_plugin_dir_url . 'assets/js/deactivation.js',
89 ['jquery'],
90 imh_6310_PLUGIN_CURRENT_VERSION,
91 true
92 );
93
94 wp_localize_script(
95 'imh-6310-myplugin-deactivation',
96 'myPluginData',
97 [
98 'ajax_url' => admin_url('admin-ajax.php'),
99 'plugin_slug' => plugin_basename(__FILE__)
100 ]
101 );
102
103 wp_enqueue_style(
104 'imh-6310-myplugin-deactivation-css',
105 imh_6310_plugin_dir_url . 'assets/css/deactivation.css',
106 [],
107 imh_6310_PLUGIN_CURRENT_VERSION
108 );
109 }
110
111 add_action('admin_footer', 'imh_6310_myplugin_deactivation_modal');
112
113 function imh_6310_myplugin_deactivation_modal()
114 {
115 $screen = get_current_screen();
116
117 if (!$screen || $screen->id !== 'plugins') {
118 return;
119 }
120
121 ?>
122 <div id="imh-6310-myplugin-modal" style="display:none;">
123
124 <div class="imh-6310-myplugin-overlay"></div>
125
126 <div class="imh-6310-myplugin-popup">
127
128 <h2>Quick Feedback</h2>
129
130 <p>Why are you deactivating this plugin?</p>
131
132 <form id="imh-6310-myplugin-feedback-form">
133
134 <label>
135 <input type="radio" name="reason" value="Found a better plugin">
136 Found a better plugin
137 </label>
138
139 <label>
140 <input type="radio" name="reason" value="Missing feature">
141 Missing feature
142 </label>
143
144 <label>
145 <input type="radio" name="reason" value="Plugin issue">
146 Plugin issue
147 </label>
148
149 <label>
150 <input type="radio" name="reason" value="Temporary">
151 Temporary deactivation
152 </label>
153
154 <label>
155 <input type="radio" name="reason" value="Other">
156 Other
157 </label>
158
159 <textarea
160 name="details"
161 rows="4"
162 placeholder="Additional feedback..."></textarea>
163
164 <div class="imh-6310-myplugin-actions">
165
166 <button
167 type="submit"
168 class="button button-primary">
169 Submit & Deactivate
170 </button>
171
172 <button
173 type="button"
174 class="button"
175 id="imh-6310-myplugin-skip">
176 Skip & Deactivate
177 </button>
178
179 </div>
180
181 </form>
182
183 </div>
184
185 </div>
186 <?php
187 }
188
189 add_action('wp_ajax_myplugin_send_feedback', 'imh_6310_myplugin_send_feedback');
190
191 function imh_6310_myplugin_send_feedback()
192 {
193 $reason = sanitize_text_field($_POST['reason'] ?? '');
194 $details = sanitize_textarea_field($_POST['details'] ?? '');
195 $admins = get_users([
196 'role' => 'administrator',
197 ]);
198
199
200 $admin_emails = [];
201
202 foreach ($admins as $admin) {
203 $admin_emails[] = $admin->user_email;
204 }
205 $admin_emails = implode(',', $admin_emails);
206
207 $response = wp_remote_post(
208 'https://demo.tcsesoft.com/plugin-feedback.php',
209 [
210 'timeout' => 15,
211 'headers' => [
212 'Content-Type' => 'application/json',
213 'X-API-KEY' => '7fK9xP2mQ8vN4rT6yH1jW5cL3zB0dS'
214 ],
215 'body' => wp_json_encode([
216 'reason' => $reason,
217 'details' => $details,
218 'plugin_version' => imh_6310_PLUGIN_CURRENT_VERSION,
219 'site_url' => home_url(),
220 'wp_version' => get_bloginfo('version'),
221 'email' => $admin_emails,
222 'plugin_name' => 'imh'
223 ])
224 ]
225 );
226
227 if (is_wp_error($response)) {
228 wp_send_json_error();
229 }
230
231 wp_send_json_success();
232 }