acf_qtranslate_acf_4_wysiwyg

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

Defined (1)

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

/src/acf_4/fields/wysiwyg.php  
  1. class acf_qtranslate_acf_4_wysiwyg extends acf_field_wysiwyg { 
  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_wysiwyg'; 
  20. $this->label = __("Wysiwyg Editor", 'acf'); 
  21. $this->category = __("qTranslate", 'acf'); 
  22. $this->defaults = array( 
  23. 'toolbar' => 'full',  
  24. 'media_upload' => 'yes',  
  25. 'default_value' => '',  
  26. ); 
  27.  
  28. acf_field::__construct(); 
  29.  
  30. /** 
  31. * input_admin_head() 
  32. * This action is called in the admin_head action on the edit screen where your field is created. 
  33. * Use this action to add css and javascript to assist your create_field() action. 
  34. * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head 
  35. * @type action 
  36. * @since 3.6 
  37. * @date 23/01/13 
  38. */ 
  39. function input_admin_head() {} 
  40.  
  41. /** 
  42. * create_field() 
  43. * Create the HTML interface for your field 
  44. * @param $field - an array holding all the field's data 
  45. * @type action 
  46. * @since 3.6 
  47. * @date 23/01/13 
  48. */ 
  49. function create_field($field) { 
  50. global $q_config, $wp_version; 
  51. $languages = qtrans_getSortedLanguages(true); 
  52. $values = qtrans_split($field['value'], $quicktags = true); 
  53. $currentLanguage = $this->plugin->get_active_language(); 
  54.  
  55. echo '<div class="multi-language-field multi-language-field-wysiwyg">'; 
  56.  
  57. foreach ($languages as $language) { 
  58. $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor'; 
  59. echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>'; 
  60.  
  61. foreach ($languages as $language): 
  62. $value = $values[$language]; 
  63. $id = 'wysiwyg-' . $field['id'] . '-' . uniqid(); 
  64. $name = $field['name'] . "[$language]"; 
  65. $class = ($language === $currentLanguage) ? 'acf_wysiwyg wp-editor-wrap current-language' : 'acf_wysiwyg wp-editor-wrap'; 
  66.  
  67. ?> 
  68. <div id="wp-<?php echo $id; ?>-wrap" class="<?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>"> 
  69. <?php if( user_can_richedit() && $field['media_upload'] == 'yes' ): ?> 
  70. <?php if( version_compare($wp_version, '3.3', '<') ): ?> 
  71. <div id="editor-toolbar"> 
  72. <div id="media-buttons" class="hide-if-no-js"> 
  73. <?php do_action( 'media_buttons' ); ?> 
  74. </div> 
  75. </div> 
  76. <?php else: ?> 
  77. <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools"> 
  78. <div id="wp-<?php echo $id; ?>-media-buttons" class="hide-if-no-js wp-media-buttons"> 
  79. <?php do_action( 'media_buttons' ); ?> 
  80. </div> 
  81. </div> 
  82. <?php endif; ?> 
  83. <?php endif; ?> 
  84. <div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container"> 
  85. <textarea id="<?php echo $id; ?>" class="qtx-wp-editor-area" name="<?php echo $name; ?>" ><?php 
  86.  
  87. if( user_can_richedit() ) 
  88. echo wp_richedit_pre( $field['value'] ); 
  89. else 
  90. echo wp_htmledit_pre( $field['value'] ); 
  91.  
  92. ?></textarea> 
  93. </div> 
  94. </div> 
  95. <?php endforeach; 
  96.  
  97. echo '</div>'; 
  98.  
  99. /** 
  100. * format_value 
  101. * @description: uses the basic value and allows the field type to format it 
  102. * @since: 3.6 
  103. * @created: 26/01/13 
  104. */ 
  105. function format_value($value, $post_id, $field) { 
  106. return $value; 
  107.  
  108. /** 
  109. * format_value_for_api() 
  110. * 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 
  111. * @type filter 
  112. * @since 3.6 
  113. * @date 23/01/13 
  114. * @param $value - the value which was loaded from the database 
  115. * @param $post_id - the $post_id from which the value was loaded 
  116. * @param $field - the field array holding all the field options 
  117. * @return $value - the modified value 
  118. */ 
  119. function format_value_for_api($value, $post_id, $field) { 
  120. $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value); 
  121. return parent::format_value_for_api($value, $post_id, $field); 
  122.  
  123. /** 
  124. * update_value() 
  125. * This filter is appied to the $value before it is updated in the db 
  126. * @type filter 
  127. * @since 3.6 
  128. * @date 23/01/13 
  129. * @param $value - the value which will be saved in the database 
  130. * @param $post_id - the $post_id of which the value will be saved 
  131. * @param $field - the field array holding all the field options 
  132. * @return $value - the modified value 
  133. */ 
  134. function update_value($value, $post_id, $field) { 
  135. return qtrans_join($value); 
  136.