install_theme_search_form

函式
install_theme_search_form ( $type_selector = true )
引數
  • (bool) $type_selector
    Required:
    Default: true
定義位置
相關方法
install_search_forminstall_theme_informationinstall_themes_uploadinstall_themes_feature_listinstall_themes_dashboard
引入
2.8.0
棄用
-

install_theme_search_form: 這個函式用來顯示WordPress主題安裝的搜尋表單。它輸出搜尋表單的HTML程式碼。

顯示用於搜尋主題的搜尋表單。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function install_theme_search_form( $type_selector = true ) {
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
if ( ! $type_selector ) {
echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
}
?>
<form id="search-themes" method="get">
<input type="hidden" name="tab" value="search" />
<?php if ( $type_selector ) : ?>
<label class="screen-reader-text" for="typeselector"><?php _e( 'Type of search' ); ?></label>
<select name="type" id="typeselector">
<option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
<option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
<option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option>
</select>
<label class="screen-reader-text" for="s">
<?php
switch ( $type ) {
case 'term':
_e( 'Search by keyword' );
break;
case 'author':
_e( 'Search by author' );
break;
case 'tag':
_e( 'Search by tag' );
break;
}
?>
</label>
<?php else : ?>
<label class="screen-reader-text" for="s"><?php _e( 'Search by keyword' ); ?></label>
<?php endif; ?>
<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" />
<?php submit_button( __( 'Search' ), '', 'search', false ); ?>
</form>
<?php
}
function install_theme_search_form( $type_selector = true ) { $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; if ( ! $type_selector ) { echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>'; } ?> <form id="search-themes" method="get"> <input type="hidden" name="tab" value="search" /> <?php if ( $type_selector ) : ?> <label class="screen-reader-text" for="typeselector"><?php _e( 'Type of search' ); ?></label> <select name="type" id="typeselector"> <option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option> <option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option> <option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option> </select> <label class="screen-reader-text" for="s"> <?php switch ( $type ) { case 'term': _e( 'Search by keyword' ); break; case 'author': _e( 'Search by author' ); break; case 'tag': _e( 'Search by tag' ); break; } ?> </label> <?php else : ?> <label class="screen-reader-text" for="s"><?php _e( 'Search by keyword' ); ?></label> <?php endif; ?> <input type="search" name="s" id="s" size="30" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" /> <?php submit_button( __( 'Search' ), '', 'search', false ); ?> </form> <?php }
function install_theme_search_form( $type_selector = true ) {
	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
	if ( ! $type_selector ) {
		echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
	}
	?>
<form id="search-themes" method="get">
	<input type="hidden" name="tab" value="search" />
	<?php if ( $type_selector ) : ?>
	<label class="screen-reader-text" for="typeselector"><?php _e( 'Type of search' ); ?></label>
	<select	name="type" id="typeselector">
	<option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
	<option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
	<option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option>
	</select>
	<label class="screen-reader-text" for="s">
		<?php
		switch ( $type ) {
			case 'term':
				_e( 'Search by keyword' );
				break;
			case 'author':
				_e( 'Search by author' );
				break;
			case 'tag':
				_e( 'Search by tag' );
				break;
		}
		?>
	</label>
	<?php else : ?>
	<label class="screen-reader-text" for="s"><?php _e( 'Search by keyword' ); ?></label>
	<?php endif; ?>
	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" />
	<?php submit_button( __( 'Search' ), '', 'search', false ); ?>
</form>
	<?php
}

常見問題

FAQs
檢視更多 >