| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 7 |
|
| 8 |
/** |
| 9 |
* WP Adminify |
| 10 |
* @package WP Admin Bar |
| 11 |
* |
| 12 |
* @author Jewel Theme <support@jeweltheme.com> |
| 13 |
*/ |
| 14 |
|
| 15 |
class AdminBar extends AdminSettingsModel |
| 16 |
{ |
| 17 |
public function __construct() |
| 18 |
{ |
| 19 |
$this->admin_bar_settings(); |
| 20 |
} |
| 21 |
|
| 22 |
public function get_defaults() |
| 23 |
{ |
| 24 |
return [ |
| 25 |
'admin_bar_settings' => [ |
| 26 |
'admin_bar_user_roles' => [], |
| 27 |
'enable_admin_bar' => true, |
| 28 |
'admin_bar_hide_frontend' => 'show', |
| 29 |
'admin_bar_position' => 'top', |
| 30 |
'admin_bar_search' => true, |
| 31 |
'admin_bar_comments' => true, |
| 32 |
'admin_bar_view_website' => true, |
| 33 |
'admin_bar_dark_light_btn' => true, |
| 34 |
'admin_bar_container' => 'admin_bar_only', |
| 35 |
'admin_bar_light_bg' => 'color', |
| 36 |
'admin_bar_light_bg_color' => '#fff', |
| 37 |
'admin_bar_light_bg_gradient' => [ |
| 38 |
'background-color' => '#0347FF', |
| 39 |
'background-gradient-color' => '#fd1919', |
| 40 |
'background-gradient-direction' => '135deg' |
| 41 |
], |
| 42 |
'admin_bar_dark_bg' => 'color', |
| 43 |
'admin_bar_dark_bg_color' => '#1D1D1D', |
| 44 |
'admin_bar_dark_bg_gradient' => [ |
| 45 |
'background-color' => '#0347FF', |
| 46 |
'background-gradient-color' => '#fd1919', |
| 47 |
'background-gradient-direction' => '135deg' |
| 48 |
], |
| 49 |
'admin_bar_text_color' => '', |
| 50 |
'admin_bar_link_color' => [ |
| 51 |
'bg_color' => '#fff', |
| 52 |
'link_color' => '#4a4a4a', |
| 53 |
'hover_color' => '#4a4a4a' |
| 54 |
], |
| 55 |
'admin_bar_link_dropdown_color' => [ |
| 56 |
'wrapper_bg' => '#fff', |
| 57 |
'bg_color' => '#fff', |
| 58 |
'link_color' => '#4a4a4a', |
| 59 |
'hover_color' => '#4a4a4a' |
| 60 |
], |
| 61 |
'admin_bar_icon_color' => '' |
| 62 |
] |
| 63 |
]; |
| 64 |
} |
| 65 |
|
| 66 |
public function admin_bar_settings_user_roles(&$fields) |
| 67 |
{ |
| 68 |
$fields[] = array( |
| 69 |
'id' => 'admin_bar_user_roles', |
| 70 |
'type' => 'select', |
| 71 |
'title' => __('Disable for', WP_ADMINIFY_TD), |
| 72 |
'placeholder' => __('Select User roles you don\'t want to show', WP_ADMINIFY_TD), |
| 73 |
'options' => 'roles', |
| 74 |
'multiple' => true, |
| 75 |
'chosen' => true, |
| 76 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_user_roles'], |
| 77 |
); |
| 78 |
|
| 79 |
$fields[] = array( |
| 80 |
'id' => 'enable_admin_bar', |
| 81 |
'type' => 'switcher', |
| 82 |
'title' => __('Admin Bar', WP_ADMINIFY_TD), |
| 83 |
'label' => __('Enable/Disable Admin Bar includes Logo, Search, Dark/Light Mode, User Info etc.', WP_ADMINIFY_TD), |
| 84 |
'text_on' => __('Enabled', WP_ADMINIFY_TD), |
| 85 |
'text_off' => __('Disabled', WP_ADMINIFY_TD), |
| 86 |
'text_width' => 100, |
| 87 |
'default' => $this->get_default_field('admin_bar_settings')['enable_admin_bar'], |
| 88 |
); |
| 89 |
|
| 90 |
$fields[] = array( |
| 91 |
'id' => 'admin_bar_hide_frontend', |
| 92 |
'type' => 'button_set', |
| 93 |
'title' => __('Frontend Admin Bar', WP_ADMINIFY_TD), |
| 94 |
'options' => array( |
| 95 |
'show' => __('Show', WP_ADMINIFY_TD), |
| 96 |
'hide' => __('Hide', WP_ADMINIFY_TD), |
| 97 |
), |
| 98 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_hide_frontend'], |
| 99 |
'dependency' => array('enable_admin_bar', '==', 'true', 'true'), |
| 100 |
); |
| 101 |
|
| 102 |
if (jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 103 |
$fields[] = array( |
| 104 |
'id' => 'admin_bar_position', |
| 105 |
'type' => 'button_set', |
| 106 |
'title' => __('Admin Bar Postion', WP_ADMINIFY_TD), |
| 107 |
'options' => array( |
| 108 |
'top' => __('Top', WP_ADMINIFY_TD), |
| 109 |
'bottom' => __('Bottom', WP_ADMINIFY_TD), |
| 110 |
), |
| 111 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_position'], |
| 112 |
'dependency' => array('enable_admin_bar', '==', 'true', 'true'), |
| 113 |
); |
| 114 |
} else { |
| 115 |
|
| 116 |
$fields[] = array( |
| 117 |
'id' => 'admin_bar_position', |
| 118 |
'type' => 'button_set', |
| 119 |
'title' => __('Admin Bar Postion', WP_ADMINIFY_TD), |
| 120 |
'options' => array( |
| 121 |
'top' => __('Top', WP_ADMINIFY_TD), |
| 122 |
'pro_feature' => __('Bottom', WP_ADMINIFY_TD), |
| 123 |
), |
| 124 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_position'], |
| 125 |
'dependency' => array('enable_admin_bar', '==', 'true', 'true'), |
| 126 |
); |
| 127 |
$fields[] = array( |
| 128 |
'type' => 'notice', |
| 129 |
'title' => '', |
| 130 |
'style' => 'warning', |
| 131 |
'content' => Utils::adminify_upgrade_pro(), |
| 132 |
'dependency' => array('enable_admin_bar|admin_bar_position', '==|==', 'true|pro_feature', 'true'), |
| 133 |
); |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
// array( |
| 139 |
// 'id' => 'admin_bar_layout', |
| 140 |
// 'type' => 'switcher', |
| 141 |
// 'title' => 'Default Admin bar' |
| 142 |
// ), |
| 143 |
|
| 144 |
$fields[] = array( |
| 145 |
'id' => 'admin_bar_search', |
| 146 |
'type' => 'switcher', |
| 147 |
'title' => __('Search Form', WP_ADMINIFY_TD), |
| 148 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_search'], |
| 149 |
'text_on' => __('Show', WP_ADMINIFY_TD), |
| 150 |
'text_off' => __('Hide', WP_ADMINIFY_TD), |
| 151 |
'text_width' => '100', |
| 152 |
'dependency' => array('enable_admin_bar', '==', 'true', 'true'), |
| 153 |
); |
| 154 |
|
| 155 |
$fields[] = array( |
| 156 |
'id' => 'admin_bar_comments', |
| 157 |
'type' => 'switcher', |
| 158 |
'title' => __('Comments Icon', WP_ADMINIFY_TD), |
| 159 |
'text_on' => __('Show', WP_ADMINIFY_TD), |
| 160 |
'text_off' => __('Hide', WP_ADMINIFY_TD), |
| 161 |
'text_width' => '100', |
| 162 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_comments'], |
| 163 |
'dependency' => array('enable_admin_bar', '==', 'true', 'true'), |
| 164 |
); |
| 165 |
$fields[] = array( |
| 166 |
'id' => 'admin_bar_view_website', |
| 167 |
'type' => 'switcher', |
| 168 |
'title' => 'View Website Icon', |
| 169 |
'text_on' => __('Show', WP_ADMINIFY_TD), |
| 170 |
'text_off' => __('Hide', WP_ADMINIFY_TD), |
| 171 |
'text_width' => '100', |
| 172 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_view_website'], |
| 173 |
'dependency' => array('enable_admin_bar', '==', 'true', 'true'), |
| 174 |
); |
| 175 |
$fields[] = array( |
| 176 |
'id' => 'admin_bar_dark_light_btn', |
| 177 |
'type' => 'switcher', |
| 178 |
'title' => __('Light/Dark Button', WP_ADMINIFY_TD), |
| 179 |
'text_on' => __('Show', WP_ADMINIFY_TD), |
| 180 |
'text_off' => __('Hide', WP_ADMINIFY_TD), |
| 181 |
'text_width' => '100', |
| 182 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_dark_light_btn'], |
| 183 |
'dependency' => array('enable_admin_bar', '==', 'true', 'true'), |
| 184 |
); |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
/** |
| 190 |
* Style Tab Settings |
| 191 |
* |
| 192 |
* @return void |
| 193 |
*/ |
| 194 |
public function admin_bar_style_tab_settings(&$fields) |
| 195 |
{ |
| 196 |
$fields[] = array( |
| 197 |
'id' => 'admin_bar_container', |
| 198 |
'type' => 'button_set', |
| 199 |
'title' => __('Admin Bar Select', WP_ADMINIFY_TD), |
| 200 |
'description' => __('Select to change Colors of Full Container(with Admin bar and Navigation) or Admin Bar only', WP_ADMINIFY_TD), |
| 201 |
'options' => array( |
| 202 |
'full_container' => __('Full Container', WP_ADMINIFY_TD), |
| 203 |
'admin_bar_only' => __('Admin Bar', WP_ADMINIFY_TD), |
| 204 |
), |
| 205 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_container'], |
| 206 |
'dependency' => array('layout_type', '==', 'horizontal', 'true'), |
| 207 |
); |
| 208 |
|
| 209 |
if (!jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 210 |
$fields[] = array( |
| 211 |
'type' => 'notice', |
| 212 |
'title' => __('', WP_ADMINIFY_TD), |
| 213 |
'style' => 'warning', |
| 214 |
'content' => Utils::adminify_upgrade_pro(), |
| 215 |
'dependency' => array('admin_bar_container', '==', 'full_container', 'true'), |
| 216 |
); |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
$fields[] = array( |
| 221 |
'id' => 'admin_bar_light_bg', |
| 222 |
'type' => 'button_set', |
| 223 |
'title' => __('Background', WP_ADMINIFY_TD), |
| 224 |
'options' => array( |
| 225 |
'color' => __('Color', WP_ADMINIFY_TD), |
| 226 |
'gradient' => __('Gradient', WP_ADMINIFY_TD), |
| 227 |
), |
| 228 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_light_bg'], |
| 229 |
'dependency' => array('admin_bar_mode', '==', 'light', 'true'), |
| 230 |
); |
| 231 |
|
| 232 |
$fields[] = array( |
| 233 |
'id' => 'admin_bar_light_bg_color', |
| 234 |
'type' => 'color', |
| 235 |
'title' => __('Background Color', WP_ADMINIFY_TD), |
| 236 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_light_bg_color'], |
| 237 |
'dependency' => array('admin_bar_light_bg|admin_bar_mode', '==|==', 'color|light', 'true'), |
| 238 |
); |
| 239 |
|
| 240 |
|
| 241 |
if (jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 242 |
$fields[] = array( |
| 243 |
'id' => 'admin_bar_light_bg_gradient', |
| 244 |
'type' => 'background', |
| 245 |
'title' => __('Gradient Background', WP_ADMINIFY_TD), |
| 246 |
'background_color' => true, |
| 247 |
'background_image' => false, |
| 248 |
'background_position' => false, |
| 249 |
'background_repeat' => false, |
| 250 |
'background_attachment' => false, |
| 251 |
'background_size' => false, |
| 252 |
'background_origin' => false, |
| 253 |
'background_clip' => false, |
| 254 |
'background_blend_mode' => false, |
| 255 |
'background_gradient' => true, |
| 256 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_light_bg_gradient'], |
| 257 |
'dependency' => array('admin_bar_light_bg|admin_bar_mode', '==|==', 'gradient|light', 'true') |
| 258 |
); |
| 259 |
} else { |
| 260 |
$fields[] = array( |
| 261 |
'type' => 'notice', |
| 262 |
'title' => __('', WP_ADMINIFY_TD), |
| 263 |
'style' => 'warning', |
| 264 |
'content' => Utils::adminify_upgrade_pro(), |
| 265 |
'dependency' => array('admin_bar_light_bg|admin_bar_mode', '==|==', 'gradient|light', 'true') |
| 266 |
); |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
// Dark Background |
| 271 |
$fields[] = array( |
| 272 |
'id' => 'admin_bar_dark_bg', |
| 273 |
'type' => 'button_set', |
| 274 |
'title' => __('Background Type', WP_ADMINIFY_TD), |
| 275 |
'options' => array( |
| 276 |
'color' => __('Color', WP_ADMINIFY_TD), |
| 277 |
'gradient' => __('Gradient', WP_ADMINIFY_TD), |
| 278 |
), |
| 279 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_dark_bg'], |
| 280 |
'dependency' => array('admin_bar_mode', '==', 'dark', 'true'), |
| 281 |
); |
| 282 |
|
| 283 |
$fields[] = array( |
| 284 |
'id' => 'admin_bar_dark_bg_color', |
| 285 |
'type' => 'color', |
| 286 |
'title' => __('Background Color', WP_ADMINIFY_TD), |
| 287 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_dark_bg_color'], |
| 288 |
'dependency' => array('admin_bar_dark_bg|admin_bar_mode', '==|==', 'color|dark', 'true'), |
| 289 |
); |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
if (jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 294 |
$fields[] = array( |
| 295 |
'id' => 'admin_bar_dark_bg_gradient', |
| 296 |
'type' => 'background', |
| 297 |
'title' => __('Gradient Background', WP_ADMINIFY_TD), |
| 298 |
'background_color' => true, |
| 299 |
'background_image' => false, |
| 300 |
'background_position' => false, |
| 301 |
'background_repeat' => false, |
| 302 |
'background_attachment' => false, |
| 303 |
'background_size' => false, |
| 304 |
'background_origin' => false, |
| 305 |
'background_clip' => false, |
| 306 |
'background_blend_mode' => false, |
| 307 |
'background_gradient' => true, |
| 308 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_dark_bg_gradient'], |
| 309 |
'dependency' => array('admin_bar_dark_bg|admin_bar_mode', '==|==', 'gradient|dark', 'true') |
| 310 |
); |
| 311 |
} else { |
| 312 |
$fields[] = array( |
| 313 |
'type' => 'notice', |
| 314 |
'title' => __('', WP_ADMINIFY_TD), |
| 315 |
'style' => 'warning', |
| 316 |
'content' => Utils::adminify_upgrade_pro(), |
| 317 |
'dependency' => array('admin_bar_dark_bg|admin_bar_mode', '==|==', 'gradient|dark', 'true') |
| 318 |
); |
| 319 |
} |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
$fields[] = array( |
| 324 |
'id' => 'admin_bar_text_color', |
| 325 |
'type' => 'color', |
| 326 |
'title' => __('Text Color', WP_ADMINIFY_TD), |
| 327 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_text_color'], |
| 328 |
); |
| 329 |
|
| 330 |
$fields[] = array( |
| 331 |
'type' => 'subheading', |
| 332 |
'content' => __('"New" Button Style', WP_ADMINIFY_TD) |
| 333 |
); |
| 334 |
$fields[] = array( |
| 335 |
'id' => 'admin_bar_link_color', |
| 336 |
'type' => 'color_group', |
| 337 |
'title' => __('"New" Button color', WP_ADMINIFY_TD), |
| 338 |
'subtitle' => __('"New" Button Link colors active, hover, background etc ', WP_ADMINIFY_TD), |
| 339 |
'options' => array( |
| 340 |
'bg_color' => __('Background Color', WP_ADMINIFY_TD), |
| 341 |
'link_color' => __('Text Color', WP_ADMINIFY_TD), |
| 342 |
'hover_color' => __('Hover Color', WP_ADMINIFY_TD), |
| 343 |
), |
| 344 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_link_color'], |
| 345 |
); |
| 346 |
$fields[] = array( |
| 347 |
'id' => 'admin_bar_link_dropdown_color', |
| 348 |
'type' => 'color_group', |
| 349 |
'title' => __('"New" Dropdown', WP_ADMINIFY_TD), |
| 350 |
'subtitle' => __('"New" Dropdown Link colors active, hover, background etc ', WP_ADMINIFY_TD), |
| 351 |
'options' => array( |
| 352 |
'wrapper_bg' => __('Wrapper BG', WP_ADMINIFY_TD), |
| 353 |
'bg_color' => __('Item Hover BG', WP_ADMINIFY_TD), |
| 354 |
'link_color' => __('Link Color', WP_ADMINIFY_TD), |
| 355 |
'hover_color' => __('Hover Color', WP_ADMINIFY_TD), |
| 356 |
), |
| 357 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_link_dropdown_color'], |
| 358 |
); |
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
$fields[] = array( |
| 363 |
'type' => 'subheading', |
| 364 |
'content' => __('Icon Color', WP_ADMINIFY_TD), |
| 365 |
); |
| 366 |
$fields[] = array( |
| 367 |
'id' => 'admin_bar_icon_color', |
| 368 |
'type' => 'color', |
| 369 |
'title' => __('Color', WP_ADMINIFY_TD), |
| 370 |
'default' => $this->get_default_field('admin_bar_settings')['admin_bar_icon_color'], |
| 371 |
); |
| 372 |
} |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
public function admin_bar_settings() |
| 377 |
{ |
| 378 |
|
| 379 |
if (!class_exists('ADMINIFY')) { |
| 380 |
return; |
| 381 |
} |
| 382 |
|
| 383 |
$settings_tab_fields = []; |
| 384 |
$style_tab_fields = []; |
| 385 |
$this->admin_bar_settings_user_roles($settings_tab_fields); |
| 386 |
$this->admin_bar_style_tab_settings($style_tab_fields); |
| 387 |
|
| 388 |
// Admin Bar Section |
| 389 |
\ADMINIFY::createSection($this->prefix, array( |
| 390 |
'title' => __('Admin Bar', WP_ADMINIFY_TD), |
| 391 |
'icon' => 'fas fa-user-shield', |
| 392 |
'fields' => array( |
| 393 |
array( |
| 394 |
'type' => 'subheading', |
| 395 |
'content' => Utils::adminfiy_help_urls( |
| 396 |
__('Admin Bar Settings', WP_ADMINIFY_TD), |
| 397 |
'https://wpadminify.com/kb/wp-admin-bar/', |
| 398 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 399 |
'https://www.facebook.com/groups/jeweltheme', |
| 400 |
'https://wpadminify.com/support/' |
| 401 |
) |
| 402 |
), |
| 403 |
array( |
| 404 |
'id' => 'admin_bar_settings', |
| 405 |
'type' => 'tabbed', |
| 406 |
'title' => '', |
| 407 |
'tabs' => array( |
| 408 |
array( |
| 409 |
'title' => __('Settings', WP_ADMINIFY_TD), |
| 410 |
'fields' => $settings_tab_fields |
| 411 |
), |
| 412 |
array( |
| 413 |
'title' => 'Styles', |
| 414 |
'fields' => $style_tab_fields |
| 415 |
), |
| 416 |
), |
| 417 |
), |
| 418 |
) |
| 419 |
)); |
| 420 |
} |
| 421 |
} |
| 422 |
|