acf_qtranslate_acf_4_text

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

Defined (1)

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

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