functions.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * Pendant functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Pendant
  8. * @since Pendant 1.0
  9. */
  10. if ( ! function_exists( 'pendant_support' ) ) :
  11. /**
  12. * Sets up theme defaults and registers support for various WordPress features.
  13. *
  14. * @since Block Canvas 1.0
  15. *
  16. * @return void
  17. */
  18. function pendant_support() {
  19. // Make theme available for translation.
  20. load_theme_textdomain( 'pendant' );
  21. // Add support for block styles.
  22. add_theme_support( 'wp-block-styles' );
  23. // Enqueue editor styles.
  24. add_editor_style( 'style.css' );
  25. }
  26. endif;
  27. add_action( 'after_setup_theme', 'pendant_support' );
  28. if ( ! function_exists( 'pendant_styles' ) ) :
  29. /**
  30. * Enqueue styles.
  31. *
  32. * @since Block Canvas 1.0
  33. *
  34. * @return void
  35. */
  36. function pendant_styles() {
  37. // Register theme stylesheet.
  38. wp_register_style(
  39. 'pendant-style',
  40. get_template_directory_uri() . '/style.css',
  41. array(),
  42. wp_get_theme()->get( 'Version' )
  43. );
  44. // Enqueue theme stylesheet.
  45. wp_enqueue_style( 'pendant-style' );
  46. }
  47. endif;
  48. add_action( 'wp_enqueue_scripts', 'pendant_styles' );
  49. function pendant_register_block_pattern_categories() {
  50. register_block_pattern_category( 'featured', array( 'label' => __( 'Featured', 'pendant' ) ) );
  51. register_block_pattern_category( 'query', array( 'label' => __( 'Query', 'pendant' ) ) );
  52. register_block_pattern_category( 'call-to-action', array( 'label' => __( 'Call to Action', 'pendant' ) ) );
  53. register_block_pattern_category( 'media', array( 'label' => __( 'Media', 'pendant' ) ) );
  54. register_block_pattern_category( 'quotes', array( 'label' => __( 'Quotes', 'pendant' ) ) );
  55. register_block_pattern_category( 'list', array( 'label' => __( 'List', 'pendant' ) ) );
  56. register_block_pattern_category( 'images', array( 'label' => __( 'Images', 'pendant' ) ) );
  57. register_block_pattern_category( 'gallery', array( 'label' => __( 'Gallery', 'pendant' ) ) );
  58. }
  59. add_action( 'init', 'pendant_register_block_pattern_categories', 9 );
  60. /**
  61. * Jetpack may attempt to register fonts for the Google Font Provider.
  62. * If Jetpack registeres fonts in the same family as what this theme offers
  63. * then those are included instead (and may be different typeface choices
  64. * than what are expressed here.)
  65. * This filter eliminates the fonts that Pendant natively supplies.
  66. *
  67. * This will no longer be needed once this Jetpack issue has been resolved:
  68. * https://github.com/Automattic/jetpack/issues/25987
  69. */
  70. function pendant_filter_jetpack_google_fonts_list( $list_to_filter ) {
  71. $filtered = array_filter(
  72. $list_to_filter,
  73. function( $font_family ) {
  74. return 'Jost' !== $font_family && 'Literata' !== $font_family;
  75. }
  76. );
  77. return $filtered;
  78. }
  79. add_filter( 'jetpack_google_fonts_list', 'pendant_filter_jetpack_google_fonts_list' );