| @@ -1,27 +1,23 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Admin; | |
| 3 | +namespace WPAdminify\Inc\Admin; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Inc\Utils; | |
| 6 | -use \PXLBSAdminify\Inc\Classes\CustomAdminColumns; | |
| 7 | -use \PXLBSAdminify\Inc\Classes\Tweaks; | |
| 8 | -use \PXLBSAdminify\Inc\Classes\MenuStyle; | |
| 9 | -use \PXLBSAdminify\Inc\Classes\AdminBar; | |
| 10 | -use \PXLBSAdminify\Inc\Classes\OutputCSS; | |
| 11 | -use \PXLBSAdminify\Inc\Classes\ThirdPartyCompatibility; | |
| 12 | -use \PXLBSAdminify\Inc\Classes\AdminFooterText; | |
| 13 | -use \PXLBSAdminify\Inc\Admin\Modules; | |
| 14 | -use \PXLBSAdminify\Inc\Classes\Sidebar_Widgets; | |
| 15 | -use \PXLBSAdminify\Inc\Classes\Remove_DashboardWidgets; | |
| 16 | -use PXLBSAdminify\Inc\Classes\Adminify_Rollback; | |
| 17 | -use PXLBSAdminify\Inc\Admin\AdminSettings; | |
| 18 | -use PXLBSAdminify\Inc\Admin\Frames\Init as FrameInit; | |
| 5 | +use \WPAdminify\Inc\Classes\Tweaks; | |
| 6 | +use \WPAdminify\Inc\Classes\MenuStyle; | |
| 7 | +use \WPAdminify\Inc\Classes\CustomAdminColumns; | |
| 8 | +use \WPAdminify\Inc\Classes\AdminBar; | |
| 9 | +use \WPAdminify\Inc\Classes\DashboardWidgets; | |
| 10 | +use \WPAdminify\Inc\Classes\Sidebar_Widgets; | |
| 11 | +use \WPAdminify\Inc\Classes\OutputCSS; | |
| 12 | +use \WPAdminify\Inc\Classes\ThirdPartyCompatibility; | |
| 13 | +use \WPAdminify\Inc\Classes\AdminFooterText; | |
| 14 | +use \WPAdminify\Inc\Admin\Modules; | |
| 15 | +use WPAdminify\Inc\Classes\Adminify_Rollback; | |
| 16 | +use WPAdminify\Inc\Admin\AdminSettings; | |
| 19 | 17 | |
| 20 | 18 | // no direct access allowed |
| 21 | -if (!defined('ABSPATH')) { | |
| 22 | - exit; | |
| 23 | -} | |
| 19 | +if (!defined('ABSPATH')) exit; | |
| 24 | 20 | /** |
| 25 | 21 | * WP Adminify |
| 26 | 22 | * Admin Class |
| 27 | 23 | * |
| @@ -28,264 +24,108 @@ | ||
| 28 | 24 | * @author Jewel Theme <support@jeweltheme.com> |
| 29 | 25 | */ |
| 30 | 26 | |
| 31 | 27 | if (!class_exists('Admin')) { |
| 32 | - class Admin | |
| 33 | - { | |
| 34 | - public $options = []; | |
| 28 | + class Admin | |
| 29 | + { | |
| 30 | + public function __construct() | |
| 31 | + { | |
| 32 | + $this->jltwp_adminify_modules_manager(); | |
| 35 | 33 | |
| 36 | - public function __construct() | |
| 37 | - { | |
| 38 | - $this->options = AdminSettings::get_instance()->get(); | |
| 34 | + //Remove Page Header like - Dashboard, Plugins, Users etc | |
| 35 | + add_action('admin_head', [$this, 'remove_page_headline'], 99); | |
| 39 | 36 | |
| 40 | - $this->pxlbsadminify_modules_manager(); | |
| 37 | + jltwp_adminify()->add_filter('support_forum_url', [$this, 'jltwp_adminify_support_forum_url']); | |
| 41 | 38 | |
| 42 | - // Remove Page Header like - Dashboard, Plugins, Users etc | |
| 43 | - // add_action('admin_head', [$this, 'remove_page_headline'], 99); | |
| 39 | + //Disable deactivation feedback form | |
| 40 | + jltwp_adminify()->add_filter('show_deactivation_feedback_form', '__return_false'); | |
| 44 | 41 | |
| 42 | + //Disable after deactivation subscription cancellation window | |
| 43 | + jltwp_adminify()->add_filter('show_deactivation_subscription_cancellation', '__return_false'); | |
| 44 | + } | |
| 45 | 45 | |
| 46 | - // Freemius Hooks | |
| 47 | - jltwp_adminify()->add_filter('plugin_icon', array($this, 'pxlbsadminify_logo_icon')); | |
| 48 | 46 | |
| 49 | - add_action('admin_menu', array($this, 'support_menu'), 1100); | |
| 50 | - add_action('network_admin_menu', array($this, 'support_menu'), 1100); | |
| 51 | - add_action('admin_menu', [$this, 'submenu_link_new_tab']); | |
| 52 | - // jltwp_adminify()->add_filter('support_forum_url', [$this, 'pxlbsadminify_support_forum_url']); | |
| 47 | + /** | |
| 48 | + * WP Adminify: Modules | |
| 49 | + */ | |
| 50 | + public function jltwp_adminify_modules_manager() | |
| 51 | + { | |
| 52 | + $this->options = (array) AdminSettings::get_instance()->get(); | |
| 53 | + new Modules(); | |
| 54 | + new CustomAdminColumns(); | |
| 55 | + new MenuStyle(); | |
| 56 | + if (!empty($this->options['admin_ui'])) { | |
| 57 | + new AdminBar(); | |
| 58 | + } | |
| 59 | + new Tweaks(); | |
| 60 | + new Sidebar_Widgets(); | |
| 61 | + new OutputCSS(); | |
| 62 | + new ThirdPartyCompatibility(); | |
| 63 | + new AdminFooterText(); | |
| 53 | 64 | |
| 54 | - // Disable deactivation feedback form | |
| 55 | - jltwp_adminify()->add_filter('show_deactivation_feedback_form', '__return_false'); | |
| 65 | + // Register Default Dashboard Widgets | |
| 66 | + new DashboardWidgets(); | |
| 56 | 67 | |
| 57 | - // Disable after deactivation subscription cancellation window | |
| 58 | - jltwp_adminify()->add_filter('show_deactivation_subscription_cancellation', '__return_false'); | |
| 68 | + // Version Rollback | |
| 69 | + Adminify_Rollback::get_instance(); | |
| 70 | + AdminifyPromo::get_instance(); | |
| 71 | + } | |
| 59 | 72 | |
| 60 | - $this->disable_gutenberg_editor(); | |
| 61 | 73 | |
| 62 | - add_filter('show_admin_bar', [ $this, 'pxlbsadminify_removeAdminBar'], PHP_INT_MAX); | |
| 63 | - add_action('wp_head', [ $this,'pxlbsadminify_remove_header_for_baknd'], PHP_INT_MAX); | |
| 74 | + /** | |
| 75 | + * Remove Page Headlines: Dashboard, Plugins, Users | |
| 76 | + * | |
| 77 | + * @return void | |
| 78 | + */ | |
| 79 | + public function remove_page_headline() | |
| 80 | + { | |
| 81 | + $screen = get_current_screen(); | |
| 82 | + if (empty($screen->id)) { | |
| 83 | + return; | |
| 84 | + } | |
| 64 | 85 | |
| 65 | - } | |
| 86 | + if (in_array($screen->id, array( | |
| 87 | + 'dashboard', | |
| 88 | + 'nav-menus', | |
| 89 | + 'edit-tags', | |
| 90 | + 'themes', | |
| 91 | + 'widgets', | |
| 92 | + 'plugins', | |
| 93 | + 'plugin-install', | |
| 94 | + 'users', | |
| 95 | + 'user', | |
| 96 | + 'profile', | |
| 97 | + 'tools', | |
| 98 | + 'import', | |
| 99 | + 'export', | |
| 100 | + 'export-personal-data', | |
| 101 | + 'erase-personal-data', | |
| 102 | + 'options-general', | |
| 103 | + 'options-writing', | |
| 104 | + 'options-reading', | |
| 105 | + 'options-discussion', | |
| 106 | + 'options-media', | |
| 107 | + 'options-permalink' | |
| 108 | + ))) { | |
| 109 | + echo '<style>#wpbody-content .wrap h1,#wpbody-content .wrap h1.wp-heading-inline{display:none;}</style>'; | |
| 110 | + } | |
| 111 | + } | |
| 66 | 112 | |
| 67 | - function pxlbsadminify_removeAdminBar($status) | |
| 68 | - { | |
| 69 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. | |
| 70 | - if (!empty($_GET['bknd']) && sanitize_text_field(wp_unslash($_GET['bknd']))) { | |
| 71 | - return false; | |
| 72 | - } | |
| 73 | - return $status; | |
| 74 | - } | |
| 75 | 113 | |
| 76 | - function pxlbsadminify_remove_header_for_baknd() { | |
| 77 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. | |
| 78 | - if (isset($_GET['bknd']) && sanitize_text_field(wp_unslash($_GET['bknd'])) == '1') { | |
| 79 | - echo '<script> | |
| 80 | - jQuery(document).ready(function($){ | |
| 81 | - $("header").remove(); | |
| 82 | - $("footer").remove(); | |
| 83 | - }) | |
| 84 | - </script>'; | |
| 85 | - } | |
| 86 | - } | |
| 87 | - | |
| 88 | - public function disable_gutenberg_editor() | |
| 89 | - { | |
| 90 | - // Sidebar Widgets Remove | |
| 91 | - if (!empty($this->options['remove_widgets']['disable_gutenberg_editor'])) { | |
| 92 | - // Disable Gutenberg for Block Editor | |
| 93 | - add_filter('gutenberg_use_widgets_block_editor', '__return_false'); | |
| 94 | - // Disable Gutenberg for widgets. | |
| 95 | - add_filter('use_widgets_block_editor', '__return_false'); | |
| 96 | - } | |
| 97 | - | |
| 98 | - // Disable Block Editor Gutenberg | |
| 99 | - if (!empty($this->options["disable_gutenberg"]['disable_for']) && in_array('block_editor', $this->options["disable_gutenberg"]['disable_for'])) { | |
| 100 | - add_filter('use_block_editor_for_post', '__return_false'); | |
| 101 | - add_action('wp_enqueue_scripts', [$this, 'remove_backend_gutenberg_scripts'], 20); | |
| 102 | - } | |
| 103 | - | |
| 104 | - // Remove all scripts and styles added by Gutenberg | |
| 105 | - if (isset($this->options["disable_gutenberg"]['disable_gutenberg_enable']) && $this->options["disable_gutenberg"]['disable_gutenberg_enable'] && in_array('remove_gutenberg_scripts', $this->options["disable_gutenberg"]['disable_for'])) { | |
| 106 | - add_action('wp_enqueue_scripts', [$this, 'remove_gutenberg_scripts']); | |
| 107 | - remove_action('enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles'); | |
| 108 | - } | |
| 109 | - } | |
| 110 | - | |
| 111 | - | |
| 112 | - // Dequeue all Frontend scripts and styles added by Gutenberg | |
| 113 | - public function remove_gutenberg_scripts() | |
| 114 | - { | |
| 115 | - wp_dequeue_style('wp-block-library'); | |
| 116 | - wp_dequeue_style('wc-block-style'); // Remove WooCommerce block CSS | |
| 117 | - | |
| 118 | - // Remove Inline CSS | |
| 119 | - // wp_deregister_style('wp-block-library-inline'); | |
| 120 | - // wp_dequeue_style('wp-block-library-inline'); | |
| 121 | - } | |
| 122 | - | |
| 123 | - /** | |
| 124 | - * Remove Gutenberg Scripts | |
| 125 | - * | |
| 126 | - * @return void | |
| 127 | - */ | |
| 128 | - public function remove_backend_gutenberg_scripts() | |
| 129 | - { | |
| 130 | - if (is_admin()) { | |
| 131 | - // Remove CSS on the front end. | |
| 132 | - wp_dequeue_style('wp-block-library'); | |
| 133 | - | |
| 134 | - // Remove Gutenberg theme. | |
| 135 | - wp_dequeue_style('wp-block-library-theme'); | |
| 136 | - | |
| 137 | - // Remove inline global CSS on the front end. | |
| 138 | - wp_dequeue_style('global-styles'); | |
| 139 | - } | |
| 140 | - } | |
| 141 | - | |
| 142 | - /** | |
| 143 | - * Adminify Logo | |
| 144 | - * | |
| 145 | - * @param [type] $logo | |
| 146 | - * | |
| 147 | - * @return void | |
| 148 | - */ | |
| 149 | - public function pxlbsadminify_logo_icon($logo) | |
| 150 | - { | |
| 151 | - $logo = PXLBSADMINIFY_PATH . '/assets/images/adminify.svg'; | |
| 152 | - return $logo; | |
| 153 | - } | |
| 154 | - | |
| 155 | - | |
| 156 | - /** | |
| 157 | - * WP Adminify: Modules | |
| 158 | - */ | |
| 159 | - public function pxlbsadminify_modules_manager() | |
| 160 | - { | |
| 161 | - // new MenuStyle(); | |
| 162 | - new Modules(); | |
| 163 | - new AdminBar(); | |
| 164 | - new Tweaks(); | |
| 165 | - new OutputCSS(); | |
| 166 | - new ThirdPartyCompatibility(); | |
| 167 | - new AdminFooterText(); | |
| 168 | - new Sidebar_Widgets(); | |
| 169 | - new Remove_DashboardWidgets(); | |
| 170 | - | |
| 171 | - if (!empty($this->options['admin_ui']) && preg_match('/https:\/\//', site_url()) && is_ssl()) { | |
| 172 | - FrameInit::instance(); | |
| 173 | - } | |
| 174 | - | |
| 175 | - // Version Rollback | |
| 176 | - // Adminify_Rollback::get_instance(); | |
| 177 | - } | |
| 178 | - | |
| 179 | - | |
| 180 | - /** | |
| 181 | - * Remove Page Headlines: Dashboard, Plugins, Users | |
| 182 | - * | |
| 183 | - * @return void | |
| 184 | - */ | |
| 185 | - public function remove_page_headline() | |
| 186 | - { | |
| 187 | - $screen = get_current_screen(); | |
| 188 | - if (empty($screen->id)) { | |
| 189 | - return; | |
| 190 | - } | |
| 191 | - | |
| 192 | - if (in_array( | |
| 193 | - $screen->id, | |
| 194 | - [ | |
| 195 | - 'dashboard', | |
| 196 | - 'nav-menus', | |
| 197 | - 'edit-tags', | |
| 198 | - 'themes', | |
| 199 | - 'widgets', | |
| 200 | - 'plugins', | |
| 201 | - 'plugin-install', | |
| 202 | - 'users', | |
| 203 | - 'user', | |
| 204 | - 'profile', | |
| 205 | - 'tools', | |
| 206 | - 'import', | |
| 207 | - 'export', | |
| 208 | - 'export-personal-data', | |
| 209 | - 'erase-personal-data', | |
| 210 | - 'options-general', | |
| 211 | - 'options-writing', | |
| 212 | - 'options-reading', | |
| 213 | - 'options-discussion', | |
| 214 | - 'options-media', | |
| 215 | - 'options-permalink', | |
| 216 | - ] | |
| 217 | - )) { | |
| 218 | - echo '<style>#wpbody-content .wrap > h1,#wpbody-content .wrap > h1.wp-heading-inline{display:none;}</style>'; | |
| 219 | - } | |
| 220 | - } | |
| 221 | - | |
| 222 | - | |
| 223 | - public function support_menu() | |
| 224 | - { | |
| 225 | - // $this->submenu_link_new_tab(); | |
| 226 | - // $adminify_ui = AdminSettings::get_instance()->get('admin_ui'); | |
| 227 | - $support_url = 'adminify-support'; | |
| 228 | - // if($adminify_ui ) { | |
| 229 | - // $support_urlsss = \PXLBSAdminify\Inc\Admin\AdminSettings::support_url(); | |
| 230 | - // } | |
| 231 | - add_submenu_page( | |
| 232 | - 'wp-adminify-settings', // Ex. wp-adminify-settings | |
| 233 | - __('Get Support', 'adminify'), | |
| 234 | - __('Support', 'adminify'), | |
| 235 | - 'manage_options', | |
| 236 | - $support_url, | |
| 237 | - [$this, 'support_menu_redirect'], | |
| 238 | - 60 | |
| 239 | - ); | |
| 240 | - | |
| 241 | - // Hook into admin_init to handle the redirect early, before any output | |
| 242 | - add_action('admin_init', [$this, 'handle_support_redirect']); | |
| 243 | - } | |
| 244 | - | |
| 245 | - /** | |
| 246 | - * Handle support menu redirect | |
| 247 | - * This method is called when the support page would normally load | |
| 248 | - */ | |
| 249 | - public function support_menu_redirect() | |
| 250 | - { | |
| 251 | - // This function body will never execute because we redirect in admin_init | |
| 252 | - // But it needs to exist as the callback | |
| 253 | - } | |
| 254 | - | |
| 255 | - /** | |
| 256 | - * Handle the actual redirect in admin_init before any output | |
| 257 | - */ | |
| 258 | - public function handle_support_redirect() | |
| 259 | - { | |
| 260 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. | |
| 261 | - if (isset($_GET['page']) && sanitize_key(wp_unslash($_GET['page'])) === 'adminify-support') { | |
| 262 | - $redirect_url = \PXLBSAdminify\Inc\Admin\AdminSettings::support_url(); | |
| 263 | - | |
| 264 | - // Add the URLs to the allowed redirect hosts filter | |
| 265 | - add_filter('allowed_redirect_hosts', function($hosts) { | |
| 266 | - $hosts[] = 'wpadminify.com'; | |
| 267 | - $hosts[] = 'wordpress.org'; | |
| 268 | - return $hosts; | |
| 269 | - }); | |
| 270 | - | |
| 271 | - wp_safe_redirect($redirect_url, 301); | |
| 272 | - exit; | |
| 273 | - } | |
| 274 | - } | |
| 275 | - | |
| 276 | - | |
| 277 | - public function submenu_link_new_tab() | |
| 278 | - { | |
| 279 | - add_action('admin_footer', function () { | |
| 280 | -?> | |
| 281 | - <script type="text/javascript"> | |
| 282 | - jQuery(document).ready(function($) { | |
| 283 | - $('a[href="admin.php?page=adminify-support"]').attr('target', '_blank'); | |
| 284 | - }); | |
| 285 | - </script> | |
| 286 | -<?php | |
| 287 | - }); | |
| 288 | - } | |
| 289 | - | |
| 290 | - } | |
| 114 | + /** | |
| 115 | + * Support Forum URL | |
| 116 | + * | |
| 117 | + * @param [type] $support_url and Pro Support | |
| 118 | + * | |
| 119 | + * @return void | |
| 120 | + */ | |
| 121 | + public function jltwp_adminify_support_forum_url($support_url) | |
| 122 | + { | |
| 123 | + if (jltwp_adminify()->is_premium()) { | |
| 124 | + $support_url = 'https://wpadminify.com/support'; | |
| 125 | + } else { | |
| 126 | + $support_url = 'https://wordpress.org/support/plugin/adminify/'; | |
| 127 | + } | |
| 128 | + return $support_url; | |
| 129 | + } | |
| 130 | + } | |
| 291 | 131 | } |