|
1 <?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' ); |
|
2 /** |
|
3 * OptionTree documentation page functions. |
|
4 * |
|
5 * @package OptionTree |
|
6 * @author Derek Herman <derek@valendesigns.com> |
|
7 * @copyright Copyright (c) 2013, Derek Herman |
|
8 * @since 2.0 |
|
9 */ |
|
10 |
|
11 /** |
|
12 * Creating Options option type. |
|
13 * |
|
14 * @return string |
|
15 * |
|
16 * @access public |
|
17 * @since 2.0 |
|
18 */ |
|
19 if ( ! function_exists( 'ot_type_creating_options' ) ) { |
|
20 |
|
21 function ot_type_creating_options() { |
|
22 |
|
23 /* format setting outer wrapper */ |
|
24 echo '<div class="format-setting type-textblock wide-desc">'; |
|
25 |
|
26 /* description */ |
|
27 echo '<div class="description">'; |
|
28 |
|
29 echo '<h4>'. __( 'Label', 'option-tree' ) . ':</h4>'; |
|
30 echo '<p>' . __( 'The Label field should be a short but descriptive block of text 100 characters or less with no HTML.', 'option-tree' ) . '</p>'; |
|
31 |
|
32 echo '<h4>'. __( 'ID', 'option-tree' ) . ':</h4>'; |
|
33 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>'; |
|
34 |
|
35 echo '<h4>'. __( 'Type', 'option-tree' ) . ':</h4>'; |
|
36 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>'; |
|
37 |
|
38 echo '<ul class="docs-ul">'; |
|
39 foreach( ot_option_types_array() as $key => $value ) |
|
40 echo '<li>' . $value . '</li>'; |
|
41 echo '</ul>'; |
|
42 |
|
43 echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>'; |
|
44 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>'; |
|
45 |
|
46 echo '<h4>'. __( 'Choices', 'option-tree' ) . ':</h4>'; |
|
47 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>'; |
|
48 |
|
49 echo '<h4>'. __( 'Settings', 'option-tree' ) . ':</h4>'; |
|
50 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>'; |
|
51 |
|
52 echo '<h4>'. __( 'Standard', 'option-tree' ) . ':</h4>'; |
|
53 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>'; |
|
54 |
|
55 echo '<h4>'. __( 'Rows', 'option-tree' ) . ':</h4>'; |
|
56 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>'; |
|
57 |
|
58 echo '<h4>'. __( 'Post Type', 'option-tree' ) . ':</h4>'; |
|
59 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>'; |
|
60 |
|
61 echo '<ul class="docs-ul">'; |
|
62 echo '<li><code>post</code></li>'; |
|
63 echo '<li><code>page</code></li>'; |
|
64 echo '<li><code>attachment</code></li>'; |
|
65 echo '</ul>'; |
|
66 |
|
67 echo '<h4>'. __( 'Taxonomy', 'option-tree' ) . ':</h4>'; |
|
68 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>'; |
|
69 |
|
70 echo '<h4>'. __( 'Min, Max, & Step', 'option-tree' ) . ':</h4>'; |
|
71 echo '<p>' . __( 'Add a comma separated list of options in the following format <code>0,100,1</code> (slide from <code>0-100</code> in intervals of <code>1</code>). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' ) . '</p>'; |
|
72 |
|
73 echo '<h4>'. __( 'CSS Class', 'option-tree' ) . ':</h4>'; |
|
74 echo '<p>' . __( 'Add and optional class to any option type.', 'option-tree' ) . '</p>'; |
|
75 |
|
76 echo '</div>'; |
|
77 |
|
78 echo '</div>'; |
|
79 |
|
80 } |
|
81 |
|
82 } |
|
83 |
|
84 /** |
|
85 * ot_get_option() option type. |
|
86 * |
|
87 * This is a callback function to display text about ot_get_option(). |
|
88 * |
|
89 * @return string |
|
90 * |
|
91 * @access public |
|
92 * @since 2.0 |
|
93 */ |
|
94 if ( ! function_exists( 'ot_type_option_types' ) ) { |
|
95 |
|
96 function ot_type_option_types() { |
|
97 |
|
98 /* format setting outer wrapper */ |
|
99 echo '<div class="format-setting type-textblock wide-desc">'; |
|
100 |
|
101 /* description */ |
|
102 echo '<div class="description">'; |
|
103 |
|
104 echo '<h4>'. __( 'Background', 'option-tree' ) . ':</h4>'; |
|
105 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>'; |
|
106 |
|
107 echo '<h4>'. __( 'Category Select', 'option-tree' ) . ':</h4>'; |
|
108 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>'; |
|
109 |
|
110 echo '<h4>'. __( 'Category Checkbox', 'option-tree' ) . ':</h4>'; |
|
111 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>'; |
|
112 |
|
113 echo '<h4>'. __( 'Checkbox', 'option-tree' ) . ':</h4>'; |
|
114 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>'; |
|
115 |
|
116 echo '<h4>'. __( 'Colorpicker', 'option-tree' ) . ':</h4>'; |
|
117 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>'; |
|
118 |
|
119 echo '<h4>'. __( 'CSS', 'option-tree' ) . ':</h4>'; |
|
120 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>'; |
|
121 |
|
122 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>'; |
|
123 |
|
124 echo '<p>'. __( 'Input', 'option-tree' ) . ':</p>'; |
|
125 echo '<pre><code>body { |
|
126 {{custom_background_css}} |
|
127 background-color: {{custom_background_css|background-color}}; |
|
128 }</code></pre>'; |
|
129 |
|
130 echo '<p>'. __( 'Output', 'option-tree' ) . ':</p>'; |
|
131 echo '<pre><code>/* BEGIN custom_background_css */ |
|
132 body { |
|
133 background: color image repeat attachment position; |
|
134 background-color: color; |
|
135 } |
|
136 /* END custom_background_css */</code></pre>'; |
|
137 |
|
138 echo '<h4>'. __( 'Custom Post Type Select', 'option-tree' ) . ':</h4>'; |
|
139 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>'; |
|
140 |
|
141 echo '<h4>'. __( 'Custom Post Type Checkbox', 'option-tree' ) . ':</h4>'; |
|
142 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>'; |
|
143 |
|
144 echo '<h4>'. __( 'List Item', 'option-tree' ) . ':</h4>'; |
|
145 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>'; |
|
146 |
|
147 echo '<h4>'. __( 'Measurement', 'option-tree' ) . ':</h4>'; |
|
148 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>'; |
|
149 |
|
150 echo '<p>' . __( 'Example filter to add new units to the Measurement option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>'; |
|
151 echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) { |
|
152 |
|
153 /* only run the filter on measurement with a field ID of my_measurement */ |
|
154 if ( $field_id == \'my_measurement\' ) { |
|
155 $array[\'in\'] = \'inches\'; |
|
156 $array[\'ft\'] = \'feet\'; |
|
157 } |
|
158 |
|
159 return $array; |
|
160 } |
|
161 add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>'; |
|
162 |
|
163 echo '<p>' . __( 'Example filter to completely change the units in the Measurement option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>'; |
|
164 echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) { |
|
165 |
|
166 /* only run the filter on measurement with a field ID of my_measurement */ |
|
167 if ( $field_id == \'my_measurement\' ) { |
|
168 $array = array( |
|
169 \'in\' => \'inches\', |
|
170 \'ft\' => \'feet\' |
|
171 ); |
|
172 } |
|
173 |
|
174 return $array; |
|
175 } |
|
176 add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>'; |
|
177 |
|
178 echo '<h4>'. __( 'Numeric Slider', 'option-tree' ) . ':</h4>'; |
|
179 echo '<p>' . __( 'The Numeric Slider option type displays a jQuery UI slider. It will return a single numerical value for use in a custom function or loop.', 'option-tree' ) . '</p>'; |
|
180 |
|
181 echo '<h4>'. __( 'Page Select', 'option-tree' ) . ':</h4>'; |
|
182 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>'; |
|
183 |
|
184 echo '<h4>'. __( 'Page Checkbox', 'option-tree' ) . ':</h4>'; |
|
185 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>'; |
|
186 |
|
187 echo '<h4>'. __( 'Post Select', 'option-tree' ) . ':</h4>'; |
|
188 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>'; |
|
189 |
|
190 echo '<h4>'. __( 'Post Checkbox', 'option-tree' ) . ':</h4>'; |
|
191 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>'; |
|
192 |
|
193 echo '<h4>'. __( 'Radio', 'option-tree' ) . ':</h4>'; |
|
194 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>'; |
|
195 |
|
196 echo '<h4>'. __( 'Radio Image', 'option-tree' ) . ':</h4>'; |
|
197 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>'; |
|
198 |
|
199 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>'; |
|
200 echo '<pre><code>function filter_radio_images( $array, $field_id ) { |
|
201 |
|
202 /* only run the filter where the field ID is my_radio_images */ |
|
203 if ( $field_id == \'my_radio_images\' ) { |
|
204 $array = array( |
|
205 array( |
|
206 \'value\' => \'left-sidebar\', |
|
207 \'label\' => __( \'Left Sidebar\', \'option-tree\' ), |
|
208 \'src\' => OT_URL . \'/assets/images/layout/left-sidebar.png\' |
|
209 ), |
|
210 array( |
|
211 \'value\' => \'right-sidebar\', |
|
212 \'label\' => __( \'Right Sidebar\', \'option-tree\' ), |
|
213 \'src\' => OT_URL . \'/assets/images/layout/right-sidebar.png\' |
|
214 ) |
|
215 ); |
|
216 } |
|
217 |
|
218 return $array; |
|
219 |
|
220 } |
|
221 add_filter( \'ot_radio_images\', \'filter_radio_images\', 10, 2 );</code></pre>'; |
|
222 |
|
223 echo '<h4>'. __( 'Select', 'option-tree' ) . ':</h4>'; |
|
224 echo '<p>' . __( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'option-tree' ) . '</p>'; |
|
225 |
|
226 echo '<h4>'. __( 'Sidebar Select', 'option-tree' ) . ':</h4>'; |
|
227 echo '<p>' . __( 'This option type makes it possible for users to select a WordPress registered sidebar to use on a specific area. By using the two provided filters, <code>ot_recognized_sidebars</code>, and <code>ot_recognized_sidebars_{$field_id}</code> we can be selective about which sidebars are available on a specific content area.', 'option-tree' ) . '</p>'; |
|
228 echo '<p>' . __( 'For example, if we create a WordPress theme that provides the ability to change the Blog Sidebar and we don\'t want to have the footer sidebars available on this area, we can unset those sidebars either manually or by using a regular expression if we have a common name like <code>footer-sidebar-$i</code>.', 'option-tree' ) . '</p>'; |
|
229 |
|
230 echo '<h4>'. __( 'Slider', 'option-tree' ) . ':</h4>'; |
|
231 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>'; |
|
232 |
|
233 echo '<h4>'. __( 'Tag Checkbox', 'option-tree' ) . ':</h4>'; |
|
234 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>'; |
|
235 |
|
236 echo '<h4>'. __( 'Tag Select', 'option-tree' ) . ':</h4>'; |
|
237 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>'; |
|
238 |
|
239 echo '<h4>'. __( 'Taxonomy Checkbox', 'option-tree' ) . ':</h4>'; |
|
240 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>'; |
|
241 |
|
242 echo '<h4>'. __( 'Taxonomy Select', 'option-tree' ) . ':</h4>'; |
|
243 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>'; |
|
244 |
|
245 echo '<h4>'. __( 'Text (Input)', 'option-tree' ) . ':</h4>'; |
|
246 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>'; |
|
247 |
|
248 echo '<h4>'. __( 'Textarea', 'option-tree' ) . ':</h4>'; |
|
249 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>'; |
|
250 |
|
251 echo '<p class="aside">' . __( 'Example filters to alter the Textarea option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>'; |
|
252 |
|
253 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>'; |
|
254 echo '<pre><code>function filter_textarea_wpautop( $content, $field_id ) { |
|
255 |
|
256 /* only run the filter on the textarea with a field ID of my_textarea */ |
|
257 if ( $field_id == \'my_textarea\' ) { |
|
258 return false; |
|
259 } |
|
260 |
|
261 return $content; |
|
262 |
|
263 } |
|
264 add_filter( \'ot_wpautop\', \'filter_textarea_wpautop\', 10, 1 );</code></pre>'; |
|
265 |
|
266 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>'; |
|
267 echo '<pre><code>function filter_textarea_media_buttons( $content, $field_id ) { |
|
268 |
|
269 /* only run the filter on the textarea with a field ID of my_textarea */ |
|
270 if ( $field_id == \'my_textarea\' ) { |
|
271 return false; |
|
272 } |
|
273 |
|
274 return $content; |
|
275 |
|
276 } |
|
277 add_filter( \'ot_media_buttons\', \'filter_textarea_media_buttons\', 10, 2 );</code></pre>'; |
|
278 |
|
279 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>'; |
|
280 echo '<pre><code>function filter_textarea_tinymce( $content, $field_id ) { |
|
281 |
|
282 /* only run the filter on the textarea with a field ID of my_textarea */ |
|
283 if ( $field_id == \'my_textarea\' ) { |
|
284 return false; |
|
285 } |
|
286 |
|
287 return $content; |
|
288 |
|
289 } |
|
290 add_filter( \'ot_tinymce\', \'filter_textarea_tinymce\', 10, 2 );</code></pre>'; |
|
291 |
|
292 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>'; |
|
293 echo '<pre><code>function filter_textarea_quicktags( $content, $field_id ) { |
|
294 |
|
295 /* only run the filter on the textarea with a field ID of my_textarea */ |
|
296 if ( $field_id == \'my_textarea\' ) { |
|
297 return array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close,fullscreen\' ); |
|
298 } else if ( $field_id == \'my_other_textarea\' ) { |
|
299 return false; /* show no quicktags */ |
|
300 } |
|
301 |
|
302 return $content; |
|
303 |
|
304 } |
|
305 add_filter( \'ot_quicktags\', \'filter_textarea_quicktags\', 10, 1 );</code></pre>'; |
|
306 |
|
307 echo '<h4>'. __( 'Textarea Simple', 'option-tree' ) . ':</h4>'; |
|
308 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>'; |
|
309 |
|
310 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>'; |
|
311 echo '<pre><code>function filter_textarea_simple_wpautop( $content, $field_id ) { |
|
312 |
|
313 /* only run the filter on the textarea with a field ID of my_textarea */ |
|
314 if ( $field_id == \'my_textarea\' ) { |
|
315 return true; |
|
316 } |
|
317 |
|
318 return $content; |
|
319 |
|
320 } |
|
321 add_filter( \'ot_wpautop\', \'filter_textarea_simple_wpautop\', 10, 2 );</code></pre>'; |
|
322 |
|
323 echo '<h4>'. __( 'Textblock', 'option-tree' ) . ':</h4>'; |
|
324 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>'; |
|
325 |
|
326 echo '<h4>'. __( 'Textblock Titled', 'option-tree' ) . ':</h4>'; |
|
327 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>'; |
|
328 |
|
329 echo '<h4>'. __( 'Typography', 'option-tree' ) . ':</h4>'; |
|
330 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>'; |
|
331 |
|
332 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>'; |
|
333 echo '<pre><code>function filter_ot_recognized_font_families( $array, $field_id ) { |
|
334 |
|
335 /* only run the filter when the field ID is my_google_fonts_headings */ |
|
336 if ( $field_id == \'my_google_fonts_headings\' ) { |
|
337 $array = array( |
|
338 \'sans-serif\' => \'sans-serif\', |
|
339 \'open-sans\' => \'"Open Sans", sans-serif\', |
|
340 \'droid-sans\' => \'"Droid Sans", sans-serif\' |
|
341 ); |
|
342 } |
|
343 |
|
344 return $array; |
|
345 |
|
346 } |
|
347 add_filter( \'ot_recognized_font_families\', \'filter_ot_recognized_font_families\', 10, 2 );</code></pre>'; |
|
348 |
|
349 echo '<h4>'. __( 'Upload', 'option-tree' ) . ':</h4>'; |
|
350 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>'; |
|
351 |
|
352 echo '</div>'; |
|
353 |
|
354 echo '</div>'; |
|
355 |
|
356 } |
|
357 |
|
358 } |
|
359 |
|
360 /** |
|
361 * ot_get_option() option type. |
|
362 * |
|
363 * This is a callback function to display text about ot_get_option(). |
|
364 * |
|
365 * @return string |
|
366 * |
|
367 * @access public |
|
368 * @since 2.0 |
|
369 */ |
|
370 if ( ! function_exists( 'ot_type_ot_get_option' ) ) { |
|
371 |
|
372 function ot_type_ot_get_option() { |
|
373 |
|
374 /* format setting outer wrapper */ |
|
375 echo '<div class="format-setting type-textblock wide-desc">'; |
|
376 |
|
377 /* description */ |
|
378 echo '<div class="description">'; |
|
379 |
|
380 echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>'; |
|
381 |
|
382 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>'; |
|
383 |
|
384 echo '<h4>' . __( 'Usage', 'option-tree' ) . ':</h4>'; |
|
385 |
|
386 echo '<p><code><?php ot_get_option( $option_id, $default ); ?></code></p>'; |
|
387 |
|
388 echo '<h4>' . __( 'Parameters', 'option-tree' ) . ':</h4>'; |
|
389 |
|
390 echo '<code>$option_id</code>'; |
|
391 |
|
392 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>'; |
|
393 |
|
394 echo '<code>$default</code>'; |
|
395 |
|
396 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>'; |
|
397 |
|
398 echo '</div>'; |
|
399 |
|
400 echo '</div>'; |
|
401 |
|
402 } |
|
403 |
|
404 } |
|
405 |
|
406 /** |
|
407 * get_option_tree() option type. |
|
408 * |
|
409 * This is a callback function to display text about get_option_tree(). |
|
410 * |
|
411 * @return string |
|
412 * |
|
413 * @access public |
|
414 * @since 2.0 |
|
415 */ |
|
416 if ( ! function_exists( 'ot_type_get_option_tree' ) ) { |
|
417 |
|
418 function ot_type_get_option_tree() { |
|
419 |
|
420 /* format setting outer wrapper */ |
|
421 echo '<div class="format-setting type-textblock wide-desc">'; |
|
422 |
|
423 /* description */ |
|
424 echo '<div class="description">'; |
|
425 |
|
426 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>'; |
|
427 |
|
428 echo '<p>' . __( 'Use', 'option-tree' ) . '<code>ot_get_option()</code>' . __( 'instead', 'option-tree' ) . '.</p>'; |
|
429 |
|
430 echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>'; |
|
431 |
|
432 echo '<p>' . __( 'This function returns, or echos if asked, a value from the "option_tree" array of saved values.', 'option-tree' ) . '</p>'; |
|
433 |
|
434 echo '<h4>' . __( 'Usage', 'option-tree' ) . ':</h4>'; |
|
435 |
|
436 echo '<p><code><?php get_option_tree( $item_id, $options, $echo, $is_array, $offset ); ?></code></p>'; |
|
437 |
|
438 echo '<h4>' . __( 'Parameters', 'option-tree' ) . ':</h4>'; |
|
439 |
|
440 echo '<code>$item_id</code>'; |
|
441 |
|
442 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>'; |
|
443 |
|
444 echo '<code>$options</code>'; |
|
445 |
|
446 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>'; |
|
447 |
|
448 echo '<code>$echo</code>'; |
|
449 |
|
450 echo '<p>(<em>' . __( 'boolean', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Echo the output.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': FALSE</p>'; |
|
451 |
|
452 echo '<code>$is_array</code>'; |
|
453 |
|
454 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>'; |
|
455 |
|
456 echo '<code>$offset</code>'; |
|
457 |
|
458 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>'; |
|
459 |
|
460 echo '</div>'; |
|
461 |
|
462 echo '</div>'; |
|
463 |
|
464 } |
|
465 |
|
466 } |
|
467 |
|
468 /** |
|
469 * Examples option type. |
|
470 * |
|
471 * @return string |
|
472 * |
|
473 * @access public |
|
474 * @since 2.0 |
|
475 */ |
|
476 if ( ! function_exists( 'ot_type_examples' ) ) { |
|
477 |
|
478 function ot_type_examples() { |
|
479 |
|
480 /* format setting outer wrapper */ |
|
481 echo '<div class="format-setting type-textblock wide-desc">'; |
|
482 |
|
483 /* description */ |
|
484 echo '<div class="description">'; |
|
485 |
|
486 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>'; |
|
487 |
|
488 echo '<h4>' . __( 'String Examples', 'option-tree' ) . ':</h4>'; |
|
489 |
|
490 echo '<p>' . __( 'Returns the value of <code>test_input</code>.', 'option-tree' ) . '</p>'; |
|
491 |
|
492 echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) { |
|
493 $test_input = ot_get_option( \'test_input\' ); |
|
494 }</code></pre>'; |
|
495 |
|
496 echo '<p>' . __( 'Returns the value of <code>test_input</code>, but also has a default value if it returns empty.', 'option-tree' ) . '</p>'; |
|
497 |
|
498 echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) { |
|
499 $test_input = ot_get_option( \'test_input\', \'default input value goes here.\' ); |
|
500 }</code></pre>'; |
|
501 |
|
502 echo '<h4>' . __( 'Array Examples', 'option-tree' ) . ':</h4>'; |
|
503 |
|
504 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>'; |
|
505 |
|
506 echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) { |
|
507 /* get an array of page id\'s */ |
|
508 $ids = ot_get_option( \'navigation_ids\', array() ); |
|
509 |
|
510 /* echo custom navigation using wp_list_pages() */ |
|
511 if ( ! empty( $ids ) ) |
|
512 echo \'<ul>\'; |
|
513 wp_list_pages( |
|
514 array( |
|
515 \'include\' => $ids, |
|
516 \'title_li\' => \'\' |
|
517 ) |
|
518 ); |
|
519 echo \'</ul>\'; |
|
520 } |
|
521 |
|
522 }</code></pre>'; |
|
523 |
|
524 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>'; |
|
525 |
|
526 echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) { |
|
527 /* get the array */ |
|
528 $measurement = ot_get_option( \'measurement_option_type_id\' ); |
|
529 |
|
530 /* only echo values if they actually exist, else echo some default value */ |
|
531 if ( isset( measurement[0] ) && $measurement[1] ) { |
|
532 echo $measurement[0].$measurement[1]; |
|
533 } else { |
|
534 echo \'10px\'; |
|
535 } |
|
536 |
|
537 }</code></pre>'; |
|
538 |
|
539 echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) { |
|
540 /* get the array, and have a default just incase */ |
|
541 $measurement = ot_get_option( \'measurement_option_type_id\', array( \'10\', \'px\' ) ); |
|
542 |
|
543 /* implode array into a string value */ |
|
544 if ( ! empty( measurement ) ) { |
|
545 echo implode( \'\', $measurement ); |
|
546 } |
|
547 |
|
548 }</code></pre>'; |
|
549 |
|
550 echo '<p>' . __( 'This example displays a very basic slider loop.', 'option-tree' ) . '</p>'; |
|
551 |
|
552 echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) { |
|
553 |
|
554 /* get the slider array */ |
|
555 $slides = ot_get_option( \'my_slider\', array() ); |
|
556 |
|
557 if ( ! empty( $slides ) ) { |
|
558 foreach( $slides as $slide ) { |
|
559 echo \' |
|
560 <li> |
|
561 <a href="\' . $slide[\'link\'] . \'"><img src="\' . $slide[\'image\'] . \'" alt="\' . $slide[\'title\'] . \'" /></a> |
|
562 <div class="description">\' . $slide[\'description\'] . \'</div> |
|
563 </li>\'; |
|
564 } |
|
565 } |
|
566 |
|
567 }</code></pre>'; |
|
568 |
|
569 echo '</div>'; |
|
570 |
|
571 echo '</div>'; |
|
572 |
|
573 } |
|
574 |
|
575 } |
|
576 |
|
577 /** |
|
578 * Layouts Overview option type. |
|
579 * |
|
580 * @return string |
|
581 * |
|
582 * @access public |
|
583 * @since 2.0 |
|
584 */ |
|
585 if ( ! function_exists( 'ot_type_layouts_overview' ) ) { |
|
586 |
|
587 function ot_type_layouts_overview() { |
|
588 |
|
589 /* format setting outer wrapper */ |
|
590 echo '<div class="format-setting type-textblock wide-desc">'; |
|
591 |
|
592 /* description */ |
|
593 echo '<div class="description">'; |
|
594 |
|
595 echo '<h4>'. __( 'It\'s Super Simple', 'option-tree' ) . '</h4>'; |
|
596 |
|
597 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>'; |
|
598 |
|
599 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>'; |
|
600 |
|
601 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>'; |
|
602 |
|
603 echo '<h4>' . __( 'For Developers', 'option-tree' ) . ':</h4>'; |
|
604 echo '<p>' . __( '', 'option-tree' ) . '</p>'; |
|
605 |
|
606 echo '<h5>' . __( 'Creating a Layout', 'option-tree' ) . ':</h5>'; |
|
607 echo '<ul class="docs-ul">'; |
|
608 echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>'; |
|
609 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>'; |
|
610 echo '<li>' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>'; |
|
611 echo '</ul>'; |
|
612 |
|
613 echo '<h5>' . __( 'Activating a Layout', 'option-tree' ) . ':</h5>'; |
|
614 echo '<ul class="docs-ul">'; |
|
615 echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>'; |
|
616 echo '<li>' . __( 'Click on the activate layout button in the actions list.', 'option-tree' ) . '</li>'; |
|
617 echo '</ul>'; |
|
618 |
|
619 echo '<h5>' . __( 'Deleting a Layout', 'option-tree' ) . ':</h5>'; |
|
620 echo '<ul class="docs-ul">'; |
|
621 echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>'; |
|
622 echo '<li>' . __( 'Click on the delete layout button in the actions list.', 'option-tree' ) . '</li>'; |
|
623 echo '</ul>'; |
|
624 |
|
625 echo '<h5>' . __( 'Edit Layout Data', 'option-tree' ) . ':</h5>'; |
|
626 echo '<ul class="docs-ul">'; |
|
627 echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>'; |
|
628 echo '<li>' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>'; |
|
629 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>'; |
|
630 echo '<li>' . __( 'If you want to edit a new layout, first create it then save your theme options.', 'option-tree' ) . '</li>'; |
|
631 echo '</ul>'; |
|
632 |
|
633 echo '<h4>' . __( 'End-Users Mode', 'option-tree' ) . ':</h4>'; |
|
634 echo '<p>' . __( '', 'option-tree' ) . '</p>'; |
|
635 |
|
636 echo '<h5>' . __( 'Creating a Layout', 'option-tree' ) . ':</h5>'; |
|
637 echo '<ul class="docs-ul">'; |
|
638 echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>'; |
|
639 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>'; |
|
640 echo '<li>' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>'; |
|
641 echo '</ul>'; |
|
642 |
|
643 echo '<h5>' . __( 'Activating a Layout', 'option-tree' ) . ':</h5>'; |
|
644 echo '<ul class="docs-ul">'; |
|
645 echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>'; |
|
646 echo '<li>' . __( 'Choose a layout from the select list and click the "Activate Layout" button.', 'option-tree' ) . '</li>'; |
|
647 echo '</ul>'; |
|
648 |
|
649 echo '<h5>' . __( 'Deleting a Layout', 'option-tree' ) . ':</h5>'; |
|
650 echo '<ul class="docs-ul">'; |
|
651 echo '<li>'. __( 'End-Users mode does not allow deleting layouts.', 'option-tree' ) . '</li>'; |
|
652 echo '</ul>'; |
|
653 |
|
654 echo '<h5>' . __( 'Edit Layout Data', 'option-tree' ) . ':</h5>'; |
|
655 echo '<ul class="docs-ul">'; |
|
656 echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> tab.', 'option-tree' ) . '</li>'; |
|
657 echo '<li>' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>'; |
|
658 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>'; |
|
659 echo '</ul>'; |
|
660 |
|
661 echo '</div>'; |
|
662 |
|
663 echo '</div>'; |
|
664 |
|
665 } |
|
666 |
|
667 } |
|
668 |
|
669 /** |
|
670 * Meta Boxes option type. |
|
671 * |
|
672 * @return string |
|
673 * |
|
674 * @access public |
|
675 * @since 2.0 |
|
676 */ |
|
677 if ( ! function_exists( 'ot_type_meta_boxes' ) ) { |
|
678 |
|
679 function ot_type_meta_boxes() { |
|
680 |
|
681 /* format setting outer wrapper */ |
|
682 echo '<div class="format-setting type-textblock wide-desc">'; |
|
683 |
|
684 /* description */ |
|
685 echo '<div class="description">'; |
|
686 |
|
687 echo '<h4>'. __( 'How-to-guide', 'option-tree' ) . '</h4>'; |
|
688 |
|
689 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>'; |
|
690 |
|
691 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>'; |
|
692 |
|
693 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>'; |
|
694 |
|
695 echo '<h5>' . __( 'Create and include your custom meta boxes file.', 'option-tree' ) . '</h5>'; |
|
696 echo '<ul class="docs-ul">'; |
|
697 echo '<li>'. __( 'Create a file and name it anything you want, maybe <code>meta-boxes.php</code>.', 'option-tree' ) . '</li>'; |
|
698 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>'; |
|
699 echo '<li>' . __( 'Add the following code to your <code>functions.php</code>.', 'option-tree' ) . '</li>'; |
|
700 echo '</ul>'; |
|
701 |
|
702 echo '<pre><code>/** |
|
703 * Meta Boxes |
|
704 */ |
|
705 load_template( trailingslashit( get_template_directory() ) . \'includes/meta-boxes.php\' ); |
|
706 </code></pre>'; |
|
707 |
|
708 echo '<ul class="docs-ul">'; |
|
709 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>'; |
|
710 echo '</ul>'; |
|
711 |
|
712 echo "<pre><code>/** |
|
713 * Initialize the meta boxes. |
|
714 */ |
|
715 add_action( 'admin_init', 'custom_meta_boxes' ); |
|
716 |
|
717 function custom_meta_boxes() { |
|
718 |
|
719 $my_meta_box = array( |
|
720 'id' => 'my_meta_box', |
|
721 'title' => 'My Meta Box', |
|
722 'desc' => '', |
|
723 'pages' => array( 'post' ), |
|
724 'context' => 'normal', |
|
725 'priority' => 'high', |
|
726 'fields' => array( |
|
727 array( |
|
728 'id' => 'background', |
|
729 'label' => 'Background', |
|
730 'desc' => '', |
|
731 'std' => '', |
|
732 'type' => 'background', |
|
733 'class' => '', |
|
734 'choices' => array() |
|
735 ) |
|
736 ) |
|
737 ); |
|
738 |
|
739 ot_register_meta_box( $my_meta_box ); |
|
740 |
|
741 }</code></pre>"; |
|
742 |
|
743 echo '</div>'; |
|
744 |
|
745 echo '</div>'; |
|
746 |
|
747 } |
|
748 |
|
749 } |
|
750 |
|
751 /** |
|
752 * Theme Mode option type. |
|
753 * |
|
754 * @return string |
|
755 * |
|
756 * @access public |
|
757 * @since 2.0 |
|
758 */ |
|
759 if ( ! function_exists( 'ot_type_theme_mode' ) ) { |
|
760 |
|
761 function ot_type_theme_mode() { |
|
762 |
|
763 /* format setting outer wrapper */ |
|
764 echo '<div class="format-setting type-textblock wide-desc">'; |
|
765 |
|
766 /* description */ |
|
767 echo '<div class="description">'; |
|
768 |
|
769 echo '<h4>'. __( 'How-to-guide', 'option-tree' ) . '</h4>'; |
|
770 |
|
771 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>'; |
|
772 |
|
773 echo '<h5>' . __( 'Step 1: Include the plugin & turn on theme mode.', 'option-tree' ) . '</h5>'; |
|
774 echo '<ul class="docs-ul">'; |
|
775 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>'; |
|
776 echo '<li>' . __( 'Unpack the ZIP archive.', 'option-tree' ) . '</li>'; |
|
777 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>'; |
|
778 echo '<li>' . __( 'Add the following code to the beginning of your <code>functions.php</code>.', 'option-tree' ) . '</li>'; |
|
779 echo '</ul>'; |
|
780 |
|
781 echo '<pre><code>/** |
|
782 * Optional: set \'ot_show_pages\' filter to false. |
|
783 * This will hide the settings & documentation pages. |
|
784 */ |
|
785 add_filter( \'ot_show_pages\', \'__return_false\' ); |
|
786 |
|
787 /** |
|
788 * Optional: set \'ot_show_new_layout\' filter to false. |
|
789 * This will hide the "New Layout" section on the Theme Options page. |
|
790 */ |
|
791 add_filter( \'ot_show_new_layout\', \'__return_false\' ); |
|
792 |
|
793 /** |
|
794 * Required: set \'ot_theme_mode\' filter to true. |
|
795 */ |
|
796 add_filter( \'ot_theme_mode\', \'__return_true\' ); |
|
797 |
|
798 /** |
|
799 * Required: include OptionTree. |
|
800 */ |
|
801 load_template( trailingslashit( get_template_directory() ) . \'option-tree/ot-loader.php\' ); |
|
802 </code></pre>'; |
|
803 |
|
804 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>'; |
|
805 |
|
806 echo '<h5>' . __( 'Step 2: Create Theme Options without using the UI Builder.', 'option-tree' ) . '</h5>'; |
|
807 echo '<ul class="docs-ul">'; |
|
808 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>'; |
|
809 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>'; |
|
810 echo '<li>' . __( 'Add the following code to your <code>functions.php</code>.', 'option-tree' ) . '</li>'; |
|
811 echo '</ul>'; |
|
812 |
|
813 echo '<pre><code>/** |
|
814 * Theme Options |
|
815 */ |
|
816 load_template( trailingslashit( get_template_directory() ) . \'includes/theme-options.php\' ); |
|
817 </code></pre>'; |
|
818 |
|
819 echo '<ul class="docs-ul">'; |
|
820 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>'; |
|
821 echo '</ul>'; |
|
822 |
|
823 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 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>'; |
|
824 |
|
825 echo "<pre><code>/** |
|
826 * Initialize the options before anything else. |
|
827 */ |
|
828 add_action( 'admin_init', 'custom_theme_options', 1 ); |
|
829 |
|
830 /** |
|
831 * Build the custom settings & update OptionTree. |
|
832 */ |
|
833 function custom_theme_options() { |
|
834 /** |
|
835 * Get a copy of the saved settings array. |
|
836 */ |
|
837 $saved_settings = get_option( 'option_tree_settings', array() ); |
|
838 |
|
839 /** |
|
840 * Custom settings array that will eventually be |
|
841 * passes to the OptionTree Settings API Class. |
|
842 */ |
|
843 $custom_settings = array( |
|
844 'contextual_help' => array( |
|
845 'content' => array( |
|
846 array( |
|
847 'id' => 'general_help', |
|
848 'title' => 'General', |
|
849 'content' => '<p>Help content goes here!</p>' |
|
850 ) |
|
851 ), |
|
852 'sidebar' => '<p>Sidebar content goes here!</p>', |
|
853 ), |
|
854 'sections' => array( |
|
855 array( |
|
856 'id' => 'general', |
|
857 'title' => 'General' |
|
858 ) |
|
859 ), |
|
860 'settings' => array( |
|
861 array( |
|
862 'id' => 'my_checkbox', |
|
863 'label' => 'Checkbox', |
|
864 'desc' => '', |
|
865 'std' => '', |
|
866 'type' => 'checkbox', |
|
867 'section' => 'general', |
|
868 'class' => '', |
|
869 'choices' => array( |
|
870 array( |
|
871 'value' => 'yes', |
|
872 'label' => 'Yes' |
|
873 ) |
|
874 ) |
|
875 ), |
|
876 array( |
|
877 'id' => 'my_layout', |
|
878 'label' => 'Layout', |
|
879 'desc' => 'Choose a layout for your theme', |
|
880 'std' => 'right-sidebar', |
|
881 'type' => 'radio-image', |
|
882 'section' => 'general', |
|
883 'class' => '', |
|
884 'choices' => array( |
|
885 array( |
|
886 'value' => 'left-sidebar', |
|
887 'label' => 'Left Sidebar', |
|
888 'src' => OT_URL . '/assets/images/layout/left-sidebar.png' |
|
889 ), |
|
890 array( |
|
891 'value' => 'right-sidebar', |
|
892 'label' => 'Right Sidebar', |
|
893 'src' => OT_URL . '/assets/images/layout/right-sidebar.png' |
|
894 ), |
|
895 array( |
|
896 'value' => 'full-width', |
|
897 'label' => 'Full Width (no sidebar)', |
|
898 'src' => OT_URL . '/assets/images/layout/full-width.png' |
|
899 ), |
|
900 array( |
|
901 'value' => 'dual-sidebar', |
|
902 'label' => __( 'Dual Sidebar', 'option-tree' ), |
|
903 'src' => OT_URL . '/assets/images/layout/dual-sidebar.png' |
|
904 ), |
|
905 array( |
|
906 'value' => 'left-dual-sidebar', |
|
907 'label' => __( 'Left Dual Sidebar', 'option-tree' ), |
|
908 'src' => OT_URL . '/assets/images/layout/left-dual-sidebar.png' |
|
909 ), |
|
910 array( |
|
911 'value' => 'right-dual-sidebar', |
|
912 'label' => __( 'Right Dual Sidebar', 'option-tree' ), |
|
913 'src' => OT_URL . '/assets/images/layout/right-dual-sidebar.png' |
|
914 ) |
|
915 ) |
|
916 ), |
|
917 array( |
|
918 'id' => 'my_slider', |
|
919 'label' => 'Images', |
|
920 'desc' => '', |
|
921 'std' => '', |
|
922 'type' => 'list-item', |
|
923 'section' => 'general', |
|
924 'class' => '', |
|
925 'choices' => array(), |
|
926 'settings' => array( |
|
927 array( |
|
928 'id' => 'slider_image', |
|
929 'label' => 'Image', |
|
930 'desc' => '', |
|
931 'std' => '', |
|
932 'type' => 'upload', |
|
933 'class' => '', |
|
934 'choices' => array() |
|
935 ), |
|
936 array( |
|
937 'id' => 'slider_link', |
|
938 'label' => 'Link to Post', |
|
939 'desc' => 'Enter the posts url.', |
|
940 'std' => '', |
|
941 'type' => 'text', |
|
942 'class' => '', |
|
943 'choices' => array() |
|
944 ), |
|
945 array( |
|
946 'id' => 'slider_description', |
|
947 'label' => 'Description', |
|
948 'desc' => 'This text is used to add fancy captions in the slider.', |
|
949 'std' => '', |
|
950 'type' => 'textarea', |
|
951 'class' => '', |
|
952 'choices' => array() |
|
953 ) |
|
954 ) |
|
955 ) |
|
956 ) |
|
957 ); |
|
958 |
|
959 /* settings are not the same update the DB */ |
|
960 if ( $saved_settings !== $custom_settings ) { |
|
961 update_option( 'option_tree_settings', $custom_settings ); |
|
962 } |
|
963 |
|
964 } |
|
965 </code></pre>"; |
|
966 |
|
967 echo '</div>'; |
|
968 |
|
969 echo '</div>'; |
|
970 |
|
971 } |
|
972 |
|
973 } |
|
974 |
|
975 /* End of file ot-functions-docs-page.php */ |
|
976 /* Location: ./includes/ot-functions-docs-page.php */ |