PluginProbe
Image Hotspot – Map Image Annotation / 3.8
Image Hotspot – Map Image Annotation v3.8
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.8, at index.php

236 lines 7.2 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.8
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.8);
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 // wp_register_style('imh-6310-head-css', false);
71 // wp_enqueue_style('imh-6310-head-css');
72
73 // wp_add_inline_style(
74 // 'imh-6310-head-css',
75 // '.imh-6310-point-icons { display: none; }'
76 // );
77 // }
78
79 // add_action('wp_enqueue_scripts', 'imh_6310_head_css', 999);
80
81 //Deactivate code start from here
82 add_action('admin_enqueue_scripts', 'imh_6310_myplugin_enqueue_assets');
83
84 function imh_6310_myplugin_enqueue_assets($hook)
85 {
86 if ($hook !== 'plugins.php') {
87 return;
88 }
89
90 wp_enqueue_script(
91 'imh-6310-myplugin-deactivation',
92 imh_6310_plugin_dir_url . 'assets/js/deactivation.js',
93 ['jquery'],
94 imh_6310_PLUGIN_CURRENT_VERSION,
95 true
96 );
97
98 wp_localize_script(
99 'imh-6310-myplugin-deactivation',
100 'myPluginData',
101 [
102 'ajax_url' => admin_url('admin-ajax.php'),
103 'plugin_slug' => plugin_basename(__FILE__)
104 ]
105 );
106
107 wp_enqueue_style(
108 'imh-6310-myplugin-deactivation-css',
109 imh_6310_plugin_dir_url . 'assets/css/deactivation.css',
110 [],
111 imh_6310_PLUGIN_CURRENT_VERSION
112 );
113 }
114
115 add_action('admin_footer', 'imh_6310_myplugin_deactivation_modal');
116
117 function imh_6310_myplugin_deactivation_modal()
118 {
119 $screen = get_current_screen();
120
121 if (!$screen || $screen->id !== 'plugins') {
122 return;
123 }
124
125 ?>
126 <div id="imh-6310-myplugin-modal" style="display:none;">
127
128 <div class="imh-6310-myplugin-overlay"></div>
129
130 <div class="imh-6310-myplugin-popup">
131
132 <h2>Quick Feedback</h2>
133
134 <p>Why are you deactivating this plugin?</p>
135
136 <form id="imh-6310-myplugin-feedback-form">
137
138 <label>
139 <input type="radio" name="reason" value="Found a better plugin">
140 Found a better plugin
141 </label>
142
143 <label>
144 <input type="radio" name="reason" value="Missing feature">
145 Missing feature
146 </label>
147
148 <label>
149 <input type="radio" name="reason" value="Plugin issue">
150 Plugin issue
151 </label>
152
153 <label>
154 <input type="radio" name="reason" value="Temporary">
155 Temporary deactivation
156 </label>
157
158 <label>
159 <input type="radio" name="reason" value="Other">
160 Other
161 </label>
162
163 <textarea
164 name="details"
165 rows="4"
166 placeholder="Additional feedback..."></textarea>
167
168 <div class="imh-6310-myplugin-actions">
169
170 <button
171 type="submit"
172 class="button button-primary">
173 Submit & Deactivate
174 </button>
175
176 <button
177 type="button"
178 class="button"
179 id="imh-6310-myplugin-skip">
180 Skip & Deactivate
181 </button>
182
183 </div>
184
185 </form>
186
187 </div>
188
189 </div>
190 <?php
191 }
192
193 add_action('wp_ajax_myplugin_send_feedback', 'imh_6310_myplugin_send_feedback');
194
195 function imh_6310_myplugin_send_feedback()
196 {
197 $reason = sanitize_text_field($_POST['reason'] ?? '');
198 $details = sanitize_textarea_field($_POST['details'] ?? '');
199 $admins = get_users([
200 'role' => 'administrator',
201 ]);
202
203
204 $admin_emails = [];
205
206 foreach ($admins as $admin) {
207 $admin_emails[] = $admin->user_email;
208 }
209 $admin_emails = implode(',', $admin_emails);
210
211 $response = wp_remote_post(
212 'https://demo.tcsesoft.com/plugin-feedback.php',
213 [
214 'timeout' => 15,
215 'headers' => [
216 'Content-Type' => 'application/json',
217 'X-API-KEY' => '7fK9xP2mQ8vN4rT6yH1jW5cL3zB0dS'
218 ],
219 'body' => wp_json_encode([
220 'reason' => $reason,
221 'details' => $details,
222 'plugin_version' => imh_6310_PLUGIN_CURRENT_VERSION,
223 'site_url' => home_url(),
224 'wp_version' => get_bloginfo('version'),
225 'email' => $admin_emails,
226 'plugin_name' => 'imh'
227 ])
228 ]
229 );
230
231 if (is_wp_error($response)) {
232 wp_send_json_error();
233 }
234
235 wp_send_json_success();
236 }