OptionTree - Version 2.3.1

Version Description

  • Hotfix - Fixed a bug with the Gallery option type that would show attachments in the media window when none had been added yet.
  • Hotfix - Added the option to save the Gallery as a shortcode by adding ot-gallery-shortcode to the elements class attribute.
  • Hotfix - Fixed conditions not being effective in List Items directly after clicking "Add New". Contributors via github @bitcommit.
Download this release

Release Info

Developer valendesigns
Plugin Icon wp plugin OptionTree
Version 2.3.1
Comparing to
See all releases

Code changes from version 2.3.0 to 2.3.1

assets/js/ot-admin.js CHANGED
@@ -244,6 +244,7 @@
244
  OT_UI.init_sortable();
245
  OT_UI.init_select_wrapper();
246
  OT_UI.init_numeric_slider();
 
247
  }, 500);
248
  self.processing = false;
249
  }
@@ -643,15 +644,12 @@
643
  });
644
  })(jQuery);
645
 
646
- /* Gallery*/
647
  !function ($) {
648
 
649
  ot_gallery = {
650
 
651
  frame: function (elm) {
652
-
653
- if ( this._frame )
654
- return this._frame
655
 
656
  var selection = this.select(elm)
657
 
@@ -671,6 +669,7 @@
671
  , ids = library.pluck('id')
672
  , parent = $(elm).parents('.format-setting-inner')
673
  , input = parent.children('.ot-gallery-value')
 
674
 
675
  input.attr('value', ids)
676
 
@@ -682,11 +681,13 @@
682
  url: ajaxurl,
683
  dataType: 'html',
684
  data: {
685
- action: 'gallery_update',
686
- ids: ids
687
  },
688
  success: function(res) {
689
  parent.children('.ot-gallery-list').html(res)
 
 
690
  if ( $(elm).parent().children('.ot-gallery-delete').length <= 0 ) {
691
  $(elm).parent().append('<a href="#" class="option-tree-ui-button button button-secondary hug-left ot-gallery-delete">' + option_tree.delete + '</a>')
692
  }
@@ -701,9 +702,10 @@
701
  }
702
 
703
  , select: function (elm) {
704
- var ids = $(elm).parents('.format-setting-inner').children('.ot-gallery-value').attr('value')
705
- , fakeShortcode = '[gallery ids="' + ids + '"]'
706
- , shortcode = wp.shortcode.next('gallery', ( ids ? fakeShortcode : wp.media.view.settings.ot_gallery.shortcode ) )
 
707
  , defaultPostId = wp.media.gallery.defaults.id
708
  , attachments
709
  , selection
@@ -718,6 +720,12 @@
718
  if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) )
719
  shortcode.set( 'id', defaultPostId )
720
 
 
 
 
 
 
 
721
  attachments = wp.media.gallery.attachments( shortcode )
722
 
723
  selection = new wp.media.model.Selection( attachments.models, {
244
  OT_UI.init_sortable();
245
  OT_UI.init_select_wrapper();
246
  OT_UI.init_numeric_slider();
247
+ OT_UI.parse_condition();
248
  }, 500);
249
  self.processing = false;
250
  }
644
  });
645
  })(jQuery);
646
 
