ACF qTranslate - Version 1.7.11

Version Description

  • Core: Enable support for ACF included within theme
  • Bug Fix: Fixed do_action support when removing repeater rows
  • Bug Fix: Removing qTranslateConfig.qtx.addContentHooksTinyMCE calls
Download this release

Release Info

Developer funkjedi
Plugin Icon wp plugin ACF qTranslate
Version 1.7.11
Comparing to
See all releases

Code changes from version 1.7.10 to 1.7.11

acf-qtranslate.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields: qTranslate
4
  Plugin URI: http://github.com/funkjedi/acf-qtranslate
5
  Description: Provides multilingual versions of the text, text area, and wysiwyg fields.
6
- Version: 1.7.10
7
  Author: funkjedi
8
  Author URI: http://funkjedi.com
9
  License: GPLv2 or later
3
  Plugin Name: Advanced Custom Fields: qTranslate
4
  Plugin URI: http://github.com/funkjedi/acf-qtranslate
5
  Description: Provides multilingual versions of the text, text area, and wysiwyg fields.
6
+ Version: 1.7.11
7
  Author: funkjedi
8
  Author URI: http://funkjedi.com
9
  License: GPLv2 or later
assets/acf_5/qtranslatex.js CHANGED
@@ -59,7 +59,7 @@
59
  qTranslateConfig.qtx.addContentHookC(field, form);
60
 
61
  if (jQuery(field).hasClass('wp-editor-area')) {
62
- qTranslateConfig.qtx.addContentHooksTinyMCE();
63
 
64
  // We must manually trigger load event so that the
65
  // loadTinyMceHooks function which calls setEditorHooks is executed
@@ -74,19 +74,19 @@
74
 
75
  });
76
 
77
- qTranslateConfig.qtx.addContentHooksTinyMCE();
78
 
79
  // Watch and remove content hooks when fields are removed
80
  // however ACF removes the elements from the DOM early so
81
  // we must hook into handler and perform updates there
82
  var _hooked_repeater_remove = acf.fields.repeater.remove;
83
- acf.fields.repeater.remove = function(event) {
84
- var row = event.$el.closest('.acf-row');
85
  row.find(_.toArray(field_types).join(',')).filter('.qtranxs-translatable').each(function() {
86
  qTranslateConfig.qtx.removeContentHook(this);
87
  });
88
  // call the original handler
89
- _hooked_repeater_remove.call(this, event);
90
  };
91
 
92
  });
59
  qTranslateConfig.qtx.addContentHookC(field, form);
60
 
61
  if (jQuery(field).hasClass('wp-editor-area')) {
62
+ //qTranslateConfig.qtx.addContentHooksTinyMCE();
63
 
64
  // We must manually trigger load event so that the
65
  // loadTinyMceHooks function which calls setEditorHooks is executed
74
 
75
  });
76
 
77
+ //qTranslateConfig.qtx.addContentHooksTinyMCE();
78
 
79
  // Watch and remove content hooks when fields are removed
80
  // however ACF removes the elements from the DOM early so
81
  // we must hook into handler and perform updates there
82
  var _hooked_repeater_remove = acf.fields.repeater.remove;
83
+ acf.fields.repeater.remove = function($el) {
84
+ var row = ($el.$el || $el).closest('.acf-row'); // support old versions of ACF5PRO as well
85
  row.find(_.toArray(field_types).join(',')).filter('.qtranxs-translatable').each(function() {
86
  qTranslateConfig.qtx.removeContentHook(this);
87
  });
88
  // call the original handler
89
+ _hooked_repeater_remove.call(this, $el);
90
  };
91
 
92
  });
assets/common.css CHANGED
@@ -28,7 +28,7 @@
28
  margin-top: -6px;
29
  }
30
 
31
- .multi-language-field .wp-switch-editor {
32
  float: right;
33
  position: relative;
34
  top: 1px;
28
  margin-top: -6px;
29
  }
30
 
31
+ .multi-language-field > .wp-switch-editor {
32
  float: right;
33
  position: relative;
34
  top: 1px;
assets/common.js CHANGED
@@ -44,8 +44,8 @@ jQuery(function($) {
44
  var id = $(this).attr( 'data-wp-editor-id' );
45
  if (id) { // WP 4.3
46
  window.switchEditors.go(id, editor);
47
- } else { // WP < 4.3
48
- switchEditors.switchto(this);
49
  }
50
  });
51
  });
44
  var id = $(this).attr( 'data-wp-editor-id' );
45
  if (id) { // WP 4.3
46
  window.switchEditors.go(id, editor);
47
+ } else { // WP < 4.3
48
+ switchEditors.switchto(this);
49
  }
50
  });
51
  });
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: funkjedi
3
  Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
  Requires at least: 3.5.0
5
  Tested up to: 4.2.1
6
- Version: 1.7.10
7
- Stable tag: 1.7.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -59,6 +59,11 @@ The plugin is based on code samples posted to the ACF support forums by taeo bac
59
 
60
  == Changelog ==
