first commit

This commit is contained in:
alazhar
2020-01-02 23:15:16 +07:00
commit eda9661806
3433 changed files with 595883 additions and 0 deletions

View File

@ -0,0 +1,352 @@
/* --------------------------------------------------
:: Screen Meta & Menu Icon
---------------------------------------------------*/
.appearance_page_ot-theme-options #screen-meta { margin-right: 20px; margin-left: 2px; min-width: 533px; }
/* --------------------------------------------------
:: Messages
---------------------------------------------------*/
.wrap.settings-wrap div.error,
.wrap.settings-wrap div.updated { margin: 9px 5px 0px 2px !important; }
/* --------------------------------------------------
:: OptionTree Wrappers
---------------------------------------------------*/
#option-tree-settings-api .metabox-holder { overflow: hidden; }
#option-tree-settings-api .postbox { background: #fff; border: none; margin: 0 20px; }
#option-tree-settings-api .inside { margin: 0px !important; padding: 0px !important; }
#option-tree-settings-api .ui-tabs { background: #fff url(../images/ot-menu-bg.png) repeat-y 0 0; border: 1px solid #ccc; border-top: none; margin: 0px 5px 0 2px; min-width: 533px; padding-bottom: 5px; position: relative; -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05); box-shadow:0 1px 3px rgba(0,0,0,0.05); -webkit-border-bottom-right-radius: 3px; -webkit-border-bottom-left-radius: 3px; -moz-border-radius-bottomright: 3px; -moz-border-radius-bottomleft: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; }
/* --------------------------------------------------
:: Header
---------------------------------------------------*/
#option-tree-header-wrap { position: relative; }
#option-tree-header { background: #464646; color: #ccc; display: block; margin: 11px 5px 0 2px; min-width: 535px; overflow: hidden; position: relative; background-image:-webkit-linear-gradient(bottom, #373737, #464646 5px); -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05); box-shadow:0 1px 3px rgba(0,0,0,0.05); -webkit-border-top-left-radius: 3px; -webkit-border-top-right-radius: 3px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; }
#option-tree-header li { display: block; float: left; margin: 0px; padding: 0px; }
#option-tree-header li a { color: #ccc; text-decoration: none; }
#option-tree-header li a:hover { color: #fafafa; }
#option-tree-header #option-tree-logo a { background: transparent url(../images/ot-logo.png) no-repeat 13px center; border-right: 1px solid #333; display: block; float: left; height: 24px; line-height: 24px; padding: 3px 12px 3px 13px; text-indent: -9999px; width: 24px; }
#option-tree-header li#option-tree-logo:hover { color: #fafafa; background-color: #3a3a3a; background-image: -ms-linear-gradient(bottom,#3a3a3a,#222); background-image: -moz-linear-gradient(bottom,#3a3a3a,#222); background-image: -o-linear-gradient(bottom,#3a3a3a,#222); background-image: -webkit-gradient(linear,left bottom,left top,from(#3a3a3a),to(#222)); background-image: -webkit-linear-gradient(bottom,#3a3a3a,#222); background-image: linear-gradient(bottom,#3a3a3a,#222);-webkit-border-top-left-radius: 4px; -moz-border-radius-topleft: 4px; border-top-left-radius: 4px; }
#option-tree-header #option-tree-version { }
#option-tree-header #option-tree-version span { border-left: 1px solid #555; display: block; float: left; height: 24px; line-height: 24px; padding: 3px 12px 3px 12px; }
/* --------------------------------------------------
:: Sub Header
---------------------------------------------------*/
#option-tree-sub-header { background: #fafafa url(../images/ot-sub-header-bg.png) repeat-x 0 0; border: 1px solid #ccc; border-top: none; display: block; margin: 0 5px 0 2px; min-width: 523px; overflow: hidden; padding: 5px; position: relative; -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05); box-shadow:0 1px 3px rgba(0,0,0,0.05); }
/* --------------------------------------------------
:: Tabs
---------------------------------------------------*/
.wrap.settings-wrap .ui-tabs-nav { background: url(../images/ot-menu-top-bg.png) no-repeat right top; float: left; list-style: none; margin: 0 0 0 -4px; padding: 1em 0; width: 151px; }
.wrap.settings-wrap .ui-tabs-nav li { border: 1px solid transparent; border-right-width: 0px; display: block; margin: 0; }
.wrap.settings-wrap .ui-tabs-nav li.ui-state-active { background: #fff; border-color: #ccc; color: #000; }
.wrap.settings-wrap .ui-tabs-nav li a { color: #21759b; display: block; line-height: 18px; padding: 5px 5px 5px 12px; text-decoration: none; }
.wrap.settings-wrap .ui-tabs-nav li a:hover,
.wrap.settings-wrap .ui-tabs-nav li.ui-state-active a { color: #000; }
.wrap.settings-wrap .ui-tabs-panel { clear: both; }
/* --------------------------------------------------
:: Format Settings
---------------------------------------------------*/
.format-settings { padding: 10px 0 20px 0; position: relative; width: 100%; }
/* --------------------------------------------------
:: Format Setting Label
---------------------------------------------------*/
.format-setting-label { border-bottom: 1px dashed #ddd; margin: 0 0 14px 0; padding: 5px 0px 1px 0px; width: 100%; }
#option-tree-settings-api .description h3,
#option-tree-settings-api .format-setting-label .label,
.metabox-holder .format-setting-label .label { background: none; border: none; color: #333; cursor: text; display: block; font-family: sans-serif !important; font-size: 1.2em !important; font-weight: bold !important; letter-spacing: 0; padding: 0 0 9px 0 !important; -webkit-user-select: text; text-shadow: none; }
/* --------------------------------------------------
:: Format Setting
---------------------------------------------------*/
.format-setting { overflow: hidden; position: relative; width: 100%; }
.format-setting .format-setting-inner { float: left; position: relative; width: 63%; }
.format-setting.no-desc .format-setting-inner,
.format-setting.wide-desc .format-setting-inner,
.option-tree-list-item .format-setting-inner { width: 100%; }
.format-setting .description { float: right; padding: 5px 0; width: 35%; }
.format-setting.no-desc .description,
.format-setting.wide-desc .description,
.option-tree-list-item .description { float: none; width: 100%; }
.list-item-description { padding-top: 10px; }
#option-tree-settings-api h4 { color: #333; font-size: 1.12em; font-weight: bold; margin: 1em 0 0.5em 0; padding: 0; }
#option-tree-settings-api h5 { color: #444; font-size: 1em; font-weight: bold; margin: 1em 0 0.5em 0; padding: 0; }
#option-tree-settings-api p { margin: 0 0 1.5em 0 !important; }
#post .format-setting-inner p { float: left; width: 100%; margin: 0 0 1.05em 0 !important; }
.aside { border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 15px; }
.deprecated { border-bottom: 1px solid #eee; color: #b94029; padding-bottom: 15px; margin-bottom: 15px; }
.warning { color: #b94029; }
.docs-ul { line-height: 1.3em; margin: 0; padding: 0 0 1em 0; }
.docs-ul li { list-style-type: square; margin-left: 20px; }
#contextual-help-setting { float: left; padding: 10px 0 5px 0; width: 100%; }
#contextual-help-label { float: left; padding-top: 20px; width: 100%; }
#option_tree_settings_help { float: left; width: 100%; }
#option-tree-settings-api blockquote { font-style: italic; padding-left: 15px; position: relative; }
#option-tree-settings-api blockquote:before { color: #ccc; content: "\201C"; display: block; font-size: 400%; font-style: normal; left: -10px; position: absolute; top: 10px; }
@media only screen and (max-width: 900px) {
.format-setting .description,
.format-setting .format-setting-inner { width: 100%; }
.format-setting .description { padding-top: 0px; }
}
/* --------------------------------------------------
:: Code formatting
---------------------------------------------------*/
#option-tree-settings-api code { background-color: #f1f1f1; color: #000; }
#option-tree-settings-api pre { font-size: 13px; padding: 0; margin: 1.5em 0; line-height: 18px; overflow: auto; overflow-Y: hidden; padding-top: 18px; background: #f1f1f1; border-bottom: 1px solid #f1f1f1; margin-bottom: 20px; color: #000; white-space:pre-wrap; word-wrap:break-word; }
#option-tree-settings-api pre code { padding: 0 18px 18px 18px; display: block; background: url(../images/ot-pre-bg.gif) repeat left top; }
/* --------------------------------------------------
:: Input & Upload
---------------------------------------------------*/
input.option-tree-ui-upload-input,
input.option-tree-ui-input { background: #fff; border: 1px solid #ccc !important; line-height: 17px; font-size: 12px; margin-bottom: 5px; padding: 7px 6px; position: relative; width: 100%; border-radius: 2px; -webkit-border-radius: 2px; -moz-border-radius: 2px; -moz-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05); -webkit-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05); box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05); }
input:focus.option-tree-ui-upload-input,
input:focus.option-tree-ui-input { border-color: #bbb !important; }
@media screen and (-webkit-min-device-pixel-ratio:0) {
.option-tree-ui-input,
.option-tree-ui-upload-input { padding: 5px 6px !important; }
}
/* --------------------------------------------------
:: Upload
---------------------------------------------------*/
div.option-tree-ui-media-wrap { margin: 5px 63px 0 0; min-height: 35px; position: relative; }
.option-tree-ui-media-wrap img { background: #fafafa; border: 1px solid #ccc; padding: 4px; border-radius: 2px; -webkit-border-radius: 2px; -moz-border-radius: 2px; display: block; float: left; max-width: 100%; height: auto; -ms-interpolation-mode: bicubic; }
.option-tree-ui-upload-parent { width: auto !important; margin-right: 53px; padding: 0px; position: relative; }
.format-setting .ot_upload_media { top: 0px; margin: 0px !important; position: absolute; right: -53px; }
.option-tree-ui-media-wrap a.option-tree-ui-remove-media { float: none !important; margin: 0px !important; position: absolute !important; right: -63px; top: 1px; }
/* --------------------------------------------------
:: Textarea
---------------------------------------------------*/
.fill-area .description,
.fill-area .format-setting-inner { width: 100% !important; }
.wp-editor-area { display: block;}
.textarea,
.ot-metabox-wrapper textarea { width: 99.9%; border: 1px solid #ccc; font-family: Consolas, Monaco, monospace; line-height: 150%; outline: 0; padding: 10px; resize: vertical; }
.ot-metabox-wrapper .wp-editor-container { border: none; }
.ot-metabox-wrapper textarea:focus { border-color: #bbb !important; }
@media only screen and (max-width: 1105px) { .type-textarea .description, .type-textarea .format-setting-inner { width: 100%; } }
/* --------------------------------------------------
:: Setting Item with Drag & Drop
---------------------------------------------------*/
.option-tree-setting-wrap { margin-top: 0px; }
.option-tree-setting-wrap li { margin: 4px 0px; }
.option-tree-setting { border: 1px solid #ccc; cursor: move; overflow: hidden; position: relative; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; }
.ui-state-disabled .option-tree-setting { cursor: default; }
.option-tree-setting a { text-decoration: none; }
.option-tree-setting .open { background: #fafafa; line-height: 21px; height: 21px; padding: 10px 100px 10px 10px; display: block; }
.option-tree-setting .open:hover { background: #fafafa url(../images/ot-dots.png) no-repeat 4px 15px; }
.button-section { position: absolute; right: 0px; top: 1px; }
.option-tree-setting.is-section .open { background: #e9f2fb; }
.option-tree-setting.is-section .open:hover { background: #e9f2fb url(../images/ot-dots.png) no-repeat 4px 15px; }
.format-setting .ui-sortable-helper
.option-tree-setting .open { background: #fff url(../images/ot-dots.png) no-repeat 4px 15px; }
.ui-state-highlight { border: 1px dashed #ccc; line-height: 21px; height: 21px; padding: 10px 0px; display: block; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
.option-tree-setting-body { background: #fff; border-top: 1px solid #ccc; display: none; padding: 10px; -webkit-border-bottom-right-radius: 3px; -webkit-border-bottom-left-radius: 3px; -moz-border-radius-bottomright: 3px; -moz-border-radius-bottomleft: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; }
li ul .format-settings { padding: 0 0 10px 0; }
li ul .format-setting-label { border: none; padding: 0px; margin: 0px; }
/* --------------------------------------------------
:: Layouts
---------------------------------------------------*/
#option_tree_layouts { display: none; padding-top: 12px; }
#option-tree-options-layouts-form { left: 13px; position: absolute; top: 40px; z-index: 100; }
.option-tree-save-layout { width: 250px; overflow: hidden; }
.option-tree-save-layout .widefat { float: left; width: 128px !important; }
.option-tree-save-layout button { margin: 0 0 0 10px; }
.option-tree-active-layout { }
/* --------------------------------------------------
:: Select
---------------------------------------------------*/
.select-group { margin-right: 53px; overflow: hidden; width: auto; }
.select-wrapper { background: #fff url(../images/ot-select.png) no-repeat right center; border: 1px solid #ccc; display: block; float: left; font-size: 12px; height: 27px; margin: 0 5px 5px 0; width: auto; border-radius: 2px; -webkit-border-radius: 2px; -moz-border-radius: 2px; -moz-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05); -webkit-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05); box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05); }
.select-wrapper:hover { background-image: url(../images/ot-select-hover.png); border-color: #bbb; }
select.option-tree-ui-select { cursor: pointer; filter: alpha(opacity: 0); font-size: 14px; height: 29px; margin: 0; -moz-opacity: 0; opacity: 0; padding: 0 !important; position: relative; width: inherit; z-index: 4; min-width: 118px; }
select.option-tree-ui-select option { padding: 3px 15px !important; }
.select-wrapper span { height: 27px; line-height: 27px; padding-left: 7px; position: absolute; z-index: 2; }
#option-tree-options-layouts-form .select-wrapper { left: 244px; position: absolute; top: 0; float: none; }
.type-measurement select.option-tree-ui-select { min-width: 68px !important; }
.type-measurement .select-wrapper { position: absolute; right: 0px; top: 0px; }
/* FireFox */
@-moz-document url-prefix() {
#option-tree-options-layouts-form .select-wrapper { left: 250px; }
}
/* Webkit */
@media screen and (-webkit-min-device-pixel-ratio:0) {
.select-wrapper span {
height: 26px;
line-height: 26px;
}
}
/* Opera 11 */
@media not screen and (1) {
.select-wrapper {
height: 26px;
}
}
/* --------------------------------------------------
:: Measurement
---------------------------------------------------*/
.option-tree-ui-measurement-input-wrap { margin-right: 80px; }
/* --------------------------------------------------
:: Checkbox & Radio
---------------------------------------------------*/
.format-setting.type-checkbox input,
.format-setting.type-radio input { float: left; margin: 2px 5px 0 1px; }
.format-setting.type-checkbox label,
.format-setting.type-radio label { float: left; max-width: 90%; padding: 0px; }
#option-tree-settings-api .format-setting.type-checkbox p,
#option-tree-settings-api .format-setting.type-radio p { float: left; margin: 0.5em 0 !important; width: 100%; }
/* --------------------------------------------------
:: Radio Images
---------------------------------------------------*/
.type-radio-image .option-tree-ui-radio-images { float: left; margin: 0 10px 10px 0px; }
.type-radio-image .option-tree-ui-radio-images img { background: #fff; border: 1px solid #ccc; cursor: pointer; padding: 5px; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; }
.type-radio-image .option-tree-ui-radio-images img.option-tree-ui-radio-image-selected,
.type-radio-image .option-tree-ui-radio-images img:hover { border-color: #464646; -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05); box-shadow:0 1px 3px rgba(0,0,0,0.05); }
/* --------------------------------------------------
:: Colorpicker
---------------------------------------------------*/
.option-tree-ui-colorpicker-input-wrap{ margin-right: 53px; position: relative; width: auto; }
.format-settings .cp_box { background: #f1f1f1; border: 1px solid #ccc; bottom: 5px; height: 27px; position: absolute; right: -53px; width: 46px; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; }
.colorpicker { width: 342px; height: 170px; overflow: hidden; position: absolute; background: #fafafa url(../images/colorpicker/color_bg.png); font-family: Arial, Helvetica, sans-serif; display: none; border: 1px solid #bbb; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05); box-shadow:0 1px 3px rgba(0,0,0,0.05); z-index: 100; }
.colorpicker_color { width: 150px; height: 150px; left: 10px; top: 10px; position: absolute; background: #f00; overflow: hidden; cursor: crosshair; }
.colorpicker_color div { position: absolute; top: 0; left: 0; width: 150px; height: 150px; background: url(../images/colorpicker/color_overlay.png); }
.colorpicker_color div div { position: absolute; top: 0; left: 0; width: 11px; height: 11px; overflow: hidden; background: url(../images/colorpicker/color_select.gif); margin: -5px 0 0 -5px; }
.colorpicker_hue { position: absolute; top: 10px; left: 164px; width: 35px; height: 150px; cursor: n-resize; }
.colorpicker_hue div { position: absolute; width: 35px; height: 9px; overflow: hidden; background: url(../images/colorpicker/color_indicator.png) left top; margin: -5px 0 0 0; }
.colorpicker_new_color { position: absolute; width: 60px; height: 30px; right: 80px; top: 10px; background: #f00; }
.colorpicker_current_color { position: absolute; width: 60px; height: 30px; right: 10px; top: 10px; background: #f00; }
.colorpicker input { background-color: transparent !important; border: 1px solid transparent !important; position: absolute !important; font-size: 10px !important; font-family: Arial, Helvetica, sans-serif !important; color: #666 !important; top: 0px !important; right: 12px !important; text-align: right !important; margin: 0 !important; padding: 0 !important; height: 22px !important;line-height: 22px !important; }
.colorpicker_hex { position: absolute; width: 72px; height: 22px; background: url(../images/colorpicker/color_hex.png) top; left: 201px; bottom: 9px; }
.colorpicker_hex input { left: 13px; height: 22px; line-height: 22px; padding: 10px; }
.colorpicker_field { height: 22px; width: 62px; background-position: top; position: absolute; }
.colorpicker_field span { position: absolute; width: 12px; height: 22px; overflow: hidden; top: 0; right: 0; cursor: n-resize; }
.colorpicker_rgb_r { background-image: url(../images/colorpicker/color_rgb_r.png); top: 49px; left: 201px; }
.colorpicker_rgb_g { background-image: url(../images/colorpicker/color_rgb_g.png); top: 79px; left: 201px; }
.colorpicker_rgb_b { background-image: url(../images/colorpicker/color_rgb_b.png); top: 109px; left: 201px; }
.colorpicker_hsb_h { background-image: url(../images/colorpicker/color_hsb_h.png); top: 49px; right: 9px; }
.colorpicker_hsb_s { background-image: url(../images/colorpicker/color_hsb_s.png); top: 79px; right: 9px }
.colorpicker_hsb_b { background-image: url(../images/colorpicker/color_hsb_b.png); top: 109px; right: 9px; }
.colorpicker_submit { position: absolute; width: 16px; height: 16px; background: url(../images/colorpicker/color_wheel.png) top; right: 10px; bottom: 10px; overflow: hidden; }
.colorpicker_focus { background-position: center; }
.colorpicker_hex.colorpicker_focus { background-position: bottom; }
.colorpicker_submit.colorpicker_focus { background-position: bottom; }
.colorpicker_slider { background-position: bottom; }
@media not screen and (1) {
.format-settings .cp_box { height: 26px; }
}
/* --------------------------------------------------
:: OptionTree UI Buttons
---------------------------------------------------*/
.option-tree-ui-buttons { background: #fff; border: 1px solid #ccc; margin: 11px 5px 0 2px; min-width: 523px; overflow: hidden; padding: 5px; position: relative; -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05); box-shadow:0 1px 3px rgba(0,0,0,0.05); -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
.option-tree-ui-buttons.alt { background: #f5f5f5; border-color: #dfdfdf;}
.option-tree-ui-buttons:before,
.option-tree-ui-buttons:after { content: "\0020"; display: block; height: 0; visibility: hidden; }
.option-tree-ui-buttons:after { clear: both; }
.option-tree-ui-buttons { zoom: 1; }
.option-tree-ui-button { background: #f5f5f5; border: 1px solid #ccc; color: #444; cursor: pointer; display: inline-block; float: left; font-size: 11px; font-weight: bold; height: 27px; line-height: 27px; margin: 5px; padding: 0px 14px; position: relative; text-align: center; text-decoration: none; text-shadow: 0 1px 0 rgba(255,255,255,0.7); background: -moz-linear-gradient(top, #f5f5f5 0%, #f1f1f1 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#f1f1f1)); background: -webkit-linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); background: -o-linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); background: -ms-linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); background: linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#f1f1f1',GradientType=0 ); -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; -webkit-transition: border-color .20s; -moz-transition: border-color .20s; -o-transition: border-color .20s; transition: border-color .20s; -webkit-user-select: none; z-index: 1; }
button.option-tree-ui-button { height: 29px; line-height: 11px; padding: 7px 14px 9px 14px; }
.option-tree-ui-button.right { float: right; }
.option-tree-ui-button.hug-left { margin-left: 0px; }
.option-tree-ui-button.hug-right { margin-right: 0px; }
.option-tree-ui-button.pad { padding: 0px 21px; }
.option-tree-ui-button.left-item { margin: 5px 0 5px 5px; -webkit-border-top-right-radius: 0px; -webkit-border-bottom-right-radius: 0px; -moz-border-radius-topright: 0px; -moz-border-radius-bottomright: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; }
.option-tree-ui-button.center-item { margin: 5px 0 5px -1px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; }
.option-tree-ui-button.right-item { margin: 5px 5px 5px -1px; -webkit-border-top-left-radius: 0px; -webkit-border-bottom-left-radius: 0px; -moz-border-radius-topleft: 0px; -moz-border-radius-bottomleft: 0px; border-top-left-radius: 0px; border-bottom-left-radius: 0px; }
.option-tree-ui-button:hover,
.option-tree-ui-button:focus { background: #f8f8f8; border-color: #c6c6c6; color: #333; background: -moz-linear-gradient(top, #f8f8f8 0%, #f1f1f1 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#f1f1f1)); background: -webkit-linear-gradient(top, #f8f8f8 0%,#f1f1f1 100%); background: -o-linear-gradient(top, #f8f8f8 0%,#f1f1f1 100%); background: -ms-linear-gradient(top, #f8f8f8 0%,#f1f1f1 100%); background: linear-gradient(top, #f8f8f8 0%,#f1f1f1 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8f8f8', endColorstr='#f1f1f1',GradientType=0 ); box-shadow: 0px 1px 1px rgba(0,0,0, 0.1); -moz-box-shadow: 0px 1px 1px rgba(0,0,0, 0.1); -webkit-box-shadow: 0px 1px 1px rgba(0,0,0, 0.1); z-index: 2; }
.option-tree-ui-button:active { box-shadow: inset 0px 0px 5px rgba(0,0,0, 0.1); -moz-box-shadow: inset 0px 0px 5px rgba(0,0,0, 0.1); -webkit-box-shadow: inset 0px 0px 5px rgba(0,0,0, 0.1); z-index: 3; }
.option-tree-ui-button.active,
.option-tree-ui-button.active:hover,
.option-tree-ui-button.active:active { background: #eee; border-color: #c6c6c6; cursor: default; background: -moz-linear-gradient(top, #eee 0%, #e5e5e5 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eee), color-stop(100%,#e5e5e5)); background: -webkit-linear-gradient(top, #eee 0%,#e5e5e5 100%); background: -o-linear-gradient(top, #eee 0%,#e5e5e5 100%); background: -ms-linear-gradient(top, #eee 0%,#e5e5e5 100%); background: linear-gradient(top, #eee 0%,#e5e5e5 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eee', endColorstr='#e5e5e5',GradientType=0 ); box-shadow: inset 0px 0px 5px rgba(0,0,0, 0.1); -moz-box-shadow: inset 0px 0px 5px rgba(0,0,0, 0.1); -webkit-box-shadow: inset 0px 0px 5px rgba(0,0,0, 0.1); z-index: 3; }
.option-tree-ui-button.disabled,
.option-tree-ui-button.disabled:hover,
.option-tree-ui-button.disabled:active{ background: #f5f5f5; border: 1px solid #dadada; color: #bbb; cursor: default; background: -moz-linear-gradient(top, #f5f5f5 0%, #f1f1f1 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#f1f1f1)); background: -webkit-linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); background: -o-linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); background: -ms-linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); background: linear-gradient(top, #f5f5f5 0%,#f1f1f1 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#f1f1f1',GradientType=0 ); box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; }
.option-tree-ui-button:focus { outline: none; }
button.reset-settings { position: relative; top: -45px; left: 8px; }
@media not screen and (1) {
.option-tree-ui-button { height: 26px; }
button.option-tree-ui-button { height: 28px !important; }
}
/* --------------------------------------------------
:: OptionTree UI Button Colors
---------------------------------------------------*/
/* Blue */
.option-tree-ui-button.blue { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,0.3); border-color: #0080f0; background: #2c95ff; background: -moz-linear-gradient(top, #2c95ff 0%, #288cef 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2c95ff), color-stop(100%,#288cef)); background: -webkit-linear-gradient(top, #2c95ff 0%,#288cef 100%); background: -o-linear-gradient(top, #2c95ff 0%,#288cef 100%); background: -ms-linear-gradient(top, #2c95ff 0%,#288cef 100%); background: linear-gradient(top, #2c95ff 0%,#288cef 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2c95ff', endColorstr='#288cef',GradientType=0 ); }
.option-tree-ui-button.blue:hover { border-color: #1260b9; background: #2d95ff; background: -moz-linear-gradient(top, #2d95ff 0%, #0081eb 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2d95ff), color-stop(100%,#0081eb)); background: -webkit-linear-gradient(top, #2d95ff 0%,#0081eb 100%); background: -o-linear-gradient(top, #2d95ff 0%,#0081eb 100%); background: -ms-linear-gradient(top, #2d95ff 0%,#0081eb 100%); background: linear-gradient(top, #2d95ff 0%,#0081eb 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d95ff', endColorstr='#0081eb',GradientType=0 ); }
.option-tree-ui-button.blue:active { border-color: #0083dd; }
/* Red */
.option-tree-ui-button.red { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,0.3); border-color: #d94d30; background: #e55033; background: -moz-linear-gradient(top, #e55033 0%, #d94d30 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e55033), color-stop(100%,#d94d30)); background: -webkit-linear-gradient(top, #e55033 0%,#d94d30 100%); background: -o-linear-gradient(top, #e55033 0%,#d94d30 100%); background: -ms-linear-gradient(top, #e55033 0%,#d94d30 100%); background: linear-gradient(top, #e55033 0%,#d94d30 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e55033', endColorstr='#d94d30',GradientType=0 ); }
.option-tree-ui-button.red:hover { border-color: #b72f11; background: #e65033; background: -moz-linear-gradient(top, #e65033 0%, #cc3d1f 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e65033), color-stop(100%,#cc3d1f)); background: -webkit-linear-gradient(top, #e65033 0%,#cc3d1f 100%); background: -o-linear-gradient(top, #e65033 0%,#cc3d1f 100%); background: -ms-linear-gradient(top, #e65033 0%,#cc3d1f 100%); background: linear-gradient(top, #e65033 0%,#cc3d1f 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e65033', endColorstr='#cc3d1f',GradientType=0 ); }
.option-tree-ui-button.red:active { border-color: #ce4925; }
/* Green */
.option-tree-ui-button.green { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,0.3); border-color: #29691d; background: #3c9300; background: -moz-linear-gradient(top, #3c9300 0%, #398a00 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#3c9300), color-stop(100%,#398a00)); background: -webkit-linear-gradient(top, #3c9300 0%,#398a00 100%); background: -o-linear-gradient(top, #3c9300 0%,#398a00 100%); background: -ms-linear-gradient(top, #3c9300 0%,#398a00 100%); background: linear-gradient(top, #3c9300 0%,#398a00 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3c9300', endColorstr='#398a00',GradientType=0 ); }
.option-tree-ui-button.green:hover { border-color: #275400; background: #3c9300; background: -moz-linear-gradient(top, #3c9300 0%, #347d00 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#3c9300), color-stop(100%,#347d00)); background: -webkit-linear-gradient(top, #3c9300 0%,#347d00 100%); background: -o-linear-gradient(top, #3c9300 0%,#347d00 100%); background: -ms-linear-gradient(top, #3c9300 0%,#347d00 100%); background: linear-gradient(top, #3c9300 0%,#347d00 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3c9300', endColorstr='#347d00',GradientType=0 ); }
.option-tree-ui-button.green:active { border-color: #2b7800; }
/* Grey */
.option-tree-ui-button.grey { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,1); border-color: #333; background: #555; background: -moz-linear-gradient(top, #555 0%, #444 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#555), color-stop(100%,#444)); background: -webkit-linear-gradient(top, #555 0%,#444 100%); background: -o-linear-gradient(top, #555 0%,#444 100%); background: -ms-linear-gradient(top, #555 0%,#444 100%); background: linear-gradient(top, #555 0%,#444 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#555', endColorstr='#444',GradientType=0 ); }
.option-tree-ui-button.grey:hover { border-color: #222; background: #444; background: -moz-linear-gradient(top, #444 0%, #333 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#444), color-stop(100%,#333)); background: -webkit-linear-gradient(top, #444 0%,#333 100%); background: -o-linear-gradient(top, #444 0%,#333 100%); background: -ms-linear-gradient(top, #444 0%,#333 100%); background: linear-gradient(top, #444 0%,#333 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#444', endColorstr='#333',GradientType=0 ); }
.option-tree-ui-button.grey:active { border-color: #111; }
/* All Active */
.option-tree-ui-button.blue:active,
.option-tree-ui-button.red:active,
.option-tree-ui-button.green:active,
.option-tree-ui-button.grey:active { box-shadow: inset 1px 1px 3px rgba(0,0,0, 0.2); -moz-box-shadow: inset 1px 1px 3px rgba(0,0,0, 0.2); -webkit-box-shadow: inset 1px 1px 3px rgba(0,0,0, 0.2); }
/* --------------------------------------------------
:: OptionTree UI Button Icons
---------------------------------------------------*/
.option-tree-ui-button .icon { background: url(../images/ot-ui-sprite.png) no-repeat; display: inline-block; float: left; height: 18px; margin-top: 4px; opacity: 0.65; overflow: hidden; text-indent: -9999px; width: 18px; }
button.option-tree-ui-button .icon { margin-top: -3px; }
.option-tree-ui-button.light .icon { background-image: url(../images/ot-ui-light-sprite.png); opacity: 0.9; }
.option-tree-ui-button.active .icon,
.option-tree-ui-button:hover .icon { opacity: 1; }
.option-tree-ui-button .icon.right-label { margin-right: 10px; }
.option-tree-ui-button .icon.left-label { margin-left: 10px; float: right; }
.option-tree-ui-button .upload { background-position: -0px -0px; }
.option-tree-ui-button .trash-can { background-position: -18px -0px; }
.option-tree-ui-button .pencil { background-position: -36px -0px; }
.option-tree-ui-button .check { background-position: -54px -0px; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 931 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,462 @@
/**
* Option Tree UI
*
* Dependencies: jQuery, jQuery UI, ColorPicker
*
* @author Derek Herman (derek@valendesigns.com)
*/
;(function($) {
OT_UI = {
processing: false,
init: function() {
this.init_hide_body();
this.init_sortable();
this.init_add();
this.init_edit();
this.init_remove();
this.init_edit_title()
this.init_edit_id();
this.init_activate_layout();
this.init_upload();
this.init_upload_remove();
this.init_tabs();
this.init_radio_image_select();
this.init_select_wrapper();
this.fix_upload_parent();
this.fix_colorpicker();
this.fix_textarea();
this.replicate_ajax();
this.reset_settings();
},
init_hide_body: function(elm,type) {
var css = '.option-tree-setting-body';
if ( type == 'parent' ) {
$(css).not( elm.parent().parent().children(css) ).hide();
} else if ( type == 'child' ) {
elm.closest('ul').find(css).not( elm.parent().parent().children(css) ).hide();
} else if ( type == 'child-add' ) {
elm.children().find(css).hide();
} else if ( type == 'toggle' ) {
elm.parent().parent().children(css).toggle();
} else {
$(css).hide();
}
},
init_remove_active: function(elm,type) {
var css = '.option-tree-setting-edit';
if ( type == 'parent' ) {
$(css).not(elm).removeClass('active');
} else if ( type == 'child' ) {
elm.closest('ul').find(css).not(elm).removeClass('active');
} else if ( type == 'child-add' ) {
elm.children().find(css).removeClass('active');
} else {
$(css).removeClass('active');
}
},
init_sortable: function() {
$('.option-tree-sortable').each( function() {
if ( $(this).children('li').length ) {
var elm = $(this);
elm.show();
elm.sortable({
items: 'li:not(.ui-state-disabled)',
placeholder: 'ui-state-highlight',
stop: function(evt, ui) {
setTimeout(
function(){
OT_UI.update_ids(elm);
},
200
)
}
});
elm.children('li').disableSelection();
elm.find('.option-tree-setting-body').bind('mousedown.ui-disableSelection selectstart.ui-disableSelection', function(e) {
e.stopImmediatePropagation();
});
}
});
},
init_add: function() {
$('.option-tree-section-add').live('click', function(e) {
e.preventDefault();
OT_UI.add(this,'section');
});
$('.option-tree-setting-add').live('click', function(e) {
e.preventDefault();
OT_UI.add(this,'setting');
});
$('.option-tree-help-add').live('click', function(e) {
e.preventDefault();
OT_UI.add(this,'contextual_help');
});
$('.option-tree-choice-add').live('click', function(e) {
e.preventDefault();
OT_UI.add(this,'choice');
});
$('.option-tree-list-item-add').live('click', function(e) {
e.preventDefault();
OT_UI.add(this,'list_item');
});
$('.option-tree-list-item-setting-add').live('click', function(e) {
e.preventDefault();
if ( $(this).parents('ul').parents('ul').hasClass('ui-sortable') ) {
alert(option_tree.setting_limit);
return false;
}
OT_UI.add(this,'list_item_setting');
});
},
init_edit: function() {
$('.option-tree-setting-edit').live('click', function(e) {
e.preventDefault();
if ( $(this).parents().hasClass('option-tree-setting-body') ) {
OT_UI.init_remove_active($(this),'child');
OT_UI.init_hide_body($(this),'child');
} else {
OT_UI.init_remove_active($(this),'parent');
OT_UI.init_hide_body($(this), 'parent');
}
$(this).toggleClass('active');
OT_UI.init_hide_body($(this), 'toggle');
});
},
init_remove: function() {
$('.option-tree-setting-remove').live('click', function(event) {
event.preventDefault();
if ( $(this).parents('li').hasClass('ui-state-disabled') ) {
alert(option_tree.remove_no);
return false;
}
var agree = confirm(option_tree.remove_agree);
if (agree) {
var list = $(this).parents('ul');
OT_UI.remove(this);
setTimeout( function() {
OT_UI.update_ids(list);
}, 200 );
}
return false;
});
},
init_edit_title: function() {
$('.option-tree-setting-title').live('keyup', function() {
OT_UI.edit_title(this);
});
},
init_edit_id: function() {
$('.section-id').live('keyup', function(){
OT_UI.update_id(this);
});
},
init_activate_layout: function() {
$('.option-tree-layout-activate').live('click', function() {
var active = $(this).parents('.option-tree-setting').find('.open').text();
$('.option-tree-layout-activate').removeClass('active');
$(this).toggleClass('active');
$('.active-layout-input').attr({'value':active});
});
$('#option-tree-options-layouts-form select').live('change', function() {
var agree = confirm(option_tree.activate_layout_agree);
if (agree) {
$('#option-tree-options-layouts-form').submit();
} else {
var active = $('#the_current_layout').attr('value');
$('#option-tree-options-layouts-form select option[value="' + active + '"]').attr({'selected':'selected'});
$('#option-tree-options-layouts-form select').prev('span').replaceWith('<span>' + active + '</span>');
}
});
},
add: function(elm,type) {
var self = this,
list = '',
list_class = '',
name = '',
post_id = 0,
get_option = '',
settings = '';
if ( type == 'contextual_help' ) {
list = $(elm).parent().find('ul:last');
list_class = 'list-contextual-help';
} else if ( type == 'choice' ) {
list = $(elm).parent().children('ul');
list_class = 'list-choice';
} else if ( type == 'list_item' ) {
list = $(elm).parent().children('ul');
list_class = 'list-sub-setting';
} else if ( type == 'list_item_setting' ) {
list = $(elm).parent().children('ul');
list_class = 'list-sub-setting';
} else {
list = $(elm).parent().find('ul:first');
list_class = ( type == 'section' ) ? 'list-section' : 'list-setting';
}
name = list.data('name');
post_id = list.data('id');
get_option = list.data('getOption');
settings = $('#'+name+'_settings_array').val();
if ( this.processing === false ) {
this.processing = true;
var count = parseInt(list.children('li').length);
$.ajax({
url: option_tree.ajax,
type: 'post',
data: {
action: 'add_' + type,
count: count,
name: name,
post_id: post_id,
get_option: get_option,
settings: settings,
type: type
},
complete: function( data ) {
if ( type == 'choice' || type == 'list_item_setting' ) {
OT_UI.init_remove_active(list,'child-add');
OT_UI.init_hide_body(list,'child-add');
} else {
OT_UI.init_remove_active();
OT_UI.init_hide_body();
}
list.append('<li class="ui-state-default ' + list_class + '">' + data.responseText + '</li>');
list.children().last().find('.option-tree-setting-edit').toggleClass('active');
list.children().last().find('.option-tree-setting-body').toggle();
list.children().last().find('.option-tree-setting-title').focus();
if ( type != 'contextual_help' ) {
OT_UI.update_ids(list);
}
setTimeout( function() {
OT_UI.init_sortable();
OT_UI.init_select_wrapper();
}, 500);
self.processing = false;
}
});
}
},
remove: function(e) {
$(e).parent().parent().parent('li').remove();
},
edit_title: function(e) {
if ( this.timer ) {
clearTimeout(e.timer);
}
this.timer = setTimeout( function() {
$(e).parent().parent().parent().parent().parent().children('.open').text(e.value);
}, 100);
return true;
},
update_id: function(e) {
if ( this.timer ) {
clearTimeout(e.timer);
}
this.timer = setTimeout( function() {
OT_UI.update_ids($(e).parents('ul'));
}, 100);
return true;
},
update_ids: function(list) {
var last_section, section, list_items = list.children('li');
list_items.each(function(index) {
if ( $(this).hasClass('list-section') ) {
section = $(this).find('.section-id').val().trim().toLowerCase().replace(/[^a-z0-9]/gi,'_');
if (!section) {
section = $(this).find('.section-title').val().trim().toLowerCase().replace(/[^a-z0-9]/gi,'_');
}
if (!section) {
section = last_section;
}
}
if ($(this).hasClass('list-setting') ) {
$(this).find('.hidden-section').attr({'value':section});
}
last_section = section;
});
},
init_upload: function() {
$('.ot_upload_media').live('click', function() {
var field_id = $(this).parent('.option-tree-ui-upload-parent').find('input').attr('id'),
post_id = $(this).attr('rel'),
backup = window.send_to_editor,
btnContent = '',
intval = window.setInterval(function() {
if ( $('#TB_iframeContent').attr('src').indexOf( "&field_id=" ) !== -1 ) {
$('#TB_iframeContent').contents().find('#tab-type_url').hide();
}
$('#TB_iframeContent').contents().find('.savesend .button').val(option_tree.upload_text);
}, 50);
tb_show('', 'media-upload.php?post_id='+post_id+'&field_id='+field_id+'&type=image&TB_iframe=1');
window.send_to_editor = function(html) {
var href = $(html).attr('href');
var image = /\.(?:jpe?g|png|gif|ico)$/i;
if (OT_UI.url_exists(href)) {
if (href.match(image)) {
btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+href+'" alt="" /></div>';
}
btnContent += '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button" title="'+option_tree.remove_media_text+'"><span class="icon trash-can">'+option_tree.remove_media_text+'</span></a>';
}
$('#'+field_id).val(href);
$('#'+field_id+'_media').remove();
$('#'+field_id).parent().parent('div').append('<div class="option-tree-ui-media-wrap" id="'+field_id+'_media" />');
$('#'+field_id+'_media').append(btnContent).slideDown();
OT_UI.fix_upload_parent();
tb_remove();
window.clearInterval(intval);
window.send_to_editor = backup;
};
return false;
});
},
init_upload_remove: function() {
$('.option-tree-ui-remove-media').live('click', function(event) {
event.preventDefault();
var agree = confirm(option_tree.remove_agree);
if (agree) {
OT_UI.remove_image(this);
return false;
}
return false;
});
},
init_upload_fix: function(elm) {
var id = $(elm).attr('id'),
val = $(elm).val(),
img = $(elm).parent().next('option-tree-ui-media-wrap').find('img'),
src = img.attr('src'),
btnContent = '';
if ( val != src ) {
img.attr('src', val);
}
if ( val !== '' && ( typeof src == 'undefined' || src == false ) && OT_UI.url_exists(val) ) {
var image = /\.(?:jpe?g|png|gif|ico)$/i;
if (val.match(image)) {
btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+val+'" alt="" /></div>';
}
btnContent += '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button" title="'+option_tree.remove_media_text+'"><span class="icon trash-can">'+option_tree.remove_media_text+'</span></a>';
$('#'+id).val(val);
$('#'+id+'_media').remove();
$('#'+id).parent().parent('div').append('<div class="option-tree-ui-media-wrap" id="'+id+'_media" />');
$('#'+id+'_media').append(btnContent).slideDown();
} else if ( val == '' || ! OT_UI.url_exists(val) ) {
$(elm).parent().next('.option-tree-ui-media-wrap').remove();
}
},
init_tabs: function() {
$(".wrap.settings-wrap .ui-tabs").tabs({
fx: {
opacity: "toggle",
duration: "fast"
}
}).bind("tabsselect", function(event, ui) {
$("input[name=\'_wp_http_referer\']").val(ui.tab);
});
},
init_radio_image_select: function() {
$('.option-tree-ui-radio-image').live('click', function() {
$('.option-tree-ui-radio-image').removeClass('option-tree-ui-radio-image-selected');
$(this).toggleClass('option-tree-ui-radio-image-selected');
$(this).parent().find('.option-tree-ui-radio').attr('checked', true);
});
},
init_select_wrapper: function() {
$('.option-tree-ui-select').each(function () {
if ( ! $(this).parent().hasClass('select-wrapper') ) {
$(this).wrap('<div class="select-wrapper" />');
$(this).parent('.select-wrapper.').prepend('<span>' + $(this).find('option:selected').text() + '</span>');
}
});
$('.option-tree-ui-select').live('change', function () {
$(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>');
});
$('.option-tree-ui-select').bind($.browser.msie ? 'click' : 'change', function(event) {
$(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>');
});
},
bind_colorpicker: function(field_id) {
$('#'+field_id).ColorPicker({
onSubmit: function(hsb, hex, rgb) {
$('#'+field_id).val('#'+hex);
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
return false;
},
onChange: function (hsb, hex, rgb) {
var bc = $.inArray(hex, [ 'FFFFFF', 'FFF', 'ffffff', 'fff' ]) != -1 ? 'ccc' : hex;
$('#cp_'+field_id).css({'backgroundColor':'#'+hex,'borderColor':'#'+bc});
$('#cp_'+field_id).prev('input').attr('value', '#'+hex);
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
},
fix_upload_parent: function() {
$('.option-tree-ui-upload-input').live('focus blur', function(){
$(this).parent('.option-tree-ui-upload-parent').toggleClass('focus');
OT_UI.init_upload_fix(this);
});
},
remove_image: function(e) {
$(e).parent().parent().find('.option-tree-ui-upload-input').attr('value','');
$(e).parent('.option-tree-ui-media-wrap').remove();
},
fix_colorpicker: function() {
$('.cp_input').live('blur', function() {
$('.cp_input').each( function(index, el) {
var val = $(el).val();
var reg = /^[A-Fa-f0-9]{6}$/;
if( reg.test(val) && val != '' ) {
$(el).attr('value', '#'+val)
} else if ( val == '' ) {
$(this).next('.cp_box').css({'background':'#f1f1f1','border-color':'#ccc'});
}
});
});
},
fix_textarea: function() {
$('.wp-editor-area').focus( function(){
$(this).parent('div').css({borderColor:'#bbb'});
}).blur( function(){
$(this).parent('div').css({borderColor:'#ccc'});
});
},
replicate_ajax: function() {
if (location.href.indexOf("#") != -1) {
var url = $("input[name=\'_wp_http_referer\']").val(),
hash = location.href.substr(location.href.indexOf("#"));
$("input[name=\'_wp_http_referer\']").val( url + hash );
this.scroll_to_top();
}
setTimeout( function() {
$(".wrap.settings-wrap .fade").fadeOut("fast");
}, 3000 );
},
reset_settings: function() {
$(".reset-settings").live("click", function(event){
var agree = confirm(option_tree.reset_agree);
if (agree) {
return true;
} else {
return false;
}
event.preventDefault();
});
},
url_exists: function(url) {
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status!=404;
},
scroll_to_top: function() {
setTimeout( function() {
$(this).scrollTop(0);
}, 50 );
}
};
$(document).ready( function() {
OT_UI.init();
});
})(jQuery);

View File

@ -0,0 +1,453 @@
/**
* Color picker
* Author: Stefan Petre www.eyecon.ro
*
* Dependencies: jQuery
*/
(function ($) {
var ColorPicker = function () {
var
ids = {},
inAction,
charMin = 65,
visible,
tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
defaults = {
eventName: 'click',
onShow: function () {},
onBeforeShow: function(){},
onHide: function () {},
onChange: function () {},
onSubmit: function () {},
color: 'ff0000',
livePreview: true,
flat: false
},
fillRGBFields = function (hsb, cal) {
var rgb = HSBToRGB(hsb);
$(cal).data('colorpicker').fields
.eq(1).val(rgb.r).end()
.eq(2).val(rgb.g).end()
.eq(3).val(rgb.b).end();
},
fillHSBFields = function (hsb, cal) {
$(cal).data('colorpicker').fields
.eq(4).val(hsb.h).end()
.eq(5).val(hsb.s).end()
.eq(6).val(hsb.b).end();
},
fillHexFields = function (hsb, cal) {
$(cal).data('colorpicker').fields
.eq(0).val(HSBToHex(hsb)).end();
},
setSelector = function (hsb, cal) {
$(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
$(cal).data('colorpicker').selectorIndic.css({
left: parseInt(150 * hsb.s/100, 10),
top: parseInt(150 * (100-hsb.b)/100, 10)
});
},
setHue = function (hsb, cal) {
$(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
},
setCurrentColor = function (hsb, cal) {
$(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
},
setNewColor = function (hsb, cal) {
$(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
},
keyDown = function (ev) {
var pressedKey = ev.charCode || ev.keyCode || -1;
if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
return false;
}
var cal = $(this).parent().parent();
if (cal.data('colorpicker').livePreview === true) {
change.apply(this);
}
},
change = function (ev) {
var cal = $(this).parent().parent(), col;
if (this.parentNode.className.indexOf('_hex') > 0) {
cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
cal.data('colorpicker').color = col = fixHSB({
h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
});
} else {
cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
}));
}
if (ev) {
fillRGBFields(col, cal.get(0));
fillHexFields(col, cal.get(0));
fillHSBFields(col, cal.get(0));
}
setSelector(col, cal.get(0));
setHue(col, cal.get(0));
setNewColor(col, cal.get(0));
cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
},
blur = function (ev) {
var cal = $(this).parent().parent();
cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus')
},
focus = function () {
charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
$(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
$(this).parent().addClass('colorpicker_focus');
},
downIncrement = function (ev) {
var field = $(this).parent().find('input').focus();
var current = {
el: $(this).parent().addClass('colorpicker_slider'),
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
y: ev.pageY,
field: field,
val: parseInt(field.val(), 10),
preview: $(this).parent().parent().data('colorpicker').livePreview
};
$(document).bind('mouseup', current, upIncrement);
$(document).bind('mousemove', current, moveIncrement);
},
moveIncrement = function (ev) {
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
if (ev.data.preview) {
change.apply(ev.data.field.get(0), [true]);
}
return false;
},
upIncrement = function (ev) {
change.apply(ev.data.field.get(0), [true]);
ev.data.el.removeClass('colorpicker_slider').find('input').focus();
$(document).unbind('mouseup', upIncrement);
$(document).unbind('mousemove', moveIncrement);
return false;
},
downHue = function (ev) {
var current = {
cal: $(this).parent(),
y: $(this).offset().top
};
current.preview = current.cal.data('colorpicker').livePreview;
$(document).bind('mouseup', current, upHue);
$(document).bind('mousemove', current, moveHue);
},
moveHue = function (ev) {
change.apply(
ev.data.cal.data('colorpicker')
.fields
.eq(4)
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
.get(0),
[ev.data.preview]
);
return false;
},
upHue = function (ev) {
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
$(document).unbind('mouseup', upHue);
$(document).unbind('mousemove', moveHue);
return false;
},
downSelector = function (ev) {
var current = {
cal: $(this).parent(),
pos: $(this).offset()
};
current.preview = current.cal.data('colorpicker').livePreview;
$(document).bind('mouseup', current, upSelector);
$(document).bind('mousemove', current, moveSelector);
},
moveSelector = function (ev) {
change.apply(
ev.data.cal.data('colorpicker')
.fields
.eq(6)
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
.end()
.eq(5)
.val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
.get(0),
[ev.data.preview]
);
return false;
},
upSelector = function (ev) {
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
$(document).unbind('mouseup', upSelector);
$(document).unbind('mousemove', moveSelector);
return false;
},
enterSubmit = function (ev) {
$(this).addClass('colorpicker_focus');
},
leaveSubmit = function (ev) {
$(this).removeClass('colorpicker_focus');
},
clickSubmit = function (ev) {
var cal = $(this).parent();
var col = cal.data('colorpicker').color;
cal.data('colorpicker').origColor = col;
setCurrentColor(col, cal.get(0));
cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col));
cal.hide();
},
show = function (ev) {
var cal = $('#' + $(this).data('colorpickerId'));
cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
var pos = $(this).offset();
var viewPort = getViewport();
var top = pos.top + this.offsetHeight;
var left = pos.left;
if (top + 176 > viewPort.t + viewPort.h) {
top -= this.offsetHeight + 176;
} else {
top += 5;
}
if (left + 356 > viewPort.l + viewPort.w) {
left -= 356;
}
cal.css({left: left + 'px', top: top + 'px'});
if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
cal.show();
}
$(document).bind('mousedown', {cal: cal}, hide);
return false;
},
hide = function (ev) {
if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
ev.data.cal.hide();
}
$(document).unbind('mousedown', hide);
}
},
isChildOf = function(parentEl, el, container) {
if (parentEl == el) {
return true;
}
if (parentEl.contains) {
return parentEl.contains(el);
}
if ( parentEl.compareDocumentPosition ) {
return !!(parentEl.compareDocumentPosition(el) & 16);
}
var prEl = el.parentNode;
while(prEl && prEl != container) {
if (prEl == parentEl)
return true;
prEl = prEl.parentNode;
}
return false;
},
getViewport = function () {
var m = document.compatMode == 'CSS1Compat';
return {
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
};
},
fixHSB = function (hsb) {
return {
h: Math.min(360, Math.max(0, hsb.h)),
s: Math.min(100, Math.max(0, hsb.s)),
b: Math.min(100, Math.max(0, hsb.b))
};
},
fixRGB = function (rgb) {
return {
r: Math.min(255, Math.max(0, rgb.r)),
g: Math.min(255, Math.max(0, rgb.g)),
b: Math.min(255, Math.max(0, rgb.b))
};
},
fixHex = function (hex) {
var len = 6 - hex.length;
if (len > 0) {
var o = [];
for (var i=0; i<len; i++) {
o.push('0');
}
o.push(hex);
hex = o.join('');
}
return hex;
},
HexToRGB = function (hex) {
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
},
HexToHSB = function (hex) {
return RGBToHSB(HexToRGB(hex));
},
RGBToHSB = function (rgb) {
var hsb = {};
hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b);
hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b);
hsb.b = Math.round((hsb.b /255)*100);
if((rgb.r==rgb.g) && (rgb.g==rgb.b)) hsb.h = 0;
else if(rgb.r>=rgb.g && rgb.g>=rgb.b) hsb.h = 60*(rgb.g-rgb.b)/(rgb.r-rgb.b);
else if(rgb.g>=rgb.r && rgb.r>=rgb.b) hsb.h = 60 + 60*(rgb.g-rgb.r)/(rgb.g-rgb.b);
else if(rgb.g>=rgb.b && rgb.b>=rgb.r) hsb.h = 120 + 60*(rgb.b-rgb.r)/(rgb.g-rgb.r);
else if(rgb.b>=rgb.g && rgb.g>=rgb.r) hsb.h = 180 + 60*(rgb.b-rgb.g)/(rgb.b-rgb.r);
else if(rgb.b>=rgb.r && rgb.r>=rgb.g) hsb.h = 240 + 60*(rgb.r-rgb.g)/(rgb.b-rgb.g);
else if(rgb.r>=rgb.b && rgb.b>=rgb.g) hsb.h = 300 + 60*(rgb.r-rgb.b)/(rgb.r-rgb.g);
else hsb.h = 0;
hsb.h = Math.round(hsb.h);
return hsb;
},
HSBToRGB = function (hsb) {
var rgb = {};
var h = Math.round(hsb.h);
var s = Math.round(hsb.s*255/100);
var v = Math.round(hsb.b*255/100);
if(s == 0) {
rgb.r = rgb.g = rgb.b = v;
} else {
var t1 = v;
var t2 = (255-s)*v/255;
var t3 = (t1-t2)*(h%60)/60;
if(h==360) h = 0;
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
else {rgb.r=0; rgb.g=0; rgb.b=0}
}
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
},
RGBToHex = function (rgb) {
var hex = [
rgb.r.toString(16),
rgb.g.toString(16),
rgb.b.toString(16)
];
$.each(hex, function (nr, val) {
if (val.length == 1) {
hex[nr] = '0' + val;
}
});
return hex.join('');
},
HSBToHex = function (hsb) {
return RGBToHex(HSBToRGB(hsb));
};
return {
init: function (options) {
options = $.extend({}, defaults, options||{});
if (typeof options.color == 'string') {
options.color = HexToHSB(options.color);
} else if (options.color.r != undefined && options.color.g != undefined && options.color.b != undefined) {
options.color = RGBToHSB(options.color);
} else if (options.color.h != undefined && options.color.s != undefined && options.color.b != undefined) {
options.color = fixHSB(options.color);
} else {
return this;
}
options.origColor = options.color;
return this.each(function () {
if (!$(this).data('colorpickerId')) {
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
$(this).data('colorpickerId', id);
var cal = $(tpl).attr('id', id);
if (options.flat) {
cal.appendTo(this).show();
} else {
cal.appendTo(document.body);
}
options.fields = cal
.find('input')
.bind('keydown', keyDown)
.bind('change', change)
.bind('blur', blur)
.bind('focus', focus);
cal.find('span').bind('mousedown', downIncrement);
options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
options.selectorIndic = options.selector.find('div div');
options.hue = cal.find('div.colorpicker_hue div');
cal.find('div.colorpicker_hue').bind('mousedown', downHue);
options.newColor = cal.find('div.colorpicker_new_color');
options.currentColor = cal.find('div.colorpicker_current_color');
cal.data('colorpicker', options);
cal.find('div.colorpicker_submit')
.bind('mouseenter', enterSubmit)
.bind('mouseleave', leaveSubmit)
.bind('click', clickSubmit);
fillRGBFields(options.color, cal.get(0));
fillHSBFields(options.color, cal.get(0));
fillHexFields(options.color, cal.get(0));
setHue(options.color, cal.get(0));
setSelector(options.color, cal.get(0));
setCurrentColor(options.color, cal.get(0));
setNewColor(options.color, cal.get(0));
if (options.flat) {
cal.css({
position: 'relative',
display: 'block'
});
} else {
$(this).bind(options.eventName, show);
}
}
});
},
showPicker: function() {
return this.each( function () {
if ($(this).data('colorpickerId')) {
show.apply(this);
}
});
},
hidePicker: function() {
return this.each( function () {
if ($(this).data('colorpickerId')) {
$('#' + $(this).data('colorpickerId')).hide();
}
});
},
setColor: function(col) {
if (typeof col == 'string') {
col = HexToHSB(col);
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
col = RGBToHSB(col);
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
col = fixHSB(col);
} else {
return this;
}
return this.each(function(){
if ($(this).data('colorpickerId')) {
var cal = $('#' + $(this).data('colorpickerId'));
cal.data('colorpicker').color = col;
cal.data('colorpicker').origColor = col;
fillRGBFields(col, cal.get(0));
fillHSBFields(col, cal.get(0));
fillHexFields(col, cal.get(0));
setHue(col, cal.get(0));
setSelector(col, cal.get(0));
setCurrentColor(col, cal.get(0));
setNewColor(col, cal.get(0));
}
});
}
};
}();
$.fn.extend({
ColorPicker: ColorPicker.init,
ColorPickerHide: ColorPicker.hide,
ColorPickerShow: ColorPicker.show,
ColorPickerSetColor: ColorPicker.setColor
});
})(jQuery);

View File

@ -0,0 +1,63 @@
<?php
/**
* Initialize the meta boxes.
*/
add_action( 'admin_init', '_custom_meta_boxes' );
/**
* Meta Boxes demo code.
*
* You can find all the available option types
* in demo-theme-options.php.
*
* @return void
*
* @access private
* @since 2.0
*/
function _custom_meta_boxes() {
/**
* Create a custom meta boxes array that we pass to
* the OptionTree Meta Box API Class.
*/
$my_meta_box = array(
'id' => 'my_meta_box',
'title' => 'Demo Meta Box',
'desc' => '',
'pages' => array( 'post' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'label' => 'Background',
'id' => 'my_background',
'type' => 'background',
'desc' => 'BlahLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Category Checkbox',
'id' => 'my_category_checkbox',
'type' => 'category-checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
)
)
);
/**
* Register our meta boxes using the
* ot_register_meta_box() function.
*/
ot_register_meta_box( $my_meta_box );
}

View File

@ -0,0 +1,473 @@
<?php
/**
* Initialize the options before anything else.
*/
add_action( 'admin_init', '_custom_theme_options', 1 );
/**
* Theme Mode demo code of all the available option types.
*
* @return void
*
* @access private
* @since 2.0
*/
function _custom_theme_options() {
/**
* Get a copy of the saved settings array.
*/
$saved_settings = get_option( 'option_tree_settings', array() );
/**
* Create a custom settings array that we pass to
* the OptionTree Settings API Class.
*/
$custom_settings = array(
'contextual_help' => array(
'content' => array(
array(
'id' => 'general_help',
'title' => 'General',
'content' => '<p>Help content goes here!</p>'
)
),
'sidebar' => '<p>Sidebar content goes here!</p>'
),
'sections' => array(
array(
'title' => 'General',
'id' => 'general_default'
),
array(
'title' => 'Miscellaneous ',
'id' => 'miscellaneous'
)
),
'settings' => array(
array(
'label' => 'Background',
'id' => 'my_background',
'type' => 'background',
'desc' => 'BlahLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Category Checkbox',
'id' => 'my_category_checkbox',
'type' => 'category-checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Category Select',
'id' => 'my_category_select',
'type' => 'category-select',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Checkbox',
'id' => 'my_checkbox',
'type' => 'checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'choices' => array(
array (
'label' => 'Yes',
'value' => 'Yes'
)
),
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Colorpicker',
'id' => 'my_colorpicker',
'type' => 'colorpicker',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'CSS',
'id' => 'my_css',
'type' => 'css',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '20',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Custom Post Type Checkbox',
'id' => 'my_custom_post_type_checkbox',
'type' => 'custom-post-type-checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => 'post',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Custom Post Type Select',
'id' => 'my_custom_post_type_select',
'type' => 'custom-post-type-select',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => 'post',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'List Item',
'id' => 'my_list_item',
'type' => 'list-item',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'settings' => array(
array(
'label' => 'Upload',
'id' => 'my_list_item_upload',
'type' => 'upload',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Text',
'id' => 'my_list_item_text',
'type' => 'text',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => ''
),
array(
'label' => 'Textarea Simple',
'id' => 'my_list_item_textarea_simple',
'type' => 'textarea-simple',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '10',
'post_type' => '',
'taxonomy' => '',
'class' => ''
)
),
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Measurement',
'id' => 'my_measurement',
'type' => 'measurement',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Page Checkbox',
'id' => 'my_page_checkbox',
'type' => 'page-checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Page Select',
'id' => 'my_page_select',
'type' => 'page-select',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Post Checkbox',
'id' => 'my_post_checkbox',
'type' => 'post-checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Post Select',
'id' => 'my_post_select',
'type' => 'post-select',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'general_default'
),
array(
'label' => 'Radio',
'id' => 'my_radio',
'type' => 'radio',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'choices' => array(
array(
'label' => 'Yes',
'value' => 'yes'
),
array(
'label' => 'No',
'value' => 'no'
),
array(
'label' => 'Maybe',
'value' => 'maybe'
)
),
'std' => 'yes',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Radio Image',
'id' => 'my_radio_image',
'type' => 'radio-image',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => 'right-sidebar',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Select',
'id' => 'my_select',
'type' => 'select',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'choices' => array(
array(
'label' => 'Yes',
'value' => 'yes'
),
array(
'label' => 'No',
'value' => 'no'
),
array(
'label' => 'Maybe',
'value' => 'maybe'
)
),
'std' => 'maybe',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Slider',
'id' => 'my_slider',
'type' => 'slider',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Tag Checkbox',
'id' => 'my_tag_checkbox',
'type' => 'tag-checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Tag Select',
'id' => 'my_tag_select',
'type' => 'tag-select',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Taxonomy Checkbox',
'id' => 'my_taxonomy_checkbox',
'type' => 'taxonomy-checkbox',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => 'category,post_tag',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Taxonomy Select',
'id' => 'my_taxonomy_select',
'type' => 'taxonomy-select',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => 'category,post_tag',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Text',
'id' => 'my_text',
'type' => 'text',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Textarea',
'id' => 'my_textarea',
'type' => 'textarea',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '15',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Textarea Simple',
'id' => 'my_textarea_simple',
'type' => 'textarea-simple',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '10',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Textblock',
'id' => 'my_textblock',
'type' => 'textblock',
'desc' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Textblock Titled',
'id' => 'my_textblock_titled',
'type' => 'textblock-titled',
'desc' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Typography',
'id' => 'my_typography',
'type' => 'typography',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
),
array(
'label' => 'Upload',
'id' => 'my_upload',
'type' => 'upload',
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'std' => '',
'rows' => '',
'post_type' => '',
'taxonomy' => '',
'class' => '',
'section' => 'miscellaneous'
)
)
);
/* settings are not the same update the DB */
if ( $saved_settings !== $custom_settings ) {
update_option( 'option_tree_settings', $custom_settings );
}
}

View File

@ -0,0 +1,336 @@
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
/**
* Compatibility Functions.
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
* @since 2.0
*/
/* run the actions & filters */
add_action( 'admin_init', 'compat_ot_import_from_files', 1 );
add_filter( 'ot_option_types_array', 'compat_ot_option_types_array', 10, 1 );
add_filter( 'ot_recognized_font_styles', 'compat_ot_recognized_font_styles', 10, 2 );
add_filter( 'ot_recognized_font_weights', 'compat_ot_recognized_font_weights', 10, 2 );
add_filter( 'ot_recognized_font_variants', 'compat_ot_recognized_font_variants', 10, 2 );
add_filter( 'ot_recognized_font_families', 'compat_ot_recognized_font_families', 10, 2 );
add_filter( 'ot_recognized_background_repeat', 'compat_ot_recognized_background_repeat', 10, 2 );
add_filter( 'ot_recognized_background_position', 'compat_ot_recognized_background_position', 10, 2 );
add_filter( 'ot_measurement_unit_types', 'compat_ot_measurement_unit_types', 10, 2 );
/**
* Import from the old 1.x files for backwards compatibility.
*
* @return void
*
* @access private
* @since 2.0.8
*/
if ( ! function_exists( 'compat_ot_import_from_files' ) ) {
function compat_ot_import_from_files() {
/* file path & name without extention */
$ot_xml = '/option-tree/theme-options.xml';
$ot_data = '/option-tree/theme-options.txt';
$ot_layout = '/option-tree/layouts.txt';
/* XML file path - child theme first then parent */
$xml_file = get_stylesheet_directory() . $ot_xml;
if ( ! is_readable( $xml_file ) )
$xml_file = get_template_directory() . $ot_xml;
/* Data file path - child theme first then parent */
$data_file = get_stylesheet_directory() . $ot_data;
if ( ! is_readable( $data_file ) )
$data_file = get_template_directory() . $ot_data;
/* Layout file path - child theme first then parent */
$layout_file = get_stylesheet_directory() . $ot_layout;
if ( ! is_readable( $layout_file ) )
$layout_file = get_template_directory() . $ot_layout;
/* check for files */
$has_xml = ( is_readable( $xml_file ) ) ? true : false;
$has_data = ( is_readable( $data_file ) ) ? true : false;
$has_layout = ( is_readable( $layout_file ) ) ? true : false;
/* auto import XML file */
if ( $has_xml == true && ! get_option( 'option_tree_settings' ) && class_exists( 'SimpleXMLElement' ) && function_exists( 'file_get_contents' ) ) {
$settings = ot_import_xml( $xml_file );
if ( isset( $settings ) && ! empty( $settings ) ) {
update_option( 'option_tree_settings', $settings );
}
}
/* auto import Data file */
if ( $has_data == true && ! get_option( 'option_tree' ) && function_exists( 'file_get_contents' ) ) {
$rawdata = @file_get_contents( $data_file );
$options = unserialize( base64_decode( $rawdata ) );
/* get settings array */
$settings = get_option( 'option_tree_settings' );
/* has options */
if ( is_array( $options ) ) {
/* validate options */
if ( is_array( $settings ) ) {
foreach( $settings['settings'] as $setting ) {
if ( isset( $options[$setting['id']] ) ) {
$content = ot_stripslashes( $options[$setting['id']] );
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
}
}
}
/* update the option tree array */
update_option( 'option_tree', $options );
}
}
/* auto import Layout file */
if ( $has_layout == true && ! get_option( 'option_tree_layouts' ) && function_exists( 'file_get_contents' ) ) {
$rawdata = @file_get_contents( $layout_file );
$layouts = unserialize( base64_decode( $rawdata ) );
/* get settings array */
$settings = get_option( 'option_tree_settings' );
/* has layouts */
if ( is_array( $layouts ) ) {
/* validate options */
if ( is_array( $settings ) ) {
foreach( $layouts as $key => $value ) {
if ( $key == 'active_layout' )
continue;
$options = unserialize( base64_decode( $value ) );
foreach( $settings['settings'] as $setting ) {
if ( isset( $options[$setting['id']] ) ) {
$content = ot_stripslashes( $options[$setting['id']] );
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
}
}
$layouts[$key] = base64_encode( serialize( $options ) );
}
}
/* update the option tree array */
if ( isset( $layouts['active_layout'] ) ) {
update_option( 'option_tree', unserialize( base64_decode( $layouts[$layouts['active_layout']] ) ) );
}
/* update the option tree layouts array */
update_option( 'option_tree_layouts', $layouts );
}
}
}
}
/**
* Filters the option types array.
*
* Allows the old 'option_tree_option_types' filter to
* change the new 'ot_option_types_array' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_option_types_array' ) ) {
function compat_ot_option_types_array( $array ) {
return apply_filters( 'option_tree_option_types', $array );
}
}
/**
* Filters the recognized font styles array.
*
* Allows the old 'recognized_font_styles' filter to
* change the new 'ot_recognized_font_styles' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_recognized_font_styles' ) ) {
function compat_ot_recognized_font_styles( $array, $id ) {
return apply_filters( 'recognized_font_styles', $array, $id );
}
}
/**
* Filters the recognized font weights array.
*
* Allows the old 'recognized_font_weights' filter to
* change the new 'ot_recognized_font_weights' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_recognized_font_weights' ) ) {
function compat_ot_recognized_font_weights( $array, $id ) {
return apply_filters( 'recognized_font_weights', $array, $id );
}
}
/**
* Filters the recognized font variants array.
*
* Allows the old 'recognized_font_variants' filter to
* change the new 'ot_recognized_font_variants' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_recognized_font_variants' ) ) {
function compat_ot_recognized_font_variants( $array, $id ) {
return apply_filters( 'recognized_font_variants', $array, $id );
}
}
/**
* Filters the recognized font families array.
*
* Allows the old 'recognized_font_families' filter to
* change the new 'ot_recognized_font_families' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_recognized_font_families' ) ) {
function compat_ot_recognized_font_families( $array, $id ) {
return apply_filters( 'recognized_font_families', $array, $id );
}
}
/**
* Filters the recognized background repeat array.
*
* Allows the old 'recognized_background_repeat' filter to
* change the new 'ot_recognized_background_repeat' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_recognized_background_repeat' ) ) {
function compat_ot_recognized_background_repeat( $array, $id ) {
return apply_filters( 'recognized_background_repeat', $array, $id );
}
}
/**
* Filters the recognized background position array.
*
* Allows the old 'recognized_background_position' filter to
* change the new 'ot_recognized_background_position' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_recognized_background_position' ) ) {
function compat_ot_recognized_background_position( $array, $id ) {
return apply_filters( 'recognized_background_position', $array, $id );
}
}
/**
* Filters the measurement unit types array.
*
* Allows the old 'measurement_unit_types' filter to
* change the new 'ot_measurement_unit_types' return value.
*
* @return array
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'compat_ot_measurement_unit_types' ) ) {
function compat_ot_measurement_unit_types( $array, $id ) {
return apply_filters( 'measurement_unit_types', $array, $id );
}
}
/* End of file ot-functions-compat.php */
/* Location: ./includes/ot-functions-compat.php */

View File

@ -0,0 +1,99 @@
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
/**
* OptionTree deprecated functions
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
* @since 2.0
*/
/**
* Displays or returns a value from the 'option_tree' array.
*
* @param string $item_id
* @param array $options
* @param bool $echo
* @param bool $is_array
* @param int $offset
* @return mixed array or comma seperated lists of values
*
* @access public
* @since 1.0.0
* @updated 2.0
* @deprecated 2.0
*/
if ( ! function_exists( 'get_option_tree' ) ) {
function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1 ) {
/* load saved options */
if ( ! $options )
$options = get_option( 'option_tree' );
/* no value return */
if ( ! isset( $options[$item_id] ) || empty( $options[$item_id] ) )
return;
/* set content value & strip slashes */
$content = option_tree_stripslashes( $options[$item_id] );
/* is an array */
if ( $is_array == true ) {
/* saved as a comma seperated lists of values, explode into an array */
if ( !is_array( $content ) )
$content = explode( ',', $content );
/* get an array value using an offset */
if ( is_numeric( $offset ) && $offset >= 0 ) {
$content = $content[$offset];
} else if ( ! is_numeric( $offset ) && isset( $content[$offset] ) ) {
$content = $content[$offset];
}
/* not an array */
} else if ( $is_array == false ) {
/* saved as array, implode and return a comma seperated lists of values */
if ( is_array( $content ) )
$content = implode( ',', $content ); /* This is fucked */
}
/* echo content */
if ( $echo )
echo $content;
return $content;
}
}
/**
* Custom stripslashes from single value or array.
*
* @param mixed $input
* @return mixed
*
* @access public
* @since 1.1.3
* @deprecated 2.0
*/
if ( ! function_exists( 'option_tree_stripslashes' ) ) {
function option_tree_stripslashes( $input ) {
if ( is_array( $input ) ) {
foreach( $input as &$val ) {
if ( is_array( $val ) ) {
$val = option_tree_stripslashes( $val );
} else {
$val = stripslashes( $val );
}
}
} else {
$input = stripslashes( $input );
}
return $input;
}
}
/* End of file ot-functions-deprecated.php */
/* Location: ./includes/ot-functions-deprecated.php */

View File

@ -0,0 +1,957 @@
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
/**
* OptionTree documentation page functions.
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
* @since 2.0
*/
/**
* Creating Options option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_creating_options' ) ) {
function ot_type_creating_options() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<h4>'. __( 'Label', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Label field should be a short but descriptive block of text 100 characters or less with no HTML.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'ID', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The ID field is a unique alphanumeric key used to differentiate each theme option (underscores are acceptable). Also, the plugin will change all text you write in this field to lowercase and replace spaces and special characters with an underscore automatically.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Type', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'You are required to choose one of the supported option types when creating a new option. Here is a list of the available option types. For more information about each type click the <code>Option Types</code> tab to the left.', 'option-tree' ) . '</p>';
echo '<ul class="docs-ul">';
foreach( ot_option_types_array() as $key => $value )
echo '<li>' . $value . '</li>';
echo '</ul>';
echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Choices', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Click the "Add Choice" button to add an item to the choices array. This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Settings', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Click the "Add Setting" button found inside a newly created setting to add an item to the settings array. This will only affect the List Item type.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Standard', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Setting the standard value for your option only works for some option types. Those types are one that have a single string value saved to them and not an array of values.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Rows', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Post Type', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Add a comma separated list of post type like <code>post,page</code>. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select. Below are the default post types available with WordPress and that are also compatible with OptionTree. You can also add your own custom <code>post_type</code>. At this time <code>any</code> does not seem to return results properly and is something I plan on looking into.', 'option-tree' ) . '</p>';
echo '<ul class="docs-ul">';
echo '<li><code>post</code></li>';
echo '<li><code>page</code></li>';
echo '<li><code>attachment</code></li>';
echo '</ul>';
echo '<h4>'. __( 'Taxonomy', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Add a comma separated list of any registered taxonomy like <code>category,post_tag</code>. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ) . '</p>';
echo '</div>';
echo '</div>';
}
}
/**
* ot_get_option() option type.
*
* This is a callback function to display text about ot_get_option().
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_option_types' ) ) {
function ot_type_option_types() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<h4>'. __( 'Background', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with <code>ot_get_option()</code>. Background has filters that allow you to change the defaults. For example, you can filter on <code>ot_recognized_background_repeat</code>, <code>ot_recognized_background_attachment</code>, and <code>ot_recognized_background_position</code>. These filters allow you to fine tune the select lists for your specific CSS needs.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Category Select', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Category Checkbox', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Checkbox', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Checkbox option type is fairly self explanatory. Typically used to ask questions. For example, "Do you want to activate asynchronous Google analytics?" would be a single checkbox with a value of yes. You could have more complex usages but the idea is that you can easily grab the value of the checkbox and use it in you theme. In this situation you would test if the checkbox has a value and execute a block of code if it does and do nothing if it doesn\'t.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Colorpicker', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'CSS', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named <code>dynamic.css</code> at the root level of your theme and change permissions using chmod so the server can write to the file. I have had the most success setting this single file to 0777 but feel free to play around with permissions until everything is working. A good starting point is 0666. When the server can save to the file CSS will automatically be updated each time you save your theme options.', 'option-tree' ) . '</p>';
echo '<p class="aside">' . __( 'An example of the CSS option type: This assumes you have an option with the ID of <code>custom_background_css</code> which will display the saved values for that option.', 'option-tree' ) . '</p>';
echo '<p>'. __( 'Input', 'option-tree' ) . ':</p>';
echo '<pre><code>body {
{{custom_background_css}}
background-color: {{custom_background_css|background-color}};
}</code></pre>';
echo '<p>'. __( 'Output', 'option-tree' ) . ':</p>';
echo '<pre><code>/* BEGIN custom_background_css */
body {
background: color image repeat attachment position;
background-color: color;
}
/* END custom_background_css */</code></pre>';
echo '<h4>'. __( 'Custom Post Type Select', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid <code>post_type</code> when created in the settings. For some reason <code>any</code> does not work correctly and will looked into in future version.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Custom Post Type Checkbox', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid <code>post_type</code> when created in the settings. For some reason <code>any</code> does not work correctly and will looked into in future version.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'List Item', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The list Item replaced the old Slider option type. It allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Measurement', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are <code>px</code>, <code>%</code>, <code>em</code>, <code>pt</code>. However, you can change them with the <code>ot_measurement_unit_types</code> filter.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'Example filter to add new units to the Measurement option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) {
/* only run the filter on measurement with a field ID of my_measurement */
if ( $field_id == \'my_measurement\' ) {
$array[\'in\'] = \'inches\';
$array[\'ft\'] = \'feet\';
}
return $array;
}
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
echo '<p>' . __( 'Example filter to completely change the units in the Measurement option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) {
/* only run the filter on measurement with a field ID of my_measurement */
if ( $field_id == \'my_measurement\' ) {
$array = array(
\'in\' => \'inches\',
\'ft\' => \'feet\'
);
}
return $array;
}
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
echo '<h4>'. __( 'Page Select', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Page Checkbox', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Page Select option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Post Select', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Post Checkbox', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Post Select option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Radio', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Radio option type could ask a question. For example, "Do you want to activate the custom navigation?" could require a yes or no answer with a radio option. In this situation you would test if the radio has a value of \'yes\' and execute a block of code, or if it\'s \'no\' execute a different block of code.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Radio Image', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using <code>ot_radio_images</code>. As well, you can add your own custom images using the choices array.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'This example executes the <code>ot_radio_images</code> filter on layout images attached to the <code>my_radio_images</code> field. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_radio_images( $array, $field_id ) {
/* only run the filter where the field ID is my_radio_images */
if ( $field_id == \'my_radio_images\' ) {
$array = array(
array(
\'value\' => \'left-sidebar\',
\'label\' => __( \'Left Sidebar\', \'option-tree\' ),
\'src\' => OT_URL . \'/assets/images/layout/left-sidebar.png\'
),
array(
\'value\' => \'right-sidebar\',
\'label\' => __( \'Right Sidebar\', \'option-tree\' ),
\'src\' => OT_URL . \'/assets/images/layout/right-sidebar.png\'
)
);
}
return $array;
}
add_filter( \'ot_radio_images\', \'filter_radio_images\', 10, 2 );</code></pre>';
echo '<h4>'. __( 'Select', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Slider', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Slider option type is technically deprecated. Use the List Item option type instead, as it\'s infinitely more customizable. Typical use is for creating sliding image content.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Tag Checkbox', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Tag Select', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Taxonomy Checkbox', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Taxonomy Select', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Text (Input)', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Text option type would be used to save a string value. For example, a link to feedburner, your Twitter username, or Google Analytics ID are all good candidates. Any optional or required text that is of reasonably short character length.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Textarea', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Textarea option type is a large string value used for custom code or text in the theme. The new Textarea has a WYSIWYG editor that can be filtered to change the buttons shown. For example, you can filter on <code>wpautop</code>, <code>media_buttons</code>, <code>tinymce</code>, and <code>quicktags</code>.', 'option-tree' ) . '</p>';
echo '<p class="aside">' . __( 'Example filters to alter the Textarea option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'This example keeps WordPress from executing the <code>wpautop</code> filter on the line breaks. The default is <code>true</code> which means it wraps line breaks with an HTML <code>p</code> tag.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_textarea_wpautop( $content, $field_id ) {
/* only run the filter on the textarea with a field ID of my_textarea */
if ( $field_id == \'my_textarea\' ) {
return false;
}
return $content;
}
add_filter( \'ot_wpautop\', \'filter_textarea_wpautop\', 10, 1 );</code></pre>';
echo '<p>' . __( 'This example keeps WordPress from executing the <code>media_buttons</code> filter on the textarea WYSIWYG. The default is <code>true</code> which means show the buttons.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_textarea_media_buttons( $content, $field_id ) {
/* only run the filter on the textarea with a field ID of my_textarea */
if ( $field_id == \'my_textarea\' ) {
return false;
}
return $content;
}
add_filter( \'ot_media_buttons\', \'filter_textarea_media_buttons\', 10, 2 );</code></pre>';
echo '<p>' . __( 'This example keeps WordPress from executing the <code>tinymce</code> filter on the textarea WYSIWYG. The default is <code>true</code> which means show the tinymce.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_textarea_tinymce( $content, $field_id ) {
/* only run the filter on the textarea with a field ID of my_textarea */
if ( $field_id == \'my_textarea\' ) {
return false;
}
return $content;
}
add_filter( \'ot_tinymce\', \'filter_textarea_tinymce\', 10, 2 );</code></pre>';
echo '<p>' . __( 'This example alters the <code>quicktags</code> filter on the textarea WYSIWYG. The default is <code>array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close\' )</code> which means show those quicktags. It also means you can filter in your own custom quicktags.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_textarea_quicktags( $content, $field_id ) {
/* only run the filter on the textarea with a field ID of my_textarea */
if ( $field_id == \'my_textarea\' ) {
return array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close,fullscreen\' );
} else if ( $field_id == \'my_other_textarea\' ) {
return false; /* show no quicktags */
}
return $content;
}
add_filter( \'ot_quicktags\', \'filter_textarea_quicktags\', 10, 1 );</code></pre>';
echo '<h4>'. __( 'Textarea Simple', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The new Textarea Simple does not have a WYSIWYG editor. But you can still filter on <code>wpautop</code>.', 'option-tree' ) . '</p>';
echo '<p class="aside">' . __( 'This example tells WordPress to execute the <code>wpautop</code> filter on the line breaks. The default is <code>false</code> which means it does not wraps line breaks with an HTML <code>p</code> tag. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_textarea_simple_wpautop( $content, $field_id ) {
/* only run the filter on the textarea with a field ID of my_textarea */
if ( $field_id == \'my_textarea\' ) {
return true;
}
return $content;
}
add_filter( \'ot_wpautop\', \'filter_textarea_simple_wpautop\', 10, 2 );</code></pre>';
echo '<h4>'. __( 'Textblock', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML on your Theme Options page but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would NEVER use this in your themes template files as it does not save a value.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Textblock Titled', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML on your Theme Options page and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would NEVER use this in your themes template files as it does not save a value.', 'option-tree' ) . '</p>';
echo '<h4>'. __( 'Typography', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Typography option type is for adding typographic styles to your theme either dynamically via the CSS option type below or manually with <code>ot_get_option()</code>. Typography has filters that allow you to change the defaults. For example, you can filter on <code>ot_recognized_font_styles</code>, <code>ot_recognized_font_weights</code>, <code>ot_recognized_font_variants</code>, and <code>ot_recognized_font_families</code>. These filters allow you to fine tune the select lists for your specific CSS needs. The most important one though is <code>ot_recognized_font_families</code> as you can add your Google Fonts to create custom font stacks.', 'option-tree' ) . '</p>';
echo '<p class="aside">' . __( 'This example would filter <code>ot_recognized_font_families</code> to build your own font stack. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
echo '<pre><code>function filter_ot_recognized_font_families( $array, $field_id ) {
/* only run the filter when the field ID is my_google_fonts_headings */
if ( $field_id == \'my_google_fonts_headings\' ) {
$array = array(
\'sans-serif\' => \'sans-serif\',
\'open-sans\' => \'"Open Sans", sans-serif\',
\'droid-sans\' => \'"Droid Sans", sans-serif\'
);
}
return $array;
}
add_filter( \'ot_recognized_font_families\', \'filter_ot_recognized_font_families\', 10, 2 );</code></pre>';
echo '<h4>'. __( 'Upload', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "Send to OptionTree" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You\'ll have to re-upload or FTP any media to your new server and change the URIs if necessary.', 'option-tree' ) . '</p>';
echo '</div>';
echo '</div>';
}
}
/**
* ot_get_option() option type.
*
* This is a callback function to display text about ot_get_option().
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_ot_get_option' ) ) {
function ot_type_ot_get_option() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'This function returns a value from the "option_tree" array of saved values or the default value supplied. The returned value would be mixed. Meaning it could be a string, integer, boolean, or array.', 'option-tree' ) . '</p>';
echo '<h4>' . __( 'Usage', 'option-tree' ) . ':</h4>';
echo '<p><code>&lt;?php ot_get_option( $option_id, $default ); ?&gt;</code></p>';
echo '<h4>' . __( 'Parameters', 'option-tree' ) . ':</h4>';
echo '<code>$option_id</code>';
echo '<p>(<em>' . __( 'string', 'option-tree' ) . '</em>) (<em>' . __( 'required', 'option-tree' ) . '</em>) ' . __( 'Enter the options unique identifier.', 'option-tree' ) . '<br />' . __( 'Default:', 'option-tree' ) . ' <em>' . __( 'None', 'option-tree' ) . '</em></p>';
echo '<code>$default</code>';
echo '<p>(<em>' . __( 'string', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Enter a default return value. This is just incase the request returns null.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': <em>' . __( 'None', 'option-tree' ) . '</em></p>';
echo '</div>';
echo '</div>';
}
}
/**
* get_option_tree() option type.
*
* This is a callback function to display text about get_option_tree().
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_get_option_tree' ) ) {
function ot_type_get_option_tree() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<p class="deprecated">' . __( 'This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'Use', 'option-tree' ) . '<code>ot_get_option()</code>' . __( 'instead', 'option-tree' ) . '.</p>';
echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'This function returns, or echos if asked, a value from the "option_tree" array of saved values.', 'option-tree' ) . '</p>';
echo '<h4>' . __( 'Usage', 'option-tree' ) . ':</h4>';
echo '<p><code>&lt;?php get_option_tree( $item_id, $options, $echo, $is_array, $offset ); ?&gt;</code></p>';
echo '<h4>' . __( 'Parameters', 'option-tree' ) . ':</h4>';
echo '<code>$item_id</code>';
echo '<p>(<em>' . __( 'string', 'option-tree' ) . '</em>) (<em>' . __( 'required', 'option-tree' ) . '</em>) ' . __( 'Enter a unique Option Key to get a returned value or array.', 'option-tree' ) . '<br />' . __( 'Default:', 'option-tree' ) . ' <em>' . __( 'None', 'option-tree' ) . '</em></p>';
echo '<code>$options</code>';
echo '<p>(<em>' . __( 'array', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Used to cut down on database queries in template files.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': <em>' . __( 'None', 'option-tree' ) . '</em></p>';
echo '<code>$echo</code>';
echo '<p>(<em>' . __( 'boolean', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Echo the output.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': FALSE</p>';
echo '<code>$is_array</code>';
echo '<p>(<em>' . __( 'boolean', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Used to indicate the $item_id is an array of values.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': FALSE</p>';
echo '<code>$offset</code>';
echo '<p>(<em>' . __( 'integer', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Numeric offset key for the $item_id array, -1 will return all values (an array starts at 0).', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': -1</p>';
echo '</div>';
echo '</div>';
}
}
/**
* Examples option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_examples' ) ) {
function ot_type_examples() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<p class="aside">' . __( 'If you\'re using the plugin version of OptionTree it is highly recommended to include a <code>function_exists</code> check in your code, as described in the examples below. If you\'ve integrated OptionTree directly into your themes root directory, you will <strong>not</strong> need to wrap your code with <code>function_exists</code>, as you\'re guaranteed to have the <code>ot_get_option()</code> function available.', 'option-tree' ) . '</p>';
echo '<h4>' . __( 'String Examples', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Returns the value of <code>test_input</code>.', 'option-tree' ) . '</p>';
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
$test_input = ot_get_option( \'test_input\' );
}</code></pre>';
echo '<p>' . __( 'Returns the value of <code>test_input</code>, but also has a default value if it returns empty.', 'option-tree' ) . '</p>';
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
$test_input = ot_get_option( \'test_input\', \'default input value goes here.\' );
}</code></pre>';
echo '<h4>' . __( 'Array Examples', 'option-tree' ) . ':</h4>';
echo '<p>' . __( 'Assigns the value of <code>navigation_ids</code> to the variable <code>$ids</code>. It then echos an unordered list of links (navigation) using <code>wp_list_pages()</code>.', 'option-tree' ) . '</p>';
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
/* get an array of page id\'s */
$ids = ot_get_option( \'navigation_ids\', array() );
/* echo custom navigation using wp_list_pages() */
if ( ! empty( $ids ) )
echo \'&lt;ul&gt;\';
wp_list_pages(
array(
\'include\' => $ids,
\'title_li\' => \'\'
)
);
echo \'&lt;/ul&gt;\';
}
}</code></pre>';
echo '<p>' . __( 'The next two examples demonstrate how to use the <strong>Measurement</strong> option type. The Measurement option type is an array with two key/value pairs. The first is the value of measurement and the second is the unit of measurement.', 'option-tree' ) . '</p>';
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
/* get the array */
$measurement = ot_get_option( \'measurement_option_type_id\' );
/* only echo values if they actually exist, else echo some default value */
if ( isset( measurement[0] ) && $measurement[1] ) {
echo $measurement[0].$measurement[1];
} else {
echo \'10px\';
}
}</code></pre>';
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
/* get the array, and have a default just incase */
$measurement = ot_get_option( \'measurement_option_type_id\', array( \'10\', \'px\' ) );
/* implode array into a string value */
if ( ! empty( measurement ) ) {
echo implode( \'\', $measurement );
}
}</code></pre>';
echo '<p>' . __( 'This example displays a very basic slider loop.', 'option-tree' ) . '</p>';
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
/* get the slider array */
$slides = ot_get_option( \'my_slider\', array() );
if ( ! empty( $slides ) ) {
foreach( $slides as $slide ) {
echo \'
&lt;li&gt;
&lt;a href="\' . $slide[\'link\'] . \'"&gt;&lt;img src="\' . $slide[\'image\'] . \'" alt="\' . $slide[\'title\'] . \'" /&gt;&lt;/a&gt;
&lt;div class="description">\' . $slide[\'description\'] . \'&lt;/div&gt;
&lt;/li&gt;\';
}
}
}</code></pre>';
echo '</div>';
echo '</div>';
}
}
/**
* Layouts Overview option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_layouts_overview' ) ) {
function ot_type_layouts_overview() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<h4>'. __( 'It\'s Super Simple', 'option-tree' ) . '</h4>';
echo '<p>' . __( 'Layouts make your theme awesome! With theme options data that you can save/import/export you can package themes with different color variations, or make it easy to do A/B testing on text and so much more. Basically, you save a snapshot of your data as a layout.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'Once you have created all your different layouts, or theme variations, you can save them to a separate text file for repackaging with your theme. Alternatively, you could just make different variations for yourself and change your theme with the click of a button, all without deleting your previous options data.', 'option-tree' ) . '</p>';
echo '<p class="aside">' . __( ' Adding a layout is ridiculously easy, follow these steps and you\'ll be on your way to having a WordPress super theme.', 'option-tree' ) . '</p>';
echo '<h4>' . __( 'For Developers', 'option-tree' ) . ':</h4>';
echo '<p>' . __( '', 'option-tree' ) . '</p>';
echo '<h5>' . __( 'Creating a Layout', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Enter a name for your layout in the text field and hit "Save Layouts", you\'ve created your first layout.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<h5>' . __( 'Activating a Layout', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Click on the activate layout button in the actions list.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<h5>' . __( 'Deleting a Layout', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Click on the delete layout button in the actions list.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<h5>' . __( 'Edit Layout Data', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'If you want to edit a new layout, first create it then save your theme options.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<h4>' . __( 'End-Users Mode', 'option-tree' ) . ':</h4>';
echo '<p>' . __( '', 'option-tree' ) . '</p>';
echo '<h5>' . __( 'Creating a Layout', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Enter a name for your layout in the text field and hit "New Layout", you\'ve created your first layout.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<h5>' . __( 'Activating a Layout', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Choose a layout from the select list and click the "Activate Layout" button.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<h5>' . __( 'Deleting a Layout', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'End-Users mode does not allow deleting layouts.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<h5>' . __( 'Edit Layout Data', 'option-tree' ) . ':</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> tab.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
}
}
/**
* Meta Boxes option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_meta_boxes' ) ) {
function ot_type_meta_boxes() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<h4>'. __( 'How-to-guide', 'option-tree' ) . '</h4>';
echo '<p>' . __( 'There are a few simple steps you need to take in order to use OptionTree\'s built in Meta Box API. In the code below I\'ll show you a basic demo of how to create your very own custom meta box using any number of the option types you have at your disposal. If you would like to see some demo code, there is a directory named <code>theme-mode</code> inside the <code>assets</code> directory that contains a file named <code>demo-meta-boxes.php</code> you can reference.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'It\'s important to note that Meta Boxes do not support WYSIWYG editors at this time and if you set one of your options to Textarea it will automatically revert to a Textarea Simple until a valid solution is found. WordPress released this statement regarding the wp_editor() function:', 'option-tree' ) . '</p>';
echo '<blockquote>' . __( 'Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page.', 'option-tree' ) . '</blockquote>';
echo '<h5>' . __( 'Create and include your custom meta boxes file.', 'option-tree' ) . '</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Create a file and name it anything you want, maybe <code>meta-boxes.php</code>.', 'option-tree' ) . '</li>';
echo '<li>'. __( 'As well, you\'ll probably want to create a directory named <code>includes</code> to put your <code>meta-boxes.php</code> into which will help keep you file structure nice and tidy.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Add the following code to your <code>functions.php</code>.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<pre><code>/**
* Meta Boxes
*/
include_once( \'includes/meta-boxes.php\' );
</code></pre>';
echo '<ul class="docs-ul">';
echo '<li>' . __( 'Add a variation of the following code to your <code>meta-boxes.php</code>. You\'ll obviously need to fill it in with all your custom array values. It\'s important to note here that we use the <code>admin_init</code> filter because if you were to call the <code>ot_register_meta_box</code> function before OptionTree was loaded the sky would fall on your head.', 'option-tree' ) . '</li>';
echo '</ul>';
echo "<pre><code>/**
* Initialize the meta boxes.
*/
add_action( 'admin_init', 'custom_meta_boxes' );
function custom_meta_boxes() {
&#36;my_meta_box = array(
'id' => 'my_meta_box',
'title' => 'My Meta Box',
'desc' => '',
'pages' => array( 'post' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'id' => 'background',
'label' => 'Background',
'desc' => '',
'std' => '',
'type' => 'background',
'class' => '',
'choices' => array()
)
)
);
ot_register_meta_box( &#36;my_meta_box );
}</code></pre>";
echo '</div>';
echo '</div>';
}
}
/**
* Theme Mode option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_theme_mode' ) ) {
function ot_type_theme_mode() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock wide-desc">';
/* description */
echo '<div class="description">';
echo '<h4>'. __( 'How-to-guide', 'option-tree' ) . '</h4>';
echo '<p>' . __( 'There are a few simple steps you need to take in order to use OptionTree as a theme included module. In the code below I\'ll show you a basic demo of how to include the entire plugin as a module, which will allow you to have the most up-to-date version of OptionTree without ever needing to hack the core of the plugin. If you would like to see some demo code, there is a directory named <code>theme-mode</code> inside the <code>assets</code> directory that contains a file named <code>demo-theme-options.php</code> you can reference.', 'option-tree' ) . '</p>';
echo '<h5>' . __( 'Step 1: Include the plugin & turn on theme mode.', 'option-tree' ) . '</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Download the latest version of <a href="http://wordpress.org/extend/plugins/option-tree/" rel="nofollow" target="_blank">OptionTree</a>.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Unpack the ZIP archive.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Put the <code>option-tree</code> directory in the root of your theme. For example, the server path would be <code>/wp-content/themes/theme-name/option-tree/</code>.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Add the following code to the beginning of your <code>functions.php</code>.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<pre><code>/**
* Optional: set \'ot_show_pages\' filter to false.
* This will hide the settings & documentation pages.
*/
add_filter( \'ot_show_pages\', \'__return_false\' );
/**
* Required: set \'ot_theme_mode\' filter to true.
*/
add_filter( \'ot_theme_mode\', \'__return_true\' );
/**
* Required: include OptionTree.
*/
include_once( \'option-tree/ot-loader.php\' );
</code></pre>';
echo '<p class="aside">' . __( 'It\'s that simple! You now have OptionTree built into your theme and anytime there\'s an update to the plugin you just replace the old version and you\'re good to go..', 'option-tree' ) . '</p>';
echo '<h5>' . __( 'Step 2: Create Theme Options without using the UI Builder.', 'option-tree' ) . '</h5>';
echo '<ul class="docs-ul">';
echo '<li>'. __( 'Create a file and name it anything you want, maybe <code>theme-options.php</code>, or use the built in file export to create it for you. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ) . '</li>';
echo '<li>'. __( 'As well, you\'ll probably want to create a directory named <code>includes</code> to put your <code>theme-options.php</code> into which will help keep you file structure nice and tidy.', 'option-tree' ) . '</li>';
echo '<li>' . __( 'Add the following code to your <code>functions.php</code>.', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<pre><code>/**
* Theme Options
*/
include_once( \'includes/theme-options.php\' );
</code></pre>';
echo '<ul class="docs-ul">';
echo '<li>' . __( 'Add a variation of the following code to your <code>theme-options.php</code>. You\'ll obviously need to fill it in with all your custom array values for contextual help (optional), sections (required), and settings (required).', 'option-tree' ) . '</li>';
echo '</ul>';
echo '<p>' . __( 'The code below is a boilerplate to get your started. For a full list of the available option types click the "Option Types" tab above. Also a quick note, you don\'t need to put OptionTree in theme mode to manually create options but you will want to hide the docs and settings as each time you load the admin area the settings be be written over with the code below if they\'ve changed in any way. However, this ensures your settings do not get tampered with by the end-user.', 'option-tree' ) . '</p>';
echo "<pre><code>/**
* Initialize the options before anything else.
*/
add_action( 'admin_init', 'custom_theme_options', 1 );
/**
* Build the custom settings & update OptionTree.
*/
function custom_theme_options() {
/**
* Get a copy of the saved settings array.
*/
&#36;saved_settings = get_option( 'option_tree_settings', array() );
/**
* Custom settings array that will eventually be
* passes to the OptionTree Settings API Class.
*/
&#36;custom_settings = array(
'contextual_help' => array(
'content' => array(
array(
'id' => 'general_help',
'title' => 'General',
'content' => '&lt;p&gt;Help content goes here!&lt;/p&gt;'
)
),
'sidebar' => '&lt;p&gt;Sidebar content goes here!&lt;/p&gt;',
),
'sections' => array(
array(
'id' => 'general',
'title' => 'General'
)
),
'settings' => array(
array(
'id' => 'my_checkbox',
'label' => 'Checkbox',
'desc' => '',
'std' => '',
'type' => 'checkbox',
'section' => 'general',
'class' => '',
'choices' => array(
array(
'value' => 'yes',
'label' => 'Yes'
)
)
),
array(
'id' => 'my_layout',
'label' => 'Layout',
'desc' => 'Choose a layout for your theme',
'std' => 'right-sidebar',
'type' => 'radio-image',
'section' => 'general',
'class' => '',
'choices' => array(
array(
'value' => 'left-sidebar',
'label' => 'Left Sidebar',
'src' => OT_URL . '/assets/images/layout/left-sidebar.png'
),
array(
'value' => 'right-sidebar',
'label' => 'Right Sidebar',
'src' => OT_URL . '/assets/images/layout/right-sidebar.png'
),
array(
'value' => 'full-width',
'label' => 'Full Width (no sidebar)',
'src' => OT_URL . '/assets/images/layout/full-width.png'
),
array(
'value' => 'dual-sidebar',
'label' => __( 'Dual Sidebar', 'option-tree' ),
'src' => OT_URL . '/assets/images/layout/dual-sidebar.png'
),
array(
'value' => 'left-dual-sidebar',
'label' => __( 'Left Dual Sidebar', 'option-tree' ),
'src' => OT_URL . '/assets/images/layout/left-dual-sidebar.png'
),
array(
'value' => 'right-dual-sidebar',
'label' => __( 'Right Dual Sidebar', 'option-tree' ),
'src' => OT_URL . '/assets/images/layout/right-dual-sidebar.png'
)
)
),
array(
'id' => 'my_slider',
'label' => 'Images',
'desc' => '',
'std' => '',
'type' => 'list-item',
'section' => 'general',
'class' => '',
'choices' => array(),
'settings' => array(
array(
'id' => 'slider_image',
'label' => 'Image',
'desc' => '',
'std' => '',
'type' => 'upload',
'class' => '',
'choices' => array()
),
array(
'id' => 'slider_link',
'label' => 'Link to Post',
'desc' => 'Enter the posts url.',
'std' => '',
'type' => 'text',
'class' => '',
'choices' => array()
),
array(
'id' => 'slider_description',
'label' => 'Description',
'desc' => 'This text is used to add fancy captions in the slider.',
'std' => '',
'type' => 'textarea',
'class' => '',
'choices' => array()
)
)
)
)
);
/* settings are not the same update the DB */
if ( &#36;saved_settings !== &#36;custom_settings ) {
update_option( 'option_tree_settings', &#36;custom_settings );
}
}
</code></pre>";
echo '</div>';
echo '</div>';
}
}
/* End of file ot-functions-docs-page.php */
/* Location: ./includes/ot-functions-docs-page.php */

View File

@ -0,0 +1,570 @@
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
/**
* OptionTree settings page functions.
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
* @since 2.0
*/
/**
* Create option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
function ot_type_theme_options_ui() {
global $blog_id;
echo '<form method="post" id="option-tree-settings-form">';
/* form nonce */
wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock has-desc">';
/* description */
echo '<div class="description">';
echo '<h4>'. __( 'Warning!', 'option-tree' ) . '</h4>';
echo '<p class="warning">' . sprintf( __( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'themes.php?page=ot-theme-options' ) . '"><code>Appearance->Theme Options</code></a>' ) . '</p>';
echo '<p class="warning">' . sprintf( __( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation' ) . '"><code>OptionTree->Documentation</code></a>' ) . '</p>';
echo '<h4>'. __( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
echo '<p class="warning">' . __( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '</p>';
echo '</div>';
/* get the saved settings */
$settings = get_option( 'option_tree_settings' );
/* wrap settings array */
echo '<div class="format-setting-inner">';
/* set count to zero */
$count = 0;
/* loop through each section and its settings */
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="option_tree_settings[settings]">';
if ( isset( $settings['sections'] ) ) {
foreach( $settings['sections'] as $section ) {
/* section */
echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( 'option_tree_settings[sections]', $count, $section ) . '</li>';
/* increment item count */
$count++;
/* settings in this section */
if ( isset( $settings['settings'] ) ) {
foreach( $settings['settings'] as $setting ) {
if ( isset( $setting['section'] ) && $setting['section'] == $section['id'] ) {
echo '<li class="ui-state-default list-setting">' . ot_settings_view( 'option_tree_settings[settings]', $count, $setting ) . '</li>';
/* increment item count */
$count++;
}
}
}
}
}
echo '</ul>';
/* buttons */
echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button blue hug-left">' . __( 'Add Section', 'option-tree' ) . '</a>';
echo '<a href="javascript:void(0);" class="option-tree-setting-add blue option-tree-ui-button">' . __( 'Add Setting', 'option-tree' ) . '</a>';
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
/* sidebar textarea */
echo '
<div class="format-setting-label" id="contextual-help-label">
<h3 class="label">' . __( 'Contextual Help', 'option-tree' ) . '</h3>
</div>
<div class="format-settings" id="contextual-help-setting">
<div class="format-setting type-textarea no-desc">
<div class="description"><strong>' . __( 'Contextual Help Sidebar', 'option-tree' ) . '</strong>: ' . __( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '</div>
<div class="format-setting-inner">
<textarea class="textarea" rows="10" cols="40" name="option_tree_settings[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
</div>
</div>
</div>';
/* set count to zero */
$count = 0;
/* loop through each contextual_help content section */
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="option_tree_settings[contextual_help][content]">';
if ( isset( $settings['contextual_help']['content'] ) ) {
foreach( $settings['contextual_help']['content'] as $content ) {
/* content */
echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( 'option_tree_settings[contextual_help][content]', $count, $content ) . '</li>';
/* increment content count */
$count++;
}
}
echo '</ul>';
echo '<a href="javascript:void(0);" class="option-tree-help-add blue option-tree-ui-button hug-left">' . __( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
echo '</div>';
echo '</div>';
echo '</form>';
}
}
/**
* Import XML option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_import_xml' ) ) {
function ot_type_import_xml() {
echo '<form method="post" id="import-xml-form">';
/* form nonce */
wp_nonce_field( 'import_xml_form', 'import_xml_nonce' );
/* format setting outer wrapper */
echo '<div class="format-setting type-textblock has-desc">';
/* description */
echo '<div class="description">';
echo '<p class="deprecated">' . __( 'This import method has been deprecated. That means it has been replaced by a new method and is no longer supported, and may be removed from future versions. All themes that use this import method should be converted to use its replacement below.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file by clicking the blue upload button. A popup window will appear, upload the XML file and click "Send to OptionTree". The file URL should be in the upload input, if it is click "Import XML".', 'option-tree' ) . '</p>';
/* button */
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import XML', 'option-tree' ) . '</button>';
echo '</div>';
echo '<div class="format-setting-inner">';
/* build upload */
echo '<div class="option-tree-ui-upload-parent">';
/* input */
echo '<input type="text" name="import_xml" id="import_xml" value="" class="widefat option-tree-ui-upload-input" />';
/* get media post_id */
$post_id = ( $id = ot_get_media_post_ID() ) ? (int) $id : 0;
/* add xml button */
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button blue light" rel="' . $post_id . '" title="' . __( 'Add XML', 'option-tree' ) . '"><span class="icon upload">' . __( 'Add XML', 'option-tree' ) . '</span></a>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</form>';
}
}
/**
* Import Settings option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_import_settings' ) ) {
function ot_type_import_settings() {
echo '<form method="post" id="import-settings-form">';
/* form nonce */
wp_nonce_field( 'import_settings_form', 'import_settings_nonce' );
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . __( 'To import your Settings copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Settings" button.', 'option-tree' ) . '</p>';
/* button */
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import Settings', 'option-tree' ) . '</button>';
echo '</div>';
/* textarea */
echo '<div class="format-setting-inner">';
echo '<textarea rows="10" cols="40" name="import_settings" id="import_settings" class="textarea"></textarea>';
echo '</div>';
echo '</div>';
echo '</form>';
}
}
/**
* Import Data option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_import_data' ) ) {
function ot_type_import_data() {
echo '<form method="post" id="import-data-form">';
/* form nonce */
wp_nonce_field( 'import_data_form', 'import_data_nonce' );
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '</p>';
/* button */
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import Theme Options', 'option-tree' ) . '</button>';
echo '</div>';
/* textarea */
echo '<div class="format-setting-inner">';
echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
echo '</div>';
echo '</div>';
echo '</form>';
}
}
/**
* Import Layouts option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_import_layouts' ) ) {
function ot_type_import_layouts() {
echo '<form method="post" id="import-layouts-form">';
/* form nonce */
wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' );
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'To import your Layouts copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Layouts" button. Keep in mind that when you import your layouts, the active layout\'s saved data will write over the current data set for your Theme Options.', 'option-tree' ) . '</p>';
/* button */
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import Layouts', 'option-tree' ) . '</button>';
echo '</div>';
/* textarea */
echo '<div class="format-setting-inner">';
echo '<textarea rows="10" cols="40" name="import_layouts" id="import_layouts" class="textarea"></textarea>';
echo '</div>';
echo '</div>';
echo '</form>';
}
}
/**
* Export Settings File option type.
*
* @return string
*
* @access public
* @since 2.0.8
*/
if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
function ot_type_export_settings_file() {
global $blog_id;
echo '<form method="post" id="export-settings-file-form">';
/* form nonce */
wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' );
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea simple has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . sprintf( __( 'Export your Settings into a fully functional <code>theme-options.php</code> file by clicking this button. For more information on how to use this file read the theme mode %s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation#section_theme_mode' ) . '"><code>OptionTree->Documentation</code></a>' ) . '</p>';
echo '</div>';
echo '<div class="format-setting-inner">';
/* button */
echo '<button class="option-tree-ui-button grey hug-left">' . __( 'Export Settings File', 'option-tree' ) . '</button>';
echo '</div>';
echo '</div>';
echo '</form>';
}
}
/**
* Export Settings option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_export_settings' ) ) {
function ot_type_export_settings() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea simple has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . __( 'Export your Settings by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Settings</strong> textarea on another web site.', 'option-tree' ) . '</p>';
echo '</div>';
/* get theme options data */
$settings = get_option( 'option_tree_settings' );
$settings = ! empty( $settings ) ? base64_encode( serialize( $settings ) ) : '';
echo '<div class="format-setting-inner">';
echo '<textarea rows="10" cols="40" name="export_settings" id="export_settings" class="textarea">' . $settings . '</textarea>';
echo '</div>';
echo '</div>';
}
}
/**
* Export Data option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_export_data' ) ) {
function ot_type_export_data() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea simple has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . __( 'Export your Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Theme Options</strong> textarea on another web site.', 'option-tree' ) . '</p>';
echo '</div>';
/* get theme options data */
$data = get_option( 'option_tree' );
$data = ! empty( $data ) ? base64_encode( serialize( $data ) ) : '';
echo '<div class="format-setting-inner">';
echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>';
echo '</div>';
echo '</div>';
}
}
/**
* Export Layouts option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_export_layouts' ) ) {
function ot_type_export_layouts() {
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea simple has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . __( 'Export your Layouts by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Layouts</strong> textarea on another web site.', 'option-tree' ) . '</p>';
echo '</div>';
/* get layout data */
$layouts = get_option( 'option_tree_layouts' );
$layouts = ! empty( $layouts ) ? base64_encode( serialize( $layouts ) ) : '';
echo '<div class="format-setting-inner">';
echo '<textarea rows="10" cols="40" name="export_layouts" id="export_layouts" class="textarea">' . $layouts . '</textarea>';
echo '</div>';
echo '</div>';
}
}
/**
* Modify Layouts option type.
*
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
function ot_type_modify_layouts() {
echo '<form method="post" id="option-tree-settings-form">';
/* form nonce */
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
/* format setting outer wrapper */
echo '<div class="format-setting type-textarea has-desc">';
/* description */
echo '<div class="description">';
echo '<p>' . __( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '</p>';
echo '<p>' . __( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '</p>';
echo '<p>' . __( 'Visit <code>OptionTree->Documentation->Layouts Overview</code> to see a more in-depth description of what layouts are and how to use them.', 'option-tree' ) . '</p>';
echo '</div>';
echo '<div class="format-setting-inner">';
/* get the saved layouts */
$layouts = get_option( 'option_tree_layouts' );
/* set active layout */
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
echo '<input type="hidden" name="option_tree_layouts[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
/* add new layout */
echo '<input type="text" name="option_tree_layouts[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
/* loop through each layout */
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
foreach( $layouts as $key => $data ) {
/* skip active layout array */
if ( $key == 'active_layout' )
continue;
/* content */
echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>';
}
}
echo '</ul>';
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Save Layouts', 'option-tree' ) . '</button>';
echo '</div>';
echo '</div>';
echo '</form>';
}
}
/* End of file ot-functions-settings-page.php */
/* Location: ./includes/ot-functions-settings-page.php */

View File

@ -0,0 +1,98 @@
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
/**
* OptionTree functions
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
* @since 2.0
*/
/**
* Get Option.
*
* Helper function to return the option value.
* If no value has been saved, it returns $default.
*
* @param string The option ID.
* @param string The default option value.
* @return mixed
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_get_option' ) ) {
function ot_get_option( $option_id, $default = '' ) {
/* get the saved options */
$options = get_option( 'option_tree' );
/* look for the saved value */
if ( isset( $options[$option_id] ) && '' != $options[$option_id] ) {
return $options[$option_id];
}
return $default;
}
}
/**
* Enqueue the dynamic CSS.
*
* @return void
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_load_dynamic_css' ) ) {
function ot_load_dynamic_css() {
/* don't load in the admin */
if ( is_admin() )
return;
/* grab a copy of the paths */
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
if ( ! empty( $ot_css_file_paths ) ) {
$last_css = '';
/* loop through paths */
foreach( $ot_css_file_paths as $key => $path ) {
if ( '' != $path && file_exists( $path ) ) {
$parts = explode( '/wp-content', $path );
if ( isset( $parts[1] ) ) {
$css = home_url( '/wp-content' . $parts[1] );
if ( $last_css !== $css ) {
/* enqueue filtered file */
wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION );
$last_css = $css;
}
}
}
}
}
}
}
/* End of file ot-functions.php */
/* Location: ./includes/ot-functions.php */

View File

@ -0,0 +1,281 @@
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
/**
* OptionTree Meta Box API
*
* This class loads all the methods and helpers specific to build a meta box.
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
*/
if ( ! class_exists( 'OT_Meta_Box' ) ) {
class OT_Meta_Box {
/* variable to store the meta box array */
private $meta_box;
/**
* PHP5 constructor method.
*
* This method adds other methods of the class to specific hooks within WordPress.
*
* @uses add_action()
*
* @return void
*
* @access public
* @since 1.0
*/
function __construct( $meta_box ) {
if ( ! is_admin() )
return;
$this->meta_box = $meta_box;
add_action( 'add_meta_boxes', array( &$this, 'add_meta_boxes' ) );
add_action( 'save_post', array( &$this, 'save_meta_box' ), 1, 2 );
}
/**
* Adds meta box to any post type
*
* @uses add_meta_box()
*
* @return void
*
* @access public
* @since 1.0
*/
function add_meta_boxes() {
foreach ( (array) $this->meta_box['pages'] as $page ) {
add_meta_box( $this->meta_box['id'], $this->meta_box['title'], array( &$this, 'build_meta_box' ), $page, $this->meta_box['context'], $this->meta_box['priority'], $this->meta_box['fields'] );
}
}
/**
* Meta box view
*
* @return string
*
* @access public
* @since 1.0
*/
function build_meta_box( $post, $metabox ) {
echo '<div class="ot-metabox-wrapper">';
/* Use nonce for verification */
echo '<input type="hidden" name="' . $this->meta_box['id'] . '_nonce" value="' . wp_create_nonce( $this->meta_box['id'] ) . '" />';
/* meta box description */
echo isset( $this->meta_box['desc'] ) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode( $this->meta_box['desc'] ) . '</div>' : '';
/* loop through meta box fields */
foreach ( $this->meta_box['fields'] as $field ) {
/* get current post meta data */
$field_value = get_post_meta( $post->ID, $field['id'], true );
/* set default to standard value */
if ( '' == $field_value && isset( $field['std'] ) ) {
$field_value = trim( $field['std'] );
}
/* build the arguments array */
$_args = array(
'type' => $field['type'],
'field_id' => $field['id'],
'field_name' => $field['id'],
'field_value' => $field_value,
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
'field_rows' => isset( $field['rows'] ) && ! empty( $field['rows'] ) ? $field['rows'] : 10,
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
'field_choices' => isset( $field['choices'] ) ? $field['choices'] : array(),
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
'post_id' => $post->ID,
'meta' => true
);
/* only allow simple textarea due to DOM issues with wp_editor() */
if ( $_args['type'] == 'textarea' )
$_args['type'] = 'textarea-simple';
/* option label */
echo '<div class="format-settings">';
echo '<div class="format-setting-label">';
echo '<label for="' . $_args['field_id'] . '" class="label">' . $field['label'] . '</label>';
echo '</div>';
/* get the option HTML */
echo ot_display_by_type( $_args );
echo '</div>';
}
echo '</div>';
}
/**
* Saves the meta box values
*
* @return void
*
* @access public
* @since 1.0
*/
function save_meta_box( $post_id, $post_object ) {
global $pagenow;
/* don't save during quick edit */
if ( $pagenow == 'admin-ajax.php' )
return $post_id;
/* don't save during autosave */
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post_id;
/* don't save if viewing a revision */
if ( $post_object->post_type == 'revision' )
return $post_id;
/* verify nonce */
if ( isset( $_POST[ $this->meta_box['id'] . '_nonce'] ) && ! wp_verify_nonce( $_POST[ $this->meta_box['id'] . '_nonce'], $this->meta_box['id'] ) )
return $post_id;
/* check permissions */
if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) )
return $post_id;
} else {
if ( ! current_user_can( 'edit_post', $post_id ) )
return $post_id;
}
foreach ( $this->meta_box['fields'] as $field ) {
$old = get_post_meta( $post_id, $field['id'], true );
$new = '';
/* there is data to validate */
if ( isset( $_POST[$field['id']] ) ) {
/* slider and list item */
if ( in_array( $field['type'], array( 'list-item', 'slider' ) ) ) {
/* required title setting */
$required_setting = array(
array(
'id' => 'title',
'label' => __( 'Title', 'option-tree' ),
'desc' => '',
'std' => '',
'type' => 'text',
'rows' => '',
'class' => 'option-tree-setting-title',
'post_type' => '',
'choices' => array()
)
);
/* get the settings array */
$settings = isset( $_POST[$field['id'] . '_settings_array'] ) ? unserialize( base64_decode( $_POST[$field['id'] . '_settings_array'] ) ) : array();
/* settings are empty for some odd ass reason get the defaults */
if ( empty( $settings ) ) {
$settings = 'slider' == $field['type'] ?
ot_slider_settings( $field['id'] ) :
ot_list_item_settings( $field['id'] );
}
/* merge the two settings array */
$settings = array_merge( $required_setting, $settings );
foreach( $_POST[$field['id']] as $k => $setting_array ) {
foreach( $settings as $sub_setting ) {
/* verify sub setting has a type & value */
if ( isset( $sub_setting['type'] ) && isset( $_POST[$field['id']][$k][$sub_setting['id']] ) ) {
$_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting( $_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] );
}
}
}
/* set up new data with validated data */
$new = $_POST[$field['id']];
} else {
/* run through validattion */
$new = ot_validate_setting( $_POST[$field['id']], $field['type'], $field['id'] );
}
/* insert CSS */
if ( $field['type'] == 'css' ) {
/* insert CSS into dynamic.css */
if ( '' !== $new ) {
ot_insert_css_with_markers( $field['id'], $new, true );
/* remove old CSS from dynamic.css */
} else {
ot_remove_old_css( $field['id'] );
}
}
}
if ( $new && $new !== $old ) {
update_post_meta( $post_id, $field['id'], $new );
} else if ( '' == $new && $old ) {
delete_post_meta( $post_id, $field['id'], $old );
}
}
}
}
}
/**
* This method instantiates the meta box class & builds the UI.
*
* @uses OT_Meta_Box()
*
* @param array Array of arguments to create a meta box
* @return void
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_register_meta_box' ) ) {
function ot_register_meta_box( $args ) {
if ( ! $args )
return;
$ot_meta_box =& new OT_Meta_Box( $args );
}
}
/* End of file ot-meta-box-api.php */
/* Location: ./includes/ot-meta-box-api.php */

View File

@ -0,0 +1,849 @@
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
/**
* OptionTree Settings API
*
* This class loads all the methods and helpers specific to a Settings page.
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
*/
if ( ! class_exists( 'OT_Settings' ) ) {
class OT_Settings {
/* the options array */
private $options;
/* hooks for targeting admin pages */
private $page_hook;
/**
* Constructor
*
* @param array An array of options
* @return void
*
* @access public
* @since 2.0
*/
public function __construct( $args ) {
$this->options = $args;
/* return early if not viewing an admin page or no options */
if ( ! is_admin() || ! is_array( $this->options ) )
return false;
/* load everything */
$this->hooks();
}
/**
* Execute the WordPress Hooks
*
* @return void
*
* @access public
* @since 2.0
*/
public function hooks() {
/* add pages & menu items */
add_action( 'admin_menu', array( &$this, 'add_page' ) );
/* register sections */
add_action( 'admin_init', array( &$this, 'add_sections' ) );
/* register settings */
add_action( 'admin_init', array( &$this, 'add_settings' ) );
/* reset options */
add_action( 'admin_init', array( &$this, 'reset_options' ), 10 );
/* initialize settings */
add_action( 'admin_init', array( &$this, 'initialize_settings' ), 11 );
}
/**
* Loads each admin page
*
* @return void
*
* @access public
* @since 2.0
*/
public function add_page() {
/* loop through options */
foreach( (array) $this->options as $option ) {
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* load page in WP top level menu */
if ( ! isset( $page['parent_slug'] ) || empty( $page['parent_slug'] ) ) {
$page_hook = add_menu_page(
$page['page_title'],
$page['menu_title'],
$page['capability'],
$page['menu_slug'],
array( &$this, 'display_page' ),
$page['icon_url'],
$page['position']
);
/* load page in WP sub menu */
} else {
$page_hook = add_submenu_page(
$page['parent_slug'],
$page['page_title'],
$page['menu_title'],
$page['capability'],
$page['menu_slug'],
array( &$this, 'display_page' )
);
}
/* only load if not a hidden page */
if ( ! isset( $page['hidden_page'] ) ) {
/* associate $page_hook with page id */
$this->page_hook[$page['id']] = $page_hook;
/* add scripts */
add_action( 'admin_print_scripts-' . $page_hook, array( &$this, 'scripts' ) );
/* add styles */
add_action( 'admin_print_styles-' . $page_hook, array( &$this, 'styles' ) );
/* add contextual help */
add_action( 'load-' . $page_hook, array( &$this, 'help' ) );
}
}
}
return false;
}
/**
* Loads the scripts
*
* @return void
*
* @access public
* @since 2.0
*/
public function scripts() {
ot_admin_scripts();
}
/**
* Loads the styles
*
* @return void
*
* @access public
* @since 2.0
*/
public function styles() {
ot_admin_styles();
}
/**
* Loads the contextual help for each page
*
* @return void
*
* @access public
* @since 2.0
*/
public function help() {
$screen = get_current_screen();
/* loop through options */
foreach( (array) $this->options as $option ) {
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* verify page */
if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) {
/* set up the help tabs */
if ( ! empty( $page['contextual_help']['content'] ) ) {
foreach( $page['contextual_help']['content'] as $contextual_help ) {
$screen->add_help_tab(
array(
'id' => esc_attr( $contextual_help['id'] ),
'title' => esc_attr( $contextual_help['title'] ),
'content' => htmlspecialchars_decode( $contextual_help['content'] ),
)
);
}
}
/* set up the help sidebar */
if ( ! empty( $page['contextual_help']['sidebar'] ) ) {
$screen->set_help_sidebar( htmlspecialchars_decode( $page['contextual_help']['sidebar'] ) );
}
}
}
}
return false;
}
/**
* Loads the content for each page
*
* @return string
*
* @access public
* @since 2.0
*/
public function display_page() {
$screen = get_current_screen();
/* loop through settings */
foreach( (array) $this->options as $option ) {
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* verify page */
if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) {
$show_buttons = isset( $page['show_buttons'] ) && $page['show_buttons'] == false ? false : true;
/* update active layout content */
if ( isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ) {
$layouts = get_option( 'option_tree_layouts' );
/* has active layout */
if ( isset( $layouts['active_layout'] ) ) {
$option_tree = get_option( $option['id'] );
$layouts[$layouts['active_layout']] = base64_encode( serialize( $option_tree ) );
update_option( 'option_tree_layouts', $layouts );
}
}
echo '<div class="wrap settings-wrap" id ="page-' . $page['id'] . '">';
screen_icon( ( isset( $page['screen_icon'] ) ? $page['screen_icon'] : 'options-general' ) );
echo '<h2>' . $page['page_title'] . '</h2>';
echo ot_alert_message( $page );
settings_errors( 'option-tree' );
/* Header */
echo '<div id="option-tree-header-wrap">';
echo '<ul id="option-tree-header">';
echo '<li id="option-tree-logo"><a href="http://wordpress.org/extend/plugins/option-tree/" target="_blank">OptionTree</a></li>';
echo '<li id="option-tree-version"><span>Version ' . OT_VERSION . '</span></li>';
echo '</ul>';
/* layouts form */
if ( $page['id'] == 'ot_theme_options' )
ot_theme_options_layouts_form();
echo '</div>';
/* remove forms on the custom settings pages */
if ( $show_buttons ) {
echo '<form action="options.php" method="post" id="option-tree-settings-api">';
settings_fields( $option['id'] );
} else {
echo '<div id="option-tree-settings-api">';
}
/* Sub Header */
echo '<div id="option-tree-sub-header">';
if ( $show_buttons )
echo '<button class="option-tree-ui-button grey right">' . $page['button_text'] . '</button>';
echo '</div>';
/* Navigation */
echo '<div class="ui-tabs">';
/* check for sections */
if ( isset( $page['sections'] ) && count( $page['sections'] ) > 0 ) {
echo '<ul class="ui-tabs-nav">';
/* loop through page sections */
foreach( (array) $page['sections'] as $section ) {
echo '<li><a href="#section_' . $section['id'] . '">' . $section['title'] . '</a></li>';
}
echo '</ul>';
}
/* sections */
echo '<div id="poststuff" class="metabox-holder">';
echo '<div id="post-body">';
echo '<div id="post-body-content">';
$this->do_settings_sections( $_GET['page'] );
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div class="clear"></div>';
echo '</div>';
/* buttons */
if ( $show_buttons ) {
echo '<div class="option-tree-ui-buttons">';
echo '<button class="option-tree-ui-button grey right">' . $page['button_text'] . '</button>';
echo '</div>';
}
echo $show_buttons ? '</form>' : '</div>';
/* reset button */
if ( $show_buttons ) {
echo '<form method="post" action="' . str_replace( '&settings-updated=true', '', $_SERVER["REQUEST_URI"] ) . '">';
/* form nonce */
wp_nonce_field( 'option_tree_reset_form', 'option_tree_reset_nonce' );
echo '<input type="hidden" name="action" value="reset" />';
echo '<button type="submit" class="option-tree-ui-button red light left reset-settings" title="' . __( 'Reset Options', 'option-tree' ) . '">' . __( 'Reset Options', 'option-tree' ) . '</button>';
echo '</form>';
}
echo '</div>';
}
}
}
return false;
}
/**
* Adds sections to the page
*
* @return void
*
* @access public
* @since 2.0
*/
public function add_sections() {
/* loop through options */
foreach( (array) $this->options as $option ) {
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* loop through page sections */
foreach( (array) $this->get_sections( $page ) as $section ) {
/* add each section */
add_settings_section(
$section['id'],
$section['title'],
array( &$this, 'display_section' ),
$page['menu_slug']
);
}
}
}
return false;
}
/**
* Callback for add_settings_section()
*
* @return string
*
* @access public
* @since 2.0
*/
public function display_section() {
/* currently pointless */
}
/**
* Add settings the the page
*
* @return void
*
* @access public
* @since 2.0
*/
public function add_settings() {
/* loop through options */
foreach( (array) $this->options as $option ) {
register_setting( $option['id'], $option['id'], array ( &$this, 'sanitize_callback' ) );
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* loop through page settings */
foreach( (array) $this->get_settings( $page ) as $setting ) {
/* skip if no setting ID */
if ( ! isset( $setting['id'] ) )
continue;
/* add get_option param to the array */
$setting['get_option'] = $option['id'];
/* add each setting */
add_settings_field(
$setting['id'],
$setting['label'],
array( &$this, 'display_setting' ),
$page['menu_slug'],
$setting['section'],
$setting
);
}
}
}
return false;
}
/**
* Callback for add_settings_field() to build each setting by type
*
* @param array Setting object array
* @return string
*
* @access public
* @since 2.0
*/
public function display_setting( $args = array() ) {
extract( $args );
/* get current saved data */
$options = get_option( $get_option, false );
/* set default to standard value */
if ( ! isset( $options[$id] ) && isset( $std ) ) {
$options[$id] = trim( $std );
}
/* build the arguments array */
$_args = array(
'type' => $type,
'field_id' => $id,
'field_name' => 'option_tree[' . $id . ']',
'field_value' => isset( $options[$id] ) ? $options[$id] : '',
'field_desc' => isset( $desc ) ? $desc : '',
'field_std' => isset( $std ) ? $std : '',
'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15,
'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post',
'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category',
'field_class' => isset( $class ) ? $class : '',
'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(),
'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(),
'post_id' => ot_get_media_post_ID(),
'get_option' => $get_option,
);
/* get the option HTML */
echo ot_display_by_type( $_args );
}
/**
* Sets the option standards if nothing yet exists.
*
* @return void
*
* @access public
* @since 2.0
*/
public function initialize_settings() {
/* loop through options */
foreach( (array) $this->options as $option ) {
/* skip if option is already set */
if ( isset( $option['id'] ) && get_option( $option['id'], false ) ) {
return false;
}
$defaults = array();
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* loop through page settings */
foreach( (array) $this->get_settings( $page ) as $setting ) {
if ( isset( $setting['std'] ) ) {
$defaults[$setting['id']] = ot_validate_setting( $setting['std'], $setting['type'], $setting['id'] );
}
}
}
update_option( $option['id'], $defaults );
}
return false;
}
/**
* Sanitize callback for register_setting()
*
* @return string
*
* @access public
* @since 2.0
*/
public function sanitize_callback( $input ) {
/* loop through options */
foreach( (array) $this->options as $option ) {
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* loop through page settings */
foreach( (array) $this->get_settings( $page ) as $setting ) {
/* verify setting has a type & value */
if ( isset( $setting['type'] ) && isset( $input[$setting['id']] ) ) {
/* validate setting */
if ( is_array( $input[$setting['id']] ) && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) {
/* required title setting */
$required_setting = array(
array(
'id' => 'title',
'label' => __( 'Title', 'option-tree' ),
'desc' => '',
'std' => '',
'type' => 'text',
'rows' => '',
'class' => 'option-tree-setting-title',
'post_type' => '',
'choices' => array()
)
);
/* get the settings array */
$settings = isset( $_POST[$setting['id'] . '_settings_array'] ) ? unserialize( base64_decode( $_POST[$setting['id'] . '_settings_array'] ) ) : array();
/* settings are empty for some odd ass reason get the defaults */
if ( empty( $settings ) ) {
$settings = 'slider' == $setting['type'] ?
ot_slider_settings( $setting['id'] ) :
ot_list_item_settings( $setting['id'] );
}
/* merge the two settings array */
$settings = array_merge( $required_setting, $settings );
foreach( $input[$setting['id']] as $k => $setting_array ) {
foreach( $settings as $sub_setting ) {
/* verify sub setting has a type & value */
if ( isset( $sub_setting['type'] ) && isset( $input[$setting['id']][$k][$sub_setting['id']] ) ) {
$input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting( $input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] );
}
}
}
} else {
$input[$setting['id']] = ot_validate_setting( $input[$setting['id']], $setting['type'], $setting['id'] );
}
}
}
}
}
return $input;
}
/**
* Helper function to get the pages array for an option
*
* @param array Option array
* @return mixed
*
* @access public
* @since 2.0
*/
public function get_pages( $option = array() ) {
if ( empty( $option ) )
return false;
/* check for pages */
if ( isset( $option['pages'] ) && ! empty( $option['pages'] ) ) {
/* return pages array */
return $option['pages'];
}
return false;
}
/**
* Helper function to get the sections array for a page
*
* @param array Page array
* @return mixed
*
* @access public
* @since 2.0
*/
public function get_sections( $page = array() ) {
if ( empty( $page ) )
return false;
/* check for sections */
if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) {
/* return sections array */
return $page['sections'];
}
return false;
}
/**
* Helper function to get the settings array for a page
*
* @param array Page array
* @return mixed
*
* @access public
* @since 2.0
*/
public function get_settings( $page = array() ) {
if ( empty( $page ) )
return false;
/* check for settings */
if ( isset( $page['settings'] ) && ! empty( $page['settings'] ) ) {
/* return settings array */
return $page['settings'];
}
return false;
}
/**
* Prints out all settings sections added to a particular settings page
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
*
* @param string The slug name of the page whos settings sections you want to output
* @return string
*
* @access public
* @since 2.0
*/
public function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields;
if ( ! isset( $wp_settings_sections ) || ! isset( $wp_settings_sections[$page] ) ) {
return false;
}
foreach ( (array) $wp_settings_sections[$page] as $section ) {
if ( ! isset( $section['id'] ) )
continue;
echo '<div id="section_' . $section['id'] . '" class="postbox ui-tabs-panel">';
call_user_func( $section['callback'], $section );
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[$page] ) || ! isset( $wp_settings_fields[$page][$section['id']] ) )
continue;
echo '<div class="inside">';
$this->do_settings_fields( $page, $section['id'] );
echo '</div>';
echo '</div>';
}
}
/**
* Print out the settings fields for a particular settings section
*
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
*
* @param string $page Slug title of the admin page who's settings fields you want to show.
* @param string $section Slug title of the settings section who's fields you want to show.
* @return string
*
* @access public
* @since 2.0
*/
public function do_settings_fields( $page, $section ) {
global $wp_settings_fields;
if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
return;
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
echo '<div class="format-settings">';
if ( $field['args']['type'] != 'textblock' ) {
echo '<div class="format-setting-label">';
echo '<h3 class="label">' . $field['title'] . '</h3>';
echo '</div>';
}
call_user_func( $field['callback'], $field['args'] );
echo '</div>';
}
}
/**
* Resets page options before the screen is displayed
*
* @return void
*
* @access public
* @since 2.0
*/
public function reset_options() {
/* check for reset action */
if ( isset( $_POST['option_tree_reset_nonce'] ) && wp_verify_nonce( $_POST['option_tree_reset_nonce'], 'option_tree_reset_form' ) ) {
/* loop through options */
foreach( (array) $this->options as $option ) {
/* loop through pages */
foreach( (array) $this->get_pages( $option ) as $page ) {
/* verify page */
if ( isset( $_GET['page'] ) && $_GET['page'] == $page['menu_slug'] ) {
/* reset options */
delete_option( $option['id'] );
}
}
}
}
return false;
}
}
}
/**
* This method instantiates the settings class & builds the UI.
*
* @uses OT_Settings()
*
* @param array Array of arguments to create settings
* @return void
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_register_settings' ) ) {
function ot_register_settings( $args ) {
if ( ! $args )
return;
$ot_settings =& new OT_Settings( $args );
}
}
/* End of file ot-settings-api.php */
/* Location: ./includes/ot-settings-api.php */

View File

@ -0,0 +1,225 @@
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
/**
* Builds the Setting & Documentation UI.
*
* @uses ot_register_settings()
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
*/
if ( function_exists( 'ot_register_settings' ) ) {
ot_register_settings( array(
array(
'id' => 'option_tree_settings',
'pages' => apply_filters( 'ot_register_pages_array', array(
array(
'id' => 'ot',
'page_title' => __( 'OptionTree', 'option-tree' ),
'menu_title' => __( 'OptionTree', 'option-tree' ),
'capability' => 'manage_options',
'menu_slug' => 'ot-settings',
'icon_url' => OT_URL . '/assets/images/ot-logo-mini.png',
'position' => 61,
'hidden_page' => true
),
array(
'id' => 'settings',
'parent_slug' => 'ot-settings',
'page_title' => __( 'Settings', 'option-tree' ),
'menu_title' => __( 'Settings', 'option-tree' ),
'capability' => 'manage_options',
'menu_slug' => 'ot-settings',
'icon_url' => null,
'position' => null,
'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
'reset_message' => __( 'Theme Options reset.', 'option-tree' ),
'button_text' => __( 'Save Settings', 'option-tree' ),
'show_buttons' => false,
'screen_icon' => 'themes',
'sections' => array(
array(
'id' => 'create_setting',
'title' => __( 'Theme Options UI', 'option-tree' )
),
array(
'id' => 'import',
'title' => __( 'Import', 'option-tree' )
),
array(
'id' => 'export',
'title' => __( 'Export', 'option-tree' )
),
array(
'id' => 'layouts',
'title' => __( 'Layouts', 'option-tree' )
)
),
'settings' => array(
array(
'id' => 'theme_options_ui_text',
'label' => __( 'Theme Options UI Builder', 'option-tree' ),
'type' => 'theme_options_ui',
'section' => 'create_setting'
),
array(
'id' => 'import_xml_text',
'label' => __( 'Settings XML', 'option-tree' ),
'type' => 'import-xml',
'section' => 'import'
),
array(
'id' => 'import_settings_text',
'label' => __( 'Settings', 'option-tree' ),
'type' => 'import-settings',
'section' => 'import'
),
array(
'id' => 'import_data_text',
'label' => __( 'Theme Options', 'option-tree' ),
'type' => 'import-data',
'section' => 'import'
),
array(
'id' => 'import_layouts_text',
'label' => __( 'Layouts', 'option-tree' ),
'type' => 'import-layouts',
'section' => 'import'
),
array(
'id' => 'export_settings_file_text',
'label' => __( 'Settings PHP File', 'option-tree' ),
'type' => 'export-settings-file',
'section' => 'export'
),
array(
'id' => 'export_settings_text',
'label' => __( 'Settings', 'option-tree' ),
'type' => 'export-settings',
'section' => 'export'
),
array(
'id' => 'export_data_text',
'label' => __( 'Theme Options', 'option-tree' ),
'type' => 'export-data',
'section' => 'export'
),
array(
'id' => 'export_layout_text',
'label' => __( 'Layouts', 'option-tree' ),
'type' => 'export-layouts',
'section' => 'export'
),
array(
'id' => 'modify_layouts_text',
'label' => __( 'Add, Activate, & Remove Layouts', 'option-tree' ),
'type' => 'modify-layouts',
'section' => 'layouts'
)
)
),
array(
'id' => 'documentation',
'parent_slug' => 'ot-settings',
'page_title' => __( 'Documentation', 'option-tree' ),
'menu_title' => __( 'Documentation', 'option-tree' ),
'capability' => 'manage_options',
'menu_slug' => 'ot-documentation',
'icon_url' => null,
'position' => null,
'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
'reset_message' => __( 'Theme Options reset.', 'option-tree' ),
'button_text' => __( 'Save Settings', 'option-tree' ),
'show_buttons' => false,
'screen_icon' => 'themes',
'sections' => array(
array(
'id' => 'creating_options',
'title' => __( 'Creating Options', 'option-tree' )
),
array(
'id' => 'option_types',
'title' => __( 'Option Types', 'option-tree' )
),
array(
'id' => 'functions',
'title' => __( 'Function References', 'option-tree' )
),
array(
'id' => 'theme_mode',
'title' => __( 'Theme Mode', 'option-tree' )
),
array(
'id' => 'meta_boxes',
'title' => __( 'Meta Boxes', 'option-tree' )
),
array(
'id' => 'examples',
'title' => __( 'Code Examples', 'option-tree' )
),
array(
'id' => 'layouts_overview',
'title' => __( 'Layouts Overview', 'option-tree' )
)
),
'settings' => array(
array(
'id' => 'creating_options_text',
'label' => __( 'Overview of available Theme Option fields.', 'option-tree' ),
'type' => 'creating-options',
'section' => 'creating_options'
),
array(
'id' => 'option_types_text',
'label' => __( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ),
'type' => 'option-types',
'section' => 'option_types'
),
array(
'id' => 'functions_ot_get_option',
'label' => __( 'Function Reference:ot_get_option()', 'option-tree' ),
'type' => 'ot-get-option',
'section' => 'functions'
),
array(
'id' => 'functions_get_option_tree',
'label' => __( 'Function Reference:get_option_tree()', 'option-tree' ),
'type' => 'get-option-tree',
'section' => 'functions'
),
array(
'id' => 'theme_mode_text',
'label' => __( 'Theme Mode', 'option-tree' ),
'type' => 'theme-mode',
'section' => 'theme_mode'
),
array(
'id' => 'meta_boxes_text',
'label' => __( 'Meta Boxes', 'option-tree' ),
'type' => 'meta-boxes',
'section' => 'meta_boxes'
),
array(
'id' => 'example_text',
'label' => __( 'Code examples for front-end development.', 'option-tree' ),
'type' => 'examples',
'section' => 'examples'
),
array(
'id' => 'layouts_overview_text',
'label' => __( 'What\'s a layout anyhow?', 'option-tree' ),
'type' => 'layouts-overview',
'section' => 'layouts_overview'
)
)
)
) )
)
)
);
}
/* End of file ot-ui-admin.php */
/* Location: ./option-tree/ot-ui-admin.php */

View File

@ -0,0 +1,56 @@
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
/**
* Builds the Theme Option UI.
*
* @uses ot_register_settings()
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
*/
/* get the settings array */
$get_settings = get_option( 'option_tree_settings' );
/* sections array */
$sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
/* settings array */
$settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
/* contexual_help array */
$contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
/* build the Theme Options */
if ( function_exists( 'ot_register_settings' ) ) {
ot_register_settings( array(
array(
'id' => 'option_tree',
'pages' => array(
array(
'id' => 'ot_theme_options',
'parent_slug' => 'themes.php',
'page_title' => __( 'Theme Options', 'option-tree' ),
'menu_title' => __( 'Theme Options', 'option-tree' ),
'capability' => 'manage_options',
'menu_slug' => 'ot-theme-options',
'icon_url' => null,
'position' => null,
'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
'reset_message' => __( 'Theme Options reset.', 'option-tree' ),
'button_text' => __( 'Save Changes', 'option-tree' ),
'screen_icon' => 'themes',
'contextual_help' => $contextual_help,
'sections' => $sections,
'settings' => $settings
)
)
)
)
);
}
/* End of file ot-ui-theme-options.php */
/* Location: ./option-tree/ot-ui-theme-options.php */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,374 @@
<?php
/**
* Plugin Name: OptionTree
* Plugin URI: http://wp.envato.com
* Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
* Version: 2.0.9
* Author: Derek Herman
* Author URI: http://valendesigns.com
* License: GPLv2
*/
/**
* This is the OptionTree loader class.
*
* @package OptionTree
* @author Derek Herman <derek@valendesigns.com>
* @copyright Copyright (c) 2012, Derek Herman
*/
if ( ! class_exists( 'OT_Loader' ) ) {
class OT_Loader {
/**
* PHP5 constructor method.
*
* This method loads other methods of the class.
*
* @return void
*
* @access public
* @since 2.0
*/
public function __construct() {
/* setup the constants */
$this->constants();
/* load text domain */
$this->load_textdomain();
/* include the required admin files */
$this->admin_includes();
/* include the required files */
$this->includes();
/* hook into WordPress */
$this->hooks();
}
/**
* Constants
*
* Defines the constants for use within OptionTree. Constants
* are prefixed with 'OT_' to avoid any naming collisions.
*
* @return void
*
* @access private
* @since 2.0
*/
public function constants() {
/**
* Current Version number.
*/
define( 'OT_VERSION', '2.0.9' );
/**
* For developers: Allow Unfiltered HTML in all the textareas.
*
* Run a filter and set to true if you want all the
* users to be able to post anything in the textareas.
* WARNING: This opens a security hole for low level users
* to be able to post malicious scripts, you've been warned.
*
* @since 2.0
*/
define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) );
/**
* For developers: Theme mode.
*
* Run a filter and set to true to enable OptionTree theme mode.
* You must have this files parent directory inside of
* your themes root directory. As well, you must include
* a reference to this file in your themes functions.php.
*
* @since 2.0
*/
define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) );
/**
* For developers: Show Pages.
*
* Run a filter and set to false if you don't want to load the
* settings & documentation pages in the admin area of WordPress.
*
* @since 2.0
*/
define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) );
/**
* For developers: Meta Boxes.
*
* Run a filter and set to false to keep OptionTree from
* loading the meta box resources.
*
* @since 2.0
*/
define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) );
/**
* Check if in theme mode.
*
* If theme mode is false then set the directory path & URL
* like it's a plugin. Else make it look in the parent
* theme root directory or child theme directory if
* OT_CHILD_MODE is set to true.
*
* @since 2.0
*/
if ( false == OT_THEME_MODE ) {
define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
define( 'OT_URL', plugin_dir_url( __FILE__ ) );
} else {
define( 'OT_DIR', trailingslashit( get_template_directory() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
define( 'OT_URL', trailingslashit( get_template_directory_uri() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
}
}
/**
* Load the text domain.
*
* @return void
*
* @access private
* @since 2.0
*/
public function load_textdomain() {
if ( false == OT_THEME_MODE ) {
load_plugin_textdomain( 'option-tree', false, OT_DIR . 'languages' );
} else {
load_theme_textdomain( 'option-tree', OT_DIR . 'languages' );
}
}
/**
* Include admin files
*
* These functions are included on admin pages only.
*
* @return void
*
* @access private
* @since 2.0
*/
public function admin_includes() {
/* exit early if we're not on an admin page */
if ( ! is_admin() )
return false;
/* global include files */
$files = array(
'ot-functions-admin',
'ot-functions-option-types',
'ot-functions-compat',
'ot-settings-api',
'ot-ui-theme-options'
);
/* include the meta box api */
if ( OT_META_BOXES == true ) {
$files[] = 'ot-meta-box-api';
}
/* include the settings & docs pages */
if ( OT_SHOW_PAGES == true ) {
$files[] = 'ot-functions-settings-page';
$files[] = 'ot-functions-docs-page';
$files[] = 'ot-ui-admin';
}
/* require the files */
foreach ( $files as $file ) {
require_once( OT_DIR . "includes/{$file}.php" );
}
}
/**
* Include front-end files
*
* These functions are included on every page load
* incase other plugins need to access them.
*
* @return void
*
* @access private
* @since 2.0
*/
public function includes() {
$files = array(
'ot-functions',
'ot-functions-deprecated'
);
/* require the files */
foreach ( $files as $file ) {
require_once( OT_DIR . "includes/{$file}.php" );
}
}
/**
* Execute the WordPress Hooks
*
* @return void
*
* @access public
* @since 2.0
*/
public function hooks() {
if ( OT_META_BOXES == true ) {
/* add scripts for metaboxes to post-new.php & post.php */
add_action( 'admin_print_scripts-post-new.php', 'ot_admin_scripts', 11 );
add_action( 'admin_print_scripts-post.php', 'ot_admin_scripts', 11 );
/* add styles for metaboxes to post-new.php & post.php */
add_action( 'admin_print_styles-post-new.php', 'ot_admin_styles', 11 );
add_action( 'admin_print_styles-post.php', 'ot_admin_styles', 11 );
}
/* prepares the after save do_action */
add_action( 'admin_init', 'ot_after_theme_options_save', 1 );
/* default settings */
add_action( 'admin_init', 'ot_default_settings', 2 );
/* add xml to upload filetypes array */
add_action( 'admin_init', 'ot_add_xml_to_upload_filetypes', 3 );
/* import */
add_action( 'admin_init', 'ot_import', 4 );
/* export */
add_action( 'admin_init', 'ot_export', 5 );
/* save settings */
add_action( 'admin_init', 'ot_save_settings', 6 );
/* save layouts */
add_action( 'admin_init', 'ot_modify_layouts', 7 );
/* create media post */
add_action( 'admin_init', 'ot_create_media_post', 8 );
/* global CSS */
add_action( 'admin_head', array( &$this, 'global_admin_css' ) );
/* dynamic front-end CSS */
add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css' );
/* insert theme CSS dynamically */
add_action( 'ot_after_theme_options_save', 'ot_save_css' );
/* AJAX call to create a new section */
add_action( 'wp_ajax_add_section', array( &$this, 'add_section' ) );
/* AJAX call to create a new setting */
add_action( 'wp_ajax_add_setting', array( &$this, 'add_setting' ) );
/* AJAX call to create a new contextual help */
add_action( 'wp_ajax_add_contextual_help', array( &$this, 'add_contextual_help' ) );
/* AJAX call to create a new choice */
add_action( 'wp_ajax_add_choice', array( &$this, 'add_choice' ) );
/* AJAX call to create a new list item setting */
add_action( 'wp_ajax_add_list_item_setting', array( &$this, 'add_list_item_setting' ) );
/* AJAX call to create a new layout */
add_action( 'wp_ajax_add_layout', array( &$this, 'add_layout' ) );
/* AJAX call to create a new list item */
add_action( 'wp_ajax_add_list_item', array( &$this, 'add_list_item' ) );
}
/**
* Adds the global CSS to fix the menu icon.
*/
public function global_admin_css() {
echo '
<style>
#adminmenu #toplevel_page_ot-settings .wp-menu-image img { padding: 4px 0px 1px 2px !important; }
</style>
';
}
/**
* AJAX utility function for adding a new section.
*/
public function add_section() {
echo ot_sections_view( 'option_tree_settings[sections]', $_REQUEST['count'] );
die();
}
/**
* AJAX utility function for adding a new setting.
*/
public function add_setting() {
echo ot_settings_view( $_REQUEST['name'], $_REQUEST['count'] );
die();
}
/**
* AJAX utility function for adding a new list item setting.
*/
public function add_list_item_setting() {
echo ot_settings_view( $_REQUEST['name'] . '[settings]', $_REQUEST['count'] );
die();
}
/**
* AJAX utility function for adding new contextual help content.
*/
public function add_contextual_help() {
echo ot_contextual_help_view( $_REQUEST['name'], $_REQUEST['count'] );
die();
}
/**
* AJAX utility function for adding a new choice.
*/
public function add_choice() {
echo ot_choices_view( $_REQUEST['name'], $_REQUEST['count'] );
die();
}
/**
* AJAX utility function for adding a new layout.
*/
public function add_layout() {
echo ot_layout_view( $_REQUEST['count'] );
die();
}
/**
* AJAX utility function for adding a new list item.
*/
public function add_list_item() {
ot_list_item_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( base64_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
die();
}
}
/**
* Instantiate the OptionTree loader class.
*
* @since 2.0
*/
$ot_loader =& new OT_Loader();
}
/* End of file ot-loader.php */
/* Location: ./ot-loader.php */

View File

@ -0,0 +1,204 @@
=== OptionTree ===
Contributors: valendesigns
Donate link: http://bit.ly/NuXI3T
Tags: admin, theme options, meta boxes, options, admin interface, ajax
Requires at least: 3.3
Tested up to: 3.5
Stable tag: 2.0.9
License: GPLv2
Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
== Description ==
Theme Options are what make a WordPress Theme truly custom. OptionTree attempts to bridge the gap between developers, designers and end-users by solving the admin User Interface issues that arise when creating a custom theme. Designers shouldn't have to be limited to what they can create visually because their programming skills aren't as developed as they would like. Also, programmers shouldn't have to recreate the wheel for every new project, so in walks OptionTree.
With OptionTree you can create as many Theme Options as your project requires and use them how you see fit. When you add a option to the Settings page, it will be available on the Theme Options page for use in your theme.
Included is the ability to Import/Export all the theme options and data for packaging with custom themes or local development. With the Import/Export feature you can get a theme set up on a live server in minutes. Theme authors can now create different version of their themes and include them with the download. It makes setting up different theme styles & options easier than ever because a theme user installs the plugin and theme and either adds their own settings or imports your defaults.
A new feature in OptionTree 2.0 is the ability to include the plugin directly in your themes root directory. Not only does that mean your theme is guaranteed to have the plugin installed you also get the ability to interact directly with OptionTree through settings and meta box arrays. You can now tell OptionTree what settings you want and know that nobody will break your theme by changing settings through the UI Builder. It's just a better plugin now!
OptionTree is a project sponsored by <a href="http://themeforest.net/?ref=valendesigns">ThemeForest</a>, the largest WordPress theme marketplace on the web, and was originally conceived to help ThemeForest authors quickly power up their themes. But it's here for the benefit of one and all, so option up folks!
== Installation ==
1. Upload `option-tree` to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Click the `OptionTree->Documentation` link in the WordPress admin sidebar menu for further setup assistance.
== Frequently Asked Questions ==
= Is this plugin PHP5 only? =
Yes. OptionTree requires PHP5 to work correctly (so does WP 3.2+).
== Screenshots ==
1. Theme Options
2. Settings
3. Documentation
== Changelog ==
= 2.0.9 =
* Fixed the issue where the Textarea Simple and CSS option types were mysteriously being ran through wpautop.
* Added missing class setting to Textarea, Textarea Simple, & CSS option types.
* Fixed theme-options.php exported array where label values were not correct.
* Change GET to POST for all AJAX calls to fix a bug where some servers would not allow long strings to be passed in GET variables.
* Added the 'ot_after_validate_setting' filter to the validation function.
* Added $field_id to the ot_validate_setting() for more precise filtering.
* Added the ot_reverse_wpautop() function that you can run input through just incase you need it.
* Updated the docs to include information on why WYSIWYG editors are not allowed in meta boxes and that they revert to a Textarea Simple.
* Update option-tree.pot file.
= 2.0.8 =
* Add auto import for backwards compatibility of old 1.x files.
* Added the ability to export settings into a fully functional theme-options.php.
* Fix typo in docs regarding the filter demo code.
* Removed slashes in the section and contextual help titles.
* Made colorpicker input field alignment more cross browser compatible.
= 2.0.7 =
* Fixed the load order to be compatible with 1.x version themes that think the get_option_tree() function doesn't exist yet.
* Tested and compatible with Cudazi themes, but the nag message is still visible.
= 2.0.6 =
* Run the 'option_tree' array through validation when importing data and layouts.
* Fix a bug where list items and sliders were not allowing the user to select the input field.
* Add a filter that allows you to not load resources for meta boxes if you're not going to use them.
* Update option-tree.pot file.
= 2.0.5 =
* Change the way the 'option_tree_settings' array validates. Strip out those damn slashes!
= 2.0.4 =
* Run the 'option_tree' array through validation when upgrading from the 1.0 branch to the 2.0 branch for the first time.
* Fix a typo in the slider array where textarea's were not saving the first time due to an incorrect array key.
= 2.0.3 =
* Had an incorrect conditional statement causing an issue where the plugin was attempting to create the 'option-tree' image attachment page, even though it was already created.
* The above also fixed a conflict with 'The Events Calendar' plugin.
= 2.0.2 =
* Added I18n support, let the translations begin. The option-tree.pot file is inside the languages directory.
* Trim whitespace on imported choices array.
* Fixed the CSS insert function not having a value to save.
= 2.0.1 =
* Import from table was not mapping settings correctly. It is now.
= 2.0 =
* Complete rewrite form the ground up.
* Better Theme Options UI Builder.
* New in-plugin documentation.
* Brand new responsive UI.
* Add new option types, most notable the List Item which should eventually replace the Slider.
* Added the simpler ot_get_option() function to eventually replace get_option_tree().
* Added support for Meta Boxes.
* Added Theme Mode where you can now include the plugin directly in your theme.
* Better validation on saved data.
* Simplified the import process.
* Added support for contextual help.
* Permanently move the Theme Option to the Appearance tab.
* Added a ton of filters.
* Made huge improvements to the code base and tested rigorously.
= 1.1.8.1 =
* Removed get_option_tree() in the WordPress admin area due to theme conflicts.
* Removed demo files in the assets folder at the request of WordPress
= 1.1.8 =
* Fixed scrolling issue on extra tall pages
* Added ability to show/hide settings & documentation via the User Profile page.
* Added Background option type.
* Added Typography option type.
* Added CSS option type.
* Better looking selects with 1=Yes,2=No where '1' is the value and 'Yes' is the text in the select.
* Made the AJAX message CSS more prominent.
* functions.load.php will now only load option type functions if viewing an OT admin page.
* Deregistered the custom jQuery UI in the 'Cispm Mail Contact' plugin when viewing an OptionTree page.
* Can now save layouts from the Theme Options page.
* You can now change the slider fields by targeting a specific "Option Key"
* Modified upload for situations where you manually enter a relative path
* Allow get_option_tree() function to be used in WP admin
* Changed permissions to edit_theme_options
= 1.1.7.1 =
* Revert functions.load.php, will fix and update in next version
= 1.1.7 =
* Added layout (theme variation) support with save/delete/activate/import/export capabilities. Contributions form Brian of flauntbooks.com
* Allow layout change on Theme Options page.
* Full Multisite compatibility by manually adding xml mime type for import options.
* Replaced eregi() with preg_match() for 5.3+ compatibility.
* Changed test data in the assets directory for new layout option.
* Made it so when the slider & upload image changes it's reflected on blur.
* Gave the slider image an upload button.
* Added do_action('option_tree_import_data') to option_tree_import_data() function before exit.
* Added do_action('option_tree_array_save') to option_tree_array_save() function before exit.
* Added do_action('option_tree_save_layout') to option_tree_save_layout() function before exit.
* Added do_action('option_tree_delete_layout') to option_tree_delete_layout() function before exit.
* Added do_action('option_tree_activate_layout') to option_tree_activate_layout() function before exit.
* Added do_action('option_tree_import_layout') to option_tree_import_layout() function before redirect.
* Added do_action('option_tree_admin_header') hook before all admin pages.
* Fixed bug where users could add a color without a hash.
* Only load option type function on Theme Options page
* Loading resources with absolute paths, no longer relative.
* Fixed a bug with uploader creating extra option-tree draft pages.
* Fixed slider toggle bug, now the sliders close when you open another or create new slide.
= 1.1.6 =
* Theme Integration added.
* Made the upload XML file openbase_dir compliant.
= 1.1.5 =
* Fixed multiple sliders issue
= 1.1.4 =
* Patch for get_option_tree() $is_array being false and still returning an array
= 1.1.3 =
* 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
= 1.1.2 =
* Fixed double quotes in Textarea option type
* Added Measurement option type for CSS values
* Fixed Post option type only returning 5 items
* Added a scrolling window for checkboxes > 10
= 1.1.1 =
* Fixed the 'remove' icon from showing when nothing's uploaded
= 1.1 =
* Fixed the Undefined index: notices when WP_DEBUG is set to true
= 1.0.0 =
* Initial version
== Upgrade Notice ==
= 2.0.9 =
The plugin has undertaken a complete rebuild! If you are not the theme developer, I urge you to contact that person before you upgrade and ask them to test the themes compatibility.
= 1.1.8.1 =
Removed get_option_tree() in the WordPress admin area due to theme conflicts.
= 1.1.8 =
Added Typography, Background, & CSS option types. Lots of way to extend them, as well.
= 1.1.7 =
Lots of additions, none critical just fun. Added layouts & upload to slider. As well, started including action hooks for extending and integrating with other plugins.
= 1.1.6 =
Added theme integration for developers. It's now possible to have a default XML file included in your theme to populate the theme options and hide the settings and docs pages. Read more about this in the plugins built in documentation.
= 1.1.5 =
Having multiple sliders caused a naming collision in the JavaScript and is now fixed. Upgrade ASAP to have multiple sliders available in the UI.
= 1.1.4 =
Fixed the returned value of the get_option_tree() function when $is_array is set to false. If you have created any slider or measurement option types please read the updated documentation for examples on how to use them in your theme.

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB