css
5 years ago
js
5 years ago
class-atomic-additional-css-manager.php
3 years ago
class-css-customizer-nudge.php
5 years ago
class-css-nudge-customize-control.php
5 years ago
class-wpcom-additional-css-manager.php
3 years ago
class-atomic-additional-css-manager.php
73 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WPORG_Additional_CSS_Manager file |
| 4 | * |
| 5 | * Responsible with replacing the Core Additional CSS section with an upgrade nudge on Atomic. |
| 6 | * |
| 7 | * @package Jetpack |
| 8 | */ |
| 9 | |
| 10 | namespace Automattic\Jetpack\Dashboard_Customizations; |
| 11 | |
| 12 | /** |
| 13 | * Class Atomic_Additional_CSS_Manager |
| 14 | * |
| 15 | * @package Automattic\Jetpack\Dashboard_Customizations |
| 16 | */ |
| 17 | class Atomic_Additional_CSS_Manager { |
| 18 | |
| 19 | /** |
| 20 | * The site domain. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | private $domain; |
| 25 | |
| 26 | /** |
| 27 | * Atomic_Additional_CSS_Manager constructor. |
| 28 | * |
| 29 | * @param string $domain the Site domain. |
| 30 | */ |
| 31 | public function __construct( $domain ) { |
| 32 | $this->domain = $domain; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Replace the Additional CSS section from Customiz¡er with an upgrade nudge. |
| 37 | * |
| 38 | * @param \WP_Customize_Manager $wp_customize_manager Core customize manager. |
| 39 | */ |
| 40 | public function register_nudge( \WP_Customize_Manager $wp_customize_manager ) { |
| 41 | $nudge_url = $this->get_nudge_url(); |
| 42 | $nudge_text = __( 'Purchase a Business Plan to<br> activate CSS customization', 'jetpack' ); |
| 43 | |
| 44 | if ( |
| 45 | ( defined( 'ENABLE_PRO_PLAN' ) && ENABLE_PRO_PLAN ) || |
| 46 | ! empty( $_GET['enable_pro_plan'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only used to customize output. |
| 47 | ! empty( $_COOKIE['enable_pro_plan'] ) |
| 48 | ) { |
| 49 | $nudge_text = __( 'Purchase a Pro Plan to<br> activate CSS customization', 'jetpack' ); |
| 50 | $nudge_url = preg_replace( '/premium$/', 'pro', $nudge_url ); |
| 51 | } |
| 52 | |
| 53 | $nudge = new CSS_Customizer_Nudge( |
| 54 | $nudge_url, |
| 55 | $nudge_text |
| 56 | ); |
| 57 | |
| 58 | $wp_customize_manager->remove_control( 'custom_css' ); |
| 59 | $wp_customize_manager->remove_section( 'custom_css' ); |
| 60 | |
| 61 | $nudge->customize_register_nudge( $wp_customize_manager ); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get the Nudge URL. |
| 66 | * |
| 67 | * @return string |
| 68 | */ |
| 69 | private function get_nudge_url() { |
| 70 | return '/checkout/' . $this->domain . '/business'; |
| 71 | } |
| 72 | } |
| 73 |