PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.20
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.20
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
userswp / admin / class-admin.php

class-admin.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.0.20, at admin/class-admin.php

235 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link http://wpgeodirectory.com
6 * @since 1.0.0
7 *
8 * @package userswp
9 * @subpackage userswp/admin
10 */
11
12 /**
13 * The admin-specific functionality of the plugin.
14 *
15 * Defines the plugin name, version, and two examples hooks for how to
16 * enqueue the admin-specific stylesheet and JavaScript.
17 *
18 * @package userswp
19 * @subpackage userswp/admin
20 * @author GeoDirectory Team <info@wpgeodirectory.com>
21 */
22 class UsersWP_Admin {
23
24 protected $admin_settings;
25 /**
26 * Register all of the hooks related to the admin area functionality
27 * of the plugin.
28 *
29 * @since 1.0.0
30 */
31 public function __construct($admin_settings) {
32
33 $this->admin_settings = $admin_settings;
34 }
35
36
37 /**
38 * Register the stylesheets for the admin area.
39 *
40 * @since 1.0.0
41 * @param $hook_suffix
42 */
43 public function enqueue_styles($hook_suffix) {
44
45 /**
46 * An instance of this class should be passed to the run() function
47 * defined in UsersWP_Loader as all of the hooks are defined
48 * in that particular class.
49 *
50 * The UsersWP_Loader will then create the relationship
51 * between the defined hooks and the functions defined in this
52 * class.
53 */
54 if ($hook_suffix == 'profile.php' || $hook_suffix == 'user-edit.php') {
55 wp_register_style('jquery-ui', plugin_dir_url(dirname(__FILE__)) . 'public/assets/css/jquery-ui.css');
56 wp_enqueue_style( 'jquery-ui' );
57 wp_enqueue_style( 'jcrop' );
58 wp_enqueue_style( "userswp", plugin_dir_url(dirname(__FILE__)) . 'public/assets/css/users-wp.css', array(), null, 'all' );
59 wp_enqueue_style( "uwp_timepicker_css", plugin_dir_url( dirname(__FILE__) ) . 'public/assets/css/jquery.ui.timepicker.css', array(), null, 'all' );
60 }
61 if ($hook_suffix == 'userswp_page_uwp_tools') {
62 wp_enqueue_style( "userswp", plugin_dir_url(dirname(__FILE__)) . 'public/assets/css/users-wp.css', array(), null, 'all' );
63 }
64 wp_enqueue_style( "userswp_admin_css", plugin_dir_url( __FILE__ ) . 'assets/css/users-wp-admin.css', array(), USERSWP_VERSION, 'all' );
65 wp_enqueue_style( "uwp_chosen_css", plugin_dir_url(dirname(__FILE__)) . 'public/assets/css/chosen.css', array(), USERSWP_VERSION, 'all' );
66 uwp_load_font_awesome();
67
68 }
69
70 /**
71 * Register the JavaScript for the admin area.
72 *
73 * @since 1.0.0
74 * @param $hook_suffix
75 */
76 public function enqueue_scripts($hook_suffix) {
77
78 /**
79 * An instance of this class should be passed to the run() function
80 * defined in UsersWP_Loader as all of the hooks are defined
81 * in that particular class.
82 *
83 * The UsersWP_Loader will then create the relationship
84 * between the defined hooks and the functions defined in this
85 * class.
86 */
87
88 if ($hook_suffix == 'profile.php' || $hook_suffix == 'user-edit.php') {
89
90 wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );
91 wp_enqueue_script( "uwp_timepicker", plugin_dir_url( dirname(__FILE__) ) . 'public/assets/js/jquery.ui.timepicker.min.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-core' ), null, false );
92 wp_enqueue_script( "userswp", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/users-wp.min.js', array( 'jquery' ), null, false );
93 wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) );
94 wp_enqueue_script( 'jcrop', array( 'jquery' ) );
95 wp_enqueue_script( "country-select", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/countrySelect.min.js', array( 'jquery' ), null, false );
96
97
98 }
99 if ($hook_suffix == 'userswp_page_uwp_tools') {
100 wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) );
101 }
102 wp_enqueue_script('jquery-ui-sortable');
103 wp_enqueue_script( "userswp_admin", plugin_dir_url( __FILE__ ) . 'assets/js/users-wp-admin.min.js', array( 'jquery' ), null, false );
104 wp_enqueue_script( "uwp_chosen", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/chosen.jquery.js', array( 'jquery' ), USERSWP_VERSION, false );
105 wp_enqueue_script( "uwp_chosen_order", plugin_dir_url( __FILE__ ) . 'assets/js/chosen.order.jquery.min.js', array( 'jquery' ), USERSWP_VERSION, false );
106
107 if ($hook_suffix == 'userswp_page_uwp_status') {
108 wp_enqueue_script( "uwp_status", USERSWP_PLUGIN_URL . '/admin/assets/js/system-status.js', array( 'jquery' ), USERSWP_VERSION, true );
109 }
110
111 $ajax_cons_data = array(
112 'url' => admin_url('admin-ajax.php'),
113 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'userswp'),
114 'custom_field_options_not_blank_var' => __('Option Values must not be blank', 'userswp'),
115 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'userswp'),
116 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'userswp'),
117 'custom_field_delete' => __('Are you sure you wish to delete this field?', 'userswp'),
118 'custom_field_id_required' => __('This field is required.', 'userswp'),
119 );
120 wp_localize_script("userswp_admin", 'uwp_admin_ajax', $ajax_cons_data);
121
122 $country_data = uwp_get_country_data();
123 wp_localize_script(USERSWP_NAME, 'uwp_country_data', $country_data);
124
125 }
126
127 public function setup_admin_menus() {
128
129 $install_type = uwp_get_installation_type();
130
131 // Proceed if main site or pages on all sites or specific blog id
132 $proceed = false;
133 $show_builder = false;
134 switch ($install_type) {
135 case "single":
136 $proceed = true;
137 $show_builder = true;
138 break;
139 case "multi_na_all":
140 $proceed = true;
141 $show_builder = true;
142 break;
143 case "multi_na_site_id":
144 if (defined('UWP_ROOT_PAGES')) {
145 $blog_id = UWP_ROOT_PAGES;
146 } else {
147 $blog_id = null;
148 }
149 $current_blog_id = get_current_blog_id();
150 if (!is_int($blog_id)) {
151 $proceed = false;
152 } else {
153 if ($blog_id == $current_blog_id) {
154 $proceed = true;
155 $show_builder = true;
156 } else {
157 $proceed = false;
158 }
159 }
160 break;
161 case "multi_na_default":
162 $is_main_site = is_main_site();
163 if ($is_main_site) {
164 $proceed = true;
165 $show_builder = true;
166 }
167 break;
168 case "multi_not_na":
169 $proceed = true;
170 $show_builder = true;
171 break;
172 default:
173 $proceed = false;
174
175 }
176
177 if (!$proceed) {
178 return;
179 }
180
181
182 add_menu_page(
183 __( 'UsersWP Settings', 'userswp' ),
184 __( 'UsersWP', 'userswp' ),
185 'manage_options',
186 'userswp',
187 array( $this->admin_settings, 'uwp_settings_page' ),
188 'dashicons-groups',
189 70
190 );
191
192 if ($show_builder) {
193 add_submenu_page(
194 "userswp",
195 __( 'Form Builder', 'userswp' ),
196 __( 'Form Builder', 'userswp' ),
197 'manage_options',
198 'uwp_form_builder',
199 array($this->admin_settings, 'uwp_settings_page')
200 );
201
202 add_submenu_page(
203 "userswp",
204 __( 'Notifications', 'userswp' ),
205 __( 'Notifications', 'userswp' ),
206 'manage_options',
207 'uwp_notifications',
208 array($this->admin_settings, 'uwp_settings_page')
209 );
210
211 $settings_page = array($this->admin_settings, 'uwp_settings_page');
212 do_action('uwp_admin_sub_menus', $settings_page, $this->admin_settings);
213 }
214 }
215
216 /**
217 * Adds UsersWP css to admin area
218 *
219 * @since 1.0.0
220 * @package userswp
221 *
222 * @return void
223 */
224 function uwp_admin_only_css() {
225 ?>
226 <style type="text/css">
227 .uwp_page .uwp-bs-modal input[type="submit"].button,
228 .uwp_page .uwp-bs-modal button.button {
229 padding: 0 10px 1px;
230 }
231 </style>
232 <?php
233 }
234
235 }