| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Classes\Helper; |
| 6 |
use WPAdminify\Inc\Utils; |
| 7 |
use WPAdminify\Inc\Admin\Options\Productivity\Duplicate_Post; |
| 8 |
use WPAdminify\Inc\Admin\Options\Productivity\PostTypesOrder; |
| 9 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 10 |
|
| 11 |
|
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
die; |
| 14 |
} // Cannot access directly. |
| 15 |
|
| 16 |
if (!class_exists('Productivity')) { |
| 17 |
class Productivity extends AdminSettingsModel |
| 18 |
{ |
| 19 |
public function __construct() |
| 20 |
{ |
| 21 |
$this->productivity_settings(); |
| 22 |
} |
| 23 |
|
| 24 |
protected function get_defaults() |
| 25 |
{ |
| 26 |
return [ |
| 27 |
// Admin Notices |
| 28 |
'hide_notices' => false, |
| 29 |
'hide_notices_non_admin' => false, |
| 30 |
'other_notices' => [], |
| 31 |
'screen_help_tab' => [ |
| 32 |
'enable_for_screen' => false, |
| 33 |
'screen_help_data' => [] |
| 34 |
], |
| 35 |
|
| 36 |
'media_attachments' => [ |
| 37 |
'enable_media' => false, |
| 38 |
'media_ininite_scroll' => false, |
| 39 |
'thumbnails_rss_feed' => false, |
| 40 |
// 'allowed_upload_files' => [], |
| 41 |
// 'convert_to_webp' => false, |
| 42 |
// 'featured_to_post' => false, |
| 43 |
// 'media_lowercase' => false, |
| 44 |
], |
| 45 |
'folders' => [ |
| 46 |
'enable_folders' => false, |
| 47 |
'enable_for' => [ 'post', 'page' ], |
| 48 |
'media' => false, |
| 49 |
], |
| 50 |
'admin_pages' => false, |
| 51 |
'dashboard_widgets' => false, |
| 52 |
'post_types_order' => [ |
| 53 |
'enable_pto' => false, |
| 54 |
'pto_taxonomies' => [], |
| 55 |
'pto_posts' => [ 'page' ], |
| 56 |
'pto_media' => false, |
| 57 |
], |
| 58 |
'menu_duplicator' => false, |
| 59 |
'post_duplicator' => [ |
| 60 |
'enable_post_duplicator' => false, |
| 61 |
'post_types' => ['page'], |
| 62 |
'taxonomies' => [], |
| 63 |
], |
| 64 |
// Post Columns |
| 65 |
'custom_admin_columns' => [ |
| 66 |
'enable' => false, |
| 67 |
'post_page_column_thumb_image' => [], |
| 68 |
'columns_data' => [], |
| 69 |
'slug_column_post_types' => [], |
| 70 |
], |
| 71 |
|
| 72 |
// Sidebar Widgets |
| 73 |
'remove_widgets' => [ |
| 74 |
'remove_widgets_type' => 'sidebar', |
| 75 |
'disable_gutenberg_editor' => false, |
| 76 |
'sidebar_widgets_list' => [], |
| 77 |
'dashboard_widgets_list' => [], |
| 78 |
// 'sidebar_widgets_user_roles' => [], |
| 79 |
], |
| 80 |
]; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
/** |
| 85 |
* Admin Notices: Settings |
| 86 |
*/ |
| 87 |
public function admin_notices_settings(&$fields) |
| 88 |
{ |
| 89 |
$fields[] = [ |
| 90 |
'id' => 'productivity_sub_heading', |
| 91 |
'type' => 'subheading', |
| 92 |
'content' => Utils::adminfiy_help_urls( |
| 93 |
'<span></span>', |
| 94 |
'https://wpadminify.com/docs/adminify/productivity/hide-admin-notices', |
| 95 |
'https://www.youtube.com/watch?v=49Cd3dYzYHs', |
| 96 |
'https://www.facebook.com/groups/jeweltheme', |
| 97 |
\WPAdminify\Inc\Admin\AdminSettings::support_url() |
| 98 |
), |
| 99 |
]; |
| 100 |
|
| 101 |
$fields[] = [ |
| 102 |
'id' => 'hide_notices', |
| 103 |
'type' => 'switcher', |
| 104 |
'title' => sprintf(__('Hide "Admin Notices"? %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 105 |
'subtitle' => __('Hide Admin Notices to make your Dashboard Clean. ', 'adminify'), |
| 106 |
'class' => 'adminify-pro-fieldset adminify-pro-notice', |
| 107 |
'text_on' => __('Yes', 'adminify'), |
| 108 |
'text_off' => __('No', 'adminify'), |
| 109 |
'text_width' => 80, |
| 110 |
'default' => $this->get_default_field('hide_notices'), |
| 111 |
]; |
| 112 |
$fields[] = [ |
| 113 |
'id' => 'hide_notices_non_admin', |
| 114 |
'type' => 'checkbox', |
| 115 |
'label' => sprintf(__('Also, Hide for Non-Admin Users? %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 116 |
'title' => ' ', |
| 117 |
'default' => $this->get_default_field('hide_notices_non_admin'), |
| 118 |
'dependency' => ['hide_notices', '==', 'true', 'true'], |
| 119 |
]; |
| 120 |
|
| 121 |
$other_notices_data = [ |
| 122 |
'welcome_panel' => sprintf(__('Remove Welcome Panel %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 123 |
'php_nag' => sprintf(__('Remove "PHP Update Required" Notice %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 124 |
'core_update_notice' => sprintf(__('Hide Core Update Notice %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 125 |
'plugin_update_notice' => sprintf(__('Hide Plugin Update Notice %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 126 |
'theme_update_notice' => sprintf(__('Hide Theme Update Notice %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 127 |
'site_health' => sprintf(__('Disable Site Health checks %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 128 |
]; |
| 129 |
|
| 130 |
$fields[] = [ |
| 131 |
'id' => 'other_notices', |
| 132 |
'type' => 'checkbox', |
| 133 |
'title' => sprintf(__('Other Notices %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 134 |
'subtitle' => __('Show/Remove Dashboard Welcome Panel, Hide WordPress Themes,Plugins,Core Update Notices', 'adminify'), |
| 135 |
'options' => $other_notices_data, |
| 136 |
'default' => $this->get_default_field('other_notices'), |
| 137 |
'dependency' => ['hide_notices', '==', 'true', 'true'], |
| 138 |
]; |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
/** |
| 143 |
* Screen & Help Tab |
| 144 |
*/ |
| 145 |
public function screen_options(&$fields) |
| 146 |
{ |
| 147 |
$screen_options_settings = [ |
| 148 |
'hide_screen_options' => sprintf(__('Hide Screen Options %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 149 |
'hide_help_tab' => sprintf(__('Hide Help Tab %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 150 |
]; |
| 151 |
|
| 152 |
$fields[] = [ |
| 153 |
'id' => 'screen_help_tab', |
| 154 |
'title' => sprintf(__('Screen Options and Help Tab %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 155 |
'subtitle' => __('Screen Options and Help Tab', 'adminify'), |
| 156 |
'type' => 'fieldset', |
| 157 |
'fields' => [ |
| 158 |
[ |
| 159 |
'id' => 'enable_for_screen', |
| 160 |
'type' => 'switcher', |
| 161 |
'title' => __('', 'adminify'), |
| 162 |
'class' => 'adminify-pl-0 adminify-pt-0 adminify-pro-feature', |
| 163 |
'text_on' => __('Show', 'adminify'), |
| 164 |
'text_off' => __('Hide', 'adminify'), |
| 165 |
'text_width' => 80, |
| 166 |
'default' => $this->get_default_field('screen_help_tab')['enable_for_screen'], |
| 167 |
], |
| 168 |
[ |
| 169 |
'id' => 'screen_help_data', |
| 170 |
'type' => 'checkbox', |
| 171 |
'class' => 'adminify-one-col', |
| 172 |
'title' => __('', 'adminify'), |
| 173 |
'options' => $screen_options_settings, |
| 174 |
'default' => $this->get_default_field('screen_help_tab')['screen_help_data'], |
| 175 |
'dependency' => ['enable_for_screen', '==', 'true', 'true'] |
| 176 |
] |
| 177 |
] |
| 178 |
]; |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
/** |
| 183 |
* Folders: Post Types Settings |
| 184 |
*/ |
| 185 |
public function folders_post_types_settings( &$fields ) { |
| 186 |
|
| 187 |
$fields[] = [ |
| 188 |
'id' => 'folders', |
| 189 |
'title' => __('Folders', 'adminify'), |
| 190 |
'subtitle' => __('Folders for Posts/Pages/Custom Post Types etc.', 'adminify'), |
| 191 |
'class' => 'adminify-two-columns', |
| 192 |
'type' => 'fieldset', |
| 193 |
'fields' => [ |
| 194 |
[ |
| 195 |
'id' => 'enable_folders', |
| 196 |
'type' => 'switcher', |
| 197 |
'title' => __('', 'adminify'), |
| 198 |
'class' => 'adminify-pl-0', |
| 199 |
'text_on' => __('Show', 'adminify'), |
| 200 |
'text_off' => __('Hide', 'adminify'), |
| 201 |
'text_width' => 80, |
| 202 |
'default' => $this->get_default_field('folders')['enable_folders'], |
| 203 |
], |
| 204 |
[ |
| 205 |
'id' => 'enable_for', |
| 206 |
'type' => 'checkbox', |
| 207 |
'title' => __('Enable for', 'adminify'), |
| 208 |
'subtitle' => __('Select Post Types for enabling Folders', 'adminify'), |
| 209 |
'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_post_types', |
| 210 |
'default' => $this->get_default_field('folders')['enable_for'], |
| 211 |
'dependency' => ['enable_folders', '==', 'true', 'true'] |
| 212 |
], |
| 213 |
[ |
| 214 |
'id' => 'media', |
| 215 |
'type' => 'switcher', |
| 216 |
'text_on' => __('Yes', 'adminify'), |
| 217 |
'text_off' => __('No', 'adminify'), |
| 218 |
'text_width' => 80, |
| 219 |
'title' => __('Enable Media Folders', 'adminify'), |
| 220 |
'subtitle' => __('Enabling Folders for Media Files', 'adminify'), |
| 221 |
'default' => $this->get_default_field('folders')['media'], |
| 222 |
'dependency' => ['enable_folders', '==', 'true', 'true'] |
| 223 |
] |
| 224 |
|
| 225 |
], |
| 226 |
]; |
| 227 |
|
| 228 |
$fields[] = [ |
| 229 |
'id' => 'admin_pages', |
| 230 |
'type' => 'switcher', |
| 231 |
'title' => sprintf(__('Admin Pages %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 232 |
'class' => 'adminify-pro-notice adminify-pro-fieldset', |
| 233 |
'text_on' => __('Yes', 'adminify'), |
| 234 |
'text_off' => __('No', 'adminify'), |
| 235 |
'text_width' => 80, |
| 236 |
'subtitle' => __('Custom Admin Pages for Creating Top Level or Sub Level Menu. Supports all page builders - Gutenberg, Elementor, Bricks, Oxygen, Divi etc', 'adminify'), |
| 237 |
'default' => $this->get_default_field('admin_pages'), |
| 238 |
]; |
| 239 |
|
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
/** |
| 244 |
* Post Types Order: Options |
| 245 |
*/ |
| 246 |
public function post_types_order_options( &$fields ) { |
| 247 |
|
| 248 |
$post_types_order_fieldset= []; |
| 249 |
|
| 250 |
$post_types_order_fieldset[] = [ |
| 251 |
'id' => 'enable_pto', |
| 252 |
'title' => __('', 'adminify'), |
| 253 |
'class' => 'adminify-pl-0', |
| 254 |
'type' => 'switcher', |
| 255 |
'text_on' => __('Show', 'adminify'), |
| 256 |
'text_off' => __('Hide', 'adminify'), |
| 257 |
'text_width' => 80, |
| 258 |
'default' => $this->get_default_field('post_types_order')['enable_pto'], |
| 259 |
]; |
| 260 |
|
| 261 |
$post_types_order_fieldset[] = [ |
| 262 |
'id' => 'pto_posts', |
| 263 |
'type' => 'checkbox', |
| 264 |
'title' => __( 'Sortable Post Types', 'adminify' ), |
| 265 |
'subtitle' => __( 'Select Post Types for sorting', 'adminify' ), |
| 266 |
'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_post_types', |
| 267 |
'default' => $this->get_default_field('post_types_order')['pto_posts'], |
| 268 |
'dependency' => ['enable_pto', '==', 'true', 'true'], |
| 269 |
]; |
| 270 |
|
| 271 |
$post_types_order_fieldset[] = [ |
| 272 |
'id' => 'pto_media', |
| 273 |
'type' => 'switcher', |
| 274 |
'title' => __( 'Sortable Media Files', 'adminify' ), |
| 275 |
'subtitle' => __( 'Enable/Disable Sortable Media Files on List View', 'adminify' ), |
| 276 |
'text_on' => __('Yes', 'adminify'), |
| 277 |
'text_off' => __('No', 'adminify'), |
| 278 |
'text_width' => 80, |
| 279 |
'default' => $this->get_default_field('post_types_order')[ 'pto_media' ], |
| 280 |
'dependency' => ['enable_pto', '==', 'true', 'true'], |
| 281 |
]; |
| 282 |
|
| 283 |
$post_types_order_fieldset[] = [ |
| 284 |
'id' => 'pto_taxonomies', |
| 285 |
'type' => 'checkbox', |
| 286 |
'title' => sprintf(__('Sortable Taxonomies %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 287 |
'subtitle' => __('Select for Sortable Taxonomies', 'adminify'), |
| 288 |
'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_taxonomies', |
| 289 |
'query_args' => [ |
| 290 |
'orderby' => 'post_title', |
| 291 |
'order' => 'ASC', |
| 292 |
], |
| 293 |
'default' => $this->get_default_field('post_types_order')['pto_taxonomies'], |
| 294 |
'dependency' => ['enable_pto', '==', 'true', 'true'], |
| 295 |
]; |
| 296 |
|
| 297 |
|
| 298 |
// Dashboard Widgets Added |
| 299 |
$fields[] = [ |
| 300 |
'id' => 'dashboard_widgets', |
| 301 |
'type' => 'switcher', |
| 302 |
'title' => __('Dashboard & Welcome Widget', 'adminify'), |
| 303 |
'subtitle' => __('Create Custom Dashboard & Sidebar Widgets', 'adminify'), |
| 304 |
'text_on' => __('Yes', 'adminify'), |
| 305 |
'text_off' => __('No', 'adminify'), |
| 306 |
'text_width' => 80, |
| 307 |
'default' => $this->get_default_field('dashboard_widgets'), |
| 308 |
]; |
| 309 |
|
| 310 |
$fields[] = [ |
| 311 |
'id' => 'post_types_order', |
| 312 |
'title' => __('Post Types Order', 'adminify'), |
| 313 |
'subtitle' => __('Enable/Disable Post Types Orders to increase your productivity.', 'adminify'), |
| 314 |
'type' => 'fieldset', |
| 315 |
'fields' => $post_types_order_fieldset, |
| 316 |
]; |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
public static function get_all_post_types() { |
| 321 |
|
| 322 |
$post_types = get_post_types( |
| 323 |
[ |
| 324 |
'show_ui' => true, |
| 325 |
], |
| 326 |
'objects' |
| 327 |
); |
| 328 |
|
| 329 |
$post_type_names = []; |
| 330 |
foreach ($post_types as $post_type) { |
| 331 |
if (in_array($post_type->name, ['attachment', 'wp_navigation', 'wp_block'])) { |
| 332 |
continue; |
| 333 |
} |
| 334 |
if($post_type->name === 'post' || $post_type->name === 'page' ){ |
| 335 |
$post_type_names[$post_type->name] = $post_type->label; |
| 336 |
} else { |
| 337 |
$is_pro = false; |
| 338 |
if(class_exists('\\WPAdminify\\Pro\\Adminify_Pro')){ |
| 339 |
$is_pro = \WPAdminify\Pro\Adminify_Pro::is_premium(); |
| 340 |
} |
| 341 |
$pro_notice = empty($is_pro) ? Utils::adminify_upgrade_pro_class() : ''; |
| 342 |
$post_type_names[$post_type->name] = $post_type->label . $pro_notice; |
| 343 |
} |
| 344 |
} |
| 345 |
return $post_type_names; |
| 346 |
} |
| 347 |
|
| 348 |
public static function get_all_taxonomies() { |
| 349 |
$taxonomies = get_taxonomies( |
| 350 |
[ |
| 351 |
'show_ui' => true, |
| 352 |
], |
| 353 |
'objects' |
| 354 |
); |
| 355 |
$taxonomy_names = []; |
| 356 |
foreach ( $taxonomies as $taxonomy ) { |
| 357 |
if ( $taxonomy->name == 'post_format' ) { |
| 358 |
continue; |
| 359 |
} |
| 360 |
|
| 361 |
$is_pro = false; |
| 362 |
if (class_exists('\\WPAdminify\\Pro\\Adminify_Pro')) { |
| 363 |
$is_pro = \WPAdminify\Pro\Adminify_Pro::is_premium(); |
| 364 |
} |
| 365 |
$pro_notice = empty($is_pro) ? Utils::adminify_upgrade_pro_class() : ''; |
| 366 |
$taxonomy_names[ $taxonomy->name ] = $taxonomy->label . $pro_notice; |
| 367 |
|
| 368 |
} |
| 369 |
return $taxonomy_names; |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
/** |
| 374 |
* Modules |
| 375 |
* |
| 376 |
*/ |
| 377 |
public function modules_settings(&$fields) |
| 378 |
{ |
| 379 |
$fields[] = [ |
| 380 |
'id' => 'menu_duplicator', |
| 381 |
'type' => 'switcher', |
| 382 |
'title' => __('Menu Duplicator', 'adminify'), |
| 383 |
'subtitle' => __('Enable Menu Duplicator to increase your productivity.', 'adminify'), |
| 384 |
'text_on' => __('Yes', 'adminify'), |
| 385 |
'text_off' => __('No', 'adminify'), |
| 386 |
'text_width' => 80, |
| 387 |
'default' => $this->get_default_field('menu_duplicator'), |
| 388 |
]; |
| 389 |
|
| 390 |
$fields[] = [ |
| 391 |
'id' => 'post_duplicator', |
| 392 |
'title' => __('Post Duplicator', 'adminify'), |
| 393 |
'subtitle' => __('Enable Post/Page/Custom Post Types Duplicator to increase your productivity.', 'adminify'), |
| 394 |
'type' => 'fieldset', |
| 395 |
'default' => $this->get_default_field('post_duplicator'), |
| 396 |
'fields' => [ |
| 397 |
[ |
| 398 |
'id' => 'enable_post_duplicator', |
| 399 |
'type' => 'switcher', |
| 400 |
'title' => __('', 'adminify'), |
| 401 |
'class' => 'adminify-pl-0', |
| 402 |
'text_on' => __('Show', 'adminify'), |
| 403 |
'text_off' => __('Hide', 'adminify'), |
| 404 |
'text_width' => 80, |
| 405 |
'default' => $this->get_default_field('post_duplicator')['enable_post_duplicator'], |
| 406 |
], |
| 407 |
[ |
| 408 |
'id' => 'post_types', |
| 409 |
'type' => 'checkbox', |
| 410 |
'title' => __('Enable for Post Types', 'adminify'), |
| 411 |
'subtitle' => __('Select Post Types for Enabling Duplicate feature', 'adminify'), |
| 412 |
'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_post_types', |
| 413 |
'default' => $this->get_default_field('post_duplicator')['post_types'], |
| 414 |
'dependency' => ['enable_post_duplicator', '==', 'true', 'true'], |
| 415 |
], |
| 416 |
[ |
| 417 |
'id' => 'taxonomies', |
| 418 |
'type' => 'checkbox', |
| 419 |
'title' => sprintf(__('Enable for Taxonomies %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 420 |
'subtitle' => __('Enable for Taxonomies', 'adminify'), |
| 421 |
'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_taxonomies', |
| 422 |
'query_args' => [ |
| 423 |
'orderby' => 'post_title', |
| 424 |
'order' => 'ASC', |
| 425 |
], |
| 426 |
'default' => $this->get_default_field('post_duplicator')['taxonomies'], |
| 427 |
'dependency' => ['enable_post_duplicator', '==', 'true', 'true'], |
| 428 |
] |
| 429 |
|
| 430 |
], |
| 431 |
]; |
| 432 |
} |
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
/** |
| 437 |
* Post/Page Columns |
| 438 |
*/ |
| 439 |
|
| 440 |
public function custom_admin_columns(&$admin_columns) |
| 441 |
{ |
| 442 |
$admin_columns[] = [ |
| 443 |
'id' => 'custom_admin_columns', |
| 444 |
'title' => __('Custom Admin Columns', 'adminify'), |
| 445 |
'subtitle' => __('Add Custom Admin Columns for Post Types or Taxonomies', 'adminify'), |
| 446 |
'type' => 'fieldset', |
| 447 |
'fields' => [ |
| 448 |
[ |
| 449 |
'id' => 'enable', |
| 450 |
'type' => 'switcher', |
| 451 |
'class' => 'adminify-pl-0', |
| 452 |
'title' => __('', 'adminify'), |
| 453 |
'text_on' => __('Show', 'adminify'), |
| 454 |
'text_off' => __('Hide', 'adminify'), |
| 455 |
'text_width' => 80, |
| 456 |
'default' => $this->get_default_field('custom_admin_columns')['enable'], |
| 457 |
], |
| 458 |
[ |
| 459 |
'id' => 'columns_data', |
| 460 |
'type' => 'checkbox', |
| 461 |
'class' => 'adminify-one-col', |
| 462 |
'title' => __('', 'adminify'), |
| 463 |
'options' => [ |
| 464 |
'post_thumb_column' => sprintf(__('Show Post Thumbnails Column? %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 465 |
'post_page_id_column' => sprintf(__('Show Post/Page ID Column. Display "ID" column for post and page table lists. %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 466 |
'comment_id_column' => __('Show "Comment ID" Column for Comment, Also show "Parent ID"', 'adminify'), |
| 467 |
'last_login_column' => sprintf(__('Show "Last Login" Column for Users %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 468 |
'taxonomy_id_column' => __('Show "Taxonomy ID" Column for all possible types of taxonomies', 'adminify'), |
| 469 |
'posts_slug_column' => __('Show "URL Path" Column for Post Types', 'adminify'), |
| 470 |
], |
| 471 |
'default' => $this->get_default_field('custom_admin_columns')['columns_data'], |
| 472 |
'dependency' => ['enable', '==', 'true', true], |
| 473 |
], |
| 474 |
[ |
| 475 |
'id' => 'post_page_column_thumb_image', |
| 476 |
'type' => 'media', |
| 477 |
'class' => 'custom-thumb-image', |
| 478 |
'title' => __('Column Thumbnail Image', 'adminify'), |
| 479 |
'library' => 'image', |
| 480 |
'preview_size' => 'thumbnail', |
| 481 |
'button_title' => __('Add Thumbnail Image', 'adminify'), |
| 482 |
'remove_title' => __('Remove Thumbnail Image', 'adminify'), |
| 483 |
'default' => $this->get_default_field('custom_admin_columns')['post_page_column_thumb_image'], |
| 484 |
'dependency' => array('columns_data', 'any', 'post_thumb_column', 'true'), |
| 485 |
], |
| 486 |
[ |
| 487 |
'id' => 'slug_column_post_types', |
| 488 |
'type' => 'checkbox', |
| 489 |
'title' => __('"URL Path" Column for Post Types', 'adminify'), |
| 490 |
'subtitle' => __('Select Post Types for Enabling "URL Path" Column Slug', 'adminify'), |
| 491 |
'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_post_types', |
| 492 |
'default' => $this->get_default_field('custom_admin_columns')['slug_column_post_types'], |
| 493 |
'dependency' => array('columns_data', 'any', 'posts_slug_column', 'true'), |
| 494 |
], |
| 495 |
] |
| 496 |
]; |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
/** |
| 503 |
* Gutenberg Settings |
| 504 |
*/ |
| 505 |
|
| 506 |
public function gutenberg_settings(&$fields) |
| 507 |
{ |
| 508 |
|
| 509 |
$fields[] = [ |
| 510 |
'id' => 'remove_widgets', |
| 511 |
'title' => __('Widgets Removal', 'adminify'), |
| 512 |
'type' => 'fieldset', |
| 513 |
'subtitle' => __('Remove unwanted Sidebar Widgets & Dashboard Widgets', 'adminify'), |
| 514 |
'fields' => [ |
| 515 |
[ |
| 516 |
'id' => 'remove_widgets_type', |
| 517 |
'type' => 'button_set', |
| 518 |
'class' => 'adminify-pl-0 !adminify-flex', |
| 519 |
'options' => [ |
| 520 |
'sidebar' => __('Sidebar Widgets', 'adminify'), |
| 521 |
'dashboard' => __('Dashboard Widgets', 'adminify'), |
| 522 |
], |
| 523 |
'default' => $this->get_default_field('remove_widgets')['remove_widgets_type'], |
| 524 |
], |
| 525 |
[ |
| 526 |
'id' => 'disable_gutenberg_editor', |
| 527 |
'type' => 'switcher', |
| 528 |
'label' => sprintf(__('<h4>%s</h4>', 'adminify'), __('Disable Gutenberg Editor for Widgets', 'adminify')), |
| 529 |
'class' => 'adminify-pl-0 adminify-col-fit', |
| 530 |
'text_on' => __('Yes', 'adminify'), |
| 531 |
'text_off' => __('No', 'adminify'), |
| 532 |
'text_width' => 80, |
| 533 |
'default' => $this->get_default_field('remove_widgets')['disable_gutenberg_editor'], |
| 534 |
'dependency' => ['remove_widgets_type', '==', 'sidebar', true], |
| 535 |
], |
| 536 |
[ |
| 537 |
'id' => 'sidebar_widgets_list', |
| 538 |
'type' => 'checkbox', |
| 539 |
'class' => 'adminify-one-col', |
| 540 |
'title' => __('', 'adminify'), |
| 541 |
'options' => '\WPAdminify\Inc\Classes\Sidebar_Widgets::render_sidebar_checkboxes', |
| 542 |
'default' => $this->get_default_field('remove_widgets')['sidebar_widgets_list'], |
| 543 |
'dependency' => ['remove_widgets_type|disable_gutenberg_editor', '==|==', 'sidebar|true', true], |
| 544 |
], |
| 545 |
[ |
| 546 |
'id' => 'dashboard_widgets_list', |
| 547 |
'type' => 'checkbox', |
| 548 |
'class' => "adminify-one-col", |
| 549 |
'title' => __('', 'adminify'), |
| 550 |
'options' => '\WPAdminify\Inc\Classes\Remove_DashboardWidgets::render_dashboard_checkboxes', |
| 551 |
'default' => $this->get_default_field('remove_widgets')['dashboard_widgets_list'], |
| 552 |
'dependency' => ['remove_widgets_type', '==', 'dashboard', true], |
| 553 |
], |
| 554 |
] |
| 555 |
]; |
| 556 |
} |
| 557 |
|
| 558 |
|
| 559 |
/** |
| 560 |
* Security: Attachments |
| 561 |
* |
| 562 |
* @return void |
| 563 |
*/ |
| 564 |
public function productivity_attachment_fields(&$attachment_fields) |
| 565 |
{ |
| 566 |
|
| 567 |
$allowed_upload_files_type = [ |
| 568 |
'svg' => sprintf(__('SVG Files %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 569 |
'avif' => sprintf(__('AVIF Files %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 570 |
'ico' => sprintf(__('ICO Files %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 571 |
'webp' => sprintf(__('WEBP Files %s', 'adminify'), Utils::adminify_upgrade_pro_class()), |
| 572 |
]; |
| 573 |
|
| 574 |
$attachment_fields_data = [ |
| 575 |
[ |
| 576 |
'id' => 'enable_media', |
| 577 |
'type' => 'switcher', |
| 578 |
'title' => __('', 'adminify'), |
| 579 |
'class' => 'adminify-pl-0', |
| 580 |
'text_on' => __('Show', 'adminify'), |
| 581 |
'text_off' => __('Hide', 'adminify'), |
| 582 |
'text_width' => 80, |
| 583 |
'default' => $this->get_default_field('media_attachments')['enable_media'], |
| 584 |
], |
| 585 |
[ |
| 586 |
'id' => 'media_ininite_scroll', |
| 587 |
'type' => 'switcher', |
| 588 |
'title' => sprintf(__('Infinite Scroll for Media Library? %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 589 |
'class' => 'adminify-pl-0 adminify-pt-0 adminify-pro-fieldset adminify-pro-notice', |
| 590 |
'text_on' => __('Yes', 'adminify'), |
| 591 |
'text_off' => __('No', 'adminify'), |
| 592 |
'text_width' => 80, |
| 593 |
'subtitle' => __('Re-enable infinite scrolling in the media library\'s grid view to ease navigation through a large collection.', 'adminify'), |
| 594 |
'default' => $this->get_default_field('media_attachments')['media_ininite_scroll'], |
| 595 |
'dependency' => ['enable_media', '==', 'true', true], |
| 596 |
], |
| 597 |
[ |
| 598 |
'id' => 'thumbnails_rss_feed', |
| 599 |
'type' => 'switcher', |
| 600 |
'title' => __('Post Thumbnails on RSS', 'adminify'), |
| 601 |
'class' => 'adminify-pl-0', |
| 602 |
'text_on' => __('Yes', 'adminify'), |
| 603 |
'text_off' => __('No', 'adminify'), |
| 604 |
'text_width' => 80, |
| 605 |
'subtitle' => __('Show/Hide Post Thumbnails on RSS excerpt and Content Feed.', 'adminify'), |
| 606 |
'default' => $this->get_default_field('media_attachments')['thumbnails_rss_feed'], |
| 607 |
'dependency' => ['enable_media', '==', 'true', true], |
| 608 |
], |
| 609 |
// [ |
| 610 |
// 'id' => 'allowed_upload_files', |
| 611 |
// 'type' => 'checkbox', |
| 612 |
// 'class' => 'adminify-pl-0', |
| 613 |
// 'title' => sprintf(__('Allowed Files Uploads %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 614 |
// 'subtitle' => __('Allow SVG/JPEG/WEBP/ICO/AVIF Files Upload', 'adminify'), |
| 615 |
// 'options' => $allowed_upload_files_type, |
| 616 |
// 'default' => $this->get_default_field('media_attachments')['allowed_upload_files'], |
| 617 |
// 'dependency' => ['enable_media', '==', 'true', true], |
| 618 |
// ], |
| 619 |
// [ |
| 620 |
// 'id' => 'convert_to_webp', |
| 621 |
// 'type' => 'switcher', |
| 622 |
// 'class' => 'adminify-pl-0', |
| 623 |
// 'text_on' => __('Yes', 'adminify'), |
| 624 |
// 'text_off' => __('No', 'adminify'), |
| 625 |
// 'text_width' => 80, |
| 626 |
// 'class' => 'adminify-pl-0', |
| 627 |
// 'title' => sprintf(__('Convert to WEBP %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 628 |
// 'subtitle' => __('Convert Uploaded image to WEBP', 'adminify'), |
| 629 |
// 'default' => $this->get_default_field('media_attachments')['convert_to_webp'], |
| 630 |
// 'dependency' => ['enable_media', '==', 'true', true], |
| 631 |
// ], |
| 632 |
// [ |
| 633 |
// 'id' => 'featured_to_post', |
| 634 |
// 'type' => 'switcher', |
| 635 |
// 'class' => 'adminify-pl-0', |
| 636 |
// 'text_on' => __('Yes', 'adminify'), |
| 637 |
// 'text_off' => __('No', 'adminify'), |
| 638 |
// 'text_width' => 80, |
| 639 |
// 'class' => 'adminify-pl-0', |
| 640 |
// 'title' => sprintf(__('Link Featured Images to Post %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 641 |
// 'subtitle' => __('Wrap featured images in your theme in links to posts.', 'adminify'), |
| 642 |
// 'default' => $this->get_default_field('media_attachments')['featured_to_post'], |
| 643 |
// 'dependency' => ['enable_media', '==', 'true', true], |
| 644 |
// ], |
| 645 |
// [ |
| 646 |
// 'id' => 'media_lowercase', |
| 647 |
// 'type' => 'switcher', |
| 648 |
// 'title' => sprintf(__('Lowercase Filenames for Uploads %s', 'adminify'), Utils::adminify_upgrade_pro_badge()), |
| 649 |
// 'subtitle' => __('Make all the filenames of new uploads to lowercase', 'adminify'), |
| 650 |
// 'class' => 'adminify-pl-0', |
| 651 |
// 'text_on' => __('Yes', 'adminify'), |
| 652 |
// 'text_off' => __('No', 'adminify'), |
| 653 |
// 'text_width' => 80, |
| 654 |
// 'class' => 'adminify-pl-0', |
| 655 |
// 'default' => $this->get_default_field('media_attachments')['media_lowercase'], |
| 656 |
// 'dependency' => ['enable_media', '==', 'true', true], |
| 657 |
// ], |
| 658 |
]; |
| 659 |
|
| 660 |
$attachment_fields[] = array( |
| 661 |
'id' => 'media_attachments', |
| 662 |
'type' => 'fieldset', |
| 663 |
'title' => __('Media Settings', 'adminify'), |
| 664 |
'subtitle' => __('Media Attachement Settings', 'adminify'), |
| 665 |
'fields' => $attachment_fields_data, |
| 666 |
// 'default' => $this->get_default_field('media_attachments'), |
| 667 |
); |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
/** |
| 672 |
* Productivity Settings |
| 673 |
* |
| 674 |
* @return void |
| 675 |
*/ |
| 676 |
public function productivity_settings() |
| 677 |
{ |
| 678 |
if (!class_exists('ADMINIFY')) { |
| 679 |
return; |
| 680 |
} |
| 681 |
|
| 682 |
$fields = []; |
| 683 |
|
| 684 |
$this->admin_notices_settings($fields); |
| 685 |
|
| 686 |
$this->screen_options($fields); |
| 687 |
|
| 688 |
// Folders |
| 689 |
$this->folders_post_types_settings( $fields ); |
| 690 |
|
| 691 |
// Post Types Order |
| 692 |
$this->post_types_order_options( $fields ); |
| 693 |
|
| 694 |
// Duplicator Settings |
| 695 |
$this->modules_settings( $fields ); |
| 696 |
|
| 697 |
// Admin Columns |
| 698 |
$this->custom_admin_columns($fields); |
| 699 |
|
| 700 |
// Media Attachment files |
| 701 |
$this->productivity_attachment_fields($fields); |
| 702 |
|
| 703 |
$this->gutenberg_settings($fields); |
| 704 |
|
| 705 |
$fields = apply_filters('adminify_settings/productivity', $fields, $this); |
| 706 |
|
| 707 |
// Productivity Section |
| 708 |
\ADMINIFY::createSection( |
| 709 |
$this->prefix, |
| 710 |
[ |
| 711 |
'title' => __('Productivity', 'adminify'), |
| 712 |
'id' => 'productivity', |
| 713 |
'icon' => 'fas fa-business-time', |
| 714 |
'fields' => $fields, |
| 715 |
] |
| 716 |
); |
| 717 |
} |
| 718 |
} |
| 719 |
} |
| 720 |
|