image_link_input_fields

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

image_link_input_fields: 這個函式用來為媒體庫中的影象連結建立輸入欄位。

檢索連結URL按鈕的HTML,預設的連結型別是指定的。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function image_link_input_fields( $post, $url_type = '' ) {
$file = wp_get_attachment_url( $post->ID );
$link = get_attachment_link( $post->ID );
if ( empty( $url_type ) ) {
$url_type = get_user_setting( 'urlbutton', 'post' );
}
$url = '';
if ( 'file' === $url_type ) {
$url = $file;
} elseif ( 'post' === $url_type ) {
$url = $link;
}
return "
<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr( $url ) . "' /><br />
<button type='button' class='button urlnone' data-link-url=''>" . __( 'None' ) . "</button>
<button type='button' class='button urlfile' data-link-url='" . esc_url( $file ) . "'>" . __( 'File URL' ) . "</button>
<button type='button' class='button urlpost' data-link-url='" . esc_url( $link ) . "'>" . __( 'Attachment Post URL' ) . '</button>
';
}
function image_link_input_fields( $post, $url_type = '' ) { $file = wp_get_attachment_url( $post->ID ); $link = get_attachment_link( $post->ID ); if ( empty( $url_type ) ) { $url_type = get_user_setting( 'urlbutton', 'post' ); } $url = ''; if ( 'file' === $url_type ) { $url = $file; } elseif ( 'post' === $url_type ) { $url = $link; } return " <input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr( $url ) . "' /><br /> <button type='button' class='button urlnone' data-link-url=''>" . __( 'None' ) . "</button> <button type='button' class='button urlfile' data-link-url='" . esc_url( $file ) . "'>" . __( 'File URL' ) . "</button> <button type='button' class='button urlpost' data-link-url='" . esc_url( $link ) . "'>" . __( 'Attachment Post URL' ) . '</button> '; }
function image_link_input_fields( $post, $url_type = '' ) {

	$file = wp_get_attachment_url( $post->ID );
	$link = get_attachment_link( $post->ID );

	if ( empty( $url_type ) ) {
		$url_type = get_user_setting( 'urlbutton', 'post' );
	}

	$url = '';

	if ( 'file' === $url_type ) {
		$url = $file;
	} elseif ( 'post' === $url_type ) {
		$url = $link;
	}

	return "
	<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr( $url ) . "' /><br />
	<button type='button' class='button urlnone' data-link-url=''>" . __( 'None' ) . "</button>
	<button type='button' class='button urlfile' data-link-url='" . esc_url( $file ) . "'>" . __( 'File URL' ) . "</button>
	<button type='button' class='button urlpost' data-link-url='" . esc_url( $link ) . "'>" . __( 'Attachment Post URL' ) . '</button>
';
}

常見問題

FAQs
檢視更多 >