image_link_input_fields()

最后更新于:2021-11-27 06:31:11

image_link_input_fields( GC_Post$post, string$url_type=”)

Retrieve HTML for the Link URL buttons with the default link type as specified.

参数

$post

(GC_Post) (Required)

$url_type

(string) (Optional)

Default value: ”

响应

(string)

源文件

文件: gc-admin/includes/media.php

function image_link_input_fields( $post, $url_type = '' ) {

	$file = gc_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_attr( $file ) . "'>" . __( 'File URL' ) . "</button>
	<button type='button' class='button urlpost' data-link-url='" . esc_attr( $link ) . "'>" . __( 'Attachment Post URL' ) . '</button>
';
}