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-wpcom-additional-css-manager.php
71 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WPCOM_Additional_CSS_Manager file |
| 4 | * |
| 5 | * Is responsible with registering the Additional CSS section in WPCOM. |
| 6 | * |
| 7 | * @package Jetpack |
| 8 | */ |
| 9 | |
| 10 | namespace Automattic\Jetpack\Dashboard_Customizations; |
| 11 | |
| 12 | /** |
| 13 | * Class WPCOM_Disable_Additional_CSS |
| 14 | * |
| 15 | * @package Automattic\Jetpack\Dashboard_Customizations |
| 16 | */ |
| 17 | class WPCOM_Additional_CSS_Manager { |
| 18 | |
| 19 | /** |
| 20 | * The site domain. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | private $domain; |
| 25 | |
| 26 | /** |
| 27 | * WPCOM_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 | * Register the Additional CSS nudge. |
| 37 | * |
| 38 | * @param \WP_Customize_Manager $wp_customize_manager The 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 Premium 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 | 'jetpack_custom_css' |
| 57 | ); |
| 58 | |
| 59 | $nudge->customize_register_nudge( $wp_customize_manager ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Get the nudge URL in WPCOM. |
| 64 | * |
| 65 | * @return string |
| 66 | */ |
| 67 | private function get_nudge_url() { |
| 68 | return '/checkout/' . $this->domain . '/premium'; |
| 69 | } |
| 70 | } |
| 71 |