PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.21
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.21
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 1.0.22 All 173 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.21, at admin/class-admin.php

236 lines 8.7 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
67 }
68
69 /**
70 * Register the JavaScript for the admin area.
71 *
72 * @since 1.0.0
73 * @param $hook_suffix
74 */
75 public function enqueue_scripts($hook_suffix) {
76
77 /**
78 * An instance of this class should be passed to the run() function
79 * defined in UsersWP_Loader as all of the hooks are defined
80 * in that particular class.
81 *
82 * The UsersWP_Loader will then create the relationship
83 * between the defined hooks and the functions defined in this
84 * class.
85 */
86
87 if ($hook_suffix == 'profile.php' || $hook_suffix == 'user-edit.php') {
88
89 wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );
90 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 );
91 wp_enqueue_script( "userswp", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/users-wp.min.js', array( 'jquery' ), null, false );
92 $uwp_localize_data = uwp_get_localize_data();
93 wp_localize_script('userswp', 'uwp_localize_data', $uwp_localize_data);
94 wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) );
95 wp_enqueue_script( 'jcrop', array( 'jquery' ) );
96 wp_enqueue_script( "country-select", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/countrySelect.min.js', array( 'jquery' ), null, false );
97
98
99 }
100 if ($hook_suffix == 'userswp_page_uwp_tools') {
101 wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) );
102 }
103 wp_enqueue_script('jquery-ui-sortable');
104 wp_enqueue_script( "userswp_admin", plugin_dir_url( __FILE__ ) . 'assets/js/users-wp-admin.min.js', array( 'jquery' ), null, false );
105 wp_enqueue_script( "uwp_chosen", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/chosen.jquery.js', array( 'jquery' ), USERSWP_VERSION, false );
106 wp_enqueue_script( "uwp_chosen_order", plugin_dir_url( __FILE__ ) . 'assets/js/chosen.order.jquery.min.js', array( 'jquery' ), USERSWP_VERSION, false );
107
108 if ($hook_suffix == 'userswp_page_uwp_status') {
109 wp_enqueue_script( "uwp_status", USERSWP_PLUGIN_URL . '/admin/assets/js/system-status.js', array( 'jquery' ), USERSWP_VERSION, true );
110 }
111
112 $ajax_cons_data = array(
113 'url' => admin_url('admin-ajax.php'),
114 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'userswp'),
115 'custom_field_options_not_blank_var' => __('Option Values must not be blank', 'userswp'),
116 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'userswp'),
117 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'userswp'),
118 'custom_field_delete' => __('Are you sure you wish to delete this field?', 'userswp'),
119 'custom_field_id_required' => __('This field is required.', 'userswp'),
120 );
121 wp_localize_script("userswp_admin", 'uwp_admin_ajax', $ajax_cons_data);
122
123 $country_data = uwp_get_country_data();
124 wp_localize_script(USERSWP_NAME, 'uwp_country_data', $country_data);
125
126 }
127
128 public function setup_admin_menus() {
129
130 $install_type = uwp_get_installation_type();
131
132 // Proceed if main site or pages on all sites or specific blog id
133 $proceed = false;
134 $show_builder = false;
135 switch ($install_type) {
136 case "single":
137 $proceed = true;
138 $show_builder = true;
139 break;
140 case "multi_na_all":
141 $proceed = true;
142 $show_builder = true;
143 break;
144 case "multi_na_site_id":
145 if (defined('UWP_ROOT_PAGES')) {
146 $blog_id = UWP_ROOT_PAGES;
147 } else {
148 $blog_id = null;
149 }
150 $current_blog_id = get_current_blog_id();
151 if (!is_int($blog_id)) {
152 $proceed = false;
153 } else {
154 if ($blog_id == $current_blog_id) {
155 $proceed = true;
156 $show_builder = true;
157 } else {
158 $proceed = false;
159 }
160 }
161 break;
162 case "multi_na_default":
163 $is_main_site = is_main_site();
164 if ($is_main_site) {
165 $proceed = true;
166 $show_builder = true;
167 }
168 break;
169 case "multi_not_na":
170 $proceed = true;
171 $show_builder = true;
172 break;
173 default:
174 $proceed = false;
175
176 }
177
178 if (!$proceed) {
179 return;
180 }
181
182
183 add_menu_page(
184 __( 'UsersWP Settings', 'userswp' ),
185 __( 'UsersWP', 'userswp' ),
186 'manage_options',
187 'userswp',
188 array( $this->admin_settings, 'uwp_settings_page' ),
189 'dashicons-groups',
190 70
191 );
192
193 if ($show_builder) {
194 add_submenu_page(
195 "userswp",
196 __( 'Form Builder', 'userswp' ),
197 __( 'Form Builder', 'userswp' ),
198 'manage_options',
199 'uwp_form_builder',
200 array($this->admin_settings, 'uwp_settings_page')
201 );
202
203 add_submenu_page(
204 "userswp",
205 __( 'Notifications', 'userswp' ),
206 __( 'Notifications', 'userswp' ),
207 'manage_options',
208 'uwp_notifications',
209 array($this->admin_settings, 'uwp_settings_page')
210 );
211
212 $settings_page = array($this->admin_settings, 'uwp_settings_page');
213 do_action('uwp_admin_sub_menus', $settings_page, $this->admin_settings);
214 }
215 }
216
217 /**
218 * Adds UsersWP css to admin area
219 *
220 * @since 1.0.0
221 * @package userswp
222 *
223 * @return void
224 */
225 function uwp_admin_only_css() {
226 ?>
227 <style type="text/css">
228 .uwp_page .uwp-bs-modal input[type="submit"].button,
229 .uwp_page .uwp-bs-modal button.button {
230 padding: 0 10px 1px;
231 }
232 </style>
233 <?php
234 }
235
236 }