PluginProbe
Property Hive / 1.4.6
Property Hive v1.4.6
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.6, at includes/admin/class-ph-admin-assets.php

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