Skip to content

Commit

Permalink
Rename 'encoded' to 'encode'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheu committed Oct 7, 2015
1 parent 6d1b861 commit 586c55f
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 40 deletions.
11 changes: 5 additions & 6 deletions dev.php
Expand Up @@ -65,7 +65,6 @@ function shortcode_ui_dev_advanced_example() {
'listItemImage' => 'dashicons-editor-quote', // Icon/attachment for shortcode. Optional. src or dashicons-$icon. Defaults to carrot.
'inner_content' => array(
'label' => 'Quote',
'encoded' => true,
),
'post_type' => array( 'post' ), //Post type support
// Available shortcode attributes and default values. Required. Array.
Expand All @@ -81,11 +80,11 @@ function shortcode_ui_dev_advanced_example() {
'frameTitle' => esc_html__( 'Select Image', 'your-text-domain ' ), // Media Library frame title
),
array(
'label' => esc_html__( 'Citation Source', 'your-text-domain' ),
'attr' => 'source',
'type' => 'text',
'encoded' => true,
'meta' => array( // Holds custom field attributes.
'label' => esc_html__( 'Citation Source', 'your-text-domain' ),
'attr' => 'source',
'type' => 'text',
'encode' => true,
'meta' => array( // Holds custom field attributes.
'placeholder' => 'Test placeholder',
'data-test' => 1, // Custom data attribute
),
Expand Down
4 changes: 2 additions & 2 deletions inc/class-shortcode-ui.php
Expand Up @@ -391,8 +391,8 @@ public function filter_shortcode_atts_decode_encoded( $out, $pairs, $atts ) {

foreach ( $args['attrs'] as $attr ) {

$default = isset( $fields[ $attr['type'] ]['encoded'] ) ? $fields[ $attr['type'] ]['encoded'] : false;
$encoded = isset( $attr['encoded'] ) ? $attr['encoded'] : $default;
$default = isset( $fields[ $attr['type'] ]['encode'] ) ? $fields[ $attr['type'] ]['encode'] : false;
$encoded = isset( $attr['encode'] ) ? $attr['encode'] : $default;

if ( $encoded && isset( $out[ $attr['attr'] ] ) ) {
$out[ $attr['attr'] ] = rawurldecode( $out[ $attr['attr'] ] );
Expand Down
2 changes: 1 addition & 1 deletion inc/fields/class-shortcode-ui-fields.php
Expand Up @@ -22,7 +22,7 @@ class Shortcode_UI_Fields {
private $field_defaults = array(
'template' => 'shortcode-ui-field-text',
'view' => 'editAttributeField',
'encoded' => false,
'encode' => false,
);

/**
Expand Down
24 changes: 12 additions & 12 deletions js-tests/build/specs.js
Expand Up @@ -38,7 +38,7 @@ describe( "Shortcode Attribute Model", function() {
type: 'text',
value: 'test value',
description: 'test description',
encoded: false,
encode: false,
meta: {
placeholder: 'test placeholder'
},
Expand Down Expand Up @@ -136,10 +136,10 @@ describe( "Shortcode Model", function() {
shortcode_tag: 'test_shortcode_encoded',
attrs: [
{
attr: 'attr',
type: 'text',
value: '<b class="foo">bar</b>',
encoded: true,
attr: 'attr',
type: 'text',
value: '<b class="foo">bar</b>',
encode: true,
},
],
});
Expand Down Expand Up @@ -252,9 +252,9 @@ describe( "MCE View Constructor", function() {
shortcode_tag: 'test_shortcode_encoded',
attrs: [
{
attr: 'attr',
label: 'Attribute',
encoded: true,
attr: 'attr',
label: 'Attribute',
encode: true,
}
],
} ) );
Expand Down Expand Up @@ -476,7 +476,7 @@ var ShortcodeAttribute = Backbone.Model.extend({
type: '',
value: '',
description: '',
encoded: false,
encode: false,
meta: {
placeholder: '',
},
Expand Down Expand Up @@ -565,7 +565,7 @@ Shortcode = Backbone.Model.extend({
}

// Encode textareas incase HTML
if ( attr.get( 'encoded' ) ) {
if ( attr.get( 'encode' ) ) {
attr.set( 'value', encodeURIComponent( decodeURIComponent( attr.get( 'value' ) ) ), { silent: true } );
}

Expand Down Expand Up @@ -743,7 +743,7 @@ var shortcodeViewConstructor = {
var value = options.attrs.named[ attr.get('attr') ];

// Maybe decode value.
if ( attr.get('encoded') ) {
if ( attr.get('encode') ) {
value = decodeURIComponent( value );
}

Expand Down Expand Up @@ -881,7 +881,7 @@ var shortcodeViewConstructor = {
value = attributes.named[ key ];
attr = currentShortcode.get( 'attrs' ).findWhere({ attr: key });

if ( attr && attr.get('encoded') ) {
if ( attr && attr.get('encode') ) {
value = decodeURIComponent( value );
}

Expand Down
2 changes: 1 addition & 1 deletion js-tests/src/shortcodeAttributeModelSpec.js
Expand Up @@ -8,7 +8,7 @@ describe( "Shortcode Attribute Model", function() {
type: 'text',
value: 'test value',
description: 'test description',
encoded: false,
encode: false,
meta: {
placeholder: 'test placeholder'
},
Expand Down
8 changes: 4 additions & 4 deletions js-tests/src/shortcodeModelSpec.js
Expand Up @@ -79,10 +79,10 @@ describe( "Shortcode Model", function() {
shortcode_tag: 'test_shortcode_encoded',
attrs: [
{
attr: 'attr',
type: 'text',
value: '<b class="foo">bar</b>',
encoded: true,
attr: 'attr',
type: 'text',
value: '<b class="foo">bar</b>',
encode: true,
},
],
});
Expand Down
6 changes: 3 additions & 3 deletions js-tests/src/utils/mceViewConstructorSpec.js
Expand Up @@ -45,9 +45,9 @@ describe( "MCE View Constructor", function() {
shortcode_tag: 'test_shortcode_encoded',
attrs: [
{
attr: 'attr',
label: 'Attribute',
encoded: true,
attr: 'attr',
label: 'Attribute',
encode: true,
}
],
} ) );
Expand Down
8 changes: 4 additions & 4 deletions js/build/shortcode-ui.js
Expand Up @@ -120,7 +120,7 @@ var ShortcodeAttribute = Backbone.Model.extend({
type: '',
value: '',
description: '',
encoded: false,
encode: false,
meta: {
placeholder: '',
},
Expand Down Expand Up @@ -209,7 +209,7 @@ Shortcode = Backbone.Model.extend({
}

// Encode textareas incase HTML
if ( attr.get( 'encoded' ) ) {
if ( attr.get( 'encode' ) ) {
attr.set( 'value', encodeURIComponent( decodeURIComponent( attr.get( 'value' ) ) ), { silent: true } );
}

Expand Down Expand Up @@ -418,7 +418,7 @@ var shortcodeViewConstructor = {
var value = options.attrs.named[ attr.get('attr') ];

// Maybe decode value.
if ( attr.get('encoded') ) {
if ( attr.get('encode') ) {
value = decodeURIComponent( value );
}

Expand Down Expand Up @@ -556,7 +556,7 @@ var shortcodeViewConstructor = {
value = attributes.named[ key ];
attr = currentShortcode.get( 'attrs' ).findWhere({ attr: key });

if ( attr && attr.get('encoded') ) {
if ( attr && attr.get('encode') ) {
value = decodeURIComponent( value );
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/models/shortcode-attribute.js
Expand Up @@ -8,7 +8,7 @@ var ShortcodeAttribute = Backbone.Model.extend({
type: '',
value: '',
description: '',
encoded: false,
encode: false,
meta: {
placeholder: '',
},
Expand Down
2 changes: 1 addition & 1 deletion js/src/models/shortcode.js
Expand Up @@ -74,7 +74,7 @@ Shortcode = Backbone.Model.extend({
}

// Encode textareas incase HTML
if ( attr.get( 'encoded' ) ) {
if ( attr.get( 'encode' ) ) {
attr.set( 'value', encodeURIComponent( decodeURIComponent( attr.get( 'value' ) ) ), { silent: true } );
}

Expand Down
4 changes: 2 additions & 2 deletions js/src/utils/shortcode-view-constructor.js
Expand Up @@ -56,7 +56,7 @@ var shortcodeViewConstructor = {
var value = options.attrs.named[ attr.get('attr') ];

// Maybe decode value.
if ( attr.get('encoded') ) {
if ( attr.get('encode') ) {
value = decodeURIComponent( value );
}

Expand Down Expand Up @@ -194,7 +194,7 @@ var shortcodeViewConstructor = {
value = attributes.named[ key ];
attr = currentShortcode.get( 'attrs' ).findWhere({ attr: key });

if ( attr && attr.get('encoded') ) {
if ( attr && attr.get('encode') ) {
value = decodeURIComponent( value );
}

Expand Down
6 changes: 3 additions & 3 deletions php-tests/test-shortcode-ui.php
Expand Up @@ -24,9 +24,9 @@ public function test_filter_shortcode_atts_decode_encoded() {
shortcode_ui_register_for_shortcode( $shortcode, array(
'attrs' => array(
array(
'attr' => 'test',
'type' => 'text',
'encoded' => true,
'attr' => 'test',
'type' => 'text',
'encode' => true,
),
),
) );
Expand Down

0 comments on commit 586c55f

Please sign in to comment.