[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentytwentyfive/ -> functions.php (source)

   1  <?php
   2  /**
   3   * Twenty Twenty-Five functions and definitions.
   4   *
   5   * @link https://developer.wordpress.org/themes/basics/theme-functions/
   6   *
   7   * @package WordPress
   8   * @subpackage Twenty_Twenty_Five
   9   * @since Twenty Twenty-Five 1.0
  10   */
  11  
  12  // Adds theme support for post formats.
  13  if ( ! function_exists( 'twentytwentyfive_post_format_setup' ) ) :
  14      /**
  15       * Adds theme support for post formats.
  16       *
  17       * @since Twenty Twenty-Five 1.0
  18       *
  19       * @return void
  20       */
  21  	function twentytwentyfive_post_format_setup() {
  22          add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) );
  23      }
  24  endif;
  25  add_action( 'after_setup_theme', 'twentytwentyfive_post_format_setup' );
  26  
  27  // Enqueues editor-style.css in the editors.
  28  if ( ! function_exists( 'twentytwentyfive_editor_style' ) ) :
  29      /**
  30       * Enqueues editor-style.css in the editors.
  31       *
  32       * @since Twenty Twenty-Five 1.0
  33       *
  34       * @return void
  35       */
  36  	function twentytwentyfive_editor_style() {
  37          add_editor_style( get_parent_theme_file_uri( 'assets/css/editor-style.css' ) );
  38      }
  39  endif;
  40  add_action( 'after_setup_theme', 'twentytwentyfive_editor_style' );
  41  
  42  // Enqueues style.css on the front.
  43  if ( ! function_exists( 'twentytwentyfive_enqueue_styles' ) ) :
  44      /**
  45       * Enqueues style.css on the front.
  46       *
  47       * @since Twenty Twenty-Five 1.0
  48       *
  49       * @return void
  50       */
  51  	function twentytwentyfive_enqueue_styles() {
  52          wp_enqueue_style(
  53              'twentytwentyfive-style',
  54              get_parent_theme_file_uri( 'style.css' ),
  55              array(),
  56              wp_get_theme()->get( 'Version' )
  57          );
  58      }
  59  endif;
  60  add_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' );
  61  
  62  // Registers custom block styles.
  63  if ( ! function_exists( 'twentytwentyfive_block_styles' ) ) :
  64      /**
  65       * Registers custom block styles.
  66       *
  67       * @since Twenty Twenty-Five 1.0
  68       *
  69       * @return void
  70       */
  71  	function twentytwentyfive_block_styles() {
  72          register_block_style(
  73              'core/list',
  74              array(
  75                  'name'         => 'checkmark-list',
  76                  'label'        => __( 'Checkmark', 'twentytwentyfive' ),
  77                  'inline_style' => '
  78                  ul.is-style-checkmark-list {
  79                      list-style-type: "\2713";
  80                  }
  81  
  82                  ul.is-style-checkmark-list li {
  83                      padding-inline-start: 1ch;
  84                  }',
  85              )
  86          );
  87      }
  88  endif;
  89  add_action( 'init', 'twentytwentyfive_block_styles' );
  90  
  91  // Registers pattern categories.
  92  if ( ! function_exists( 'twentytwentyfive_pattern_categories' ) ) :
  93      /**
  94       * Registers pattern categories.
  95       *
  96       * @since Twenty Twenty-Five 1.0
  97       *
  98       * @return void
  99       */
 100  	function twentytwentyfive_pattern_categories() {
 101  
 102          register_block_pattern_category(
 103              'twentytwentyfive_page',
 104              array(
 105                  'label'       => __( 'Pages', 'twentytwentyfive' ),
 106                  'description' => __( 'A collection of full page layouts.', 'twentytwentyfive' ),
 107              )
 108          );
 109  
 110          register_block_pattern_category(
 111              'twentytwentyfive_post-format',
 112              array(
 113                  'label'       => __( 'Post formats', 'twentytwentyfive' ),
 114                  'description' => __( 'A collection of post format patterns.', 'twentytwentyfive' ),
 115              )
 116          );
 117      }
 118  endif;
 119  add_action( 'init', 'twentytwentyfive_pattern_categories' );
 120  
 121  // Registers block binding sources.
 122  if ( ! function_exists( 'twentytwentyfive_register_block_bindings' ) ) :
 123      /**
 124       * Registers the post format block binding source.
 125       *
 126       * @since Twenty Twenty-Five 1.0
 127       *
 128       * @return void
 129       */
 130  	function twentytwentyfive_register_block_bindings() {
 131          register_block_bindings_source(
 132              'twentytwentyfive/format',
 133              array(
 134                  'label'              => _x( 'Post format name', 'Label for the block binding placeholder in the editor', 'twentytwentyfive' ),
 135                  'get_value_callback' => 'twentytwentyfive_format_binding',
 136              )
 137          );
 138      }
 139  endif;
 140  add_action( 'init', 'twentytwentyfive_register_block_bindings' );
 141  
 142  // Registers block binding callback function for the post format name.
 143  if ( ! function_exists( 'twentytwentyfive_format_binding' ) ) :
 144      /**
 145       * Callback function for the post format name block binding source.
 146       *
 147       * @since Twenty Twenty-Five 1.0
 148       *
 149       * @return string|void Post format name, or nothing if the format is 'standard'.
 150       */
 151  	function twentytwentyfive_format_binding() {
 152          $post_format_slug = get_post_format();
 153  
 154          if ( $post_format_slug && 'standard' !== $post_format_slug ) {
 155              return get_post_format_string( $post_format_slug );
 156          }
 157      }
 158  endif;


Generated : Sun Dec 22 08:20:01 2024 Cross-referenced by PHPXref