wp-customize-fonts.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. return sprintf(
  9. __( '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' ),
  10. __( 'https://wordpress.com/support/custom-fonts/' )
  11. );
  12. }
  13. function init_deprecation_notice( $wp_customize ) {
  14. $wp_customize->add_section(
  15. $this->section_key,
  16. array(
  17. 'capability' => 'edit_theme_options',
  18. 'title' => __( 'Fonts', 'blockbase' ),
  19. )
  20. );
  21. $wp_customize->add_control(
  22. $this->section_key . '-v1-blockbase-font-deprecation-notice',
  23. array(
  24. 'type' => 'hidden',
  25. 'description' => '<div class="notice notice-info">
  26. <p>' . $this->generate_deprecation_message() . '</p>
  27. </div>',
  28. 'settings' => array(),
  29. 'section' => $this->section_key,
  30. )
  31. );
  32. $wp_customize->add_control(
  33. $this->section_key . '-site-editor-button',
  34. array(
  35. 'type' => 'hidden',
  36. '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' ) ) ),
  37. 'settings' => array(),
  38. 'section' => $this->section_key,
  39. )
  40. );
  41. }
  42. }
  43. new GlobalStylesFontsCustomizer;