PluginProbe
Property Hive / 2.4.0
Property Hive v2.4.0
2.4.0 2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 All 262 releases
← All changes | includes/admin/class-ph-admin-assets.php +334 -19 1.4.58 → 2.4.0 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +// phpcs:set WordPress.Security.ValidatedSanitizedInput customSanitizingFunctions[] ph_clean
3 +// ph_clean() recursively sanitizes text; presence, shape and unslashing checks remain separate.
4 +
2 5 /**
3 6 * Load assets.
4 7 *
5 8 * @author PropertyHive
@@ -14,8 +17,9 @@
14 17
15 18 /**
16 19 * PH_Admin_Assets Class
17 20 */
21 +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy public global class PH_Admin_Assets; preserving the existing PH_* class name is required for plugin and extension compatibility.
18 22 class PH_Admin_Assets {
19 23
20 24 /**
21 25 * Hook in tabs.
@@ -34,9 +38,9 @@
34 38 // Sitewide menu CSS
35 39 //wp_enqueue_style( 'propertyhive_admin_menu_styles', PH()->plugin_url() . '/assets/css/menu.css', array(), PH_VERSION );
36 40
37 41 $screen = get_current_screen();
38 -
42 +
39 43 if ( in_array( $screen->id, ph_get_screen_ids() ) ) {
40 44
41 45 $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.9.2';
42 46
@@ -50,14 +54,70 @@
50 54
51 55 wp_enqueue_style( 'chosen', PH()->plugin_url() . '/assets/css/chosen.css', array(), PH_VERSION );
52 56
53 57 wp_enqueue_style( 'multiselect', PH()->plugin_url() . '/assets/css/jquery.multiselect.css', array(), '2.4.18' );
58 +
59 + if ( apply_filters('propertyhive_disable_notes_mention', false) === false )
60 + {
61 + wp_enqueue_style( 'tinymce-mention', PH()->plugin_url() . '/assets/js/tinymce-mention-plugin/autocomplete.css', array(), PH_VERSION );
62 + }
63 +
64 + if ( get_option('propertyhive_maps_provider') == 'mapbox' )
65 + {
66 + wp_enqueue_style('mapbox', PH()->plugin_url() . '/assets/js/mapbox/mapbox-gl.css', array(), '3.8.0' );
67 + }
54 68 }
55 69
70 + if ( in_array( $screen->id, array( 'dashboard_page_ph-onboarding' ), true ) )
71 + {
72 + wp_enqueue_style( 'propertyhive_admin_onboarding', PH()->plugin_url() . '/assets/css/admin-onboarding.css', array(), PH_VERSION );
73 + }
74 +
75 + if ( in_array( $screen->id, array( 'property' ) ) )
76 + {
77 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only tour asset selection; no data is changed.
78 + if ( isset( $_GET['tutorial'] ) && is_string( $_GET['tutorial'] ) && sanitize_text_field( wp_unslash( $_GET['tutorial'] ) ) === 'yes' )
79 + {
80 + wp_register_style( 'tour-css', PH()->plugin_url() . '/assets/css/tours/style.css', array(), '1.0.1' );
81 + wp_register_style( 'driver-css', PH()->plugin_url() . '/assets/css/tours/driver-js.css', array(), '1.0.1' );
82 + wp_enqueue_style( 'tour-css' );
83 + wp_enqueue_style( 'driver-css' );
84 + }
85 + }
86 +
87 + if ( in_array( $screen->id, array( 'edit-contact', 'edit-enquiry', 'edit-appraisal', 'edit-viewing', 'edit-offer', 'edit-sale', 'edit-key_date' ) ) )
88 + {
89 + wp_enqueue_style( 'daterangepicker.css', PH()->plugin_url() . '/assets/js/daterangepicker/daterangepicker.css', array(), '3.1.0' );
90 + }
91 +
92 + if ( in_array( $screen->id, array( 'edit-key_date') ) )
93 + {
94 + wp_enqueue_style( 'admin-hide-default-post-data.css', PH()->plugin_url() . '/assets/css/admin-hide-default-post-data.css', array(), PH_VERSION );
95 + }
96 +
97 + if (
98 + get_option('propertyhive_module_disabled_viewings', '') != 'yes' &&
99 + in_array( $screen->id, array( 'property', 'contact' ) )
100 + )
101 + {
102 + wp_enqueue_style( 'propertyhive_fancybox_css', PH()->plugin_url() . '/assets/css/jquery.fancybox.css', array(), '3.5.7' );
103 + }
104 +
56 105 /*if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
57 106 wp_enqueue_style( 'propertyhive_admin_dashboard_styles', PH()->plugin_url() . '/assets/css/dashboard.css', array(), PH_VERSION );
58 107 }*/
59 108
109 + if ( $screen->id === 'plugins' )
110 + {
111 + // Enqueue the CSS file
112 + wp_enqueue_style(
113 + 'propertyhive_deactivate_survey',
114 + PH()->plugin_url() . '/assets/css/deactivate-survey.css',
115 + array(),
116 + '1.0.0'
117 + );
118 + }
119 +
60 120 do_action( 'propertyhive_admin_css' );
61 121 }
62 122
63 123
@@ -64,39 +124,96 @@
64 124 /**
65 125 * Enqueue scripts
66 126 */
67 127 public function admin_scripts() {
68 - global $wp_query, $post;
128 + global $wp_query, $post, $tabs;
69 129
70 130 $screen = get_current_screen();
71 - $ph_screen_id = sanitize_title( __( 'PropertyHive', 'propertyhive' ) );
72 131 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
73 132
74 133 // Register scripts
75 - wp_register_script( 'propertyhive_dashboard', PH()->plugin_url() . '/assets/js/admin/dashboard' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION );
134 + wp_register_script( 'propertyhive_dashboard', PH()->plugin_url() . '/assets/js/admin/dashboard' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
76 135
77 - wp_register_script( 'propertyhive_admin', PH()->plugin_url() . '/assets/js/admin/admin' . /*$suffix .*/ '.js', array( 'jquery', 'jquery-tiptip' ), PH_VERSION );
136 + wp_register_script( 'propertyhive_admin', PH()->plugin_url() . '/assets/js/admin/admin' . /*$suffix .*/ '.js', array( 'jquery', 'jquery-tiptip' ), PH_VERSION, true );
78 137
79 138 wp_register_script( 'jquery-tiptip', PH()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
80 139
81 - wp_register_script( 'propertyhive_admin_meta_boxes', PH()->plugin_url() . '/assets/js/admin/meta-boxes' . /*$suffix .*/ '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable' ), PH_VERSION );
140 + wp_register_script( 'propertyhive_admin_meta_boxes', PH()->plugin_url() . '/assets/js/admin/meta-boxes' . /*$suffix .*/ '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable' ), PH_VERSION, true );
82 141
83 - wp_register_script( 'propertyhive_admin_settings', PH()->plugin_url() . '/assets/js/admin/settings' . /*$suffix .*/ '.js', array( 'jquery', 'wp-color-picker' ), PH_VERSION );
142 + wp_register_script( 'propertyhive_admin_settings', PH()->plugin_url() . '/assets/js/admin/settings' . /*$suffix .*/ '.js', array( 'jquery', 'wp-color-picker' ), PH_VERSION, true );
84 143
85 - wp_register_script( 'ajax-chosen', PH()->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery' . /*$suffix .*/ '.js', array('jquery', 'chosen'), PH_VERSION );
144 + wp_register_script( 'propertyhive_admin_onboarding', PH()->plugin_url() . '/assets/js/admin/onboarding' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
86 145
87 - wp_register_script( 'chosen', PH()->plugin_url() . '/assets/js/chosen/chosen.jquery' . /*$suffix .*/ '.js', array('jquery'), PH_VERSION );
146 + wp_register_script( 'propertyhive_admin_recently_viewed', PH()->plugin_url() . '/assets/js/admin/recently-viewed' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
88 147
89 - wp_register_script( 'multiselect', PH()->plugin_url() . '/assets/js/multiselect/jquery.multiselect' . /*$suffix .*/ '.js', array('jquery'), '2.4.18' );
148 + wp_register_script( 'ajax-chosen', PH()->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery' . /*$suffix .*/ '.js', array('jquery', 'chosen'), PH_VERSION, true );
90 149
91 - wp_register_script( 'flot', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), PH_VERSION );
92 - wp_register_script( 'flot-resize', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION );
93 - wp_register_script( 'flot-time', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION );
150 + wp_register_script( 'chosen', PH()->plugin_url() . '/assets/js/chosen/chosen.jquery' . /*$suffix .*/ '.js', array('jquery'), PH_VERSION, true );
151 +
152 + wp_register_script( 'multiselect', PH()->plugin_url() . '/assets/js/multiselect/jquery.multiselect' . /*$suffix .*/ '.js', array('jquery'), '2.4.18', true );
153 +
154 + wp_register_script( 'flot', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), PH_VERSION, true );
155 + wp_register_script( 'flot-resize', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION, true );
156 + wp_register_script( 'flot-time', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION, true );
94 157 //wp_register_script( 'flot-pie', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION );
95 158 //wp_register_script( 'flot-stack', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION );
96 159
97 160 wp_enqueue_script( 'propertyhive_admin' );
98 161
162 + $params = array();
163 +
164 + // Add a bit better support for Gutenberg if enabled somehow (i.e. using Houzez) to load AJAX grids
165 + if (
166 + isset($post->ID) &&
167 + function_exists( 'use_block_editor_for_post_type' ) &&
168 + use_block_editor_for_post_type( get_post_type($post->ID) ) &&
169 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only classic/block editor selection controls the scripts loaded.
170 + !isset( $_GET['classic-editor'] ) &&
171 + is_array($tabs) &&
172 + !empty($tabs)
173 + )
174 + {
175 + $ajax_actions = array();
176 +
177 + foreach ( $tabs as $key => $tab )
178 + {
179 + if ( isset($tab['ajax_actions']) && !empty($tab['ajax_actions']) )
180 + {
181 + foreach ( $tab['ajax_actions'] as $ajax_action )
182 + {
183 + $ajax_actions[] = $ajax_action;
184 + }
185 + }
186 + }
187 +
188 + if ( !empty($ajax_actions) )
189 + {
190 + $params = array(
191 + 'ajax_actions' => $ajax_actions,
192 + 'post_id' => $post->ID,
193 + );
194 +
195 + }
196 + }
197 +
198 + wp_localize_script( 'propertyhive_admin', 'propertyhive_admin', $params );
199 +
200 + $recently_viewed = get_user_meta( get_current_user_id(), '_propertyhive_recently_viewed', TRUE );
201 + if ( !is_array($recently_viewed) )
202 + {
203 + $recently_viewed = array();
204 + }
205 +
206 + $params = array(
207 + 'recently_viewed' => $recently_viewed,
208 + );
209 + wp_localize_script( 'propertyhive_admin_recently_viewed', 'propertyhive_admin_recently_viewed', $params );
210 +
211 + wp_localize_script( 'multiselect', 'propertyhive_multiselect_params', apply_filters( 'propertyhive_multiselect_params', array(
212 + 'search' => false,
213 + 'selected_text' => __( 'selected', 'propertyhive' ),
214 + ) ) );
215 +
99 216 // PropertyHive admin pages
100 217 if ( in_array( $screen->id, array( 'dashboard' ) ) )
101 218 {
102 219 wp_enqueue_script( 'propertyhive_dashboard' );
@@ -106,31 +223,175 @@
106 223 );
107 224 wp_localize_script( 'propertyhive_dashboard', 'propertyhive_dashboard', $params );
108 225 }
109 226
227 + if ( in_array( $screen->id, array( 'dashboard_page_ph-onboarding' ), true ) )
228 + {
229 + wp_enqueue_script( 'propertyhive_admin_onboarding' );
230 + }
231 +
232 + if ( in_array( $screen->id, array( 'edit-contact', 'edit-enquiry', 'edit-appraisal', 'edit-viewing', 'edit-offer', 'edit-sale', 'edit-key_date' ) ) )
233 + {
234 + wp_enqueue_script( 'moment' );
235 + wp_enqueue_script( 'daterangepicker.js', PH()->plugin_url() . '/assets/js/daterangepicker/daterangepicker.js', array( 'jquery', 'moment' ), '3.1.0', true );
236 + wp_enqueue_script( 'date_range_filter.js', PH()->plugin_url() . '/assets/js/admin/date_range_filter.js', array( 'jquery', 'moment', 'daterangepicker.js' ), PH_VERSION, true );
237 + }
238 +
239 + if ( in_array( $screen->id, array( 'edit-key_date' ) ) )
240 + {
241 + wp_enqueue_script( 'inline-edit-key_date.js', PH()->plugin_url() . '/assets/js/admin/inline-edit-key_date.js', array('jquery'), PH_VERSION, true );
242 + }
243 +
244 + if (
245 + get_option('propertyhive_module_disabled_viewings', '') != 'yes' &&
246 + in_array( $screen->id, array( 'property', 'contact' ) )
247 + )
248 + {
249 + wp_enqueue_script( 'propertyhive_fancybox', PH()->plugin_url() . '/assets/js/fancybox/jquery.fancybox.js', array('jquery'), '3.5.7', true );
250 + }
251 +
252 + if ( in_array( $screen->id, array( 'property' ) ) )
253 + {
254 + if ( ! class_exists( '_WP_Editors', false ) )
255 + {
256 + require( ABSPATH . WPINC . '/class-wp-editor.php' );
257 + }
258 + add_action( 'admin_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) );
259 +
260 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only tour asset selection; no data is changed.
261 + if ( isset( $_GET['tutorial'] ) && is_string( $_GET['tutorial'] ) && sanitize_text_field( wp_unslash( $_GET['tutorial'] ) ) === 'yes' )
262 + {
263 + wp_enqueue_script( 'driver-js', PH()->plugin_url() . '/assets/js/tours/driver-js.js', array(), '1.0.1', true );
264 + wp_register_script( 'tour', PH()->plugin_url() . '/assets/js/tours/tour.js', array( 'driver-js' ), '1.0.1', true );
265 + wp_enqueue_script( 'tour' );
266 +
267 + $tours = [
268 + 'add-property' => [
269 + [
270 + 'element' => '#title',
271 + 'popover' => [
272 + 'title' => __( 'Enter the Property\'s Display Address', 'propertyhive' ),
273 + 'description' => __( 'This is the title or address that will be shown publicly. Make it clear and appealing for your audience.', 'propertyhive' ),
274 + 'side' => 'bottom',
275 + ],
276 + ],
277 + [
278 + 'element' => '#propertyhive_metabox_tabs',
279 + 'popover' => [
280 + 'title' => __( 'Explore the Property Record', 'propertyhive' ),
281 + 'description' => __( 'The property record is organized into sections for easy navigation. Use these tabs to switch between sections.<br><br>Go ahead, try clicking them now.', 'propertyhive' ),
282 + 'side' => 'bottom',
283 + 'onPrevClick' => 'revert_to_first_tab',
284 + 'onNextClick' => 'revert_to_first_tab',
285 + ],
286 + ],
287 + [
288 + 'element' => '#propertyhive-property-address',
289 + 'popover' => [
290 + 'title' => __( 'Enter the Property Details', 'propertyhive' ),
291 + 'description' => __( 'Use these fields to input essential property information like address, price, bedrooms, and more. You can also upload images to showcase the property.', 'propertyhive' ),
292 + 'side' => 'top',
293 + 'onNextClick' => 'revert_to_third_tab',
294 + ],
295 + ],
296 + [
297 + 'element' => '#\\_on_market',
298 + 'popover' => [
299 + 'title' => __( 'Put it on the Market', 'propertyhive' ),
300 + 'description' => __( 'For a property to show on your website it will need to be set to \'On Market\' under the \'Marketing\' tab.', 'propertyhive' ),
301 + 'side' => 'top',
302 + 'onPrevClick' => 'revert_to_first_tab',
303 + 'onNextClick' => 'revert_to_first_tab',
304 + ],
305 + ],
306 + [
307 + 'element' => '#submitdiv',
308 + 'popover' => [
309 + 'title' => __( 'Publish your Property', 'propertyhive' ),
310 + 'description' => __( 'When you\'re done and are ready to save your changes, simply click \'Publish\'', 'propertyhive' ),
311 + 'side' => 'left',
312 + 'onPrevClick' => 'revert_to_third_tab',
313 + ],
314 + ],
315 + ],
316 + ];
317 + wp_localize_script(
318 + 'tour',
319 + 'tour_plugin',
320 + array(
321 + 'tours' => $tours,
322 + )
323 + );
324 + }
325 + }
326 +
110 327 if ( in_array( $screen->id, ph_get_screen_ids() ) )
111 328 {
112 329 wp_enqueue_script( 'ajax-chosen' );
113 330 wp_enqueue_script( 'chosen' );
114 331 wp_enqueue_script( 'jquery-ui-sortable' );
332 + wp_enqueue_script( 'wp-tinymce' );
115 333
116 - $api_key = get_option('propertyhive_google_maps_api_key');
117 - wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3');
118 - wp_enqueue_script('googlemaps');
334 + if ( get_option('propertyhive_maps_provider') == 'mapbox' )
335 + {
336 + wp_register_script('mapbox', PH()->plugin_url() . '/assets/js/mapbox/mapbox-gl.js', false, '3.8.0', true );
337 + wp_enqueue_script('mapbox');
119 338
339 + if ( get_option('propertyhive_geocoding_provider') == '' )
340 + {
341 + $api_key = get_option('propertyhive_google_maps_geocoding_api_key');
342 + wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3', true );
343 + wp_enqueue_script('googlemaps');
344 + }
345 + }
346 + elseif ( get_option('propertyhive_maps_provider') == 'osm' )
347 + {
348 + wp_register_style('leaflet', PH()->plugin_url() . '/assets/js/leaflet/leaflet.css', array(), '1.9.4');
349 + wp_enqueue_style('leaflet');
350 +
351 + wp_register_script('leaflet', PH()->plugin_url() . '/assets/js/leaflet/leaflet.js', array(), '1.9.4', false);
352 + wp_enqueue_script('leaflet');
353 +
354 + if ( get_option('propertyhive_geocoding_provider') == '' )
355 + {
356 + $api_key = get_option('propertyhive_google_maps_geocoding_api_key');
357 + wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3', true );
358 + wp_enqueue_script('googlemaps');
359 + }
360 + }
361 + else
362 + {
363 + $api_key = get_option('propertyhive_google_maps_api_key');
364 + wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3', true );
365 + wp_enqueue_script('googlemaps');
366 + }
367 +
120 368 wp_enqueue_media();
121 369 wp_enqueue_script( 'propertyhive_admin_meta_boxes' );
370 + wp_enqueue_script( 'propertyhive_admin_recently_viewed' );
122 371 wp_enqueue_script( 'jquery-ui-datepicker' );
123 372 wp_enqueue_script( 'jquery-ui-autocomplete' );
124 373 wp_enqueue_script( 'ajax-chosen' );
125 374 wp_enqueue_script( 'chosen' );
126 -
375 +
127 376 $params = array(
128 377 'plugin_url' => PH()->plugin_url(),
129 378 'ajax_url' => admin_url('admin-ajax.php'),
130 379 'post_id' => isset( $post->ID ) ? $post->ID : '',
380 + 'get_notes_nonce' => wp_create_nonce("get-notes"),
381 + 'pin_note_nonce' => wp_create_nonce("pin-note"),
131 382 'add_note_nonce' => wp_create_nonce("add-note"),
132 383 'delete_note_nonce' => wp_create_nonce("delete-note"),
384 + 'add_key_date_nonce' => wp_create_nonce( 'propertyhive-add-key-date' ),
385 + 'export_sub_grid_nonce' => wp_create_nonce( 'propertyhive-export-sub-grid' ),
386 + 'viewing_details_meta_nonce' => wp_create_nonce( 'viewing-details-meta-box' ),
387 + 'viewing_actions_nonce' => wp_create_nonce( 'viewing-actions' ),
388 + 'save_key_date_nonce' => wp_create_nonce( 'save-key-date' ),
389 + 'delete_key_date_nonce' => wp_create_nonce( 'delete-key-date' ),
390 + 'check_duplicate_reference_number_nonce' => wp_create_nonce("check-duplicate-reference-number"),
391 + 'enable_description_editor' => apply_filters('propertyhive_enable_description_editor', false),
392 + 'leasehold_tenures' => apply_filters('propertyhive_leasehold_tenure_names', array( 'leasehold', 'share of freehold' ) ),
393 + 'disable_notes_mention' => apply_filters('propertyhive_disable_notes_mention', false),
133 394 );
134 395 wp_localize_script( 'propertyhive_admin_meta_boxes', 'propertyhive_admin_meta_boxes', $params );
135 396
136 397 if ( is_rtl() )
@@ -137,8 +398,13 @@
137 398 {
138 399 wp_enqueue_script( 'chosen-rtl', PH()->plugin_url() . '/assets/js/chosen/chosen-rtl' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
139 400 }
140 401 }
402 +
403 + if ( in_array( $screen->id, array('profile', 'user', 'user-edit') ) )
404 + {
405 + wp_enqueue_media();
406 + }
141 407
142 408 if ( strpos($screen->id, 'page_ph-settings') !== FALSE )
143 409 {
144 410 wp_enqueue_script( 'propertyhive_admin_settings' );
@@ -149,10 +415,22 @@
149 415 'primary_department_not_active_warning' => __( 'The chosen primary department has not been selected as active', 'propertyhive' ),
150 416 'no_countries_selected' => __( 'Please select which countries you operate in', 'propertyhive' ),
151 417 'default_country_not_in_selected' => __( 'The default country hasn\'t been selected as a country you operate in', 'propertyhive' ),
152 418 'admin_url' => admin_url(),
153 - 'taxonomy_section' => ( ( isset($_GET['section']) ) ? sanitize_text_field($_GET['section']) : '' ),
419 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only settings section passed through WordPress script localization.
420 + 'taxonomy_section' => isset( $_GET['section'] ) && is_string( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '',
421 + 'ajax_nonce' => wp_create_nonce("updates"),
422 + 'features_settings_url' => admin_url('admin.php?page=ph-settings&tab=features'),
154 423 );
424 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Settings tab determines whether the existing license status is refreshed.
425 + if ( isset( $_GET['tab'] ) && is_string( $_GET['tab'] ) && sanitize_text_field( wp_unslash( $_GET['tab'] ) ) === 'licensekey' )
426 + {
427 + $params['valid_pro_license_key'] = PH()->license->is_valid_pro_license_key(true);
428 + }
429 + else
430 + {
431 + $params['valid_pro_license_key'] = PH()->license->is_valid_pro_license_key();
432 + }
155 433 wp_localize_script( 'propertyhive_admin_settings', 'propertyhive_admin_settings', $params );
156 434 }
157 435
158 436 // Reports Pages
@@ -166,8 +444,45 @@
166 444 wp_enqueue_script( 'flot-time' );
167 445 //wp_enqueue_script( 'flot-pie' );
168 446 //wp_enqueue_script( 'flot-stack' );
169 447 }
448 +
449 + if ( $screen->id === 'plugins' )
450 + {
451 + // Enqueue the JavaScript file
452 + wp_enqueue_script(
453 + 'propertyhive_deactivate_survey',
454 + PH()->plugin_url() . '/assets/js/deactivate-survey.js',
455 + array('jquery'), // Depend on jQuery
456 + '1.0.0',
457 + true // Load in footer
458 + );
459 +
460 + wp_localize_script('propertyhive_deactivate_survey', 'deactivation_survey', array(
461 + 'nonce' => wp_create_nonce('deactivate-survey'),
462 +
463 + 'modalTitle' => __('If you have a moment, please let us know why you are deactivating:', 'propertyhive'),
464 + 'modalHeader' => __('Quick Feedback', 'propertyhive'),
465 + 'skipDeactivate' => __('Skip & Deactivate', 'propertyhive'),
466 + 'cancel' => __('Cancel', 'propertyhive'),
467 + 'deactivate' => __('Submit & Deactivate', 'propertyhive'),
468 +
469 + 'brokeSite' => __('The plugin broke my site', 'propertyhive'),
470 + 'confusing' => __('The plugin is confusing', 'propertyhive'),
471 + 'inadequateSupport' => __('The support/documentation is inadequate', 'propertyhive'),
472 + 'poorPerformance' => __('The plugin is too slow/affects performance', 'propertyhive'),
473 + 'notNeeded' => __('I no longer need the plugin', 'propertyhive'),
474 + 'betterPlugin' => __('I found a better plugin', 'propertyhive'),
475 + 'temporary' => __('It\'s a temporary deactivation', 'propertyhive'),
476 + 'other' => __('Other', 'propertyhive'),
477 +
478 + 'brokeSiteLabel' => __('Oh no! Can you tell us more? (optional)', 'propertyhive'),
479 + 'betterPluginLabel' => __('What\'s the plugin\'s name? (optional)', 'propertyhive'),
480 + 'otherLabel' => __('Additional feedback or comments: (optional)', 'propertyhive'),
481 +
482 + 'anonymous' => __('Anonymous feedback', 'propertyhive'),
483 + ));
484 + }
170 485 }
171 486
172 487 }
173 488
@@ -172,5 +487,5 @@
172 487 }
173 488
174 489 endif;
175 490
176 -return new PH_Admin_Assets();
491 +return new PH_Admin_Assets();