image_align_input_fields

函式
image_align_input_fields ( $post, $checked = '' )
引數
  • (WP_Post) $post
    Required:
  • (string) $checked
    Required:
    Default: (empty)
返回值
  • (string)
定義位置
相關方法
image_link_input_fieldsimage_size_input_fieldsget_plugin_filescomment_id_fieldsget_post_field
引入
2.7.0
棄用
-

image_align_input_fields: 此函式用於為影象建立對齊輸入欄位。

檢索影象對齊單選按鈕的HTML,並選中指定的一個。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function image_align_input_fields( $post, $checked = '' ) {
if ( empty( $checked ) ) {
$checked = get_user_setting( 'align', 'none' );
}
$alignments = array(
'none' => __( 'None' ),
'left' => __( 'Left' ),
'center' => __( 'Center' ),
'right' => __( 'Right' ),
);
if ( ! array_key_exists( (string) $checked, $alignments ) ) {
$checked = 'none';
}
$output = array();
foreach ( $alignments as $name => $label ) {
$name = esc_attr( $name );
$output[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" .
( $checked == $name ? " checked='checked'" : '' ) .
" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
}
return implode( "n", $output );
}
function image_align_input_fields( $post, $checked = '' ) { if ( empty( $checked ) ) { $checked = get_user_setting( 'align', 'none' ); } $alignments = array( 'none' => __( 'None' ), 'left' => __( 'Left' ), 'center' => __( 'Center' ), 'right' => __( 'Right' ), ); if ( ! array_key_exists( (string) $checked, $alignments ) ) { $checked = 'none'; } $output = array(); foreach ( $alignments as $name => $label ) { $name = esc_attr( $name ); $output[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" . ( $checked == $name ? " checked='checked'" : '' ) . " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; } return implode( "n", $output ); }
function image_align_input_fields( $post, $checked = '' ) {

	if ( empty( $checked ) ) {
		$checked = get_user_setting( 'align', 'none' );
	}

	$alignments = array(
		'none'   => __( 'None' ),
		'left'   => __( 'Left' ),
		'center' => __( 'Center' ),
		'right'  => __( 'Right' ),
	);

	if ( ! array_key_exists( (string) $checked, $alignments ) ) {
		$checked = 'none';
	}

	$output = array();

	foreach ( $alignments as $name => $label ) {
		$name     = esc_attr( $name );
		$output[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" .
			( $checked == $name ? " checked='checked'" : '' ) .
			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
	}

	return implode( "n", $output );
}

常見問題

FAQs
檢視更多 >