Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 2
CRAP
n/a
0 / 0
Automattic\Jetpack\Masterbar\register_css_nudge_control
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
30
Automattic\Jetpack\Masterbar\load_bootstrap_on_init
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * Bootstrap file for the nudges.
4 *
5 * @package automattic/jetpack-masterbar
6 */
7
8namespace Automattic\Jetpack\Masterbar;
9
10use Automattic\Jetpack\Status;
11use Automattic\Jetpack\Status\Host;
12
13/**
14 * The WP_Customize_Control core class is loaded only on customize_register.
15 *
16 * @param \WP_Customize_Manager $customize_manager Core customize manager.
17 */
18function register_css_nudge_control( \WP_Customize_Manager $customize_manager ) {
19    $domain = ( new Status() )->get_site_suffix();
20
21    if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
22        $manager = new WPCOM_Additional_CSS_Manager( $domain );
23    } elseif ( ( new Host() )->is_woa_site() ) {
24        $manager = new Atomic_Additional_CSS_Manager( $domain );
25    }
26
27    if ( ! isset( $manager ) ) {
28        return;
29    }
30
31    $manager->register_nudge( $customize_manager );
32}
33
34/**
35 * Load the bootstrap on init action.
36 *
37 * We need to load on init because otherwise the filter will not be set to true in WPCOM (since the add_filter is set on init).
38 */
39function load_bootstrap_on_init() {
40
41    /**
42     * Disable Additional CSS section from Customizer in WPCOM and Atomic and replace it with a nudge.
43     *
44     * @module masterbar
45     *
46     * @since jetpack-9.9.0
47     *
48     * @param bool
49     */
50    if ( \apply_filters( 'jetpack_customize_enable_additional_css_nudge', false ) ) {
51        \add_action( 'customize_register', __NAMESPACE__ . '\register_css_nudge_control' );
52    }
53}
54
55add_action( 'init', __NAMESPACE__ . '\load_bootstrap_on_init' );