647
+ /* Gallery */
648
  !function ($) {
649
 
650
  ot_gallery = {
651
 
652
  frame: function (elm) {
 
 
 
653
 
654
  var selection = this.select(elm)
655
 
669
  , ids = library.pluck('id')
670
  , parent = $(elm).parents('.format-setting-inner')
671
  , input = parent.children('.ot-gallery-value')
672
+ , shortcode = wp.media.gallery.shortcode( selection ).string().replace(/\"/g,"'")
673
 
674
  input.attr('value', ids)
675
 
681
  url: ajaxurl,
682
  dataType: 'html',
683
  data: {
684
+ action: 'gallery_update'
685
+ , ids: ids
686
  },
687
  success: function(res) {
688
  parent.children('.ot-gallery-list').html(res)
689
+ if ( input.hasClass('ot-gallery-shortcode') )
690
+ input.val(shortcode)
691
  if ( $(elm).parent().children('.ot-gallery-delete').length <= 0 ) {
692
  $(elm).parent().append('<a href="#" class="option-tree-ui-button button button-secondary hug-left ot-gallery-delete">' + option_tree.delete + '</a>')
693
  }
702
  }
703
 
704
  , select: function (elm) {
705
+ var input = $(elm).parents('.format-setting-inner').children('.ot-gallery-value')
706
+ , ids = input.attr('value')
707
+ , _shortcode = input.hasClass('ot-gallery-shortcode') ? ids : '[gallery ids=\'' + ids + '\]'
708
+ , shortcode = wp.shortcode.next('gallery', ( ids ? _shortcode : wp.media.view.settings.ot_gallery.shortcode ) )
709
  , defaultPostId = wp.media.gallery.defaults.id
710
  , attachments
711
  , selection
720
  if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) )
721
  shortcode.set( 'id', defaultPostId )
722
 
723
+ if ( _.isUndefined( shortcode.get('ids') ) && ! input.hasClass('ot-gallery-shortcode') && ids )
724
+ shortcode.set( 'ids', ids )
725
+
726
+ if ( _.isUndefined( shortcode.get('ids') ) )
727
+ shortcode.set( 'ids', '0' )
728
+
729
  attachments = wp.media.gallery.attachments( shortcode )
730
 
731
  selection = new wp.media.model.Selection( attachments.models, {
includes/ot-functions-option-types.php CHANGED
@@ -749,8 +749,21 @@ if ( ! function_exists( 'ot_type_gallery' ) ) {
749
  // Saved values
750
  echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="ot-gallery-value ' . esc_attr( $field_class ) . '" />';
751
 
 
 
 
752
  // Turn the field value into an array of IDs
753
- $ids = ! empty( $field_value ) && $field_value != '' ? explode( ',', $field_value ) : array();
 
 
 
 
 
 
 
 
 
 
754
 
755
  // Has attachment IDs
756
  if ( ! empty( $ids ) ) {
749
  // Saved values
750
  echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="ot-gallery-value ' . esc_attr( $field_class ) . '" />';
751
 
752
+ // Search the string for the IDs
753
+ preg_match( '/ids=\'(.*?)\'/', $field_value, $matches );
754
+
755
  // Turn the field value into an array of IDs
756
+ if ( isset( $matches[1] ) ) {
757
+
758
+ // The string is a shortcode
759
+ $ids = explode( ',', $matches[1] );
760
+
761
+ } else {
762
+
763
+ // The string is a comma separated list of IDs
764
+ $ids = ! empty( $field_value ) && $field_value != '' ? explode( ',', $field_value ) : array();
765
+
766
+ }
767
 
768
  // Has attachment IDs
769
  if ( ! empty( $ids ) ) {
ot-loader.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: OptionTree
4
  * Plugin URI: http://wp.envato.com
5
  * Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
6
- * Version: 2.3.0
7
  * Author: Derek Herman
8
  * Author URI: http://valendesigns.com
9
  * License: GPLv3
@@ -142,7 +142,7 @@ if ( ! class_exists( 'OT_Loader' ) ) {
142
  /**
143
  * Current Version number.
144
  */
145
- define( 'OT_VERSION', '2.3.0' );
146
 
147
  /**
148
  * For developers: Theme mode.
3
  * Plugin Name: OptionTree
4
  * Plugin URI: http://wp.envato.com
5
  * Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
6
+ * Version: 2.3.1
7
  * Author: Derek Herman
8
  * Author URI: http://valendesigns.com
9
  * License: GPLv3
142
  /**
143
  * Current Version number.
144
  */
145
+ define( 'OT_VERSION', '2.3.1' );
146
 
147
  /**
148
  * For developers: Theme mode.
readme.txt CHANGED
@@ -4,17 +4,26 @@ Donate link: http://bit.ly/NuXI3T
4
  Tags: options, theme options, meta boxes
5
  Requires at least: 3.5
6
  Tested up to: 3.8.1
7
- Stable tag: 2.3.0
8
  License: GPLv3
9
 
10
  Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
11
 
12
  == Description ==
13
 
14
- OptionTree attempts to bridge the gap between WordPress developers, designers and end-users by creating fully responsive option panels and meta boxes with an ease unlike any other plugin. Packed full of advanced features with tons of hooks, and filters to adjust every aspect of the UX. Build your theme options with a drag & drop interface locally and export a fully functioning `theme-options.php` file for production use that's i18n translation ready with you own custom text domain. And, in just a few simple lines of code, all your themes can have separate settings arrays saved to the database with unique IDs. Not only that, but OptionTree takes full advantage of the new color schemes introduced in WordPress 3.8 and looks and feels built-in.
 
 
 
 
 
 
 
 
 
15
 
16
  #### Option Types
17
- This is a complete list of all the available option types that come shipped with OptionTree. If you don't see the one you need, just know that adding your own custom option type is a breeze.
18
 
19
  * Background
20
  * Category Checkbox
@@ -53,15 +62,6 @@ This is a complete list of all the available option types that come shipped with
53
  * Typography
54
  * Upload
55
 
56
- #### Learn More
57
- If you're like me, you want to know how everything works. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and see first hand how to integrate OptionTree into your own project. I'll walk you through installing OptionTree and you'll get a chance to see all the various options and filters first hand and in the wild.
58
-
59
- #### Contributing
60
- To contribute or report bugs, please go to the [OptionTree Github](https://github.com/valendesigns/option-tree) repository.
61
-
62
- #### Sponsorship
63
- OptionTree is a project partly sponsored by <a href="http://themeforest.net/?ref=valendesigns">ThemeForest</a>, the largest WordPress theme marketplace on the web.
64
-
65
  == Installation ==
66
 
67
  **Plugin Mode**
@@ -106,6 +106,11 @@ There sure is, and I'm glad you asked. Download and activate the [OptionTree The
106
 
107
  == Changelog ==
108
 
 
 
 
 
 
109
  = 2.3.0 =
110
  * Added the Tab option type.
111
  * Added Ace Editor to the CSS option type. Contributors via github @imangm and @valendesigns.
4
  Tags: options, theme options, meta boxes
5
  Requires at least: 3.5
6
  Tested up to: 3.8.1
7
+ Stable tag: 2.3.1
8
  License: GPLv3
9
 
10
  Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
11
 
12
  == Description ==
13
 
14
+ OptionTree attempts to bridge the gap between WordPress developers, designers and end-users by creating fully responsive option panels and meta boxes with an ease unlike any other plugin. Packed full of advanced features with tons of hooks and filters to adjust every aspect of the user experience. You can build your theme options with a drag & drop interface locally and export a fully functioning `theme-options.php` file for production use that's i18n translation ready with you own custom text domain. And, in just a few simple lines of code, all your themes can have separate settings arrays saved to the database with unique IDs. Not only that, but OptionTree takes full advantage of the new color schemes introduced in WordPress 3.8, it looks and feels built-in.
15
+
16
+ #### Theme Integration
17
+ If you're like me, you want to know how everything works. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and see first hand how to integrate OptionTree into your own project. I'll walk you through installing OptionTree and you'll get a chance to see all the various options and filters first hand and in the wild.
18
+
19
+ #### Contributing
20
+ To contribute or report bugs, please go to the [OptionTree Github](https://github.com/valendesigns/option-tree) repository.
21
+
22
+ #### Sponsorship
23
+ OptionTree is a project partly sponsored by <a href="http://themeforest.net/?ref=valendesigns">ThemeForest</a>, the largest WordPress theme marketplace on the web.
24
 
25
  #### Option Types
26
+ This is a complete list of all the available option types that come shipped with OptionTree.
27
 
28
  * Background
29
  * Category Checkbox
62
  * Typography
63
  * Upload
64
 
 
 
 
 
 
 
 
 
 
65
  == Installation ==
66
 
67
  **Plugin Mode**
106
 
107
  == Changelog ==
108
 
109
+ = 2.3.1 =
110
+ * Hotfix - Fixed a bug with the Gallery option type that would show attachments in the media window when none had been added yet.
111
+ * Hotfix - Added the option to save the Gallery as a shortcode by adding `ot-gallery-shortcode` to the elements `class` attribute.
112
+ * Hotfix - Fixed conditions not being effective in List Items directly after clicking "Add New". Contributors via github @bitcommit.
113
+
114
  = 2.3.0 =
115
  * Added the Tab option type.
116
  * Added Ace Editor to the CSS option type. Contributors via github @imangm and @valendesigns.