image_link_input_fields() – Retrieve HTML for the Link URL buttons with the default link type as specified.

You appear to be a bot. Output may be restricted

Description

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

Usage

$string = image_link_input_fields( $post, $url_type );

Parameters

$post
( WP_Post ) required
$url_type
( string ) optional

Returns

string

Source

File name: wordpress/wp-admin/includes/media.php
Lines:

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

 View on GitHub View on Trac