| 1 |
<?php |
| 2 |
|
| 3 |
namespace PXLBSAdminify\Inc\Modules\DashboardWidget; |
| 4 |
|
| 5 |
use PXLBSAdminify\Inc\Utils; |
| 6 |
// no direct access allowed |
| 7 |
if (!defined('ABSPATH')) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
/** |
| 12 |
* PXLBSAdminify |
| 13 |
* |
| 14 |
* @package Module: Dashboard Widget |
| 15 |
* |
| 16 |
* @author Jewel Theme <support@jeweltheme.com> |
| 17 |
*/ |
| 18 |
|
| 19 |
if (!class_exists('DashboardWidget_Setttings')) { |
| 20 |
|
| 21 |
class DashboardWidget_Setttings extends DashboardWidgetModel |
| 22 |
{ |
| 23 |
|
| 24 |
public function __construct() |
| 25 |
{ |
| 26 |
// this should be first so the default values get stored |
| 27 |
$this->dashboard_widget_settings(); |
| 28 |
parent::__construct((array) get_option($this->prefix)); |
| 29 |
|
| 30 |
add_action('admin_enqueue_scripts', [$this, 'dash_widget_setting_css']); |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
/** |
| 35 |
* Dashboard Admin Custom CSS |
| 36 |
* |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
public function dash_widget_setting_css() |
| 40 |
{ |
| 41 |
$css = ' |
| 42 |
.adminify-dashboard-widgets .adminify-header{ |
| 43 |
margin-top:30px; |
| 44 |
} |
| 45 |
.adminify-dashboard-widgets .adminify-header-right{ |
| 46 |
padding: 25px; |
| 47 |
} |
| 48 |
.adminify-dashboard-widgets .wp-adminify-dashboard-widgets form{ |
| 49 |
background: #fff; |
| 50 |
} |
| 51 |
.adminify-dashboard-widgets .adminify-section .adminify-field-subheading{ |
| 52 |
background-color: transparent; |
| 53 |
}'; |
| 54 |
|
| 55 |
printf('<style>body.wp-adminify{%s}</style>', esc_html(wp_strip_all_tags($css))); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public function get_defaults() |
| 61 |
{ |
| 62 |
return [ |
| 63 |
'dashboard_widget_types' => [ |
| 64 |
'dashboard_widgets' => [ |
| 65 |
'title' => '', |
| 66 |
'widget_pos' => 'normal', |
| 67 |
'widget_type' => 'editor', |
| 68 |
'dashw_video' => [ |
| 69 |
'dashw_type_video_type' => 'self_hosted', |
| 70 |
'dashw_type_video_title' => '', |
| 71 |
'dashw_type_video_type_self_hosted' => [ |
| 72 |
'url' => '', |
| 73 |
'id' => '', |
| 74 |
'width' => '', |
| 75 |
'height' => '', |
| 76 |
'thumbnail' => '', |
| 77 |
'alt' => '', |
| 78 |
'title' => '', |
| 79 |
'description' => '', |
| 80 |
], |
| 81 |
'dashw_type_video_type_youtube' => '', |
| 82 |
'dashw_type_video_type_vimeo' => '', |
| 83 |
'dashw_type_video_type_iframe' => '', |
| 84 |
], |
| 85 |
'dashw_type_editor' => '', |
| 86 |
'dashw_type_icon' => '', |
| 87 |
'dashw_type_icon_tooltip' => '', |
| 88 |
'dashw_type_icon_link' => [ |
| 89 |
'url' => 'https://wpadminify.com/', |
| 90 |
'text' => __('Adminify', 'adminify'), |
| 91 |
'target' => '_blank', |
| 92 |
], |
| 93 |
'dashw_type_shortcode' => '', |
| 94 |
'dashw_type_script' => '<script> |
| 95 |
;(function($) { |
| 96 |
"use strict"; |
| 97 |
$(document).ready( function() { |
| 98 |
// Write your JS code here |
| 99 |
}); |
| 100 |
})( jQuery ); |
| 101 |
</script>', |
| 102 |
'dashw_type_rss_feed' => '', |
| 103 |
'dashw_type_rss_count' => 5, |
| 104 |
'dashw_type_rss_excerpt' => true, |
| 105 |
'dashw_type_rss_date' => true, |
| 106 |
'dashw_type_rss_author' => true, |
| 107 |
'user_roles' => '', |
| 108 |
|
| 109 |
], |
| 110 |
'welcome_dash_widget' => [ |
| 111 |
'enable_custom_welcome_dash_widget' => false, |
| 112 |
'widget_template_type' => 'specific_page', |
| 113 |
'custom_page' => '', |
| 114 |
'panel_height' => 600, |
| 115 |
'elementor_section_id' => '', |
| 116 |
'elementor_widget_id' => '', |
| 117 |
'elementor_template_id' => '', |
| 118 |
'oxygen_template_id' => '', |
| 119 |
'dismissible' => true, |
| 120 |
'user_roles' => '', |
| 121 |
], |
| 122 |
], |
| 123 |
]; |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
/** |
| 128 |
* Welcome Widget Settings |
| 129 |
* |
| 130 |
* @param [type] $welcome_widgets |
| 131 |
* |
| 132 |
* @return void |
| 133 |
*/ |
| 134 |
public function welcome_widgets_settings(&$welcome_widgets) |
| 135 |
{ |
| 136 |
$welcome_widget_fields = []; |
| 137 |
$this->welcome_widget_fields($welcome_widget_fields); |
| 138 |
$welcome_widgets[] = [ |
| 139 |
'id' => 'welcome_dash_widget', |
| 140 |
'type' => 'fieldset', |
| 141 |
'class' => 'adminify-one-col', |
| 142 |
'title' => '', |
| 143 |
'fields' => $welcome_widget_fields, |
| 144 |
]; |
| 145 |
} |
| 146 |
|
| 147 |
public function welcome_widget_fields(&$welcome_widget_fields) |
| 148 |
{ |
| 149 |
$welcome_widget_fields[] = [ |
| 150 |
'id' => 'enable_custom_welcome_dash_widget', |
| 151 |
'type' => 'switcher', |
| 152 |
'title' => __('Enable Custom Welcome Panel?', 'adminify'), |
| 153 |
'subtitle' => __('Enable if you want to show any Elementor Template/Page on Welcome Panel', 'adminify'), |
| 154 |
'text_on' => __('Enable', 'adminify'), |
| 155 |
'text_off' => __('Disable', 'adminify'), |
| 156 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['enable_custom_welcome_dash_widget'], |
| 157 |
'text_width' => 100, |
| 158 |
]; |
| 159 |
|
| 160 |
// Default Page |
| 161 |
$page_type_options = [ |
| 162 |
'specific_page' => __('Page', 'adminify'), |
| 163 |
]; |
| 164 |
|
| 165 |
// Oxygen Builder Support |
| 166 |
if (Utils::is_plugin_active('oxygen/functions.php')) { |
| 167 |
$page_oxygen_options = []; |
| 168 |
$page_oxygen_options = [ |
| 169 |
'oxygen_template' => __('Oxygen Template', 'adminify'), |
| 170 |
]; |
| 171 |
$page_type_options = array_merge($page_type_options, $page_oxygen_options); |
| 172 |
} |
| 173 |
|
| 174 |
// Elementor Builder |
| 175 |
if (Utils::is_plugin_active('elementor/elementor.php')) { |
| 176 |
$page_elementory_options = []; |
| 177 |
$page_elementory_options = [ |
| 178 |
'elementor_template' => __('Elementor Page Template', 'adminify'), |
| 179 |
'elementor_section' => __('Elementor Saved Section', 'adminify'), |
| 180 |
'elementor_widget' => __('Elementor Saved Widget', 'adminify'), |
| 181 |
]; |
| 182 |
$page_type_options = array_merge($page_type_options, $page_elementory_options); |
| 183 |
} |
| 184 |
|
| 185 |
$welcome_widget_fields[] = [ |
| 186 |
'id' => 'widget_template_type', |
| 187 |
'type' => 'select', |
| 188 |
'title' => __('Select Page/Template', 'adminify'), |
| 189 |
'placeholder' => __('Select an option', 'adminify'), |
| 190 |
'options' => $page_type_options, |
| 191 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['widget_template_type'], |
| 192 |
'dependency' => ['enable_custom_welcome_dash_widget', '==', 'true', true], |
| 193 |
]; |
| 194 |
|
| 195 |
// Default Page |
| 196 |
$welcome_widget_fields[] = [ |
| 197 |
'id' => 'custom_page', |
| 198 |
'type' => 'select', |
| 199 |
'title' => __('Select Page', 'adminify'), |
| 200 |
'placeholder' => __('Select a Page', 'adminify'), |
| 201 |
'options' => 'pages', |
| 202 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['custom_page'], |
| 203 |
'dependency' => ['widget_template_type|enable_custom_welcome_dash_widget', '==|==', 'specific_page|true', true], |
| 204 |
]; |
| 205 |
|
| 206 |
|
| 207 |
$welcome_widget_fields[] = [ |
| 208 |
'id' => 'panel_height', |
| 209 |
'type' => 'number', |
| 210 |
'title' => __('Panel Height', 'adminify'), |
| 211 |
'unit' => 'px', |
| 212 |
'default' => 100, |
| 213 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['panel_height'], |
| 214 |
'dependency' => ['widget_template_type|enable_custom_welcome_dash_widget', '==|==', 'specific_page|true', true], |
| 215 |
]; |
| 216 |
|
| 217 |
// Oxygen Builder |
| 218 |
if (Utils::is_plugin_active('oxygen/functions.php')) { |
| 219 |
$welcome_widget_fields[] = [ |
| 220 |
'id' => 'oxygen_template_id', |
| 221 |
'type' => 'select', |
| 222 |
'title' => __('Select Template', 'adminify'), |
| 223 |
'placeholder' => __('Select a Template', 'adminify'), |
| 224 |
'options' => 'posts', |
| 225 |
'query_args' => [ |
| 226 |
'post_type' => 'ct_template', |
| 227 |
], |
| 228 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['oxygen_template_id'], |
| 229 |
'dependency' => ['widget_template_type|enable_custom_welcome_dash_widget', '==|==', 'oxygen_template|true', true], |
| 230 |
]; |
| 231 |
} |
| 232 |
|
| 233 |
// Elementor Builder |
| 234 |
if (Utils::is_plugin_active('elementor/elementor.php')) { |
| 235 |
$welcome_widget_fields[] = [ |
| 236 |
'id' => 'elementor_section_id', |
| 237 |
'type' => 'select', |
| 238 |
'title' => __('Saved Section', 'adminify'), |
| 239 |
'options' => 'PXLBSAdminify\Inc\Utils::get_section_template_options', |
| 240 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['elementor_section_id'], |
| 241 |
'dependency' => ['widget_template_type|enable_custom_welcome_dash_widget', '==|==', 'elementor_section|true', true], |
| 242 |
]; |
| 243 |
|
| 244 |
$welcome_widget_fields[] = [ |
| 245 |
'id' => 'elementor_widget_id', |
| 246 |
'type' => 'select', |
| 247 |
'title' => __('Saved Widget', 'adminify'), |
| 248 |
'options' => 'PXLBSAdminify\Inc\Utils::get_widget_template_options', |
| 249 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['elementor_widget_id'], |
| 250 |
'dependency' => ['widget_template_type|enable_custom_welcome_dash_widget', '==|==', 'elementor_widget|true', true], |
| 251 |
]; |
| 252 |
|
| 253 |
$welcome_widget_fields[] = [ |
| 254 |
'id' => 'elementor_template_id', |
| 255 |
'type' => 'select', |
| 256 |
'title' => __('Saved Template', 'adminify'), |
| 257 |
'options' => 'PXLBSAdminify\Inc\Utils::get_page_template_options', |
| 258 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['elementor_template_id'], |
| 259 |
'dependency' => ['widget_template_type|enable_custom_welcome_dash_widget', '==|==', 'elementor_template|true', true], |
| 260 |
]; |
| 261 |
} |
| 262 |
|
| 263 |
|
| 264 |
$welcome_widget_fields[] = [ |
| 265 |
'id' => 'dismissible', |
| 266 |
'type' => 'switcher', |
| 267 |
/* translators: %s: Pro upgrade badge */ |
| 268 |
'title' => sprintf(__('Dismissible %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 269 |
'class' => 'adminify-pro-fieldset adminify-pro-notice', |
| 270 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['dismissible'], |
| 271 |
'dependency' => ['enable_custom_welcome_dash_widget', '==', 'true', true], |
| 272 |
]; |
| 273 |
|
| 274 |
$welcome_widget_fields[] = [ |
| 275 |
'id' => 'user_roles', |
| 276 |
'type' => 'select', |
| 277 |
'title' => __('Allowed User Roles', 'adminify'), |
| 278 |
'subtitle' => __('Allow users to access this section', 'adminify'), |
| 279 |
'placeholder' => __('Select a role', 'adminify'), |
| 280 |
'chosen' => true, |
| 281 |
'multiple' => true, |
| 282 |
'options' => 'roles', |
| 283 |
'default' => $this->get_default_field('dashboard_widget_types')['welcome_dash_widget']['user_roles'], |
| 284 |
'dependency' => ['enable_custom_welcome_dash_widget', '==', 'true', true], |
| 285 |
]; |
| 286 |
} |
| 287 |
|
| 288 |
/** |
| 289 |
* Dashboard Widgets Setting |
| 290 |
* |
| 291 |
* @param [type] $dash_widgets_setting |
| 292 |
* |
| 293 |
* @return void |
| 294 |
*/ |
| 295 |
public function dash_widget_setting_setup(&$dash_widgets_setting) |
| 296 |
{ |
| 297 |
$dash_widgets = []; |
| 298 |
$this->dashboard_widgets($dash_widgets); |
| 299 |
|
| 300 |
$welcome_widgets = []; |
| 301 |
$this->welcome_widgets_settings($welcome_widgets); |
| 302 |
|
| 303 |
$dash_widgets_setting[] = [ |
| 304 |
'type' => 'subheading', |
| 305 |
'id' => 'dashboard_widget_types_subheading', |
| 306 |
'content' => Utils::help_urls( |
| 307 |
__('Custom Dashboard & Welcome Widgets', 'adminify'), |
| 308 |
'https://wpadminify.com/kb/wordpress-custom-dashboard-widget', |
| 309 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 310 |
'https://www.facebook.com/groups/jeweltheme', |
| 311 |
\PXLBSAdminify\Inc\Admin\AdminSettings::support_url() |
| 312 |
), |
| 313 |
]; |
| 314 |
|
| 315 |
$dash_widgets_setting[] = [ |
| 316 |
'id' => 'dashboard_widget_types', |
| 317 |
'type' => 'tabbed', |
| 318 |
'title' => '', |
| 319 |
'tabs' => [ |
| 320 |
[ |
| 321 |
'title' => __('Dashboard Widgets', 'adminify'), |
| 322 |
'id' => 'dashboard_widgets_tab', |
| 323 |
'fields' => $dash_widgets, |
| 324 |
], |
| 325 |
|
| 326 |
[ |
| 327 |
'title' => __('Welcome Widget', 'adminify'), |
| 328 |
'id' => 'welcome_widgets_tab', |
| 329 |
'fields' => $welcome_widgets, |
| 330 |
], |
| 331 |
|
| 332 |
], |
| 333 |
]; |
| 334 |
} |
| 335 |
|
| 336 |
/** |
| 337 |
* Dashboard Widgets Section |
| 338 |
* |
| 339 |
* @param [type] $dash_widgets |
| 340 |
* |
| 341 |
* @return void |
| 342 |
*/ |
| 343 |
public function dashboard_widgets(&$dash_widgets) |
| 344 |
{ |
| 345 |
$dashboard_group_fields = []; |
| 346 |
$this->dashboard_widget_group_fields($dashboard_group_fields); |
| 347 |
|
| 348 |
$dash_widgets[] = [ |
| 349 |
'id' => 'dashboard_widgets', |
| 350 |
'type' => 'group', |
| 351 |
'title' => '', |
| 352 |
'max' => 2, |
| 353 |
'max_text' => __('Get <strong>Pro Version</strong> to Unlock this feature. <a href="https://wpadminify.com/pricing" target="_blank">Upgrade to Pro Now!</a>', 'adminify'), |
| 354 |
'accordion_title_title' => __('Dashboard Widget Name:', 'adminify'), |
| 355 |
'accordion_title_prefix' => __('Dashboard Widget Name: ', 'adminify'), |
| 356 |
'accordion_title_number' => true, |
| 357 |
'accordion_title_auto' => true, |
| 358 |
'button_title' => __('Add New Widget', 'adminify'), |
| 359 |
'fields' => $dashboard_group_fields, |
| 360 |
]; |
| 361 |
} |
| 362 |
|
| 363 |
|
| 364 |
public function dashboard_widget_group_fields(&$dashboard_group_fields) |
| 365 |
{ |
| 366 |
$dashboard_widget_video = []; |
| 367 |
$this->dashboard_widget_video($dashboard_widget_video); |
| 368 |
|
| 369 |
$dashboard_group_fields[] = [ |
| 370 |
'id' => 'title', |
| 371 |
'type' => 'text', |
| 372 |
'title' => __('Widget Title', 'adminify'), |
| 373 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['title'], |
| 374 |
]; |
| 375 |
|
| 376 |
$dashboard_group_fields[] = [ |
| 377 |
'id' => 'widget_pos', |
| 378 |
'type' => 'button_set', |
| 379 |
'title' => __('Widget Position', 'adminify'), |
| 380 |
'options' => [ |
| 381 |
'side' => __('Side', 'adminify'), |
| 382 |
'normal' => __('Normal', 'adminify'), |
| 383 |
], |
| 384 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['widget_pos'], |
| 385 |
]; |
| 386 |
|
| 387 |
$dashboard_group_fields[] = [ |
| 388 |
'id' => 'widget_type', |
| 389 |
'type' => 'button_set', |
| 390 |
'title' => __('Content Type', 'adminify'), |
| 391 |
'options' => [ |
| 392 |
'editor' => __('Editor', 'adminify'), |
| 393 |
'icon' => __('Icon', 'adminify'), |
| 394 |
'video' => __('Video', 'adminify'), |
| 395 |
'shortcode' => __('Shortcode', 'adminify'), |
| 396 |
'rss_feed' => __('RSS Feed', 'adminify'), |
| 397 |
'script' => __('Script', 'adminify'), |
| 398 |
], |
| 399 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['widget_type'], |
| 400 |
]; |
| 401 |
|
| 402 |
$dashboard_group_fields[] = [ |
| 403 |
'id' => 'dashw_video', |
| 404 |
'type' => 'fieldset', |
| 405 |
'title' => __('Video', 'adminify'), |
| 406 |
'fields' => $dashboard_widget_video, |
| 407 |
'dependency' => ['widget_type', '==', 'video'], |
| 408 |
]; |
| 409 |
|
| 410 |
$dashboard_group_fields[] = [ |
| 411 |
'id' => 'dashw_type_editor', |
| 412 |
'type' => 'wp_editor', |
| 413 |
'title' => __('Content', 'adminify'), |
| 414 |
'subtitle' => __('Contents with Editor and HTML mode', 'adminify'), |
| 415 |
'height' => '100px', |
| 416 |
'dependency' => ['widget_type', '==', 'editor'], |
| 417 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_editor'], |
| 418 |
]; |
| 419 |
|
| 420 |
|
| 421 |
$dashboard_group_fields[] = [ |
| 422 |
'id' => 'dashw_type_icon', |
| 423 |
'type' => 'adminify_icon', |
| 424 |
/* translators: %s: Pro upgrade badge */ |
| 425 |
'title' => sprintf(__('Icon %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 426 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 427 |
'dependency' => ['widget_type', '==', 'icon'], |
| 428 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_icon'], |
| 429 |
]; |
| 430 |
|
| 431 |
$dashboard_group_fields[] = [ |
| 432 |
'id' => 'dashw_type_icon_tooltip', |
| 433 |
'type' => 'text', |
| 434 |
/* translators: %s: Pro upgrade badge */ |
| 435 |
'title' => sprintf(__('Tooltip Text %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 436 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 437 |
'dependency' => ['widget_type', '==', 'icon'], |
| 438 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_icon_tooltip'], |
| 439 |
]; |
| 440 |
|
| 441 |
|
| 442 |
$dashboard_group_fields[] = [ |
| 443 |
'id' => 'dashw_type_icon_link', |
| 444 |
'type' => 'link', |
| 445 |
/* translators: %s: Pro upgrade badge */ |
| 446 |
'title' => sprintf(__('Link %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 447 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 448 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_icon_link'], |
| 449 |
'dependency' => ['widget_type', '==', 'icon'], |
| 450 |
]; |
| 451 |
|
| 452 |
|
| 453 |
$dashboard_group_fields[] = [ |
| 454 |
'id' => 'dashw_type_shortcode', |
| 455 |
'type' => 'textarea', |
| 456 |
/* translators: %s: Pro upgrade badge */ |
| 457 |
'title' => sprintf(__('Shortcode %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 458 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 459 |
'dependency' => ['widget_type', '==', 'shortcode'], |
| 460 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_shortcode'], |
| 461 |
]; |
| 462 |
|
| 463 |
|
| 464 |
$dashboard_group_fields[] = [ |
| 465 |
'id' => 'dashw_type_script', |
| 466 |
'type' => 'code_editor', |
| 467 |
/* translators: %s: Pro upgrade badge */ |
| 468 |
'title' => sprintf(__('Script %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 469 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 470 |
'subtitle' => __('Write Custom Script code inside <strong><script></script></strong> tag.', 'adminify'), |
| 471 |
'settings' => [ |
| 472 |
'theme' => 'dracula', |
| 473 |
'mode' => 'htmlmixed', |
| 474 |
], |
| 475 |
'sanitize' => false, |
| 476 |
'dependency' => ['widget_type', '==', 'script'], |
| 477 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_script'], |
| 478 |
]; |
| 479 |
|
| 480 |
$dashboard_group_fields[] = [ |
| 481 |
'id' => 'dashw_type_rss_feed', |
| 482 |
'type' => 'text', |
| 483 |
/* translators: %s: Pro upgrade badge */ |
| 484 |
'title' => sprintf(__('RSS Feed URL %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 485 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 486 |
'dependency' => ['widget_type', '==', 'rss_feed'], |
| 487 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_rss_feed'], |
| 488 |
]; |
| 489 |
|
| 490 |
$dashboard_group_fields[] = [ |
| 491 |
'id' => 'dashw_type_rss_count', |
| 492 |
'type' => 'number', |
| 493 |
/* translators: %s: Pro upgrade badge */ |
| 494 |
'title' => sprintf(__('No. of Feed Posts %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 495 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 496 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_rss_count'], |
| 497 |
'dependency' => ['widget_type', '==', 'rss_feed'], |
| 498 |
]; |
| 499 |
|
| 500 |
$dashboard_group_fields[] = [ |
| 501 |
'id' => 'dashw_type_rss_excerpt', |
| 502 |
'type' => 'switcher', |
| 503 |
/* translators: %s: Pro upgrade badge */ |
| 504 |
'title' => sprintf(__('Show Excerpt? %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 505 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 506 |
'text_on' => __('Yes', 'adminify'), |
| 507 |
'text_off' => __('No', 'adminify'), |
| 508 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_rss_excerpt'], |
| 509 |
'dependency' => ['widget_type', '==', 'rss_feed'], |
| 510 |
]; |
| 511 |
|
| 512 |
$dashboard_group_fields[] = [ |
| 513 |
'id' => 'dashw_type_rss_date', |
| 514 |
'type' => 'switcher', |
| 515 |
/* translators: %s: Pro upgrade badge */ |
| 516 |
'title' => sprintf(__('Show Date? %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 517 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 518 |
'text_on' => __('Yes', 'adminify'), |
| 519 |
'text_off' => __('No', 'adminify'), |
| 520 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_rss_date'], |
| 521 |
'dependency' => ['widget_type', '==', 'rss_feed'], |
| 522 |
]; |
| 523 |
|
| 524 |
|
| 525 |
$dashboard_group_fields[] = [ |
| 526 |
'id' => 'dashw_type_rss_author', |
| 527 |
'type' => 'switcher', |
| 528 |
/* translators: %s: Pro upgrade badge */ |
| 529 |
'title' => sprintf(__('Show Author? %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 530 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 531 |
'text_on' => __('Yes', 'adminify'), |
| 532 |
'text_off' => __('No', 'adminify'), |
| 533 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_type_rss_author'], |
| 534 |
'dependency' => ['widget_type', '==', 'rss_feed'], |
| 535 |
]; |
| 536 |
|
| 537 |
|
| 538 |
$dashboard_group_fields[] = [ |
| 539 |
'id' => 'user_roles', |
| 540 |
'type' => 'select', |
| 541 |
'title' => __('Allowed User Roles', 'adminify'), |
| 542 |
'subtitle' => __('Allow users to access this section', 'adminify'), |
| 543 |
'placeholder' => __('Select a role', 'adminify'), |
| 544 |
'chosen' => true, |
| 545 |
'multiple' => true, |
| 546 |
'options' => 'roles', |
| 547 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['user_roles'], |
| 548 |
]; |
| 549 |
} |
| 550 |
|
| 551 |
public function dashboard_widget_video(&$dashboard_widget_video) |
| 552 |
{ |
| 553 |
$dashboard_widget_video[] = [ |
| 554 |
'id' => 'dashw_type_video_type', |
| 555 |
'type' => 'button_set', |
| 556 |
'title' => __('Video Type', 'adminify'), |
| 557 |
'options' => [ |
| 558 |
'self_hosted' => __('Self Hosted ', 'adminify'), |
| 559 |
'youtube' => __('Youtube', 'adminify'), |
| 560 |
'vimeo' => __('Vimeo', 'adminify'), |
| 561 |
'iframe' => __('iFrame', 'adminify'), |
| 562 |
], |
| 563 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_video']['dashw_type_video_type'], |
| 564 |
]; |
| 565 |
|
| 566 |
|
| 567 |
$dashboard_widget_video[] = [ |
| 568 |
'id' => 'dashw_type_video_title', |
| 569 |
'type' => 'text', |
| 570 |
/* translators: %s: Pro upgrade badge */ |
| 571 |
'title' => sprintf(__('Text %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 572 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 573 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_video']['dashw_type_video_title'], |
| 574 |
'dependency' => ['dashw_type_video_type', '!==', 'iframe', true], |
| 575 |
]; |
| 576 |
|
| 577 |
|
| 578 |
$dashboard_widget_video[] = [ |
| 579 |
'id' => 'dashw_type_video_type_self_hosted', |
| 580 |
'type' => 'media', |
| 581 |
/* translators: %s: Pro upgrade badge */ |
| 582 |
'title' => sprintf(__('Upload Video %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 583 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 584 |
'library' => 'video', |
| 585 |
'preview' => true, |
| 586 |
'dependency' => ['dashw_type_video_type', '==', 'self_hosted'], |
| 587 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_video']['dashw_type_video_type_self_hosted'], |
| 588 |
]; |
| 589 |
|
| 590 |
$dashboard_widget_video[] = [ |
| 591 |
'id' => 'dashw_type_video_type_youtube', |
| 592 |
'type' => 'text', |
| 593 |
/* translators: %s: Pro upgrade badge */ |
| 594 |
'title' => sprintf(__('Youtube URL %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 595 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 596 |
'validate' => 'adminify_validate_url', |
| 597 |
'dependency' => ['dashw_type_video_type', '==', 'youtube'], |
| 598 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_video']['dashw_type_video_type_youtube'], |
| 599 |
]; |
| 600 |
|
| 601 |
$dashboard_widget_video[] = [ |
| 602 |
'id' => 'dashw_type_video_type_vimeo', |
| 603 |
'type' => 'text', |
| 604 |
/* translators: %s: Pro upgrade badge */ |
| 605 |
'title' => sprintf(__('Vimeo URL %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 606 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 607 |
'validate' => 'adminify_validate_url', |
| 608 |
'dependency' => ['dashw_type_video_type', '==', 'vimeo'], |
| 609 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_video']['dashw_type_video_type_vimeo'], |
| 610 |
]; |
| 611 |
|
| 612 |
$dashboard_widget_video[] = [ |
| 613 |
'id' => 'dashw_type_video_type_iframe', |
| 614 |
'type' => 'text', |
| 615 |
/* translators: %s: Pro upgrade badge */ |
| 616 |
'title' => sprintf(__('iFrame Video URL %s', 'adminify'), Utils::upgrade_pro_badge()), |
| 617 |
'class' => 'adminify-pro-fieldset adminify-pro-notice adminify-pro-pointer', |
| 618 |
'validate' => 'adminify_validate_url', |
| 619 |
'dependency' => ['dashw_type_video_type', '==', 'iframe'], |
| 620 |
'default' => $this->get_default_field('dashboard_widget_types')['dashboard_widgets']['dashw_video']['dashw_type_video_type_iframe'], |
| 621 |
]; |
| 622 |
} |
| 623 |
|
| 624 |
public function dashboard_widget_settings() |
| 625 |
{ |
| 626 |
if (!class_exists('ADMINIFY')) { |
| 627 |
return; |
| 628 |
} |
| 629 |
|
| 630 |
// WP Adminify Dashboard Widgets Settings |
| 631 |
\ADMINIFY::createOptions( |
| 632 |
$this->prefix, |
| 633 |
[ |
| 634 |
|
| 635 |
// Framework Title |
| 636 |
'framework_title' => __('Adminify Dashboard Widget <small>by Jewel Theme</small>', 'adminify'), |
| 637 |
'framework_class' => 'adminify-dashboard-widgets', |
| 638 |
|
| 639 |
// menu settings |
| 640 |
'menu_title' => __('Dashboard Widget', 'adminify'), |
| 641 |
'menu_slug' => 'adminify-dashboard-widgets', |
| 642 |
'menu_type' => 'submenu', // menu, submenu, options, theme, etc. |
| 643 |
'menu_capability' => 'manage_options', |
| 644 |
'menu_icon' => '', |
| 645 |
'menu_position' => 18, |
| 646 |
'menu_hook_priority' => 21, |
| 647 |
'menu_hidden' => false, |
| 648 |
'menu_parent' => 'wp-adminify-settings', |
| 649 |
|
| 650 |
// footer |
| 651 |
'footer_text' => ' ', |
| 652 |
'footer_after' => ' ', |
| 653 |
'footer_credit' => ' ', |
| 654 |
|
| 655 |
// menu extras |
| 656 |
'show_bar_menu' => false, |
| 657 |
'show_sub_menu' => false, |
| 658 |
'show_in_network' => false, |
| 659 |
'show_in_customizer' => false, |
| 660 |
|
| 661 |
'show_search' => false, |
| 662 |
'show_reset_all' => false, |
| 663 |
'show_reset_section' => false, |
| 664 |
'show_footer' => true, |
| 665 |
'show_all_options' => true, |
| 666 |
'show_form_warning' => true, |
| 667 |
'sticky_header' => false, |
| 668 |
'save_defaults' => false, |
| 669 |
'ajax_save' => true, |
| 670 |
|
| 671 |
// admin bar menu settings |
| 672 |
'admin_bar_menu_icon' => '', |
| 673 |
'admin_bar_menu_priority' => 45, |
| 674 |
|
| 675 |
// database model |
| 676 |
'database' => 'options', // options, transient, theme_mod, network(multisite support) |
| 677 |
'transient_time' => 0, |
| 678 |
|
| 679 |
// typography options |
| 680 |
'enqueue_webfont' => true, |
| 681 |
'async_webfont' => false, |
| 682 |
|
| 683 |
// others |
| 684 |
'output_css' => false, |
| 685 |
|
| 686 |
// theme and wrapper classname |
| 687 |
'nav' => 'normal', |
| 688 |
'theme' => 'dark', |
| 689 |
'class' => 'wp-adminify-dashboard-widgets', |
| 690 |
] |
| 691 |
); |
| 692 |
|
| 693 |
$dash_widgets_setting = []; |
| 694 |
$this->dash_widget_setting_setup($dash_widgets_setting); |
| 695 |
$dash_widgets_setting = apply_filters('pxlbsadminify_settings/dashboar_widgets', $dash_widgets_setting, $this); |
| 696 |
|
| 697 |
\ADMINIFY::createSection( |
| 698 |
$this->prefix, |
| 699 |
[ |
| 700 |
'title' => __('Dashboard Widget', 'adminify'), |
| 701 |
'icon' => 'fas fa-bolt', |
| 702 |
'fields' => $dash_widgets_setting, |
| 703 |
] |
| 704 |
); |
| 705 |
} |
| 706 |
} |
| 707 |
} |
| 708 |
|