acf_qtranslate_acf_5_textarea

The Advanced Custom Fields: qTranslate acf qtranslate 5 textarea class.

Defined (1)

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

/src/acf_5/fields/textarea.php  
  1. class acf_qtranslate_acf_5_textarea extends acf_field_textarea { 
  2.  
  3. /** 
  4. * The plugin instance. 
  5. * @var \acf_qtranslate\plugin 
  6. */ 
  7. protected $plugin; 
  8.  
  9.  
  10. /** 
  11. * __construct 
  12. * This function will setup the field type data 
  13. * @type function 
  14. * @date 5/03/2014 
  15. * @since 5.0.0 
  16. * @param n/a 
  17. * @return n/a 
  18. */ 
  19. function __construct($plugin) { 
  20. $this->plugin = $plugin; 
  21.  
  22. $this->name = 'qtranslate_textarea'; 
  23. $this->label = __("Text Area", 'acf'); 
  24. $this->category = __("qTranslate", 'acf'); 
  25. $this->defaults = array( 
  26. 'default_value' => '',  
  27. 'new_lines' => '',  
  28. 'maxlength' => '',  
  29. 'placeholder' => '',  
  30. 'readonly' => 0,  
  31. 'disabled' => 0,  
  32. 'rows' => '' 
  33. ); 
  34.  
  35. acf_field::__construct(); 
  36.  
  37. /** 
  38. * render_field() 
  39. * Create the HTML interface for your field 
  40. * @param $field - an array holding all the field's data 
  41. * @type action 
  42. * @since 3.6 
  43. * @date 23/01/13 
  44. */ 
  45. function render_field($field) { 
  46. global $q_config; 
  47. $languages = qtrans_getSortedLanguages(true); 
  48. $values = qtrans_split($field['value'], $quicktags = true); 
  49. $currentLanguage = $this->plugin->get_active_language(); 
  50.  
  51. // vars 
  52. $o = array( 'id', 'class', 'name', 'placeholder', 'rows' ); 
  53. $s = array( 'readonly', 'disabled' ); 
  54. $e = ''; 
  55.  
  56. // maxlength 
  57. if( $field['maxlength'] !== '' ) { 
  58. $o[] = 'maxlength'; 
  59.  
  60. // rows 
  61. if( empty($field['rows']) ) { 
  62. $field['rows'] = 8; 
  63.  
  64. // populate atts 
  65. $atts = array(); 
  66. foreach( $o as $k ) { 
  67. $atts[ $k ] = $field[ $k ]; 
  68.  
  69. // special atts 
  70. foreach( $s as $k ) { 
  71. if( $field[ $k ] ) { 
  72. $atts[ $k ] = $k; 
  73.  
  74. // render 
  75. $e .= '<div class="acf-input-wrap multi-language-field">'; 
  76.  
  77. foreach ($languages as $language) { 
  78. $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor'; 
  79. $e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>'; 
  80.  
  81. foreach ($languages as $language) { 
  82. $atts['class'] = $field['class']; 
  83. if ($language === $currentLanguage) { 
  84. $atts['class'] .= ' current-language'; 
  85. $atts['name'] = $field['name'] . "[$language]"; 
  86. $atts['data-language'] = $language; 
  87. $e .= '<textarea ' . acf_esc_attr( $atts ) . ' >'; 
  88. $e .= esc_textarea( $values[$language] ); 
  89. $e .= '</textarea>'; 
  90.  
  91. $e .= '</div>'; 
  92.  
  93. // return 
  94. echo $e; 
  95.  
  96. /** 
  97. * update_value() 
  98. * This filter is appied to the $value before it is updated in the db 
  99. * @type filter 
  100. * @since 3.6 
  101. * @date 23/01/13 
  102. * @param $value - the value which will be saved in the database 
  103. * @param $post_id - the $post_id of which the value will be saved 
  104. * @param $field - the field array holding all the field options 
  105. * @return $value - the modified value 
  106. */ 
  107. function update_value($value, $post_id, $field) { 
  108. return qtrans_join($value); 
  109.