| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 7 |
|
| 8 |
// no direct access allowed |
| 9 |
if (!defined('ABSPATH')) exit; |
| 10 |
|
| 11 |
/** |
| 12 |
* @package WPAdminify |
| 13 |
* Quick Menu |
| 14 |
* |
| 15 |
* @author Jewel Theme <support@jeweltheme.com> |
| 16 |
*/ |
| 17 |
|
| 18 |
class Module_QuickCircleMenu extends AdminSettingsModel |
| 19 |
{ |
| 20 |
|
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
$this->quick_menu_settings(); |
| 24 |
} |
| 25 |
|
| 26 |
public function get_defaults() |
| 27 |
{ |
| 28 |
return [ |
| 29 |
'quick_menus_user_roles' => [], |
| 30 |
'quick_menus' => [ |
| 31 |
[ |
| 32 |
'menu_title' => __('New Post', WP_ADMINIFY_TD), |
| 33 |
'menu_link' => [ |
| 34 |
'url' => esc_url(admin_url('post-new.php')), |
| 35 |
'target' => '_self' |
| 36 |
], |
| 37 |
'menu_icon' => 'dashicons dashicons-edit-page' |
| 38 |
], |
| 39 |
[ |
| 40 |
'menu_title' => __('New Page', WP_ADMINIFY_TD), |
| 41 |
'menu_link' => [ |
| 42 |
'url' => esc_url(admin_url('post-new.php?post_type=page')), |
| 43 |
'target' => '_self' |
| 44 |
], |
| 45 |
'menu_icon' => 'dashicons dashicons-welcome-add-page' |
| 46 |
], |
| 47 |
[ |
| 48 |
'menu_title' => __('New Media', WP_ADMINIFY_TD), |
| 49 |
'menu_link' => [ |
| 50 |
'url' => esc_url(admin_url('media-new.php')), |
| 51 |
'target' => '_self' |
| 52 |
], |
| 53 |
'menu_icon' => 'dashicons dashicons-admin-media', |
| 54 |
] |
| 55 |
] |
| 56 |
]; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
/** |
| 61 |
* User Roles |
| 62 |
* |
| 63 |
* @return void |
| 64 |
*/ |
| 65 |
public function quick_menu_user_roles(&$fields) |
| 66 |
{ |
| 67 |
$fields[] = array( |
| 68 |
'type' => 'subheading', |
| 69 |
'content' => Utils::adminfiy_help_urls( |
| 70 |
__('Quick Menu Settings', WP_ADMINIFY_TD), |
| 71 |
'https://wpadminify.com/kb/floating-dashboard-quick-menu', |
| 72 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 73 |
'https://www.facebook.com/groups/jeweltheme', |
| 74 |
'https://wpadminify.com/support/quick-circle-menu/' |
| 75 |
) |
| 76 |
); |
| 77 |
|
| 78 |
$fields[] = array( |
| 79 |
'id' => 'quick_menus_user_roles', |
| 80 |
'type' => 'select', |
| 81 |
'title' => __('Disable for', WP_ADMINIFY_TD), |
| 82 |
'placeholder' => __('Select User roles you want to show', WP_ADMINIFY_TD), |
| 83 |
'options' => 'roles', |
| 84 |
'multiple' => true, |
| 85 |
'chosen' => true, |
| 86 |
'default' => $this->get_default_field('quick_menus_user_roles'), |
| 87 |
); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Default Data Settings |
| 92 |
*/ |
| 93 |
public function quick_menu_default_settings(&$fields) |
| 94 |
{ |
| 95 |
|
| 96 |
$fields[] = array( |
| 97 |
'type' => 'subheading', |
| 98 |
'content' => __('Add/Remove Quick Menu', WP_ADMINIFY_TD), |
| 99 |
); |
| 100 |
|
| 101 |
if (jltwp_adminify()->can_use_premium_code__premium_only()) { |
| 102 |
|
| 103 |
$fields[] = array( |
| 104 |
'id' => 'quick_menus', |
| 105 |
'type' => 'group', |
| 106 |
'title' => '', |
| 107 |
'accordion_title_prefix' => __('Quick Menu: ', WP_ADMINIFY_TD), |
| 108 |
'accordion_title_number' => true, |
| 109 |
'accordion_title_auto' => true, |
| 110 |
'button_title' => __('Add New Quick Menu', WP_ADMINIFY_TD), |
| 111 |
'fields' => array( |
| 112 |
array( |
| 113 |
'id' => 'menu_title', |
| 114 |
'type' => 'text', |
| 115 |
'title' => __('Menu Title', WP_ADMINIFY_TD), |
| 116 |
), |
| 117 |
array( |
| 118 |
'id' => 'menu_link', |
| 119 |
'type' => 'link', |
| 120 |
'title' => __('Link', WP_ADMINIFY_TD), |
| 121 |
'add_title' => __('Add Menu Link', WP_ADMINIFY_TD), |
| 122 |
'edit_title' => __('Edit Menu Link', WP_ADMINIFY_TD), |
| 123 |
'remove_title' => __('Remove Menu Link', WP_ADMINIFY_TD), |
| 124 |
), |
| 125 |
array( |
| 126 |
'id' => 'menu_icon', |
| 127 |
'type' => 'icon', |
| 128 |
'title' => __('Icon', WP_ADMINIFY_TD), |
| 129 |
'button_title' => __('Add Menu Icon', WP_ADMINIFY_TD), |
| 130 |
'remove_title' => __('Remove Menu Icon', WP_ADMINIFY_TD), |
| 131 |
), |
| 132 |
), |
| 133 |
'default' => $this->get_default_field('quick_menus'), |
| 134 |
); |
| 135 |
} else { |
| 136 |
|
| 137 |
$fields[] = array( |
| 138 |
'id' => 'quick_menus', |
| 139 |
'type' => 'group', |
| 140 |
'title' => '', |
| 141 |
'accordion_title_prefix' => __('Quick Menu: ', WP_ADMINIFY_TD), |
| 142 |
'accordion_title_number' => true, |
| 143 |
'accordion_title_auto' => true, |
| 144 |
'max' => 3, |
| 145 |
'max_text' => __('Get <strong>Pro Version</strong> to Unlock this feature. <a href="https://wpadminify.com/pricing" target="_blank">Upgrade to Pro Now!</a>', WP_ADMINIFY_TD), |
| 146 |
'button_title' => __('Add New Quick Menu', WP_ADMINIFY_TD), |
| 147 |
'fields' => array( |
| 148 |
array( |
| 149 |
'id' => 'menu_title', |
| 150 |
'type' => 'text', |
| 151 |
'title' => __('Menu Title', WP_ADMINIFY_TD), |
| 152 |
), |
| 153 |
array( |
| 154 |
'id' => 'menu_link', |
| 155 |
'type' => 'link', |
| 156 |
'title' => __('Link', WP_ADMINIFY_TD), |
| 157 |
'add_title' => __('Add Menu Link', WP_ADMINIFY_TD), |
| 158 |
'edit_title' => __('Edit Menu Link', WP_ADMINIFY_TD), |
| 159 |
'remove_title' => __('Remove Menu Link', WP_ADMINIFY_TD), |
| 160 |
), |
| 161 |
array( |
| 162 |
'id' => 'menu_icon', |
| 163 |
'type' => 'icon', |
| 164 |
'title' => __('Icon', WP_ADMINIFY_TD), |
| 165 |
'button_title' => __('Add Menu Icon', WP_ADMINIFY_TD), |
| 166 |
'remove_title' => __('Remove Menu Icon', WP_ADMINIFY_TD), |
| 167 |
), |
| 168 |
), |
| 169 |
'default' => $this->get_default_field('quick_menus'), |
| 170 |
); |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
public function quick_menu_settings() |
| 175 |
{ |
| 176 |
|
| 177 |
if (!class_exists('ADMINIFY')) { |
| 178 |
return; |
| 179 |
} |
| 180 |
|
| 181 |
$fields = []; |
| 182 |
$this->quick_menu_user_roles($fields); |
| 183 |
$this->quick_menu_default_settings($fields); |
| 184 |
|
| 185 |
|
| 186 |
// Quick Menu Section |
| 187 |
\ADMINIFY::createSection($this->prefix, array( |
| 188 |
'title' => __('Quick Menu', WP_ADMINIFY_TD), |
| 189 |
'icon' => 'fas fa-plane-departure', |
| 190 |
'parent' => 'module_settings', |
| 191 |
// 'dependency' => array('quick_menu', '==', 'true', '', 'visible'), // Section Dependency |
| 192 |
'fields' => $fields |
| 193 |
)); |
| 194 |
} |
| 195 |
} |
| 196 |
|