WebPageCache
7 months ago
external
2 months ago
ExcludeJsFromDelay.php
2 years ago
OptimizerBanner.php
11 months ago
OptimizerBase.php
2 years ago
OptimizerCSSMin.php
2 years ago
OptimizerCache.php
1 year ago
OptimizerCacheStructure.php
2 years ago
OptimizerCriticalCss.php
1 year ago
OptimizerElementor.php
2 years ago
OptimizerFonts.php
2 years ago
OptimizerImages.php
1 year ago
OptimizerLogger.php
1 year ago
OptimizerMain.php
2 months ago
OptimizerOnInit.php
11 months ago
OptimizerScripts.php
2 years ago
OptimizerSettings.php
2 months ago
OptimizerStyles.php
2 years ago
OptimizerUrl.php
1 year ago
OptimizerUtils.php
2 months ago
OptimizerWhiteLabel.php
2 years ago
OptimizerWhiteLabel.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | namespace TenWebOptimizer; |
| 4 | |
| 5 | class OptimizerWhiteLabel |
| 6 | { |
| 7 | private static $instance = null; |
| 8 | |
| 9 | private $white_labeled_plugins = [ |
| 10 | 'tenweb-speed-optimizer/tenweb_speed_optimizer.php', |
| 11 | ]; |
| 12 | |
| 13 | private $whitelabeled_menus = [ |
| 14 | '10web Booster' |
| 15 | ]; |
| 16 | |
| 17 | private $top_bar_menus = [ |
| 18 | 'two_options' |
| 19 | ]; |
| 20 | |
| 21 | private $company_name = TWO_SO_ORGANIZATION_NAME; |
| 22 | |
| 23 | public function register_hooks() |
| 24 | { |
| 25 | if (!defined('TWO_SO_ORGANIZATION_NAME')) { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | add_action('pre_current_active_plugins', [$this, 'whiteLabelPluginsList'], 999999); |
| 30 | add_action('admin_menu', [$this, 'whiteLabelTopMenus'], 999999); |
| 31 | add_action('admin_bar_menu', [$this, 'whiteLabelAdminBarMenus'], 999999); |
| 32 | } |
| 33 | |
| 34 | public function whiteLabelPluginsList() |
| 35 | { |
| 36 | global $wp_list_table; |
| 37 | |
| 38 | $plugins = $wp_list_table->items; |
| 39 | |
| 40 | $plugin = $plugins[$this->white_labeled_plugins[0]]; |
| 41 | $slug = $this->white_labeled_plugins[0]; |
| 42 | $main_php = explode('/', $slug); |
| 43 | |
| 44 | if (is_array($main_php)) { |
| 45 | $main_php = end($main_php); |
| 46 | } |
| 47 | $name = str_ireplace('10web', $this->company_name, $plugin['Name']); |
| 48 | $Description = str_ireplace('10web', $this->company_name, $plugin['Description']); |
| 49 | |
| 50 | $wp_list_table->items[$slug]['Name'] = $name; |
| 51 | $wp_list_table->items[$slug]['Description'] = $Description; |
| 52 | unset($wp_list_table->items[$slug]['Author']); |
| 53 | unset($wp_list_table->items[$slug]['AuthorURI']); |
| 54 | unset($wp_list_table->items[$slug]['AuthorName']); |
| 55 | unset($wp_list_table->items[$slug]['PluginURI']); |
| 56 | |
| 57 | if (isset($wp_list_table->items[$slug]['slug'])) { |
| 58 | unset($wp_list_table->items[$slug]['slug']); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | public function whiteLabelTopMenus() |
| 63 | { |
| 64 | global $menu; |
| 65 | |
| 66 | foreach ($menu as $key => $item) { |
| 67 | if (str_ireplace($this->whitelabeled_menus, '', $item[0]) !== $item[0]) { |
| 68 | $name = str_ireplace('10web', $this->company_name, $item[0]); |
| 69 | $title = str_ireplace('10web', $this->company_name, $item[0]); |
| 70 | $menu[$key][0] = $name; // phpcs:ignore |
| 71 | $menu[$key][3] = $title; // phpcs:ignore |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | public function whiteLabelAdminBarMenus($admin_menu) |
| 77 | { |
| 78 | $wl_menu = $admin_menu->get_node($this->top_bar_menus[0]); |
| 79 | |
| 80 | if (!empty($wl_menu)) { |
| 81 | $wl_menu->title = str_ireplace('10web', $this->company_name, $wl_menu->title); |
| 82 | $admin_menu->add_node($wl_menu); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | public static function get_instance() |
| 87 | { |
| 88 | if (null == self::$instance) { |
| 89 | self::$instance = new self(); |
| 90 | } |
| 91 | |
| 92 | return self::$instance; |
| 93 | } |
| 94 | } |
| 95 |