acf_field_color_picker

The Advanced Custom Fields acf field color picker class.

Defined (1)

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

/core/fields/color_picker.php  
  1. class acf_field_color_picker extends acf_field 
  2.  
  3. /** 
  4. * __construct 
  5. * Set name / label needed for actions / filters 
  6. * @since 3.6 
  7. * @date 23/01/13 
  8. */ 
  9.  
  10. function __construct() 
  11. // vars 
  12. $this->name = 'color_picker'; 
  13. $this->label = __("Color Picker", 'acf'); 
  14. $this->category = __("jQuery", 'acf'); 
  15. $this->defaults = array( 
  16. 'default_value' => '',  
  17. ); 
  18.  
  19.  
  20. // do not delete! 
  21. parent::__construct(); 
  22.  
  23.  
  24.  
  25. /** 
  26. * create_field() 
  27. * Create the HTML interface for your field 
  28. * @param $field - an array holding all the field's data 
  29. * @type action 
  30. * @since 3.6 
  31. * @date 23/01/13 
  32. */ 
  33.  
  34. function create_field( $field ) 
  35. // vars 
  36. $o = array( 'id', 'class', 'name', 'value' ); 
  37. $e = ''; 
  38.  
  39.  
  40. $e .= '<div class="acf-color_picker">'; 
  41. $e .= '<input type="text"'; 
  42.  
  43. foreach( $o as $k ) 
  44. $e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';  
  45.  
  46. $e .= ' />'; 
  47. $e .= '</div>'; 
  48.  
  49.  
  50. // return 
  51. echo $e; 
  52.  
  53.  
  54. /** 
  55. * create_options() 
  56. * Create extra options for your field. This is rendered when editing a field. 
  57. * The value of $field['name'] can be used (like bellow) to save extra data to the $field 
  58. * @type action 
  59. * @since 3.6 
  60. * @date 23/01/13 
  61. * @param $field - an array holding all the field's data 
  62. */ 
  63.  
  64. function create_options( $field ) 
  65. // vars 
  66. $key = $field['name']; 
  67.  
  68. ?> 
  69. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  70. <td class="label"> 
  71. <label><?php _e("Default Value", 'acf'); ?></label> 
  72. </td> 
  73. <td> 
  74. <?php  
  75. do_action('acf/create_field', array( 
  76. 'type' => 'text',  
  77. 'name' => 'fields[' .$key.'][default_value]',  
  78. 'value' => $field['default_value'],  
  79. 'placeholder' => '#ffffff' 
  80. )); 
  81. ?> 
  82. </td> 
  83. </tr> 
  84. <?php 
  85.  
  86.