| @@ -1,25 +1,24 @@ | ||
| 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\Utils; | |
| 6 | +use \WPAdminify\Inc\Classes\Tweaks; | |
| 7 | +use \WPAdminify\Inc\Classes\MenuStyle; | |
| 8 | +use \WPAdminify\Inc\Classes\CustomAdminColumns; | |
| 9 | +use \WPAdminify\Inc\Classes\AdminBar; | |
| 10 | +use \WPAdminify\Inc\Classes\DashboardWidgets; | |
| 11 | +use \WPAdminify\Inc\Classes\Sidebar_Widgets; | |
| 12 | +use \WPAdminify\Inc\Classes\OutputCSS; | |
| 13 | +use \WPAdminify\Inc\Classes\ThirdPartyCompatibility; | |
| 14 | +use \WPAdminify\Inc\Classes\AdminFooterText; | |
| 15 | +use \WPAdminify\Inc\Admin\Modules; | |
| 16 | +use WPAdminify\Inc\Classes\Adminify_Rollback; | |
| 17 | +use WPAdminify\Inc\Admin\AdminSettings; | |
| 19 | 18 | |
| 20 | 19 | // no direct access allowed |
| 21 | -if (!defined('ABSPATH')) { | |
| 20 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 22 | 21 | exit; |
| 23 | 22 | } |
| 24 | 23 | /** |
| 25 | 24 | * WP Adminify |
| @@ -27,154 +26,50 @@ | ||
| 27 | 26 | * |
| 28 | 27 | * @author Jewel Theme <support@jeweltheme.com> |
| 29 | 28 | */ |
| 30 | 29 | |
| 31 | -if (!class_exists('Admin')) { | |
| 32 | - class Admin | |
| 33 | - { | |
| 34 | - public $options = []; | |
| 30 | +if ( ! class_exists( 'Admin' ) ) { | |
| 31 | + class Admin { | |
| 35 | 32 | |
| 36 | - public function __construct() | |
| 37 | - { | |
| 38 | - $this->options = AdminSettings::get_instance()->get(); | |
| 33 | + public function __construct() { | |
| 34 | + $this->jltwp_adminify_modules_manager(); | |
| 39 | 35 | |
| 40 | - $this->pxlbsadminify_modules_manager(); | |
| 41 | - | |
| 42 | 36 | // Remove Page Header like - Dashboard, Plugins, Users etc |
| 43 | - // add_action('admin_head', [$this, 'remove_page_headline'], 99); | |
| 37 | + add_action( 'admin_head', [ $this, 'remove_page_headline' ], 99 ); | |
| 44 | 38 | |
| 39 | + jltwp_adminify()->add_filter( 'support_forum_url', [ $this, 'jltwp_adminify_support_forum_url' ] ); | |
| 45 | 40 | |
| 46 | - // Freemius Hooks | |
| 47 | - jltwp_adminify()->add_filter('plugin_icon', array($this, 'pxlbsadminify_logo_icon')); | |
| 48 | - | |
| 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']); | |
| 53 | - | |
| 54 | 41 | // Disable deactivation feedback form |
| 55 | - jltwp_adminify()->add_filter('show_deactivation_feedback_form', '__return_false'); | |
| 42 | + jltwp_adminify()->add_filter( 'show_deactivation_feedback_form', '__return_false' ); | |
| 56 | 43 | |
| 57 | 44 | // Disable after deactivation subscription cancellation window |
| 58 | - jltwp_adminify()->add_filter('show_deactivation_subscription_cancellation', '__return_false'); | |
| 59 | - | |
| 60 | - $this->disable_gutenberg_editor(); | |
| 61 | - | |
| 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); | |
| 64 | - | |
| 45 | + jltwp_adminify()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' ); | |
| 65 | 46 | } |
| 66 | 47 | |
| 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 | 48 | |
| 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 | 49 | /** |
| 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 | 50 | * WP Adminify: Modules |
| 158 | 51 | */ |
| 159 | - public function pxlbsadminify_modules_manager() | |
| 160 | - { | |
| 161 | - // new MenuStyle(); | |
| 52 | + public function jltwp_adminify_modules_manager() { | |
| 53 | + $this->options = (array) AdminSettings::get_instance()->get(); | |
| 162 | 54 | new Modules(); |
| 163 | - new AdminBar(); | |
| 55 | + new CustomAdminColumns(); | |
| 56 | + new MenuStyle( $this->options ); | |
| 57 | + if ( ! empty( $this->options['admin_ui'] ) ) { | |
| 58 | + new AdminBar(); | |
| 59 | + } | |
| 164 | 60 | new Tweaks(); |
| 61 | + new Sidebar_Widgets(); | |
| 165 | 62 | new OutputCSS(); |
| 166 | 63 | new ThirdPartyCompatibility(); |
| 167 | 64 | new AdminFooterText(); |
| 168 | - new Sidebar_Widgets(); | |
| 169 | - new Remove_DashboardWidgets(); | |
| 170 | 65 | |
| 171 | - if (!empty($this->options['admin_ui']) && preg_match('/https:\/\//', site_url()) && is_ssl()) { | |
| 172 | - FrameInit::instance(); | |
| 173 | - } | |
| 66 | + // Register Default Dashboard Widgets | |
| 67 | + new DashboardWidgets(); | |
| 174 | 68 | |
| 175 | 69 | // Version Rollback |
| 176 | - // Adminify_Rollback::get_instance(); | |
| 70 | + Adminify_Rollback::get_instance(); | |
| 71 | + AdminifyPromo::get_instance(); | |
| 177 | 72 | } |
| 178 | 73 | |
| 179 | 74 | |
| 180 | 75 | /** |
| @@ -181,16 +76,15 @@ | ||
| 181 | 76 | * Remove Page Headlines: Dashboard, Plugins, Users |
| 182 | 77 | * |
| 183 | 78 | * @return void |
| 184 | 79 | */ |
| 185 | - public function remove_page_headline() | |
| 186 | - { | |
| 80 | + public function remove_page_headline() { | |
| 187 | 81 | $screen = get_current_screen(); |
| 188 | - if (empty($screen->id)) { | |
| 82 | + if ( empty( $screen->id ) ) { | |
| 189 | 83 | return; |
| 190 | 84 | } |
| 191 | 85 | |
| 192 | - if (in_array( | |
| 86 | + if ( in_array( | |
| 193 | 87 | $screen->id, |
| 194 | 88 | [ |
| 195 | 89 | 'dashboard', |
| 196 | 90 | 'nav-menus', |
| @@ -213,79 +107,27 @@ | ||
| 213 | 107 | 'options-discussion', |
| 214 | 108 | 'options-media', |
| 215 | 109 | 'options-permalink', |
| 216 | 110 | ] |
| 217 | - )) { | |
| 218 | - echo '<style>#wpbody-content .wrap > h1,#wpbody-content .wrap > h1.wp-heading-inline{display:none;}</style>'; | |
| 111 | + ) ) { | |
| 112 | + echo Utils::wp_kses_custom( '<style>#wpbody-content .wrap h1,#wpbody-content .wrap h1.wp-heading-inline{display:none;}</style>' ); | |
| 219 | 113 | } |
| 220 | 114 | } |
| 221 | 115 | |
| 222 | 116 | |
| 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 | 117 | /** |
| 246 | - * Handle support menu redirect | |
| 247 | - * This method is called when the support page would normally load | |
| 118 | + * Support Forum URL | |
| 119 | + * | |
| 120 | + * @param [type] $support_url and Pro Support | |
| 121 | + * | |
| 122 | + * @return void | |
| 248 | 123 | */ |
| 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; | |
| 124 | + public function jltwp_adminify_support_forum_url( $support_url ) { | |
| 125 | + if ( jltwp_adminify()->is_premium() ) { | |
| 126 | + $support_url = 'https://wpadminify.com/support'; | |
| 127 | + } else { | |
| 128 | + $support_url = 'https://wordpress.org/support/plugin/adminify/'; | |
| 273 | 129 | } |
| 130 | + return $support_url; | |
| 274 | 131 | } |
| 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 | 132 | } |
| 291 | 133 | } |