ACF qTranslate - Version 1.7.12

Version Description

  • Bug Fix: Fixed ACF5 Image/File edit and delete buttons
Download this release

Release Info

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

Code changes from version 1.7.11 to 1.7.12

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.11
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.12
7
  Author: funkjedi
8
  Author URI: http://funkjedi.com
9
  License: GPLv2 or later
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.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,6 +59,9 @@ The plugin is based on code samples posted to the ACF support forums by taeo bac
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
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.12
7
+ Stable tag: 1.7.12
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.12 =
63
+ * Bug Fix: Fixed ACF5 Image/File edit and delete buttons
64
+
65
  = 1.7.11 =
66
  * Core: Enable support for ACF included within theme
67
  * Bug Fix: Fixed do_action support when removing repeater rows
src/acf_5/fields/file.php CHANGED
@@ -62,37 +62,35 @@ class acf_qtranslate_acf_5_file extends acf_field_file {
62
  */
63
  function render_field($field) {
64
  global $q_config;
 
65
  $languages = qtrans_getSortedLanguages(true);
66
  $values = qtrans_split($field['value'], $quicktags = true);
67
  $currentLanguage = $this->plugin->get_active_language();
68
 
 
 
 
69
  // enqueue
70
- acf_enqueue_uploader();
 
 
71
 
72
  // vars
73
  $o = array(
74
  'icon' => '',
75
  'title' => '',
76
- 'size' => '',
77
  'url' => '',
78
- 'name' => '',
 
79
  );
80
 
81
  $div = array(
82
  'class' => 'acf-file-uploader acf-cf',
83
  'data-library' => $field['library'],
84
- 'data-mime_types' => $field['mime_types']
 
85
  );
86
 
87
- $input_atts = array(
88
- 'type' => 'hidden',
89
- 'name' => $field['name'],
90
- 'value' => $field['value'],
91
- 'data-name' => 'value-id'
92
- );
93
-
94
- $url = '';
95
-
96
  echo '<div class="multi-language-field multi-language-field-image">';
97
 
98
  foreach ($languages as $language) {
@@ -103,33 +101,32 @@ class acf_qtranslate_acf_5_file extends acf_field_file {
103
  echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
104
  }
105
 
 
 
106
  foreach ($languages as $language):
107
 
108
- $input_atts['name'] = $field['name'] . '[' . $language . ']';
109
  $field['value'] = $values[$language];
110
  $div['data-language'] = $language;
111
  $div['class'] = 'acf-file-uploader acf-cf';
112
 
113
  // has value?
114
- if( $field['value'] && is_numeric($field['value']) ) {
115
  $file = get_post( $field['value'] );
116
  if( $file ) {
117
- $div['class'] .= ' has-value';
118
-
119
  $o['icon'] = wp_mime_type_icon( $file->ID );
120
  $o['title'] = $file->post_title;
121
- $o['size'] = @size_format(filesize( get_attached_file( $file->ID ) ));
122
  $o['url'] = wp_get_attachment_url( $file->ID );
123
 
124
  $explode = explode('/', $o['url']);
125
- $o['name'] = end( $explode );
126
  }
127
- }
128
 
129
- // basic?
130
- $basic = !current_user_can('upload_files');
131
- if ($basic) {
132
- $div['class'] .= ' basic';
133
  }
134
 
135
  if ($language === $currentLanguage) {
@@ -139,7 +136,7 @@ class acf_qtranslate_acf_5_file extends acf_field_file {
139
  ?>
140
  <div <?php acf_esc_attr_e($div); ?>>
141
  <div class="acf-hidden">
142
- <?php acf_hidden_input(array( 'name' => $input_atts['name'], 'value' => $field['value'], 'data-name' => 'id' )); ?>
143
  </div>
144
  <div class="show-if-value file-wrap acf-soh">
145
  <div class="file-icon">
@@ -150,24 +147,24 @@ class acf_qtranslate_acf_5_file extends acf_field_file {
150
  <strong data-name="title"><?php echo $o['title']; ?></strong>
151
  </p>
152
  <p>
153
- <strong><?php _e('File Name', 'acf'); ?>:</strong>
154
- <a data-name="name" href="<?php echo $o['url']; ?>" target="_blank"><?php echo $o['name']; ?></a>
155
  </p>
156
  <p>
157
- <strong><?php _e('File Size', 'acf'); ?>:</strong>
158
- <span data-name="size"><?php echo $o['size']; ?></span>
159
  </p>
160
 
161
  <ul class="acf-hl acf-soh-target">
162
- <?php if( !$basic ): ?>
163
- <li><a class="acf-icon dark" data-name="edit" href="#"><i class="acf-sprite-edit"></i></a></li>
164
  <?php endif; ?>
165
- <li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
166
  </ul>
167
  </div>
168
  </div>
169
  <div class="hide-if-value">
170
- <?php if( $basic ): ?>
171
 
172
  <?php if( $field['value'] && !is_numeric($field['value']) ): ?>
173
  <div class="acf-error-message"><p><?php echo $field['value']; ?></p></div>
@@ -177,7 +174,7 @@ class acf_qtranslate_acf_5_file extends acf_field_file {
177
 
178
  <?php else: ?>
179
 
180
- <p style="margin:0;"><?php _e('No File selected','acf'); ?> <a data-name="add" class="acf-button" href="#"><?php _e('Add File','acf'); ?></a></p>
181
 
182
  <?php endif; ?>
183
 
62
  */
63
  function render_field($field) {
64
  global $q_config;
65
+
66
  $languages = qtrans_getSortedLanguages(true);
67
  $values = qtrans_split($field['value'], $quicktags = true);
68
  $currentLanguage = $this->plugin->get_active_language();
69
 
70
+ // vars
71
+ $uploader = acf_get_setting('uploader');
72
+
73
  // enqueue
74
+ if( $uploader == 'wp' ) {
75
+ acf_enqueue_uploader();
76
+ }
77
 
78
  // vars
79
  $o = array(
80
  'icon' => '',
81
  'title' => '',
 
82
  'url' => '',
83
+ 'filesize' => '',
84
+ 'filename' => '',
85
  );
86
 
87
  $div = array(
88
  'class' => 'acf-file-uploader acf-cf',
89
  'data-library' => $field['library'],
90
+ 'data-mime_types' => $field['mime_types'],
91
+ 'data-uploader' => $uploader
92
  );
93
 
 
 
 
 
 
 
 
 
 
94
  echo '<div class="multi-language-field multi-language-field-image">';
95
 
96
  foreach ($languages as $language) {
101
  echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
102
  }
103
 
104
+ $field_name = $field['name'];
105
+
106
  foreach ($languages as $language):
107
 
108
+ $field['name'] = $field_name . '[' . $language . ']';
109
  $field['value'] = $values[$language];
110
  $div['data-language'] = $language;
111
  $div['class'] = 'acf-file-uploader acf-cf';
112
 
113
  // has value?
114
+ if( $field['value'] ) {
115
  $file = get_post( $field['value'] );
116
  if( $file ) {
 
 
117
  $o['icon'] = wp_mime_type_icon( $file->ID );
118
  $o['title'] = $file->post_title;
119
+ $o['filesize'] = @size_format(filesize( get_attached_file( $file->ID ) ));
120
  $o['url'] = wp_get_attachment_url( $file->ID );
121
 
122
  $explode = explode('/', $o['url']);
123
+ $o['filename'] = end( $explode );
124
  }
 
125
 
126
+ // url exists
127
+ if( $o['url'] ) {
128
+ $div['class'] .= ' has-value';
129
+ }
130
  }
131
 
132
  if ($language === $currentLanguage) {
136
  ?>
137
  <div <?php acf_esc_attr_e($div); ?>>
138
  <div class="acf-hidden">
139
+ <?php acf_hidden_input(array( 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'id' )); ?>
140
  </div>
141
  <div class="show-if-value file-wrap acf-soh">
142
  <div class="file-icon">
147
  <strong data-name="title"><?php echo $o['title']; ?></strong>
148
  </p>
149
  <p>
150
+ <strong><?php _e('File name', 'acf'); ?>:</strong>
151
+ <a data-name="filename" href="<?php echo $o['url']; ?>" target="_blank"><?php echo $o['filename']; ?></a>
152
  </p>
153
  <p>
154
+ <strong><?php _e('File size', 'acf'); ?>:</strong>
155
+ <span data-name="filesize"><?php echo $o['filesize']; ?></span>
156
  </p>
157
 
158
  <ul class="acf-hl acf-soh-target">
159
+ <?php if( $uploader != 'basic' ): ?>
160
+ <li><a class="acf-icon -pencil dark" data-name="edit" href="#"></a></li>
161
  <?php endif; ?>
162
+ <li><a class="acf-icon -cancel dark" data-name="remove" href="#"></a></li>
163
  </ul>
164
  </div>
165
  </div>
166
  <div class="hide-if-value">
167
+ <?php if( $uploader == 'basic' ): ?>
168
 
169
  <?php if( $field['value'] && !is_numeric($field['value']) ): ?>
170
  <div class="acf-error-message"><p><?php echo $field['value']; ?></p></div>
174
 
175
  <?php else: ?>
176
 
177
+ <p style="margin:0;"><?php _e('No file selected','acf'); ?> <a data-name="add" class="acf-button button" href="#"><?php _e('Add File','acf'); ?></a></p>
178
 
179
  <?php endif; ?>
180
 
src/acf_5/fields/image.php CHANGED
@@ -67,29 +67,34 @@ class acf_qtranslate_acf_5_image extends acf_field_image {
67
  */
68
  function render_field($field) {
69
  global $q_config;
 
70
  $languages = qtrans_getSortedLanguages(true);
71
  $values = qtrans_split($field['value'], $quicktags = true);
72
  $currentLanguage = $this->plugin->get_active_language();
73
 
 
 
 
 
74
  // enqueue
75
- acf_enqueue_uploader();
 
 
76
 
77
  // vars
 
 
78
  $div = array(
79
  'class' => 'acf-image-uploader acf-cf',
80
  'data-preview_size' => $field['preview_size'],
81
  'data-library' => $field['library'],
82
- 'data-mime_types' => $field['mime_types']
 
83
  );
84
 
85
- $input_atts = array(
86
- 'type' => 'hidden',
87
- 'name' => $field['name'],
88
- 'value' => $field['value'],
89
- 'data-name' => 'value-id'
90
- );
91
 
92
- $url = '';
93
 
94
  echo '<div class="multi-language-field multi-language-field-image">';
95
 
@@ -101,25 +106,28 @@ class acf_qtranslate_acf_5_image extends acf_field_image {
101
  echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
102
  }
103
 
 
 
104
  foreach ($languages as $language):
105
 
106
- $input_atts['name'] = $field['name'] . '[' . $language . ']';
107
  $field['value'] = $values[$language];
108
  $div['data-language'] = $language;
109
  $div['class'] = 'acf-image-uploader acf-cf';
110
 
111
  // has value?
112
- if( $field['value'] && is_numeric($field['value']) ) {
 
113
  $url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
114
- $url = $url[0];
115
 
116
- $div['class'] .= ' has-value';
117
- }
118
 
119
- // basic?
120
- $basic = !current_user_can('upload_files');
121
- if ($basic) {
122
- $div['class'] .= ' basic';
123
  }
124
 
125
  if ($language === $currentLanguage) {
@@ -129,25 +137,30 @@ class acf_qtranslate_acf_5_image extends acf_field_image {
129
  ?>
130
  <div <?php acf_esc_attr_e( $div ); ?>>
131
  <div class="acf-hidden">
132
- <?php acf_hidden_input(array( 'name' => $input_atts['name'], 'value' => $field['value'], 'data-name' => 'id' )); ?>
133
  </div>
134
- <div class="view show-if-value acf-soh">
135
- <img data-name="image" src="<?php echo $url; ?>" alt=""/>
136
  <ul class="acf-hl acf-soh-target">
137
- <?php if( !$basic ): ?>
138
- <li><a class="acf-icon dark" data-name="edit" href="#"><i class="acf-sprite-edit"></i></a></li>
139
  <?php endif; ?>
140
- <li><a class="acf-icon dark" data-name="remove" href="#"><i class="acf-sprite-delete"></i></a></li>
141
  </ul>
142
  </div>
143
  <div class="view hide-if-value">
144
- <?php if( $basic ): ?>
 
145
  <?php if( $field['value'] && !is_numeric($field['value']) ): ?>
146
  <div class="acf-error-message"><p><?php echo $field['value']; ?></p></div>
147
  <?php endif; ?>
 
148
  <input type="file" name="<?php echo $field['name']; ?>" id="<?php echo $field['id']; ?>" />
 
149
  <?php else: ?>
150
- <p style="margin:0;"><?php _e('No image selected','acf'); ?> <a data-name="add" class="acf-button" href="#"><?php _e('Add Image','acf'); ?></a></p>
 
 
151
  <?php endif; ?>
152
  </div>
153
  </div>
67
  */
68
  function render_field($field) {
69
  global $q_config;
70
+
71
  $languages = qtrans_getSortedLanguages(true);
72
  $values = qtrans_split($field['value'], $quicktags = true);
73
  $currentLanguage = $this->plugin->get_active_language();
74
 
75
+
76
+ // vars
77
+ $uploader = acf_get_setting('uploader');
78
+
79
  // enqueue
80
+ if( $uploader == 'wp' ) {
81
+ acf_enqueue_uploader();
82
+ }
83
 
84
  // vars
85
+ $url = '';
86
+ $alt = '';
87
  $div = array(
88
  'class' => 'acf-image-uploader acf-cf',
89
  'data-preview_size' => $field['preview_size'],
90
  'data-library' => $field['library'],
91
+ 'data-mime_types' => $field['mime_types'],
92
+ 'data-uploader' => $uploader
93
  );
94
 
95
+ // get size of preview value
96
+ $size = acf_get_image_size($field['preview_size']);
 
 
 
 
97
 
 
98
 
99
  echo '<div class="multi-language-field multi-language-field-image">';
100
 
106
  echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
107
  }
108
 
109
+ $field_name = $field['name'];
110
+
111
  foreach ($languages as $language):
112
 
113
+ $field['name'] = $field_name . '[' . $language . ']';
114
  $field['value'] = $values[$language];
115
  $div['data-language'] = $language;
116
  $div['class'] = 'acf-image-uploader acf-cf';
117
 
118
  // has value?
119
+ if( $field['value'] ) {
120
+ // update vars
121
  $url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
122
+ $alt = get_post_meta($field['value'], '_wp_attachment_image_alt', true);
123
 
124
+ // url exists
125
+ if( $url ) $url = $url[0];
126
 
127
+ // url exists
128
+ if( $url ) {
129
+ $div['class'] .= ' has-value';
130
+ }
131
  }
132
 
133
  if ($language === $currentLanguage) {
137
  ?>
138
  <div <?php acf_esc_attr_e( $div ); ?>>
139
  <div class="acf-hidden">
140
+ <?php acf_hidden_input(array( 'name' => $field['name'], 'value' => $field['value'] )); ?>
141
  </div>
142
+ <div class="view show-if-value acf-soh" <?php if( $size['width'] ) echo 'style="max-width: '.$size['width'].'px"'; ?>>
143
+ <img data-name="image" src="<?php echo $url; ?>" alt="<?php echo $alt; ?>"/>
144
  <ul class="acf-hl acf-soh-target">
145
+ <?php if( $uploader != 'basic' ): ?>
146
+ <li><a class="acf-icon -pencil dark" data-name="edit" href="#" title="<?php _e('Edit', 'acf'); ?>"></a></li>
147
  <?php endif; ?>
148
+ <li><a class="acf-icon -cancel dark" data-name="remove" href="#" title="<?php _e('Remove', 'acf'); ?>"></a></li>
149
  </ul>
150
  </div>
151
  <div class="view hide-if-value">
152
+ <?php if( $uploader == 'basic' ): ?>
153
+
154
  <?php if( $field['value'] && !is_numeric($field['value']) ): ?>
155
  <div class="acf-error-message"><p><?php echo $field['value']; ?></p></div>
156
  <?php endif; ?>
157
+
158
  <input type="file" name="<?php echo $field['name']; ?>" id="<?php echo $field['id']; ?>" />
159
+
160
  <?php else: ?>
161
+
162
+ <p style="margin:0;"><?php _e('No image selected','acf'); ?> <a data-name="add" class="acf-button button" href="#"><?php _e('Add Image','acf'); ?></a></p>
163
+
164
  <?php endif; ?>
165
  </div>
166
  </div>