Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
84.62% |
11 / 13 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| WPCOM_Additional_CSS_Manager | |
84.62% |
11 / 13 |
|
75.00% |
3 / 4 |
4.06 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| register_nudge | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| get_nudge_url | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_plan | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * WPCOM_Additional_CSS_Manager file |
| 4 | * |
| 5 | * Is responsible with registering the Additional CSS section in WPCOM. |
| 6 | * |
| 7 | * @package automattic/jetpack-masterbar |
| 8 | */ |
| 9 | |
| 10 | namespace Automattic\Jetpack\Masterbar; |
| 11 | |
| 12 | /** |
| 13 | * Class WPCOM_Disable_Additional_CSS |
| 14 | */ |
| 15 | class WPCOM_Additional_CSS_Manager { |
| 16 | |
| 17 | /** |
| 18 | * The site domain. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | private $domain; |
| 23 | |
| 24 | /** |
| 25 | * WPCOM_Additional_CSS_Manager constructor. |
| 26 | * |
| 27 | * @param string $domain the Site domain. |
| 28 | */ |
| 29 | public function __construct( $domain ) { |
| 30 | $this->domain = $domain; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Register the Additional CSS nudge. |
| 35 | * |
| 36 | * @param \WP_Customize_Manager $wp_customize_manager The core customize manager. |
| 37 | */ |
| 38 | public function register_nudge( \WP_Customize_Manager $wp_customize_manager ) { |
| 39 | $plan_name = $this->get_plan()->product_name_short; |
| 40 | |
| 41 | $nudge_url = $this->get_nudge_url(); |
| 42 | /* translators: %s is the plan name. */ |
| 43 | $nudge_text = sprintf( __( 'Purchase the %s plan to<br> activate CSS customization', 'jetpack-masterbar' ), $plan_name ); |
| 44 | |
| 45 | $nudge = new CSS_Customizer_Nudge( |
| 46 | $nudge_url, |
| 47 | $nudge_text, |
| 48 | 'jetpack_custom_css' |
| 49 | ); |
| 50 | |
| 51 | $nudge->customize_register_nudge( $wp_customize_manager ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Get the nudge URL in WPCOM. |
| 56 | * |
| 57 | * @return string |
| 58 | */ |
| 59 | private function get_nudge_url() { |
| 60 | return '/checkout/' . $this->domain . '/' . $this->get_plan()->path_slug; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Get the plan. |
| 65 | * |
| 66 | * @return mixed |
| 67 | */ |
| 68 | protected function get_plan() { |
| 69 | $plan_slug = apply_filters( 'wpcom_customize_css_plan_slug', 'value_bundle' ); |
| 70 | |
| 71 | return \Automattic\Jetpack\Plans::get_plan( $plan_slug ); |
| 72 | } |
| 73 | } |