class-bulk.php
2 years ago
class-cdn.php
2 years ago
class-dashboard.php
2 years ago
class-directory.php
2 years ago
class-integrations.php
2 years ago
class-lazy.php
2 years ago
class-nextgen.php
2 years ago
class-settings.php
2 years ago
class-tutorials.php
2 years ago
class-upgrade.php
2 years ago
class-webp.php
2 years ago
class-upgrade.php
94 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Smush upgrade page class: Upgrade extends Abstract_Page. |
| 4 | * |
| 5 | * @since 3.2.3 |
| 6 | * @package Smush\App\Pages |
| 7 | */ |
| 8 | |
| 9 | namespace Smush\App\Pages; |
| 10 | |
| 11 | use Smush\App\Abstract_Page; |
| 12 | |
| 13 | if ( ! defined( 'WPINC' ) ) { |
| 14 | die; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Class Upgrade |
| 19 | */ |
| 20 | class Upgrade extends Abstract_Page { |
| 21 | /** |
| 22 | * Parent slug. |
| 23 | */ |
| 24 | private $parent_slug; |
| 25 | |
| 26 | public function __construct( $slug, $title, $parent_slug = false, $is_upsell_link = false ) { |
| 27 | parent::__construct( $slug, $title, $parent_slug, false, $is_upsell_link ); |
| 28 | |
| 29 | if ( $is_upsell_link ) { |
| 30 | $this->parent_slug = $parent_slug; |
| 31 | add_action( 'admin_head', array( $this, 'adjust_upsell_submenu' ) ); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | public function adjust_upsell_submenu() { |
| 36 | $submenu_selector = "#toplevel_page_{$this->parent_slug} li:last-child a"; |
| 37 | ?> |
| 38 | <style> |
| 39 | <?php echo esc_html( $submenu_selector ); ?> { |
| 40 | background-color: #8d00b1 !important; |
| 41 | color: #fff !important; |
| 42 | font-weight: 500 !important; |
| 43 | white-space: nowrap; |
| 44 | } |
| 45 | </style> |
| 46 | <script> |
| 47 | window.addEventListener( 'load', function() { |
| 48 | document.querySelector( '<?php echo esc_html( $submenu_selector ); ?>' ).target="_blank"; |
| 49 | } ); |
| 50 | </script> |
| 51 | <?php |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Render the page. |
| 56 | */ |
| 57 | public function render() { |
| 58 | ?> |
| 59 | <div class="<?php echo $this->settings->get( 'accessible_colors' ) ? 'sui-wrap sui-color-accessible' : 'sui-wrap'; ?>"> |
| 60 | <?php $this->render_inner_content(); ?> |
| 61 | </div> |
| 62 | <?php |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Render inner content. |
| 67 | */ |
| 68 | public function render_inner_content() { |
| 69 | $this->view( 'smush-upgrade-page' ); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * On load actions. |
| 74 | */ |
| 75 | public function on_load() { |
| 76 | add_action( |
| 77 | 'admin_enqueue_scripts', |
| 78 | function() { |
| 79 | wp_enqueue_script( 'smush-sui', WP_SMUSH_URL . 'app/assets/js/smush-sui.min.js', array( 'jquery', 'clipboard' ), WP_SHARED_UI_VERSION, true ); |
| 80 | wp_enqueue_script( 'smush-wistia', '//fast.wistia.com/assets/external/E-v1.js', array(), WP_SMUSH_VERSION, true ); |
| 81 | wp_enqueue_style( 'smush-admin', WP_SMUSH_URL . 'app/assets/css/smush-admin.min.css', array(), WP_SMUSH_VERSION ); |
| 82 | } |
| 83 | ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Common hooks for all screens. |
| 88 | */ |
| 89 | public function add_action_hooks() { |
| 90 | add_filter( 'admin_body_class', array( $this, 'smush_body_classes' ) ); |
| 91 | } |
| 92 | |
| 93 | } |
| 94 |