wp-customize-fonts.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. class GlobalStylesFontsCustomizer {
  3. private $section_key = 'customize-global-styles-fonts';
  4. function __construct() {
  5. add_action( 'customize_register', array( $this, 'init_deprecation_notice' ) );
  6. }
  7. function generate_deprecation_message() {
  8. if ( ! defined( 'GUTENBERG_VERSION' ) || version_compare( GUTENBERG_VERSION, '13.3', '<=' ) ) {
  9. return __( 'Please activate or update Gutenberg to use the custom fonts feature.', 'blockbase' );
  10. }
  11. return sprintf(
  12. __( 'Updating fonts for this theme is now even easier! Use the site editor to select and preview different font families. <a href="%s">More information.</a>', 'blockbase' ),
  13. __('https://wordpress.com/support/custom-fonts/')
  14. );
  15. }
  16. function init_deprecation_notice( $wp_customize ) {
  17. $wp_customize->add_section(
  18. $this->section_key,
  19. array(
  20. 'capability' => 'edit_theme_options',
  21. 'title' => __( 'Fonts', 'blockbase' ),
  22. )
  23. );
  24. $wp_customize->add_control(
  25. $this->section_key . '-v1-blockbase-font-deprecation-notice',
  26. array(
  27. 'type' => 'hidden',
  28. 'description' => '<div class="notice notice-info">
  29. <p>' . $this->generate_deprecation_message() . '</p>
  30. </div>',
  31. 'settings' => array(),
  32. 'section' => $this->section_key,
  33. )
  34. );
  35. $wp_customize->add_control(
  36. $this->section_key . '-site-editor-button',
  37. array(
  38. 'type' => 'hidden',
  39. 'description' => sprintf( '<a class="button button-primary" href=%s style="font-style: normal;" >Use Site Editor</a>', esc_url( admin_url( 'site-editor.php?styles=open' ) ) ),
  40. 'settings' => array(),
  41. 'section' => $this->section_key,
  42. )
  43. );
  44. }
  45. }
  46. new GlobalStylesFontsCustomizer;