%s', $input_id, $attributes['label'] ); } $input_markup = sprintf( '', $input_id, esc_attr( get_search_query() ), esc_attr( $attributes['placeholder'] ) ); if ( ! empty( $attributes['buttonText'] ) ) { $button_markup = sprintf( '', $attributes['buttonText'] ); } $class = 'wp-block-search'; if ( isset( $attributes['className'] ) ) { $class .= ' ' . $attributes['className']; } if ( isset( $attributes['align'] ) ) { $class .= ' align' . $attributes['align']; } return sprintf( '
', $class, esc_url( home_url( '/' ) ), $label_markup . $input_markup . $button_markup ); } /** * Registers the `core/search` block on the server. */ function register_block_core_search() { register_block_type( 'core/search', array( 'attributes' => array( 'align' => array( 'type' => 'string', 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), ), 'className' => array( 'type' => 'string', ), 'label' => array( 'type' => 'string', 'default' => __( 'Search' ), ), 'placeholder' => array( 'type' => 'string', 'default' => '', ), 'buttonText' => array( 'type' => 'string', 'default' => __( 'Search' ), ), ), 'render_callback' => 'render_block_core_search', ) ); } add_action( 'init', 'register_block_core_search' );