| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin; |
| 4 |
|
| 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; |
| 18 |
|
| 19 |
// no direct access allowed |
| 20 |
if (!defined('ABSPATH')) { |
| 21 |
exit; |
| 22 |
} |
| 23 |
/** |
| 24 |
* WP Adminify |
| 25 |
* Admin Class |
| 26 |
* |
| 27 |
* @author Jewel Theme <support@jeweltheme.com> |
| 28 |
*/ |
| 29 |
|
| 30 |
if (!class_exists('Admin')) { |
| 31 |
class Admin |
| 32 |
{ |
| 33 |
public $options; |
| 34 |
|
| 35 |
public function __construct() |
| 36 |
{ |
| 37 |
$this->jltwp_adminify_modules_manager(); |
| 38 |
|
| 39 |
// Remove Page Header like - Dashboard, Plugins, Users etc |
| 40 |
add_action('admin_head', [$this, 'remove_page_headline'], 99); |
| 41 |
add_action('admin_head', [$this, 'change_gutenberg_editor_logo'], 99); |
| 42 |
|
| 43 |
// Freemius Hooks |
| 44 |
jltwp_adminify()->add_filter('freemius_pricing_js_path', array($this, 'jltwp_new_freemius_pricing_js')); |
| 45 |
jltwp_adminify()->add_filter('plugin_icon', array($this, 'jltwp_adminify_logo_icon')); |
| 46 |
|
| 47 |
jltwp_adminify()->add_filter('support_forum_url', [$this, 'jltwp_adminify_support_forum_url']); |
| 48 |
|
| 49 |
// Disable deactivation feedback form |
| 50 |
jltwp_adminify()->add_filter('show_deactivation_feedback_form', '__return_false'); |
| 51 |
|
| 52 |
// Disable after deactivation subscription cancellation window |
| 53 |
jltwp_adminify()->add_filter('show_deactivation_subscription_cancellation', '__return_false'); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
/** |
| 58 |
* Adminify Logo |
| 59 |
* |
| 60 |
* @param [type] $logo |
| 61 |
* |
| 62 |
* @return void |
| 63 |
*/ |
| 64 |
public function jltwp_adminify_logo_icon($logo) |
| 65 |
{ |
| 66 |
$logo = WP_ADMINIFY_PATH . '/assets/images/adminify.svg'; |
| 67 |
return $logo; |
| 68 |
} |
| 69 |
|
| 70 |
public function jltwp_new_freemius_pricing_js($default_pricing_js_path) |
| 71 |
{ |
| 72 |
return WP_ADMINIFY_PATH . '/Libs/freemius-pricing/freemius-pricing.js'; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
// Gutenberg Editor WordPress Logo Change |
| 77 |
public function change_gutenberg_editor_logo() |
| 78 |
{ |
| 79 |
|
| 80 |
// it is not a necessary thing but it prevents this CSS to be added on every WordPress admin page |
| 81 |
$screen = get_current_screen(); |
| 82 |
if (!$screen->is_block_editor) { |
| 83 |
return; |
| 84 |
} |
| 85 |
|
| 86 |
$gutenberg_editor_logo = (array) AdminSettings::get_instance()->get('gutenberg_editor_logo'); |
| 87 |
|
| 88 |
echo '<style> |
| 89 |
/* hides the logo */ |
| 90 |
body.is-fullscreen-mode .edit-post-header a.components-button svg{ |
| 91 |
display: none; |
| 92 |
} |
| 93 |
/* adds a custom image */ |
| 94 |
body.is-fullscreen-mode .edit-post-header a.components-button:before{ |
| 95 |
background-image: url( ' . esc_url($gutenberg_editor_logo['url']) . ' ); |
| 96 |
background-size: cover; |
| 97 |
/* you can the image paddings with the parameters below*/ |
| 98 |
top: 10px; |
| 99 |
right: 10px; |
| 100 |
bottom: 10px; |
| 101 |
left: 10px; |
| 102 |
} |
| 103 |
</style>'; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
/** |
| 108 |
* WP Adminify: Modules |
| 109 |
*/ |
| 110 |
public function jltwp_adminify_modules_manager() |
| 111 |
{ |
| 112 |
$this->options = (array) AdminSettings::get_instance()->get(); |
| 113 |
new Modules(); |
| 114 |
new CustomAdminColumns(); |
| 115 |
new MenuStyle($this->options); |
| 116 |
if (!empty($this->options['admin_ui'])) { |
| 117 |
new AdminBar(); |
| 118 |
} |
| 119 |
new Tweaks(); |
| 120 |
new Sidebar_Widgets(); |
| 121 |
new OutputCSS(); |
| 122 |
new ThirdPartyCompatibility(); |
| 123 |
new AdminFooterText(); |
| 124 |
|
| 125 |
// Register Default Dashboard Widgets |
| 126 |
new DashboardWidgets(); |
| 127 |
|
| 128 |
// Version Rollback |
| 129 |
Adminify_Rollback::get_instance(); |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
/** |
| 134 |
* Remove Page Headlines: Dashboard, Plugins, Users |
| 135 |
* |
| 136 |
* @return void |
| 137 |
*/ |
| 138 |
public function remove_page_headline() |
| 139 |
{ |
| 140 |
$screen = get_current_screen(); |
| 141 |
if (empty($screen->id)) { |
| 142 |
return; |
| 143 |
} |
| 144 |
|
| 145 |
if (in_array( |
| 146 |
$screen->id, |
| 147 |
[ |
| 148 |
'dashboard', |
| 149 |
'nav-menus', |
| 150 |
'edit-tags', |
| 151 |
'themes', |
| 152 |
'widgets', |
| 153 |
'plugins', |
| 154 |
'plugin-install', |
| 155 |
'users', |
| 156 |
'user', |
| 157 |
'profile', |
| 158 |
'tools', |
| 159 |
'import', |
| 160 |
'export', |
| 161 |
'export-personal-data', |
| 162 |
'erase-personal-data', |
| 163 |
'options-general', |
| 164 |
'options-writing', |
| 165 |
'options-reading', |
| 166 |
'options-discussion', |
| 167 |
'options-media', |
| 168 |
'options-permalink', |
| 169 |
] |
| 170 |
)) { |
| 171 |
echo '<style>#wpbody-content .wrap > h1,#wpbody-content .wrap > h1.wp-heading-inline{display:none;}</style>'; |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
/** |
| 177 |
* Support Contact URL |
| 178 |
* |
| 179 |
* @param [type] $support_url and Pro Support |
| 180 |
* |
| 181 |
* @return void |
| 182 |
*/ |
| 183 |
public function jltwp_adminify_support_forum_url($support_url) |
| 184 |
{ |
| 185 |
if (jltwp_adminify()->is_premium()) { |
| 186 |
$support_url = 'https://wpadminify.com/contact'; |
| 187 |
} else { |
| 188 |
$support_url = 'https://wordpress.org/support/plugin/adminify/'; |
| 189 |
} |
| 190 |
return $support_url; |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
|