Skip to content

Commit c186e98

Browse files
committed
Handle repeatable groups for attribute values (or any array value) with a modified JSON string. Bump to 1.0.1
1 parent 6d90a5e commit c186e98

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
WordPress Shortcode Button (1.0.0)
1+
WordPress Shortcode Button (1.0.1)
22
================
33

44
Tinymce and Quicktag buttons (and modals) for outputting shortcodes. Built to work with [CMB2](https://github.com/WebDevStudios/CMB2).
@@ -129,6 +129,9 @@ function shortcode_button_only_pages() {
129129

130130
#### Changelog
131131

132+
* 1.0.1
133+
* Handle repeatable groups for attribute values (or any array value) with a modified JSON string (which will need to be converted in your shortcode).
134+
132135
* 1.0.0
133136
* Add a conflict-resolution loader (like CMB2), so that only one version of Shortcode_Button is loaded, and it always loads the newest version.
134137
* Use WordPress core `wp.shortcode()` javascript api.

lib/class-shortcode-button.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,18 @@ public function sanitize_cmb_fields( $fields ) {
394394
function filter_form_fields( $updated, $allvalues = array() ) {
395395
// Pass updated form values through a filter and return
396396
$filtered = (array) apply_filters( "{$this->button_slug}_shortcode_fields", $updated, $this, empty( $allvalues ) ? $updated : $allvalues );
397+
398+
foreach ( $filtered as $key => $value ) {
399+
// If value is an array, we need to create a modified JSON-encoded string.
400+
if ( is_array( $value ) ) {
401+
$filtered[ $key ] = str_replace(
402+
array( '"', '[', ']' ),
403+
array( "'", '|~', '~|' ),
404+
wp_json_encode( $value )
405+
);
406+
}
407+
}
408+
397409
return $filtered;
398410
}
399411

shortcode-button.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*
55
* @todo Fix generic ids possibly conflicting (maybe add a prefix to all fields)
66
*
7-
* @version 1.0.0
7+
* @version 1.0.1
88
*/
9-
if ( ! class_exists( 'Shortcode_Button_100', false ) ) {
9+
if ( ! class_exists( 'Shortcode_Button_101', false ) ) {
1010

1111
/**
1212
* Handles checking for and loading the newest version of Shortcode_Button
@@ -19,14 +19,14 @@
1919
* @license GPL-2.0+
2020
* @link http://webdevstudios.com
2121
*/
22-
class Shortcode_Button_100 {
22+
class Shortcode_Button_101 {
2323

2424
/**
2525
* Current version number
2626
* @var string
2727
* @since 1.0.0
2828
*/
29-
const VERSION = '1.0.0';
29+
const VERSION = '1.0.1';
3030

3131
/**
3232
* Current version hook priority.
@@ -35,7 +35,7 @@ class Shortcode_Button_100 {
3535
* @var int
3636
* @since 1.0.0
3737
*/
38-
const PRIORITY = 9999;
38+
const PRIORITY = 9998;
3939

4040
/**
4141
* Starts the version checking process.
@@ -92,5 +92,5 @@ public function include_lib() {
9292
}
9393

9494
// Make it so...
95-
new Shortcode_Button_100;
95+
new Shortcode_Button_101;
9696
}

0 commit comments

Comments
 (0)