PluginProbe
Property Hive / 1.4.49
Property Hive v1.4.49
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.49, at includes/admin/class-ph-admin-assets.php

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