acf_qtranslate_acf_4_textarea

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

Defined (1)

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

/src/acf_4/fields/textarea.php  
  1. class acf_qtranslate_acf_4_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. * Set name / label needed for actions / filters 
  13. * @since 3.6 
  14. * @date 23/01/13 
  15. */ 
  16. function __construct($plugin) { 
  17. $this->plugin = $plugin; 
  18.  
  19. $this->name = 'qtranslate_textarea'; 
  20. $this->label = __("Text Area", 'acf'); 
  21. $this->category = __("qTranslate", 'acf'); 
  22. $this->defaults = array( 
  23. 'default_value' => '',  
  24. 'formatting' => 'br',  
  25. 'maxlength' => '',  
  26. 'placeholder' => '',  
  27. 'rows' => '' 
  28. ); 
  29.  
  30. acf_field::__construct(); 
  31.  
  32. /** 
  33. * create_field() 
  34. * Create the HTML interface for your field 
  35. * @param $field - an array holding all the field's data 
  36. * @type action 
  37. * @since 3.6 
  38. * @date 23/01/13 
  39. */ 
  40. function create_field($field) { 
  41. global $q_config; 
  42. $languages = qtrans_getSortedLanguages(true); 
  43. $values = qtrans_split($field['value'], $quicktags = true); 
  44. $currentLanguage = $this->plugin->get_active_language(); 
  45.  
  46. echo '<div class="multi-language-field">'; 
  47.  
  48. foreach ($languages as $language) { 
  49. $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor'; 
  50. echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>'; 
  51.  
  52. foreach ($languages as $language) { 
  53. $class = ($language === $currentLanguage) ? $field['class'] . ' current-language' : $field['class']; 
  54. echo '<textarea data-language="' . esc_attr($language) . '" id="' . esc_attr( $field['id'] ) . '" rows="4" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[$language]") . '">' . esc_textarea($values[$language]) . '</textarea>'; 
  55.  
  56. echo '</div>'; 
  57.  
  58. /** 
  59. * format_value 
  60. * @description: uses the basic value and allows the field type to format it 
  61. * @since: 3.6 
  62. * @created: 26/01/13 
  63. */ 
  64. function format_value($value, $post_id, $field) { 
  65. return $value; 
  66.  
  67. /** 
  68. * format_value_for_api() 
  69. * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field 
  70. * @type filter 
  71. * @since 3.6 
  72. * @date 23/01/13 
  73. * @param $value - the value which was loaded from the database 
  74. * @param $post_id - the $post_id from which the value was loaded 
  75. * @param $field - the field array holding all the field options 
  76. * @return $value - the modified value 
  77. */ 
  78. function format_value_for_api($value, $post_id, $field) { 
  79. $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value); 
  80. return parent::format_value_for_api($value, $post_id, $field); 
  81.  
  82. /** 
  83. * update_value() 
  84. * This filter is appied to the $value before it is updated in the db 
  85. * @type filter 
  86. * @since 3.6 
  87. * @date 23/01/13 
  88. * @param $value - the value which will be saved in the database 
  89. * @param $post_id - the $post_id of which the value will be saved 
  90. * @param $field - the field array holding all the field options 
  91. * @return $value - the modified value 
  92. */ 
  93. function update_value($value, $post_id, $field) { 
  94. return qtrans_join($value); 
  95.