PluginProbe
Property Hive / 1.4.62
Property Hive v1.4.62
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 1.4.61 All 261 releases
propertyhive / includes / admin / class-ph-admin-assets.php

class-ph-admin-assets.php in Property Hive 1.4.62, at includes/admin/class-ph-admin-assets.php

176 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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
56 /*if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
57 wp_enqueue_style( 'propertyhive_admin_dashboard_styles', PH()->plugin_url() . '/assets/css/dashboard.css', array(), PH_VERSION );
58 }*/
59
60 do_action( 'propertyhive_admin_css' );
61 }
62
63
64 /**
65 * Enqueue scripts
66 */
67 public function admin_scripts() {
68 global $wp_query, $post;
69
70 $screen = get_current_screen();
71 $ph_screen_id = sanitize_title( __( 'PropertyHive', 'propertyhive' ) );
72 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
73
74 // Register scripts
75 wp_register_script( 'propertyhive_dashboard', PH()->plugin_url() . '/assets/js/admin/dashboard' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION );
76
77 wp_register_script( 'propertyhive_admin', PH()->plugin_url() . '/assets/js/admin/admin' . /*$suffix .*/ '.js', array( 'jquery', 'jquery-tiptip' ), PH_VERSION );
78
79 wp_register_script( 'jquery-tiptip', PH()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
80
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 );
82
83 wp_register_script( 'propertyhive_admin_settings', PH()->plugin_url() . '/assets/js/admin/settings' . /*$suffix .*/ '.js', array( 'jquery', 'wp-color-picker' ), PH_VERSION );
84
85 wp_register_script( 'ajax-chosen', PH()->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery' . /*$suffix .*/ '.js', array('jquery', 'chosen'), PH_VERSION );
86
87 wp_register_script( 'chosen', PH()->plugin_url() . '/assets/js/chosen/chosen.jquery' . /*$suffix .*/ '.js', array('jquery'), PH_VERSION );
88
89 wp_register_script( 'multiselect', PH()->plugin_url() . '/assets/js/multiselect/jquery.multiselect' . /*$suffix .*/ '.js', array('jquery'), '2.4.18' );
90
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 );
94 //wp_register_script( 'flot-pie', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION );
95 //wp_register_script( 'flot-stack', PH()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), PH_VERSION );
96
97 wp_enqueue_script( 'propertyhive_admin' );
98
99 // PropertyHive admin pages
100 if ( in_array( $screen->id, array( 'dashboard' ) ) )
101 {
102 wp_enqueue_script( 'propertyhive_dashboard' );
103
104 $params = array(
105 'ajax_url' => admin_url('admin-ajax.php'),
106 );
107 wp_localize_script( 'propertyhive_dashboard', 'propertyhive_dashboard', $params );
108 }
109
110 if ( in_array( $screen->id, ph_get_screen_ids() ) )
111 {
112 wp_enqueue_script( 'ajax-chosen' );
113 wp_enqueue_script( 'chosen' );
114 wp_enqueue_script( 'jquery-ui-sortable' );
115
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');
119
120 wp_enqueue_media();
121 wp_enqueue_script( 'propertyhive_admin_meta_boxes' );
122 wp_enqueue_script( 'jquery-ui-datepicker' );
123 wp_enqueue_script( 'jquery-ui-autocomplete' );
124 wp_enqueue_script( 'ajax-chosen' );
125 wp_enqueue_script( 'chosen' );
126
127 $params = array(
128 'plugin_url' => PH()->plugin_url(),
129 'ajax_url' => admin_url('admin-ajax.php'),
130 'post_id' => isset( $post->ID ) ? $post->ID : '',
131 'add_note_nonce' => wp_create_nonce("add-note"),
132 'delete_note_nonce' => wp_create_nonce("delete-note"),
133 );
134 wp_localize_script( 'propertyhive_admin_meta_boxes', 'propertyhive_admin_meta_boxes', $params );
135
136 if ( is_rtl() )
137 {
138 wp_enqueue_script( 'chosen-rtl', PH()->plugin_url() . '/assets/js/chosen/chosen-rtl' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
139 }
140 }
141
142 if ( strpos($screen->id, 'page_ph-settings') !== FALSE )
143 {
144 wp_enqueue_script( 'propertyhive_admin_settings' );
145
146 $params = array(
147 'confirm_not_selected_warning' => __( 'Please check the box to confirm that you are happy to remove this term', 'propertyhive' ),
148 'no_departments_selected_warning' => __( 'Please select at least one active department', 'propertyhive' ),
149 'primary_department_not_active_warning' => __( 'The chosen primary department has not been selected as active', 'propertyhive' ),
150 'no_countries_selected' => __( 'Please select which countries you operate in', 'propertyhive' ),
151 'default_country_not_in_selected' => __( 'The default country hasn\'t been selected as a country you operate in', 'propertyhive' ),
152 'admin_url' => admin_url(),
153 'taxonomy_section' => ( ( isset($_GET['section']) ) ? sanitize_text_field($_GET['section']) : '' ),
154 );
155 wp_localize_script( 'propertyhive_admin_settings', 'propertyhive_admin_settings', $params );
156 }
157
158 // Reports Pages
159 if ( strpos($screen->id, 'page_ph-reports') !== FALSE || in_array( $screen->id, array( 'property' ) ) )
160 {
161 //wp_register_script( 'ph-reports', PH()->plugin_url() . '/assets/js/admin/reports' . /*$suffix .*/ '.js', array( 'jquery', 'jquery-ui-datepicker' ), PH_VERSION );
162
163 //wp_enqueue_script( 'ph-reports' );
164 wp_enqueue_script( 'flot' );
165 wp_enqueue_script( 'flot-resize' );
166 wp_enqueue_script( 'flot-time' );
167 //wp_enqueue_script( 'flot-pie' );
168 //wp_enqueue_script( 'flot-stack' );
169 }
170 }
171
172 }
173
174 endif;
175
176 return new PH_Admin_Assets();