| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils ; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel ; |
| 7 |
if ( !defined( 'ABSPATH' ) ) { |
| 8 |
die; |
| 9 |
} |
| 10 |
// Cannot access directly. |
| 11 |
if ( !class_exists( 'DismissNotices' ) ) { |
| 12 |
class DismissNotices extends AdminSettingsModel |
| 13 |
{ |
| 14 |
public function __construct() |
| 15 |
{ |
| 16 |
$this->admin_notices_options(); |
| 17 |
} |
| 18 |
|
| 19 |
public function get_defaults() |
| 20 |
{ |
| 21 |
return [ |
| 22 |
'admin_notice_user_roles' => [], |
| 23 |
'hide_notices' => false, |
| 24 |
'remove_welcome_panel' => false, |
| 25 |
'remove_php_update_required_nag' => false, |
| 26 |
'remove_try_gutenberg_panel' => false, |
| 27 |
'core_update_notice' => false, |
| 28 |
'plugin_update_notice' => false, |
| 29 |
'theme_update_notice' => false, |
| 30 |
]; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* User Roles |
| 35 |
*/ |
| 36 |
public function admin_notices_user_roles( &$fields ) |
| 37 |
{ |
| 38 |
$fields[] = [ |
| 39 |
'type' => 'subheading', |
| 40 |
'content' => Utils::adminfiy_help_urls( |
| 41 |
__( 'Admin Notices Settings', 'adminify' ), |
| 42 |
'https://wpadminify.com/kb/disable-admin-notice-in-wordpress-dashboard/', |
| 43 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 44 |
'https://www.facebook.com/groups/jeweltheme', |
| 45 |
'https://wpadminify.com/support/' |
| 46 |
), |
| 47 |
]; |
| 48 |
$fields[] = [ |
| 49 |
'id' => 'admin_notice_user_roles', |
| 50 |
'type' => 'select', |
| 51 |
'title' => __( 'Visible for', 'adminify' ), |
| 52 |
'placeholder' => __( 'Select User roles you want to show', 'adminify' ), |
| 53 |
'options' => 'roles', |
| 54 |
'multiple' => true, |
| 55 |
'chosen' => true, |
| 56 |
'default' => $this->get_default_field( 'admin_notice_user_roles' ), |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Admin Notices: Settings |
| 62 |
*/ |
| 63 |
public function admin_notices_settings( &$fields ) |
| 64 |
{ |
| 65 |
$fields[] = [ |
| 66 |
'type' => 'notice', |
| 67 |
'title' => __( 'Hide All "Admin Notices"?', 'adminify' ), |
| 68 |
'subtitle' => sprintf( __( 'Move all Admin Notices to <a href="%s">Dashboard->Notices</a>.', 'adminify' ), esc_url( admin_url( 'index.php?page=wp-adminify-notices' ) ) ), |
| 69 |
'style' => 'warning', |
| 70 |
'content' => Utils::adminify_upgrade_pro(), |
| 71 |
]; |
| 72 |
$fields[] = [ |
| 73 |
'id' => 'remove_welcome_panel', |
| 74 |
'type' => 'switcher', |
| 75 |
'title' => __( 'Remove Welcome Panel', 'adminify' ), |
| 76 |
'label' => __( 'Show/Remove Dashboard Welcome Panel', 'adminify' ), |
| 77 |
'text_on' => 'Yes', |
| 78 |
'text_off' => 'No', |
| 79 |
'text_width' => 80, |
| 80 |
'default' => $this->get_default_field( 'remove_welcome_panel' ), |
| 81 |
]; |
| 82 |
$fields[] = [ |
| 83 |
'type' => 'notice', |
| 84 |
'title' => __( 'Remove "PHP Update Required" Notice', 'adminify' ), |
| 85 |
'label' => __( 'Show/Remove "PHP Update Required" Notice', 'adminify' ), |
| 86 |
'style' => 'warning', |
| 87 |
'content' => Utils::adminify_upgrade_pro(), |
| 88 |
]; |
| 89 |
$fields[] = [ |
| 90 |
'id' => 'remove_try_gutenberg_panel', |
| 91 |
'type' => 'switcher', |
| 92 |
'title' => __( 'Remove "Try Gutenberg" Panel', 'adminify' ), |
| 93 |
'label' => __( 'Show/Remove "Try Gutenberg" Panel', 'adminify' ), |
| 94 |
'text_on' => 'Yes', |
| 95 |
'text_off' => 'No', |
| 96 |
'text_width' => 80, |
| 97 |
'default' => $this->get_default_field( 'remove_try_gutenberg_panel' ), |
| 98 |
]; |
| 99 |
$fields[] = [ |
| 100 |
'type' => 'subheading', |
| 101 |
'content' => __( 'WordPress Core/Theme/Plugin Notices', 'adminify' ), |
| 102 |
]; |
| 103 |
$fields[] = [ |
| 104 |
'type' => 'notice', |
| 105 |
'title' => __( 'Hide Core Update Notice', 'adminify' ), |
| 106 |
'label' => __( 'Show/Hide Core Update Notice', 'adminify' ), |
| 107 |
'style' => 'warning', |
| 108 |
'content' => Utils::adminify_upgrade_pro(), |
| 109 |
]; |
| 110 |
$fields[] = [ |
| 111 |
'type' => 'notice', |
| 112 |
'title' => __( 'Hide Plugin Update Notice', 'adminify' ), |
| 113 |
'label' => __( 'Show/Hide Plugin Update Notice', 'adminify' ), |
| 114 |
'style' => 'warning', |
| 115 |
'content' => Utils::adminify_upgrade_pro(), |
| 116 |
]; |
| 117 |
$fields[] = [ |
| 118 |
'type' => 'notice', |
| 119 |
'title' => __( 'Hide Theme Update Notice', 'adminify' ), |
| 120 |
'label' => __( 'Show/Hide Theme Update Notice', 'adminify' ), |
| 121 |
'style' => 'warning', |
| 122 |
'content' => Utils::adminify_upgrade_pro(), |
| 123 |
]; |
| 124 |
} |
| 125 |
|
| 126 |
public function admin_notices_options() |
| 127 |
{ |
| 128 |
if ( !class_exists( 'ADMINIFY' ) ) { |
| 129 |
return; |
| 130 |
} |
| 131 |
$fields = []; |
| 132 |
$this->admin_notices_user_roles( $fields ); |
| 133 |
$this->admin_notices_settings( $fields ); |
| 134 |
// Admin Notices Section |
| 135 |
\ADMINIFY::createSection( $this->prefix, [ |
| 136 |
'title' => __( 'Admin Notices', 'adminify' ), |
| 137 |
'icon' => 'fas fa-exclamation-circle', |
| 138 |
'id' => 'adminify-admin-notices', |
| 139 |
'fields' => $fields, |
| 140 |
] ); |
| 141 |
} |
| 142 |
|
| 143 |
} |
| 144 |
} |