61
 
 
 
 
 
 
62
  = 1.7.10 =
63
  * Bug Fix: (HeikoMamerow) ACF5 File compatibility fix
64
  * Bug Fix: (Tusko) ACF5 Image compatibility fix
3
  Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
  Requires at least: 3.5.0
5
  Tested up to: 4.2.1
6
+ Version: 1.7.11
7
+ Stable tag: 1.7.11
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
59
 
60
  == Changelog ==
61
 
62
+ = 1.7.11 =
63
+ * Core: Enable support for ACF included within theme
64
+ * Bug Fix: Fixed do_action support when removing repeater rows
65
+ * Bug Fix: Removing qTranslateConfig.qtx.addContentHooksTinyMCE calls
66
+
67
  = 1.7.10 =
68
  * Bug Fix: (HeikoMamerow) ACF5 File compatibility fix
69
  * Bug Fix: (Tusko) ACF5 Image compatibility fix
src/acf_5/fields/wysiwyg.php CHANGED
@@ -34,20 +34,8 @@ class acf_qtranslate_acf_5_wysiwyg extends acf_field_wysiwyg {
34
  'default_value' => '',
35
  );
36
 
37
- // Create an acf version of the_content filter (acf_the_content)
38
- if( !empty($GLOBALS['wp_embed']) ) {
39
- add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
40
- add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
41
- }
42
-
43
- add_filter( 'acf_the_content', 'capital_P_dangit', 11 );
44
- add_filter( 'acf_the_content', 'wptexturize' );
45
- add_filter( 'acf_the_content', 'convert_smilies' );
46
- add_filter( 'acf_the_content', 'convert_chars' );
47
- add_filter( 'acf_the_content', 'wpautop' );
48
- add_filter( 'acf_the_content', 'shortcode_unautop' );
49
- add_filter( 'acf_the_content', 'prepend_attachment' );
50
- add_filter( 'acf_the_content', 'do_shortcode', 11);
51
 
52
  // actions
53
  add_action('acf/input/admin_footer', array($this, 'input_admin_footer'));
