From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- srcs/wordpress/wp-includes/blocks/search.php | 93 ++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 srcs/wordpress/wp-includes/blocks/search.php (limited to 'srcs/wordpress/wp-includes/blocks/search.php') diff --git a/srcs/wordpress/wp-includes/blocks/search.php b/srcs/wordpress/wp-includes/blocks/search.php new file mode 100644 index 0000000..6cd909f --- /dev/null +++ b/srcs/wordpress/wp-includes/blocks/search.php @@ -0,0 +1,93 @@ +%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' ); -- cgit