Нет описания

bootstrap.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Bootstrap file for the nudges.
  4. *
  5. * @package Jetpack
  6. */
  7. namespace Automattic\Jetpack\Dashboard_Customizations;
  8. use \Automattic\Jetpack\Status;
  9. /**
  10. * The WP_Customize_Control core class is loaded only on customize_register.
  11. *
  12. * @param \WP_Customize_Manager $customize_manager Core customize manager.
  13. */
  14. function register_css_nudge_control( \WP_Customize_Manager $customize_manager ) {
  15. require_once __DIR__ . '/additional-css/class-css-nudge-customize-control.php';
  16. require_once __DIR__ . '/additional-css/class-css-customizer-nudge.php';
  17. $domain = ( new Status() )->get_site_suffix();
  18. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
  19. require_once __DIR__ . '/additional-css/class-wpcom-additional-css-manager.php';
  20. $manager = new WPCOM_Additional_CSS_Manager( $domain );
  21. } elseif ( jetpack_is_atomic_site() ) {
  22. require_once __DIR__ . '/additional-css/class-atomic-additional-css-manager.php';
  23. $manager = new Atomic_Additional_CSS_Manager( $domain );
  24. }
  25. if ( ! isset( $manager ) ) {
  26. return;
  27. }
  28. $manager->register_nudge( $customize_manager );
  29. }
  30. /**
  31. * Load the bootstrap on init action.
  32. *
  33. * 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).
  34. */
  35. function load_bootstrap_on_init() {
  36. /**
  37. * Disable Additional CSS section from Customizer in WPCOM and Atomic and replace it with a nudge.
  38. *
  39. * @module masterbar
  40. *
  41. * @since 9.9.0
  42. *
  43. * @param bool
  44. */
  45. if ( \apply_filters( 'jetpack_customize_enable_additional_css_nudge', false ) ) {
  46. \add_action( 'customize_register', __NAMESPACE__ . '\register_css_nudge_control' );
  47. }
  48. }
  49. add_action( 'init', __NAMESPACE__ . '\load_bootstrap_on_init' );