Version Description
- Fixes returning empty table after saving content containing a single quote.
Download this release
Release Info
Developer | Jonua |
Plugin | Advanced Custom Fields: Table Field |
Version | 1.3.3 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.3.3
- acf-table-v4.php +45 -2
- acf-table-v5.php +44 -2
- acf-table.php +1 -1
- changelog.txt +5 -2
- js/input-v4.js +1 -1
- js/input-v5.js +1 -1
- lang/acf-table-da_DK.po +2 -2
- lang/acf-table-de_DE.po +2 -2
- lang/acf-table-pl_PL.po +2 -2
- lang/acf-table.pot +2 -2
- readme.txt +44 -7
acf-table-v4.php
CHANGED
@@ -37,7 +37,7 @@
|
|
37 |
// settings
|
38 |
$this->settings = array(
|
39 |
'dir_url' => plugins_url( '', __FILE__ ) . '/',
|
40 |
-
'version' => '1.3.
|
41 |
);
|
42 |
|
43 |
// PREVENTS SAVING INVALID TABLE FIELD JSON DATA {
|
@@ -369,7 +369,7 @@
|
|
369 |
{
|
370 |
if ( is_string( $value ) ) {
|
371 |
|
372 |
-
|
373 |
$value = urldecode( $value );
|
374 |
$value = json_decode( $value, true );
|
375 |
}
|
@@ -401,8 +401,51 @@
|
|
401 |
$value = array_replace_recursive( $data, $value );
|
402 |
}
|
403 |
|
|
|
|
|
404 |
return $value;
|
405 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
}
|
407 |
|
408 |
// create field
|
37 |
// settings
|
38 |
$this->settings = array(
|
39 |
'dir_url' => plugins_url( '', __FILE__ ) . '/',
|
40 |
+
'version' => '1.3.3',
|
41 |
);
|
42 |
|
43 |
// PREVENTS SAVING INVALID TABLE FIELD JSON DATA {
|
369 |
{
|
370 |
if ( is_string( $value ) ) {
|
371 |
|
372 |
+
$value = wp_unslash( $value );
|
373 |
$value = urldecode( $value );
|
374 |
$value = json_decode( $value, true );
|
375 |
}
|
401 |
$value = array_replace_recursive( $data, $value );
|
402 |
}
|
403 |
|
404 |
+
$value = $this->table_slash( $value );
|
405 |
+
|
406 |
return $value;
|
407 |
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* table_slash()
|
411 |
+
*
|
412 |
+
* Add slashes to a string or strings in an array.
|
413 |
+
*
|
414 |
+
* This should be used instead of wp_slash() because wp_slash() convertes all
|
415 |
+
* array values to strings which affects also the table object values of
|
416 |
+
* type number converting to string.
|
417 |
+
*/
|
418 |
+
|
419 |
+
function table_slash( $value ) {
|
420 |
+
|
421 |
+
if ( is_array( $value ) ) {
|
422 |
+
|
423 |
+
foreach ( $value as $k => $v ) {
|
424 |
+
|
425 |
+
if (
|
426 |
+
is_array( $v ) OR
|
427 |
+
is_object( $v )
|
428 |
+
) {
|
429 |
+
$value[ $k ] = $this->table_slash( $v );
|
430 |
+
}
|
431 |
+
else if( is_string( $v ) ) {
|
432 |
+
|
433 |
+
$value[ $k ] = addslashes( $v );
|
434 |
+
}
|
435 |
+
else {
|
436 |
+
|
437 |
+
$value[ $k ] = $v;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
|
441 |
+
} else {
|
442 |
+
|
443 |
+
$value = addslashes( $value );
|
444 |
+
}
|
445 |
+
|
446 |
+
return $value;
|
447 |
+
}
|
448 |
+
|
449 |
}
|
450 |
|
451 |
// create field
|
acf-table-v5.php
CHANGED
@@ -21,7 +21,7 @@ class acf_field_table extends acf_field {
|
|
21 |
* settings (array) Array of settings
|
22 |
*/
|
23 |
$this->settings = array(
|
24 |
-
'version' => '1.3.
|
25 |
'dir_url' => plugins_url( '', __FILE__ ) . '/',
|
26 |
);
|
27 |
|
@@ -425,7 +425,7 @@ class acf_field_table extends acf_field {
|
|
425 |
|
426 |
if ( is_string( $value ) ) {
|
427 |
|
428 |
-
|
429 |
$value = urldecode( $value );
|
430 |
$value = json_decode( $value, true );
|
431 |
}
|
@@ -457,6 +457,8 @@ class acf_field_table extends acf_field {
|
|
457 |
$value = array_replace_recursive( $data, $value );
|
458 |
}
|
459 |
|
|
|
|
|
460 |
return $value;
|
461 |
}
|
462 |
|
@@ -679,6 +681,46 @@ class acf_field_table extends acf_field {
|
|
679 |
|
680 |
*/
|
681 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
682 |
}
|
683 |
|
684 |
// create field
|
21 |
* settings (array) Array of settings
|
22 |
*/
|
23 |
$this->settings = array(
|
24 |
+
'version' => '1.3.3',
|
25 |
'dir_url' => plugins_url( '', __FILE__ ) . '/',
|
26 |
);
|
27 |
|
425 |
|
426 |
if ( is_string( $value ) ) {
|
427 |
|
428 |
+
$value = wp_unslash( $value );
|
429 |
$value = urldecode( $value );
|
430 |
$value = json_decode( $value, true );
|
431 |
}
|
457 |
$value = array_replace_recursive( $data, $value );
|
458 |
}
|
459 |
|
460 |
+
$value = $this->table_slash( $value );
|
461 |
+
|
462 |
return $value;
|
463 |
}
|
464 |
|
681 |
|
682 |
*/
|
683 |
|
684 |
+
/**
|
685 |
+
* table_slash()
|
686 |
+
*
|
687 |
+
* Add slashes to a string or strings in an array.
|
688 |
+
*
|
689 |
+
* This should be used instead of wp_slash() because wp_slash() convertes all
|
690 |
+
* array values to strings which affects also the table object values of
|
691 |
+
* type number converting to string.
|
692 |
+
*/
|
693 |
+
|
694 |
+
function table_slash( $value ) {
|
695 |
+
|
696 |
+
if ( is_array( $value ) ) {
|
697 |
+
|
698 |
+
foreach ( $value as $k => $v ) {
|
699 |
+
|
700 |
+
if (
|
701 |
+
is_array( $v ) OR
|
702 |
+
is_object( $v )
|
703 |
+
) {
|
704 |
+
$value[ $k ] = $this->table_slash( $v );
|
705 |
+
}
|
706 |
+
else if( is_string( $v ) ) {
|
707 |
+
|
708 |
+
$value[ $k ] = addslashes( $v );
|
709 |
+
}
|
710 |
+
else {
|
711 |
+
|
712 |
+
$value[ $k ] = $v;
|
713 |
+
}
|
714 |
+
}
|
715 |
+
|
716 |
+
} else {
|
717 |
+
|
718 |
+
$value = addslashes( $value );
|
719 |
+
}
|
720 |
+
|
721 |
+
return $value;
|
722 |
+
}
|
723 |
+
|
724 |
}
|
725 |
|
726 |
// create field
|
acf-table.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Advanced Custom Fields: Table Field
|
4 |
Plugin URI: http://www.johannheyne.de/
|
5 |
Description: This free Add-on adds a table field type for the Advanced Custom Fields plugin.
|
6 |
-
Version: 1.3.
|
7 |
Author: Johann Heyne
|
8 |
Author URI: http://www.johannheyne.de/
|
9 |
License: GPLv2 or later
|
3 |
Plugin Name: Advanced Custom Fields: Table Field
|
4 |
Plugin URI: http://www.johannheyne.de/
|
5 |
Description: This free Add-on adds a table field type for the Advanced Custom Fields plugin.
|
6 |
+
Version: 1.3.3
|
7 |
Author: Johann Heyne
|
8 |
Author URI: http://www.johannheyne.de/
|
9 |
License: GPLv2 or later
|
changelog.txt
CHANGED
@@ -1,10 +1,13 @@
|
|
1 |
== Changelog ==
|
2 |
|
3 |
-
= 1.3.
|
|
|
|
|
|
|
4 |
* Fixes returning empty table after saving content containing quotes
|
5 |
* Fixes an issue using update_field() on a table field
|
6 |
|
7 |
-
= 1.3.
|
8 |
* Changes table data storing format from JSON string to serialized array. This is due to an issue caused by third party plugins using update_post_meta() without providing wp_slash() to the value before. Existing table data values in JSON string format in the database will still exists and be compatible. When a field is saved again, the storage format changes from JSON to serialized array.
|
9 |
* Fixes an PHP error of table caption
|
10 |
|
1 |
== Changelog ==
|
2 |
|
3 |
+
= 1.3.3 =
|
4 |
+
* Fixes returning empty table after saving content containing a single quote
|
5 |
+
|
6 |
+
= 1.3.3 =
|
7 |
* Fixes returning empty table after saving content containing quotes
|
8 |
* Fixes an issue using update_field() on a table field
|
9 |
|
10 |
+
= 1.3.3 =
|
11 |
* Changes table data storing format from JSON string to serialized array. This is due to an issue caused by third party plugins using update_post_meta() without providing wp_slash() to the value before. Existing table data values in JSON string format in the database will still exists and be compatible. When a field is saved again, the storage format changes from JSON to serialized array.
|
12 |
* Fixes an PHP error of table caption
|
13 |
|
js/input-v4.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
var t = this;
|
6 |
|
7 |
-
t.version = '1.3.
|
8 |
|
9 |
t.param = {};
|
10 |
|
4 |
|
5 |
var t = this;
|
6 |
|
7 |
+
t.version = '1.3.3';
|
8 |
|
9 |
t.param = {};
|
10 |
|
js/input-v5.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
var t = this;
|
6 |
|
7 |
-
t.version = '1.3.
|
8 |
|
9 |
t.param = {};
|
10 |
|
4 |
|
5 |
var t = this;
|
6 |
|
7 |
+
t.version = '1.3.3';
|
8 |
|
9 |
t.param = {};
|
10 |
|
lang/acf-table-da_DK.po
CHANGED
@@ -38,10 +38,10 @@ msgid ""
|
|
38 |
msgstr ""
|
39 |
|
40 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
41 |
-
#. Fields: Table Field 1.3.
|
42 |
#. Plugin URI of the plugin/theme
|
43 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
44 |
-
#. Fields: Table Field 1.3.
|
45 |
#. Author URI of the plugin/theme
|
46 |
msgid "http://www.johannheyne.de/"
|
47 |
msgstr "http://www.johannheyne.de/"
|
38 |
msgstr ""
|
39 |
|
40 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
41 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
42 |
#. Plugin URI of the plugin/theme
|
43 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
44 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
45 |
#. Author URI of the plugin/theme
|
46 |
msgid "http://www.johannheyne.de/"
|
47 |
msgstr "http://www.johannheyne.de/"
|
lang/acf-table-de_DE.po
CHANGED
@@ -38,10 +38,10 @@ msgstr ""
|
|
38 |
"Tabellen Feldtype hinzu."
|
39 |
|
40 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
41 |
-
#. Fields: Table Field 1.3.
|
42 |
#. Plugin URI of the plugin/theme
|
43 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
44 |
-
#. Fields: Table Field 1.3.
|
45 |
#. Author URI of the plugin/theme
|
46 |
msgid "http://www.johannheyne.de/"
|
47 |
msgstr "http://www.johannheyne.de/"
|
38 |
"Tabellen Feldtype hinzu."
|
39 |
|
40 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
41 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
42 |
#. Plugin URI of the plugin/theme
|
43 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
44 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
45 |
#. Author URI of the plugin/theme
|
46 |
msgid "http://www.johannheyne.de/"
|
47 |
msgstr "http://www.johannheyne.de/"
|
lang/acf-table-pl_PL.po
CHANGED
@@ -36,10 +36,10 @@ msgid ""
|
|
36 |
msgstr ""
|
37 |
|
38 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
39 |
-
#. Fields: Table Field 1.3.
|
40 |
#. Plugin URI of the plugin/theme
|
41 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
42 |
-
#. Fields: Table Field 1.3.
|
43 |
#. Author URI of the plugin/theme
|
44 |
msgid "http://www.johannheyne.de/"
|
45 |
msgstr ""
|
36 |
msgstr ""
|
37 |
|
38 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
39 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
40 |
#. Plugin URI of the plugin/theme
|
41 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
42 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
43 |
#. Author URI of the plugin/theme
|
44 |
msgid "http://www.johannheyne.de/"
|
45 |
msgstr ""
|
lang/acf-table.pot
CHANGED
@@ -32,10 +32,10 @@ msgid "This free Add-on adds a table field type for the Advanced Custom Fields p
|
|
32 |
msgstr ""
|
33 |
|
34 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
35 |
-
#. Fields: Table Field 1.3.
|
36 |
#. Plugin URI of the plugin/theme
|
37 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
38 |
-
#. Fields: Table Field 1.3.
|
39 |
#. Author URI of the plugin/theme
|
40 |
msgid "http://www.johannheyne.de/"
|
41 |
msgstr ""
|
32 |
msgstr ""
|
33 |
|
34 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
35 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
36 |
#. Plugin URI of the plugin/theme
|
37 |
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
38 |
+
#. Fields: Table Field 1.3.3) #-#-#-#-#
|
39 |
#. Author URI of the plugin/theme
|
40 |
msgid "http://www.johannheyne.de/"
|
41 |
msgstr ""
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: jonua
|
|
3 |
Tags: acf table
|
4 |
Requires at least: 5.0.3
|
5 |
Tested up to: 5.1
|
6 |
-
Stable tag: 1.3.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
|
@@ -235,17 +235,48 @@ Or you can **insert a table from a ACF option page**…
|
|
235 |
|
236 |
`[table field-name="your table field name" post-id="option" table-class="my-table"]`
|
237 |
|
238 |
-
=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
-
|
|
|
|
|
|
|
|
|
241 |
|
242 |
-
|
|
|
|
|
|
|
|
|
243 |
|
244 |
-
|
|
|
245 |
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
-
`define( "ACF_TABLEFIELD_FILTER_POSTMETA", false );`
|
249 |
|
250 |
== Installation ==
|
251 |
|
@@ -278,6 +309,9 @@ However, only when activated as a plugin will updates be available.
|
|
278 |
|
279 |
== Upgrade Notice ==
|
280 |
|
|
|
|
|
|
|
281 |
= 1.3.2 =
|
282 |
Fixes returning empty table after saving content containing quotes.
|
283 |
Fixes an issue using update_field() on a table field.
|
@@ -288,6 +322,9 @@ Fixes an PHP error of table caption.
|
|
288 |
|
289 |
== Changelog ==
|
290 |
|
|
|
|
|
|
|
291 |
= 1.3.2 =
|
292 |
* Fixes returning empty table after saving content containing quotes
|
293 |
* Fixes an issue using update_field() on a table field
|
3 |
Tags: acf table
|
4 |
Requires at least: 5.0.3
|
5 |
Tested up to: 5.1
|
6 |
+
Stable tag: 1.3.3
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
|
235 |
|
236 |
`[table field-name="your table field name" post-id="option" table-class="my-table"]`
|
237 |
|
238 |
+
= Updating a table using update_field() =
|
239 |
+
|
240 |
+
You can use the ACF PHP function `update_field()` to change a tables data.
|
241 |
+
|
242 |
+
Example: adding a new row
|
243 |
+
`
|
244 |
+
// the post ID where to update the table field
|
245 |
+
$post_id = 123;
|
246 |
+
|
247 |
+
// gets the table data
|
248 |
+
$table_data = get_field( 'table', $post_id );
|
249 |
+
|
250 |
+
// defines the new row and its columns
|
251 |
+
$new_row = array(
|
252 |
+
|
253 |
+
// must define the same amount of columns as exists in the table
|
254 |
|
255 |
+
// column 1
|
256 |
+
array(
|
257 |
+
// the 'c' stands for content of the cell
|
258 |
+
'c' => 'Cell Content of Column 1',
|
259 |
+
),
|
260 |
|
261 |
+
// column 2
|
262 |
+
array(
|
263 |
+
'c' => 'Cell Content of Column 2',
|
264 |
+
)
|
265 |
+
);
|
266 |
|
267 |
+
// adds the new row to the table body data
|
268 |
+
array_push( $table_data['body'], $new_row );
|
269 |
|
270 |
+
// saves the new table data
|
271 |
+
update_field( 'table', $table_data, $post_id );
|
272 |
+
`
|
273 |
+
|
274 |
+
= Third party plugins issues =
|
275 |
+
|
276 |
+
Since version 1.3.1 of the table plugin, the storing format of the table data changes from JSON string to serialized array for new or updated tables. The issue with JSON is because of third party plugins that do not properly applying `wp_slash()` to a post_meta value before updating with `update_post_metadata()`. This can break JSON strings because `update_post_metadata()` removes backslashes by default. Backslashes are part of the JSON string syntax escaping quotation marks in content.
|
277 |
+
|
278 |
+
The table field plugin prevents broken JSON strings to save as a table field data and throws an error message that explains the issue. But this may also breaks the functionality of the third party plugin trying to update the table data. You could disable the JSON string check in the table field plugin using the following code in the wp-config.php file. But then the table JSON data are no longer protected from destroing by `update_post_metadata()`. Use the following code in wp-config.php only, if you understand the risk…
|
279 |
|
|
|
280 |
|
281 |
== Installation ==
|
282 |
|
309 |
|
310 |
== Upgrade Notice ==
|
311 |
|
312 |
+
= 1.3.3 =
|
313 |
+
* Fixes returning empty table after saving content containing a single quote.
|
314 |
+
|
315 |
= 1.3.2 =
|
316 |
Fixes returning empty table after saving content containing quotes.
|
317 |
Fixes an issue using update_field() on a table field.
|
322 |
|
323 |
== Changelog ==
|
324 |
|
325 |
+
= 1.3.3 =
|
326 |
+
* Fixes returning empty table after saving content containing a single quote.
|
327 |
+
|
328 |
= 1.3.2 =
|
329 |
* Fixes returning empty table after saving content containing quotes
|
330 |
* Fixes an issue using update_field() on a table field
|