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