image_link_input_fields

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

Description

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

Returns (string)

Parameters (2)

0. $post (WP_Post)
The post.
1. $url_type — Optional. (string) => ''
The url type.

Usage

  1. if ( !function_exists( 'image_link_input_fields' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/media.php'; 
  3.  
  4. // The post. 
  5. $post = null; 
  6.  
  7. // The url type. 
  8. $url_type = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = image_link_input_fields($post, $url_type); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/media.php  
  1. function image_link_input_fields($post, $url_type = '') { 
  2.  
  3. $file = wp_get_attachment_url($post->ID); 
  4. $link = get_attachment_link($post->ID); 
  5.  
  6. if ( empty($url_type) ) 
  7. $url_type = get_user_setting('urlbutton', 'post'); 
  8.  
  9. $url = ''; 
  10. if ( $url_type == 'file' ) 
  11. $url = $file; 
  12. elseif ( $url_type == 'post' ) 
  13. $url = $link; 
  14.  
  15. return " 
  16. <input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br /> 
  17. <button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button> 
  18. <button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button> 
  19. <button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button> 
  20. ";