[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/blocks/ -> navigation-overlay-close.php (source)

   1  <?php
   2  /**
   3   * Server-side registering of the `core/navigation-overlay-close` block.
   4   *
   5   * @package WordPress
   6   */
   7  
   8  /**
   9   * Renders the `core/navigation-overlay-close` block on server.
  10   *
  11   * @since 7.0.0
  12   *
  13   * @param array $attributes The block attributes.
  14   *
  15   * @return string Returns the block content.
  16   */
  17  function render_block_core_navigation_overlay_close( $attributes ) {
  18      $text         = empty( $attributes['text'] ) ? __( 'Close' ) : $attributes['text'];
  19      $display_mode = empty( $attributes['displayMode'] ) ? 'icon' : $attributes['displayMode'];
  20      $show_icon    = 'both' === $display_mode || 'icon' === $display_mode;
  21      $show_text    = 'both' === $display_mode || 'text' === $display_mode;
  22      $button_text  = '';
  23  
  24      if ( $show_icon ) {
  25          $button_text .= '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1.1-1-6.1 6.2-6.1-6.2-1.1 1 6.1 6.3-6.5 6.7 1.1 1 6.5-6.6 6.5 6.6 1.1-1z" /></svg>';
  26      }
  27  
  28      if ( $show_text ) {
  29          $button_text .= '<span class="wp-block-navigation-overlay-close__text">' . wp_kses_post( $text ) . '</span>';
  30      }
  31  
  32      $wrapper_attributes = get_block_wrapper_attributes();
  33      $html_content       = sprintf(
  34          '<button %1$s type="button" %2$s >%3$s</button>',
  35          $wrapper_attributes,
  36          ! $show_text ? 'aria-label="' . __( 'Close' ) . '"' : '',
  37          $button_text
  38      );
  39  
  40      return $html_content;
  41  }
  42  
  43  /**
  44   * Registers the navigation overlay close block.
  45   *
  46   * @since 7.0.0
  47   */
  48  function register_block_core_navigation_overlay_close() {
  49      register_block_type_from_metadata(
  50          __DIR__ . '/navigation-overlay-close',
  51          array(
  52              'render_callback' => 'render_block_core_navigation_overlay_close',
  53          )
  54      );
  55  }
  56  add_action( 'init', 'register_block_core_navigation_overlay_close' );


Generated : Sun Jun 14 08:20:09 2026 Cross-referenced by PHPXref