Version Description
- Added Slider option type with filter for changing the optional fields
- Fixed the text displayed for Measurement option type after options are reset
- Added filter to measurement units
- Code cleanup in the option_tree_array_save() function
- Fixed double quotes on front-end display
Download this release
Release Info
Developer | valendesigns |
Plugin | OptionTree |
Version | 1.1.3 |
Comparing to | |
See all releases |
Code changes from version 1.1.2 to 1.1.3
- assets/css/style.css +67 -0
- assets/images/icon_up.png +0 -0
- assets/js/jquery.option.tree.js +100 -5
- classes/class.admin.php +20 -63
- front-end/docs.php +115 -6
- front-end/settings.php +2 -1
- functions/admin/category.php +5 -9
- functions/admin/checkbox.php +6 -14
- functions/admin/custom-post.php +5 -9
- functions/admin/measurement.php +11 -16
- functions/admin/page.php +5 -9
- functions/admin/post.php +5 -9
- functions/admin/radio.php +5 -13
- functions/admin/slider.php +129 -0
- functions/admin/tag.php +5 -9
- functions/functions.load.php +1 -0
- functions/get-option-tree.php +49 -12
- index.php +4 -3
- readme.txt +10 -3
assets/css/style.css
CHANGED
@@ -222,6 +222,15 @@ a:hover strong {
|
|
222 |
border-color: #666;
|
223 |
}
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
/* Content Inner */
|
226 |
#framework_wrap #content {
|
227 |
padding: 0;
|
@@ -651,6 +660,64 @@ a:hover strong {
|
|
651 |
z-index: 2;
|
652 |
padding-left: 6px;
|
653 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
654 |
/* Docs */
|
655 |
#framework_wrap #options_tabs.docs {
|
656 |
font-size: 11px !important;
|
222 |
border-color: #666;
|
223 |
}
|
224 |
|
225 |
+
#framework_wrap a.button-framework.light {
|
226 |
+
border: 1px solid #dfdfdf;
|
227 |
+
color: #464646;
|
228 |
+
}
|
229 |
+
#framework_wrap a:hover.button-framework.light {
|
230 |
+
color: #000;
|
231 |
+
border-color: #adaca7;
|
232 |
+
}
|
233 |
+
|
234 |
/* Content Inner */
|
235 |
#framework_wrap #content {
|
236 |
padding: 0;
|
660 |
z-index: 2;
|
661 |
padding-left: 6px;
|
662 |
}
|
663 |
+
/* Image Slider */
|
664 |
+
.option-tree-slider {
|
665 |
+
background: #eaf3fa;
|
666 |
+
padding: 0px 10px;
|
667 |
+
margin-bottom: 8px;
|
668 |
+
text-shadow: 0 1px 0 #fff;
|
669 |
+
position: relative;
|
670 |
+
/* CSS3 */
|
671 |
+
-webkit-border-radius: 4px;
|
672 |
+
-moz-border-radius: 4px;
|
673 |
+
border-radius: 4px;
|
674 |
+
-moz-box-shadow: 1px 1px 0px #ccc;
|
675 |
+
-webkit-box-shadow: 1px 1px 0px #ccc;
|
676 |
+
box-shadow: 1px 1px 0px #ccc;
|
677 |
+
}
|
678 |
+
.option-tree-slider p {
|
679 |
+
padding-bottom: 5px !important;
|
680 |
+
margin-bottom: 0px !important;
|
681 |
+
}
|
682 |
+
#framework_wrap #content .option-option-tree-slider .section .element input[type="text"],
|
683 |
+
#framework_wrap #content .option-option-tree-slider .section .element textarea {
|
684 |
+
background: #fff;
|
685 |
+
width: 323px;
|
686 |
+
}
|
687 |
+
.option-tree-slider-wrap .edit {
|
688 |
+
position: absolute;
|
689 |
+
height: 16px;
|
690 |
+
width: 16px;
|
691 |
+
display: block;
|
692 |
+
text-indent: -9999px;
|
693 |
+
background: url(../images/icon_edit.png);
|
694 |
+
top: 6px;
|
695 |
+
right: 27px;
|
696 |
+
z-index: 10;
|
697 |
+
}
|
698 |
+
.option-tree-slider-wrap .edit.down {
|
699 |
+
background: url(../images/icon_up.png) !important;
|
700 |
+
}
|
701 |
+
.option-tree-slider-wrap .trash {
|
702 |
+
position: absolute;
|
703 |
+
height: 16px;
|
704 |
+
width: 16px;
|
705 |
+
display: block;
|
706 |
+
text-indent: -9999px;
|
707 |
+
background: url(../images/icon_delete.png);
|
708 |
+
top: 6px;
|
709 |
+
right: 6px;
|
710 |
+
z-index: 10;
|
711 |
+
}
|
712 |
+
.option-tree-slider-wrap .open {
|
713 |
+
padding: 5px 0px;
|
714 |
+
padding-right: 40px;
|
715 |
+
display: block;
|
716 |
+
font-size: 11px;
|
717 |
+
}
|
718 |
+
.option-tree-slider-wrap .option-tree-slider-body {
|
719 |
+
display: ;
|
720 |
+
}
|
721 |
/* Docs */
|
722 |
#framework_wrap #options_tabs.docs {
|
723 |
font-size: 11px !important;
|
assets/images/icon_up.png
ADDED
Binary file
|
assets/js/jquery.option.tree.js
CHANGED
@@ -306,6 +306,8 @@
|
|
306 |
$.post(ajaxurl, d, function (r) {
|
307 |
if (r != -1) {
|
308 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Theme Options were saved</div>');
|
|
|
|
|
309 |
} else {
|
310 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>Theme Options could not be saved</div>');
|
311 |
}
|
@@ -326,7 +328,13 @@
|
|
326 |
.removeAttr('checked')
|
327 |
.removeAttr('selected');
|
328 |
$('.select').each(function () {
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
});
|
331 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Theme Options were deleted</div>');
|
332 |
} else {
|
@@ -745,8 +753,95 @@
|
|
745 |
}
|
746 |
return false;
|
747 |
}
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
})(jQuery);
|
306 |
$.post(ajaxurl, d, function (r) {
|
307 |
if (r != -1) {
|
308 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Theme Options were saved</div>');
|
309 |
+
$(".option-tree-slider-body").hide();
|
310 |
+
$('.option-tree-slider .edit').removeClass('down');
|
311 |
} else {
|
312 |
$('.ajax-message').ajaxMessage('<div class="message warning"><span> </span>Theme Options could not be saved</div>');
|
313 |
}
|
328 |
.removeAttr('checked')
|
329 |
.removeAttr('selected');
|
330 |
$('.select').each(function () {
|
331 |
+
var new_text = '-- Choose One --';
|
332 |
+
if ( $(this).parents('div').hasClass('measurement') )
|
333 |
+
new_text = ' --';
|
334 |
+
$(this).prev('span').html(new_text);
|
335 |
+
});
|
336 |
+
$('ul.option-tree-slider-wrap li').each(function () {
|
337 |
+
$(this).remove();
|
338 |
});
|
339 |
$('.ajax-message').ajaxMessage('<div class="message"><span> </span>Theme Options were deleted</div>');
|
340 |
} else {
|
753 |
}
|
754 |
return false;
|
755 |
}
|
756 |
+
};
|
757 |
+
$(document).ready(function () {
|
758 |
+
inlineEditOption.init();
|
759 |
+
})
|
760 |
+
})(jQuery);
|
761 |
+
|
762 |
+
/**
|
763 |
+
*
|
764 |
+
* Image Slider
|
765 |
+
*
|
766 |
+
* Creates & Updates Image Slider
|
767 |
+
* Dependencies: jQuery, jQuery UI
|
768 |
+
*
|
769 |
+
*/
|
770 |
+
(function ($) {
|
771 |
+
ImageSlider = {
|
772 |
+
processing: false,
|
773 |
+
init: function () {
|
774 |
+
$(".option-tree-slider-body").hide();
|
775 |
+
$('.option-tree-slider .edit').live('click', function(event){
|
776 |
+
event.preventDefault();
|
777 |
+
$(this).toggleClass('down');
|
778 |
+
$(this).parent().find('.option-tree-slider-body').toggle();
|
779 |
+
});
|
780 |
+
$('.option-tree-slider-title').live('keyup', function(){
|
781 |
+
ImageSlider.update_slider_title(this);
|
782 |
+
});
|
783 |
+
$('.remove-slide').live('click', function(event){
|
784 |
+
event.preventDefault();
|
785 |
+
var agree = confirm("Are you sure you wish to delete this slide?");
|
786 |
+
if (agree) {
|
787 |
+
ImageSlider.delete_slider_image(this);
|
788 |
+
return false;
|
789 |
+
} else {
|
790 |
+
return false;
|
791 |
+
}
|
792 |
+
});
|
793 |
+
$('.add-slide').live('click', function(event){
|
794 |
+
event.preventDefault();
|
795 |
+
ImageSlider.add_slider($(this).attr('id'));
|
796 |
+
});
|
797 |
+
|
798 |
+
if($('.option-tree-slider-wrap').length){
|
799 |
+
$('.option-tree-slider-wrap').sortable({
|
800 |
+
update: function(event,ui){
|
801 |
+
$('ul.option-tree-slider-wrap').find('li:not(.ui-sortable-helper)').each(function(inc){
|
802 |
+
var target = $(this).find('a.open').attr('href').split("#")[1];
|
803 |
+
$('#' + target).find('input.option-tree-slider-order').val(inc + 1);
|
804 |
+
});
|
805 |
+
}
|
806 |
+
});
|
807 |
+
}
|
808 |
+
},
|
809 |
+
update_slider_title: function(e) {
|
810 |
+
var element = e;
|
811 |
+
if ( this.timer ) {
|
812 |
+
clearTimeout( element.timer );
|
813 |
+
}
|
814 |
+
this.timer = setTimeout( function() {
|
815 |
+
$(element).parents('.option-tree-slider').find('.open').text( element.value );
|
816 |
+
}, 100);
|
817 |
+
return true;
|
818 |
+
},
|
819 |
+
add_slider: function(id) {
|
820 |
+
var self = this;
|
821 |
+
if ( this.processing === false ) {
|
822 |
+
this.processing = true;
|
823 |
+
var image_count = parseInt($( '.option-tree-slider-wrap li' ).length) - 1;
|
824 |
+
$.ajax({
|
825 |
+
url: ajaxurl,
|
826 |
+
type: 'get',
|
827 |
+
data: {
|
828 |
+
action: 'option_tree_add_slider',
|
829 |
+
slide_id: id,
|
830 |
+
count: image_count
|
831 |
+
},
|
832 |
+
complete: function( data ) {
|
833 |
+
$('.option-tree-slider-wrap').append( '<li>' + data.responseText + '</li>' );
|
834 |
+
$('li:last .option-tree-slider .edit').toggleClass('down');
|
835 |
+
self.processing = false;
|
836 |
+
}
|
837 |
+
});
|
838 |
+
}
|
839 |
+
},
|
840 |
+
delete_slider_image: function(e) {
|
841 |
+
$(e).parents('li').remove();
|
842 |
+
}
|
843 |
+
};
|
844 |
+
$(document).ready(function () {
|
845 |
+
ImageSlider.init();
|
846 |
+
})
|
847 |
})(jQuery);
|
classes/class.admin.php
CHANGED
@@ -307,7 +307,7 @@ class OT_Admin
|
|
307 |
add_thickbox();
|
308 |
wp_enqueue_script( 'jquery-table-dnd', OT_PLUGIN_URL.'/assets/js/jquery.table.dnd.js', array('jquery'), $this->version );
|
309 |
wp_enqueue_script( 'jquery-color-picker', OT_PLUGIN_URL.'/assets/js/jquery.color.picker.js', array('jquery'), $this->version );
|
310 |
-
wp_enqueue_script( 'jquery-option-tree', OT_PLUGIN_URL.'/assets/js/jquery.option.tree.js', array('jquery','media-upload','thickbox','jquery-ui-core','jquery-ui-tabs','jquery-table-dnd','jquery-color-picker'), $this->version );
|
311 |
|
312 |
// remove GD star rating conflicts
|
313 |
wp_deregister_style( 'gdsr-jquery-ui-core' );
|
@@ -445,69 +445,11 @@ class OT_Admin
|
|
445 |
// set option values
|
446 |
foreach ( $this->option_array as $value )
|
447 |
{
|
448 |
-
|
449 |
-
if (
|
450 |
-
isset( $_REQUEST['checkboxes'] ) &&
|
451 |
-
( $value->item_type == "checkbox" ||
|
452 |
-
$value->item_type == "posts" ||
|
453 |
-
$value->item_type == "pages" ||
|
454 |
-
$value->item_type == "categories" ||
|
455 |
-
$value->item_type == "tags" ||
|
456 |
-
$value->item_type == "custom_posts"
|
457 |
-
)
|
458 |
-
)
|
459 |
{
|
460 |
-
|
461 |
-
|
462 |
-
if ($key == $value->item_id)
|
463 |
-
{
|
464 |
-
$values = implode(',',$val);
|
465 |
-
$new_settings[$key] = $values;
|
466 |
-
}
|
467 |
-
}
|
468 |
-
// no checkbox values
|
469 |
-
if ( !isset( $_REQUEST['checkboxes'] ) )
|
470 |
-
{
|
471 |
-
$key = $value->item_id;
|
472 |
-
$values = null;
|
473 |
-
$new_settings[$key] = $values;
|
474 |
-
}
|
475 |
-
// radio
|
476 |
-
}
|
477 |
-
else if ( isset( $_REQUEST['radios'] ) && $value->item_type == "radio" )
|
478 |
-
{
|
479 |
-
// grab radio array()
|
480 |
-
foreach( $_REQUEST['radios'] as $key => $val)
|
481 |
-
{
|
482 |
-
if ($key == $value->item_id)
|
483 |
-
{
|
484 |
-
$values = implode(',',$val);
|
485 |
-
$new_settings[$key] = $values;
|
486 |
-
}
|
487 |
-
}
|
488 |
-
// value unit
|
489 |
-
}
|
490 |
-
else if ( isset( $_REQUEST['measurement'] ) && $value->item_type == "measurement" )
|
491 |
-
{
|
492 |
-
// grab radio array()
|
493 |
-
foreach( $_REQUEST['measurement'] as $key => $val)
|
494 |
-
{
|
495 |
-
if ($key == $value->item_id)
|
496 |
-
{
|
497 |
-
$values = implode(',',$val);
|
498 |
-
$new_settings[$key] = $values;
|
499 |
-
}
|
500 |
-
}
|
501 |
-
// everything else
|
502 |
-
}
|
503 |
-
else
|
504 |
-
{
|
505 |
-
$key = trim( $value->item_id );
|
506 |
-
if ( isset( $_REQUEST[$key] ) )
|
507 |
-
{
|
508 |
-
$val = $_REQUEST[$key];
|
509 |
-
$new_settings[$key] = $val;
|
510 |
-
}
|
511 |
}
|
512 |
}
|
513 |
|
@@ -927,6 +869,21 @@ class OT_Admin
|
|
927 |
die(-1);
|
928 |
}
|
929 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
930 |
/**
|
931 |
* Returns the ID of a cutom post tpye
|
932 |
*
|
307 |
add_thickbox();
|
308 |
wp_enqueue_script( 'jquery-table-dnd', OT_PLUGIN_URL.'/assets/js/jquery.table.dnd.js', array('jquery'), $this->version );
|
309 |
wp_enqueue_script( 'jquery-color-picker', OT_PLUGIN_URL.'/assets/js/jquery.color.picker.js', array('jquery'), $this->version );
|
310 |
+
wp_enqueue_script( 'jquery-option-tree', OT_PLUGIN_URL.'/assets/js/jquery.option.tree.js', array('jquery','media-upload','thickbox','jquery-ui-core','jquery-ui-tabs','jquery-table-dnd','jquery-color-picker', 'jquery-ui-sortable'), $this->version );
|
311 |
|
312 |
// remove GD star rating conflicts
|
313 |
wp_deregister_style( 'gdsr-jquery-ui-core' );
|
445 |
// set option values
|
446 |
foreach ( $this->option_array as $value )
|
447 |
{
|
448 |
+
$key = trim( $value->item_id );
|
449 |
+
if ( isset( $_REQUEST[$key] ) )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
{
|
451 |
+
$val = $_REQUEST[$key];
|
452 |
+
$new_settings[$key] = $val;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
}
|
454 |
}
|
455 |
|
869 |
die(-1);
|
870 |
}
|
871 |
|
872 |
+
function option_tree_add_slider()
|
873 |
+
{
|
874 |
+
$count = $_GET['count'] + 1;
|
875 |
+
$id = $_GET['slide_id'];
|
876 |
+
$image = array(
|
877 |
+
'order' => $count,
|
878 |
+
'title' => '',
|
879 |
+
'image' => '',
|
880 |
+
'link' => '',
|
881 |
+
'description' => ''
|
882 |
+
);
|
883 |
+
slider_view( $id, $image, $count );
|
884 |
+
die();
|
885 |
+
}
|
886 |
+
|
887 |
/**
|
888 |
* Returns the ID of a cutom post tpye
|
889 |
*
|
front-end/docs.php
CHANGED
@@ -78,7 +78,7 @@
|
|
78 |
|
79 |
<p>
|
80 |
This example returns the $item_id value.
|
81 |
-
<pre><code><
|
82 |
if ( function_exists( 'get_option_tree' ) ) {
|
83 |
get_option_tree( 'test_option' );
|
84 |
}
|
@@ -87,7 +87,7 @@ if ( function_exists( 'get_option_tree' ) ) {
|
|
87 |
|
88 |
<p>
|
89 |
These examples will echo the $item_id value.
|
90 |
-
<pre><code><
|
91 |
if ( function_exists( 'get_option_tree') ) {
|
92 |
get_option_tree( 'test_option', '', true );
|
93 |
}
|
@@ -101,8 +101,8 @@ if ( function_exists( 'get_option_tree') ) {
|
|
101 |
</p>
|
102 |
|
103 |
<p>
|
104 |
-
This example will echo the value of $item_id by grabbing the first offset key in the array.
|
105 |
-
<pre><code><
|
106 |
if ( function_exists( 'get_option_tree' ) ) {
|
107 |
get_option_tree( 'test_option', '', true, true, 0 );
|
108 |
}
|
@@ -125,7 +125,7 @@ if ( function_exists( 'get_option_tree' ) ) {
|
|
125 |
}
|
126 |
?></code></pre>
|
127 |
OR a more WordPress version would be:<br /><br />
|
128 |
-
<pre><code><
|
129 |
if ( function_exists( 'get_option_tree' ) ) {
|
130 |
// set an array of page id's
|
131 |
$ids = get_option_tree( 'list_of_page_ids', $theme_options, false, true, -1 );
|
@@ -140,6 +140,31 @@ if ( function_exists( 'get_option_tree' ) ) {
|
|
140 |
);
|
141 |
echo '</ul>';
|
142 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
?></code></pre>
|
144 |
</p>
|
145 |
|
@@ -246,8 +271,91 @@ if ( function_exists( 'get_option_tree' ) ) {
|
|
246 |
|
247 |
<p>
|
248 |
<strong>Measurement</strong>:<br />
|
249 |
-
The Measurement option type is a mix of input and select. The input excepts a value and the select lets you
|
|
|
|
|
|
|
|
|
|
|
250 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
</div>
|
253 |
|
@@ -290,6 +398,7 @@ if ( function_exists( 'get_option_tree' ) ) {
|
|
290 |
<li>Custom Post</li>
|
291 |
<li>Custom Posts</li>
|
292 |
<li>Measurement</li>
|
|
|
293 |
</ul>
|
294 |
|
295 |
<p>
|
78 |
|
79 |
<p>
|
80 |
This example returns the $item_id value.
|
81 |
+
<pre><code><?php
|
82 |
if ( function_exists( 'get_option_tree' ) ) {
|
83 |
get_option_tree( 'test_option' );
|
84 |
}
|
87 |
|
88 |
<p>
|
89 |
These examples will echo the $item_id value.
|
90 |
+
<pre><code><?php
|
91 |
if ( function_exists( 'get_option_tree') ) {
|
92 |
get_option_tree( 'test_option', '', true );
|
93 |
}
|
101 |
</p>
|
102 |
|
103 |
<p>
|
104 |
+
This example will echo the value of $item_id by grabbing the first offset key in the array.
|
105 |
+
<pre><code><?php
|
106 |
if ( function_exists( 'get_option_tree' ) ) {
|
107 |
get_option_tree( 'test_option', '', true, true, 0 );
|
108 |
}
|
125 |
}
|
126 |
?></code></pre>
|
127 |
OR a more WordPress version would be:<br /><br />
|
128 |
+
<pre><code><?php
|
129 |
if ( function_exists( 'get_option_tree' ) ) {
|
130 |
// set an array of page id's
|
131 |
$ids = get_option_tree( 'list_of_page_ids', $theme_options, false, true, -1 );
|
140 |
);
|
141 |
echo '</ul>';
|
142 |
}
|
143 |
+
?></code></pre>
|
144 |
+
</p>
|
145 |
+
|
146 |
+
<p>
|
147 |
+
This example explains how to use the Measurement post type in your PHP files. The Measurement post type is an array of key/value pairs where the first key's value is the value of the measurement and the second key's value is the unit of measurement.
|
148 |
+
<pre><code><?php
|
149 |
+
if ( function_exists( 'get_option_tree' ) ) {
|
150 |
+
$measurement = get_option_tree( 'measurement_type_id' );
|
151 |
+
echo $measurement[0].$measurement[1];
|
152 |
+
}
|
153 |
+
?></code></pre>
|
154 |
+
</p>
|
155 |
+
|
156 |
+
<p>
|
157 |
+
This example displays a very basic slider loop.
|
158 |
+
<pre><code><?php
|
159 |
+
if ( function_exists( 'get_option_tree' ) ) {
|
160 |
+
foreach( (array) get_option_tree( 'my_slider' ) as $slide ) {
|
161 |
+
echo '
|
162 |
+
<li>
|
163 |
+
<a href="'.$slide['link'].'"><img src="'.$slide['image'].'" alt="'.$slide['title'].'" /></a>
|
164 |
+
<div class="description">'.$slide['description'].'</div>
|
165 |
+
</li>';
|
166 |
+
}
|
167 |
+
}
|
168 |
?></code></pre>
|
169 |
</p>
|
170 |
|
271 |
|
272 |
<p>
|
273 |
<strong>Measurement</strong>:<br />
|
274 |
+
The Measurement option type is a mix of input and select fields. The text input excepts a value and the select list lets you choose the unit of measurement to add to that value. Currently the default units are px, %, em, pt. However, you can change them with the<code>measurement_unit_types</code> filter.
|
275 |
+
</p>
|
276 |
+
|
277 |
+
<p>
|
278 |
+
<strong>Filter to completely change the units in the Measurement option type</strong><br />
|
279 |
+
Added to functions.php
|
280 |
</p>
|
281 |
+
|
282 |
+
<pre><code>add_filter( 'measurement_unit_types', 'custom_unit_types' );
|
283 |
+
|
284 |
+
function custom_unit_types()
|
285 |
+
{
|
286 |
+
$array = array(
|
287 |
+
'in' => 'inches',
|
288 |
+
'ft' => 'feet'
|
289 |
+
);
|
290 |
+
return $array;
|
291 |
+
}</code></pre>
|
292 |
+
|
293 |
+
<p>
|
294 |
+
<strong>Filter to add new units in the Measurement option type</strong><br />
|
295 |
+
Added to functions.php
|
296 |
+
</p>
|
297 |
+
|
298 |
+
<pre><code>add_filter( 'measurement_unit_types', 'custom_unit_types' );
|
299 |
+
|
300 |
+
function custom_unit_types($array)
|
301 |
+
{
|
302 |
+
$array['in'] = 'inches';
|
303 |
+
$array['ft'] = 'feet';
|
304 |
+
return $array;
|
305 |
+
}</code></pre>
|
306 |
+
|
307 |
+
<p>
|
308 |
+
<strong>Slider</strong>:<br />
|
309 |
+
The Slider option type is a mix of elements that you can change with the<code>image_slider_fields</code> filter. The currently supported element types are text, textarea, & hidden. In the future there will be more input types. As well, the current inputs are order, title, image, link, & description. Order & title are required fields. However, the other three can be altered using the filter above.<br />
|
310 |
+
|
311 |
+
<p>
|
312 |
+
<strong>Filter to completely change the input fields in the Slider option type</strong><br />
|
313 |
+
Added to functions.php
|
314 |
+
</p>
|
315 |
+
<pre><code>add_filter( 'image_slider_fields', 'new_slider_fields' );
|
316 |
+
|
317 |
+
function new_slider_fields()
|
318 |
+
{
|
319 |
+
$array = array(
|
320 |
+
array(
|
321 |
+
'name' => 'image',
|
322 |
+
'type' => 'text',
|
323 |
+
'label' => 'Post Image URL',
|
324 |
+
'class' => ''
|
325 |
+
),
|
326 |
+
array(
|
327 |
+
'name' => 'link',
|
328 |
+
'type' => 'text',
|
329 |
+
'label' => 'Post URL',
|
330 |
+
'class' => ''
|
331 |
+
),
|
332 |
+
array(
|
333 |
+
'name' => 'description',
|
334 |
+
'type' => 'textarea',
|
335 |
+
'label' => 'Post Description',
|
336 |
+
'class' => ''
|
337 |
+
)
|
338 |
+
);
|
339 |
+
return $array;
|
340 |
+
}</code></pre>
|
341 |
+
|
342 |
+
<p>
|
343 |
+
<strong>Filter to add a new field to the Slider option type</strong><br />
|
344 |
+
Added to functions.php
|
345 |
+
</p>
|
346 |
+
<pre><code>add_filter( 'image_slider_fields', 'new_slider_fields' );
|
347 |
+
|
348 |
+
function new_slider_fields($array)
|
349 |
+
{
|
350 |
+
$array[] =
|
351 |
+
array(
|
352 |
+
'name' => 'awesome_field',
|
353 |
+
'type' => 'text',
|
354 |
+
'label' => 'Write Something Awesome',
|
355 |
+
'class' => ''
|
356 |
+
);
|
357 |
+
return $array;
|
358 |
+
}</code></pre>
|
359 |
|
360 |
</div>
|
361 |
|
398 |
<li>Custom Post</li>
|
399 |
<li>Custom Posts</li>
|
400 |
<li>Measurement</li>
|
401 |
+
<li>Slider</li>
|
402 |
</ul>
|
403 |
|
404 |
<p>
|
front-end/settings.php
CHANGED
@@ -130,7 +130,8 @@
|
|
130 |
'tags' => 'Tags',
|
131 |
'custom_post' => 'Custom Post',
|
132 |
'custom_posts' => 'Custom Posts',
|
133 |
-
'measurement' => 'Measurement'
|
|
|
134 |
);
|
135 |
foreach ( $types as $key => $value )
|
136 |
{
|
130 |
'tags' => 'Tags',
|
131 |
'custom_post' => 'Custom Post',
|
132 |
'custom_posts' => 'Custom Posts',
|
133 |
+
'measurement' => 'Measurement',
|
134 |
+
'slider' => 'Slider'
|
135 |
);
|
136 |
foreach ( $types as $key => $value )
|
137 |
{
|
functions/admin/category.php
CHANGED
@@ -71,16 +71,12 @@ function option_tree_categories( $value, $settings, $int )
|
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
-
// check for settings item value
|
75 |
-
if ( isset( $settings[$value->item_id] ) )
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
$ch_values = array();
|
82 |
}
|
83 |
-
|
84 |
// loop through tags
|
85 |
$categories = &get_categories( array( 'hide_empty' => false ) );
|
86 |
if ( $categories )
|
@@ -93,7 +89,7 @@ function option_tree_categories( $value, $settings, $int )
|
|
93 |
{
|
94 |
$checked = ' checked="checked"';
|
95 |
}
|
96 |
-
echo '<div class="input_wrap"><input name="
|
97 |
$count++;
|
98 |
}
|
99 |
}
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
+
// check for settings item value
|
75 |
+
if ( isset( $settings[$value->item_id] ) ) {
|
76 |
+
$ch_values = (array) $settings[$value->item_id];
|
77 |
+
} else {
|
|
|
|
|
|
|
78 |
$ch_values = array();
|
79 |
}
|
|
|
80 |
// loop through tags
|
81 |
$categories = &get_categories( array( 'hide_empty' => false ) );
|
82 |
if ( $categories )
|
89 |
{
|
90 |
$checked = ' checked="checked"';
|
91 |
}
|
92 |
+
echo '<div class="input_wrap"><input name="'.$value->item_id.'['.$count.']" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$category->term_id.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$category->name.'</label></div>';
|
93 |
$count++;
|
94 |
}
|
95 |
}
|
functions/admin/checkbox.php
CHANGED
@@ -20,29 +20,21 @@ function option_tree_checkbox( $value, $settings, $int )
|
|
20 |
<div class="element">
|
21 |
<?php
|
22 |
// check for settings item value
|
23 |
-
if ( isset( $settings[$value->item_id] ) )
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
-
else
|
28 |
-
{
|
29 |
$ch_values = array();
|
30 |
}
|
31 |
-
|
32 |
$count = 0;
|
33 |
-
|
34 |
-
// create options array
|
35 |
-
$options_array = explode( ',', $value->item_options );
|
36 |
-
|
37 |
// loop through options array
|
38 |
-
foreach ( $
|
39 |
{
|
40 |
$checked = '';
|
41 |
-
if ( in_array( trim( $option ), $ch_values) )
|
42 |
{
|
43 |
$checked = ' checked="checked"';
|
44 |
}
|
45 |
-
echo '<div class="input_wrap"><input name="
|
46 |
$count++;
|
47 |
}
|
48 |
?>
|
20 |
<div class="element">
|
21 |
<?php
|
22 |
// check for settings item value
|
23 |
+
if ( isset( $settings[$value->item_id] ) ) {
|
24 |
+
$ch_values = (array) $settings[$value->item_id];
|
25 |
+
} else {
|
|
|
|
|
|
|
26 |
$ch_values = array();
|
27 |
}
|
|
|
28 |
$count = 0;
|
|
|
|
|
|
|
|
|
29 |
// loop through options array
|
30 |
+
foreach ( explode( ',', $value->item_options ) as $option )
|
31 |
{
|
32 |
$checked = '';
|
33 |
+
if ( in_array( trim( $option ), $ch_values ) )
|
34 |
{
|
35 |
$checked = ' checked="checked"';
|
36 |
}
|
37 |
+
echo '<div class="input_wrap"><input name="'.$value->item_id.'['.$count.']" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.trim( $option ).'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.trim( $option ).'</label></div>';
|
38 |
$count++;
|
39 |
}
|
40 |
?>
|
functions/admin/custom-post.php
CHANGED
@@ -71,16 +71,12 @@ function option_tree_custom_posts( $value, $settings, $int )
|
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
-
// check for settings item value
|
75 |
-
if ( isset( $settings[$value->item_id] ) )
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
$ch_values = array();
|
82 |
}
|
83 |
-
|
84 |
// loop through tags
|
85 |
$posts = &get_posts( array( 'post_type' => $value->item_options, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
|
86 |
if ( $posts )
|
@@ -93,7 +89,7 @@ function option_tree_custom_posts( $value, $settings, $int )
|
|
93 |
{
|
94 |
$checked = ' checked="checked"';
|
95 |
}
|
96 |
-
echo '<div class="input_wrap"><input name="
|
97 |
$count++;
|
98 |
}
|
99 |
}
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
+
// check for settings item value
|
75 |
+
if ( isset( $settings[$value->item_id] ) ) {
|
76 |
+
$ch_values = (array) $settings[$value->item_id];
|
77 |
+
} else {
|
|
|
|
|
|
|
78 |
$ch_values = array();
|
79 |
}
|
|
|
80 |
// loop through tags
|
81 |
$posts = &get_posts( array( 'post_type' => $value->item_options, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
|
82 |
if ( $posts )
|
89 |
{
|
90 |
$checked = ' checked="checked"';
|
91 |
}
|
92 |
+
echo '<div class="input_wrap"><input name="'.$value->item_id.'['.$count.']" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$post->ID.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$post->post_title.'</label></div>';
|
93 |
$count++;
|
94 |
}
|
95 |
}
|
functions/admin/measurement.php
CHANGED
@@ -13,39 +13,34 @@
|
|
13 |
* @return string
|
14 |
*/
|
15 |
function option_tree_measurement( $value, $settings, $int ) { ?>
|
16 |
-
<div class="option option-
|
17 |
<h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
|
18 |
<div class="section">
|
19 |
<div class="element">
|
20 |
-
<?php
|
21 |
if ( isset( $settings[$value->item_id] ) )
|
22 |
-
|
23 |
-
|
24 |
-
}
|
25 |
-
else
|
26 |
-
{
|
27 |
-
$measurement = array();
|
28 |
-
}
|
29 |
-
?>
|
30 |
-
<input type="text" name="measurement[<?php echo $value->item_id; ?>][]" value="<?php if ( isset( $measurement[0] ) ) { echo htmlspecialchars( stripslashes( $measurement[0] ), ENT_QUOTES); } ?>" class="measurement" />
|
31 |
|
32 |
<div class="select_wrapper measurement">
|
33 |
-
<select name="
|
34 |
<?php
|
35 |
-
echo '<option value=""
|
36 |
$units = array(
|
37 |
'px' => 'px',
|
38 |
'%' => '%',
|
39 |
'em' => 'em',
|
40 |
'pt' => 'pt'
|
41 |
);
|
42 |
-
|
|
|
43 |
foreach ( $units as $unit ) {
|
44 |
-
$selected = '';
|
45 |
if ( isset( $measurement[1] ) && $measurement[1] == trim( $unit ) ) {
|
46 |
$selected = ' selected="selected"';
|
|
|
|
|
47 |
}
|
48 |
-
echo '<option'.$selected.'
|
49 |
}
|
50 |
?>
|
51 |
</select>
|
13 |
* @return string
|
14 |
*/
|
15 |
function option_tree_measurement( $value, $settings, $int ) { ?>
|
16 |
+
<div class="option option-measurement">
|
17 |
<h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
|
18 |
<div class="section">
|
19 |
<div class="element">
|
20 |
+
<?php
|
21 |
if ( isset( $settings[$value->item_id] ) )
|
22 |
+
$measurement = $settings[$value->item_id]; ?>
|
23 |
+
<input type="text" name="<?php echo $value->item_id; ?>[0]" value="<?php if ( isset( $measurement[0] ) ) { echo htmlspecialchars( stripslashes( $measurement[0] ), ENT_QUOTES); } ?>" class="measurement" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
<div class="select_wrapper measurement">
|
26 |
+
<select name="<?php echo $value->item_id; ?>[1]" class="select">
|
27 |
<?php
|
28 |
+
echo '<option value=""> -- </option>';
|
29 |
$units = array(
|
30 |
'px' => 'px',
|
31 |
'%' => '%',
|
32 |
'em' => 'em',
|
33 |
'pt' => 'pt'
|
34 |
);
|
35 |
+
// filter the unit types
|
36 |
+
$units = apply_filters( 'measurement_unit_types', $units );
|
37 |
foreach ( $units as $unit ) {
|
|
|
38 |
if ( isset( $measurement[1] ) && $measurement[1] == trim( $unit ) ) {
|
39 |
$selected = ' selected="selected"';
|
40 |
+
} else {
|
41 |
+
$selected = '';
|
42 |
}
|
43 |
+
echo '<option'.$selected.' value="'.trim( $unit ).'"> '.trim( $unit ).'</option>';
|
44 |
}
|
45 |
?>
|
46 |
</select>
|
functions/admin/page.php
CHANGED
@@ -71,16 +71,12 @@ function option_tree_pages( $value, $settings, $int )
|
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
-
// check for settings item value
|
75 |
-
if ( isset( $settings[$value->item_id] ) )
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
$ch_values = array();
|
82 |
}
|
83 |
-
|
84 |
// loop through tags
|
85 |
$pages = &get_pages();
|
86 |
if ( $pages )
|
@@ -93,7 +89,7 @@ function option_tree_pages( $value, $settings, $int )
|
|
93 |
{
|
94 |
$checked = ' checked="checked"';
|
95 |
}
|
96 |
-
echo '<div class="input_wrap"><input name="
|
97 |
$count++;
|
98 |
}
|
99 |
}
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
+
// check for settings item value
|
75 |
+
if ( isset( $settings[$value->item_id] ) ) {
|
76 |
+
$ch_values = (array) $settings[$value->item_id];
|
77 |
+
} else {
|
|
|
|
|
|
|
78 |
$ch_values = array();
|
79 |
}
|
|
|
80 |
// loop through tags
|
81 |
$pages = &get_pages();
|
82 |
if ( $pages )
|
89 |
{
|
90 |
$checked = ' checked="checked"';
|
91 |
}
|
92 |
+
echo '<div class="input_wrap"><input name="'.$value->item_id.'['.$count.']" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$page->ID.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$page->post_title.'</label></div>';
|
93 |
$count++;
|
94 |
}
|
95 |
}
|
functions/admin/post.php
CHANGED
@@ -71,16 +71,12 @@ function option_tree_posts( $value, $settings, $int )
|
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
-
// check for settings item value
|
75 |
-
if ( isset( $settings[$value->item_id] ) )
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
$ch_values = array();
|
82 |
}
|
83 |
-
|
84 |
// loop through posts
|
85 |
$posts = &get_posts( array( 'numberposts' => -1, 'orderby' => 'date' ) );
|
86 |
if ( $posts )
|
@@ -93,7 +89,7 @@ function option_tree_posts( $value, $settings, $int )
|
|
93 |
{
|
94 |
$checked = ' checked="checked"';
|
95 |
}
|
96 |
-
echo '<div class="input_wrap"><input name="
|
97 |
$count++;
|
98 |
}
|
99 |
}
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
+
// check for settings item value
|
75 |
+
if ( isset( $settings[$value->item_id] ) ) {
|
76 |
+
$ch_values = (array) $settings[$value->item_id];
|
77 |
+
} else {
|
|
|
|
|
|
|
78 |
$ch_values = array();
|
79 |
}
|
|
|
80 |
// loop through posts
|
81 |
$posts = &get_posts( array( 'numberposts' => -1, 'orderby' => 'date' ) );
|
82 |
if ( $posts )
|
89 |
{
|
90 |
$checked = ' checked="checked"';
|
91 |
}
|
92 |
+
echo '<div class="input_wrap"><input name="'.$value->item_id.'['.$count.']" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$post->ID.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$post->post_title.'</label></div>';
|
93 |
$count++;
|
94 |
}
|
95 |
}
|
functions/admin/radio.php
CHANGED
@@ -20,29 +20,21 @@ function option_tree_radio( $value, $settings, $int )
|
|
20 |
<div class="element">
|
21 |
<?php
|
22 |
// check for settings item value
|
23 |
-
if ( isset( $settings[$value->item_id] ) )
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
-
else
|
28 |
-
{
|
29 |
$ch_values = array();
|
30 |
}
|
31 |
-
|
32 |
$count = 0;
|
33 |
-
|
34 |
-
// create options array
|
35 |
-
$options_array = explode( ',', $value->item_options );
|
36 |
-
|
37 |
// loop through options array
|
38 |
-
foreach ( $
|
39 |
{
|
40 |
$checked = '';
|
41 |
if ( in_array( trim( $option ), $ch_values ) )
|
42 |
{
|
43 |
$checked = ' checked="checked"';
|
44 |
}
|
45 |
-
echo '<div class="input_wrap"><input name="
|
46 |
$count++;
|
47 |
}
|
48 |
?>
|
20 |
<div class="element">
|
21 |
<?php
|
22 |
// check for settings item value
|
23 |
+
if ( isset( $settings[$value->item_id] ) ) {
|
24 |
+
$ch_values = (array) $settings[$value->item_id];
|
25 |
+
} else {
|
|
|
|
|
|
|
26 |
$ch_values = array();
|
27 |
}
|
|
|
28 |
$count = 0;
|
|
|
|
|
|
|
|
|
29 |
// loop through options array
|
30 |
+
foreach ( explode( ',', $value->item_options ) as $option )
|
31 |
{
|
32 |
$checked = '';
|
33 |
if ( in_array( trim( $option ), $ch_values ) )
|
34 |
{
|
35 |
$checked = ' checked="checked"';
|
36 |
}
|
37 |
+
echo '<div class="input_wrap"><input name="'.$value->item_id.'" id="'.$value->item_id.'_'.$count.'" type="radio" value="'.trim( $option ).'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.trim( $option ).'</label></div>';
|
38 |
$count++;
|
39 |
}
|
40 |
?>
|
functions/admin/slider.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
|
2 |
+
/**
|
3 |
+
* Image Slider Option
|
4 |
+
*
|
5 |
+
* @access public
|
6 |
+
* @since 1.1.3
|
7 |
+
*
|
8 |
+
* @param array $value
|
9 |
+
* @param array $settings
|
10 |
+
* @param int $int
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
function option_tree_slider( $value, $settings, $int )
|
15 |
+
{
|
16 |
+
?>
|
17 |
+
<div class="option option-option-tree-slider">
|
18 |
+
<h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
|
19 |
+
<div class="section">
|
20 |
+
<div class="element">
|
21 |
+
<?php $count = 0; ?>
|
22 |
+
<ul class="ui-sortable option-tree-slider-wrap">
|
23 |
+
<?php
|
24 |
+
if ( !empty( $settings[$value->item_id] ) ) {
|
25 |
+
foreach( $settings[$value->item_id] as $image ) { ?>
|
26 |
+
<li><?php slider_view( $value->item_id, $image, $count ); ?></li><?php
|
27 |
+
$count++;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
?>
|
31 |
+
</ul>
|
32 |
+
<a href="#" id="<?php echo $value->item_id; ?>" class="button-framework light add-slide right">Add Slide</a>
|
33 |
+
</div>
|
34 |
+
<div class="description">
|
35 |
+
<?php echo htmlspecialchars_decode( $value->item_desc ); ?>
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
<?php
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Image Slider HTML
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @since 1.1.3
|
47 |
+
*
|
48 |
+
* @param string $id
|
49 |
+
* @param array $image
|
50 |
+
* @param int $count
|
51 |
+
*
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
function slider_view( $id, $image, $count )
|
55 |
+
{
|
56 |
+
// required fileds
|
57 |
+
$requred_fields = array(
|
58 |
+
array(
|
59 |
+
'name' => 'order',
|
60 |
+
'type' => 'hidden',
|
61 |
+
'label' => '',
|
62 |
+
'class' => 'option-tree-slider-order'
|
63 |
+
),
|
64 |
+
array(
|
65 |
+
'name' => 'title',
|
66 |
+
'type' => 'text',
|
67 |
+
'label' => 'Title',
|
68 |
+
'class' => 'option-tree-slider-title'
|
69 |
+
)
|
70 |
+
);
|
71 |
+
|
72 |
+
// optional fields
|
73 |
+
$image_slider_fields = array(
|
74 |
+
array(
|
75 |
+
'name' => 'image',
|
76 |
+
'type' => 'text',
|
77 |
+
'label' => 'Image URL',
|
78 |
+
'class' => ''
|
79 |
+
),
|
80 |
+
array(
|
81 |
+
'name' => 'link',
|
82 |
+
'type' => 'text',
|
83 |
+
'label' => 'Link URL',
|
84 |
+
'class' => ''
|
85 |
+
),
|
86 |
+
array(
|
87 |
+
'name' => 'description',
|
88 |
+
'type' => 'textarea',
|
89 |
+
'label' => 'Description',
|
90 |
+
'class' => ''
|
91 |
+
)
|
92 |
+
);
|
93 |
+
|
94 |
+
// filter the optional fields
|
95 |
+
$image_slider_fields = apply_filters( 'image_slider_fields', $image_slider_fields );
|
96 |
+
|
97 |
+
// merge required & optional arrays
|
98 |
+
$image_slider_fields = array_merge( $requred_fields, $image_slider_fields );
|
99 |
+
?>
|
100 |
+
<div id="option-tree-slider-editor_<?php echo $count; ?>" class="option-tree-slider">
|
101 |
+
<div class="open">
|
102 |
+
<?php echo empty( $image['title'] ) ? "Slide " . ($count + 1) : stripslashes($image['title']); ?>
|
103 |
+
</div>
|
104 |
+
<a href="#" class="edit">Edit</a>
|
105 |
+
<a href="#" class="trash remove-slide">Delete</a>
|
106 |
+
<div class="option-tree-slider-body">
|
107 |
+
<?php
|
108 |
+
foreach( $image_slider_fields as $field ) {
|
109 |
+
if ( $field['type'] == 'text' ) {
|
110 |
+
echo '
|
111 |
+
<p>
|
112 |
+
<label>'.$field['label'].'</label>
|
113 |
+
<input type="text" name="'.$id.'['.$count.']['.$field['name'].']" value="'.( isset( $image[$field['name']] ) ? stripslashes($image[$field['name']]) : '' ).'" class="'.$field['class'].'" />
|
114 |
+
</p>';
|
115 |
+
} else if ( $field['type'] == 'textarea' ) {
|
116 |
+
echo '
|
117 |
+
<p>
|
118 |
+
<label>'.$field['label'].'</label>
|
119 |
+
<textarea name="'.$id.'['.$count.']['.$field['name'].']" rows="6" class="'.$field['class'].'">'.( isset( $image[$field['name']] ) ? stripslashes($image[$field['name']]) : '' ).'</textarea>
|
120 |
+
</p>';
|
121 |
+
} else if ( $field['type'] == 'hidden' ) {
|
122 |
+
echo '<input type="hidden" name="'.$id.'['.$count.']['.$field['name'].']" value="'.( isset( $image[$field['name']] ) ? stripslashes($image[$field['name']]) : '' ).'" class="'.$field['class'].'" />';
|
123 |
+
}
|
124 |
+
}
|
125 |
+
?>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
<?php
|
129 |
+
}
|
functions/admin/tag.php
CHANGED
@@ -71,16 +71,12 @@ function option_tree_tags( $value, $settings, $int )
|
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
-
// check for settings item value
|
75 |
-
if ( isset( $settings[$value->item_id] ) )
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
$ch_values = array();
|
82 |
}
|
83 |
-
|
84 |
// loop through tags
|
85 |
$tags = &get_tags( array( 'hide_empty' => false ) );
|
86 |
if ( $tags )
|
@@ -93,7 +89,7 @@ function option_tree_tags( $value, $settings, $int )
|
|
93 |
{
|
94 |
$checked = ' checked="checked"';
|
95 |
}
|
96 |
-
echo '<div class="input_wrap"><input name="
|
97 |
$count++;
|
98 |
}
|
99 |
}
|
71 |
<div class="section">
|
72 |
<div class="element">
|
73 |
<?php
|
74 |
+
// check for settings item value
|
75 |
+
if ( isset( $settings[$value->item_id] ) ) {
|
76 |
+
$ch_values = (array) $settings[$value->item_id];
|
77 |
+
} else {
|
|
|
|
|
|
|
78 |
$ch_values = array();
|
79 |
}
|
|
|
80 |
// loop through tags
|
81 |
$tags = &get_tags( array( 'hide_empty' => false ) );
|
82 |
if ( $tags )
|
89 |
{
|
90 |
$checked = ' checked="checked"';
|
91 |
}
|
92 |
+
echo '<div class="input_wrap"><input name="'.$value->item_id.'['.$count.']" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$tag->term_id.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$tag->name.'</label></div>';
|
93 |
$count++;
|
94 |
}
|
95 |
}
|
functions/functions.load.php
CHANGED
@@ -25,6 +25,7 @@ if ( is_admin() )
|
|
25 |
include( 'admin/tag.php' );
|
26 |
include( 'admin/custom-post.php' );
|
27 |
include( 'admin/measurement.php' );
|
|
|
28 |
}
|
29 |
else if ( !is_admin() )
|
30 |
{
|
25 |
include( 'admin/tag.php' );
|
26 |
include( 'admin/custom-post.php' );
|
27 |
include( 'admin/measurement.php' );
|
28 |
+
include( 'admin/slider.php' );
|
29 |
}
|
30 |
else if ( !is_admin() )
|
31 |
{
|
functions/get-option-tree.php
CHANGED
@@ -16,26 +16,28 @@
|
|
16 |
* @return mixed
|
17 |
*/
|
18 |
function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1)
|
19 |
-
{
|
20 |
// load saved options
|
21 |
if ( !$options )
|
22 |
$options = get_option( 'option_tree' );
|
23 |
|
24 |
-
//
|
25 |
-
if ( !isset( $options[$item_id] ) )
|
26 |
return;
|
27 |
|
28 |
-
//
|
29 |
-
$content =
|
30 |
-
|
31 |
-
//
|
32 |
-
if ( $is_array )
|
33 |
{
|
34 |
-
$
|
|
|
|
|
|
|
|
|
35 |
if ( is_numeric( $offset ) && $offset >= 0)
|
36 |
-
|
37 |
-
$content = htmlspecialchars_decode( trim( $content[$offset] ) );
|
38 |
-
}
|
39 |
}
|
40 |
|
41 |
// echo content
|
@@ -43,4 +45,39 @@ function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array
|
|
43 |
echo $content;
|
44 |
|
45 |
return $content;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
16 |
* @return mixed
|
17 |
*/
|
18 |
function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1)
|
19 |
+
{
|
20 |
// load saved options
|
21 |
if ( !$options )
|
22 |
$options = get_option( 'option_tree' );
|
23 |
|
24 |
+
// no value return
|
25 |
+
if ( !isset( $options[$item_id] ) || empty( $options[$item_id] ) )
|
26 |
return;
|
27 |
|
28 |
+
// set content value & strip slashes
|
29 |
+
$content = option_tree_stripslashes( $options[$item_id] );
|
30 |
+
|
31 |
+
// is an array
|
32 |
+
if ( $is_array || is_array( $content ) )
|
33 |
{
|
34 |
+
// $is_array is true but it's not an actual array, so build it!
|
35 |
+
if ( !is_array( $content ) )
|
36 |
+
$content = explode( ',', $content );
|
37 |
+
|
38 |
+
// get an array value using an offset
|
39 |
if ( is_numeric( $offset ) && $offset >= 0)
|
40 |
+
$content = $content[$offset];
|
|
|
|
|
41 |
}
|
42 |
|
43 |
// echo content
|
45 |
echo $content;
|
46 |
|
47 |
return $content;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Custom stripslashes from single value or array.
|
52 |
+
*
|
53 |
+
* @uses stripslashes()
|
54 |
+
*
|
55 |
+
* @access public
|
56 |
+
* @since 1.1.3
|
57 |
+
*
|
58 |
+
* @param mixed $input
|
59 |
+
*
|
60 |
+
* @return mixed
|
61 |
+
*/
|
62 |
+
function option_tree_stripslashes( $input )
|
63 |
+
{
|
64 |
+
if ( is_array( $input ) )
|
65 |
+
{
|
66 |
+
foreach( $input as &$val )
|
67 |
+
{
|
68 |
+
if ( is_array( $val ) )
|
69 |
+
{
|
70 |
+
$val = option_tree_stripslashes( $val );
|
71 |
+
}
|
72 |
+
else
|
73 |
+
{
|
74 |
+
$val = stripslashes( $val );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
else
|
79 |
+
{
|
80 |
+
$input = stripslashes( $input );
|
81 |
+
}
|
82 |
+
return $input;
|
83 |
}
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: OptionTree
|
4 |
Plugin URI: http://wp.envato.com
|
5 |
Description: Customizable WordPress Theme Options Admin Interface
|
6 |
-
Version: 1.1.
|
7 |
Author: Derek Herman
|
8 |
Author URI: http://valendesigns.com
|
9 |
*/
|
@@ -13,7 +13,7 @@ Author URI: http://valendesigns.com
|
|
13 |
*
|
14 |
* @since 1.0.0
|
15 |
*/
|
16 |
-
define( 'OT_VERSION', '1.1.
|
17 |
define( 'OT_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
|
18 |
define( 'OT_PLUGIN_URL', WP_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) );
|
19 |
|
@@ -60,4 +60,5 @@ add_action( 'wp_ajax_option_tree_edit', array( $ot_admin, 'option_tree_edit' ) )
|
|
60 |
add_action( 'wp_ajax_option_tree_delete', array( $ot_admin, 'option_tree_delete' ) );
|
61 |
add_action( 'wp_ajax_option_tree_next_id', array( $ot_admin, 'option_tree_next_id' ) );
|
62 |
add_action( 'wp_ajax_option_tree_sort', array( $ot_admin, 'option_tree_sort' ) );
|
63 |
-
add_action( 'wp_ajax_option_tree_import_data', array( $ot_admin, 'option_tree_import_data' ) );
|
|
3 |
Plugin Name: OptionTree
|
4 |
Plugin URI: http://wp.envato.com
|
5 |
Description: Customizable WordPress Theme Options Admin Interface
|
6 |
+
Version: 1.1.3
|
7 |
Author: Derek Herman
|
8 |
Author URI: http://valendesigns.com
|
9 |
*/
|
13 |
*
|
14 |
* @since 1.0.0
|
15 |
*/
|
16 |
+
define( 'OT_VERSION', '1.1.3' );
|
17 |
define( 'OT_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
|
18 |
define( 'OT_PLUGIN_URL', WP_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) );
|
19 |
|
60 |
add_action( 'wp_ajax_option_tree_delete', array( $ot_admin, 'option_tree_delete' ) );
|
61 |
add_action( 'wp_ajax_option_tree_next_id', array( $ot_admin, 'option_tree_next_id' ) );
|
62 |
add_action( 'wp_ajax_option_tree_sort', array( $ot_admin, 'option_tree_sort' ) );
|
63 |
+
add_action( 'wp_ajax_option_tree_import_data', array( $ot_admin, 'option_tree_import_data' ) );
|
64 |
+
add_action( 'wp_ajax_option_tree_add_slider', array( $ot_admin, 'option_tree_add_slider' ) );
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: valendesigns
|
|
3 |
Donate link:
|
4 |
Tags: admin, theme options, options, admin interface, ajax
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.1.
|
8 |
|
9 |
Customizable WordPress Theme Options Admin Interface
|
10 |
|
@@ -29,7 +29,7 @@ OptionTree is a project sponsored by ThemeForest, the largest WordPress theme ma
|
|
29 |
|
30 |
= Is this plugin PHP5 only? =
|
31 |
|
32 |
-
|
33 |
|
34 |
== Screenshots ==
|
35 |
|
@@ -39,6 +39,13 @@ Yes OptionTree requires your host be running PHP5 to work correctly.
|
|
39 |
|
40 |
== Changelog ==
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
= 1.1.2 =
|
43 |
* Fixed double quotes in Textarea option type
|
44 |
* Added Measurement option type for CSS values
|
3 |
Donate link:
|
4 |
Tags: admin, theme options, options, admin interface, ajax
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.1
|
7 |
+
Stable tag: 1.1.3
|
8 |
|
9 |
Customizable WordPress Theme Options Admin Interface
|
10 |
|
29 |
|
30 |
= Is this plugin PHP5 only? =
|
31 |
|
32 |
+
Sorry, but yes. OptionTree requires PHP5 to work correctly.
|
33 |
|
34 |
== Screenshots ==
|
35 |
|
39 |
|
40 |
== Changelog ==
|
41 |
|
42 |
+
= 1.1.3 =
|
43 |
+
* Added Slider option type with filter for changing the optional fields
|
44 |
+
* Fixed the text displayed for Measurement option type after options are reset
|
45 |
+
* Added filter to measurement units
|
46 |
+
* Code cleanup in the option_tree_array_save() function
|
47 |
+
* Fixed double quotes on front-end display
|
48 |
+
|
49 |
= 1.1.2 =
|
50 |
* Fixed double quotes in Textarea option type
|
51 |
* Added Measurement option type for CSS values
|