@@ -68,51 +56,89 @@ class acf_qtranslate_acf_5_wysiwyg extends acf_field_wysiwyg {
68
  */
69
  function render_field($field) {
70
 
 
 
 
 
71
  // enqueue
72
  acf_enqueue_uploader();
73
 
 
74
  // vars
75
  $id = uniqid('acf-editor-');
76
- //$id = $field['id'] . '-' . uniqid();
77
- $mode = 'html';
78
  $show_tabs = true;
 
 
79
 
80
  // get height
81
  $height = acf_get_user_setting('wysiwyg_height', 300);
82
  $height = max( $height, 300 ); // minimum height is 300
83
 
 
84
  // detect mode
85
- // case: visual tab only
86
- if ($field['tabs'] == 'visual') {
87
- $mode = 'tmce';
88
  $show_tabs = false;
89
- }
90
- // case: text tab only
91
- elseif ($field['tabs'] == 'text') {
 
 
92
  $show_tabs = false;
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
- // case: both tabs
95
- elseif (wp_default_editor() == 'tinymce') {
96
- $mode = 'tmce';
 
 
 
 
97
  }
98
 
 
99
  // mode
100
- $switch_class = ($mode === 'html') ? 'html-active' : 'tmce-active';
 
101
 
102
  // filter value for editor
103
- remove_all_filters('acf_the_editor_content');
104
-
105
- global $q_config, $wp_version;
106
-
 
107
  // WP 4.3
108
  if( version_compare($wp_version, '4.3', '>=' ) ) {
109
- add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
 
 
 
 
110
  // WP < 4.3
111
  } else {
112
- $function = ($mode === 'html') ? 'wp_htmledit_pre' : 'wp_richedit_pre';
113
- add_filter('acf_the_editor_content', $function, 10, 1);
 
 
 
 
 
114
  }
115
-
 
 
 
116
  $languages = qtrans_getSortedLanguages(true);
117
  $values = qtrans_split($field['value'], $quicktags = true);
118
  $currentLanguage = $this->plugin->get_active_language();
@@ -126,23 +152,24 @@ class acf_qtranslate_acf_5_wysiwyg extends acf_field_wysiwyg {
126
 
127
  $uid = uniqid('acf-editor-');
128
  foreach ($languages as $language):
129
-
130
  $id = $uid . "-$language";
131
  $name = $field['name'] . "[$language]";
132
  $class = $switch_class;
133
  if ($language === $currentLanguage) {
134
  $class .= ' current-language';
135
  }
 
136
  // WP 4.3
137
  if( version_compare($wp_version, '4.3', '>=' ) ) {
138
- $button = 'data-wp-editor-id="' . $id . '"';
139
  // WP < 4.3
140
- } else {
141
- $button = 'onclick="switchEditors.switchto(this);"';
142
  }
143
-
144
- $value = apply_filters('acf_the_editor_content', $values[$language], $mode);
145
-
146
  ?>
147
  <div id="wp-<?php echo $id; ?>-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
148
  <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
34
  'default_value' => '',
35
  );
36
 
37
+ // add acf_the_content filters
38
+ $this->add_filters();
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  // actions
41
  add_action('acf/input/admin_footer', array($this, 'input_admin_footer'));
56
  */
57
  function render_field($field) {
58
 
59
+ // global
60
+ global $wp_version;
61
+
62
+
63
  // enqueue
64
  acf_enqueue_uploader();
65
 
66
+
67
  // vars
68
  $id = uniqid('acf-editor-');
69
+ $default_editor = 'html';
 
70
  $show_tabs = true;
71
+ $button = '';
72
+
73
 
74
  // get height
75
  $height = acf_get_user_setting('wysiwyg_height', 300);
76
  $height = max( $height, 300 ); // minimum height is 300
77
 
78
+
79
  // detect mode
80
+ if( !user_can_richedit() ) {
81
+
 
82
  $show_tabs = false;
83
+
84
+ } elseif( $field['tabs'] == 'visual' ) {
85
+
86
+ // case: visual tab only
87
+ $default_editor = 'tinymce';
88
  $show_tabs = false;
89
+
90
+ } elseif( $field['tabs'] == 'text' ) {
91
+
92
+ // case: text tab only
93
+ $show_tabs = false;
94
+
95
+ } elseif( wp_default_editor() == 'tinymce' ) {
96
+
97
+ // case: both tabs
98
+ $default_editor = 'tinymce';
99
+
100
  }
101
+
102
+
103
+ // must be logged in tp upload
104
+ if( !current_user_can('upload_files') ) {
105
+
106
+ $field['media_upload'] = 0;
107
+
108
  }
109
 
110
+
111
  // mode
112
+ $switch_class = ($default_editor === 'html') ? 'html-active' : 'tmce-active';
113
+
114
 
115
  // filter value for editor
116
+ remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
117
+ remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 );
118
+ remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 );
119
+
120
+
121
  // WP 4.3
122
  if( version_compare($wp_version, '4.3', '>=' ) ) {
123
+
124
+ add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
125
+
126
+ $button = 'data-wp-editor-id="' . $id . '"';
127
+
128
  // WP < 4.3
129
  } else {
130
+
131
+ $function = ($default_editor === 'html') ? 'wp_htmledit_pre' : 'wp_richedit_pre';
132
+
133
+ add_filter('acf_the_editor_content', $function, 10, 1);
134
+
135
+ $button = 'onclick="switchEditors.switchto(this);"';
136
+
137
  }
138
+
139
+
140
+ global $q_config;
141
+
142
  $languages = qtrans_getSortedLanguages(true);
143
  $values = qtrans_split($field['value'], $quicktags = true);
144
  $currentLanguage = $this->plugin->get_active_language();
152
 
153
  $uid = uniqid('acf-editor-');
154
  foreach ($languages as $language):
155
+
156
  $id = $uid . "-$language";
157
  $name = $field['name'] . "[$language]";
158
  $class = $switch_class;
159
  if ($language === $currentLanguage) {
160
  $class .= ' current-language';
161
  }
162
+
163
  // WP 4.3
164
  if( version_compare($wp_version, '4.3', '>=' ) ) {
165
+ $button = 'data-wp-editor-id="' . $id . '"';
166
  // WP < 4.3
167
+ } else {
168
+ $button = 'onclick="switchEditors.switchto(this);"';
169
  }
170
+
171
+ $value = apply_filters('acf_the_editor_content', $values[$language], $default_editor);
172
+
173
  ?>
174
  <div id="wp-<?php echo $id; ?>-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
175
  <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
src/plugin.php CHANGED
@@ -14,7 +14,7 @@ class acf_qtranslate_plugin {
14
  * @return void
15
  */
16
  public function __construct() {
17
- add_action('plugins_loaded', array($this, 'plugins_loaded'), 3);
18
  add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
19
  add_action('admin_menu', array($this, 'admin_menu'));
20
  add_action('admin_init', array($this, 'admin_init'));
@@ -26,7 +26,7 @@ class acf_qtranslate_plugin {
26
  * Setup plugin if Advanced Custom Fields is enabled.
27
  * @return void
28
  */
29
- public function plugins_loaded() {
30
  if ($this->acf_enabled() && $this->qtranslate_variant_enabled()) {
31
 
32
  // setup qtranslate fields for ACF 4
14
  * @return void
15
  */
16
  public function __construct() {
17
+ add_action('after_setup_theme', array($this, 'after_setup_theme'), 3);
18
  add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
19
  add_action('admin_menu', array($this, 'admin_menu'));
20
  add_action('admin_init', array($this, 'admin_init'));
26
  * Setup plugin if Advanced Custom Fields is enabled.
27
  * @return void
28
  */
29
+ public function after_setup_theme() {
30
  if ($this->acf_enabled() && $this->qtranslate_variant_enabled()) {
31
 
32
  // setup qtranslate fields for ACF 4