/** * Include admin files conditionally */ public function disable_propertyhive_meta_box_dragging() { $screen = get_current_screen(); if (in_array($screen->id, ph_get_screen_ids())) { //wp_deregister_script('postbox'); } }
/** * Enqueue scripts */ public function admin_scripts() { global $wp_query, $post; $screen = get_current_screen(); $ph_screen_id = sanitize_title(__('PropertyHive', 'propertyhive')); $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; // Register scripts wp_register_script('propertyhive_dashboard', PH()->plugin_url() . '/assets/js/admin/dashboard' . '.js', array('jquery'), PH_VERSION); wp_register_script('propertyhive_admin', PH()->plugin_url() . '/assets/js/admin/admin' . '.js', array('jquery', 'jquery-tiptip'), PH_VERSION); wp_register_script('jquery-tiptip', PH()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . '.js', array('jquery'), PH_VERSION, true); wp_register_script('propertyhive_admin_meta_boxes', PH()->plugin_url() . '/assets/js/admin/meta-boxes' . '.js', array('jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable'), PH_VERSION); wp_register_script('propertyhive_admin_settings', PH()->plugin_url() . '/assets/js/admin/settings' . '.js', array('jquery', 'wp-color-picker'), PH_VERSION); wp_register_script('ajax-chosen', PH()->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery' . '.js', array('jquery', 'chosen'), PH_VERSION); wp_register_script('chosen', PH()->plugin_url() . '/assets/js/chosen/chosen.jquery' . '.js', array('jquery'), PH_VERSION); // PropertyHive admin pages if (in_array($screen->id, array('dashboard'))) { wp_enqueue_script('propertyhive_dashboard'); $params = array('ajax_url' => admin_url('admin-ajax.php')); wp_localize_script('propertyhive_dashboard', 'propertyhive_dashboard', $params); } if (in_array($screen->id, ph_get_screen_ids())) { wp_enqueue_script('propertyhive_admin'); wp_enqueue_script('ajax-chosen'); wp_enqueue_script('chosen'); wp_enqueue_script('jquery-ui-sortable'); $api_key = get_option('propertyhive_google_maps_api_key'); wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ($api_key != '' && $api_key !== FALSE ? 'key=' . $api_key : ''), false, '3'); wp_enqueue_script('googlemaps'); } if (in_array($screen->id, array('property', 'contact', 'enquiry'))) { wp_enqueue_media(); wp_enqueue_script('propertyhive_admin_meta_boxes'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script('jquery-ui-autocomplete'); wp_enqueue_script('ajax-chosen'); wp_enqueue_script('chosen'); $params = array('plugin_url' => PH()->plugin_url(), 'ajax_url' => admin_url('admin-ajax.php'), 'post_id' => isset($post->ID) ? $post->ID : '', 'add_note_nonce' => wp_create_nonce("add-note"), 'delete_note_nonce' => wp_create_nonce("delete-note")); wp_localize_script('propertyhive_admin_meta_boxes', 'propertyhive_admin_meta_boxes', $params); if (is_rtl()) { wp_enqueue_script('chosen-rtl', PH()->plugin_url() . '/assets/js/chosen/chosen-rtl' . '.js', array('jquery'), PH_VERSION, true); } } if (in_array($screen->id, array('property-hive_page_ph-settings'))) { wp_enqueue_script('propertyhive_admin_settings'); $params = array('confirm_not_selected_warning' => __('Please check the box to confirm that you are happy to remove this term', 'propertyhive'), 'no_departments_selected_warning' => __('Please select at least one active department', 'propertyhive'), 'primary_department_not_active_warning' => __('The chosen primary department has not been selected as active', 'propertyhive'), 'no_countries_selected' => __('Please select which countries you operate in', 'propertyhive'), 'default_country_not_in_selected' => __('The default country hasn\'t been selected as a country you operate in', 'propertyhive'), 'admin_url' => admin_url(), 'taxonomy_section' => isset($_GET['section']) ? $_GET['section'] : ''); wp_localize_script('propertyhive_admin_settings', 'propertyhive_admin_settings', $params); } }