PluginProbe
Property Hive / 1.4.46
Property Hive v1.4.46
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.46, at includes/admin/class-ph-admin-assets.php

178 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
52 if ( in_array( $screen->id, array( 'property', 'contact', 'appraisal', 'viewing', 'admin_page_ph-generate-applicant-list' ) ) )
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 wp_enqueue_script( 'propertyhive_admin' );
97
98 // PropertyHive admin pages
99 if ( in_array( $screen->id, array( 'dashboard' ) ) )
100 {
101 wp_enqueue_script( 'propertyhive_dashboard' );
102
103 $params = array(
104 'ajax_url' => admin_url('admin-ajax.php'),
105 );
106 wp_localize_script( 'propertyhive_dashboard', 'propertyhive_dashboard', $params );
107 }
108
109 if ( in_array( $screen->id, ph_get_screen_ids() ) )
110 {
111 wp_enqueue_script( 'ajax-chosen' );
112 wp_enqueue_script( 'chosen' );
113 wp_enqueue_script( 'jquery-ui-sortable' );
114
115 $api_key = get_option('propertyhive_google_maps_api_key');
116 wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3');
117 wp_enqueue_script('googlemaps');
118 }
119
120 if ( in_array( $screen->id, ph_get_screen_ids() ) )
121 {
122 wp_enqueue_media();
123 wp_enqueue_script( 'propertyhive_admin_meta_boxes' );
124 wp_enqueue_script( 'jquery-ui-datepicker' );
125 wp_enqueue_script( 'jquery-ui-autocomplete' );
126 wp_enqueue_script( 'ajax-chosen' );
127 wp_enqueue_script( 'chosen' );
128
129 $params = array(
130 'plugin_url' => PH()->plugin_url(),
131 'ajax_url' => admin_url('admin-ajax.php'),
132 'post_id' => isset( $post->ID ) ? $post->ID : '',
133 'add_note_nonce' => wp_create_nonce("add-note"),
134 'delete_note_nonce' => wp_create_nonce("delete-note"),
135 );
136 wp_localize_script( 'propertyhive_admin_meta_boxes', 'propertyhive_admin_meta_boxes', $params );
137
138 if ( is_rtl() )
139 {
140 wp_enqueue_script( 'chosen-rtl', PH()->plugin_url() . '/assets/js/chosen/chosen-rtl' . /*$suffix .*/ '.js', array( 'jquery' ), PH_VERSION, true );
141 }
142 }
143
144 if ( strpos($screen->id, 'page_ph-settings') !== FALSE )
145 {
146 wp_enqueue_script( 'propertyhive_admin_settings' );
147
148 $params = array(
149 'confirm_not_selected_warning' => __( 'Please check the box to confirm that you are happy to remove this term', 'propertyhive' ),
150 'no_departments_selected_warning' => __( 'Please select at least one active department', 'propertyhive' ),
151 'primary_department_not_active_warning' => __( 'The chosen primary department has not been selected as active', 'propertyhive' ),
152 'no_countries_selected' => __( 'Please select which countries you operate in', 'propertyhive' ),
153 'default_country_not_in_selected' => __( 'The default country hasn\'t been selected as a country you operate in', 'propertyhive' ),
154 'admin_url' => admin_url(),
155 'taxonomy_section' => ( ( isset($_GET['section']) ) ? sanitize_text_field($_GET['section']) : '' ),
156 );
157 wp_localize_script( 'propertyhive_admin_settings', 'propertyhive_admin_settings', $params );
158 }
159
160 // Reports Pages
161 if ( strpos($screen->id, 'page_ph-reports') !== FALSE )
162 {
163 //wp_register_script( 'ph-reports', PH()->plugin_url() . '/assets/js/admin/reports' . /*$suffix .*/ '.js', array( 'jquery', 'jquery-ui-datepicker' ), PH_VERSION );
164
165 //wp_enqueue_script( 'ph-reports' );
166 wp_enqueue_script( 'flot' );
167 wp_enqueue_script( 'flot-resize' );
168 //wp_enqueue_script( 'flot-time' );
169 //wp_enqueue_script( 'flot-pie' );
170 //wp_enqueue_script( 'flot-stack' );
171 }
172 }
173
174 }
175
176 endif;
177
178 return new PH_Admin_Assets();