| 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.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 |
$ajax_cons_data = array( |
| 108 |
'url' => admin_url('admin-ajax.php'), |
| 109 |
'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'userswp'), |
| 110 |
'custom_field_options_not_blank_var' => __('Option Values must not be blank', 'userswp'), |
| 111 |
'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'userswp'), |
| 112 |
'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'userswp'), |
| 113 |
'custom_field_delete' => __('Are you wish to delete this field?', 'userswp'), |
| 114 |
'custom_field_id_required' => __('This field is required.', 'userswp'), |
| 115 |
); |
| 116 |
wp_localize_script("userswp_admin", 'uwp_admin_ajax', $ajax_cons_data); |
| 117 |
|
| 118 |
$country_data = uwp_get_country_data(); |
| 119 |
wp_localize_script(USERSWP_NAME, 'uwp_country_data', $country_data); |
| 120 |
|
| 121 |
} |
| 122 |
|
| 123 |
public function setup_admin_menus() { |
| 124 |
|
| 125 |
$install_type = uwp_get_installation_type(); |
| 126 |
|
| 127 |
// Proceed if main site or pages on all sites or specific blog id |
| 128 |
$proceed = false; |
| 129 |
$show_builder = false; |
| 130 |
switch ($install_type) { |
| 131 |
case "single": |
| 132 |
$proceed = true; |
| 133 |
$show_builder = true; |
| 134 |
break; |
| 135 |
case "multi_na_all": |
| 136 |
$proceed = true; |
| 137 |
break; |
| 138 |
case "multi_na_site_id": |
| 139 |
if (defined('UWP_ROOT_PAGES')) { |
| 140 |
$blog_id = UWP_ROOT_PAGES; |
| 141 |
} else { |
| 142 |
$blog_id = null; |
| 143 |
} |
| 144 |
$current_blog_id = get_current_blog_id(); |
| 145 |
if (!is_int($blog_id)) { |
| 146 |
$proceed = false; |
| 147 |
} else { |
| 148 |
if ($blog_id == $current_blog_id) { |
| 149 |
$proceed = true; |
| 150 |
$show_builder = true; |
| 151 |
} else { |
| 152 |
$proceed = false; |
| 153 |
} |
| 154 |
} |
| 155 |
break; |
| 156 |
case "multi_na_default": |
| 157 |
$is_main_site = is_main_site(); |
| 158 |
if ($is_main_site) { |
| 159 |
$proceed = true; |
| 160 |
$show_builder = true; |
| 161 |
} |
| 162 |
break; |
| 163 |
case "multi_not_na": |
| 164 |
$proceed = true; |
| 165 |
$show_builder = true; |
| 166 |
break; |
| 167 |
default: |
| 168 |
$proceed = false; |
| 169 |
|
| 170 |
} |
| 171 |
|
| 172 |
if (!$proceed) { |
| 173 |
return; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
add_menu_page( |
| 178 |
'UsersWP Settings', |
| 179 |
'UsersWP', |
| 180 |
'manage_options', |
| 181 |
'userswp', |
| 182 |
array( $this->admin_settings, 'uwp_settings_page' ), |
| 183 |
'dashicons-groups', |
| 184 |
70 |
| 185 |
); |
| 186 |
|
| 187 |
if ($show_builder) { |
| 188 |
add_submenu_page( |
| 189 |
"userswp", |
| 190 |
"Form Builder", |
| 191 |
"Form Builder", |
| 192 |
'manage_options', |
| 193 |
'uwp_form_builder', |
| 194 |
array($this->admin_settings, 'uwp_settings_page') |
| 195 |
); |
| 196 |
|
| 197 |
add_submenu_page( |
| 198 |
"userswp", |
| 199 |
"Notifications", |
| 200 |
"Notifications", |
| 201 |
'manage_options', |
| 202 |
'uwp_notifications', |
| 203 |
array($this->admin_settings, 'uwp_settings_page') |
| 204 |
); |
| 205 |
|
| 206 |
$settings_page = array($this->admin_settings, 'uwp_settings_page'); |
| 207 |
do_action('uwp_admin_sub_menus', $settings_page, $this->admin_settings); |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
/** |
| 212 |
* Adds UsersWP css to admin area |
| 213 |
* |
| 214 |
* @since 1.0.0 |
| 215 |
* @package userswp |
| 216 |
* |
| 217 |
* @return void |
| 218 |
*/ |
| 219 |
function uwp_admin_only_css() { |
| 220 |
?> |
| 221 |
<style type="text/css"> |
| 222 |
.uwp_page .uwp-bs-modal input[type="submit"].button, |
| 223 |
.uwp_page .uwp-bs-modal button.button { |
| 224 |
padding: 0 10px 1px; |
| 225 |
} |
| 226 |
</style> |
| 227 |
<?php |
| 228 |
} |
| 229 |
|
| 230 |
} |