image_link_input_fields

The timeline below displays how wordpress function image_link_input_fields has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves HTML for the Link URL buttons with the default link type as specified.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param string  $url_type
 * @return string
 */
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 "\n\t<input type='text' class='text urlfield' name='attachments[{$post->ID}][url]' value='" . esc_attr($url) . "' /><br />\n\t<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>\n\t<button type='button' class='button urlfile' data-link-url='" . esc_url($file) . "'>" . __('File URL') . "</button>\n\t<button type='button' class='button urlpost' data-link-url='" . esc_url($link) . "'>" . __('Attachment Post URL') . '</button>
';
}

WordPress Version: 5.5

/**
 * Retrieve HTML for the Link URL buttons with the default link type as specified.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param string  $url_type
 * @return string
 */
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 "\n\t<input type='text' class='text urlfield' name='attachments[{$post->ID}][url]' value='" . esc_attr($url) . "' /><br />\n\t<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>\n\t<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>\n\t<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . '</button>
';
}

WordPress Version: 5.4

/**
 * Retrieve HTML for the Link URL buttons with the default link type as specified.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param string $url_type
 * @return string
 */
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 "\n\t<input type='text' class='text urlfield' name='attachments[{$post->ID}][url]' value='" . esc_attr($url) . "' /><br />\n\t<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>\n\t<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>\n\t<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . '</button>
';
}

WordPress Version: 5.1

/**
 * Retrieve HTML for the Link URL buttons with the default link type as specified.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param string $url_type
 * @return string
 */
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 ($url_type == 'file') {
        $url = $file;
    } elseif ($url_type == 'post') {
        $url = $link;
    }
    return "\n\t<input type='text' class='text urlfield' name='attachments[{$post->ID}][url]' value='" . esc_attr($url) . "' /><br />\n\t<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>\n\t<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>\n\t<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . '</button>
';
}

WordPress Version: 4.1

/**
 * Retrieve HTML for the Link URL buttons with the default link type as specified.
 *
 * @since 2.7.0
 *
 * @param WP_Post $post
 * @param string $url_type
 * @return string
 */
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 ($url_type == 'file') {
        $url = $file;
    } elseif ($url_type == 'post') {
        $url = $link;
    }
    return "\n\t<input type='text' class='text urlfield' name='attachments[{$post->ID}][url]' value='" . esc_attr($url) . "' /><br />\n\t<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>\n\t<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>\n\t<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>\n";
}

WordPress Version: 3.7

/**
 * Retrieve HTML for the Link URL buttons with the default link type as specified.
 *
 * @since 2.7.0
 *
 * @param object $post
 * @param string $url_type
 * @return string
 */
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 ($url_type == 'file') {
        $url = $file;
    } elseif ($url_type == 'post') {
        $url = $link;
    }
    return "\n\t<input type='text' class='text urlfield' name='attachments[{$post->ID}][url]' value='" . esc_attr($url) . "' /><br />\n\t<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>\n\t<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>\n\t<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>\n";
}