image_align_input_fields

Retrieve HTML for the image alignment radio buttons with the specified one checked.

Description

(string) image_align_input_fields( (WP_Post) $post, (string) $checked = '' ); 

Returns (string)

Parameters (2)

0. $post (WP_Post)
The post.
1. $checked — Optional. (string) => ''
The checked.

Usage

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

Defined (1)

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

/wp-admin/includes/media.php  
  1. function image_align_input_fields( $post, $checked = '' ) { 
  2.  
  3. if ( empty($checked) ) 
  4. $checked = get_user_setting('align', 'none'); 
  5.  
  6. $alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right')); 
  7. if ( !array_key_exists( (string) $checked, $alignments ) ) 
  8. $checked = 'none'; 
  9.  
  10. $out = array(); 
  11. foreach ( $alignments as $name => $label ) { 
  12. $name = esc_attr($name); 
  13. $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'". 
  14. ( $checked == $name ? " checked='checked'" : "" ) . 
  15. " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; 
  16. return join("\n", $out);