bootstrap.php
72 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Bootstrap file for the nudges. |
| 4 | * |
| 5 | * @deprecated 13.7 |
| 6 | * |
| 7 | * @package Jetpack |
| 8 | * |
| 9 | * @phan-file-suppress PhanDeprecatedFunction -- Ok for deprecated code to call other deprecated code. |
| 10 | */ |
| 11 | |
| 12 | namespace Automattic\Jetpack\Dashboard_Customizations; |
| 13 | |
| 14 | _deprecated_file( __FILE__, 'jetpack-13.7' ); |
| 15 | |
| 16 | use Automattic\Jetpack\Status; |
| 17 | use Automattic\Jetpack\Status\Host; |
| 18 | |
| 19 | /** |
| 20 | * The WP_Customize_Control core class is loaded only on customize_register. |
| 21 | * |
| 22 | * @deprecated 13.7 |
| 23 | * |
| 24 | * @param \WP_Customize_Manager $customize_manager Core customize manager. |
| 25 | */ |
| 26 | function register_css_nudge_control( \WP_Customize_Manager $customize_manager ) { |
| 27 | _deprecated_function( __FUNCTION__, 'jetpack-13.7', 'Automattic\\Jetpack\\Masterbar\\register_css_nudge_control' ); |
| 28 | require_once __DIR__ . '/additional-css/class-css-nudge-customize-control.php'; |
| 29 | require_once __DIR__ . '/additional-css/class-css-customizer-nudge.php'; |
| 30 | |
| 31 | $domain = ( new Status() )->get_site_suffix(); |
| 32 | |
| 33 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
| 34 | require_once __DIR__ . '/additional-css/class-wpcom-additional-css-manager.php'; |
| 35 | $manager = new WPCOM_Additional_CSS_Manager( $domain ); |
| 36 | } elseif ( ( new Host() )->is_woa_site() ) { |
| 37 | require_once __DIR__ . '/additional-css/class-atomic-additional-css-manager.php'; |
| 38 | $manager = new Atomic_Additional_CSS_Manager( $domain ); |
| 39 | } |
| 40 | |
| 41 | if ( ! isset( $manager ) ) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | $manager->register_nudge( $customize_manager ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Load the bootstrap on init action. |
| 50 | * |
| 51 | * 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). |
| 52 | * |
| 53 | * @deprecated 13.7 |
| 54 | */ |
| 55 | function load_bootstrap_on_init() { |
| 56 | _deprecated_function( __FUNCTION__, 'jetpack-13.7', 'Automattic\\Jetpack\\Masterbar\\load_bootstrap_on_init' ); |
| 57 | /** |
| 58 | * Disable Additional CSS section from Customizer in WPCOM and Atomic and replace it with a nudge. |
| 59 | * |
| 60 | * @module masterbar |
| 61 | * |
| 62 | * @since 9.9.0 |
| 63 | * |
| 64 | * @param bool |
| 65 | */ |
| 66 | if ( \apply_filters( 'jetpack_customize_enable_additional_css_nudge', false ) ) { |
| 67 | \add_action( 'customize_register', __NAMESPACE__ . '\register_css_nudge_control' ); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | add_action( 'init', __NAMESPACE__ . '\load_bootstrap_on_init' ); |
| 72 |