Version Description
- 2019/05/19
- OptionTree security fix
Download this release
Release Info
Developer | WebFactory |
Plugin | Coming Soon, Under Construction & Maintenance Page |
Version | 1.50 |
Comparing to | |
See all releases |
Code changes from version 1.45 to 1.50
- admin/includes/class-ot-cleanup.php +297 -0
- admin/includes/class-ot-meta-box.php +375 -0
- admin/includes/class-ot-post-formats.php +122 -0
- admin/includes/class-ot-settings.php +1045 -0
- admin/includes/ot-functions-admin.php +5766 -5818
- admin/includes/ot-functions-deprecated.php +82 -87
- admin/includes/ot-functions-option-types.php +2658 -2727
- admin/includes/ot-functions-settings-page.php +453 -541
- admin/includes/ot-functions.php +311 -321
- admin/ot-loader.php +720 -790
- nifty-coming-soon.php +1 -1
- readme.txt +7 -3
admin/includes/class-ot-cleanup.php
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Cleanup.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Cleanup' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Cleanup class.
|
16 |
+
*
|
17 |
+
* This class loads all the OptionTree Cleanup methods and helpers.
|
18 |
+
*/
|
19 |
+
class OT_Cleanup {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class constructor.
|
23 |
+
*
|
24 |
+
* This method adds other methods of the class to specific hooks within WordPress.
|
25 |
+
*
|
26 |
+
* @uses add_action()
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
* @since 2.4.6
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
if ( ! is_admin() ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
// Load styles.
|
37 |
+
add_action( 'admin_head', array( $this, 'styles' ), 1 );
|
38 |
+
|
39 |
+
// Maybe Clean up OptionTree.
|
40 |
+
add_action( 'admin_menu', array( $this, 'maybe_cleanup' ), 100 );
|
41 |
+
|
42 |
+
// Increase timeout if allowed.
|
43 |
+
add_action( 'ot_pre_consolidate_posts', array( $this, 'increase_timeout' ) );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Adds the cleanup styles to the admin head
|
48 |
+
*
|
49 |
+
* @access public
|
50 |
+
* @since 2.5.0
|
51 |
+
*/
|
52 |
+
public function styles() {
|
53 |
+
echo '<style>#toplevel_page_ot-cleanup{display:none;}</style>';
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Check if OptionTree needs to be cleaned up from a previous install.
|
58 |
+
*
|
59 |
+
* @access public
|
60 |
+
* @since 2.4.6
|
61 |
+
*/
|
62 |
+
public function maybe_cleanup() {
|
63 |
+
global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table;
|
64 |
+
|
65 |
+
$table_name = $wpdb->prefix . 'option_tree';
|
66 |
+
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore
|
67 |
+
$ot_maybe_cleanup_posts = count( $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree' LIMIT 2" ) ) > 1; // phpcs:ignore
|
68 |
+
$ot_maybe_cleanup_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) == $table_name; // phpcs:ignore
|
69 |
+
|
70 |
+
if ( ! $ot_maybe_cleanup_posts && ! $ot_maybe_cleanup_table && 'ot-cleanup' === $page ) {
|
71 |
+
wp_safe_redirect( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) );
|
72 |
+
exit;
|
73 |
+
}
|
74 |
+
|
75 |
+
if ( $ot_maybe_cleanup_posts || $ot_maybe_cleanup_table ) {
|
76 |
+
|
77 |
+
if ( 'ot-cleanup' !== $page ) {
|
78 |
+
add_action( 'admin_notices', array( $this, 'cleanup_notice' ) );
|
79 |
+
}
|
80 |
+
|
81 |
+
$theme_check_bs = 'add_menu_' . 'page'; // phpcs:ignore
|
82 |
+
|
83 |
+
$theme_check_bs( apply_filters( 'ot_cleanup_page_title', __( 'OptionTree Cleanup', 'option-tree' ) ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ), 'edit_theme_options', 'ot-cleanup', array( $this, 'options_page' ) );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Adds an admin nag.
|
89 |
+
*
|
90 |
+
* @access public
|
91 |
+
* @since 2.4.6
|
92 |
+
*/
|
93 |
+
public function cleanup_notice() {
|
94 |
+
|
95 |
+
if ( 'appearance_page_ot-cleanup' !== get_current_screen()->id ) {
|
96 |
+
$link = sprintf( '<a href="%s">%s</a>', admin_url( 'themes.php?page=ot-cleanup' ), apply_filters( 'ot_cleanup_menu_title', esc_html__( 'OptionTree Cleanup', 'option-tree' ) ) );
|
97 |
+
|
98 |
+
/* translators: %s: internal admin page URL */
|
99 |
+
echo '<div class="update-nag">' . sprintf( esc_html__( 'OptionTree has outdated data that should be removed. Please go to %s for more information.', 'option-tree' ), $link ) . '</div>'; // phpcs:ignore
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Adds a Tools sub page to clean up the database with.
|
105 |
+
*
|
106 |
+
* @access public
|
107 |
+
* @since 2.4.6
|
108 |
+
*/
|
109 |
+
public function options_page() {
|
110 |
+
global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table;
|
111 |
+
|
112 |
+
// Option ID.
|
113 |
+
$option_id = 'ot_media_post_ID';
|
114 |
+
|
115 |
+
// Get the media post ID.
|
116 |
+
$post_ID = get_option( $option_id, false );
|
117 |
+
|
118 |
+
// Zero loop count.
|
119 |
+
$count = 0;
|
120 |
+
|
121 |
+
// Check for safe mode.
|
122 |
+
$safe_mode = ini_get( 'safe_mode' ); // phpcs:ignore
|
123 |
+
|
124 |
+
echo '<div class="wrap">';
|
125 |
+
|
126 |
+
echo '<h2>' . apply_filters( 'ot_cleanup_page_title', esc_html__( 'OptionTree Cleanup', 'option-tree' ) ) . '</h2>'; // phpcs:ignore
|
127 |
+
|
128 |
+
if ( $ot_maybe_cleanup_posts ) {
|
129 |
+
|
130 |
+
$posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree'" ); // phpcs:ignore
|
131 |
+
|
132 |
+
echo '<h3>' . esc_html__( 'Multiple Media Posts', 'option-tree' ) . '</h3>';
|
133 |
+
|
134 |
+
/* translators: %1$s: number of media posts, %2$s: media post type, %3$s: table name */
|
135 |
+
$string = esc_html__( 'There are currently %1$s OptionTree media posts in your database. At some point in the past, a version of OptionTree added multiple %2$s media post objects cluttering up your %3$s table. There is no associated risk or harm that these posts have caused other than to add size to your overall database. Thankfully, there is a way to remove all these orphaned media posts and get your database cleaned up.', 'option-tree' );
|
136 |
+
echo '<p>' . sprintf( $string, '<code>' . number_format( count( $posts ) ) . '</code>', '<tt>option-tree</tt>', '<tt>' . $wpdb->posts . '</tt>' ) . '</p>'; // phpcs:ignore
|
137 |
+
|
138 |
+
/* translators: %s: number of media posts being deleted */
|
139 |
+
echo '<p>' . sprintf( esc_html__( 'By clicking the button below, OptionTree will delete %s records and consolidate them into one single OptionTree media post for uploading attachments to. Additionally, the attachments will have their parent ID updated to the correct media post.', 'option-tree' ), '<code>' . number_format( count( $posts ) - 1 ) . '</code>' ) . '</p>';
|
140 |
+
|
141 |
+
echo '<p><strong>' . esc_html__( 'This could take a while to fully process depending on how many records you have in your database, so please be patient and wait for the script to finish.', 'option-tree' ) . '</strong></p>';
|
142 |
+
|
143 |
+
/* translators: %1$s: the word Note wrapped in a strong attribute, %2$s: number of posts being deleted */
|
144 |
+
$string = __( '%1$s: Your server is running in safe mode. Which means this page will automatically reload after deleting %2$s posts, you can filter this number using %3$s if your server is having trouble processing that many at one time.', 'option-tree' );
|
145 |
+
echo $safe_mode ? '<p>' . sprintf( $string, '<strong>' . esc_html__( 'Note', 'option-tree' ) . '</strong>:', apply_filters( 'ot_consolidate_posts_reload', 500 ), '<tt>ot_consolidate_posts_reload</tt>' ) . '</p>' : ''; // phpcs:ignore
|
146 |
+
|
147 |
+
echo '<p><a class="button button-primary" href="' . wp_nonce_url( admin_url( 'themes.php?page=ot-cleanup' ), 'consolidate-posts' ) . '">' . esc_html__( 'Consolidate Posts', 'option-tree' ) . '</a></p>'; // phpcs:ignore
|
148 |
+
|
149 |
+
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'consolidate-posts' ) ) { // phpcs:ignore
|
150 |
+
|
151 |
+
if ( false === $post_ID || empty( $post_ID ) ) {
|
152 |
+
$post_ID = isset( $posts[0]->ID ) ? $posts[0]->ID : null;
|
153 |
+
|
154 |
+
// Add to the DB.
|
155 |
+
if ( null !== $post_ID ) {
|
156 |
+
update_option( $option_id, $post_ID );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
// Do pre consolidation action to increase timeout.
|
161 |
+
do_action( 'ot_pre_consolidate_posts' );
|
162 |
+
|
163 |
+
// Loop over posts.
|
164 |
+
foreach ( $posts as $post ) {
|
165 |
+
|
166 |
+
// Don't destroy the correct post.
|
167 |
+
if ( $post_ID === $post->ID ) {
|
168 |
+
continue;
|
169 |
+
}
|
170 |
+
|
171 |
+
// Update count.
|
172 |
+
$count++;
|
173 |
+
|
174 |
+
// Reload script in safe mode.
|
175 |
+
if ( $safe_mode && $count > absint( apply_filters( 'ot_consolidate_posts_reload', 500 ) ) ) {
|
176 |
+
echo '<br />' . esc_html__( 'Reloading...', 'option-tree' );
|
177 |
+
echo '
|
178 |
+
<script>
|
179 |
+
setTimeout( ot_script_reload, 3000 )
|
180 |
+
function ot_script_reload() {
|
181 |
+
window.location = "' . esc_url_raw( self_admin_url( 'themes.php?page=ot-cleanup&_wpnonce=' . wp_create_nonce( 'consolidate-posts' ) ) ) . '"
|
182 |
+
}
|
183 |
+
</script>';
|
184 |
+
break;
|
185 |
+
}
|
186 |
+
|
187 |
+
// Get the attachments.
|
188 |
+
$attachments = get_children( 'post_type=attachment&post_parent=' . $post->ID );
|
189 |
+
|
190 |
+
// Update the attachments parent ID.
|
191 |
+
if ( ! empty( $attachments ) ) {
|
192 |
+
|
193 |
+
/* translators: %1$s: the post type, %2$s: the post ID */
|
194 |
+
$string = esc_html__( 'Updating Attachments parent ID for %1$s post %2$s.', 'option-tree' );
|
195 |
+
echo sprintf( $string . '<br />', '<tt>option-tree</tt>', '<tt>#' . $post->ID . '</tt>' ); // phpcs:ignore
|
196 |
+
|
197 |
+
foreach ( $attachments as $attachment_id => $attachment ) {
|
198 |
+
wp_update_post(
|
199 |
+
array(
|
200 |
+
'ID' => $attachment_id,
|
201 |
+
'post_parent' => $post_ID,
|
202 |
+
)
|
203 |
+
);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/* translators: %1$s: the post type, %2$s: the post ID */
|
208 |
+
$string = esc_html__( 'Deleting %1$s post %2$s.', 'option-tree' );
|
209 |
+
|
210 |
+
// Delete post.
|
211 |
+
echo sprintf( $string . '<br />', '<tt>option-tree</tt>', '<tt>#' . $post->ID . '</tt>' ); // phpcs:ignore
|
212 |
+
wp_delete_post( $post->ID, true );
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
echo '<br />' . esc_html__( 'Clean up script has completed, the page will now reload...', 'option-tree' );
|
217 |
+
|
218 |
+
echo '
|
219 |
+
<script>
|
220 |
+
setTimeout( ot_script_reload, 3000 )
|
221 |
+
function ot_script_reload() {
|
222 |
+
window.location = "' . esc_url_raw( self_admin_url( 'themes.php?page=ot-cleanup' ) ) . '"
|
223 |
+
}
|
224 |
+
</script>';
|
225 |
+
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( $ot_maybe_cleanup_table ) {
|
230 |
+
|
231 |
+
$table_name = $wpdb->prefix . 'option_tree';
|
232 |
+
|
233 |
+
echo $ot_maybe_cleanup_posts ? '<hr />' : '';
|
234 |
+
|
235 |
+
echo '<h3>' . esc_html__( 'Outdated Table', 'option-tree' ) . '</h3>';
|
236 |
+
|
237 |
+
/* translators: %s: table name */
|
238 |
+
$string = esc_html__( 'If you have upgraded from an old 1.x version of OptionTree at some point, you have an extra %s table in your database that can be removed. It\'s not hurting anything, but does not need to be there. If you want to remove it. Click the button below.', 'option-tree' );
|
239 |
+
|
240 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
241 |
+
|
242 |
+
echo '<p><a class="button button-primary" href="' . esc_url_raw( wp_nonce_url( admin_url( 'themes.php?page=ot-cleanup' ), 'drop-table' ) ) . '">' . esc_html__( 'Drop Table', 'option-tree' ) . '</a></p>';
|
243 |
+
|
244 |
+
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'drop-table' ) ) { // phpcs:ignore
|
245 |
+
|
246 |
+
/* translators: %s: table name */
|
247 |
+
$string = esc_html__( 'Deleting the outdated and unused %s table...', 'option-tree' );
|
248 |
+
|
249 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
250 |
+
|
251 |
+
$wpdb->query( "DROP TABLE IF EXISTS $table_name" ); // phpcs:ignore
|
252 |
+
|
253 |
+
if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) != $table_name ) { // phpcs:ignore
|
254 |
+
|
255 |
+
/* translators: %s: table name */
|
256 |
+
$string = esc_html__( 'The %s table has been successfully deleted. The page will now reload...', 'option-tree' );
|
257 |
+
|
258 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
259 |
+
|
260 |
+
echo '
|
261 |
+
<script>
|
262 |
+
setTimeout( ot_script_reload, 3000 )
|
263 |
+
function ot_script_reload() {
|
264 |
+
window.location = "' . esc_url_raw( self_admin_url( 'themes.php?page=ot-cleanup' ) ) . '"
|
265 |
+
}
|
266 |
+
</script>';
|
267 |
+
|
268 |
+
} else {
|
269 |
+
|
270 |
+
/* translators: %s: table name */
|
271 |
+
$string = esc_html__( 'Something went wrong. The %s table was not deleted.', 'option-tree' );
|
272 |
+
|
273 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
echo '</div>';
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Increase PHP timeout.
|
283 |
+
*
|
284 |
+
* This is to prevent bulk operations from timing out
|
285 |
+
*
|
286 |
+
* @access public
|
287 |
+
* @since 2.4.6
|
288 |
+
*/
|
289 |
+
public function increase_timeout() {
|
290 |
+
if ( ! ini_get( 'safe_mode' ) ) { // phpcs:ignore
|
291 |
+
@set_time_limit( 0 ); // phpcs:ignore
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
new OT_Cleanup();
|
admin/includes/class-ot-meta-box.php
ADDED
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Meta Box.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Meta_Box' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Meta Box class.
|
16 |
+
*
|
17 |
+
* This class loads all the methods and helpers specific to build a meta box.
|
18 |
+
*/
|
19 |
+
class OT_Meta_Box {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Stores the meta box config array.
|
23 |
+
*
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
private $meta_box;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Class constructor.
|
30 |
+
*
|
31 |
+
* This method adds other methods of the class to specific hooks within WordPress.
|
32 |
+
*
|
33 |
+
* @uses add_action()
|
34 |
+
*
|
35 |
+
* @access public
|
36 |
+
* @since 1.0
|
37 |
+
*
|
38 |
+
* @param array $meta_box Meta box config array.
|
39 |
+
*/
|
40 |
+
public function __construct( $meta_box ) {
|
41 |
+
if ( ! is_admin() ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
global $ot_meta_boxes;
|
46 |
+
|
47 |
+
if ( ! isset( $ot_meta_boxes ) ) {
|
48 |
+
$ot_meta_boxes = array();
|
49 |
+
}
|
50 |
+
|
51 |
+
$ot_meta_boxes[] = $meta_box;
|
52 |
+
|
53 |
+
$this->meta_box = $meta_box;
|
54 |
+
|
55 |
+
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
56 |
+
|
57 |
+
add_action( 'save_post', array( $this, 'save_meta_box' ), 1, 2 );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Adds meta box to any post type
|
62 |
+
*
|
63 |
+
* @uses add_meta_box()
|
64 |
+
*
|
65 |
+
* @access public
|
66 |
+
* @since 1.0
|
67 |
+
*/
|
68 |
+
public function add_meta_boxes() {
|
69 |
+
global $wp_version;
|
70 |
+
|
71 |
+
$is_wp_5 = version_compare( $wp_version, '5.0', '>=' );
|
72 |
+
|
73 |
+
foreach ( (array) $this->meta_box['pages'] as $page ) {
|
74 |
+
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'] );
|
75 |
+
|
76 |
+
if ( $is_wp_5 ) {
|
77 |
+
add_filter(
|
78 |
+
'postbox_classes_' . $page . '_' . $this->meta_box['id'],
|
79 |
+
function( $classes ) {
|
80 |
+
array_push( $classes, 'ot-meta-box' );
|
81 |
+
return $classes;
|
82 |
+
}
|
83 |
+
);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Meta box view.
|
90 |
+
*
|
91 |
+
* @access public
|
92 |
+
* @since 1.0
|
93 |
+
*
|
94 |
+
* @param object $post The WP_Post object.
|
95 |
+
* @param array $fields The meta box fields.
|
96 |
+
*/
|
97 |
+
public function build_meta_box( $post, $fields ) {
|
98 |
+
unset( $fields ); // @todo Check if the loop can use this param.
|
99 |
+
|
100 |
+
echo '<div class="ot-metabox-wrapper">';
|
101 |
+
|
102 |
+
// Use nonce for verification.
|
103 |
+
echo '<input type="hidden" name="' . esc_attr( $this->meta_box['id'] ) . '_nonce" value="' . esc_attr( wp_create_nonce( $this->meta_box['id'] ) ) . '" />';
|
104 |
+
|
105 |
+
// Meta box description.
|
106 |
+
echo isset( $this->meta_box['desc'] ) && ! empty( $this->meta_box['desc'] ) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode( $this->meta_box['desc'] ) . '</div>' : ''; // phpcs:ignore
|
107 |
+
|
108 |
+
// Loop through meta box fields.
|
109 |
+
foreach ( $this->meta_box['fields'] as $field ) {
|
110 |
+
|
111 |
+
// Get current post meta data.
|
112 |
+
$field_value = get_post_meta( $post->ID, $field['id'], true );
|
113 |
+
|
114 |
+
// Set standard value.
|
115 |
+
if ( isset( $field['std'] ) ) {
|
116 |
+
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
117 |
+
}
|
118 |
+
|
119 |
+
// Build the arguments array.
|
120 |
+
$_args = array(
|
121 |
+
'type' => $field['type'],
|
122 |
+
'field_id' => $field['id'],
|
123 |
+
'field_name' => $field['id'],
|
124 |
+
'field_value' => $field_value,
|
125 |
+
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
126 |
+
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
127 |
+
'field_rows' => isset( $field['rows'] ) && ! empty( $field['rows'] ) ? $field['rows'] : 10,
|
128 |
+
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
129 |
+
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
130 |
+
'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
131 |
+
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
132 |
+
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
133 |
+
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
134 |
+
'field_choices' => isset( $field['choices'] ) ? $field['choices'] : array(),
|
135 |
+
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
136 |
+
'post_id' => $post->ID,
|
137 |
+
'meta' => true,
|
138 |
+
);
|
139 |
+
|
140 |
+
$conditions = '';
|
141 |
+
|
142 |
+
// Setup the conditions.
|
143 |
+
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
144 |
+
$conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"';
|
145 |
+
$conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : '';
|
146 |
+
}
|
147 |
+
|
148 |
+
// Only allow simple textarea due to DOM issues with wp_editor().
|
149 |
+
if ( false === apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) && 'textarea' === $_args['type'] ) {
|
150 |
+
$_args['type'] = 'textarea-simple';
|
151 |
+
}
|
152 |
+
|
153 |
+
// Build the setting CSS class.
|
154 |
+
if ( ! empty( $_args['field_class'] ) ) {
|
155 |
+
|
156 |
+
$classes = explode( ' ', $_args['field_class'] );
|
157 |
+
|
158 |
+
foreach ( $classes as $key => $value ) {
|
159 |
+
|
160 |
+
$classes[ $key ] = $value . '-wrap';
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
$class = 'format-settings ' . implode( ' ', $classes );
|
165 |
+
} else {
|
166 |
+
|
167 |
+
$class = 'format-settings';
|
168 |
+
}
|
169 |
+
|
170 |
+
// Option label.
|
171 |
+
echo '<div id="setting_' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $class ) . '"' . $conditions . '>'; // phpcs:ignore
|
172 |
+
|
173 |
+
echo '<div class="format-setting-wrap">';
|
174 |
+
|
175 |
+
// Don't show title with textblocks.
|
176 |
+
if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) {
|
177 |
+
echo '<div class="format-setting-label">';
|
178 |
+
echo '<label for="' . esc_attr( $field['id'] ) . '" class="label">' . esc_html( $field['label'] ) . '</label>';
|
179 |
+
echo '</div>';
|
180 |
+
}
|
181 |
+
|
182 |
+
// Get the option HTML.
|
183 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
184 |
+
|
185 |
+
echo '</div>';
|
186 |
+
|
187 |
+
echo '</div>';
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
echo '<div class="clear"></div>';
|
192 |
+
|
193 |
+
echo '</div>';
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Saves the meta box values
|
198 |
+
*
|
199 |
+
* @access public
|
200 |
+
* @since 1.0
|
201 |
+
*
|
202 |
+
* @param int $post_id The post ID.
|
203 |
+
* @param object $post_object The WP_Post object.
|
204 |
+
* @return int|void
|
205 |
+
*/
|
206 |
+
public function save_meta_box( $post_id, $post_object ) {
|
207 |
+
global $pagenow;
|
208 |
+
|
209 |
+
// Verify nonce.
|
210 |
+
if ( isset( $_POST[ $this->meta_box['id'] . '_nonce' ] ) && ! wp_verify_nonce( $_POST[ $this->meta_box['id'] . '_nonce' ], $this->meta_box['id'] ) ) { // phpcs:ignore
|
211 |
+
return $post_id;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Store the post global for use later.
|
215 |
+
$post_global = $_POST;
|
216 |
+
|
217 |
+
// Don't save if $_POST is empty.
|
218 |
+
if ( empty( $post_global ) || ( isset( $post_global['vc_inline'] ) && true === $post_global['vc_inline'] ) ) {
|
219 |
+
return $post_id;
|
220 |
+
}
|
221 |
+
|
222 |
+
// Don't save during quick edit.
|
223 |
+
if ( 'admin-ajax.php' === $pagenow ) {
|
224 |
+
return $post_id;
|
225 |
+
}
|
226 |
+
|
227 |
+
// Don't save during autosave.
|
228 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
229 |
+
return $post_id;
|
230 |
+
}
|
231 |
+
|
232 |
+
// Don't save if viewing a revision.
|
233 |
+
if ( 'revision' === $post_object->post_type || 'revision.php' === $pagenow ) {
|
234 |
+
return $post_id;
|
235 |
+
}
|
236 |
+
|
237 |
+
// Check permissions.
|
238 |
+
if ( isset( $post_global['post_type'] ) && 'page' === $post_global['post_type'] ) {
|
239 |
+
if ( ! current_user_can( 'edit_page', $post_id ) ) {
|
240 |
+
return $post_id;
|
241 |
+
}
|
242 |
+
} else {
|
243 |
+
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
244 |
+
return $post_id;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
foreach ( $this->meta_box['fields'] as $field ) {
|
249 |
+
|
250 |
+
$old = get_post_meta( $post_id, $field['id'], true );
|
251 |
+
$new = '';
|
252 |
+
|
253 |
+
// There is data to validate.
|
254 |
+
if ( isset( $post_global[ $field['id'] ] ) ) {
|
255 |
+
|
256 |
+
// Slider and list item.
|
257 |
+
if ( in_array( $field['type'], array( 'list-item', 'slider' ), true ) ) {
|
258 |
+
|
259 |
+
// Required title setting.
|
260 |
+
$required_setting = array(
|
261 |
+
array(
|
262 |
+
'id' => 'title',
|
263 |
+
'label' => __( 'Title', 'option-tree' ),
|
264 |
+
'desc' => '',
|
265 |
+
'std' => '',
|
266 |
+
'type' => 'text',
|
267 |
+
'rows' => '',
|
268 |
+
'class' => 'option-tree-setting-title',
|
269 |
+
'post_type' => '',
|
270 |
+
'choices' => array(),
|
271 |
+
),
|
272 |
+
);
|
273 |
+
|
274 |
+
// Convert the settings to an array.
|
275 |
+
$settings = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : array();
|
276 |
+
|
277 |
+
// Settings are empty for some odd reason get the defaults.
|
278 |
+
if ( empty( $settings ) ) {
|
279 |
+
$settings = ( 'slider' === $field['type'] ) ? ot_slider_settings( $field['id'] ) : ot_list_item_settings( $field['id'] );
|
280 |
+
}
|
281 |
+
|
282 |
+
// Merge the two settings array.
|
283 |
+
$settings = array_merge( $required_setting, $settings );
|
284 |
+
|
285 |
+
foreach ( $post_global[ $field['id'] ] as $k => $setting_array ) {
|
286 |
+
|
287 |
+
foreach ( $settings as $sub_setting ) {
|
288 |
+
|
289 |
+
// Verify sub setting has a type & value.
|
290 |
+
if ( isset( $sub_setting['type'] ) && isset( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
291 |
+
|
292 |
+
$post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'] );
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
// Set up new data with validated data.
|
298 |
+
$new = $post_global[ $field['id'] ];
|
299 |
+
|
300 |
+
} elseif ( 'social-links' === $field['type'] ) {
|
301 |
+
|
302 |
+
// Convert the settings to an array.
|
303 |
+
$settings = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : array();
|
304 |
+
|
305 |
+
// Settings are empty get the defaults.
|
306 |
+
if ( empty( $settings ) ) {
|
307 |
+
$settings = ot_social_links_settings( $field['id'] );
|
308 |
+
}
|
309 |
+
|
310 |
+
foreach ( $post_global[ $field['id'] ] as $k => $setting_array ) {
|
311 |
+
|
312 |
+
foreach ( $settings as $sub_setting ) {
|
313 |
+
|
314 |
+
// Verify sub setting has a type & value.
|
315 |
+
if ( isset( $sub_setting['type'] ) && isset( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
316 |
+
$post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'] );
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
// Set up new data with validated data.
|
322 |
+
$new = $post_global[ $field['id'] ];
|
323 |
+
} else {
|
324 |
+
|
325 |
+
// Run through validation.
|
326 |
+
$new = ot_validate_setting( $post_global[ $field['id'] ], $field['type'], $field['id'] );
|
327 |
+
}
|
328 |
+
|
329 |
+
// Insert CSS.
|
330 |
+
if ( 'css' === $field['type'] ) {
|
331 |
+
|
332 |
+
if ( '' !== $new ) {
|
333 |
+
|
334 |
+
// insert CSS into dynamic.css.
|
335 |
+
ot_insert_css_with_markers( $field['id'], $new, true );
|
336 |
+
} else {
|
337 |
+
|
338 |
+
// Remove old CSS from dynamic.css.
|
339 |
+
ot_remove_old_css( $field['id'] );
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
if ( isset( $new ) && $new !== $old ) {
|
345 |
+
update_post_meta( $post_id, $field['id'], $new );
|
346 |
+
} elseif ( '' === $new && $old ) {
|
347 |
+
delete_post_meta( $post_id, $field['id'], $old );
|
348 |
+
}
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
}
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
if ( ! function_exists( 'ot_register_meta_box' ) ) {
|
357 |
+
|
358 |
+
/**
|
359 |
+
* This method instantiates the meta box class & builds the UI.
|
360 |
+
*
|
361 |
+
* @uses OT_Meta_Box()
|
362 |
+
*
|
363 |
+
* @param array $args Meta box arguments.
|
364 |
+
*
|
365 |
+
* @access public
|
366 |
+
* @since 2.0
|
367 |
+
*/
|
368 |
+
function ot_register_meta_box( $args ) {
|
369 |
+
if ( ! $args ) {
|
370 |
+
return;
|
371 |
+
}
|
372 |
+
|
373 |
+
new OT_Meta_Box( $args );
|
374 |
+
}
|
375 |
+
}
|
admin/includes/class-ot-post-formats.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Post Formats.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Post_Formats' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Post Formats class.
|
16 |
+
*
|
17 |
+
* This class loads all the methods and helpers specific to build a the post format metaboxes.
|
18 |
+
*/
|
19 |
+
class OT_Post_Formats {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class Constructor
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @since 2.3.0
|
26 |
+
*/
|
27 |
+
public function __construct() {
|
28 |
+
$this->setup_actions();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Setup the default filters and actions.
|
33 |
+
*
|
34 |
+
* @uses add_action() To add various actions.
|
35 |
+
* @uses add_filter() To add various filters.
|
36 |
+
*
|
37 |
+
* @access private
|
38 |
+
* @since 2.3.0
|
39 |
+
*/
|
40 |
+
private function setup_actions() {
|
41 |
+
|
42 |
+
// Initialize the meta boxes.
|
43 |
+
add_action( 'admin_init', array( $this, 'meta_boxes' ), 2 );
|
44 |
+
|
45 |
+
// Setup pings for the link & quote URLs.
|
46 |
+
add_filter( 'pre_ping', array( $this, 'pre_ping_post_links' ), 10, 3 );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Builds the default Meta Boxes.
|
51 |
+
*
|
52 |
+
* @access private
|
53 |
+
* @since 2.3.0
|
54 |
+
*/
|
55 |
+
public function meta_boxes() {
|
56 |
+
|
57 |
+
// Exit if called outside of WP admin.
|
58 |
+
if ( ! is_admin() ) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Filter the post formats meta boxes.
|
64 |
+
*
|
65 |
+
* @since 2.6.0
|
66 |
+
*
|
67 |
+
* @param array $meta_boxes The meta boxes being registered.
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
+
$meta_boxes = apply_filters(
|
71 |
+
'ot_recognized_post_format_meta_boxes',
|
72 |
+
array(
|
73 |
+
ot_meta_box_post_format_gallery(),
|
74 |
+
ot_meta_box_post_format_link(),
|
75 |
+
ot_meta_box_post_format_quote(),
|
76 |
+
ot_meta_box_post_format_video(),
|
77 |
+
ot_meta_box_post_format_audio(),
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Register our meta boxes using the
|
83 |
+
* ot_register_meta_box() function.
|
84 |
+
*/
|
85 |
+
foreach ( $meta_boxes as $meta_box ) {
|
86 |
+
ot_register_meta_box( $meta_box );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Setup pings for the link & quote URLs
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @since 2.3.0
|
95 |
+
*
|
96 |
+
* @param array $post_links The URLs to ping.
|
97 |
+
* @param array $pung Pinged URLs.
|
98 |
+
* @param int $post_id Post ID.
|
99 |
+
*/
|
100 |
+
public function pre_ping_post_links( $post_links, $pung, $post_id = null ) {
|
101 |
+
|
102 |
+
$_link = get_post_meta( $post_id, '_format_link_url', true );
|
103 |
+
if ( ! empty( $_link ) && ! in_array( $_link, $pung, true ) && ! in_array( $_link, $post_links, true ) ) {
|
104 |
+
$post_links[] = $_link;
|
105 |
+
}
|
106 |
+
|
107 |
+
$_quote = get_post_meta( $post_id, '_format_quote_source_url', true );
|
108 |
+
if ( ! empty( $_quote ) && ! in_array( $_quote, $pung, true ) && ! in_array( $_quote, $post_links, true ) ) {
|
109 |
+
$post_links[] = $_quote;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Instantiate The Class.
|
117 |
+
*
|
118 |
+
* @since 1.0
|
119 |
+
*/
|
120 |
+
if ( function_exists( 'ot_register_meta_box' ) ) {
|
121 |
+
new OT_Post_Formats();
|
122 |
+
}
|
admin/includes/class-ot-settings.php
ADDED
@@ -0,0 +1,1045 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Settings.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Settings' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Settings class.
|
16 |
+
*
|
17 |
+
* This class loads all the methods and helpers specific to a Settings page.
|
18 |
+
*/
|
19 |
+
class OT_Settings {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* An array of options.
|
23 |
+
*
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
private $options;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Page hook for targeting admin page.
|
30 |
+
*
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
private $page_hook;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
*
|
38 |
+
* @param array $args An array of options.
|
39 |
+
*
|
40 |
+
* @access public
|
41 |
+
* @since 2.0
|
42 |
+
*/
|
43 |
+
public function __construct( $args ) {
|
44 |
+
|
45 |
+
$this->options = $args;
|
46 |
+
|
47 |
+
// Return early if not viewing an admin page or no options.
|
48 |
+
if ( ! is_admin() || ! is_array( $this->options ) ) {
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
// Load everything.
|
53 |
+
$this->hooks();
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Execute the WordPress Hooks
|
58 |
+
*
|
59 |
+
* @access public
|
60 |
+
* @since 2.0
|
61 |
+
*/
|
62 |
+
public function hooks() {
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Filter the `admin_menu` action hook priority.
|
66 |
+
*
|
67 |
+
* @since 2.5.0
|
68 |
+
*
|
69 |
+
* @param int $priority The priority. Default '10'.
|
70 |
+
*/
|
71 |
+
$priority = apply_filters( 'ot_admin_menu_priority', 10 );
|
72 |
+
|
73 |
+
// Add pages & menu items.
|
74 |
+
add_action( 'admin_menu', array( $this, 'add_page' ), $priority );
|
75 |
+
|
76 |
+
// Register sections.
|
77 |
+
add_action( 'admin_init', array( $this, 'add_sections' ) );
|
78 |
+
|
79 |
+
// Register settings.
|
80 |
+
add_action( 'admin_init', array( $this, 'add_settings' ) );
|
81 |
+
|
82 |
+
// Reset options.
|
83 |
+
add_action( 'admin_init', array( $this, 'reset_options' ), 10 );
|
84 |
+
|
85 |
+
// Initialize settings.
|
86 |
+
add_action( 'admin_init', array( $this, 'initialize_settings' ), 11 );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Loads each admin page
|
91 |
+
*
|
92 |
+
* @return bool
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @since 2.0
|
96 |
+
*/
|
97 |
+
public function add_page() {
|
98 |
+
|
99 |
+
// Loop through options.
|
100 |
+
foreach ( (array) $this->options as $option ) {
|
101 |
+
|
102 |
+
// Loop through pages.
|
103 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Theme Check... stop nagging me about this kind of stuff.
|
107 |
+
* The damn admin pages are required for OT to function, duh!
|
108 |
+
*/
|
109 |
+
$theme_check_bs = 'add_menu_' . 'page'; // phpcs:ignore
|
110 |
+
$theme_check_bs2 = 'add_submenu_' . 'page'; // phpcs:ignore
|
111 |
+
|
112 |
+
// Load page in WP top level menu.
|
113 |
+
if ( ! isset( $page['parent_slug'] ) || empty( $page['parent_slug'] ) ) {
|
114 |
+
$page_hook = $theme_check_bs(
|
115 |
+
$page['page_title'],
|
116 |
+
$page['menu_title'],
|
117 |
+
$page['capability'],
|
118 |
+
$page['menu_slug'],
|
119 |
+
array( $this, 'display_page' ),
|
120 |
+
$page['icon_url'],
|
121 |
+
$page['position']
|
122 |
+
);
|
123 |
+
|
124 |
+
// Load page in WP sub menu.
|
125 |
+
} else {
|
126 |
+
$page_hook = $theme_check_bs2(
|
127 |
+
$page['parent_slug'],
|
128 |
+
$page['page_title'],
|
129 |
+
$page['menu_title'],
|
130 |
+
$page['capability'],
|
131 |
+
$page['menu_slug'],
|
132 |
+
array( $this, 'display_page' )
|
133 |
+
);
|
134 |
+
}
|
135 |
+
|
136 |
+
// Only load if not a hidden page.
|
137 |
+
if ( ! isset( $page['hidden_page'] ) ) {
|
138 |
+
|
139 |
+
// Associate $page_hook with page id.
|
140 |
+
$this->page_hook[ $page['id'] ] = $page_hook;
|
141 |
+
|
142 |
+
// Add scripts.
|
143 |
+
add_action( 'admin_print_scripts-' . $page_hook, array( $this, 'scripts' ) );
|
144 |
+
|
145 |
+
// Add styles.
|
146 |
+
add_action( 'admin_print_styles-' . $page_hook, array( $this, 'styles' ) );
|
147 |
+
|
148 |
+
// Add contextual help.
|
149 |
+
add_action( 'load-' . $page_hook, array( $this, 'help' ) );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Loads the scripts
|
159 |
+
*
|
160 |
+
* @access public
|
161 |
+
* @since 2.0
|
162 |
+
*/
|
163 |
+
public function scripts() {
|
164 |
+
ot_admin_scripts();
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Loads the styles
|
169 |
+
*
|
170 |
+
* @access public
|
171 |
+
* @since 2.0
|
172 |
+
*/
|
173 |
+
public function styles() {
|
174 |
+
ot_admin_styles();
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Loads the contextual help for each page
|
179 |
+
*
|
180 |
+
* @return bool
|
181 |
+
*
|
182 |
+
* @access public
|
183 |
+
* @since 2.0
|
184 |
+
*/
|
185 |
+
public function help() {
|
186 |
+
$screen = get_current_screen();
|
187 |
+
|
188 |
+
// Loop through options.
|
189 |
+
foreach ( (array) $this->options as $option ) {
|
190 |
+
|
191 |
+
// Loop through pages.
|
192 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
193 |
+
|
194 |
+
// Verify page.
|
195 |
+
if ( ! isset( $page['hidden_page'] ) && $screen->id === $this->page_hook[ $page['id'] ] ) {
|
196 |
+
|
197 |
+
// Set up the help tabs.
|
198 |
+
if ( ! empty( $page['contextual_help']['content'] ) ) {
|
199 |
+
foreach ( $page['contextual_help']['content'] as $contextual_help ) {
|
200 |
+
$screen->add_help_tab(
|
201 |
+
array(
|
202 |
+
'id' => esc_attr( $contextual_help['id'] ),
|
203 |
+
'title' => esc_attr( $contextual_help['title'] ),
|
204 |
+
'content' => htmlspecialchars_decode( $contextual_help['content'] ),
|
205 |
+
)
|
206 |
+
);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
// Set up the help sidebar.
|
211 |
+
if ( ! empty( $page['contextual_help']['sidebar'] ) ) {
|
212 |
+
$screen->set_help_sidebar( htmlspecialchars_decode( $page['contextual_help']['sidebar'] ) );
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return false;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Loads the content for each page
|
223 |
+
*
|
224 |
+
* @access public
|
225 |
+
* @since 2.0
|
226 |
+
*/
|
227 |
+
public function display_page() {
|
228 |
+
$screen = get_current_screen();
|
229 |
+
|
230 |
+
// Loop through settings.
|
231 |
+
foreach ( (array) $this->options as $option ) {
|
232 |
+
|
233 |
+
// Loop through pages.
|
234 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
235 |
+
|
236 |
+
// Verify page.
|
237 |
+
if ( ! isset( $page['hidden_page'] ) && $screen->id === $this->page_hook[ $page['id'] ] ) {
|
238 |
+
|
239 |
+
$show_buttons = isset( $page['show_buttons'] ) && false === $page['show_buttons'] ? false : true;
|
240 |
+
|
241 |
+
// Update active layout content.
|
242 |
+
if ( isset( $_REQUEST['settings-updated'] ) && true === filter_var( wp_unslash( $_REQUEST['settings-updated'] ), FILTER_VALIDATE_BOOLEAN ) ) { // phpcs:ignore
|
243 |
+
|
244 |
+
$layouts = get_option( ot_layouts_id() );
|
245 |
+
|
246 |
+
// Has active layout.
|
247 |
+
if ( isset( $layouts['active_layout'] ) ) {
|
248 |
+
$option_tree = get_option( $option['id'], array() );
|
249 |
+
$layouts[ $layouts['active_layout'] ] = ot_encode( $option_tree );
|
250 |
+
update_option( ot_layouts_id(), $layouts );
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
echo '<div class="wrap settings-wrap" id="page-' . esc_attr( $page['id'] ) . '">';
|
255 |
+
|
256 |
+
echo '<h2>' . wp_kses_post( $page['page_title'] ) . '</h2>';
|
257 |
+
|
258 |
+
echo ot_alert_message( $page ); // phpcs:ignore
|
259 |
+
|
260 |
+
settings_errors( 'option-tree' );
|
261 |
+
|
262 |
+
// Header.
|
263 |
+
echo '<div id="option-tree-header-wrap">';
|
264 |
+
|
265 |
+
echo '<ul id="option-tree-header">';
|
266 |
+
|
267 |
+
// Add additional theme specific links here.
|
268 |
+
do_action( 'ot_header_list', $page['id'] );
|
269 |
+
|
270 |
+
echo '</ul>';
|
271 |
+
|
272 |
+
// Layouts form.
|
273 |
+
if ( 'ot_theme_options' === $page['id'] && true === OT_SHOW_NEW_LAYOUT ) {
|
274 |
+
ot_theme_options_layouts_form();
|
275 |
+
}
|
276 |
+
|
277 |
+
echo '</div>';
|
278 |
+
|
279 |
+
// Remove forms on the custom settings pages.
|
280 |
+
if ( $show_buttons ) {
|
281 |
+
|
282 |
+
echo '<form action="options.php" method="post" id="option-tree-settings-api">';
|
283 |
+
|
284 |
+
settings_fields( $option['id'] );
|
285 |
+
} else {
|
286 |
+
|
287 |
+
echo '<div id="option-tree-settings-api">';
|
288 |
+
}
|
289 |
+
|
290 |
+
/* Sub Header */
|
291 |
+
echo '<div id="option-tree-sub-header">';
|
292 |
+
|
293 |
+
|
294 |
+
|
295 |
+
if ( $show_buttons )
|
296 |
+
echo '<button class="option-tree-ui-button button button-primary right">' . $page['button_text'] . '</button>';
|
297 |
+
echo '<a target="_blank" href="'. get_site_url().'/?get_preview=true"><div class="option-tree-ui-button button right">Live Preview</div></a>';
|
298 |
+
$options = get_option('nifty_options');
|
299 |
+
if (false && empty($options['hide_notice']['rate'])) {
|
300 |
+
$dismiss_url = add_query_arg(array('action' => 'nifty_dismiss_notice', 'notice' => 'rate', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
|
301 |
+
echo '<div id="rate-plugin">Please help us out by rating Nifty. It only takes a second & it helps to keep the plugin going! <b>Thank you!</b><p><a target="_blank" href="https://wordpress.org/support/plugin/nifty-coming-soon-and-under-construction-page/reviews/#new-post" class="button button-primary">I want to help! Let\'s rate the plugin!</a> <a href="' . $dismiss_url . '">I\'ve already rated Nifty</a></p></div>';
|
302 |
+
}
|
303 |
+
|
304 |
+
if (empty($options['hide_notice']['weforms']) && !ot_is_weforms_active()) {
|
305 |
+
$dismiss_url = add_query_arg(array('action' => 'nifty_dismiss_notice', 'notice' => 'weforms', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
|
306 |
+
echo '<div id="rate-plugin">Collecting leads & subscribers is the key function of any Coming Soon page. That\'s why we partnered with the free <a href="#" class="open-weforms-upsell">weForms</a> plugin to enable you to start collecting leads and subscribers. A contact form, event registration form, survey form - weForms supports all of them.<p><a href="#" class="button button-primary open-weforms-upsell">Install the free weForms plugin & start collecting leads</a> <a href="' . $dismiss_url . '">I\'m not interested</a></p></div>';
|
307 |
+
}
|
308 |
+
|
309 |
+
/*
|
310 |
+
echo '<div class="of-notice-small"><p>All themes come with <b>optin boxes</b> & <b>optin popups</b> that you can connect to Mailchimp and other autoresponders to collect leads & subscribers.';
|
311 |
+
if (ot_is_weforms_active()) {
|
312 |
+
echo '<br>Configure them in <a href="#weforms_sign_up_form" class="change_tab" data-tab="0">General Settings - weForms</a> settings.';
|
313 |
+
} else {
|
314 |
+
echo '<br>To enable this feature <a class="open-weforms-upsell" href="#">install the free weForms plugin</a>.';
|
315 |
+
}
|
316 |
+
echo '</p></div>';
|
317 |
+
*/
|
318 |
+
|
319 |
+
// weforms install dialog
|
320 |
+
echo '<div id="weforms-upsell-dialog" style="display: none;" title="weForms"><span class="ui-helper-hidden-accessible"><input type="text"/></span>';
|
321 |
+
echo '<div style="padding: 20px; font-size: 14px;">';
|
322 |
+
echo '<ul class="weforms-list">';
|
323 |
+
echo '<li>free plugin that integrates with Nifty</li>';
|
324 |
+
echo '<li>instantly create any kind of form you need</li>';
|
325 |
+
echo '<li>collect leads & subscribers</li>';
|
326 |
+
echo '<li>easily connect with leading autoresponder services</li>';
|
327 |
+
echo '<li>completely customize the look & feel of your form</li>';
|
328 |
+
echo '</ul>';
|
329 |
+
echo '<p class="upsell-footer"><a class="button button-primary" id="install-weforms">Install & activate weForms to create any form you need</a></p>';
|
330 |
+
echo '</div>';
|
331 |
+
echo '</div>'; // weforms install dialog
|
332 |
+
|
333 |
+
|
334 |
+
|
335 |
+
echo '</div>';
|
336 |
+
|
337 |
+
// Navigation.
|
338 |
+
echo '<div class="ui-tabs">';
|
339 |
+
|
340 |
+
// Check for sections.
|
341 |
+
if ( isset( $page['sections'] ) && 0 < count( $page['sections'] ) ) {
|
342 |
+
|
343 |
+
echo '<ul class="ui-tabs-nav">';
|
344 |
+
|
345 |
+
// Loop through page sections.
|
346 |
+
foreach ( (array) $page['sections'] as $section ) {
|
347 |
+
echo '<li id="tab_' . esc_attr( $section['id'] ) . '"><a href="#section_' . esc_attr( $section['id'] ) . '">' . wp_kses_post( $section['title'] ) . '</a></li>';
|
348 |
+
}
|
349 |
+
|
350 |
+
echo '</ul>';
|
351 |
+
}
|
352 |
+
|
353 |
+
// Sections.
|
354 |
+
echo '<div id="poststuff" class="metabox-holder">';
|
355 |
+
|
356 |
+
echo '<div id="post-body">';
|
357 |
+
|
358 |
+
echo '<div id="post-body-content">';
|
359 |
+
|
360 |
+
$this->do_settings_sections( isset( $_GET['page'] ) ? $_GET['page'] : '' ); // phpcs:ignore
|
361 |
+
|
362 |
+
echo '</div>';
|
363 |
+
|
364 |
+
echo '</div>';
|
365 |
+
|
366 |
+
echo '</div>';
|
367 |
+
|
368 |
+
echo '<div class="clear"></div>';
|
369 |
+
|
370 |
+
echo '</div>';
|
371 |
+
|
372 |
+
// Buttons.
|
373 |
+
if ( $show_buttons ) {
|
374 |
+
|
375 |
+
echo '<div class="option-tree-ui-buttons">';
|
376 |
+
|
377 |
+
echo '<button class="option-tree-ui-button button button-primary right">' . esc_html( $page['button_text'] ) . '</button>';
|
378 |
+
|
379 |
+
echo '</div>';
|
380 |
+
}
|
381 |
+
|
382 |
+
echo $show_buttons ? '</form>' : '</div>';
|
383 |
+
|
384 |
+
// Reset button.
|
385 |
+
if ( $show_buttons ) {
|
386 |
+
|
387 |
+
echo '<form method="post" action="' . esc_url_raw( str_replace( '&settings-updated=true', '', $_SERVER['REQUEST_URI'] ) ) . '">'; // phpcs:ignore
|
388 |
+
|
389 |
+
// Form nonce.
|
390 |
+
wp_nonce_field( 'option_tree_reset_form', 'option_tree_reset_nonce' );
|
391 |
+
|
392 |
+
echo '<input type="hidden" name="action" value="reset" />';
|
393 |
+
|
394 |
+
echo '<button type="submit" class="option-tree-ui-button button button-secondary left reset-settings" title="' . esc_html__( 'Reset Options', 'option-tree' ) . '">' . esc_html__( 'Reset Options', 'option-tree' ) . '</button>';
|
395 |
+
|
396 |
+
echo '</form>';
|
397 |
+
}
|
398 |
+
|
399 |
+
echo '</div>';
|
400 |
+
}
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
return false;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Adds sections to the page
|
409 |
+
*
|
410 |
+
* @return bool
|
411 |
+
*
|
412 |
+
* @access public
|
413 |
+
* @since 2.0
|
414 |
+
*/
|
415 |
+
public function add_sections() {
|
416 |
+
|
417 |
+
// Loop through options.
|
418 |
+
foreach ( (array) $this->options as $option ) {
|
419 |
+
|
420 |
+
// Loop through pages.
|
421 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
422 |
+
|
423 |
+
// Loop through page sections.
|
424 |
+
foreach ( (array) $this->get_sections( $page ) as $section ) {
|
425 |
+
|
426 |
+
// Add each section.
|
427 |
+
add_settings_section(
|
428 |
+
$section['id'],
|
429 |
+
$section['title'],
|
430 |
+
array( $this, 'display_section' ),
|
431 |
+
$page['menu_slug']
|
432 |
+
);
|
433 |
+
|
434 |
+
}
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
return false;
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* Callback for add_settings_section()
|
443 |
+
*
|
444 |
+
* @access public
|
445 |
+
* @since 2.0
|
446 |
+
*/
|
447 |
+
public function display_section() {
|
448 |
+
/* currently pointless */
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Add settings the the page
|
453 |
+
*
|
454 |
+
* @return bool
|
455 |
+
*
|
456 |
+
* @access public
|
457 |
+
* @since 2.0
|
458 |
+
*/
|
459 |
+
public function add_settings() {
|
460 |
+
|
461 |
+
// Loop through options.
|
462 |
+
foreach ( (array) $this->options as $option ) {
|
463 |
+
|
464 |
+
register_setting( $option['id'], $option['id'], array( $this, 'sanitize_callback' ) );
|
465 |
+
|
466 |
+
// Loop through pages.
|
467 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
468 |
+
|
469 |
+
// Loop through page settings.
|
470 |
+
foreach ( (array) $this->get_the_settings( $page ) as $setting ) {
|
471 |
+
|
472 |
+
// Skip if missing setting ID, label, or section.
|
473 |
+
if ( ! isset( $setting['id'] ) || ! isset( $setting['label'] ) || ! isset( $setting['section'] ) ) {
|
474 |
+
continue;
|
475 |
+
}
|
476 |
+
|
477 |
+
// Add get_option param to the array.
|
478 |
+
$setting['get_option'] = $option['id'];
|
479 |
+
|
480 |
+
// Add each setting.
|
481 |
+
add_settings_field(
|
482 |
+
$setting['id'],
|
483 |
+
$setting['label'],
|
484 |
+
array( $this, 'display_setting' ),
|
485 |
+
$page['menu_slug'],
|
486 |
+
$setting['section'],
|
487 |
+
$setting
|
488 |
+
);
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
return false;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Callback for add_settings_field() to build each setting by type
|
498 |
+
*
|
499 |
+
* @param array $args Setting object array.
|
500 |
+
*
|
501 |
+
* @access public
|
502 |
+
* @since 2.0
|
503 |
+
*/
|
504 |
+
public function display_setting( $args = array() ) {
|
505 |
+
extract( $args ); // phpcs:ignore
|
506 |
+
|
507 |
+
// Get current saved data.
|
508 |
+
$options = get_option( $get_option, false );
|
509 |
+
|
510 |
+
// Set field value.
|
511 |
+
$field_value = isset( $options[ $id ] ) ? $options[ $id ] : '';
|
512 |
+
|
513 |
+
// Set standard value.
|
514 |
+
if ( isset( $std ) ) {
|
515 |
+
$field_value = ot_filter_std_value( $field_value, $std );
|
516 |
+
}
|
517 |
+
|
518 |
+
// Allow the descriptions to be filtered before being displayed.
|
519 |
+
$desc = apply_filters( 'ot_filter_description', ( isset( $desc ) ? $desc : '' ), $id );
|
520 |
+
|
521 |
+
// Build the arguments array.
|
522 |
+
$_args = array(
|
523 |
+
'type' => $type,
|
524 |
+
'field_id' => $id,
|
525 |
+
'field_name' => $get_option . '[' . $id . ']',
|
526 |
+
'field_value' => $field_value,
|
527 |
+
'field_desc' => $desc,
|
528 |
+
'field_std' => isset( $std ) ? $std : '',
|
529 |
+
'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15,
|
530 |
+
'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post',
|
531 |
+
'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category',
|
532 |
+
'field_min_max_step' => isset( $min_max_step ) && ! empty( $min_max_step ) ? $min_max_step : '0,100,1',
|
533 |
+
'field_condition' => isset( $condition ) && ! empty( $condition ) ? $condition : '',
|
534 |
+
'field_operator' => isset( $operator ) && ! empty( $operator ) ? $operator : 'and',
|
535 |
+
'field_class' => isset( $class ) ? $class : '',
|
536 |
+
'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(),
|
537 |
+
'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(),
|
538 |
+
'post_id' => ot_get_media_post_ID(),
|
539 |
+
'get_option' => $get_option,
|
540 |
+
);
|
541 |
+
|
542 |
+
// Limit DB queries for Google Fonts.
|
543 |
+
if ( 'google-fonts' === $type ) {
|
544 |
+
ot_fetch_google_fonts();
|
545 |
+
ot_set_google_fonts( $id, $field_value );
|
546 |
+
}
|
547 |
+
|
548 |
+
// Get the option HTML.
|
549 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
550 |
+
}
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Sets the option standards if nothing yet exists.
|
554 |
+
*
|
555 |
+
* @access public
|
556 |
+
* @since 2.0
|
557 |
+
*/
|
558 |
+
public function initialize_settings() {
|
559 |
+
|
560 |
+
// Loop through options.
|
561 |
+
foreach ( (array) $this->options as $option ) {
|
562 |
+
|
563 |
+
// Skip if option is already set.
|
564 |
+
if ( isset( $option['id'] ) && get_option( $option['id'], false ) ) {
|
565 |
+
return false;
|
566 |
+
}
|
567 |
+
|
568 |
+
$defaults = array();
|
569 |
+
|
570 |
+
// Loop through pages.
|
571 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
572 |
+
|
573 |
+
// Loop through page settings.
|
574 |
+
foreach ( (array) $this->get_the_settings( $page ) as $setting ) {
|
575 |
+
|
576 |
+
if ( isset( $setting['std'] ) ) {
|
577 |
+
|
578 |
+
$defaults[ $setting['id'] ] = ot_validate_setting( $setting['std'], $setting['type'], $setting['id'] );
|
579 |
+
}
|
580 |
+
}
|
581 |
+
}
|
582 |
+
|
583 |
+
update_option( $option['id'], $defaults );
|
584 |
+
}
|
585 |
+
|
586 |
+
return false;
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Sanitize callback for register_setting()
|
591 |
+
*
|
592 |
+
* @param mixed $input The setting input.
|
593 |
+
* @return string
|
594 |
+
*
|
595 |
+
* @access public
|
596 |
+
* @since 2.0
|
597 |
+
*/
|
598 |
+
public function sanitize_callback( $input ) {
|
599 |
+
|
600 |
+
// Store the post global for use later.
|
601 |
+
$post_global = $_POST; // phpcs:ignore
|
602 |
+
|
603 |
+
// Loop through options.
|
604 |
+
foreach ( (array) $this->options as $option ) {
|
605 |
+
|
606 |
+
// Loop through pages.
|
607 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
608 |
+
|
609 |
+
// Loop through page settings.
|
610 |
+
foreach ( (array) $this->get_the_settings( $page ) as $setting ) {
|
611 |
+
|
612 |
+
// Verify setting has a type & value.
|
613 |
+
if ( isset( $setting['type'] ) && isset( $input[ $setting['id'] ] ) ) {
|
614 |
+
|
615 |
+
// Get the defaults.
|
616 |
+
$current_settings = get_option( ot_settings_id() );
|
617 |
+
$current_options = get_option( $option['id'] );
|
618 |
+
|
619 |
+
// Validate setting.
|
620 |
+
if ( is_array( $input[ $setting['id'] ] ) && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
621 |
+
|
622 |
+
// Required title setting.
|
623 |
+
$required_setting = array(
|
624 |
+
array(
|
625 |
+
'id' => 'title',
|
626 |
+
'label' => __( 'Title', 'option-tree' ),
|
627 |
+
'desc' => '',
|
628 |
+
'std' => '',
|
629 |
+
'type' => 'text',
|
630 |
+
'rows' => '',
|
631 |
+
'class' => 'option-tree-setting-title',
|
632 |
+
'post_type' => '',
|
633 |
+
'choices' => array(),
|
634 |
+
),
|
635 |
+
);
|
636 |
+
|
637 |
+
// Convert the settings to an array.
|
638 |
+
$settings = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : array();
|
639 |
+
|
640 |
+
// Settings are empty for some odd reason get the defaults.
|
641 |
+
if ( empty( $settings ) ) {
|
642 |
+
$settings = 'slider' === $setting['type'] ? ot_slider_settings( $setting['id'] ) : ot_list_item_settings( $setting['id'] );
|
643 |
+
}
|
644 |
+
|
645 |
+
// Merge the two settings arrays.
|
646 |
+
$settings = array_merge( $required_setting, $settings );
|
647 |
+
|
648 |
+
// Create an empty WPML id array.
|
649 |
+
$wpml_ids = array();
|
650 |
+
|
651 |
+
foreach ( $input[ $setting['id'] ] as $k => $setting_array ) {
|
652 |
+
|
653 |
+
$has_value = false;
|
654 |
+
foreach ( $settings as $sub_setting ) {
|
655 |
+
|
656 |
+
// Setup the WPML ID.
|
657 |
+
$wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
|
658 |
+
|
659 |
+
// Add id to array.
|
660 |
+
$wpml_ids[] = $wpml_id;
|
661 |
+
|
662 |
+
/* verify sub setting has a type & value */
|
663 |
+
if ( isset( $sub_setting['type'] ) && isset( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
664 |
+
|
665 |
+
// Validate setting.
|
666 |
+
$input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id );
|
667 |
+
$has_value = true;
|
668 |
+
}
|
669 |
+
}
|
670 |
+
|
671 |
+
if ( ! $has_value ) {
|
672 |
+
unset( $input[ $setting['id'] ][ $k ] );
|
673 |
+
}
|
674 |
+
}
|
675 |
+
} elseif ( is_array( $input[ $setting['id'] ] ) && 'social-links' === $setting['type'] ) {
|
676 |
+
|
677 |
+
// Convert the settings to an array.
|
678 |
+
$settings = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : array();
|
679 |
+
|
680 |
+
// Settings are empty get the defaults.
|
681 |
+
if ( empty( $settings ) ) {
|
682 |
+
$settings = ot_social_links_settings( $setting['id'] );
|
683 |
+
}
|
684 |
+
|
685 |
+
// Create an empty WPML id array.
|
686 |
+
$wpml_ids = array();
|
687 |
+
|
688 |
+
foreach ( $input[ $setting['id'] ] as $k => $setting_array ) {
|
689 |
+
|
690 |
+
$has_value = false;
|
691 |
+
foreach ( $settings as $sub_setting ) {
|
692 |
+
|
693 |
+
// Setup the WPML ID.
|
694 |
+
$wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
|
695 |
+
|
696 |
+
// Add id to array.
|
697 |
+
$wpml_ids[] = $wpml_id;
|
698 |
+
|
699 |
+
// Verify sub setting has a type & value.
|
700 |
+
if ( isset( $sub_setting['type'] ) && isset( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
701 |
+
|
702 |
+
if ( 'href' === $sub_setting['id'] ) {
|
703 |
+
$sub_setting['type'] = 'url';
|
704 |
+
}
|
705 |
+
|
706 |
+
// Validate setting.
|
707 |
+
$input_safe = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id );
|
708 |
+
|
709 |
+
if ( ! empty( $input_safe ) ) {
|
710 |
+
$input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = $input_safe;
|
711 |
+
$has_value = true;
|
712 |
+
}
|
713 |
+
}
|
714 |
+
}
|
715 |
+
|
716 |
+
if ( ! $has_value ) {
|
717 |
+
unset( $input[ $setting['id'] ][ $k ] );
|
718 |
+
}
|
719 |
+
}
|
720 |
+
} else {
|
721 |
+
$input[ $setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ], $setting['type'], $setting['id'], $setting['id'] );
|
722 |
+
}
|
723 |
+
}
|
724 |
+
|
725 |
+
// Unregister WPML strings that were deleted from lists and sliders.
|
726 |
+
if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
727 |
+
|
728 |
+
if ( ! isset( $wpml_ids ) ) {
|
729 |
+
$wpml_ids = array();
|
730 |
+
}
|
731 |
+
|
732 |
+
foreach ( $current_settings['settings'] as $check_setting ) {
|
733 |
+
|
734 |
+
if ( $setting['id'] === $check_setting['id'] && ! empty( $current_options[ $setting['id'] ] ) ) {
|
735 |
+
|
736 |
+
foreach ( $current_options[ $setting['id'] ] as $key => $value ) {
|
737 |
+
|
738 |
+
foreach ( $value as $ckey => $cvalue ) {
|
739 |
+
|
740 |
+
$id = $setting['id'] . '_' . $ckey . '_' . $key;
|
741 |
+
|
742 |
+
if ( ! in_array( $id, $wpml_ids, true ) ) {
|
743 |
+
ot_wpml_unregister_string( $id );
|
744 |
+
}
|
745 |
+
}
|
746 |
+
}
|
747 |
+
}
|
748 |
+
}
|
749 |
+
}
|
750 |
+
|
751 |
+
/* unregister WPML strings that were deleted from social links */
|
752 |
+
if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && 'social-links' === $setting['type'] ) {
|
753 |
+
|
754 |
+
if ( ! isset( $wpml_ids ) ) {
|
755 |
+
$wpml_ids = array();
|
756 |
+
}
|
757 |
+
|
758 |
+
foreach ( $current_settings['settings'] as $check_setting ) {
|
759 |
+
|
760 |
+
if ( $setting['id'] === $check_setting['id'] && ! empty( $current_options[ $setting['id'] ] ) ) {
|
761 |
+
|
762 |
+
foreach ( $current_options[ $setting['id'] ] as $key => $value ) {
|
763 |
+
|
764 |
+
foreach ( $value as $ckey => $cvalue ) {
|
765 |
+
|
766 |
+
$id = $setting['id'] . '_' . $ckey . '_' . $key;
|
767 |
+
|
768 |
+
if ( ! in_array( $id, $wpml_ids, true ) ) {
|
769 |
+
ot_wpml_unregister_string( $id );
|
770 |
+
}
|
771 |
+
}
|
772 |
+
}
|
773 |
+
}
|
774 |
+
}
|
775 |
+
}
|
776 |
+
}
|
777 |
+
}
|
778 |
+
}
|
779 |
+
|
780 |
+
return $input;
|
781 |
+
}
|
782 |
+
|
783 |
+
/**
|
784 |
+
* Helper function to get the pages array for an option
|
785 |
+
*
|
786 |
+
* @param array $option Option array.
|
787 |
+
* @return mixed
|
788 |
+
*
|
789 |
+
* @access public
|
790 |
+
* @since 2.0
|
791 |
+
*/
|
792 |
+
public function get_pages( $option = array() ) {
|
793 |
+
|
794 |
+
if ( empty( $option ) ) {
|
795 |
+
return false;
|
796 |
+
}
|
797 |
+
|
798 |
+
// Check for pages.
|
799 |
+
if ( isset( $option['pages'] ) && ! empty( $option['pages'] ) ) {
|
800 |
+
|
801 |
+
// Return pages array.
|
802 |
+
return $option['pages'];
|
803 |
+
|
804 |
+
}
|
805 |
+
|
806 |
+
return false;
|
807 |
+
}
|
808 |
+
|
809 |
+
/**
|
810 |
+
* Helper function to get the sections array for a page
|
811 |
+
*
|
812 |
+
* @param array $page Page array.
|
813 |
+
* @return mixed
|
814 |
+
*
|
815 |
+
* @access public
|
816 |
+
* @since 2.0
|
817 |
+
*/
|
818 |
+
public function get_sections( $page = array() ) {
|
819 |
+
|
820 |
+
if ( empty( $page ) ) {
|
821 |
+
return false;
|
822 |
+
}
|
823 |
+
|
824 |
+
// Check for sections.
|
825 |
+
if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) {
|
826 |
+
|
827 |
+
// Return sections array.
|
828 |
+
return $page['sections'];
|
829 |
+
|
830 |
+
}
|
831 |
+
|
832 |
+
return false;
|
833 |
+
}
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Helper function to get the settings array for a page
|
837 |
+
*
|
838 |
+
* @param array $page Page array.
|
839 |
+
* @return mixed
|
840 |
+
*
|
841 |
+
* @access public
|
842 |
+
* @since 2.0
|
843 |
+
*/
|
844 |
+
public function get_the_settings( $page = array() ) {
|
845 |
+
|
846 |
+
if ( empty( $page ) ) {
|
847 |
+
return false;
|
848 |
+
}
|
849 |
+
|
850 |
+
/* check for settings */
|
851 |
+
if ( isset( $page['settings'] ) && ! empty( $page['settings'] ) ) {
|
852 |
+
|
853 |
+
/* return settings array */
|
854 |
+
return $page['settings'];
|
855 |
+
|
856 |
+
}
|
857 |
+
|
858 |
+
return false;
|
859 |
+
}
|
860 |
+
|
861 |
+
/**
|
862 |
+
* Prints out all settings sections added to a particular settings page
|
863 |
+
*
|
864 |
+
* @global $wp_settings_sections Storage array of all settings sections added to admin pages.
|
865 |
+
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
|
866 |
+
*
|
867 |
+
* @param string $page The slug name of the page whos settings sections you want to output.
|
868 |
+
* @return string
|
869 |
+
*
|
870 |
+
* @access public
|
871 |
+
* @since 2.0
|
872 |
+
*/
|
873 |
+
public function do_settings_sections( $page ) {
|
874 |
+
global $wp_settings_sections, $wp_settings_fields;
|
875 |
+
|
876 |
+
if ( ! isset( $wp_settings_sections ) || ! isset( $wp_settings_sections[ $page ] ) ) {
|
877 |
+
return false;
|
878 |
+
}
|
879 |
+
|
880 |
+
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
|
881 |
+
|
882 |
+
if ( ! isset( $section['id'] ) ) {
|
883 |
+
continue;
|
884 |
+
}
|
885 |
+
|
886 |
+
$section_id = $section['id'];
|
887 |
+
|
888 |
+
echo '<div id="section_' . esc_attr( $section_id ) . '" class="postbox ui-tabs-panel">';
|
889 |
+
|
890 |
+
call_user_func( $section['callback'], $section );
|
891 |
+
|
892 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section_id ] ) ) {
|
893 |
+
continue;
|
894 |
+
}
|
895 |
+
|
896 |
+
echo '<div class="inside">';
|
897 |
+
|
898 |
+
/**
|
899 |
+
* Hook to insert arbitrary markup before the `do_settings_fields` method.
|
900 |
+
*
|
901 |
+
* @since 2.6.0
|
902 |
+
*
|
903 |
+
* @param string $page The page slug.
|
904 |
+
* @param string $section_id The section ID.
|
905 |
+
*/
|
906 |
+
do_action( 'ot_do_settings_fields_before', $page, $section_id );
|
907 |
+
|
908 |
+
$this->do_settings_fields( $page, $section_id );
|
909 |
+
|
910 |
+
/**
|
911 |
+
* Hook to insert arbitrary markup after the `do_settings_fields` method.
|
912 |
+
*
|
913 |
+
* @since 2.6.0
|
914 |
+
*
|
915 |
+
* @param string $page The page slug.
|
916 |
+
* @param string $section_id The section ID.
|
917 |
+
*/
|
918 |
+
do_action( 'ot_do_settings_fields_after', $page, $section_id );
|
919 |
+
|
920 |
+
echo '</div>';
|
921 |
+
|
922 |
+
echo '</div>';
|
923 |
+
}
|
924 |
+
|
925 |
+
}
|
926 |
+
|
927 |
+
/**
|
928 |
+
* Print out the settings fields for a particular settings section
|
929 |
+
*
|
930 |
+
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
|
931 |
+
*
|
932 |
+
* @param string $page Slug title of the admin page who's settings fields you want to show.
|
933 |
+
* @param string $section Slug title of the settings section who's fields you want to show.
|
934 |
+
* @return string
|
935 |
+
*
|
936 |
+
* @access public
|
937 |
+
* @since 2.0
|
938 |
+
*/
|
939 |
+
public function do_settings_fields( $page, $section ) {
|
940 |
+
global $wp_settings_fields;
|
941 |
+
|
942 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
|
943 |
+
return;
|
944 |
+
}
|
945 |
+
|
946 |
+
foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
|
947 |
+
|
948 |
+
$conditions = '';
|
949 |
+
|
950 |
+
if ( isset( $field['args']['condition'] ) && ! empty( $field['args']['condition'] ) ) {
|
951 |
+
|
952 |
+
$conditions = ' data-condition="' . esc_attr( $field['args']['condition'] ) . '"';
|
953 |
+
$conditions .= isset( $field['args']['operator'] ) && in_array( $field['args']['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['args']['operator'] ) . '"' : '';
|
954 |
+
}
|
955 |
+
|
956 |
+
// Build the setting CSS class.
|
957 |
+
if ( isset( $field['args']['class'] ) && ! empty( $field['args']['class'] ) ) {
|
958 |
+
|
959 |
+
$classes = explode( ' ', $field['args']['class'] );
|
960 |
+
|
961 |
+
foreach ( $classes as $key => $value ) {
|
962 |
+
$classes[ $key ] = $value . '-wrap';
|
963 |
+
}
|
964 |
+
|
965 |
+
$class = 'format-settings ' . implode( ' ', $classes );
|
966 |
+
} else {
|
967 |
+
|
968 |
+
$class = 'format-settings';
|
969 |
+
}
|
970 |
+
|
971 |
+
echo '<div id="setting_' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $class ) . '"' . $conditions . '>'; // phpcs:ignore
|
972 |
+
|
973 |
+
echo '<div class="format-setting-wrap">';
|
974 |
+
|
975 |
+
if ( 'textblock' !== $field['args']['type'] && ! empty( $field['title'] ) ) {
|
976 |
+
|
977 |
+
echo '<div class="format-setting-label">';
|
978 |
+
|
979 |
+
echo '<h3 class="label">' . wp_kses_post( $field['title'] ) . '</h3>';
|
980 |
+
|
981 |
+
echo '</div>';
|
982 |
+
}
|
983 |
+
|
984 |
+
call_user_func( $field['callback'], $field['args'] );
|
985 |
+
|
986 |
+
echo '</div>';
|
987 |
+
|
988 |
+
echo '</div>';
|
989 |
+
}
|
990 |
+
}
|
991 |
+
|
992 |
+
/**
|
993 |
+
* Resets page options before the screen is displayed
|
994 |
+
*
|
995 |
+
* @access public
|
996 |
+
* @since 2.0
|
997 |
+
*
|
998 |
+
* @return bool
|
999 |
+
*/
|
1000 |
+
public function reset_options() {
|
1001 |
+
|
1002 |
+
// Check for reset action.
|
1003 |
+
if ( isset( $_POST['option_tree_reset_nonce'] ) && wp_verify_nonce( $_POST['option_tree_reset_nonce'], 'option_tree_reset_form' ) ) { // phpcs:ignore
|
1004 |
+
|
1005 |
+
// Loop through options.
|
1006 |
+
foreach ( (array) $this->options as $option ) {
|
1007 |
+
|
1008 |
+
// Loop through pages.
|
1009 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
1010 |
+
|
1011 |
+
// Verify page.
|
1012 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] === $page['menu_slug'] ) {
|
1013 |
+
|
1014 |
+
// Reset options.
|
1015 |
+
delete_option( $option['id'] );
|
1016 |
+
}
|
1017 |
+
}
|
1018 |
+
}
|
1019 |
+
}
|
1020 |
+
return false;
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
if ( ! function_exists( 'ot_register_settings' ) ) {
|
1027 |
+
|
1028 |
+
/**
|
1029 |
+
* This method instantiates the settings class & builds the UI.
|
1030 |
+
*
|
1031 |
+
* @uses OT_Settings()
|
1032 |
+
*
|
1033 |
+
* @param array $args Array of arguments to create settings.
|
1034 |
+
*
|
1035 |
+
* @access public
|
1036 |
+
* @since 2.0
|
1037 |
+
*/
|
1038 |
+
function ot_register_settings( $args ) {
|
1039 |
+
if ( ! $args ) {
|
1040 |
+
return;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
new OT_Settings( $args );
|
1044 |
+
}
|
1045 |
+
}
|
admin/includes/ot-functions-admin.php
CHANGED
@@ -1,72 +1,80 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
* Functions used only while viewing the admin UI.
|
4 |
*
|
5 |
* Limit loading these function only when needed
|
6 |
* and not in the front end.
|
7 |
*
|
8 |
-
* @package
|
9 |
-
* @author Derek Herman <derek@valendesigns.com>
|
10 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
11 |
-
* @since 2.0
|
12 |
*/
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
*
|
19 |
-
* @return void
|
20 |
-
*
|
21 |
-
* @access public
|
22 |
-
* @since 2.1
|
23 |
-
*/
|
24 |
if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
)
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
}
|
72 |
|
@@ -74,6085 +82,6025 @@ if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
|
74 |
|
75 |
}
|
76 |
|
77 |
-
/**
|
78 |
-
* Registers the Settings page
|
79 |
-
*
|
80 |
-
* @uses ot_register_settings()
|
81 |
-
*
|
82 |
-
* @return void
|
83 |
-
*
|
84 |
-
* @access public
|
85 |
-
* @since 2.1
|
86 |
-
*/
|
87 |
if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
88 |
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
-
|
93 |
-
if ( OT_SHOW_OPTIONS_UI == true && isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ot-settings' && ( $ot_has_custom_theme_options == true || has_action( 'admin_init', 'custom_theme_options' ) || has_action( 'init', 'custom_theme_options' ) ) ) {
|
94 |
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
|
|
|
98 |
|
99 |
-
|
|
|
100 |
|
101 |
-
|
|
|
102 |
|
103 |
-
|
|
|
|
|
|
|
|
|
104 |
|
105 |
-
|
106 |
-
$ot_register_pages_array = array(
|
107 |
-
array(
|
108 |
-
'id' => 'ot',
|
109 |
-
'page_title' => __( 'OptionTree', 'option-tree' ),
|
110 |
-
'menu_title' => __( 'OptionTree', 'option-tree' ),
|
111 |
-
'capability' => 'edit_theme_options',
|
112 |
-
'menu_slug' => 'ot-settings',
|
113 |
-
'icon_url' => null,
|
114 |
-
'position' => 61,
|
115 |
-
'hidden_page' => true
|
116 |
-
),
|
117 |
-
array(
|
118 |
-
'id' => 'settings',
|
119 |
-
'parent_slug' => 'ot-settings',
|
120 |
-
'page_title' => __( 'Settings', 'option-tree' ),
|
121 |
-
'menu_title' => __( 'Settings', 'option-tree' ),
|
122 |
-
'capability' => 'edit_theme_options',
|
123 |
-
'menu_slug' => 'ot-settings',
|
124 |
-
'icon_url' => null,
|
125 |
-
'position' => null,
|
126 |
-
'updated_message' => __( 'Your changes are saved.', 'option-tree' ),
|
127 |
-
'reset_message' => __( 'Options have been reset to the default.', 'option-tree' ),
|
128 |
-
'button_text' => __( 'Save Settings', 'option-tree' ),
|
129 |
-
'show_buttons' => false,
|
130 |
-
'sections' => array(
|
131 |
-
array(
|
132 |
-
'id' => 'create_setting',
|
133 |
-
'title' => __( 'Theme Options UI', 'option-tree' )
|
134 |
-
),
|
135 |
-
array(
|
136 |
-
'id' => 'import',
|
137 |
-
'title' => __( 'Import', 'option-tree' )
|
138 |
-
),
|
139 |
-
array(
|
140 |
-
'id' => 'export',
|
141 |
-
'title' => __( 'Export', 'option-tree' )
|
142 |
-
),
|
143 |
-
array(
|
144 |
-
'id' => 'layouts',
|
145 |
-
'title' => __( 'Layouts', 'option-tree' )
|
146 |
-
)
|
147 |
-
),
|
148 |
-
'settings' => array(
|
149 |
-
array(
|
150 |
-
'id' => 'theme_options_ui_text',
|
151 |
-
'label' => __( 'Theme Options UI Builder', 'option-tree' ),
|
152 |
-
'type' => 'theme_options_ui',
|
153 |
-
'section' => 'create_setting'
|
154 |
-
),
|
155 |
-
array(
|
156 |
-
'id' => 'import_xml_text',
|
157 |
-
'label' => __( 'Settings XML', 'option-tree' ),
|
158 |
-
'type' => 'import-xml',
|
159 |
-
'section' => 'import'
|
160 |
-
),
|
161 |
-
array(
|
162 |
-
'id' => 'import_settings_text',
|
163 |
-
'label' => __( 'Settings', 'option-tree' ),
|
164 |
-
'type' => 'import-settings',
|
165 |
-
'section' => 'import'
|
166 |
-
),
|
167 |
-
array(
|
168 |
-
'id' => 'import_data_text',
|
169 |
-
'label' => __( 'Theme Options', 'option-tree' ),
|
170 |
-
'type' => 'import-data',
|
171 |
-
'section' => 'import'
|
172 |
-
),
|
173 |
-
array(
|
174 |
-
'id' => 'import_layouts_text',
|
175 |
-
'label' => __( 'Layouts', 'option-tree' ),
|
176 |
-
'type' => 'import-layouts',
|
177 |
-
'section' => 'import'
|
178 |
-
),
|
179 |
-
array(
|
180 |
-
'id' => 'export_settings_file_text',
|
181 |
-
'label' => __( 'Settings PHP File', 'option-tree' ),
|
182 |
-
'type' => 'export-settings-file',
|
183 |
-
'section' => 'export'
|
184 |
-
),
|
185 |
-
array(
|
186 |
-
'id' => 'export_settings_text',
|
187 |
-
'label' => __( 'Settings', 'option-tree' ),
|
188 |
-
'type' => 'export-settings',
|
189 |
-
'section' => 'export'
|
190 |
-
),
|
191 |
-
array(
|
192 |
-
'id' => 'export_data_text',
|
193 |
-
'label' => __( 'Theme Options', 'option-tree' ),
|
194 |
-
'type' => 'export-data',
|
195 |
-
'section' => 'export'
|
196 |
-
),
|
197 |
-
array(
|
198 |
-
'id' => 'export_layout_text',
|
199 |
-
'label' => __( 'Layouts', 'option-tree' ),
|
200 |
-
'type' => 'export-layouts',
|
201 |
-
'section' => 'export'
|
202 |
-
),
|
203 |
-
array(
|
204 |
-
'id' => 'modify_layouts_text',
|
205 |
-
'label' => __( 'Layout Management', 'option-tree' ),
|
206 |
-
'type' => 'modify-layouts',
|
207 |
-
'section' => 'layouts'
|
208 |
-
)
|
209 |
-
)
|
210 |
-
),
|
211 |
-
array(
|
212 |
-
'id' => 'documentation',
|
213 |
-
'parent_slug' => 'ot-settings',
|
214 |
-
'page_title' => __( 'Documentation', 'option-tree' ),
|
215 |
-
'menu_title' => __( 'Documentation', 'option-tree' ),
|
216 |
-
'capability' => 'edit_theme_options',
|
217 |
-
'menu_slug' => 'ot-documentation',
|
218 |
-
'icon_url' => null,
|
219 |
-
'position' => null,
|
220 |
-
'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
|
221 |
-
'reset_message' => __( 'Theme Options reset.', 'option-tree' ),
|
222 |
-
'button_text' => __( 'Save Settings', 'option-tree' ),
|
223 |
-
'show_buttons' => false,
|
224 |
-
'sections' => array(
|
225 |
-
array(
|
226 |
-
'id' => 'creating_options',
|
227 |
-
'title' => __( 'Creating Options', 'option-tree' )
|
228 |
-
),
|
229 |
-
array(
|
230 |
-
'id' => 'option_types',
|
231 |
-
'title' => __( 'Option Types', 'option-tree' )
|
232 |
-
),
|
233 |
-
array(
|
234 |
-
'id' => 'functions',
|
235 |
-
'title' => __( 'Function References', 'option-tree' )
|
236 |
-
),
|
237 |
-
array(
|
238 |
-
'id' => 'theme_mode',
|
239 |
-
'title' => __( 'Theme Mode', 'option-tree' )
|
240 |
-
),
|
241 |
-
array(
|
242 |
-
'id' => 'meta_boxes',
|
243 |
-
'title' => __( 'Meta Boxes', 'option-tree' )
|
244 |
-
),
|
245 |
-
array(
|
246 |
-
'id' => 'examples',
|
247 |
-
'title' => __( 'Code Examples', 'option-tree' )
|
248 |
-
),
|
249 |
-
array(
|
250 |
-
'id' => 'layouts_overview',
|
251 |
-
'title' => __( 'Layouts Overview', 'option-tree' )
|
252 |
-
)
|
253 |
-
),
|
254 |
-
'settings' => array(
|
255 |
-
array(
|
256 |
-
'id' => 'creating_options_text',
|
257 |
-
'label' => __( 'Overview of available Theme Option fields.', 'option-tree' ),
|
258 |
-
'type' => 'creating-options',
|
259 |
-
'section' => 'creating_options'
|
260 |
-
),
|
261 |
-
array(
|
262 |
-
'id' => 'option_types_text',
|
263 |
-
'label' => __( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ),
|
264 |
-
'type' => 'option-types',
|
265 |
-
'section' => 'option_types'
|
266 |
-
),
|
267 |
-
array(
|
268 |
-
'id' => 'functions_ot_get_option',
|
269 |
-
'label' => __( 'Function Reference:ot_get_option()', 'option-tree' ),
|
270 |
-
'type' => 'ot-get-option',
|
271 |
-
'section' => 'functions'
|
272 |
-
),
|
273 |
-
array(
|
274 |
-
'id' => 'functions_get_option_tree',
|
275 |
-
'label' => __( 'Function Reference:get_option_tree()', 'option-tree' ),
|
276 |
-
'type' => 'get-option-tree',
|
277 |
-
'section' => 'functions'
|
278 |
-
),
|
279 |
-
array(
|
280 |
-
'id' => 'theme_mode_text',
|
281 |
-
'label' => __( 'Theme Mode', 'option-tree' ),
|
282 |
-
'type' => 'theme-mode',
|
283 |
-
'section' => 'theme_mode'
|
284 |
-
),
|
285 |
-
array(
|
286 |
-
'id' => 'meta_boxes_text',
|
287 |
-
'label' => __( 'Meta Boxes', 'option-tree' ),
|
288 |
-
'type' => 'meta-boxes',
|
289 |
-
'section' => 'meta_boxes'
|
290 |
-
),
|
291 |
-
array(
|
292 |
-
'id' => 'example_text',
|
293 |
-
'label' => __( 'Code examples for front-end development.', 'option-tree' ),
|
294 |
-
'type' => 'examples',
|
295 |
-
'section' => 'examples'
|
296 |
-
),
|
297 |
-
array(
|
298 |
-
'id' => 'layouts_overview_text',
|
299 |
-
'label' => __( 'What\'s a layout anyhow?', 'option-tree' ),
|
300 |
-
'type' => 'layouts-overview',
|
301 |
-
'section' => 'layouts_overview'
|
302 |
-
)
|
303 |
-
)
|
304 |
-
)
|
305 |
-
);
|
306 |
-
|
307 |
-
// Loop over the settings and remove as needed.
|
308 |
-
foreach( $ot_register_pages_array as $key => $page ) {
|
309 |
-
|
310 |
-
// Remove various options from the Settings UI.
|
311 |
-
if ( $page['id'] == 'settings' ) {
|
312 |
-
|
313 |
-
// Remove the Theme Options UI
|
314 |
-
if ( OT_SHOW_OPTIONS_UI == false ) {
|
315 |
-
|
316 |
-
foreach( $page['sections'] as $section_key => $section ) {
|
317 |
-
if ( $section['id'] == 'create_setting' ) {
|
318 |
-
unset($ot_register_pages_array[$key]['sections'][$section_key]);
|
319 |
-
}
|
320 |
-
}
|
321 |
-
|
322 |
-
foreach( $page['settings'] as $setting_key => $setting ) {
|
323 |
-
if ( $setting['section'] == 'create_setting' ) {
|
324 |
-
unset($ot_register_pages_array[$key]['settings'][$setting_key]);
|
325 |
-
}
|
326 |
-
}
|
327 |
-
|
328 |
-
}
|
329 |
-
|
330 |
-
// Remove parts of the Imports UI
|
331 |
-
if ( OT_SHOW_SETTINGS_IMPORT == false ) {
|
332 |
-
|
333 |
-
foreach( $page['settings'] as $setting_key => $setting ) {
|
334 |
-
if ( $setting['section'] == 'import' && in_array( $setting['id'], array('import_xml_text', 'import_settings_text' ) ) ) {
|
335 |
-
unset($ot_register_pages_array[$key]['settings'][$setting_key]);
|
336 |
-
}
|
337 |
-
}
|
338 |
-
|
339 |
-
}
|
340 |
-
|
341 |
-
// Remove parts of the Export UI
|
342 |
-
if ( OT_SHOW_SETTINGS_EXPORT == false ) {
|
343 |
-
|
344 |
-
foreach( $page['settings'] as $setting_key => $setting ) {
|
345 |
-
if ( $setting['section'] == 'export' && in_array( $setting['id'], array('export_settings_file_text', 'export_settings_text' ) ) ) {
|
346 |
-
unset($ot_register_pages_array[$key]['settings'][$setting_key]);
|
347 |
-
}
|
348 |
-
}
|
349 |
-
|
350 |
-
}
|
351 |
-
|
352 |
-
// Remove the Layouts UI
|
353 |
-
if ( OT_SHOW_NEW_LAYOUT == false ) {
|
354 |
-
|
355 |
-
foreach( $page['sections'] as $section_key => $section ) {
|
356 |
-
if ( $section['id'] == 'layouts' ) {
|
357 |
-
unset($ot_register_pages_array[$key]['sections'][$section_key]);
|
358 |
-
}
|
359 |
-
}
|
360 |
-
|
361 |
-
foreach( $page['settings'] as $setting_key => $setting ) {
|
362 |
-
if ( $setting['section'] == 'layouts' ) {
|
363 |
-
unset($ot_register_pages_array[$key]['settings'][$setting_key]);
|
364 |
-
}
|
365 |
-
}
|
366 |
-
|
367 |
-
}
|
368 |
-
|
369 |
-
}
|
370 |
-
|
371 |
-
// Remove the Documentation UI.
|
372 |
-
if ( OT_SHOW_DOCS == false && $page['id'] == 'documentation' ) {
|
373 |
-
|
374 |
-
unset( $ot_register_pages_array[$key] );
|
375 |
-
|
376 |
-
}
|
377 |
|
378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
|
380 |
-
|
381 |
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
-
|
392 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
}
|
394 |
|
395 |
-
|
396 |
-
* Runs directly after the Theme Options are save.
|
397 |
-
*
|
398 |
-
* @return void
|
399 |
-
*
|
400 |
-
* @access public
|
401 |
-
* @since 2.0
|
402 |
-
*/
|
403 |
-
if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
|
404 |
-
|
405 |
-
function ot_after_theme_options_save() {
|
406 |
|
407 |
-
|
408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
|
410 |
-
|
411 |
-
if ( apply_filters( 'niftycs_options_menu_slug', 'niftycs-options' ) == $page && $updated ) {
|
412 |
|
413 |
-
|
414 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
|
416 |
-
|
417 |
-
do_action( 'ot_after_theme_options_save', $options );
|
418 |
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
|
421 |
-
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
}
|
424 |
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
|
444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
|
446 |
-
|
447 |
-
if ( ! $input || ! $type || ! $field_id )
|
448 |
-
return $input;
|
449 |
|
450 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
|
452 |
-
|
453 |
-
if ( ! empty( $wmpl_id ) ) {
|
454 |
|
455 |
-
|
456 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
|
460 |
-
|
|
|
|
|
|
|
461 |
|
462 |
-
|
463 |
|
464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
|
466 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
|
468 |
-
|
469 |
|
470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
|
472 |
-
|
|
|
473 |
|
474 |
-
|
|
|
475 |
|
476 |
-
|
|
|
477 |
|
478 |
-
|
|
|
479 |
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
}
|
485 |
-
}
|
486 |
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
|
492 |
-
|
|
|
493 |
|
494 |
-
|
495 |
-
foreach( $input as $key => $value ) {
|
496 |
|
497 |
-
|
498 |
-
|
499 |
|
500 |
-
|
|
|
501 |
|
502 |
-
|
|
|
|
|
|
|
503 |
|
504 |
-
|
|
|
|
|
|
|
505 |
|
506 |
-
|
507 |
-
|
508 |
|
509 |
-
|
|
|
510 |
|
511 |
-
|
|
|
512 |
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
|
518 |
-
|
|
|
|
|
|
|
519 |
|
520 |
-
|
521 |
-
|
522 |
-
}
|
523 |
|
524 |
-
|
525 |
|
526 |
-
|
527 |
-
|
528 |
|
529 |
-
|
530 |
-
|
531 |
|
532 |
-
|
533 |
-
|
534 |
|
535 |
-
|
536 |
-
|
|
|
|
|
|
|
|
|
537 |
|
538 |
-
|
539 |
-
|
|
|
|
|
540 |
|
541 |
-
|
542 |
-
|
|
|
543 |
|
544 |
-
|
545 |
-
foreach( $input as $key => $value ) {
|
546 |
-
if ( empty( $value ) && strlen( $value ) == 0 ) {
|
547 |
-
unset( $input[$key] );
|
548 |
-
}
|
549 |
-
}
|
550 |
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
|
556 |
-
|
557 |
|
558 |
-
|
559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
560 |
|
561 |
-
|
|
|
562 |
|
563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
564 |
|
565 |
-
|
566 |
|
567 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
}
|
573 |
|
574 |
-
|
575 |
-
$input = ot_validate_setting( $input, 'colorpicker', $field_id );
|
576 |
|
577 |
-
|
|
|
|
|
578 |
|
579 |
-
|
|
|
|
|
580 |
|
581 |
-
|
582 |
|
583 |
-
|
584 |
|
585 |
-
|
586 |
|
587 |
-
|
588 |
-
foreach( $input as $key => $value ) {
|
589 |
-
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
|
590 |
-
$errors[] = $key;
|
591 |
-
}
|
592 |
-
if ( empty( $value ) && strlen( $value ) == 0 ) {
|
593 |
-
unset( $input[$key] );
|
594 |
-
}
|
595 |
-
}
|
596 |
|
597 |
-
|
598 |
-
if ( isset( $errors ) ) {
|
599 |
|
600 |
-
|
|
|
601 |
|
602 |
-
|
603 |
|
604 |
-
|
605 |
|
606 |
-
|
607 |
|
608 |
-
|
609 |
|
610 |
-
|
611 |
-
|
612 |
-
}
|
613 |
|
614 |
-
|
615 |
|
616 |
-
|
617 |
|
618 |
-
|
619 |
-
if ( is_array( $input ) && ! empty( $input ) ) {
|
620 |
-
$input = array_values( $input );
|
621 |
-
}
|
622 |
|
623 |
-
|
624 |
-
if ( empty( $input ) ) {
|
625 |
-
$input = '';
|
626 |
-
}
|
627 |
|
628 |
-
|
|
|
629 |
|
630 |
-
|
631 |
-
if ( is_array( $input ) && ! empty( $input ) ) {
|
632 |
-
foreach( $input as $key => $value ) {
|
633 |
-
if ( ! empty( $value ) ) {
|
634 |
-
$input[$key] = ot_validate_setting( $input[$key], 'colorpicker', $field_id . '-' . $key );
|
635 |
-
$has_value = true;
|
636 |
-
}
|
637 |
-
}
|
638 |
-
}
|
639 |
|
640 |
-
|
641 |
-
if ( ! isset( $has_value ) ) {
|
642 |
-
$input = '';
|
643 |
-
}
|
644 |
|
645 |
-
|
646 |
|
647 |
-
|
648 |
|
649 |
-
|
650 |
-
|
651 |
-
$input = '';
|
652 |
-
}
|
653 |
|
654 |
-
|
655 |
|
656 |
-
|
657 |
-
foreach( $input as $key => $value ) {
|
658 |
-
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
|
659 |
-
$errors[] = $key;
|
660 |
-
}
|
661 |
-
if ( empty( $value ) && strlen( $value ) == 0 ) {
|
662 |
-
unset( $input[$key] );
|
663 |
-
}
|
664 |
-
}
|
665 |
|
666 |
-
|
667 |
-
if ( isset( $errors ) ) {
|
668 |
|
669 |
-
|
670 |
|
671 |
-
|
672 |
|
673 |
-
|
674 |
|
675 |
-
|
|
|
676 |
|
677 |
-
|
678 |
|
679 |
-
|
680 |
-
$input = '';
|
681 |
-
}
|
682 |
|
683 |
-
|
684 |
|
685 |
-
|
686 |
|
687 |
-
|
688 |
-
foreach( $input as $key => $value ) {
|
689 |
-
if ( ! empty( $value ) ) {
|
690 |
-
$has_value = true;
|
691 |
-
}
|
692 |
-
}
|
693 |
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
}
|
698 |
|
699 |
-
|
|
|
|
|
700 |
|
701 |
-
|
702 |
-
$input = esc_url_raw( $input );
|
703 |
-
}
|
704 |
|
705 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
706 |
|
707 |
-
|
708 |
|
709 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
710 |
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
722 |
|
723 |
-
|
724 |
-
if ( ! isset( $has_value ) ) {
|
725 |
-
$input = '';
|
726 |
-
}
|
727 |
|
728 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
729 |
|
730 |
-
|
731 |
|
732 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
733 |
|
734 |
-
|
735 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
736 |
}
|
737 |
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
747 |
|
748 |
-
|
749 |
-
global $wp_styles, $post;
|
750 |
|
751 |
-
|
752 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
753 |
|
754 |
-
|
755 |
-
wp_enqueue_style( 'wp-color-picker' );
|
756 |
|
757 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
758 |
|
759 |
-
|
760 |
-
wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION );
|
761 |
|
762 |
-
|
763 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
764 |
|
765 |
-
|
766 |
-
if ( isset( $post->post_type ) && $post->post_type == 'post' )
|
767 |
-
wp_dequeue_style( 'jquery-ui-css' );
|
768 |
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
781 |
|
782 |
-
|
783 |
-
if ( in_array( get_current_screen()->id, $screen_ids ) ) {
|
784 |
-
wp_dequeue_style( 'plugin_name-admin-ui-css' );
|
785 |
-
wp_dequeue_style( 'jquery-ui-css' );
|
786 |
-
}
|
787 |
|
788 |
-
|
789 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
790 |
|
791 |
-
|
792 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
793 |
}
|
794 |
|
795 |
-
|
796 |
-
* Setup the default admin scripts
|
797 |
-
*
|
798 |
-
* @uses add_thickbox() Include Thickbox for file uploads
|
799 |
-
* @uses wp_enqueue_script() Add OptionTree scripts
|
800 |
-
* @uses wp_localize_script() Used to include arbitrary Javascript data
|
801 |
-
*
|
802 |
-
* @return void
|
803 |
-
*
|
804 |
-
* @access public
|
805 |
-
* @since 2.0
|
806 |
-
*/
|
807 |
-
if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
808 |
|
809 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
810 |
|
811 |
-
|
812 |
-
do_action( 'ot_admin_scripts_before' );
|
813 |
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
821 |
|
822 |
-
|
823 |
-
wp_enqueue_script( 'jquery-ui-slider' );
|
824 |
|
825 |
-
|
826 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
|
828 |
-
|
829 |
-
wp_enqueue_script( 'wp-color-picker' );
|
830 |
|
831 |
-
|
832 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
833 |
|
834 |
-
|
835 |
-
wp_enqueue_script( 'jquery-ui-timepicker', OT_URL . 'assets/js/vendor/jquery/jquery-ui-timepicker.js', array( 'jquery', 'jquery-ui-slider', 'jquery-ui-datepicker' ), '1.4.3' );
|
836 |
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
841 |
|
|
|
842 |
|
843 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
844 |
|
845 |
-
|
846 |
-
wp_enqueue_script( 'ot-admin-js', OT_URL . 'assets/js/ot-admin.js', array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-sortable', 'jquery-ui-slider', 'wp-color-picker', 'ace-editor', 'jquery-ui-datepicker', 'jquery-ui-timepicker' ), OT_VERSION );
|
847 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
848 |
|
|
|
849 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
850 |
|
|
|
851 |
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
|
|
|
|
875 |
|
876 |
-
|
877 |
-
wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array );
|
878 |
|
879 |
-
|
880 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
881 |
|
882 |
-
|
883 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
}
|
885 |
|
886 |
-
|
887 |
-
* Returns the ID of a custom post type by post_title.
|
888 |
-
*
|
889 |
-
* @uses get_results()
|
890 |
-
*
|
891 |
-
* @return int
|
892 |
-
*
|
893 |
-
* @access public
|
894 |
-
* @since 2.0
|
895 |
-
*/
|
896 |
-
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
|
897 |
|
898 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
899 |
|
900 |
-
|
901 |
-
$option_id = 'ot_media_post_ID';
|
902 |
|
903 |
-
|
904 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
905 |
|
906 |
-
|
907 |
-
if ( $post_ID === false || empty( $post_ID ) ) {
|
908 |
-
global $wpdb;
|
909 |
|
910 |
-
|
911 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
912 |
|
913 |
-
|
914 |
-
if ( $post_ID !== null )
|
915 |
-
update_option( $option_id, $post_ID );
|
916 |
|
917 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
|
919 |
-
|
|
|
|
|
920 |
|
921 |
-
|
922 |
|
923 |
-
|
|
|
|
|
924 |
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
* @uses get_results()
|
929 |
-
*
|
930 |
-
* @return void
|
931 |
-
*
|
932 |
-
* @access public
|
933 |
-
* @since 2.0
|
934 |
-
*/
|
935 |
-
if ( ! function_exists( 'ot_create_media_post' ) ) {
|
936 |
|
937 |
-
|
938 |
-
|
939 |
-
$regsiter_post_type = 'register_' . 'post_type';
|
940 |
-
$regsiter_post_type( 'option-tree', array(
|
941 |
-
'labels' => array( 'name' => __( 'Nifty options', 'option-tree' ) ),
|
942 |
-
'public' => false,
|
943 |
-
'show_ui' => false,
|
944 |
-
'capability_type' => 'post',
|
945 |
-
'exclude_from_search' => true,
|
946 |
-
'hierarchical' => false,
|
947 |
-
'rewrite' => false,
|
948 |
-
'supports' => array( 'title', 'editor' ),
|
949 |
-
'can_export' => false,
|
950 |
-
'show_in_nav_menus' => false
|
951 |
-
) );
|
952 |
-
|
953 |
-
/* look for custom page */
|
954 |
-
$post_id = ot_get_media_post_ID();
|
955 |
-
|
956 |
-
/* no post exists */
|
957 |
-
if ( $post_id == 0 ) {
|
958 |
-
|
959 |
-
/* create post object */
|
960 |
-
$_p = array();
|
961 |
-
$_p['post_title'] = 'Media';
|
962 |
-
$_p['post_name'] = 'media';
|
963 |
-
$_p['post_status'] = 'private';
|
964 |
-
$_p['post_type'] = 'option-tree';
|
965 |
-
$_p['comment_status'] = 'closed';
|
966 |
-
$_p['ping_status'] = 'closed';
|
967 |
-
|
968 |
-
/* insert the post into the database */
|
969 |
-
wp_insert_post( $_p );
|
970 |
|
971 |
-
|
|
|
|
|
972 |
|
973 |
-
|
974 |
|
975 |
-
|
|
|
|
|
976 |
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
* @return void
|
981 |
-
*
|
982 |
-
* @access public
|
983 |
-
* @since 2.0
|
984 |
-
*/
|
985 |
-
if ( ! function_exists( 'ot_default_settings' ) ) {
|
986 |
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
if ( ! get_option( ot_settings_id() ) ) {
|
991 |
-
|
992 |
-
$section_count = 0;
|
993 |
-
$settings_count = 0;
|
994 |
-
$settings = array();
|
995 |
-
$table_name = $wpdb->prefix . 'option_tree';
|
996 |
-
|
997 |
-
if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) == $table_name && $old_settings = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY item_sort ASC" ) ) {
|
998 |
-
|
999 |
-
foreach ( $old_settings as $setting ) {
|
1000 |
-
|
1001 |
-
/* heading is a section now */
|
1002 |
-
if ( $setting->item_type == 'heading' ) {
|
1003 |
-
|
1004 |
-
/* add section to the sections array */
|
1005 |
-
$settings['sections'][$section_count]['id'] = $setting->item_id;
|
1006 |
-
$settings['sections'][$section_count]['title'] = $setting->item_title;
|
1007 |
-
|
1008 |
-
/* save the last section id to use in creating settings */
|
1009 |
-
$section = $setting->item_id;
|
1010 |
-
|
1011 |
-
/* increment the section count */
|
1012 |
-
$section_count++;
|
1013 |
-
|
1014 |
-
} else {
|
1015 |
-
|
1016 |
-
/* add setting to the settings array */
|
1017 |
-
$settings['settings'][$settings_count]['id'] = $setting->item_id;
|
1018 |
-
$settings['settings'][$settings_count]['label'] = $setting->item_title;
|
1019 |
-
$settings['settings'][$settings_count]['desc'] = $setting->item_desc;
|
1020 |
-
$settings['settings'][$settings_count]['section'] = $section;
|
1021 |
-
$settings['settings'][$settings_count]['type'] = ot_map_old_option_types( $setting->item_type );
|
1022 |
-
$settings['settings'][$settings_count]['std'] = '';
|
1023 |
-
$settings['settings'][$settings_count]['class'] = '';
|
1024 |
-
|
1025 |
-
/* textarea rows */
|
1026 |
-
$rows = '';
|
1027 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) {
|
1028 |
-
if ( (int) $setting->item_options > 0 ) {
|
1029 |
-
$rows = (int) $setting->item_options;
|
1030 |
-
} else {
|
1031 |
-
$rows = 15;
|
1032 |
-
}
|
1033 |
-
}
|
1034 |
-
$settings['settings'][$settings_count]['rows'] = $rows;
|
1035 |
-
|
1036 |
-
/* post type */
|
1037 |
-
$post_type = '';
|
1038 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ) ) ) {
|
1039 |
-
if ( '' != $setting->item_options ) {
|
1040 |
-
$post_type = $setting->item_options;
|
1041 |
-
} else {
|
1042 |
-
$post_type = 'post';
|
1043 |
-
}
|
1044 |
-
}
|
1045 |
-
$settings['settings'][$settings_count]['post_type'] = $post_type;
|
1046 |
-
|
1047 |
-
/* choices */
|
1048 |
-
$choices = array();
|
1049 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) {
|
1050 |
-
if ( '' != $setting->item_options ) {
|
1051 |
-
$choices = ot_convert_string_to_array( $setting->item_options );
|
1052 |
-
}
|
1053 |
-
}
|
1054 |
-
$settings['settings'][$settings_count]['choices'] = $choices;
|
1055 |
-
|
1056 |
-
$settings_count++;
|
1057 |
-
}
|
1058 |
-
|
1059 |
-
}
|
1060 |
-
|
1061 |
-
/* make sure each setting has a section just incase */
|
1062 |
-
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
1063 |
-
foreach( $settings['settings'] as $k => $setting ) {
|
1064 |
-
if ( '' == $setting['section'] ) {
|
1065 |
-
$settings['settings'][$k]['section'] = $settings['sections'][0]['id'];
|
1066 |
-
}
|
1067 |
-
}
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
}
|
1071 |
-
|
1072 |
-
/* if array if not properly formed create fallback settings array */
|
1073 |
-
if ( ! isset( $settings['sections'] ) || ! isset( $settings['settings'] ) ) {
|
1074 |
-
|
1075 |
-
$settings = array(
|
1076 |
-
'sections' => array(
|
1077 |
-
array(
|
1078 |
-
'id' => 'general',
|
1079 |
-
'title' => __( 'General', 'option-tree' )
|
1080 |
-
)
|
1081 |
-
),
|
1082 |
-
'settings' => array(
|
1083 |
-
array(
|
1084 |
-
'id' => 'sample_text',
|
1085 |
-
'label' => __( 'Sample Text Field Label', 'option-tree' ),
|
1086 |
-
'desc' => __( 'Description for the sample text field.', 'option-tree' ),
|
1087 |
-
'section' => 'general',
|
1088 |
-
'type' => 'text',
|
1089 |
-
'std' => '',
|
1090 |
-
'class' => '',
|
1091 |
-
'rows' => '',
|
1092 |
-
'post_type' => '',
|
1093 |
-
'choices' => array()
|
1094 |
-
)
|
1095 |
-
)
|
1096 |
-
);
|
1097 |
-
|
1098 |
-
}
|
1099 |
-
|
1100 |
-
/* update the settings array */
|
1101 |
-
update_option( ot_settings_id(), $settings );
|
1102 |
-
|
1103 |
-
/* get option tree array */
|
1104 |
-
$options = get_option( ot_options_id() );
|
1105 |
-
|
1106 |
-
/* validate options */
|
1107 |
-
if ( is_array( $options ) ) {
|
1108 |
-
|
1109 |
-
foreach( $settings['settings'] as $setting ) {
|
1110 |
-
|
1111 |
-
if ( isset( $options[$setting['id']] ) ) {
|
1112 |
-
|
1113 |
-
$content = ot_stripslashes( $options[$setting['id']] );
|
1114 |
-
|
1115 |
-
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
1116 |
-
|
1117 |
-
}
|
1118 |
-
|
1119 |
-
}
|
1120 |
-
|
1121 |
-
/* execute the action hook and pass the theme options to it */
|
1122 |
-
do_action( 'ot_before_theme_options_save', $options );
|
1123 |
-
|
1124 |
-
/* update the option tree array */
|
1125 |
-
update_option( ot_options_id(), $options );
|
1126 |
-
|
1127 |
-
}
|
1128 |
|
1129 |
-
|
|
|
|
|
1130 |
|
1131 |
-
|
|
|
1132 |
|
1133 |
-
|
|
|
|
|
1134 |
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
* @return void
|
1139 |
-
*
|
1140 |
-
* @access public
|
1141 |
-
* @since 2.0
|
1142 |
-
*/
|
1143 |
-
if ( ! function_exists( 'ot_save_css' ) ) {
|
1144 |
|
1145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1146 |
|
1147 |
-
|
1148 |
-
|
|
|
1149 |
|
1150 |
-
|
1151 |
-
|
|
|
1152 |
|
1153 |
-
|
1154 |
-
|
|
|
1155 |
|
1156 |
-
|
1157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
|
1159 |
-
|
1160 |
-
if ( isset( $options[$setting['id']] ) && '' !== $options[$setting['id']] ) {
|
1161 |
|
1162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1163 |
|
1164 |
-
|
1165 |
-
} else {
|
1166 |
|
1167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1168 |
|
1169 |
-
|
1170 |
|
1171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1172 |
|
1173 |
-
|
1174 |
|
1175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1176 |
|
1177 |
-
|
1178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1179 |
}
|
1180 |
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1190 |
|
1191 |
-
|
1192 |
|
1193 |
-
|
1194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1195 |
|
1196 |
-
|
1197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1198 |
}
|
1199 |
|
1200 |
-
|
1201 |
-
* Filter 'upload_mimes' and add xml.
|
1202 |
-
*
|
1203 |
-
* @param array $mimes An array of valid upload mime types
|
1204 |
-
* @return array
|
1205 |
-
*
|
1206 |
-
* @access public
|
1207 |
-
* @since 2.0
|
1208 |
-
*/
|
1209 |
-
if ( ! function_exists( 'ot_upload_mimes' ) ) {
|
1210 |
|
1211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1212 |
|
1213 |
-
|
1214 |
|
1215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1216 |
|
1217 |
-
|
1218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1219 |
}
|
1220 |
|
1221 |
-
|
1222 |
-
* Filters 'wp_mime_type_icon' and have xml display as a document.
|
1223 |
-
*
|
1224 |
-
* @param string $icon The mime icon
|
1225 |
-
* @param string $mime The mime type
|
1226 |
-
* @return string
|
1227 |
-
*
|
1228 |
-
* @access public
|
1229 |
-
* @since 2.0
|
1230 |
-
*/
|
1231 |
-
if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) {
|
1232 |
|
1233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1234 |
|
1235 |
-
|
1236 |
-
return wp_mime_type_icon( 'document' );
|
1237 |
|
1238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1239 |
|
1240 |
-
|
1241 |
|
1242 |
-
|
|
|
1243 |
|
1244 |
-
|
1245 |
-
|
1246 |
-
*
|
1247 |
-
* @return void
|
1248 |
-
*
|
1249 |
-
* @access public
|
1250 |
-
* @since 2.0
|
1251 |
-
*/
|
1252 |
-
if ( ! function_exists( 'ot_import' ) ) {
|
1253 |
|
1254 |
-
|
|
|
1255 |
|
1256 |
-
|
1257 |
-
if ( isset( $_POST['import_xml_nonce'] ) && wp_verify_nonce( $_POST['import_xml_nonce'], 'import_xml_form' ) ) {
|
1258 |
|
1259 |
-
|
1260 |
-
$file = isset( $_POST['import_xml'] ) ? esc_url( $_POST['import_xml'] ) : '';
|
1261 |
|
1262 |
-
|
1263 |
-
if ( preg_match( "/(.xml)$/i", $file ) && class_exists( 'SimpleXMLElement' ) ) {
|
1264 |
|
1265 |
-
|
1266 |
|
1267 |
-
|
1268 |
|
1269 |
-
|
1270 |
-
$message = 'failed';
|
1271 |
|
1272 |
-
|
1273 |
-
if ( isset( $settings ) && ! empty( $settings ) ) {
|
1274 |
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
$attachmentid = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$file'" );
|
1279 |
-
wp_delete_attachment( $attachmentid, true );
|
1280 |
-
}
|
1281 |
|
1282 |
-
|
1283 |
-
|
|
|
1284 |
|
1285 |
-
|
1286 |
-
$message = 'success';
|
1287 |
|
1288 |
-
|
1289 |
|
1290 |
-
|
1291 |
-
|
1292 |
-
exit;
|
1293 |
|
1294 |
-
|
|
|
1295 |
|
1296 |
-
|
1297 |
-
|
1298 |
|
1299 |
-
|
1300 |
-
$textarea = isset( $_POST['import_settings'] ) ? unserialize( ot_decode( $_POST['import_settings'] ) ) : '';
|
1301 |
|
1302 |
-
|
1303 |
-
$message = 'failed';
|
1304 |
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
$message = 'success';
|
1309 |
-
}
|
1310 |
|
1311 |
-
|
1312 |
-
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
1313 |
-
exit;
|
1314 |
|
1315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1316 |
|
1317 |
-
|
1318 |
-
if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) {
|
1319 |
|
1320 |
-
|
1321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1322 |
|
1323 |
-
|
1324 |
-
$options = isset( $_POST['import_data'] ) ? unserialize( ot_decode( $_POST['import_data'] ) ) : '';
|
1325 |
|
1326 |
-
|
1327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1328 |
|
1329 |
-
|
1330 |
-
if ( is_array( $options ) ) {
|
1331 |
|
1332 |
-
|
1333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1334 |
|
1335 |
-
|
1336 |
|
1337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1338 |
|
1339 |
-
|
1340 |
|
1341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1342 |
|
1343 |
-
|
1344 |
|
1345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1346 |
|
1347 |
-
|
1348 |
|
1349 |
-
|
1350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1351 |
|
1352 |
-
|
1353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1354 |
|
1355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1356 |
|
1357 |
-
|
1358 |
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1362 |
|
1363 |
-
|
|
|
1364 |
|
1365 |
-
|
1366 |
-
|
1367 |
|
1368 |
-
|
1369 |
-
|
1370 |
|
1371 |
-
|
1372 |
-
|
|
|
|
|
1373 |
|
1374 |
-
|
1375 |
-
|
1376 |
|
1377 |
-
|
1378 |
-
|
|
|
1379 |
|
1380 |
-
|
1381 |
-
|
|
|
1382 |
|
1383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1384 |
|
1385 |
-
|
1386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1387 |
|
1388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1389 |
|
1390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1391 |
|
1392 |
-
|
1393 |
|
1394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1395 |
|
1396 |
-
|
1397 |
|
1398 |
-
|
1399 |
|
1400 |
-
|
1401 |
|
1402 |
-
|
1403 |
|
1404 |
-
|
1405 |
|
1406 |
-
|
|
|
|
|
1407 |
|
1408 |
-
|
1409 |
-
|
|
|
1410 |
|
1411 |
-
|
|
|
|
|
|
|
|
|
|
|
1412 |
|
1413 |
-
|
1414 |
-
|
|
|
1415 |
|
1416 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1417 |
|
1418 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1419 |
|
1420 |
-
|
1421 |
-
update_option( ot_layouts_id(), $layouts );
|
1422 |
|
1423 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1424 |
|
1425 |
-
|
1426 |
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
|
|
|
|
|
|
|
|
1430 |
|
1431 |
-
|
|
|
1432 |
|
1433 |
-
|
|
|
1434 |
|
1435 |
-
|
|
|
1436 |
|
|
|
|
|
|
|
|
|
1437 |
}
|
1438 |
|
1439 |
-
/**
|
1440 |
-
* Export before the screen is displayed.
|
1441 |
-
*
|
1442 |
-
* @return void
|
1443 |
-
*
|
1444 |
-
* @access public
|
1445 |
-
* @since 2.0.8
|
1446 |
-
*/
|
1447 |
-
if ( ! function_exists( 'ot_export' ) ) {
|
1448 |
-
|
1449 |
-
function ot_export() {
|
1450 |
-
|
1451 |
-
/* check and verify export settings file nonce */
|
1452 |
-
if ( isset( $_POST['export_settings_file_nonce'] ) && wp_verify_nonce( $_POST['export_settings_file_nonce'], 'export_settings_file_form' ) ) {
|
1453 |
-
|
1454 |
-
ot_export_php_settings_array();
|
1455 |
-
|
1456 |
-
}
|
1457 |
-
|
1458 |
-
}
|
1459 |
-
|
1460 |
-
}
|
1461 |
-
|
1462 |
-
/**
|
1463 |
-
* Reusable XMl import helper function.
|
1464 |
-
*
|
1465 |
-
* @param string $file The path to the file.
|
1466 |
-
* @return mixed False or an array of settings.
|
1467 |
-
*
|
1468 |
-
* @access public
|
1469 |
-
* @since 2.0.8
|
1470 |
-
*/
|
1471 |
-
if ( ! function_exists( 'ot_import_xml' ) ) {
|
1472 |
-
|
1473 |
-
function ot_import_xml( $file ) {
|
1474 |
-
|
1475 |
-
$get_data = wp_remote_get( $file );
|
1476 |
-
|
1477 |
-
if ( is_wp_error( $get_data ) )
|
1478 |
-
return false;
|
1479 |
-
|
1480 |
-
$rawdata = isset( $get_data['body'] ) ? $get_data['body'] : false;
|
1481 |
-
|
1482 |
-
if ( $rawdata ) {
|
1483 |
-
|
1484 |
-
$section_count = 0;
|
1485 |
-
$settings_count = 0;
|
1486 |
-
|
1487 |
-
$section = '';
|
1488 |
-
|
1489 |
-
$settings = array();
|
1490 |
-
$xml = new SimpleXMLElement( $rawdata );
|
1491 |
-
|
1492 |
-
foreach ( $xml->row as $value ) {
|
1493 |
-
|
1494 |
-
/* heading is a section now */
|
1495 |
-
if ( $value->item_type == 'heading' ) {
|
1496 |
-
|
1497 |
-
/* add section to the sections array */
|
1498 |
-
$settings['sections'][$section_count]['id'] = (string) $value->item_id;
|
1499 |
-
$settings['sections'][$section_count]['title'] = (string) $value->item_title;
|
1500 |
-
|
1501 |
-
/* save the last section id to use in creating settings */
|
1502 |
-
$section = (string) $value->item_id;
|
1503 |
-
|
1504 |
-
/* increment the section count */
|
1505 |
-
$section_count++;
|
1506 |
-
|
1507 |
-
} else {
|
1508 |
-
|
1509 |
-
/* add setting to the settings array */
|
1510 |
-
$settings['settings'][$settings_count]['id'] = (string) $value->item_id;
|
1511 |
-
$settings['settings'][$settings_count]['label'] = (string) $value->item_title;
|
1512 |
-
$settings['settings'][$settings_count]['desc'] = (string) $value->item_desc;
|
1513 |
-
$settings['settings'][$settings_count]['section'] = $section;
|
1514 |
-
$settings['settings'][$settings_count]['type'] = ot_map_old_option_types( (string) $value->item_type );
|
1515 |
-
$settings['settings'][$settings_count]['std'] = '';
|
1516 |
-
$settings['settings'][$settings_count]['class'] = '';
|
1517 |
-
|
1518 |
-
/* textarea rows */
|
1519 |
-
$rows = '';
|
1520 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) {
|
1521 |
-
if ( (int) $value->item_options > 0 ) {
|
1522 |
-
$rows = (int) $value->item_options;
|
1523 |
-
} else {
|
1524 |
-
$rows = 15;
|
1525 |
-
}
|
1526 |
-
}
|
1527 |
-
$settings['settings'][$settings_count]['rows'] = $rows;
|
1528 |
-
|
1529 |
-
/* post type */
|
1530 |
-
$post_type = '';
|
1531 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ) ) ) {
|
1532 |
-
if ( '' != (string) $value->item_options ) {
|
1533 |
-
$post_type = (string) $value->item_options;
|
1534 |
-
} else {
|
1535 |
-
$post_type = 'post';
|
1536 |
-
}
|
1537 |
-
}
|
1538 |
-
$settings['settings'][$settings_count]['post_type'] = $post_type;
|
1539 |
-
|
1540 |
-
/* choices */
|
1541 |
-
$choices = array();
|
1542 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) {
|
1543 |
-
if ( '' != (string) $value->item_options ) {
|
1544 |
-
$choices = ot_convert_string_to_array( (string) $value->item_options );
|
1545 |
-
}
|
1546 |
-
}
|
1547 |
-
$settings['settings'][$settings_count]['choices'] = $choices;
|
1548 |
-
|
1549 |
-
$settings_count++;
|
1550 |
-
}
|
1551 |
-
|
1552 |
-
}
|
1553 |
-
|
1554 |
-
/* make sure each setting has a section just incase */
|
1555 |
-
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
1556 |
-
foreach( $settings['settings'] as $k => $setting ) {
|
1557 |
-
if ( '' == $setting['section'] ) {
|
1558 |
-
$settings['settings'][$k]['section'] = $settings['sections'][0]['id'];
|
1559 |
-
}
|
1560 |
-
}
|
1561 |
-
}
|
1562 |
-
|
1563 |
-
return $settings;
|
1564 |
-
|
1565 |
-
}
|
1566 |
-
|
1567 |
-
return false;
|
1568 |
-
}
|
1569 |
-
|
1570 |
-
}
|
1571 |
-
|
1572 |
-
/**
|
1573 |
-
* Export the Theme Mode theme-options.php
|
1574 |
-
*
|
1575 |
-
* @return attachment
|
1576 |
-
*
|
1577 |
-
* @access public
|
1578 |
-
* @since 2.0.8
|
1579 |
-
*/
|
1580 |
-
if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
1581 |
-
|
1582 |
-
function ot_export_php_settings_array() {
|
1583 |
-
|
1584 |
-
$content = '';
|
1585 |
-
$build_settings = '';
|
1586 |
-
$contextual_help = '';
|
1587 |
-
$sections = '';
|
1588 |
-
$settings = '';
|
1589 |
-
$option_tree_settings = get_option( ot_settings_id(), array() );
|
1590 |
-
|
1591 |
-
// Domain string helper
|
1592 |
-
function ot_I18n_string( $string ) {
|
1593 |
-
if ( ! empty( $string ) && isset( $_POST['domain'] ) && ! empty( $_POST['domain'] ) ) {
|
1594 |
-
$domain = str_replace( ' ', '-', trim( $_POST['domain'] ) );
|
1595 |
-
return "__( '$string', '$domain' )";
|
1596 |
-
}
|
1597 |
-
return "'$string'";
|
1598 |
-
}
|
1599 |
-
|
1600 |
-
header( "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
|
1601 |
-
header( "Pragma: no-cache ");
|
1602 |
-
header( "Content-Description: File Transfer" );
|
1603 |
-
header( 'Content-Disposition: attachment; filename="theme-options.php"');
|
1604 |
-
header( "Content-Type: application/octet-stream");
|
1605 |
-
header( "Content-Transfer-Encoding: binary" );
|
1606 |
-
|
1607 |
-
/* build contextual help content */
|
1608 |
-
if ( isset( $option_tree_settings['contextual_help']['content'] ) ) {
|
1609 |
-
$help = '';
|
1610 |
-
foreach( $option_tree_settings['contextual_help']['content'] as $value ) {
|
1611 |
-
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1612 |
-
$_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
|
1613 |
-
$_content = ot_I18n_string( isset( $value['content'] ) ? html_entity_decode( str_replace( "'", "\'", $value['content'] ) ) : '' );
|
1614 |
-
$help.= "
|
1615 |
-
array(
|
1616 |
-
'id' => '$_id',
|
1617 |
-
'title' => $_title,
|
1618 |
-
'content' => $_content
|
1619 |
-
),";
|
1620 |
-
}
|
1621 |
-
$help = substr_replace( $help, '' , -1 );
|
1622 |
-
$contextual_help = "
|
1623 |
-
'content' => array( $help
|
1624 |
-
),";
|
1625 |
-
}
|
1626 |
-
|
1627 |
-
/* build contextual help sidebar */
|
1628 |
-
if ( isset( $option_tree_settings['contextual_help']['sidebar'] ) ) {
|
1629 |
-
$contextual_help.= "
|
1630 |
-
'sidebar' => " . ot_I18n_string( html_entity_decode( str_replace( "'", "\'", $option_tree_settings['contextual_help']['sidebar'] ) ) );
|
1631 |
-
}
|
1632 |
-
|
1633 |
-
/* check that $contexual_help has a value and add to $build_settings */
|
1634 |
-
if ( '' != $contextual_help ) {
|
1635 |
-
$build_settings.= "
|
1636 |
-
'contextual_help' => array( $contextual_help
|
1637 |
-
),";
|
1638 |
-
}
|
1639 |
-
|
1640 |
-
/* build sections */
|
1641 |
-
if ( isset( $option_tree_settings['sections'] ) ) {
|
1642 |
-
foreach( $option_tree_settings['sections'] as $value ) {
|
1643 |
-
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1644 |
-
$_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
|
1645 |
-
$sections.= "
|
1646 |
-
array(
|
1647 |
-
'id' => '$_id',
|
1648 |
-
'title' => $_title
|
1649 |
-
),";
|
1650 |
-
}
|
1651 |
-
$sections = substr_replace( $sections, '' , -1 );
|
1652 |
-
}
|
1653 |
-
|
1654 |
-
/* check that $sections has a value and add to $build_settings */
|
1655 |
-
if ( '' != $sections ) {
|
1656 |
-
$build_settings.= "
|
1657 |
-
'sections' => array( $sections
|
1658 |
-
)";
|
1659 |
-
}
|
1660 |
-
|
1661 |
-
/* build settings */
|
1662 |
-
if ( isset( $option_tree_settings['settings'] ) ) {
|
1663 |
-
foreach( $option_tree_settings['settings'] as $value ) {
|
1664 |
-
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1665 |
-
$_label = ot_I18n_string( isset( $value['label'] ) ? str_replace( "'", "\'", $value['label'] ) : '' );
|
1666 |
-
$_desc = ot_I18n_string( isset( $value['desc'] ) ? str_replace( "'", "\'", $value['desc'] ) : '' );
|
1667 |
-
$_std = isset( $value['std'] ) ? str_replace( "'", "\'", $value['std'] ) : '';
|
1668 |
-
$_type = isset( $value['type'] ) ? $value['type'] : '';
|
1669 |
-
$_section = isset( $value['section'] ) ? $value['section'] : '';
|
1670 |
-
$_rows = isset( $value['rows'] ) ? $value['rows'] : '';
|
1671 |
-
$_post_type = isset( $value['post_type'] ) ? $value['post_type'] : '';
|
1672 |
-
$_taxonomy = isset( $value['taxonomy'] ) ? $value['taxonomy'] : '';
|
1673 |
-
$_min_max_step = isset( $value['min_max_step'] ) ? $value['min_max_step'] : '';
|
1674 |
-
$_class = isset( $value['class'] ) ? $value['class'] : '';
|
1675 |
-
$_condition = isset( $value['condition'] ) ? $value['condition'] : '';
|
1676 |
-
$_operator = isset( $value['operator'] ) ? $value['operator'] : '';
|
1677 |
-
|
1678 |
-
$choices = '';
|
1679 |
-
if ( isset( $value['choices'] ) && ! empty( $value['choices'] ) ) {
|
1680 |
-
foreach( $value['choices'] as $choice ) {
|
1681 |
-
$_choice_value = isset( $choice['value'] ) ? str_replace( "'", "\'", $choice['value'] ) : '';
|
1682 |
-
$_choice_label = ot_I18n_string( isset( $choice['label'] ) ? str_replace( "'", "\'", $choice['label'] ) : '' );
|
1683 |
-
$_choice_src = isset( $choice['src'] ) ? str_replace( "'", "\'", $choice['src'] ) : '';
|
1684 |
-
$choices.= "
|
1685 |
-
array(
|
1686 |
-
'value' => '$_choice_value',
|
1687 |
-
'label' => $_choice_label,
|
1688 |
-
'src' => '$_choice_src'
|
1689 |
-
),";
|
1690 |
-
}
|
1691 |
-
$choices = substr_replace( $choices, '' , -1 );
|
1692 |
-
$choices = ",
|
1693 |
-
'choices' => array( $choices
|
1694 |
-
)";
|
1695 |
-
}
|
1696 |
-
|
1697 |
-
$std = "'$_std'";
|
1698 |
-
if ( is_array( $_std ) ) {
|
1699 |
-
$std_array = array();
|
1700 |
-
foreach( $_std as $_sk => $_sv ) {
|
1701 |
-
$std_array[] = "'$_sk' => '$_sv'";
|
1702 |
-
}
|
1703 |
-
$std = 'array(
|
1704 |
-
' . implode( ",\n", $std_array ) . '
|
1705 |
-
)';
|
1706 |
-
}
|
1707 |
-
|
1708 |
-
$setting_settings = '';
|
1709 |
-
if ( isset( $value['settings'] ) && ! empty( $value['settings'] ) ) {
|
1710 |
-
foreach( $value['settings'] as $setting ) {
|
1711 |
-
$_setting_id = isset( $setting['id'] ) ? $setting['id'] : '';
|
1712 |
-
$_setting_label = ot_I18n_string( isset( $setting['label'] ) ? str_replace( "'", "\'", $setting['label'] ) : '' );
|
1713 |
-
$_setting_desc = ot_I18n_string( isset( $setting['desc'] ) ? str_replace( "'", "\'", $setting['desc'] ) : '' );
|
1714 |
-
$_setting_std = isset( $setting['std'] ) ? $setting['std'] : '';
|
1715 |
-
$_setting_type = isset( $setting['type'] ) ? $setting['type'] : '';
|
1716 |
-
$_setting_rows = isset( $setting['rows'] ) ? $setting['rows'] : '';
|
1717 |
-
$_setting_post_type = isset( $setting['post_type'] ) ? $setting['post_type'] : '';
|
1718 |
-
$_setting_taxonomy = isset( $setting['taxonomy'] ) ? $setting['taxonomy'] : '';
|
1719 |
-
$_setting_min_max_step = isset( $setting['min_max_step'] ) ? $setting['min_max_step'] : '';
|
1720 |
-
$_setting_class = isset( $setting['class'] ) ? $setting['class'] : '';
|
1721 |
-
$_setting_condition = isset( $setting['condition'] ) ? $setting['condition'] : '';
|
1722 |
-
$_setting_operator = isset( $setting['operator'] ) ? $setting['operator'] : '';
|
1723 |
-
|
1724 |
-
$setting_choices = '';
|
1725 |
-
if ( isset( $setting['choices'] ) && ! empty( $setting['choices'] ) ) {
|
1726 |
-
foreach( $setting['choices'] as $setting_choice ) {
|
1727 |
-
$_setting_choice_value = isset( $setting_choice['value'] ) ? $setting_choice['value'] : '';
|
1728 |
-
$_setting_choice_label = ot_I18n_string( isset( $setting_choice['label'] ) ? str_replace( "'", "\'", $setting_choice['label'] ) : '' );
|
1729 |
-
$_setting_choice_src = isset( $setting_choice['src'] ) ? str_replace( "'", "\'", $setting_choice['src'] ) : '';
|
1730 |
-
$setting_choices.= "
|
1731 |
-
array(
|
1732 |
-
'value' => '$_setting_choice_value',
|
1733 |
-
'label' => $_setting_choice_label,
|
1734 |
-
'src' => '$_setting_choice_src'
|
1735 |
-
),";
|
1736 |
-
}
|
1737 |
-
$setting_choices = substr_replace( $setting_choices, '' , -1 );
|
1738 |
-
$setting_choices = ",
|
1739 |
-
'choices' => array( $setting_choices
|
1740 |
-
)";
|
1741 |
-
}
|
1742 |
-
|
1743 |
-
$setting_std = "'$_setting_std'";
|
1744 |
-
if ( is_array( $_setting_std ) ) {
|
1745 |
-
$setting_std_array = array();
|
1746 |
-
foreach( $_setting_std as $_ssk => $_ssv ) {
|
1747 |
-
$setting_std_array[] = "'$_ssk' => '$_ssv'";
|
1748 |
-
}
|
1749 |
-
$setting_std = 'array(
|
1750 |
-
' . implode( ",\n", $setting_std_array ) . '
|
1751 |
-
)';
|
1752 |
-
}
|
1753 |
-
|
1754 |
-
$setting_settings.= "
|
1755 |
-
array(
|
1756 |
-
'id' => '$_setting_id',
|
1757 |
-
'label' => $_setting_label,
|
1758 |
-
'desc' => $_setting_desc,
|
1759 |
-
'std' => $setting_std,
|
1760 |
-
'type' => '$_setting_type',
|
1761 |
-
'rows' => '$_setting_rows',
|
1762 |
-
'post_type' => '$_setting_post_type',
|
1763 |
-
'taxonomy' => '$_setting_taxonomy',
|
1764 |
-
'min_max_step'=> '$_setting_min_max_step',
|
1765 |
-
'class' => '$_setting_class',
|
1766 |
-
'condition' => '$_setting_condition',
|
1767 |
-
'operator' => '$_setting_operator'$setting_choices
|
1768 |
-
),";
|
1769 |
-
}
|
1770 |
-
$setting_settings = substr_replace( $setting_settings, '' , -1 );
|
1771 |
-
$setting_settings = ",
|
1772 |
-
'settings' => array( $setting_settings
|
1773 |
-
)";
|
1774 |
-
}
|
1775 |
-
|
1776 |
-
$settings.= "
|
1777 |
-
array(
|
1778 |
-
'id' => '$_id',
|
1779 |
-
'label' => $_label,
|
1780 |
-
'desc' => $_desc,
|
1781 |
-
'std' => $std,
|
1782 |
-
'type' => '$_type',
|
1783 |
-
'section' => '$_section',
|
1784 |
-
'rows' => '$_rows',
|
1785 |
-
'post_type' => '$_post_type',
|
1786 |
-
'taxonomy' => '$_taxonomy',
|
1787 |
-
'min_max_step'=> '$_min_max_step',
|
1788 |
-
'class' => '$_class',
|
1789 |
-
'condition' => '$_condition',
|
1790 |
-
'operator' => '$_operator'$choices$setting_settings
|
1791 |
-
),";
|
1792 |
-
}
|
1793 |
-
$settings = substr_replace( $settings, '' , -1 );
|
1794 |
-
}
|
1795 |
-
|
1796 |
-
/* check that $sections has a value and add to $build_settings */
|
1797 |
-
if ( '' != $settings ) {
|
1798 |
-
$build_settings.= ",
|
1799 |
-
'settings' => array( $settings
|
1800 |
-
)";
|
1801 |
-
}
|
1802 |
-
|
1803 |
-
$content.= "<?php
|
1804 |
-
/**
|
1805 |
-
* Initialize the custom theme options.
|
1806 |
-
*/
|
1807 |
-
add_action( 'init', 'custom_theme_options' );
|
1808 |
-
|
1809 |
-
/**
|
1810 |
-
* Build the custom settings & update OptionTree.
|
1811 |
-
*/
|
1812 |
-
function custom_theme_options() {
|
1813 |
-
|
1814 |
-
/* OptionTree is not loaded yet, or this is not an admin request */
|
1815 |
-
if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() )
|
1816 |
-
return false;
|
1817 |
-
|
1818 |
-
/**
|
1819 |
-
* Get a copy of the saved settings array.
|
1820 |
-
*/
|
1821 |
-
\$saved_settings = get_option( ot_settings_id(), array() );
|
1822 |
-
|
1823 |
-
/**
|
1824 |
-
* Custom settings array that will eventually be
|
1825 |
-
* passes to the OptionTree Settings API Class.
|
1826 |
-
*/
|
1827 |
-
\$custom_settings = array( $build_settings
|
1828 |
-
);
|
1829 |
-
|
1830 |
-
/* allow settings to be filtered before saving */
|
1831 |
-
\$custom_settings = apply_filters( ot_settings_id() . '_args', \$custom_settings );
|
1832 |
-
|
1833 |
-
/* settings are not the same update the DB */
|
1834 |
-
if ( \$saved_settings !== \$custom_settings ) {
|
1835 |
-
update_option( ot_settings_id(), \$custom_settings );
|
1836 |
-
}
|
1837 |
-
|
1838 |
-
/* Lets OptionTree know the UI Builder is being overridden */
|
1839 |
-
global \$ot_has_custom_theme_options;
|
1840 |
-
\$ot_has_custom_theme_options = true;
|
1841 |
-
|
1842 |
-
}";
|
1843 |
-
|
1844 |
-
echo $content;
|
1845 |
-
die();
|
1846 |
-
}
|
1847 |
-
|
1848 |
-
}
|
1849 |
-
|
1850 |
-
/**
|
1851 |
-
* Save settings array before the screen is displayed.
|
1852 |
-
*
|
1853 |
-
* @return void
|
1854 |
-
*
|
1855 |
-
* @access public
|
1856 |
-
* @since 2.0
|
1857 |
-
*/
|
1858 |
-
if ( ! function_exists( 'ot_save_settings' ) ) {
|
1859 |
-
|
1860 |
-
function ot_save_settings() {
|
1861 |
-
|
1862 |
-
/* check and verify import settings nonce */
|
1863 |
-
if ( isset( $_POST['option_tree_settings_nonce'] ) && wp_verify_nonce( $_POST['option_tree_settings_nonce'], 'option_tree_settings_form' ) ) {
|
1864 |
-
|
1865 |
-
/* settings value */
|
1866 |
-
$settings = isset( $_POST[ot_settings_id()] ) ? $_POST[ot_settings_id()] : '';
|
1867 |
-
|
1868 |
-
/* validate sections */
|
1869 |
-
if ( isset( $settings['sections'] ) ) {
|
1870 |
-
|
1871 |
-
/* fix numeric keys since drag & drop will change them */
|
1872 |
-
$settings['sections'] = array_values( $settings['sections'] );
|
1873 |
-
|
1874 |
-
/* loop through sections */
|
1875 |
-
foreach( $settings['sections'] as $k => $section ) {
|
1876 |
-
|
1877 |
-
/* remove from array if missing values */
|
1878 |
-
if ( ( ! isset( $section['title'] ) && ! isset( $section['id'] ) ) || ( '' == $section['title'] && '' == $section['id'] ) ) {
|
1879 |
-
|
1880 |
-
unset( $settings['sections'][$k] );
|
1881 |
-
|
1882 |
-
} else {
|
1883 |
-
|
1884 |
-
/* validate label */
|
1885 |
-
if ( '' != $section['title'] ) {
|
1886 |
-
|
1887 |
-
$settings['sections'][$k]['title'] = wp_kses_post( $section['title'] );
|
1888 |
-
|
1889 |
-
}
|
1890 |
-
|
1891 |
-
/* missing title set to unfiltered ID */
|
1892 |
-
if ( ! isset( $section['title'] ) || '' == $section['title'] ) {
|
1893 |
-
|
1894 |
-
$settings['sections'][$k]['title'] = wp_kses_post( $section['id'] );
|
1895 |
-
|
1896 |
-
/* missing ID set to title */
|
1897 |
-
} else if ( ! isset( $section['id'] ) || '' == $section['id'] ) {
|
1898 |
-
|
1899 |
-
$section['id'] = wp_kses_post( $section['title'] );
|
1900 |
-
|
1901 |
-
}
|
1902 |
-
|
1903 |
-
/* sanitize ID once everything has been checked first */
|
1904 |
-
$settings['sections'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $section['id'] ) );
|
1905 |
-
|
1906 |
-
}
|
1907 |
-
|
1908 |
-
}
|
1909 |
-
|
1910 |
-
$settings['sections'] = ot_stripslashes( $settings['sections'] );
|
1911 |
-
|
1912 |
-
}
|
1913 |
-
|
1914 |
-
/* validate settings by looping over array as many times as it takes */
|
1915 |
-
if ( isset( $settings['settings'] ) ) {
|
1916 |
-
|
1917 |
-
$settings['settings'] = ot_validate_settings_array( $settings['settings'] );
|
1918 |
-
|
1919 |
-
}
|
1920 |
-
|
1921 |
-
/* validate contextual_help */
|
1922 |
-
if ( isset( $settings['contextual_help']['content'] ) ) {
|
1923 |
-
|
1924 |
-
/* fix numeric keys since drag & drop will change them */
|
1925 |
-
$settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] );
|
1926 |
-
|
1927 |
-
/* loop through content */
|
1928 |
-
foreach( $settings['contextual_help']['content'] as $k => $content ) {
|
1929 |
-
|
1930 |
-
/* remove from array if missing values */
|
1931 |
-
if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' == $content['title'] && '' == $content['id'] ) ) {
|
1932 |
-
|
1933 |
-
unset( $settings['contextual_help']['content'][$k] );
|
1934 |
-
|
1935 |
-
} else {
|
1936 |
-
|
1937 |
-
/* validate label */
|
1938 |
-
if ( '' != $content['title'] ) {
|
1939 |
-
|
1940 |
-
$settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['title'] );
|
1941 |
-
|
1942 |
-
}
|
1943 |
-
|
1944 |
-
/* missing title set to unfiltered ID */
|
1945 |
-
if ( ! isset( $content['title'] ) || '' == $content['title'] ) {
|
1946 |
-
|
1947 |
-
$settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['id'] );
|
1948 |
-
|
1949 |
-
/* missing ID set to title */
|
1950 |
-
} else if ( ! isset( $content['id'] ) || '' == $content['id'] ) {
|
1951 |
-
|
1952 |
-
$content['id'] = wp_kses_post( $content['title'] );
|
1953 |
-
|
1954 |
-
}
|
1955 |
-
|
1956 |
-
/* sanitize ID once everything has been checked first */
|
1957 |
-
$settings['contextual_help']['content'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $content['id'] ) );
|
1958 |
-
|
1959 |
-
}
|
1960 |
-
|
1961 |
-
/* validate textarea description */
|
1962 |
-
if ( isset( $content['content'] ) ) {
|
1963 |
-
|
1964 |
-
$settings['contextual_help']['content'][$k]['content'] = wp_kses_post( $content['content'] );
|
1965 |
-
|
1966 |
-
}
|
1967 |
-
|
1968 |
-
}
|
1969 |
-
|
1970 |
-
}
|
1971 |
-
|
1972 |
-
/* validate contextual_help sidebar */
|
1973 |
-
if ( isset( $settings['contextual_help']['sidebar'] ) ) {
|
1974 |
-
|
1975 |
-
$settings['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] );
|
1976 |
-
|
1977 |
-
}
|
1978 |
-
|
1979 |
-
$settings['contextual_help'] = ot_stripslashes( $settings['contextual_help'] );
|
1980 |
-
|
1981 |
-
/* default message */
|
1982 |
-
$message = 'failed';
|
1983 |
-
|
1984 |
-
/* is array: save & show success message */
|
1985 |
-
if ( is_array( $settings ) ) {
|
1986 |
-
|
1987 |
-
/* WPML unregister ID's that have been removed */
|
1988 |
-
if ( function_exists( 'icl_unregister_string' ) ) {
|
1989 |
-
|
1990 |
-
$current = get_option( ot_settings_id() );
|
1991 |
-
$options = get_option( ot_options_id() );
|
1992 |
-
|
1993 |
-
if ( isset( $current['settings'] ) ) {
|
1994 |
-
|
1995 |
-
/* Empty ID array */
|
1996 |
-
$new_ids = array();
|
1997 |
-
|
1998 |
-
/* Build the WPML IDs array */
|
1999 |
-
foreach( $settings['settings'] as $setting ) {
|
2000 |
-
|
2001 |
-
if ( $setting['id'] ) {
|
2002 |
-
|
2003 |
-
$new_ids[] = $setting['id'];
|
2004 |
-
|
2005 |
-
}
|
2006 |
-
|
2007 |
-
}
|
2008 |
-
|
2009 |
-
/* Remove missing IDs from WPML */
|
2010 |
-
foreach( $current['settings'] as $current_setting ) {
|
2011 |
-
|
2012 |
-
if ( ! in_array( $current_setting['id'], $new_ids ) ) {
|
2013 |
-
|
2014 |
-
if ( ! empty( $options[$current_setting['id']] ) && in_array( $current_setting['type'], array( 'list-item', 'slider' ) ) ) {
|
2015 |
-
|
2016 |
-
foreach( $options[$current_setting['id']] as $key => $value ) {
|
2017 |
-
|
2018 |
-
foreach( $value as $ckey => $cvalue ) {
|
2019 |
-
|
2020 |
-
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
2021 |
-
|
2022 |
-
}
|
2023 |
-
|
2024 |
-
}
|
2025 |
-
|
2026 |
-
} else if ( ! empty( $options[$current_setting['id']] ) && $current_setting['type'] == 'social-icons' ) {
|
2027 |
-
|
2028 |
-
foreach( $options[$current_setting['id']] as $key => $value ) {
|
2029 |
-
|
2030 |
-
foreach( $value as $ckey => $cvalue ) {
|
2031 |
-
|
2032 |
-
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
2033 |
-
|
2034 |
-
}
|
2035 |
-
|
2036 |
-
}
|
2037 |
-
|
2038 |
-
} else {
|
2039 |
-
|
2040 |
-
ot_wpml_unregister_string( $current_setting['id'] );
|
2041 |
-
|
2042 |
-
}
|
2043 |
-
|
2044 |
-
}
|
2045 |
-
|
2046 |
-
}
|
2047 |
-
|
2048 |
-
}
|
2049 |
-
|
2050 |
-
}
|
2051 |
-
|
2052 |
-
update_option( ot_settings_id(), $settings );
|
2053 |
-
$message = 'success';
|
2054 |
-
|
2055 |
-
// bust cache in 3rd party plugins
|
2056 |
-
if (function_exists('w3tc_pgcache_flush')) {
|
2057 |
-
w3tc_pgcache_flush();
|
2058 |
-
}
|
2059 |
-
if (function_exists('wp_cache_clear_cache')) {
|
2060 |
-
wp_cache_clear_cache();
|
2061 |
-
}
|
2062 |
-
if (class_exists('Endurance_Page_Cache')) {
|
2063 |
-
$epc = new Endurance_Page_Cache;
|
2064 |
-
$epc->purge_all();
|
2065 |
-
}
|
2066 |
-
if (class_exists('SG_CachePress_Supercacher') && method_exists('SG_CachePress_Supercacher', 'purge_cache')) {
|
2067 |
-
SG_CachePress_Supercacher::purge_cache(true);
|
2068 |
-
}
|
2069 |
-
if (class_exists('SiteGround_Optimizer\Supercacher\Supercacher')) {
|
2070 |
-
SiteGround_Optimizer\Supercacher\Supercacher::purge_cache();
|
2071 |
-
}
|
2072 |
-
if (isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) {
|
2073 |
-
$GLOBALS['wp_fastest_cache']->deleteCache(true);
|
2074 |
-
}
|
2075 |
-
if (is_callable(array('Swift_Performance_Cache', 'clear_all_cache'))) {
|
2076 |
-
Swift_Performance_Cache::clear_all_cache();
|
2077 |
-
}
|
2078 |
-
}
|
2079 |
-
|
2080 |
-
/* redirect */
|
2081 |
-
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'action' => 'save-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
2082 |
-
exit;
|
2083 |
-
|
2084 |
-
}
|
2085 |
-
|
2086 |
-
return false;
|
2087 |
-
|
2088 |
-
}
|
2089 |
-
|
2090 |
-
}
|
2091 |
-
|
2092 |
-
/**
|
2093 |
-
* Validate the settings array before save.
|
2094 |
-
*
|
2095 |
-
* This function will loop over the settings array as many
|
2096 |
-
* times as it takes to validate every sub setting.
|
2097 |
-
*
|
2098 |
-
* @param array $settings The array of settings.
|
2099 |
-
* @return array
|
2100 |
-
*
|
2101 |
-
* @access public
|
2102 |
-
* @since 2.0
|
2103 |
-
*/
|
2104 |
-
if ( ! function_exists( 'ot_validate_settings_array' ) ) {
|
2105 |
-
|
2106 |
-
function ot_validate_settings_array( $settings = array() ) {
|
2107 |
-
|
2108 |
-
/* validate settings */
|
2109 |
-
if ( count( $settings ) > 0 ) {
|
2110 |
-
|
2111 |
-
/* fix numeric keys since drag & drop will change them */
|
2112 |
-
$settings = array_values( $settings );
|
2113 |
-
|
2114 |
-
/* loop through settings */
|
2115 |
-
foreach( $settings as $k => $setting ) {
|
2116 |
-
|
2117 |
-
|
2118 |
-
/* remove from array if missing values */
|
2119 |
-
if ( ( ! isset( $setting['label'] ) && ! isset( $setting['id'] ) ) || ( '' == $setting['label'] && '' == $setting['id'] ) ) {
|
2120 |
-
|
2121 |
-
unset( $settings[$k] );
|
2122 |
-
|
2123 |
-
} else {
|
2124 |
-
|
2125 |
-
/* validate label */
|
2126 |
-
if ( '' != $setting['label'] ) {
|
2127 |
-
|
2128 |
-
$settings[$k]['label'] = wp_kses_post( $setting['label'] );
|
2129 |
-
|
2130 |
-
}
|
2131 |
-
|
2132 |
-
/* missing label set to unfiltered ID */
|
2133 |
-
if ( ! isset( $setting['label'] ) || '' == $setting['label'] ) {
|
2134 |
-
|
2135 |
-
$settings[$k]['label'] = $setting['id'];
|
2136 |
-
|
2137 |
-
/* missing ID set to label */
|
2138 |
-
} else if ( ! isset( $setting['id'] ) || '' == $setting['id'] ) {
|
2139 |
-
|
2140 |
-
$setting['id'] = wp_kses_post( $setting['label'] );
|
2141 |
-
|
2142 |
-
}
|
2143 |
-
|
2144 |
-
/* sanitize ID once everything has been checked first */
|
2145 |
-
$settings[$k]['id'] = ot_sanitize_option_id( wp_kses_post( $setting['id'] ) );
|
2146 |
-
|
2147 |
-
}
|
2148 |
-
|
2149 |
-
/* validate description */
|
2150 |
-
if ( '' != $setting['desc'] ) {
|
2151 |
-
|
2152 |
-
$settings[$k]['desc'] = wp_kses_post( $setting['desc'] );
|
2153 |
-
|
2154 |
-
}
|
2155 |
-
|
2156 |
-
/* validate choices */
|
2157 |
-
if ( isset( $setting['choices'] ) ) {
|
2158 |
-
|
2159 |
-
/* loop through choices */
|
2160 |
-
foreach( $setting['choices'] as $ck => $choice ) {
|
2161 |
-
|
2162 |
-
/* remove from array if missing values */
|
2163 |
-
if ( ( ! isset( $choice['label'] ) && ! isset( $choice['value'] ) ) || ( '' == $choice['label'] && '' == $choice['value'] ) ) {
|
2164 |
-
|
2165 |
-
unset( $setting['choices'][$ck] );
|
2166 |
-
|
2167 |
-
} else {
|
2168 |
-
|
2169 |
-
/* missing label set to unfiltered ID */
|
2170 |
-
if ( ! isset( $choice['label'] ) || '' == $choice['label'] ) {
|
2171 |
-
|
2172 |
-
$setting['choices'][$ck]['label'] = wp_kses_post( $choice['value'] );
|
2173 |
-
|
2174 |
-
/* missing value set to label */
|
2175 |
-
} else if ( ! isset( $choice['value'] ) || '' == $choice['value'] ) {
|
2176 |
-
|
2177 |
-
$setting['choices'][$ck]['value'] = ot_sanitize_option_id( wp_kses_post( $choice['label'] ) );
|
2178 |
-
|
2179 |
-
}
|
2180 |
-
|
2181 |
-
}
|
2182 |
-
|
2183 |
-
}
|
2184 |
-
|
2185 |
-
/* update keys and push new array values */
|
2186 |
-
$settings[$k]['choices'] = array_values( $setting['choices'] );
|
2187 |
-
|
2188 |
-
}
|
2189 |
-
|
2190 |
-
/* validate sub settings */
|
2191 |
-
if ( isset( $setting['settings'] ) ) {
|
2192 |
-
|
2193 |
-
$settings[$k]['settings'] = ot_validate_settings_array( $setting['settings'] );
|
2194 |
-
|
2195 |
-
}
|
2196 |
-
|
2197 |
-
}
|
2198 |
-
|
2199 |
-
}
|
2200 |
-
|
2201 |
-
/* return array but strip those damn slashes out first!!! */
|
2202 |
-
return ot_stripslashes( $settings );
|
2203 |
-
|
2204 |
-
}
|
2205 |
-
|
2206 |
-
}
|
2207 |
-
|
2208 |
-
/**
|
2209 |
-
* Save layouts array before the screen is displayed.
|
2210 |
-
*
|
2211 |
-
* @return void
|
2212 |
-
*
|
2213 |
-
* @access public
|
2214 |
-
* @since 2.0
|
2215 |
-
*/
|
2216 |
-
if ( ! function_exists( 'ot_modify_layouts' ) ) {
|
2217 |
-
|
2218 |
-
function ot_modify_layouts() {
|
2219 |
-
|
2220 |
-
/* check and verify modify layouts nonce */
|
2221 |
-
if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) {
|
2222 |
-
|
2223 |
-
/* previous layouts value */
|
2224 |
-
$option_tree_layouts = get_option( ot_layouts_id() );
|
2225 |
-
|
2226 |
-
/* new layouts value */
|
2227 |
-
$layouts = isset( $_POST[ot_layouts_id()] ) ? $_POST[ot_layouts_id()] : '';
|
2228 |
-
|
2229 |
-
/* rebuild layout array */
|
2230 |
-
$rebuild = array();
|
2231 |
-
|
2232 |
-
/* validate layouts */
|
2233 |
-
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
2234 |
-
|
2235 |
-
/* setup active layout */
|
2236 |
-
if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
|
2237 |
-
$rebuild['active_layout'] = $layouts['active_layout'];
|
2238 |
-
}
|
2239 |
-
|
2240 |
-
/* add new and overwrite active layout */
|
2241 |
-
if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
|
2242 |
-
$rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] );
|
2243 |
-
$rebuild[$rebuild['active_layout']] = ot_encode( serialize( get_option( ot_options_id() ) ) );
|
2244 |
-
}
|
2245 |
-
|
2246 |
-
$first_layout = '';
|
2247 |
-
|
2248 |
-
/* loop through layouts */
|
2249 |
-
foreach( $layouts as $key => $layout ) {
|
2250 |
-
|
2251 |
-
/* skip over active layout key */
|
2252 |
-
if ( $key == 'active_layout' )
|
2253 |
-
continue;
|
2254 |
-
|
2255 |
-
/* check if the key exists then set value */
|
2256 |
-
if ( isset( $option_tree_layouts[$key] ) && ! empty( $option_tree_layouts[$key] ) ) {
|
2257 |
-
$rebuild[$key] = $option_tree_layouts[$key];
|
2258 |
-
if ( '' == $first_layout ) {
|
2259 |
-
$first_layout = $key;
|
2260 |
-
}
|
2261 |
-
}
|
2262 |
-
|
2263 |
-
}
|
2264 |
-
|
2265 |
-
if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[$rebuild['active_layout']] ) && ! empty( $first_layout ) ) {
|
2266 |
-
$rebuild['active_layout'] = $first_layout;
|
2267 |
-
}
|
2268 |
-
|
2269 |
-
}
|
2270 |
-
|
2271 |
-
/* default message */
|
2272 |
-
$message = 'failed';
|
2273 |
-
|
2274 |
-
/* is array: save & show success message */
|
2275 |
-
if ( count( $rebuild ) > 1 ) {
|
2276 |
-
|
2277 |
-
/* rebuild the theme options */
|
2278 |
-
$rebuild_option_tree = unserialize( ot_decode( $rebuild[$rebuild['active_layout']] ) );
|
2279 |
-
if ( is_array( $rebuild_option_tree ) ) {
|
2280 |
-
|
2281 |
-
/* execute the action hook and pass the theme options to it */
|
2282 |
-
do_action( 'ot_before_theme_options_save', $rebuild_option_tree );
|
2283 |
-
|
2284 |
-
update_option( ot_options_id(), $rebuild_option_tree );
|
2285 |
-
|
2286 |
-
}
|
2287 |
-
|
2288 |
-
/* rebuild the layouts */
|
2289 |
-
update_option( ot_layouts_id(), $rebuild );
|
2290 |
-
|
2291 |
-
/* change message */
|
2292 |
-
$message = 'success';
|
2293 |
-
|
2294 |
-
} else if ( count( $rebuild ) <= 1 ) {
|
2295 |
-
|
2296 |
-
/* delete layouts option */
|
2297 |
-
delete_option( ot_layouts_id() );
|
2298 |
-
|
2299 |
-
/* change message */
|
2300 |
-
$message = 'deleted';
|
2301 |
-
|
2302 |
-
}
|
2303 |
-
|
2304 |
-
/* redirect */
|
2305 |
-
if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == apply_filters( 'niftycs_options_menu_slug', 'niftycs-options' ) ) {
|
2306 |
-
$query_args = esc_url_raw( add_query_arg( array( 'settings-updated' => 'layout' ), remove_query_arg( array( 'action', 'message' ), $_POST['_wp_http_referer'] ) ) );
|
2307 |
-
} else {
|
2308 |
-
$query_args = esc_url_raw( add_query_arg( array( 'action' => 'save-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) );
|
2309 |
-
}
|
2310 |
-
wp_safe_redirect( $query_args );
|
2311 |
-
exit;
|
2312 |
-
|
2313 |
-
}
|
2314 |
-
|
2315 |
-
return false;
|
2316 |
-
|
2317 |
-
}
|
2318 |
-
|
2319 |
-
}
|
2320 |
-
|
2321 |
-
/**
|
2322 |
-
* Helper function to display alert messages.
|
2323 |
-
*
|
2324 |
-
* @param array Page array
|
2325 |
-
* @return mixed
|
2326 |
-
*
|
2327 |
-
* @access public
|
2328 |
-
* @since 2.0
|
2329 |
-
*/
|
2330 |
-
if ( ! function_exists( 'ot_alert_message' ) ) {
|
2331 |
-
|
2332 |
-
function ot_alert_message( $page = array() ) {
|
2333 |
-
|
2334 |
-
if ( empty( $page ) )
|
2335 |
-
return false;
|
2336 |
-
|
2337 |
-
$before = apply_filters( 'ot_before_page_messages', '', $page );
|
2338 |
-
|
2339 |
-
if ( $before ) {
|
2340 |
-
return $before;
|
2341 |
-
}
|
2342 |
-
|
2343 |
-
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
|
2344 |
-
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
|
2345 |
-
$updated = isset( $_REQUEST['settings-updated'] ) ? $_REQUEST['settings-updated'] : '';
|
2346 |
-
|
2347 |
-
if ( $action == 'save-settings' ) {
|
2348 |
-
|
2349 |
-
if ( $message == 'success' ) {
|
2350 |
-
|
2351 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings updated.', 'option-tree' ) . '</p></div>';
|
2352 |
-
|
2353 |
-
} else if ( $message == 'failed' ) {
|
2354 |
-
|
2355 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be saved.', 'option-tree' ) . '</p></div>';
|
2356 |
-
|
2357 |
-
}
|
2358 |
-
|
2359 |
-
} else if ( $action == 'import-xml' || $action == 'import-settings' ) {
|
2360 |
-
|
2361 |
-
if ( $message == 'success' ) {
|
2362 |
-
|
2363 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings Imported.', 'option-tree' ) . '</p></div>';
|
2364 |
-
|
2365 |
-
} else if ( $message == 'failed' ) {
|
2366 |
-
|
2367 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be imported.', 'option-tree' ) . '</p></div>';
|
2368 |
-
|
2369 |
-
}
|
2370 |
-
} else if ( $action == 'import-data' ) {
|
2371 |
-
|
2372 |
-
if ( $message == 'success' ) {
|
2373 |
-
|
2374 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Data Imported.', 'option-tree' ) . '</p></div>';
|
2375 |
-
|
2376 |
-
} else if ( $message == 'failed' ) {
|
2377 |
-
|
2378 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Data could not be imported.', 'option-tree' ) . '</p></div>';
|
2379 |
-
|
2380 |
-
}
|
2381 |
-
|
2382 |
-
} else if ( $action == 'import-layouts' ) {
|
2383 |
-
|
2384 |
-
if ( $message == 'success' ) {
|
2385 |
-
|
2386 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Imported.', 'option-tree' ) . '</p></div>';
|
2387 |
-
|
2388 |
-
} else if ( $message == 'failed' ) {
|
2389 |
-
|
2390 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be imported.', 'option-tree' ) . '</p></div>';
|
2391 |
-
|
2392 |
-
}
|
2393 |
-
|
2394 |
-
} else if ( $action == 'save-layouts' ) {
|
2395 |
-
|
2396 |
-
if ( $message == 'success' ) {
|
2397 |
-
|
2398 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Updated.', 'option-tree' ) . '</p></div>';
|
2399 |
-
|
2400 |
-
} else if ( $message == 'failed' ) {
|
2401 |
-
|
2402 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be updated.', 'option-tree' ) . '</p></div>';
|
2403 |
-
|
2404 |
-
} else if ( $message == 'deleted' ) {
|
2405 |
-
|
2406 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts have been deleted.', 'option-tree' ) . '</p></div>';
|
2407 |
-
|
2408 |
-
}
|
2409 |
-
|
2410 |
-
} else if ( $updated == 'layout' ) {
|
2411 |
-
|
2412 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layout activated.', 'option-tree' ) . '</p></div>';
|
2413 |
-
|
2414 |
-
} else if ( $action == 'reset' ) {
|
2415 |
-
|
2416 |
-
return '<div id="message" class="updated fade below-h2"><p>' . $page['reset_message'] . '</p></div>';
|
2417 |
-
|
2418 |
-
}
|
2419 |
-
|
2420 |
-
do_action( 'ot_custom_page_messages', $page );
|
2421 |
-
|
2422 |
-
if ( $updated == 'true' ) {
|
2423 |
-
|
2424 |
-
return '<div id="message" class="updated fade below-h2"><p>' . $page['updated_message'] . '</p></div>';
|
2425 |
-
|
2426 |
-
}
|
2427 |
-
|
2428 |
-
return false;
|
2429 |
-
|
2430 |
-
}
|
2431 |
-
|
2432 |
-
}
|
2433 |
-
|
2434 |
-
/**
|
2435 |
-
* Setup the default option types.
|
2436 |
-
*
|
2437 |
-
* The returned option types are filterable so you can add your own.
|
2438 |
-
* This is not a task for a beginner as you'll need to add the function
|
2439 |
-
* that displays the option to the user and validate the saved data.
|
2440 |
-
*
|
2441 |
-
* @return array
|
2442 |
-
*
|
2443 |
-
* @access public
|
2444 |
-
* @since 2.0
|
2445 |
-
*/
|
2446 |
-
if ( ! function_exists( 'ot_option_types_array' ) ) {
|
2447 |
-
|
2448 |
-
function ot_option_types_array() {
|
2449 |
-
|
2450 |
-
return apply_filters( 'ot_option_types_array', array(
|
2451 |
-
'background' => __('Background', 'option-tree'),
|
2452 |
-
'border' => __('Border', 'option-tree'),
|
2453 |
-
'box-shadow' => __('Box Shadow', 'option-tree'),
|
2454 |
-
'category-checkbox' => __('Category Checkbox', 'option-tree'),
|
2455 |
-
'category-select' => __('Category Select', 'option-tree'),
|
2456 |
-
'checkbox' => __('Checkbox', 'option-tree'),
|
2457 |
-
'colorpicker' => __('Colorpicker', 'option-tree'),
|
2458 |
-
'colorpicker-opacity' => __('Colorpicker Opacity', 'option-tree'),
|
2459 |
-
'css' => __('CSS', 'option-tree'),
|
2460 |
-
'custom-post-type-checkbox' => __('Custom Post Type Checkbox', 'option-tree'),
|
2461 |
-
'custom-post-type-select' => __('Custom Post Type Select', 'option-tree'),
|
2462 |
-
'date-picker' => __('Date Picker', 'option-tree'),
|
2463 |
-
'date-time-picker' => __('Date Time Picker', 'option-tree'),
|
2464 |
-
'dimension' => __('Dimension', 'option-tree'),
|
2465 |
-
'gallery' => __('Gallery', 'option-tree'),
|
2466 |
-
'google-fonts' => __('Google Fonts', 'option-tree'),
|
2467 |
-
'javascript' => __('JavaScript', 'option-tree'),
|
2468 |
-
'link-color' => __('Link Color', 'option-tree'),
|
2469 |
-
'list-item' => __('List Item', 'option-tree'),
|
2470 |
-
'measurement' => __('Measurement', 'option-tree'),
|
2471 |
-
'numeric-slider' => __('Numeric Slider', 'option-tree'),
|
2472 |
-
'on-off' => __('On/Off', 'option-tree'),
|
2473 |
-
'page-checkbox' => __('Page Checkbox', 'option-tree'),
|
2474 |
-
'page-select' => __('Page Select', 'option-tree'),
|
2475 |
-
'post-checkbox' => __('Post Checkbox', 'option-tree'),
|
2476 |
-
'post-select' => __('Post Select', 'option-tree'),
|
2477 |
-
'radio' => __('Radio', 'option-tree'),
|
2478 |
-
'radio-image' => __('Radio Image', 'option-tree'),
|
2479 |
-
'select' => __('Select', 'option-tree'),
|
2480 |
-
'sidebar-select' => __('Sidebar Select', 'option-tree'),
|
2481 |
-
'slider' => __('Slider', 'option-tree'),
|
2482 |
-
'social-links' => __('Social Links', 'option-tree'),
|
2483 |
-
'spacing' => __('Spacing', 'option-tree'),
|
2484 |
-
'tab' => __('Tab', 'option-tree'),
|
2485 |
-
'tag-checkbox' => __('Tag Checkbox', 'option-tree'),
|
2486 |
-
'tag-select' => __('Tag Select', 'option-tree'),
|
2487 |
-
'taxonomy-checkbox' => __('Taxonomy Checkbox', 'option-tree'),
|
2488 |
-
'taxonomy-select' => __('Taxonomy Select', 'option-tree'),
|
2489 |
-
'text' => __('Text', 'option-tree'),
|
2490 |
-
'textarea' => __('Textarea', 'option-tree'),
|
2491 |
-
'textarea-simple' => __('Textarea Simple', 'option-tree'),
|
2492 |
-
'textblock' => __('Textblock', 'option-tree'),
|
2493 |
-
'textblock-titled' => __('Textblock Titled', 'option-tree'),
|
2494 |
-
'typography' => __('Typography', 'option-tree'),
|
2495 |
-
'upload' => __('Upload', 'option-tree')
|
2496 |
-
) );
|
2497 |
-
|
2498 |
-
}
|
2499 |
-
}
|
2500 |
-
|
2501 |
-
/**
|
2502 |
-
* Map old option types for rebuilding XML and Table data.
|
2503 |
-
*
|
2504 |
-
* @param string $type The old option type
|
2505 |
-
* @return string The new option type
|
2506 |
-
*
|
2507 |
-
* @access public
|
2508 |
-
* @since 2.0
|
2509 |
-
*/
|
2510 |
-
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
2511 |
-
|
2512 |
-
function ot_map_old_option_types( $type = '' ) {
|
2513 |
-
|
2514 |
-
if ( ! $type )
|
2515 |
-
return 'text';
|
2516 |
-
|
2517 |
-
$types = array(
|
2518 |
-
'background' => 'background',
|
2519 |
-
'category' => 'category-select',
|
2520 |
-
'categories' => 'category-checkbox',
|
2521 |
-
'checkbox' => 'checkbox',
|
2522 |
-
'colorpicker' => 'colorpicker',
|
2523 |
-
'css' => 'css',
|
2524 |
-
'custom_post' => 'custom-post-type-select',
|
2525 |
-
'custom_posts' => 'custom-post-type-checkbox',
|
2526 |
-
'input' => 'text',
|
2527 |
-
'image' => 'upload',
|
2528 |
-
'measurement' => 'measurement',
|
2529 |
-
'page' => 'page-select',
|
2530 |
-
'pages' => 'page-checkbox',
|
2531 |
-
'post' => 'post-select',
|
2532 |
-
'posts' => 'post-checkbox',
|
2533 |
-
'radio' => 'radio',
|
2534 |
-
'select' => 'select',
|
2535 |
-
'slider' => 'slider',
|
2536 |
-
'tag' => 'tag-select',
|
2537 |
-
'tags' => 'tag-checkbox',
|
2538 |
-
'textarea' => 'textarea',
|
2539 |
-
'textblock' => 'textblock',
|
2540 |
-
'typography' => 'typography',
|
2541 |
-
'upload' => 'upload'
|
2542 |
-
);
|
2543 |
-
|
2544 |
-
if ( isset( $types[$type] ) )
|
2545 |
-
return $types[$type];
|
2546 |
-
|
2547 |
-
return false;
|
2548 |
-
|
2549 |
-
}
|
2550 |
-
}
|
2551 |
-
|
2552 |
-
/**
|
2553 |
-
* Filters the typography font-family to add Google fonts dynamically.
|
2554 |
-
*
|
2555 |
-
* @param array $families An array of all recognized font families.
|
2556 |
-
* @param string $field_id ID of the feild being filtered.
|
2557 |
-
* @return array
|
2558 |
-
*
|
2559 |
-
* @access public
|
2560 |
-
* @since 2.5.0
|
2561 |
-
*/
|
2562 |
-
function ot_google_font_stack( $families, $field_id ) {
|
2563 |
-
|
2564 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
2565 |
-
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
2566 |
-
|
2567 |
-
if ( ! empty( $ot_set_google_fonts ) ) {
|
2568 |
-
foreach( $ot_set_google_fonts as $id => $sets ) {
|
2569 |
-
foreach( $sets as $value ) {
|
2570 |
-
$family = isset( $value['family'] ) ? $value['family'] : '';
|
2571 |
-
if ( $family && isset( $ot_google_fonts[$family] ) ) {
|
2572 |
-
$spaces = explode(' ', $ot_google_fonts[$family]['family'] );
|
2573 |
-
$font_stack = count( $spaces ) > 1 ? '"' . $ot_google_fonts[$family]['family'] . '"': $ot_google_fonts[$family]['family'];
|
2574 |
-
$families[$family] = apply_filters( 'ot_google_font_stack', $font_stack, $family, $field_id );
|
2575 |
-
}
|
2576 |
-
}
|
2577 |
-
}
|
2578 |
-
}
|
2579 |
-
|
2580 |
-
return $families;
|
2581 |
-
}
|
2582 |
-
add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
|
2583 |
-
|
2584 |
-
/**
|
2585 |
-
* Recognized font families
|
2586 |
-
*
|
2587 |
-
* Returns an array of all recognized font families.
|
2588 |
-
* Keys are intended to be stored in the database
|
2589 |
-
* while values are ready for display in html.
|
2590 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2591 |
-
*
|
2592 |
-
* @uses apply_filters()
|
2593 |
-
*
|
2594 |
-
* @return array
|
2595 |
-
*
|
2596 |
-
* @access public
|
2597 |
-
* @since 1.1.8
|
2598 |
-
* @updated 2.0
|
2599 |
-
*/
|
2600 |
-
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
2601 |
-
|
2602 |
-
function ot_recognized_font_families( $field_id = '' ) {
|
2603 |
-
|
2604 |
-
$families = array(
|
2605 |
-
'arial' => 'Arial',
|
2606 |
-
'georgia' => 'Georgia',
|
2607 |
-
'helvetica' => 'Helvetica',
|
2608 |
-
'palatino' => 'Palatino',
|
2609 |
-
'tahoma' => 'Tahoma',
|
2610 |
-
'times' => '"Times New Roman", sans-serif',
|
2611 |
-
'trebuchet' => 'Trebuchet',
|
2612 |
-
'verdana' => 'Verdana'
|
2613 |
-
);
|
2614 |
-
|
2615 |
-
return apply_filters( 'ot_recognized_font_families', $families, $field_id );
|
2616 |
-
|
2617 |
-
}
|
2618 |
-
|
2619 |
-
}
|
2620 |
-
|
2621 |
-
/**
|
2622 |
-
* Recognized font sizes
|
2623 |
-
*
|
2624 |
-
* Returns an array of all recognized font sizes.
|
2625 |
-
*
|
2626 |
-
* @uses apply_filters()
|
2627 |
-
*
|
2628 |
-
* @param string $field_id ID that's passed to the filters.
|
2629 |
-
* @return array
|
2630 |
-
*
|
2631 |
-
* @access public
|
2632 |
-
* @since 2.0.12
|
2633 |
-
*/
|
2634 |
-
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
|
2635 |
-
|
2636 |
-
function ot_recognized_font_sizes( $field_id ) {
|
2637 |
-
|
2638 |
-
$range = ot_range(
|
2639 |
-
apply_filters( 'ot_font_size_low_range', 0, $field_id ),
|
2640 |
-
apply_filters( 'ot_font_size_high_range', 150, $field_id ),
|
2641 |
-
apply_filters( 'ot_font_size_range_interval', 1, $field_id )
|
2642 |
-
);
|
2643 |
-
|
2644 |
-
$unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
|
2645 |
-
|
2646 |
-
foreach( $range as $k => $v ) {
|
2647 |
-
$range[$k] = $v . $unit;
|
2648 |
-
}
|
2649 |
-
|
2650 |
-
return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
|
2651 |
-
}
|
2652 |
-
|
2653 |
-
}
|
2654 |
-
|
2655 |
-
/**
|
2656 |
-
* Recognized font styles
|
2657 |
-
*
|
2658 |
-
* Returns an array of all recognized font styles.
|
2659 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2660 |
-
*
|
2661 |
-
* @uses apply_filters()
|
2662 |
-
*
|
2663 |
-
* @return array
|
2664 |
-
*
|
2665 |
-
* @access public
|
2666 |
-
* @since 1.1.8
|
2667 |
-
* @updated 2.0
|
2668 |
-
*/
|
2669 |
-
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
|
2670 |
-
|
2671 |
-
function ot_recognized_font_styles( $field_id = '' ) {
|
2672 |
-
|
2673 |
-
return apply_filters( 'ot_recognized_font_styles', array(
|
2674 |
-
'normal' => 'Normal',
|
2675 |
-
'italic' => 'Italic',
|
2676 |
-
'oblique' => 'Oblique',
|
2677 |
-
'inherit' => 'Inherit'
|
2678 |
-
), $field_id );
|
2679 |
-
|
2680 |
-
}
|
2681 |
-
|
2682 |
-
}
|
2683 |
-
|
2684 |
-
/**
|
2685 |
-
* Recognized font variants
|
2686 |
-
*
|
2687 |
-
* Returns an array of all recognized font variants.
|
2688 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2689 |
-
*
|
2690 |
-
* @uses apply_filters()
|
2691 |
-
*
|
2692 |
-
* @return array
|
2693 |
-
*
|
2694 |
-
* @access public
|
2695 |
-
* @since 1.1.8
|
2696 |
-
* @updated 2.0
|
2697 |
-
*/
|
2698 |
-
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
|
2699 |
-
|
2700 |
-
function ot_recognized_font_variants( $field_id = '' ) {
|
2701 |
-
|
2702 |
-
return apply_filters( 'ot_recognized_font_variants', array(
|
2703 |
-
'normal' => 'Normal',
|
2704 |
-
'small-caps' => 'Small Caps',
|
2705 |
-
'inherit' => 'Inherit'
|
2706 |
-
), $field_id );
|
2707 |
-
|
2708 |
-
}
|
2709 |
-
|
2710 |
-
}
|
2711 |
-
|
2712 |
-
/**
|
2713 |
-
* Recognized font weights
|
2714 |
-
*
|
2715 |
-
* Returns an array of all recognized font weights.
|
2716 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2717 |
-
*
|
2718 |
-
* @uses apply_filters()
|
2719 |
-
*
|
2720 |
-
* @return array
|
2721 |
-
*
|
2722 |
-
* @access public
|
2723 |
-
* @since 1.1.8
|
2724 |
-
* @updated 2.0
|
2725 |
-
*/
|
2726 |
-
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
2727 |
-
|
2728 |
-
function ot_recognized_font_weights( $field_id = '' ) {
|
2729 |
-
|
2730 |
-
return apply_filters( 'ot_recognized_font_weights', array(
|
2731 |
-
'normal' => 'Normal',
|
2732 |
-
'bold' => 'Bold',
|
2733 |
-
'bolder' => 'Bolder',
|
2734 |
-
'lighter' => 'Lighter',
|
2735 |
-
'100' => '100',
|
2736 |
-
'200' => '200',
|
2737 |
-
'300' => '300',
|
2738 |
-
'400' => '400',
|
2739 |
-
'500' => '500',
|
2740 |
-
'600' => '600',
|
2741 |
-
'700' => '700',
|
2742 |
-
'800' => '800',
|
2743 |
-
'900' => '900',
|
2744 |
-
'inherit' => 'Inherit'
|
2745 |
-
), $field_id );
|
2746 |
-
|
2747 |
-
}
|
2748 |
-
|
2749 |
-
}
|
2750 |
-
|
2751 |
-
/**
|
2752 |
-
* Recognized letter spacing
|
2753 |
-
*
|
2754 |
-
* Returns an array of all recognized line heights.
|
2755 |
-
*
|
2756 |
-
* @uses apply_filters()
|
2757 |
-
*
|
2758 |
-
* @param string $field_id ID that's passed to the filters.
|
2759 |
-
* @return array
|
2760 |
-
*
|
2761 |
-
* @access public
|
2762 |
-
* @since 2.0.12
|
2763 |
-
*/
|
2764 |
-
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
|
2765 |
-
|
2766 |
-
function ot_recognized_letter_spacing( $field_id ) {
|
2767 |
-
|
2768 |
-
$range = ot_range(
|
2769 |
-
apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ),
|
2770 |
-
apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ),
|
2771 |
-
apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
|
2772 |
-
);
|
2773 |
-
|
2774 |
-
$unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
|
2775 |
-
|
2776 |
-
foreach( $range as $k => $v ) {
|
2777 |
-
$range[$k] = $v . $unit;
|
2778 |
-
}
|
2779 |
-
|
2780 |
-
return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
|
2781 |
-
}
|
2782 |
-
|
2783 |
-
}
|
2784 |
-
|
2785 |
-
/**
|
2786 |
-
* Recognized line heights
|
2787 |
-
*
|
2788 |
-
* Returns an array of all recognized line heights.
|
2789 |
-
*
|
2790 |
-
* @uses apply_filters()
|
2791 |
-
*
|
2792 |
-
* @param string $field_id ID that's passed to the filters.
|
2793 |
-
* @return array
|
2794 |
-
*
|
2795 |
-
* @access public
|
2796 |
-
* @since 2.0.12
|
2797 |
-
*/
|
2798 |
-
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
|
2799 |
-
|
2800 |
-
function ot_recognized_line_heights( $field_id ) {
|
2801 |
-
|
2802 |
-
$range = ot_range(
|
2803 |
-
apply_filters( 'ot_line_height_low_range', 0, $field_id ),
|
2804 |
-
apply_filters( 'ot_line_height_high_range', 150, $field_id ),
|
2805 |
-
apply_filters( 'ot_line_height_range_interval', 1, $field_id )
|
2806 |
-
);
|
2807 |
-
|
2808 |
-
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
|
2809 |
-
|
2810 |
-
foreach( $range as $k => $v ) {
|
2811 |
-
$range[$k] = $v . $unit;
|
2812 |
-
}
|
2813 |
-
|
2814 |
-
return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
|
2815 |
-
}
|
2816 |
-
|
2817 |
-
}
|
2818 |
-
|
2819 |
-
/**
|
2820 |
-
* Recognized text decorations
|
2821 |
-
*
|
2822 |
-
* Returns an array of all recognized text decorations.
|
2823 |
-
* Keys are intended to be stored in the database
|
2824 |
-
* while values are ready for display in html.
|
2825 |
-
*
|
2826 |
-
* @uses apply_filters()
|
2827 |
-
*
|
2828 |
-
* @return array
|
2829 |
-
*
|
2830 |
-
* @access public
|
2831 |
-
* @since 2.0.10
|
2832 |
-
*/
|
2833 |
-
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
2834 |
-
|
2835 |
-
function ot_recognized_text_decorations( $field_id = '' ) {
|
2836 |
-
|
2837 |
-
return apply_filters( 'ot_recognized_text_decorations', array(
|
2838 |
-
'blink' => 'Blink',
|
2839 |
-
'inherit' => 'Inherit',
|
2840 |
-
'line-through' => 'Line Through',
|
2841 |
-
'none' => 'None',
|
2842 |
-
'overline' => 'Overline',
|
2843 |
-
'underline' => 'Underline'
|
2844 |
-
), $field_id );
|
2845 |
-
|
2846 |
-
}
|
2847 |
-
|
2848 |
-
}
|
2849 |
-
|
2850 |
-
/**
|
2851 |
-
* Recognized text transformations
|
2852 |
-
*
|
2853 |
-
* Returns an array of all recognized text transformations.
|
2854 |
-
* Keys are intended to be stored in the database
|
2855 |
-
* while values are ready for display in html.
|
2856 |
-
*
|
2857 |
-
* @uses apply_filters()
|
2858 |
-
*
|
2859 |
-
* @return array
|
2860 |
-
*
|
2861 |
-
* @access public
|
2862 |
-
* @since 2.0.10
|
2863 |
-
*/
|
2864 |
-
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
2865 |
-
|
2866 |
-
function ot_recognized_text_transformations( $field_id = '' ) {
|
2867 |
-
|
2868 |
-
return apply_filters( 'ot_recognized_text_transformations', array(
|
2869 |
-
'capitalize' => 'Capitalize',
|
2870 |
-
'inherit' => 'Inherit',
|
2871 |
-
'lowercase' => 'Lowercase',
|
2872 |
-
'none' => 'None',
|
2873 |
-
'uppercase' => 'Uppercase'
|
2874 |
-
), $field_id );
|
2875 |
-
|
2876 |
-
}
|
2877 |
-
|
2878 |
-
}
|
2879 |
-
|
2880 |
-
/**
|
2881 |
-
* Recognized background repeat
|
2882 |
-
*
|
2883 |
-
* Returns an array of all recognized background repeat values.
|
2884 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2885 |
-
*
|
2886 |
-
* @uses apply_filters()
|
2887 |
-
*
|
2888 |
-
* @return array
|
2889 |
-
*
|
2890 |
-
* @access public
|
2891 |
-
* @since 1.1.8
|
2892 |
-
* @updated 2.0
|
2893 |
-
*/
|
2894 |
-
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
2895 |
-
|
2896 |
-
function ot_recognized_background_repeat( $field_id = '' ) {
|
2897 |
-
|
2898 |
-
return apply_filters( 'ot_recognized_background_repeat', array(
|
2899 |
-
'no-repeat' => 'No Repeat',
|
2900 |
-
'repeat' => 'Repeat All',
|
2901 |
-
'repeat-x' => 'Repeat Horizontally',
|
2902 |
-
'repeat-y' => 'Repeat Vertically',
|
2903 |
-
'inherit' => 'Inherit'
|
2904 |
-
), $field_id );
|
2905 |
-
|
2906 |
-
}
|
2907 |
-
|
2908 |
-
}
|
2909 |
-
|
2910 |
-
/**
|
2911 |
-
* Recognized background attachment
|
2912 |
-
*
|
2913 |
-
* Returns an array of all recognized background attachment values.
|
2914 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2915 |
-
*
|
2916 |
-
* @uses apply_filters()
|
2917 |
-
*
|
2918 |
-
* @return array
|
2919 |
-
*
|
2920 |
-
* @access public
|
2921 |
-
* @since 1.1.8
|
2922 |
-
* @updated 2.0
|
2923 |
-
*/
|
2924 |
-
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
|
2925 |
-
|
2926 |
-
function ot_recognized_background_attachment( $field_id = '' ) {
|
2927 |
-
|
2928 |
-
return apply_filters( 'ot_recognized_background_attachment', array(
|
2929 |
-
"fixed" => "Fixed",
|
2930 |
-
"scroll" => "Scroll",
|
2931 |
-
"inherit" => "Inherit"
|
2932 |
-
), $field_id );
|
2933 |
-
|
2934 |
-
}
|
2935 |
-
|
2936 |
-
}
|
2937 |
-
|
2938 |
-
/**
|
2939 |
-
* Recognized background position
|
2940 |
-
*
|
2941 |
-
* Returns an array of all recognized background position values.
|
2942 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2943 |
-
*
|
2944 |
-
* @uses apply_filters()
|
2945 |
-
*
|
2946 |
-
* @return array
|
2947 |
-
*
|
2948 |
-
* @access public
|
2949 |
-
* @since 1.1.8
|
2950 |
-
* @updated 2.0
|
2951 |
-
*/
|
2952 |
-
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
|
2953 |
-
|
2954 |
-
function ot_recognized_background_position( $field_id = '' ) {
|
2955 |
-
|
2956 |
-
return apply_filters( 'ot_recognized_background_position', array(
|
2957 |
-
"left top" => "Left Top",
|
2958 |
-
"left center" => "Left Center",
|
2959 |
-
"left bottom" => "Left Bottom",
|
2960 |
-
"center top" => "Center Top",
|
2961 |
-
"center center" => "Center Center",
|
2962 |
-
"center bottom" => "Center Bottom",
|
2963 |
-
"right top" => "Right Top",
|
2964 |
-
"right center" => "Right Center",
|
2965 |
-
"right bottom" => "Right Bottom"
|
2966 |
-
), $field_id );
|
2967 |
-
|
2968 |
-
}
|
2969 |
-
|
2970 |
-
}
|
2971 |
-
|
2972 |
-
/**
|
2973 |
-
* Border Styles
|
2974 |
-
*
|
2975 |
-
* Returns an array of all available style types.
|
2976 |
-
*
|
2977 |
-
* @uses apply_filters()
|
2978 |
-
*
|
2979 |
-
* @return array
|
2980 |
-
*
|
2981 |
-
* @access public
|
2982 |
-
* @since 2.5.0
|
2983 |
-
*/
|
2984 |
-
if ( ! function_exists( 'ot_recognized_border_style_types' ) ) {
|
2985 |
-
|
2986 |
-
function ot_recognized_border_style_types( $field_id = '' ) {
|
2987 |
-
|
2988 |
-
return apply_filters( 'ot_recognized_border_style_types', array(
|
2989 |
-
'hidden' => 'Hidden',
|
2990 |
-
'dashed' => 'Dashed',
|
2991 |
-
'solid' => 'Solid',
|
2992 |
-
'double' => 'Double',
|
2993 |
-
'groove' => 'Groove',
|
2994 |
-
'ridge' => 'Ridge',
|
2995 |
-
'inset' => 'Inset',
|
2996 |
-
'outset' => 'Outset',
|
2997 |
-
), $field_id );
|
2998 |
-
|
2999 |
-
}
|
3000 |
-
|
3001 |
-
}
|
3002 |
-
|
3003 |
-
/**
|
3004 |
-
* Border Units
|
3005 |
-
*
|
3006 |
-
* Returns an array of all available unit types.
|
3007 |
-
*
|
3008 |
-
* @uses apply_filters()
|
3009 |
-
*
|
3010 |
-
* @return array
|
3011 |
-
*
|
3012 |
-
* @access public
|
3013 |
-
* @since 2.5.0
|
3014 |
-
*/
|
3015 |
-
if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) {
|
3016 |
-
|
3017 |
-
function ot_recognized_border_unit_types( $field_id = '' ) {
|
3018 |
-
|
3019 |
-
return apply_filters( 'ot_recognized_border_unit_types', array(
|
3020 |
-
'px' => 'px',
|
3021 |
-
'%' => '%',
|
3022 |
-
'em' => 'em',
|
3023 |
-
'pt' => 'pt'
|
3024 |
-
), $field_id );
|
3025 |
-
|
3026 |
-
}
|
3027 |
-
|
3028 |
-
}
|
3029 |
-
|
3030 |
-
/**
|
3031 |
-
* Dimension Units
|
3032 |
-
*
|
3033 |
-
* Returns an array of all available unit types.
|
3034 |
-
*
|
3035 |
-
* @uses apply_filters()
|
3036 |
-
*
|
3037 |
-
* @return array
|
3038 |
-
*
|
3039 |
-
* @access public
|
3040 |
-
* @since 2.5.0
|
3041 |
-
*/
|
3042 |
-
if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) {
|
3043 |
-
|
3044 |
-
function ot_recognized_dimension_unit_types( $field_id = '' ) {
|
3045 |
-
|
3046 |
-
return apply_filters( 'ot_recognized_dimension_unit_types', array(
|
3047 |
-
'px' => 'px',
|
3048 |
-
'%' => '%',
|
3049 |
-
'em' => 'em',
|
3050 |
-
'pt' => 'pt'
|
3051 |
-
), $field_id );
|
3052 |
-
|
3053 |
-
}
|
3054 |
-
|
3055 |
-
}
|
3056 |
-
|
3057 |
-
/**
|
3058 |
-
* Spacing Units
|
3059 |
-
*
|
3060 |
-
* Returns an array of all available unit types.
|
3061 |
-
*
|
3062 |
-
* @uses apply_filters()
|
3063 |
-
*
|
3064 |
-
* @return array
|
3065 |
-
*
|
3066 |
-
* @access public
|
3067 |
-
* @since 2.5.0
|
3068 |
-
*/
|
3069 |
-
if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) {
|
3070 |
-
|
3071 |
-
function ot_recognized_spacing_unit_types( $field_id = '' ) {
|
3072 |
-
|
3073 |
-
return apply_filters( 'ot_recognized_spacing_unit_types', array(
|
3074 |
-
'px' => 'px',
|
3075 |
-
'%' => '%',
|
3076 |
-
'em' => 'em',
|
3077 |
-
'pt' => 'pt'
|
3078 |
-
), $field_id );
|
3079 |
-
|
3080 |
-
}
|
3081 |
-
|
3082 |
-
}
|
3083 |
-
|
3084 |
-
/**
|
3085 |
-
* Recognized Google font families
|
3086 |
-
*
|
3087 |
-
* @uses apply_filters()
|
3088 |
-
*
|
3089 |
-
* @return array
|
3090 |
-
*
|
3091 |
-
* @access public
|
3092 |
-
* @since 2.5.0
|
3093 |
-
*/
|
3094 |
-
if ( ! function_exists( 'ot_recognized_google_font_families' ) ) {
|
3095 |
-
|
3096 |
-
function ot_recognized_google_font_families( $field_id ) {
|
3097 |
-
|
3098 |
-
$families = array();
|
3099 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3100 |
-
|
3101 |
-
// Forces an array rebuild when we sitch themes
|
3102 |
-
if ( empty( $ot_google_fonts ) ) {
|
3103 |
-
$ot_google_fonts = ot_fetch_google_fonts( true, true );
|
3104 |
-
}
|
3105 |
-
|
3106 |
-
foreach( (array) $ot_google_fonts as $key => $item ) {
|
3107 |
-
|
3108 |
-
if ( isset( $item['family'] ) ) {
|
3109 |
-
|
3110 |
-
$families[ $key ] = $item['family'];
|
3111 |
-
|
3112 |
-
}
|
3113 |
-
|
3114 |
-
}
|
3115 |
-
|
3116 |
-
return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
|
3117 |
-
|
3118 |
-
}
|
3119 |
-
|
3120 |
-
}
|
3121 |
-
|
3122 |
-
/**
|
3123 |
-
* Recognized Google font variants
|
3124 |
-
*
|
3125 |
-
* @uses apply_filters()
|
3126 |
-
*
|
3127 |
-
* @return array
|
3128 |
-
*
|
3129 |
-
* @access public
|
3130 |
-
* @since 2.5.0
|
3131 |
-
*/
|
3132 |
-
if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) {
|
3133 |
-
|
3134 |
-
function ot_recognized_google_font_variants( $field_id, $family ) {
|
3135 |
-
|
3136 |
-
$variants = array();
|
3137 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3138 |
-
|
3139 |
-
if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
|
3140 |
-
|
3141 |
-
$variants = $ot_google_fonts[ $family ]['variants'];
|
3142 |
-
|
3143 |
-
}
|
3144 |
-
|
3145 |
-
return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family );
|
3146 |
-
|
3147 |
-
}
|
3148 |
-
|
3149 |
-
}
|
3150 |
-
|
3151 |
-
/**
|
3152 |
-
* Recognized Google font subsets
|
3153 |
-
*
|
3154 |
-
* @uses apply_filters()
|
3155 |
-
*
|
3156 |
-
* @return array
|
3157 |
-
*
|
3158 |
-
* @access public
|
3159 |
-
* @since 2.5.0
|
3160 |
-
*/
|
3161 |
-
if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
|
3162 |
-
|
3163 |
-
function ot_recognized_google_font_subsets( $field_id, $family ) {
|
3164 |
-
|
3165 |
-
$subsets = array();
|
3166 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3167 |
-
|
3168 |
-
if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
|
3169 |
-
|
3170 |
-
$subsets = $ot_google_fonts[ $family ]['subsets'];
|
3171 |
-
|
3172 |
-
}
|
3173 |
-
|
3174 |
-
return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family );
|
3175 |
-
|
3176 |
-
}
|
3177 |
-
|
3178 |
-
}
|
3179 |
-
|
3180 |
-
/**
|
3181 |
-
* Measurement Units
|
3182 |
-
*
|
3183 |
-
* Returns an array of all available unit types.
|
3184 |
-
* Renamed in version 2.0 to avoid name collisions.
|
3185 |
-
*
|
3186 |
-
* @uses apply_filters()
|
3187 |
-
*
|
3188 |
-
* @return array
|
3189 |
-
*
|
3190 |
-
* @access public
|
3191 |
-
* @since 1.1.8
|
3192 |
-
* @updated 2.0
|
3193 |
-
*/
|
3194 |
-
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
|
3195 |
-
|
3196 |
-
function ot_measurement_unit_types( $field_id = '' ) {
|
3197 |
-
|
3198 |
-
return apply_filters( 'ot_measurement_unit_types', array(
|
3199 |
-
'px' => 'px',
|
3200 |
-
'%' => '%',
|
3201 |
-
'em' => 'em',
|
3202 |
-
'pt' => 'pt'
|
3203 |
-
), $field_id );
|
3204 |
-
|
3205 |
-
}
|
3206 |
-
|
3207 |
-
}
|
3208 |
-
|
3209 |
-
/**
|
3210 |
-
* Radio Images default array.
|
3211 |
-
*
|
3212 |
-
* Returns an array of all available radio images.
|
3213 |
-
* You can filter this function to change the images
|
3214 |
-
* on a per option basis.
|
3215 |
-
*
|
3216 |
-
* @uses apply_filters()
|
3217 |
-
*
|
3218 |
-
* @return array
|
3219 |
-
*
|
3220 |
-
* @access public
|
3221 |
-
* @since 2.0
|
3222 |
-
*/
|
3223 |
-
if ( ! function_exists( 'ot_radio_images' ) ) {
|
3224 |
-
|
3225 |
-
function ot_radio_images( $field_id = '' ) {
|
3226 |
-
|
3227 |
-
return apply_filters( 'ot_radio_images', array(
|
3228 |
-
array(
|
3229 |
-
'value' => 'left-sidebar',
|
3230 |
-
'label' => __( 'Left Sidebar', 'option-tree' ),
|
3231 |
-
'src' => OT_URL . 'assets/images/layout/left-sidebar.png'
|
3232 |
-
),
|
3233 |
-
array(
|
3234 |
-
'value' => 'right-sidebar',
|
3235 |
-
'label' => __( 'Right Sidebar', 'option-tree' ),
|
3236 |
-
'src' => OT_URL . 'assets/images/layout/right-sidebar.png'
|
3237 |
-
),
|
3238 |
-
array(
|
3239 |
-
'value' => 'full-width',
|
3240 |
-
'label' => __( 'Full Width (no sidebar)', 'option-tree' ),
|
3241 |
-
'src' => OT_URL . 'assets/images/layout/full-width.png'
|
3242 |
-
),
|
3243 |
-
array(
|
3244 |
-
'value' => 'dual-sidebar',
|
3245 |
-
'label' => __( 'Dual Sidebar', 'option-tree' ),
|
3246 |
-
'src' => OT_URL . 'assets/images/layout/dual-sidebar.png'
|
3247 |
-
),
|
3248 |
-
array(
|
3249 |
-
'value' => 'left-dual-sidebar',
|
3250 |
-
'label' => __( 'Left Dual Sidebar', 'option-tree' ),
|
3251 |
-
'src' => OT_URL . 'assets/images/layout/left-dual-sidebar.png'
|
3252 |
-
),
|
3253 |
-
array(
|
3254 |
-
'value' => 'right-dual-sidebar',
|
3255 |
-
'label' => __( 'Right Dual Sidebar', 'option-tree' ),
|
3256 |
-
'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png'
|
3257 |
-
)
|
3258 |
-
), $field_id );
|
3259 |
-
|
3260 |
-
}
|
3261 |
-
|
3262 |
-
}
|
3263 |
-
|
3264 |
-
/**
|
3265 |
-
* Default List Item Settings array.
|
3266 |
-
*
|
3267 |
-
* Returns an array of the default list item settings.
|
3268 |
-
* You can filter this function to change the settings
|
3269 |
-
* on a per option basis.
|
3270 |
-
*
|
3271 |
-
* @uses apply_filters()
|
3272 |
-
*
|
3273 |
-
* @return array
|
3274 |
-
*
|
3275 |
-
* @access public
|
3276 |
-
* @since 2.0
|
3277 |
-
*/
|
3278 |
-
if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
3279 |
-
|
3280 |
-
function ot_list_item_settings( $id ) {
|
3281 |
-
|
3282 |
-
$settings = apply_filters( 'ot_list_item_settings', array(
|
3283 |
-
array(
|
3284 |
-
'id' => 'image',
|
3285 |
-
'label' => __( 'Image', 'option-tree' ),
|
3286 |
-
'desc' => '',
|
3287 |
-
'std' => '',
|
3288 |
-
'type' => 'upload',
|
3289 |
-
'rows' => '',
|
3290 |
-
'class' => '',
|
3291 |
-
'post_type' => '',
|
3292 |
-
'choices' => array()
|
3293 |
-
),
|
3294 |
-
array(
|
3295 |
-
'id' => 'link',
|
3296 |
-
'label' => __( 'Link', 'option-tree' ),
|
3297 |
-
'desc' => '',
|
3298 |
-
'std' => '',
|
3299 |
-
'type' => 'text',
|
3300 |
-
'rows' => '',
|
3301 |
-
'class' => '',
|
3302 |
-
'post_type' => '',
|
3303 |
-
'choices' => array()
|
3304 |
-
),
|
3305 |
-
array(
|
3306 |
-
'id' => 'description',
|
3307 |
-
'label' => __( 'Description', 'option-tree' ),
|
3308 |
-
'desc' => '',
|
3309 |
-
'std' => '',
|
3310 |
-
'type' => 'textarea-simple',
|
3311 |
-
'rows' => 10,
|
3312 |
-
'class' => '',
|
3313 |
-
'post_type' => '',
|
3314 |
-
'choices' => array()
|
3315 |
-
)
|
3316 |
-
), $id );
|
3317 |
-
|
3318 |
-
return $settings;
|
3319 |
-
|
3320 |
-
}
|
3321 |
-
|
3322 |
-
}
|
3323 |
-
|
3324 |
-
/**
|
3325 |
-
* Default Slider Settings array.
|
3326 |
-
*
|
3327 |
-
* Returns an array of the default slider settings.
|
3328 |
-
* You can filter this function to change the settings
|
3329 |
-
* on a per option basis.
|
3330 |
-
*
|
3331 |
-
* @uses apply_filters()
|
3332 |
-
*
|
3333 |
-
* @return array
|
3334 |
-
*
|
3335 |
-
* @access public
|
3336 |
-
* @since 2.0
|
3337 |
-
*/
|
3338 |
-
if ( ! function_exists( 'ot_slider_settings' ) ) {
|
3339 |
-
|
3340 |
-
function ot_slider_settings( $id ) {
|
3341 |
-
|
3342 |
-
$settings = apply_filters( 'image_slider_fields', array(
|
3343 |
-
array(
|
3344 |
-
'name' => 'image',
|
3345 |
-
'type' => 'image',
|
3346 |
-
'label' => __( 'Image', 'option-tree' ),
|
3347 |
-
'class' => ''
|
3348 |
-
),
|
3349 |
-
array(
|
3350 |
-
'name' => 'link',
|
3351 |
-
'type' => 'text',
|
3352 |
-
'label' => __( 'Link', 'option-tree' ),
|
3353 |
-
'class' => ''
|
3354 |
-
),
|
3355 |
-
array(
|
3356 |
-
'name' => 'description',
|
3357 |
-
'type' => 'textarea',
|
3358 |
-
'label' => __( 'Description', 'option-tree' ),
|
3359 |
-
'class' => ''
|
3360 |
-
)
|
3361 |
-
), $id );
|
3362 |
-
|
3363 |
-
/* fix the array keys, values, and just get it 2.0 ready */
|
3364 |
-
foreach( $settings as $_k => $setting ) {
|
3365 |
-
|
3366 |
-
foreach( $setting as $s_key => $s_value ) {
|
3367 |
-
|
3368 |
-
if ( 'name' == $s_key ) {
|
3369 |
-
|
3370 |
-
$settings[$_k]['id'] = $s_value;
|
3371 |
-
unset($settings[$_k]['name']);
|
3372 |
-
|
3373 |
-
} else if ( 'type' == $s_key ) {
|
3374 |
-
|
3375 |
-
if ( 'input' == $s_value ) {
|
3376 |
-
|
3377 |
-
$settings[$_k]['type'] = 'text';
|
3378 |
-
|
3379 |
-
} else if ( 'textarea' == $s_value ) {
|
3380 |
-
|
3381 |
-
$settings[$_k]['type'] = 'textarea-simple';
|
3382 |
-
|
3383 |
-
} else if ( 'image' == $s_value ) {
|
3384 |
-
|
3385 |
-
$settings[$_k]['type'] = 'upload';
|
3386 |
-
|
3387 |
-
}
|
3388 |
-
|
3389 |
-
}
|
3390 |
-
|
3391 |
-
}
|
3392 |
-
|
3393 |
-
}
|
3394 |
-
|
3395 |
-
return $settings;
|
3396 |
-
|
3397 |
-
}
|
3398 |
-
|
3399 |
-
}
|
3400 |
-
|
3401 |
-
/**
|
3402 |
-
* Default Social Links Settings array.
|
3403 |
-
*
|
3404 |
-
* Returns an array of the default social links settings.
|
3405 |
-
* You can filter this function to change the settings
|
3406 |
-
* on a per option basis.
|
3407 |
-
*
|
3408 |
-
* @uses apply_filters()
|
3409 |
-
*
|
3410 |
-
* @return array
|
3411 |
-
*
|
3412 |
-
* @access public
|
3413 |
-
* @since 2.4.0
|
3414 |
-
*/
|
3415 |
-
if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
3416 |
-
|
3417 |
-
function ot_social_links_settings( $id ) {
|
3418 |
-
|
3419 |
-
$settings = apply_filters( 'ot_social_links_settings', array(
|
3420 |
-
array(
|
3421 |
-
'id' => 'name',
|
3422 |
-
'label' => __( 'Name', 'option-tree' ),
|
3423 |
-
'desc' => __( 'Enter the name of the social website.', 'option-tree' ),
|
3424 |
-
'std' => '',
|
3425 |
-
'type' => 'text',
|
3426 |
-
'class' => 'option-tree-setting-title'
|
3427 |
-
),
|
3428 |
-
array(
|
3429 |
-
'id' => 'title',
|
3430 |
-
'label' => 'Title',
|
3431 |
-
'desc' => __( 'Enter the text shown in the title attribute of the link.', 'option-tree' ),
|
3432 |
-
'type' => 'text'
|
3433 |
-
),
|
3434 |
-
array(
|
3435 |
-
'id' => 'href',
|
3436 |
-
'label' => 'Link',
|
3437 |
-
'desc' => sprintf( __( 'Enter a link to the profile or page on the social website. Remember to add the %s part to the front of the link.', 'option-tree' ), '<code>http://</code>' ),
|
3438 |
-
'type' => 'text',
|
3439 |
-
)
|
3440 |
-
), $id );
|
3441 |
-
|
3442 |
-
return $settings;
|
3443 |
-
|
3444 |
-
}
|
3445 |
-
|
3446 |
-
}
|
3447 |
-
|
3448 |
-
/**
|
3449 |
-
* Inserts CSS with field_id markers.
|
3450 |
-
*
|
3451 |
-
* Inserts CSS into a dynamic.css file, placing it between
|
3452 |
-
* BEGIN and END field_id markers. Replaces existing marked info,
|
3453 |
-
* but still retains surrounding data.
|
3454 |
-
*
|
3455 |
-
* @param string $field_id The CSS option field ID.
|
3456 |
-
* @param array $options The current option_tree array.
|
3457 |
-
* @return bool True on write success, false on failure.
|
3458 |
-
*
|
3459 |
-
* @access public
|
3460 |
-
* @since 1.1.8
|
3461 |
-
* @updated 2.5.3
|
3462 |
-
*/
|
3463 |
-
if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
|
3464 |
-
|
3465 |
-
function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = false ) {
|
3466 |
-
|
3467 |
-
/* missing $field_id or $insertion exit early */
|
3468 |
-
if ( '' == $field_id || '' == $insertion )
|
3469 |
-
return;
|
3470 |
-
|
3471 |
-
/* path to the dynamic.css file */
|
3472 |
-
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3473 |
-
if ( is_multisite() ) {
|
3474 |
-
$multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
|
3475 |
-
if ( file_exists( $multisite_filepath ) ) {
|
3476 |
-
$filepath = $multisite_filepath;
|
3477 |
-
}
|
3478 |
-
}
|
3479 |
-
|
3480 |
-
/* allow filter on path */
|
3481 |
-
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3482 |
-
|
3483 |
-
/* grab a copy of the paths array */
|
3484 |
-
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
3485 |
-
if ( is_multisite() ) {
|
3486 |
-
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3487 |
-
}
|
3488 |
-
|
3489 |
-
/* set the path for this field */
|
3490 |
-
$ot_css_file_paths[$field_id] = $filepath;
|
3491 |
-
|
3492 |
-
/* update the paths */
|
3493 |
-
if ( is_multisite() ) {
|
3494 |
-
update_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3495 |
-
} else {
|
3496 |
-
update_option( 'ot_css_file_paths', $ot_css_file_paths );
|
3497 |
-
}
|
3498 |
-
|
3499 |
-
/* insert CSS into file */
|
3500 |
-
if ( file_exists( $filepath ) ) {
|
3501 |
-
|
3502 |
-
$insertion = ot_normalize_css( $insertion );
|
3503 |
-
$regex = "/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/";
|
3504 |
-
$marker = $field_id;
|
3505 |
-
|
3506 |
-
/* Match custom CSS */
|
3507 |
-
preg_match_all( $regex, $insertion, $matches );
|
3508 |
-
|
3509 |
-
/* Loop through CSS */
|
3510 |
-
foreach( $matches[0] as $option ) {
|
3511 |
-
|
3512 |
-
$value = '';
|
3513 |
-
$option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) );
|
3514 |
-
$option_id = isset( $option_array[0] ) ? $option_array[0] : '';
|
3515 |
-
$option_key = isset( $option_array[1] ) ? $option_array[1] : '';
|
3516 |
-
$option_type = ot_get_option_type_by_id( $option_id );
|
3517 |
-
$fallback = '';
|
3518 |
-
|
3519 |
-
// Get the meta array value
|
3520 |
-
if ( $meta ) {
|
3521 |
-
global $post;
|
3522 |
-
|
3523 |
-
$value = get_post_meta( $post->ID, $option_id, true );
|
3524 |
-
|
3525 |
-
// Get the options array value
|
3526 |
-
} else {
|
3527 |
-
|
3528 |
-
$options = get_option( ot_options_id() );
|
3529 |
-
|
3530 |
-
if ( isset( $options[$option_id] ) ) {
|
3531 |
-
|
3532 |
-
$value = $options[$option_id];
|
3533 |
-
|
3534 |
-
}
|
3535 |
-
|
3536 |
-
}
|
3537 |
-
|
3538 |
-
// This in an array of values
|
3539 |
-
if ( is_array( $value ) ) {
|
3540 |
-
|
3541 |
-
if ( empty( $option_key ) ) {
|
3542 |
-
|
3543 |
-
// Measurement
|
3544 |
-
if ( $option_type == 'measurement' ) {
|
3545 |
-
$unit = ! empty( $value[1] ) ? $value[1] : 'px';
|
3546 |
-
|
3547 |
-
// Set $value with measurement properties
|
3548 |
-
if ( isset( $value[0] ) && strlen( $value[0] ) > 0 )
|
3549 |
-
$value = $value[0].$unit;
|
3550 |
-
|
3551 |
-
// Border
|
3552 |
-
} else if ( $option_type == 'border' ) {
|
3553 |
-
$border = array();
|
3554 |
-
|
3555 |
-
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3556 |
-
|
3557 |
-
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
|
3558 |
-
$border[] = $value['width'].$unit;
|
3559 |
-
|
3560 |
-
if ( ! empty( $value['style'] ) )
|
3561 |
-
$border[] = $value['style'];
|
3562 |
-
|
3563 |
-
if ( ! empty( $value['color'] ) )
|
3564 |
-
$border[] = $value['color'];
|
3565 |
-
|
3566 |
-
/* set $value with border properties or empty string */
|
3567 |
-
$value = ! empty( $border ) ? implode( ' ', $border ) : '';
|
3568 |
-
|
3569 |
-
// Box Shadow
|
3570 |
-
} else if ( $option_type == 'box-shadow' ) {
|
3571 |
-
|
3572 |
-
/* set $value with box-shadow properties or empty string */
|
3573 |
-
$value = ! empty( $value ) ? implode( ' ', $value ) : '';
|
3574 |
-
|
3575 |
-
// Dimension
|
3576 |
-
} else if ( $option_type == 'dimension' ) {
|
3577 |
-
$dimension = array();
|
3578 |
-
|
3579 |
-
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3580 |
-
|
3581 |
-
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
|
3582 |
-
$dimension[] = $value['width'].$unit;
|
3583 |
-
|
3584 |
-
if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 )
|
3585 |
-
$dimension[] = $value['height'].$unit;
|
3586 |
-
|
3587 |
-
// Set $value with dimension properties or empty string
|
3588 |
-
$value = ! empty( $dimension ) ? implode( ' ', $dimension ) : '';
|
3589 |
-
|
3590 |
-
// Spacing
|
3591 |
-
} else if ( $option_type == 'spacing' ) {
|
3592 |
-
$spacing = array();
|
3593 |
-
|
3594 |
-
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3595 |
-
|
3596 |
-
if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 )
|
3597 |
-
$spacing[] = $value['top'].$unit;
|
3598 |
-
|
3599 |
-
if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 )
|
3600 |
-
$spacing[] = $value['right'].$unit;
|
3601 |
-
|
3602 |
-
if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 )
|
3603 |
-
$spacing[] = $value['bottom'].$unit;
|
3604 |
-
|
3605 |
-
if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 )
|
3606 |
-
$spacing[] = $value['left'].$unit;
|
3607 |
-
|
3608 |
-
// Set $value with spacing properties or empty string
|
3609 |
-
$value = ! empty( $spacing ) ? implode( ' ', $spacing ) : '';
|
3610 |
-
|
3611 |
-
// Typography
|
3612 |
-
} else if ( $option_type == 'typography' ) {
|
3613 |
-
$font = array();
|
3614 |
-
|
3615 |
-
if ( ! empty( $value['font-color'] ) )
|
3616 |
-
$font[] = "color: " . $value['font-color'] . ";";
|
3617 |
-
|
3618 |
-
if ( ! empty( $value['font-family'] ) ) {
|
3619 |
-
foreach ( ot_recognized_font_families( $marker ) as $key => $v ) {
|
3620 |
-
if ( $key == $value['font-family'] ) {
|
3621 |
-
$font[] = "font-family: " . $v . ";";
|
3622 |
-
}
|
3623 |
-
}
|
3624 |
-
}
|
3625 |
-
|
3626 |
-
if ( ! empty( $value['font-size'] ) )
|
3627 |
-
$font[] = "font-size: " . $value['font-size'] . ";";
|
3628 |
-
|
3629 |
-
if ( ! empty( $value['font-style'] ) )
|
3630 |
-
$font[] = "font-style: " . $value['font-style'] . ";";
|
3631 |
-
|
3632 |
-
if ( ! empty( $value['font-variant'] ) )
|
3633 |
-
$font[] = "font-variant: " . $value['font-variant'] . ";";
|
3634 |
-
|
3635 |
-
if ( ! empty( $value['font-weight'] ) )
|
3636 |
-
$font[] = "font-weight: " . $value['font-weight'] . ";";
|
3637 |
-
|
3638 |
-
if ( ! empty( $value['letter-spacing'] ) )
|
3639 |
-
$font[] = "letter-spacing: " . $value['letter-spacing'] . ";";
|
3640 |
-
|
3641 |
-
if ( ! empty( $value['line-height'] ) )
|
3642 |
-
$font[] = "line-height: " . $value['line-height'] . ";";
|
3643 |
-
|
3644 |
-
if ( ! empty( $value['text-decoration'] ) )
|
3645 |
-
$font[] = "text-decoration: " . $value['text-decoration'] . ";";
|
3646 |
-
|
3647 |
-
if ( ! empty( $value['text-transform'] ) )
|
3648 |
-
$font[] = "text-transform: " . $value['text-transform'] . ";";
|
3649 |
-
|
3650 |
-
// Set $value with font properties or empty string
|
3651 |
-
$value = ! empty( $font ) ? implode( "\n", $font ) : '';
|
3652 |
-
|
3653 |
-
// Background
|
3654 |
-
} else if ( $option_type == 'background' ) {
|
3655 |
-
$bg = array();
|
3656 |
-
|
3657 |
-
if ( ! empty( $value['background-color'] ) )
|
3658 |
-
$bg[] = $value['background-color'];
|
3659 |
-
|
3660 |
-
if ( ! empty( $value['background-image'] ) ) {
|
3661 |
-
|
3662 |
-
// If an attachment ID is stored here fetch its URL and replace the value
|
3663 |
-
if ( wp_attachment_is_image( $value['background-image'] ) ) {
|
3664 |
-
|
3665 |
-
$attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' );
|
3666 |
-
|
3667 |
-
// Check for attachment data
|
3668 |
-
if ( $attachment_data ) {
|
3669 |
-
|
3670 |
-
$value['background-image'] = $attachment_data[0];
|
3671 |
-
|
3672 |
-
}
|
3673 |
-
|
3674 |
-
}
|
3675 |
-
|
3676 |
-
$bg[] = 'url("' . $value['background-image'] . '")';
|
3677 |
-
|
3678 |
-
}
|
3679 |
-
|
3680 |
-
if ( ! empty( $value['background-repeat'] ) )
|
3681 |
-
$bg[] = $value['background-repeat'];
|
3682 |
-
|
3683 |
-
if ( ! empty( $value['background-attachment'] ) )
|
3684 |
-
$bg[] = $value['background-attachment'];
|
3685 |
-
|
3686 |
-
if ( ! empty( $value['background-position'] ) )
|
3687 |
-
$bg[] = $value['background-position'];
|
3688 |
-
|
3689 |
-
if ( ! empty( $value['background-size'] ) )
|
3690 |
-
$size = $value['background-size'];
|
3691 |
-
|
3692 |
-
// Set $value with background properties or empty string
|
3693 |
-
$value = ! empty( $bg ) ? 'background: ' . implode( " ", $bg ) . ';' : '';
|
3694 |
-
|
3695 |
-
if ( isset( $size ) ) {
|
3696 |
-
if ( ! empty( $bg ) ) {
|
3697 |
-
$value.= apply_filters( 'ot_insert_css_with_markers_bg_size_white_space', "\n\x20\x20", $option_id );
|
3698 |
-
}
|
3699 |
-
$value.= "background-size: $size;";
|
3700 |
-
}
|
3701 |
-
|
3702 |
-
}
|
3703 |
-
|
3704 |
-
} else {
|
3705 |
-
|
3706 |
-
$value = $value[$option_key];
|
3707 |
-
|
3708 |
-
}
|
3709 |
-
|
3710 |
-
}
|
3711 |
-
|
3712 |
-
// If an attachment ID is stored here fetch its URL and replace the value
|
3713 |
-
if ( $option_type == 'upload' && wp_attachment_is_image( $value ) ) {
|
3714 |
-
|
3715 |
-
$attachment_data = wp_get_attachment_image_src( $value, 'original' );
|
3716 |
-
|
3717 |
-
// Check for attachment data
|
3718 |
-
if ( $attachment_data ) {
|
3719 |
-
|
3720 |
-
$value = $attachment_data[0];
|
3721 |
-
|
3722 |
-
}
|
3723 |
-
|
3724 |
-
}
|
3725 |
-
|
3726 |
-
// Attempt to fallback when `$value` is empty
|
3727 |
-
if ( empty( $value ) ) {
|
3728 |
-
|
3729 |
-
// We're trying to access a single array key
|
3730 |
-
if ( ! empty( $option_key ) ) {
|
3731 |
-
|
3732 |
-
// Link Color `inherit`
|
3733 |
-
if ( $option_type == 'link-color' ) {
|
3734 |
-
$fallback = 'inherit';
|
3735 |
-
}
|
3736 |
-
|
3737 |
-
} else {
|
3738 |
-
|
3739 |
-
// Border
|
3740 |
-
if ( $option_type == 'border' ) {
|
3741 |
-
$fallback = 'inherit';
|
3742 |
-
}
|
3743 |
-
|
3744 |
-
// Box Shadow
|
3745 |
-
if ( $option_type == 'box-shadow' ) {
|
3746 |
-
$fallback = 'none';
|
3747 |
-
}
|
3748 |
-
|
3749 |
-
// Colorpicker
|
3750 |
-
if ( $option_type == 'colorpicker' ) {
|
3751 |
-
$fallback = 'inherit';
|
3752 |
-
}
|
3753 |
-
|
3754 |
-
// Colorpicker Opacity
|
3755 |
-
if ( $option_type == 'colorpicker-opacity' ) {
|
3756 |
-
$fallback = 'inherit';
|
3757 |
-
}
|
3758 |
-
|
3759 |
-
}
|
3760 |
-
|
3761 |
-
/**
|
3762 |
-
* Filter the `dynamic.css` fallback value.
|
3763 |
-
*
|
3764 |
-
* @since 2.5.3
|
3765 |
-
*
|
3766 |
-
* @param string $fallback The default CSS fallback value.
|
3767 |
-
* @param string $option_id The option ID.
|
3768 |
-
* @param string $option_type The option type.
|
3769 |
-
* @param string $option_key The option array key.
|
3770 |
-
*/
|
3771 |
-
$fallback = apply_filters( 'ot_insert_css_with_markers_fallback', $fallback, $option_id, $option_type, $option_key );
|
3772 |
-
|
3773 |
-
}
|
3774 |
-
|
3775 |
-
// Let's fallback!
|
3776 |
-
if ( ! empty( $fallback ) ) {
|
3777 |
-
$value = $fallback;
|
3778 |
-
}
|
3779 |
-
|
3780 |
-
// Filter the CSS
|
3781 |
-
$value = apply_filters( 'ot_insert_css_with_markers_value', $value, $option_id );
|
3782 |
-
|
3783 |
-
// Insert CSS, even if the value is empty
|
3784 |
-
$insertion = stripslashes( str_replace( $option, $value, $insertion ) );
|
3785 |
-
|
3786 |
-
}
|
3787 |
-
|
3788 |
-
// Can't write to the file so we error out
|
3789 |
-
if ( ! is_writable( $filepath ) ) {
|
3790 |
-
add_settings_error( 'option-tree', 'dynamic_css', sprintf( __( 'Unable to write to file %s.', 'option-tree' ), '<code>' . $filepath . '</code>' ), 'error' );
|
3791 |
-
return false;
|
3792 |
-
}
|
3793 |
-
|
3794 |
-
// Create array from the lines of code
|
3795 |
-
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3796 |
-
|
3797 |
-
// Can't write to the file return false
|
3798 |
-
if ( ! $f = ot_file_open( $filepath, 'w' ) ) {
|
3799 |
-
return false;
|
3800 |
-
}
|
3801 |
-
|
3802 |
-
$searching = true;
|
3803 |
-
$foundit = false;
|
3804 |
-
|
3805 |
-
// Has array of lines
|
3806 |
-
if ( ! empty( $markerdata ) ) {
|
3807 |
-
|
3808 |
-
// Foreach line of code
|
3809 |
-
foreach( $markerdata as $n => $markerline ) {
|
3810 |
-
|
3811 |
-
// Found begining of marker, set $searching to false
|
3812 |
-
if ( $markerline == "/* BEGIN {$marker} */" )
|
3813 |
-
$searching = false;
|
3814 |
-
|
3815 |
-
// Keep searching each line of CSS
|
3816 |
-
if ( $searching == true ) {
|
3817 |
-
if ( $n + 1 < count( $markerdata ) )
|
3818 |
-
ot_file_write( $f, "{$markerline}\n" );
|
3819 |
-
else
|
3820 |
-
ot_file_write( $f, "{$markerline}" );
|
3821 |
-
}
|
3822 |
-
|
3823 |
-
// Found end marker write code
|
3824 |
-
if ( $markerline == "/* END {$marker} */" ) {
|
3825 |
-
ot_file_write( $f, "/* BEGIN {$marker} */\n" );
|
3826 |
-
ot_file_write( $f, "{$insertion}\n" );
|
3827 |
-
ot_file_write( $f, "/* END {$marker} */\n" );
|
3828 |
-
$searching = true;
|
3829 |
-
$foundit = true;
|
3830 |
-
}
|
3831 |
-
|
3832 |
-
}
|
3833 |
-
|
3834 |
-
}
|
3835 |
-
|
3836 |
-
// Nothing inserted, write code. DO IT, DO IT!
|
3837 |
-
if ( ! $foundit ) {
|
3838 |
-
ot_file_write( $f, "/* BEGIN {$marker} */\n" );
|
3839 |
-
ot_file_write( $f, "{$insertion}\n" );
|
3840 |
-
ot_file_write( $f, "/* END {$marker} */\n" );
|
3841 |
-
}
|
3842 |
-
|
3843 |
-
// Close file
|
3844 |
-
ot_file_close( $f );
|
3845 |
-
return true;
|
3846 |
-
}
|
3847 |
-
|
3848 |
-
return false;
|
3849 |
-
|
3850 |
-
}
|
3851 |
-
|
3852 |
-
}
|
3853 |
-
|
3854 |
-
/**
|
3855 |
-
* Remove old CSS.
|
3856 |
-
*
|
3857 |
-
* Removes CSS when the textarea is empty, but still retains surrounding styles.
|
3858 |
-
*
|
3859 |
-
* @param string $field_id The CSS option field ID.
|
3860 |
-
* @return bool True on write success, false on failure.
|
3861 |
-
*
|
3862 |
-
* @access public
|
3863 |
-
* @since 2.0
|
3864 |
-
*/
|
3865 |
-
if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
3866 |
-
|
3867 |
-
function ot_remove_old_css( $field_id = '' ) {
|
3868 |
-
|
3869 |
-
/* missing $field_id string */
|
3870 |
-
if ( '' == $field_id )
|
3871 |
-
return false;
|
3872 |
-
|
3873 |
-
/* path to the dynamic.css file */
|
3874 |
-
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3875 |
-
|
3876 |
-
/* allow filter on path */
|
3877 |
-
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3878 |
-
|
3879 |
-
/* remove CSS from file */
|
3880 |
-
if ( is_writeable( $filepath ) ) {
|
3881 |
-
|
3882 |
-
/* get each line in the file */
|
3883 |
-
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3884 |
-
|
3885 |
-
/* can't write to the file return false */
|
3886 |
-
if ( ! $f = ot_file_open( $filepath, 'w' ) )
|
3887 |
-
return false;
|
3888 |
-
|
3889 |
-
$searching = true;
|
3890 |
-
|
3891 |
-
/* has array of lines */
|
3892 |
-
if ( ! empty( $markerdata ) ) {
|
3893 |
-
|
3894 |
-
/* foreach line of code */
|
3895 |
-
foreach ( $markerdata as $n => $markerline ) {
|
3896 |
-
|
3897 |
-
/* found begining of marker, set $searching to false */
|
3898 |
-
if ( $markerline == "/* BEGIN {$field_id} */" )
|
3899 |
-
$searching = false;
|
3900 |
-
|
3901 |
-
/* $searching is true, keep rewrite each line of CSS */
|
3902 |
-
if ( $searching == true ) {
|
3903 |
-
if ( $n + 1 < count( $markerdata ) )
|
3904 |
-
ot_file_write( $f, "{$markerline}\n" );
|
3905 |
-
else
|
3906 |
-
ot_file_write( $f, "{$markerline}" );
|
3907 |
-
}
|
3908 |
-
|
3909 |
-
/* found end marker delete old CSS */
|
3910 |
-
if ( $markerline == "/* END {$field_id} */" ) {
|
3911 |
-
ot_file_write( $f, "" );
|
3912 |
-
$searching = true;
|
3913 |
-
}
|
3914 |
-
|
3915 |
-
}
|
3916 |
-
|
3917 |
-
}
|
3918 |
-
|
3919 |
-
/* close file */
|
3920 |
-
ot_file_close( $f );
|
3921 |
-
return true;
|
3922 |
-
|
3923 |
-
}
|
3924 |
-
|
3925 |
-
return false;
|
3926 |
-
|
3927 |
-
}
|
3928 |
-
|
3929 |
-
}
|
3930 |
-
|
3931 |
-
/**
|
3932 |
-
* Normalize CSS
|
3933 |
-
*
|
3934 |
-
* Normalize & Convert all line-endings to UNIX format.
|
3935 |
-
*
|
3936 |
-
* @param string $css
|
3937 |
-
* @return string
|
3938 |
-
*
|
3939 |
-
* @access public
|
3940 |
-
* @since 1.1.8
|
3941 |
-
* @updated 2.0
|
3942 |
-
*/
|
3943 |
-
if ( ! function_exists( 'ot_normalize_css' ) ) {
|
3944 |
-
|
3945 |
-
function ot_normalize_css( $css ) {
|
3946 |
-
|
3947 |
-
/* Normalize & Convert */
|
3948 |
-
$css = str_replace( "\r\n", "\n", $css );
|
3949 |
-
$css = str_replace( "\r", "\n", $css );
|
3950 |
-
|
3951 |
-
/* Don't allow out-of-control blank lines */
|
3952 |
-
$css = preg_replace( "/\n{2,}/", "\n\n", $css );
|
3953 |
-
|
3954 |
-
return $css;
|
3955 |
-
}
|
3956 |
-
|
3957 |
-
}
|
3958 |
-
|
3959 |
-
/**
|
3960 |
-
* Helper function to loop over the option types.
|
3961 |
-
*
|
3962 |
-
* @param array $type The current option type.
|
3963 |
-
*
|
3964 |
-
* @return string
|
3965 |
-
*
|
3966 |
-
* @access public
|
3967 |
-
* @since 2.0
|
3968 |
-
*/
|
3969 |
-
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
|
3970 |
-
|
3971 |
-
function ot_loop_through_option_types( $type = '', $child = false ) {
|
3972 |
-
|
3973 |
-
$content = '';
|
3974 |
-
$types = ot_option_types_array();
|
3975 |
-
|
3976 |
-
if ( $child )
|
3977 |
-
unset($types['list-item']);
|
3978 |
-
|
3979 |
-
foreach( $types as $key => $value )
|
3980 |
-
$content.= '<option value="' . $key . '" ' . selected( $type, $key, false ) . '>' . $value . '</option>';
|
3981 |
-
|
3982 |
-
return $content;
|
3983 |
-
|
3984 |
-
}
|
3985 |
-
|
3986 |
-
}
|
3987 |
-
|
3988 |
-
/**
|
3989 |
-
* Helper function to loop over choices.
|
3990 |
-
*
|
3991 |
-
* @param string $name The form element name.
|
3992 |
-
* @param array $choices The array of choices.
|
3993 |
-
*
|
3994 |
-
* @return string
|
3995 |
-
*
|
3996 |
-
* @access public
|
3997 |
-
* @since 2.0
|
3998 |
-
*/
|
3999 |
-
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
|
4000 |
-
|
4001 |
-
function ot_loop_through_choices( $name, $choices = array() ) {
|
4002 |
-
|
4003 |
-
$content = '';
|
4004 |
-
|
4005 |
-
foreach( (array) $choices as $key => $choice )
|
4006 |
-
$content.= '<li class="ui-state-default list-choice">' . ot_choices_view( $name, $key, $choice ) . '</li>';
|
4007 |
-
|
4008 |
-
return $content;
|
4009 |
-
}
|
4010 |
-
|
4011 |
-
}
|
4012 |
-
|
4013 |
-
/**
|
4014 |
-
* Helper function to loop over sub settings.
|
4015 |
-
*
|
4016 |
-
* @param string $name The form element name.
|
4017 |
-
* @param array $settings The array of settings.
|
4018 |
-
*
|
4019 |
-
* @return string
|
4020 |
-
*
|
4021 |
-
* @access public
|
4022 |
-
* @since 2.0
|
4023 |
-
*/
|
4024 |
-
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
|
4025 |
-
|
4026 |
-
function ot_loop_through_sub_settings( $name, $settings = array() ) {
|
4027 |
-
|
4028 |
-
$content = '';
|
4029 |
-
|
4030 |
-
foreach( $settings as $key => $setting )
|
4031 |
-
$content.= '<li class="ui-state-default list-sub-setting">' . ot_settings_view( $name, $key, $setting ) . '</li>';
|
4032 |
-
|
4033 |
-
return $content;
|
4034 |
-
}
|
4035 |
-
|
4036 |
-
}
|
4037 |
-
|
4038 |
-
/**
|
4039 |
-
* Helper function to display sections.
|
4040 |
-
*
|
4041 |
-
* This function is used in AJAX to add a new section
|
4042 |
-
* and when section have already been added and saved.
|
4043 |
-
*
|
4044 |
-
* @param int $key The array key for the current element.
|
4045 |
-
* @param array An array of values for the current section.
|
4046 |
-
*
|
4047 |
-
* @return void
|
4048 |
-
*
|
4049 |
-
* @access public
|
4050 |
-
* @since 2.0
|
4051 |
-
*/
|
4052 |
-
if ( ! function_exists( 'ot_sections_view' ) ) {
|
4053 |
-
|
4054 |
-
function ot_sections_view( $name, $key, $section = array() ) {
|
4055 |
-
|
4056 |
-
return '
|
4057 |
-
<div class="option-tree-setting is-section">
|
4058 |
-
<div class="open">' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( $key + 1 ) ) . '</div>
|
4059 |
-
<div class="button-section">
|
4060 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'edit', 'option-tree' ) . '">
|
4061 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4062 |
-
</a>
|
4063 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4064 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4065 |
-
</a>
|
4066 |
-
</div>
|
4067 |
-
<div class="option-tree-setting-body">
|
4068 |
-
<div class="format-settings">
|
4069 |
-
<div class="format-setting type-text">
|
4070 |
-
<div class="description">' . __( '<strong>Section Title</strong>: Displayed as a menu item on the Theme Options page.', 'option-tree' ) . '</div>
|
4071 |
-
<div class="format-setting-inner">
|
4072 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title section-title" autocomplete="off" />
|
4073 |
-
</div>
|
4074 |
-
</div>
|
4075 |
-
</div>
|
4076 |
-
<div class="format-settings">
|
4077 |
-
<div class="format-setting type-text">
|
4078 |
-
<div class="description">' . __( '<strong>Section ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
|
4079 |
-
<div class="format-setting-inner">
|
4080 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $section['id'] ) ? esc_attr( $section['id'] ) : '' ) . '" class="widefat option-tree-ui-input section-id" autocomplete="off" />
|
4081 |
-
</div>
|
4082 |
-
</div>
|
4083 |
-
</div>
|
4084 |
-
</div>
|
4085 |
-
</div>';
|
4086 |
-
|
4087 |
-
}
|
4088 |
-
|
4089 |
-
}
|
4090 |
-
|
4091 |
-
/**
|
4092 |
-
* Helper function to display settings.
|
4093 |
-
*
|
4094 |
-
* This function is used in AJAX to add a new setting
|
4095 |
-
* and when settings have already been added and saved.
|
4096 |
-
*
|
4097 |
-
* @param int $key The array key for the current element.
|
4098 |
-
* @param array An array of values for the current section.
|
4099 |
-
*
|
4100 |
-
* @return void
|
4101 |
-
*
|
4102 |
-
* @access public
|
4103 |
-
* @since 2.0
|
4104 |
-
*/
|
4105 |
-
if ( ! function_exists( 'ot_settings_view' ) ) {
|
4106 |
-
|
4107 |
-
function ot_settings_view( $name, $key, $setting = array() ) {
|
4108 |
-
|
4109 |
-
$child = ( strpos( $name, '][settings]') !== false ) ? true : false;
|
4110 |
-
$type = isset( $setting['type'] ) ? $setting['type'] : '';
|
4111 |
-
$std = isset( $setting['std'] ) ? $setting['std'] : '';
|
4112 |
-
$operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
|
4113 |
-
|
4114 |
-
// Serialize the standard value just incase
|
4115 |
-
if ( is_array( $std ) ) {
|
4116 |
-
$std = maybe_serialize( $std );
|
4117 |
-
}
|
4118 |
-
|
4119 |
-
if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ) ) ) {
|
4120 |
-
$std_form_element = '<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]">' . esc_html( $std ) . '</textarea>';
|
4121 |
-
} else {
|
4122 |
-
$std_form_element = '<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]" value="' . esc_attr( $std ) . '" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4123 |
-
}
|
4124 |
-
|
4125 |
-
return '
|
4126 |
-
<div class="option-tree-setting">
|
4127 |
-
<div class="open">' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( $key + 1 ) ) . '</div>
|
4128 |
-
<div class="button-section">
|
4129 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4130 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4131 |
-
</a>
|
4132 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4133 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4134 |
-
</a>
|
4135 |
-
</div>
|
4136 |
-
<div class="option-tree-setting-body">
|
4137 |
-
<div class="format-settings">
|
4138 |
-
<div class="format-setting type-text wide-desc">
|
4139 |
-
<div class="description">' . __( '<strong>Label</strong>: Displayed as the label of a form element on the Theme Options page.', 'option-tree' ) . '</div>
|
4140 |
-
<div class="format-setting-inner">
|
4141 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][label]" value="' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4142 |
-
</div>
|
4143 |
-
</div>
|
4144 |
-
</div>
|
4145 |
-
<div class="format-settings">
|
4146 |
-
<div class="format-setting type-text wide-desc">
|
4147 |
-
<div class="description">' . __( '<strong>ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
|
4148 |
-
<div class="format-setting-inner">
|
4149 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $setting['id'] ) ? esc_attr( $setting['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4150 |
-
</div>
|
4151 |
-
</div>
|
4152 |
-
</div>
|
4153 |
-
<div class="format-settings">
|
4154 |
-
<div class="format-setting type-select wide-desc">
|
4155 |
-
<div class="description">' . __( '<strong>Type</strong>: Choose one of the available option types from the dropdown.', 'option-tree' ) . '</div>
|
4156 |
-
<div class="format-setting-inner">
|
4157 |
-
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][type]" value="' . esc_attr( $type ) . '" class="option-tree-ui-select">
|
4158 |
-
' . ot_loop_through_option_types( $type, $child ) . '
|
4159 |
-
|
4160 |
-
</select>
|
4161 |
-
</div>
|
4162 |
-
</div>
|
4163 |
-
</div>
|
4164 |
-
<div class="format-settings">
|
4165 |
-
<div class="format-setting type-textarea wide-desc">
|
4166 |
-
<div class="description">' . __( '<strong>Description</strong>: 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' ) . '</div>
|
4167 |
-
<div class="format-setting-inner">
|
4168 |
-
<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][desc]">' . ( isset( $setting['desc'] ) ? esc_html( $setting['desc'] ) : '' ) . '</textarea>
|
4169 |
-
</div>
|
4170 |
-
</div>
|
4171 |
-
</div>
|
4172 |
-
<div class="format-settings">
|
4173 |
-
<div class="format-setting type-textblock wide-desc">
|
4174 |
-
<div class="description">' . __( '<strong>Choices</strong>: This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '</div>
|
4175 |
-
<div class="format-setting-inner">
|
4176 |
-
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4177 |
-
' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . '
|
4178 |
-
</ul>
|
4179 |
-
<a href="javascript:void(0);" class="option-tree-choice-add option-tree-ui-button button hug-left">' . __( 'Add Choice', 'option-tree' ) . '</a>
|
4180 |
-
</div>
|
4181 |
-
</div>
|
4182 |
-
</div>
|
4183 |
-
<div class="format-settings">
|
4184 |
-
<div class="format-setting type-textblock wide-desc">
|
4185 |
-
<div class="description">' . __( '<strong>Settings</strong>: This will only affect the List Item option type.', 'option-tree' ) . '</div>
|
4186 |
-
<div class="format-setting-inner">
|
4187 |
-
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4188 |
-
' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . '
|
4189 |
-
</ul>
|
4190 |
-
<a href="javascript:void(0);" class="option-tree-list-item-setting-add option-tree-ui-button button hug-left">' . __( 'Add Setting', 'option-tree' ) . '</a>
|
4191 |
-
</div>
|
4192 |
-
</div>
|
4193 |
-
</div>
|
4194 |
-
<div class="format-settings">
|
4195 |
-
<div class="format-setting type-text wide-desc">
|
4196 |
-
<div class="description">' . __( '<strong>Standard</strong>: Setting the standard value for your option only works for some option types. Read the <code>OptionTree->Documentation</code> for more information on which ones.', 'option-tree' ) . '</div>
|
4197 |
-
<div class="format-setting-inner">
|
4198 |
-
' . $std_form_element . '
|
4199 |
-
</div>
|
4200 |
-
</div>
|
4201 |
-
</div>
|
4202 |
-
<div class="format-settings">
|
4203 |
-
<div class="format-setting type-text wide-desc">
|
4204 |
-
<div class="description">' . __( '<strong>Rows</strong>: 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' ) . '</div>
|
4205 |
-
<div class="format-setting-inner">
|
4206 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][rows]" value="' . ( isset( $setting['rows'] ) ? esc_attr( $setting['rows'] ) : '' ) . '" class="widefat option-tree-ui-input" />
|
4207 |
-
</div>
|
4208 |
-
</div>
|
4209 |
-
</div>
|
4210 |
-
<div class="format-settings">
|
4211 |
-
<div class="format-setting type-text wide-desc">
|
4212 |
-
<div class="description">' . __( '<strong>Post Type</strong>: Add a comma separated list of post type like \'post,page\'. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select.', 'option-tree' ) . '</div>
|
4213 |
-
<div class="format-setting-inner">
|
4214 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][post_type]" value="' . ( isset( $setting['post_type'] ) ? esc_attr( $setting['post_type'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4215 |
-
</div>
|
4216 |
-
</div>
|
4217 |
-
</div>
|
4218 |
-
<div class="format-settings">
|
4219 |
-
<div class="format-setting type-text wide-desc">
|
4220 |
-
<div class="description">' . __( '<strong>Taxonomy</strong>: Add a comma separated list of any registered taxonomy like \'category,post_tag\'. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ) . '</div>
|
4221 |
-
<div class="format-setting-inner">
|
4222 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][taxonomy]" value="' . ( isset( $setting['taxonomy'] ) ? esc_attr( $setting['taxonomy'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4223 |
-
</div>
|
4224 |
-
</div>
|
4225 |
-
</div>
|
4226 |
-
<div class="format-settings">
|
4227 |
-
<div class="format-setting type-text wide-desc">
|
4228 |
-
<div class="description">' . __( '<strong>Min, Max, & Step</strong>: 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' ) . '</div>
|
4229 |
-
<div class="format-setting-inner">
|
4230 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][min_max_step]" value="' . ( isset( $setting['min_max_step'] ) ? esc_attr( $setting['min_max_step'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4231 |
-
</div>
|
4232 |
-
</div>
|
4233 |
-
</div>
|
4234 |
-
<div class="format-settings">
|
4235 |
-
<div class="format-setting type-text wide-desc">
|
4236 |
-
<div class="description">' . __( '<strong>CSS Class</strong>: Add and optional class to this option type.', 'option-tree' ) . '</div>
|
4237 |
-
<div class="format-setting-inner">
|
4238 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][class]" value="' . ( isset( $setting['class'] ) ? esc_attr( $setting['class'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4239 |
-
</div>
|
4240 |
-
</div>
|
4241 |
-
</div>
|
4242 |
-
<div class="format-settings">
|
4243 |
-
<div class="format-setting type-text wide-desc">
|
4244 |
-
<div class="description">' . sprintf( __( '<strong>Condition</strong>: Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, <code>value</code> is a placeholder for your condition, which can be in the form of %s.', 'option-tree' ), '<code>field_id:is(value)</code>, <code>field_id:not(value)</code>, <code>field_id:contains(value)</code>, <code>field_id:less_than(value)</code>, <code>field_id:less_than_or_equal_to(value)</code>, <code>field_id:greater_than(value)</code>, or <code>field_id:greater_than_or_equal_to(value)</code>' ) . '</div>
|
4245 |
-
<div class="format-setting-inner">
|
4246 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][condition]" value="' . ( isset( $setting['condition'] ) ? esc_attr( $setting['condition'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4247 |
-
</div>
|
4248 |
-
</div>
|
4249 |
-
</div>
|
4250 |
-
<div class="format-settings">
|
4251 |
-
<div class="format-setting type-select wide-desc">
|
4252 |
-
<div class="description">' . __( '<strong>Operator</strong>: Choose the logical operator to compute the result of the conditions.', 'option-tree' ) . '</div>
|
4253 |
-
<div class="format-setting-inner">
|
4254 |
-
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][operator]" value="' . $operator . '" class="option-tree-ui-select">
|
4255 |
-
<option value="and" ' . selected( $operator, 'and', false ) . '>' . __( 'and', 'option-tree' ) . '</option>
|
4256 |
-
<option value="or" ' . selected( $operator, 'or', false ) . '>' . __( 'or', 'option-tree' ) . '</option>
|
4257 |
-
</select>
|
4258 |
-
</div>
|
4259 |
-
</div>
|
4260 |
-
</div>
|
4261 |
-
</div>
|
4262 |
-
</div>
|
4263 |
-
' . ( ! $child ? '<input type="hidden" class="hidden-section" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][section]" value="' . ( isset( $setting['section'] ) ? esc_attr( $setting['section'] ) : '' ) . '" />' : '' );
|
4264 |
-
|
4265 |
-
}
|
4266 |
-
|
4267 |
-
}
|
4268 |
-
|
4269 |
-
/**
|
4270 |
-
* Helper function to display setting choices.
|
4271 |
-
*
|
4272 |
-
* This function is used in AJAX to add a new choice
|
4273 |
-
* and when choices have already been added and saved.
|
4274 |
-
*
|
4275 |
-
* @param string $name The form element name.
|
4276 |
-
* @param array $key The array key for the current element.
|
4277 |
-
* @param array An array of values for the current choice.
|
4278 |
-
*
|
4279 |
-
* @return void
|
4280 |
-
*
|
4281 |
-
* @access public
|
4282 |
-
* @since 2.0
|
4283 |
-
*/
|
4284 |
-
if ( ! function_exists( 'ot_choices_view' ) ) {
|
4285 |
-
|
4286 |
-
function ot_choices_view( $name, $key, $choice = array() ) {
|
4287 |
-
|
4288 |
-
return '
|
4289 |
-
<div class="option-tree-setting">
|
4290 |
-
<div class="open">' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( $key + 1 ) ) . '</div>
|
4291 |
-
<div class="button-section">
|
4292 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4293 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4294 |
-
</a>
|
4295 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4296 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4297 |
-
</a>
|
4298 |
-
</div>
|
4299 |
-
<div class="option-tree-setting-body">
|
4300 |
-
<div class="format-settings">
|
4301 |
-
<div class="format-setting-label">
|
4302 |
-
<h5>' . __( 'Label', 'option-tree' ) . '</h5>
|
4303 |
-
</div>
|
4304 |
-
<div class="format-setting type-text wide-desc">
|
4305 |
-
<div class="format-setting-inner">
|
4306 |
-
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][label]" value="' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4307 |
-
</div>
|
4308 |
-
</div>
|
4309 |
-
</div>
|
4310 |
-
<div class="format-settings">
|
4311 |
-
<div class="format-setting-label">
|
4312 |
-
<h5>' . __( 'Value', 'option-tree' ) . '</h5>
|
4313 |
-
</div>
|
4314 |
-
<div class="format-setting type-text wide-desc">
|
4315 |
-
<div class="format-setting-inner">
|
4316 |
-
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][value]" value="' . ( isset( $choice['value'] ) ? esc_attr( $choice['value'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4317 |
-
</div>
|
4318 |
-
</div>
|
4319 |
-
</div>
|
4320 |
-
<div class="format-settings">
|
4321 |
-
<div class="format-setting-label">
|
4322 |
-
<h5>' . __( 'Image Source (Radio Image only)', 'option-tree' ) . '</h5>
|
4323 |
-
</div>
|
4324 |
-
<div class="format-setting type-text wide-desc">
|
4325 |
-
<div class="format-setting-inner">
|
4326 |
-
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][src]" value="' . ( isset( $choice['src'] ) ? esc_attr( $choice['src'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4327 |
-
</div>
|
4328 |
-
</div>
|
4329 |
-
</div>
|
4330 |
-
</div>';
|
4331 |
-
|
4332 |
-
}
|
4333 |
-
|
4334 |
-
}
|
4335 |
-
|
4336 |
-
/**
|
4337 |
-
* Helper function to display sections.
|
4338 |
-
*
|
4339 |
-
* This function is used in AJAX to add a new section
|
4340 |
-
* and when section have already been added and saved.
|
4341 |
-
*
|
4342 |
-
* @param int $key The array key for the current element.
|
4343 |
-
* @param array An array of values for the current section.
|
4344 |
-
*
|
4345 |
-
* @return void
|
4346 |
-
*
|
4347 |
-
* @access public
|
4348 |
-
* @since 2.0
|
4349 |
-
*/
|
4350 |
-
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
|
4351 |
-
|
4352 |
-
function ot_contextual_help_view( $name, $key, $content = array() ) {
|
4353 |
-
|
4354 |
-
return '
|
4355 |
-
<div class="option-tree-setting">
|
4356 |
-
<div class="open">' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( $key + 1 ) ) . '</div>
|
4357 |
-
<div class="button-section">
|
4358 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4359 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4360 |
-
</a>
|
4361 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4362 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4363 |
-
</a>
|
4364 |
-
</div>
|
4365 |
-
<div class="option-tree-setting-body">
|
4366 |
-
<div class="format-settings">
|
4367 |
-
<div class="format-setting type-text no-desc">
|
4368 |
-
<div class="description">' . __( '<strong>Title</strong>: Displayed as a contextual help menu item on the Theme Options page.', 'option-tree' ) . '</div>
|
4369 |
-
<div class="format-setting-inner">
|
4370 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4371 |
-
</div>
|
4372 |
-
</div>
|
4373 |
-
</div>
|
4374 |
-
<div class="format-settings">
|
4375 |
-
<div class="format-setting type-text no-desc">
|
4376 |
-
<div class="description">' . __( '<strong>ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
|
4377 |
-
<div class="format-setting-inner">
|
4378 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $content['id'] ) ? esc_attr( $content['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4379 |
-
</div>
|
4380 |
-
</div>
|
4381 |
-
</div>
|
4382 |
-
<div class="format-settings">
|
4383 |
-
<div class="format-setting type-textarea no-desc">
|
4384 |
-
<div class="description">' . __( '<strong>Content</strong>: Enter the HTML content about this contextual help item displayed on the Theme Option page for end users to read.', 'option-tree' ) . '</div>
|
4385 |
-
<div class="format-setting-inner">
|
4386 |
-
<textarea class="textarea" rows="15" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][content]">' . ( isset( $content['content'] ) ? esc_html( $content['content'] ) : '' ) . '</textarea>
|
4387 |
-
</div>
|
4388 |
-
</div>
|
4389 |
-
</div>
|
4390 |
-
</div>
|
4391 |
-
</div>';
|
4392 |
-
|
4393 |
-
}
|
4394 |
-
|
4395 |
-
}
|
4396 |
-
|
4397 |
-
/**
|
4398 |
-
* Helper function to display sections.
|
4399 |
-
*
|
4400 |
-
* @param string $key
|
4401 |
-
* @param string $data
|
4402 |
-
* @param string $active_layout
|
4403 |
-
*
|
4404 |
-
* @return void
|
4405 |
-
*
|
4406 |
-
* @access public
|
4407 |
-
* @since 2.0
|
4408 |
-
*/
|
4409 |
-
if ( ! function_exists( 'ot_layout_view' ) ) {
|
4410 |
-
|
4411 |
-
function ot_layout_view( $key, $data = '', $active_layout = '' ) {
|
4412 |
-
|
4413 |
-
return '
|
4414 |
-
<div class="option-tree-setting">
|
4415 |
-
<div class="open">' . ( isset( $key ) ? esc_attr( $key ) : __( 'Layout', 'option-tree' ) ) . '</div>
|
4416 |
-
<div class="button-section">
|
4417 |
-
<a href="javascript:void(0);" class="option-tree-layout-activate option-tree-ui-button button left-item' . ( $active_layout == $key ? ' active' : '' ) . '" title="' . __( 'Activate', 'option-tree' ) . '">
|
4418 |
-
<span class="icon ot-icon-square-o"></span>' . __( 'Activate', 'option-tree' ) . '
|
4419 |
-
</a>
|
4420 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="'. __( 'Delete', 'option-tree' ) . '">
|
4421 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4422 |
-
</a>
|
4423 |
-
</div>
|
4424 |
-
<input type="hidden" name="' . ot_layouts_id() . '[' . esc_attr( $key ) . ']" value="' . $data . '" />
|
4425 |
-
</div>';
|
4426 |
-
|
4427 |
-
}
|
4428 |
-
|
4429 |
-
}
|
4430 |
-
|
4431 |
-
/**
|
4432 |
-
* Helper function to display list items.
|
4433 |
-
*
|
4434 |
-
* This function is used in AJAX to add a new list items
|
4435 |
-
* and when they have already been added and saved.
|
4436 |
-
*
|
4437 |
-
* @param string $name The form field name.
|
4438 |
-
* @param int $key The array key for the current element.
|
4439 |
-
* @param array An array of values for the current list item.
|
4440 |
-
*
|
4441 |
-
* @return void
|
4442 |
-
*
|
4443 |
-
* @access public
|
4444 |
-
* @since 2.0
|
4445 |
-
*/
|
4446 |
-
if ( ! function_exists( 'ot_list_item_view' ) ) {
|
4447 |
-
|
4448 |
-
function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
4449 |
-
|
4450 |
-
/* required title setting */
|
4451 |
-
$required_setting = array(
|
4452 |
-
array(
|
4453 |
-
'id' => 'title',
|
4454 |
-
'label' => __( 'Title', 'option-tree' ),
|
4455 |
-
'desc' => '',
|
4456 |
-
'std' => '',
|
4457 |
-
'type' => 'text',
|
4458 |
-
'rows' => '',
|
4459 |
-
'class' => 'option-tree-setting-title',
|
4460 |
-
'post_type' => '',
|
4461 |
-
'choices' => array()
|
4462 |
-
)
|
4463 |
-
);
|
4464 |
-
|
4465 |
-
/* load the old filterable slider settings */
|
4466 |
-
if ( 'slider' == $type ) {
|
4467 |
-
|
4468 |
-
$settings = ot_slider_settings( $name );
|
4469 |
-
|
4470 |
-
}
|
4471 |
-
|
4472 |
-
/* if no settings array load the filterable list item settings */
|
4473 |
-
if ( empty( $settings ) ) {
|
4474 |
-
|
4475 |
-
$settings = ot_list_item_settings( $name );
|
4476 |
-
|
4477 |
-
}
|
4478 |
-
|
4479 |
-
/* merge the two settings array */
|
4480 |
-
$settings = array_merge( $required_setting, $settings );
|
4481 |
-
|
4482 |
-
echo '
|
4483 |
-
<div class="option-tree-setting">
|
4484 |
-
<div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
|
4485 |
-
<div class="button-section">
|
4486 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4487 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4488 |
-
</a>
|
4489 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4490 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4491 |
-
</a>
|
4492 |
-
</div>
|
4493 |
-
<div class="option-tree-setting-body">';
|
4494 |
-
|
4495 |
-
foreach( $settings as $field ) {
|
4496 |
-
|
4497 |
-
// Set field value
|
4498 |
-
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
4499 |
-
|
4500 |
-
/* set default to standard value */
|
4501 |
-
if ( isset( $field['std'] ) ) {
|
4502 |
-
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4503 |
-
}
|
4504 |
-
|
4505 |
-
// filter the title label and description
|
4506 |
-
if ( $field['id'] == 'title' ) {
|
4507 |
-
|
4508 |
-
// filter the label
|
4509 |
-
$field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name );
|
4510 |
-
|
4511 |
-
// filter the description
|
4512 |
-
$field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name );
|
4513 |
-
|
4514 |
-
}
|
4515 |
-
|
4516 |
-
/* make life easier */
|
4517 |
-
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4518 |
-
|
4519 |
-
/* build the arguments array */
|
4520 |
-
$_args = array(
|
4521 |
-
'type' => $field['type'],
|
4522 |
-
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4523 |
-
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4524 |
-
'field_value' => $field_value,
|
4525 |
-
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4526 |
-
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4527 |
-
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4528 |
-
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4529 |
-
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4530 |
-
'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4531 |
-
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4532 |
-
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4533 |
-
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4534 |
-
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4535 |
-
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4536 |
-
'post_id' => $post_id,
|
4537 |
-
'get_option' => $get_option
|
4538 |
-
);
|
4539 |
-
|
4540 |
-
$conditions = '';
|
4541 |
-
|
4542 |
-
/* setup the conditions */
|
4543 |
-
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4544 |
-
|
4545 |
-
/* doing magic on the conditions so they work in a list item */
|
4546 |
-
$conditionals = explode( ',', $field['condition'] );
|
4547 |
-
foreach( $conditionals as $condition ) {
|
4548 |
-
$parts = explode( ':', $condition );
|
4549 |
-
if ( isset( $parts[0] ) ) {
|
4550 |
-
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4551 |
-
}
|
4552 |
-
}
|
4553 |
-
|
4554 |
-
$conditions = ' data-condition="' . $field['condition'] . '"';
|
4555 |
-
$conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
|
4556 |
-
|
4557 |
-
}
|
4558 |
-
|
4559 |
-
// Build the setting CSS class
|
4560 |
-
if ( ! empty( $_args['field_class'] ) ) {
|
4561 |
-
|
4562 |
-
$classes = explode( ' ', $_args['field_class'] );
|
4563 |
-
|
4564 |
-
foreach( $classes as $_key => $value ) {
|
4565 |
-
|
4566 |
-
$classes[$_key] = $value . '-wrap';
|
4567 |
-
|
4568 |
-
}
|
4569 |
-
|
4570 |
-
$class = 'format-settings ' . implode( ' ', $classes );
|
4571 |
-
|
4572 |
-
} else {
|
4573 |
-
|
4574 |
-
$class = 'format-settings';
|
4575 |
-
|
4576 |
-
}
|
4577 |
-
|
4578 |
-
/* option label */
|
4579 |
-
echo '<div id="setting_' . $_args['field_id'] . '" class="' . $class . '"' . $conditions . '>';
|
4580 |
-
|
4581 |
-
/* don't show title with textblocks */
|
4582 |
-
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
4583 |
-
echo '<div class="format-setting-label">';
|
4584 |
-
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4585 |
-
echo '</div>';
|
4586 |
-
}
|
4587 |
-
|
4588 |
-
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
4589 |
-
if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' )
|
4590 |
-
$_args['type'] = 'textarea-simple';
|
4591 |
-
|
4592 |
-
/* option body, list-item is not allowed inside another list-item */
|
4593 |
-
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' ) {
|
4594 |
-
echo ot_display_by_type( $_args );
|
4595 |
-
}
|
4596 |
-
|
4597 |
-
echo '</div>';
|
4598 |
-
|
4599 |
-
}
|
4600 |
-
|
4601 |
-
echo '</div>';
|
4602 |
-
|
4603 |
-
echo '</div>';
|
4604 |
-
|
4605 |
-
}
|
4606 |
-
|
4607 |
-
}
|
4608 |
-
|
4609 |
-
/**
|
4610 |
-
* Helper function to display social links.
|
4611 |
-
*
|
4612 |
-
* This function is used in AJAX to add a new list items
|
4613 |
-
* and when they have already been added and saved.
|
4614 |
-
*
|
4615 |
-
* @param string $name The form field name.
|
4616 |
-
* @param int $key The array key for the current element.
|
4617 |
-
* @param array An array of values for the current list item.
|
4618 |
-
*
|
4619 |
-
* @return void
|
4620 |
-
*
|
4621 |
-
* @access public
|
4622 |
-
* @since 2.4.0
|
4623 |
-
*/
|
4624 |
-
if ( ! function_exists( 'ot_social_links_view' ) ) {
|
4625 |
-
|
4626 |
-
function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
4627 |
-
|
4628 |
-
/* if no settings array load the filterable social links settings */
|
4629 |
-
if ( empty( $settings ) ) {
|
4630 |
-
|
4631 |
-
$settings = ot_social_links_settings( $name );
|
4632 |
-
|
4633 |
-
}
|
4634 |
-
|
4635 |
-
echo '
|
4636 |
-
<div class="option-tree-setting">
|
4637 |
-
<div class="open">' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '</div>
|
4638 |
-
<div class="button-section">
|
4639 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4640 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4641 |
-
</a>
|
4642 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4643 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4644 |
-
</a>
|
4645 |
-
</div>
|
4646 |
-
<div class="option-tree-setting-body">';
|
4647 |
-
|
4648 |
-
foreach( $settings as $field ) {
|
4649 |
-
|
4650 |
-
// Set field value
|
4651 |
-
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
4652 |
-
|
4653 |
-
/* set default to standard value */
|
4654 |
-
if ( isset( $field['std'] ) ) {
|
4655 |
-
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4656 |
-
}
|
4657 |
-
|
4658 |
-
/* make life easier */
|
4659 |
-
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4660 |
-
|
4661 |
-
/* build the arguments array */
|
4662 |
-
$_args = array(
|
4663 |
-
'type' => $field['type'],
|
4664 |
-
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4665 |
-
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4666 |
-
'field_value' => $field_value,
|
4667 |
-
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4668 |
-
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4669 |
-
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4670 |
-
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4671 |
-
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4672 |
-
'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4673 |
-
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4674 |
-
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4675 |
-
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4676 |
-
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4677 |
-
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4678 |
-
'post_id' => $post_id,
|
4679 |
-
'get_option' => $get_option
|
4680 |
-
);
|
4681 |
-
|
4682 |
-
$conditions = '';
|
4683 |
-
|
4684 |
-
/* setup the conditions */
|
4685 |
-
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4686 |
-
|
4687 |
-
/* doing magic on the conditions so they work in a list item */
|
4688 |
-
$conditionals = explode( ',', $field['condition'] );
|
4689 |
-
foreach( $conditionals as $condition ) {
|
4690 |
-
$parts = explode( ':', $condition );
|
4691 |
-
if ( isset( $parts[0] ) ) {
|
4692 |
-
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4693 |
-
}
|
4694 |
-
}
|
4695 |
-
|
4696 |
-
$conditions = ' data-condition="' . $field['condition'] . '"';
|
4697 |
-
$conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
|
4698 |
-
|
4699 |
-
}
|
4700 |
-
|
4701 |
-
/* option label */
|
4702 |
-
echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings"' . $conditions . '>';
|
4703 |
-
|
4704 |
-
/* don't show title with textblocks */
|
4705 |
-
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
4706 |
-
echo '<div class="format-setting-label">';
|
4707 |
-
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4708 |
-
echo '</div>';
|
4709 |
-
}
|
4710 |
-
|
4711 |
-
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
4712 |
-
if ( $_args['type'] == 'textarea' )
|
4713 |
-
$_args['type'] = 'textarea-simple';
|
4714 |
-
|
4715 |
-
/* option body, list-item is not allowed inside another list-item */
|
4716 |
-
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' && $_args['type'] !== 'social-links' ) {
|
4717 |
-
echo ot_display_by_type( $_args );
|
4718 |
-
}
|
4719 |
-
|
4720 |
-
echo '</div>';
|
4721 |
-
|
4722 |
-
}
|
4723 |
-
|
4724 |
-
echo '</div>';
|
4725 |
-
|
4726 |
-
echo '</div>';
|
4727 |
-
|
4728 |
-
}
|
4729 |
-
|
4730 |
-
}
|
4731 |
-
|
4732 |
-
/**
|
4733 |
-
* Helper function to display Theme Options layouts form.
|
4734 |
-
*
|
4735 |
-
* @return string
|
4736 |
-
*
|
4737 |
-
* @access public
|
4738 |
-
* @since 2.0
|
4739 |
-
*/
|
4740 |
-
if ( ! function_exists( 'niftycs_options_layouts_form' ) ) {
|
4741 |
-
|
4742 |
-
function niftycs_options_layouts_form( $active = false ) {
|
4743 |
-
|
4744 |
-
echo '<form method="post" id="option-tree-options-layouts-form">';
|
4745 |
-
|
4746 |
-
/* form nonce */
|
4747 |
-
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
4748 |
-
|
4749 |
-
/* get the saved layouts */
|
4750 |
-
$layouts = get_option( ot_layouts_id() );
|
4751 |
-
|
4752 |
-
/* set active layout */
|
4753 |
-
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
4754 |
-
|
4755 |
-
if ( is_array( $layouts ) && count( $layouts ) > 1 ) {
|
4756 |
-
|
4757 |
-
$active_layout = esc_attr( $layouts['active_layout'] );
|
4758 |
-
|
4759 |
-
echo '<input type="hidden" id="the_current_layout" value="' . $active_layout . '" />';
|
4760 |
-
|
4761 |
-
echo '<div class="option-tree-active-layout">';
|
4762 |
-
|
4763 |
-
echo '<select name="' . ot_layouts_id() . '[active_layout]" class="option-tree-ui-select">';
|
4764 |
-
|
4765 |
-
foreach( $layouts as $key => $data ) {
|
4766 |
-
|
4767 |
-
if ( $key == 'active_layout' )
|
4768 |
-
continue;
|
4769 |
-
|
4770 |
-
echo '<option' . selected( $key, $active_layout, false ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $key ) . '</option>';
|
4771 |
-
}
|
4772 |
-
|
4773 |
-
echo '</select>';
|
4774 |
-
|
4775 |
-
echo '</div>';
|
4776 |
-
|
4777 |
-
foreach( $layouts as $key => $data ) {
|
4778 |
-
|
4779 |
-
if ( $key == 'active_layout' )
|
4780 |
-
continue;
|
4781 |
-
|
4782 |
-
echo '<input type="hidden" name="' . ot_layouts_id() . '[' . $key . ']" value="' . ( isset( $data ) ? $data : '' ) . '" />';
|
4783 |
-
|
4784 |
-
}
|
4785 |
-
|
4786 |
-
}
|
4787 |
-
|
4788 |
-
/* new layout wrapper */
|
4789 |
-
echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
|
4790 |
-
|
4791 |
-
/* add new layout */
|
4792 |
-
echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4793 |
-
|
4794 |
-
echo '<button type="submit" class="option-tree-ui-button button button-primary save-layout" title="' . __( 'New Layout', 'option-tree' ) . '">' . __( 'New Layout', 'option-tree' ) . '</button>';
|
4795 |
-
|
4796 |
-
echo '</div>';
|
4797 |
-
|
4798 |
-
echo '</form>';
|
4799 |
-
|
4800 |
-
}
|
4801 |
-
|
4802 |
-
}
|
4803 |
-
|
4804 |
-
/**
|
4805 |
-
* Helper function to validate option ID's
|
4806 |
-
*
|
4807 |
-
* @param string $input The string to sanitize.
|
4808 |
-
* @return string
|
4809 |
-
*
|
4810 |
-
* @access public
|
4811 |
-
* @since 2.0
|
4812 |
-
*/
|
4813 |
-
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
|
4814 |
-
|
4815 |
-
function ot_sanitize_option_id( $input ) {
|
4816 |
-
|
4817 |
-
return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
|
4818 |
-
|
4819 |
-
}
|
4820 |
-
|
4821 |
-
}
|
4822 |
-
|
4823 |
-
/**
|
4824 |
-
* Helper function to validate layout ID's
|
4825 |
-
*
|
4826 |
-
* @param string $input The string to sanitize.
|
4827 |
-
* @return string
|
4828 |
-
*
|
4829 |
-
* @access public
|
4830 |
-
* @since 2.0
|
4831 |
-
*/
|
4832 |
-
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
|
4833 |
-
|
4834 |
-
function ot_sanitize_layout_id( $input ) {
|
4835 |
-
|
4836 |
-
return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
|
4837 |
-
|
4838 |
-
}
|
4839 |
-
|
4840 |
-
}
|
4841 |
-
|
4842 |
-
/**
|
4843 |
-
* Convert choices array to string
|
4844 |
-
*
|
4845 |
-
* @return string
|
4846 |
-
*
|
4847 |
-
* @access public
|
4848 |
-
* @since 2.0
|
4849 |
-
*/
|
4850 |
-
if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
|
4851 |
-
|
4852 |
-
function ot_convert_array_to_string( $input ) {
|
4853 |
-
|
4854 |
-
if ( is_array( $input ) ) {
|
4855 |
-
|
4856 |
-
foreach( $input as $k => $choice ) {
|
4857 |
-
$choices[$k] = $choice['value'] . '|' . $choice['label'];
|
4858 |
-
|
4859 |
-
if ( isset( $choice['src'] ) )
|
4860 |
-
$choices[$k].= '|' . $choice['src'];
|
4861 |
-
|
4862 |
-
}
|
4863 |
-
|
4864 |
-
return implode( ',', $choices );
|
4865 |
-
}
|
4866 |
-
|
4867 |
-
return false;
|
4868 |
-
}
|
4869 |
-
}
|
4870 |
-
|
4871 |
-
/**
|
4872 |
-
* Convert choices string to array
|
4873 |
-
*
|
4874 |
-
* @return array
|
4875 |
-
*
|
4876 |
-
* @access public
|
4877 |
-
* @since 2.0
|
4878 |
-
*/
|
4879 |
-
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
|
4880 |
-
|
4881 |
-
function ot_convert_string_to_array( $input ) {
|
4882 |
-
|
4883 |
-
if ( '' !== $input ) {
|
4884 |
-
|
4885 |
-
/* empty choices array */
|
4886 |
-
$choices = array();
|
4887 |
-
|
4888 |
-
/* exlode the string into an array */
|
4889 |
-
foreach( explode( ',', $input ) as $k => $choice ) {
|
4890 |
-
|
4891 |
-
/* if ":" is splitting the string go deeper */
|
4892 |
-
if ( preg_match( '/\|/', $choice ) ) {
|
4893 |
-
$split = explode( '|', $choice );
|
4894 |
-
$choices[$k]['value'] = trim( $split[0] );
|
4895 |
-
$choices[$k]['label'] = trim( $split[1] );
|
4896 |
-
|
4897 |
-
/* if radio image there are three values */
|
4898 |
-
if ( isset( $split[2] ) )
|
4899 |
-
$choices[$k]['src'] = trim( $split[2] );
|
4900 |
-
|
4901 |
-
} else {
|
4902 |
-
$choices[$k]['value'] = trim( $choice );
|
4903 |
-
$choices[$k]['label'] = trim( $choice );
|
4904 |
-
}
|
4905 |
-
|
4906 |
-
}
|
4907 |
-
|
4908 |
-
/* return a formated choices array */
|
4909 |
-
return $choices;
|
4910 |
-
|
4911 |
-
}
|
4912 |
-
|
4913 |
-
return false;
|
4914 |
-
|
4915 |
-
}
|
4916 |
-
}
|
4917 |
-
|
4918 |
-
/**
|
4919 |
-
* Helper function - strpos() with arrays.
|
4920 |
-
*
|
4921 |
-
* @param string $haystack
|
4922 |
-
* @param array $needles
|
4923 |
-
* @return bool
|
4924 |
-
*
|
4925 |
-
* @access public
|
4926 |
-
* @since 2.0
|
4927 |
-
*/
|
4928 |
-
if ( ! function_exists( 'ot_strpos_array' ) ) {
|
4929 |
-
|
4930 |
-
function ot_strpos_array( $haystack, $needles = array() ) {
|
4931 |
-
|
4932 |
-
foreach( $needles as $needle ) {
|
4933 |
-
$pos = strpos( $haystack, $needle );
|
4934 |
-
if ( $pos !== false ) {
|
4935 |
-
return true;
|
4936 |
-
}
|
4937 |
-
}
|
4938 |
-
|
4939 |
-
return false;
|
4940 |
-
}
|
4941 |
-
|
4942 |
-
}
|
4943 |
-
|
4944 |
-
/**
|
4945 |
-
* Helper function - strpos() with arrays.
|
4946 |
-
*
|
4947 |
-
* @param string $haystack
|
4948 |
-
* @param array $needles
|
4949 |
-
* @return bool
|
4950 |
-
*
|
4951 |
-
* @access public
|
4952 |
-
* @since 2.0
|
4953 |
-
*/
|
4954 |
-
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
|
4955 |
-
|
4956 |
-
function ot_array_keys_exists( $array, $keys ) {
|
4957 |
-
|
4958 |
-
foreach($keys as $k) {
|
4959 |
-
if ( isset($array[$k]) ) {
|
4960 |
-
return true;
|
4961 |
-
}
|
4962 |
-
}
|
4963 |
-
|
4964 |
-
return false;
|
4965 |
-
}
|
4966 |
-
|
4967 |
-
}
|
4968 |
-
|
4969 |
-
/**
|
4970 |
-
* Custom stripslashes from single value or array.
|
4971 |
-
*
|
4972 |
-
* @param mixed $input
|
4973 |
-
* @return mixed
|
4974 |
-
*
|
4975 |
-
* @access public
|
4976 |
-
* @since 2.0
|
4977 |
-
*/
|
4978 |
-
if ( ! function_exists( 'ot_stripslashes' ) ) {
|
4979 |
-
|
4980 |
-
function ot_stripslashes( $input ) {
|
4981 |
-
|
4982 |
-
if ( is_array( $input ) ) {
|
4983 |
-
|
4984 |
-
foreach( $input as &$val ) {
|
4985 |
-
|
4986 |
-
if ( is_array( $val ) ) {
|
4987 |
-
|
4988 |
-
$val = ot_stripslashes( $val );
|
4989 |
-
|
4990 |
-
} else {
|
4991 |
-
|
4992 |
-
$val = stripslashes( trim( $val ) );
|
4993 |
-
|
4994 |
-
}
|
4995 |
-
|
4996 |
-
}
|
4997 |
-
|
4998 |
-
} else {
|
4999 |
-
|
5000 |
-
$input = stripslashes( trim( $input ) );
|
5001 |
-
|
5002 |
-
}
|
5003 |
-
|
5004 |
-
return $input;
|
5005 |
-
|
5006 |
-
}
|
5007 |
-
|
5008 |
-
}
|
5009 |
-
|
5010 |
-
/**
|
5011 |
-
* Reverse wpautop.
|
5012 |
-
*
|
5013 |
-
* @param string $string The string to be filtered
|
5014 |
-
* @return string
|
5015 |
-
*
|
5016 |
-
* @access public
|
5017 |
-
* @since 2.0.9
|
5018 |
-
*/
|
5019 |
-
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
5020 |
-
|
5021 |
-
function ot_reverse_wpautop( $string = '' ) {
|
5022 |
-
|
5023 |
-
/* return if string is empty */
|
5024 |
-
if ( trim( $string ) === '' )
|
5025 |
-
return '';
|
5026 |
-
|
5027 |
-
/* remove all new lines & <p> tags */
|
5028 |
-
$string = str_replace( array( "\n", "<p>" ), "", $string );
|
5029 |
-
|
5030 |
-
/* replace <br /> with \r */
|
5031 |
-
$string = str_replace( array( "<br />", "<br>", "<br/>" ), "\r", $string );
|
5032 |
-
|
5033 |
-
/* replace </p> with \r\n */
|
5034 |
-
$string = str_replace( "</p>", "\r\n", $string );
|
5035 |
-
|
5036 |
-
/* return clean string */
|
5037 |
-
return trim( $string );
|
5038 |
-
|
5039 |
-
}
|
5040 |
-
|
5041 |
-
}
|
5042 |
-
|
5043 |
-
/**
|
5044 |
-
* Returns an array of elements from start to limit, inclusive.
|
5045 |
-
*
|
5046 |
-
* Occasionally zero will be some impossibly large number to
|
5047 |
-
* the "E" power when creating a range from negative to positive.
|
5048 |
-
* This function attempts to fix that by setting that number back to "0".
|
5049 |
-
*
|
5050 |
-
* @param string $start First value of the sequence.
|
5051 |
-
* @param string $limit The sequence is ended upon reaching the limit value.
|
5052 |
-
* @param string $step If a step value is given, it will be used as the increment
|
5053 |
-
* between elements in the sequence. step should be given as a
|
5054 |
-
* positive number. If not specified, step will default to 1.
|
5055 |
-
* @return array
|
5056 |
-
*
|
5057 |
-
* @access public
|
5058 |
-
* @since 2.0.12
|
5059 |
-
*/
|
5060 |
-
function ot_range( $start, $limit, $step = 1 ) {
|
5061 |
-
|
5062 |
-
if ( $step < 0 )
|
5063 |
-
$step = 1;
|
5064 |
-
|
5065 |
-
$range = range( $start, $limit, $step );
|
5066 |
-
|
5067 |
-
foreach( $range as $k => $v ) {
|
5068 |
-
if ( strpos( $v, 'E' ) ) {
|
5069 |
-
$range[$k] = 0;
|
5070 |
-
}
|
5071 |
-
}
|
5072 |
-
|
5073 |
-
return $range;
|
5074 |
-
}
|
5075 |
-
|
5076 |
-
/**
|
5077 |
-
* Helper function to return encoded strings
|
5078 |
-
*
|
5079 |
-
* @return string
|
5080 |
-
*
|
5081 |
-
* @access public
|
5082 |
-
* @since 2.0.13
|
5083 |
-
*/
|
5084 |
-
function ot_encode( $value ) {
|
5085 |
-
|
5086 |
-
$func = 'base64' . '_encode';
|
5087 |
-
return $func( $value );
|
5088 |
-
|
5089 |
-
}
|
5090 |
-
|
5091 |
-
/**
|
5092 |
-
* Helper function to return decoded strings
|
5093 |
-
*
|
5094 |
-
* @return string
|
5095 |
-
*
|
5096 |
-
* @access public
|
5097 |
-
* @since 2.0.13
|
5098 |
-
*/
|
5099 |
-
function ot_decode( $value ) {
|
5100 |
-
|
5101 |
-
$func = 'base64' . '_decode';
|
5102 |
-
return $func( $value );
|
5103 |
-
|
5104 |
-
}
|
5105 |
-
|
5106 |
-
/**
|
5107 |
-
* Helper function to open a file
|
5108 |
-
*
|
5109 |
-
* @access public
|
5110 |
-
* @since 2.0.13
|
5111 |
-
*/
|
5112 |
-
function ot_file_open( $handle, $mode ) {
|
5113 |
-
|
5114 |
-
$func = 'f' . 'open';
|
5115 |
-
return @$func( $handle, $mode );
|
5116 |
-
|
5117 |
-
}
|
5118 |
-
|
5119 |
-
/**
|
5120 |
-
* Helper function to close a file
|
5121 |
-
*
|
5122 |
-
* @access public
|
5123 |
-
* @since 2.0.13
|
5124 |
-
*/
|
5125 |
-
function ot_file_close( $handle ) {
|
5126 |
-
|
5127 |
-
$func = 'f' . 'close';
|
5128 |
-
return $func( $handle );
|
5129 |
-
|
5130 |
-
}
|
5131 |
-
|
5132 |
-
/**
|
5133 |
-
* Helper function to write to an open file
|
5134 |
-
*
|
5135 |
-
* @access public
|
5136 |
-
* @since 2.0.13
|
5137 |
-
*/
|
5138 |
-
function ot_file_write( $handle, $string ) {
|
5139 |
-
|
5140 |
-
$func = 'f' . 'write';
|
5141 |
-
return $func( $handle, $string );
|
5142 |
-
|
5143 |
-
}
|
5144 |
-
|
5145 |
-
/**
|
5146 |
-
* Helper function to filter standard option values.
|
5147 |
-
*
|
5148 |
-
* @param mixed $value Saved string or array value
|
5149 |
-
* @param mixed $std Standard string or array value
|
5150 |
-
* @return mixed String or array
|
5151 |
-
*
|
5152 |
-
* @access public
|
5153 |
-
* @since 2.0.15
|
5154 |
-
*/
|
5155 |
-
function ot_filter_std_value( $value = '', $std = '' ) {
|
5156 |
-
|
5157 |
-
$std = maybe_unserialize( $std );
|
5158 |
-
|
5159 |
-
if ( is_array( $value ) && is_array( $std ) ) {
|
5160 |
-
|
5161 |
-
foreach( $value as $k => $v ) {
|
5162 |
-
|
5163 |
-
if ( '' == $value[$k] && isset( $std[$k] ) ) {
|
5164 |
-
|
5165 |
-
$value[$k] = $std[$k];
|
5166 |
-
|
5167 |
-
}
|
5168 |
-
|
5169 |
-
}
|
5170 |
-
|
5171 |
-
} else if ( '' == $value && ! empty( $std ) ) {
|
5172 |
-
|
5173 |
-
$value = $std;
|
5174 |
-
|
5175 |
-
}
|
5176 |
-
|
5177 |
-
return $value;
|
5178 |
-
|
5179 |
-
}
|
5180 |
-
|
5181 |
-
/**
|
5182 |
-
* Helper function to set the Google fonts array.
|
5183 |
-
*
|
5184 |
-
* @param string $id The option ID.
|
5185 |
-
* @param bool $value The option value
|
5186 |
-
* @return void
|
5187 |
-
*
|
5188 |
-
* @access public
|
5189 |
-
* @since 2.5.0
|
5190 |
-
*/
|
5191 |
-
function ot_set_google_fonts( $id = '', $value = '' ) {
|
5192 |
-
|
5193 |
-
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
5194 |
-
|
5195 |
-
if ( is_array( $value ) && ! empty( $value ) ) {
|
5196 |
-
$ot_set_google_fonts[$id] = $value;
|
5197 |
-
} else if ( isset( $ot_set_google_fonts[$id] ) ) {
|
5198 |
-
unset( $ot_set_google_fonts[$id] );
|
5199 |
-
}
|
5200 |
-
|
5201 |
-
set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
|
5202 |
-
|
5203 |
-
}
|
5204 |
-
|
5205 |
-
/**
|
5206 |
-
* Helper function to remove unused options from the Google fonts array.
|
5207 |
-
*
|
5208 |
-
* @param array $options The array of saved options.
|
5209 |
-
* @return array
|
5210 |
-
*
|
5211 |
-
* @access public
|
5212 |
-
* @since 2.5.0
|
5213 |
-
*/
|
5214 |
-
function ot_update_google_fonts_after_save( $options ) {
|
5215 |
-
|
5216 |
-
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
5217 |
-
|
5218 |
-
foreach( $ot_set_google_fonts as $key => $set ) {
|
5219 |
-
if ( ! isset( $options[$key] ) ) {
|
5220 |
-
unset( $ot_set_google_fonts[$key] );
|
5221 |
-
}
|
5222 |
-
}
|
5223 |
-
set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
|
5224 |
-
|
5225 |
-
}
|
5226 |
-
add_action( 'ot_after_theme_options_save', 'ot_update_google_fonts_after_save', 1 );
|
5227 |
-
|
5228 |
-
/**
|
5229 |
-
* Helper function to fetch the Google fonts array.
|
5230 |
-
*
|
5231 |
-
* @param bool $normalize Whether or not to return a normalized array. Default 'true'.
|
5232 |
-
* @param bool $force_rebuild Whether or not to force the array to be rebuilt. Default 'false'.
|
5233 |
-
* @return array
|
5234 |
-
*
|
5235 |
-
* @access public
|
5236 |
-
* @since 2.5.0
|
5237 |
-
*/
|
5238 |
-
function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
|
5239 |
-
|
5240 |
-
/* Google Fonts cache key */
|
5241 |
-
$ot_google_fonts_cache_key = apply_filters( 'ot_google_fonts_cache_key', 'ot_google_fonts_cache' );
|
5242 |
-
|
5243 |
-
/* get the fonts from cache */
|
5244 |
-
$ot_google_fonts = apply_filters( 'ot_google_fonts_cache', get_transient( $ot_google_fonts_cache_key ) );
|
5245 |
-
|
5246 |
-
if ( $force_rebuild || ! is_array( $ot_google_fonts ) || empty( $ot_google_fonts ) ) {
|
5247 |
-
|
5248 |
-
$ot_google_fonts = array();
|
5249 |
-
|
5250 |
-
/* API url and key */
|
5251 |
-
$ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' );
|
5252 |
-
$ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', 'AIzaSyB8G-4UtQr9fhDYTiNrDP40Y5GYQQKrNWI' );
|
5253 |
-
|
5254 |
-
/* API arguments */
|
5255 |
-
$ot_google_fonts_fields = apply_filters( 'ot_google_fonts_fields', array( 'family', 'variants', 'subsets' ) );
|
5256 |
-
$ot_google_fonts_sort = apply_filters( 'ot_google_fonts_sort', 'alpha' );
|
5257 |
-
|
5258 |
-
/* Initiate API request */
|
5259 |
-
$ot_google_fonts_query_args = array(
|
5260 |
-
'key' => $ot_google_fonts_api_key,
|
5261 |
-
'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')',
|
5262 |
-
'sort' => $ot_google_fonts_sort
|
5263 |
-
);
|
5264 |
-
|
5265 |
-
/* Build and make the request */
|
5266 |
-
$ot_google_fonts_query = esc_url_raw( add_query_arg( $ot_google_fonts_query_args, $ot_google_fonts_api_url ) );
|
5267 |
-
$ot_google_fonts_response = wp_safe_remote_get( $ot_google_fonts_query, array( 'sslverify' => false, 'timeout' => 15 ) );
|
5268 |
-
|
5269 |
-
/* continue if we got a valid response */
|
5270 |
-
if ( 200 == wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) {
|
5271 |
-
|
5272 |
-
if ( $response_body = wp_remote_retrieve_body( $ot_google_fonts_response ) ) {
|
5273 |
-
|
5274 |
-
/* JSON decode the response body and cache the result */
|
5275 |
-
$ot_google_fonts_data = json_decode( trim( $response_body ), true );
|
5276 |
-
|
5277 |
-
if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) {
|
5278 |
-
|
5279 |
-
$ot_google_fonts = $ot_google_fonts_data['items'];
|
5280 |
-
|
5281 |
-
// Normalize the array key
|
5282 |
-
$ot_google_fonts_tmp = array();
|
5283 |
-
foreach( $ot_google_fonts as $key => $value ) {
|
5284 |
-
$id = remove_accents( $value['family'] );
|
5285 |
-
$id = strtolower( $id );
|
5286 |
-
$id = preg_replace( '/[^a-z0-9_\-]/', '', $id );
|
5287 |
-
$ot_google_fonts_tmp[$id] = $value;
|
5288 |
-
}
|
5289 |
-
|
5290 |
-
$ot_google_fonts = $ot_google_fonts_tmp;
|
5291 |
-
set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
|
5292 |
-
set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS );
|
5293 |
-
|
5294 |
-
}
|
5295 |
-
|
5296 |
-
}
|
5297 |
-
|
5298 |
-
}
|
5299 |
-
|
5300 |
-
}
|
5301 |
-
|
5302 |
-
return $normalize ? ot_normalize_google_fonts( $ot_google_fonts ) : $ot_google_fonts;
|
5303 |
-
|
5304 |
-
}
|
5305 |
-
|
5306 |
-
/**
|
5307 |
-
* Helper function to normalize the Google fonts array.
|
5308 |
-
*
|
5309 |
-
* @param array $google_fonts An array of fonts to nrmalize.
|
5310 |
-
* @return array
|
5311 |
-
*
|
5312 |
-
* @access public
|
5313 |
-
* @since 2.5.0
|
5314 |
-
*/
|
5315 |
-
function ot_normalize_google_fonts( $google_fonts ) {
|
5316 |
-
|
5317 |
-
$ot_normalized_google_fonts = array();
|
5318 |
-
|
5319 |
-
if ( is_array( $google_fonts ) && ! empty( $google_fonts ) ) {
|
5320 |
-
|
5321 |
-
foreach( $google_fonts as $google_font ) {
|
5322 |
-
|
5323 |
-
if( isset( $google_font['family'] ) ) {
|
5324 |
-
|
5325 |
-
$id = str_replace( ' ', '+', $google_font['family'] );
|
5326 |
-
|
5327 |
-
$ot_normalized_google_fonts[ $id ] = array(
|
5328 |
-
'family' => $google_font['family']
|
5329 |
-
);
|
5330 |
-
|
5331 |
-
if( isset( $google_font['variants'] ) ) {
|
5332 |
-
|
5333 |
-
$ot_normalized_google_fonts[ $id ]['variants'] = $google_font['variants'];
|
5334 |
-
|
5335 |
-
}
|
5336 |
-
|
5337 |
-
if( isset( $google_font['subsets'] ) ) {
|
5338 |
-
|
5339 |
-
$ot_normalized_google_fonts[ $id ]['subsets'] = $google_font['subsets'];
|
5340 |
-
|
5341 |
-
}
|
5342 |
-
|
5343 |
-
}
|
5344 |
-
|
5345 |
-
}
|
5346 |
-
|
5347 |
-
}
|
5348 |
-
|
5349 |
-
return $ot_normalized_google_fonts;
|
5350 |
-
|
5351 |
-
}
|
5352 |
-
|
5353 |
-
/**
|
5354 |
-
* Helper function to register a WPML string
|
5355 |
-
*
|
5356 |
-
* @access public
|
5357 |
-
* @since 2.1
|
5358 |
-
*/
|
5359 |
-
function ot_wpml_register_string( $id, $value ) {
|
5360 |
-
|
5361 |
-
if ( function_exists( 'icl_register_string' ) ) {
|
5362 |
-
|
5363 |
-
icl_register_string( 'Theme Options', $id, $value );
|
5364 |
-
|
5365 |
-
}
|
5366 |
-
|
5367 |
-
}
|
5368 |
-
|
5369 |
-
/**
|
5370 |
-
* Helper function to unregister a WPML string
|
5371 |
-
*
|
5372 |
-
* @access public
|
5373 |
-
* @since 2.1
|
5374 |
-
*/
|
5375 |
-
function ot_wpml_unregister_string( $id ) {
|
5376 |
-
|
5377 |
-
if ( function_exists( 'icl_unregister_string' ) ) {
|
5378 |
-
|
5379 |
-
icl_unregister_string( 'Theme Options', $id );
|
5380 |
-
|
5381 |
-
}
|
5382 |
-
|
5383 |
-
}
|
5384 |
-
|
5385 |
-
/**
|
5386 |
-
* Maybe migrate Settings
|
5387 |
-
*
|
5388 |
-
* @return void
|
5389 |
-
*
|
5390 |
-
* @access public
|
5391 |
-
* @since 2.3.3
|
5392 |
-
*/
|
5393 |
-
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
|
5394 |
-
|
5395 |
-
function ot_maybe_migrate_settings() {
|
5396 |
-
|
5397 |
-
// Filter the ID to migrate from
|
5398 |
-
$settings_id = apply_filters( 'ot_migrate_settings_id', '' );
|
5399 |
-
|
5400 |
-
// Attempt to migrate Settings
|
5401 |
-
if ( ! empty( $settings_id ) && get_option( ot_settings_id() ) === false && ot_settings_id() !== $settings_id ) {
|
5402 |
-
|
5403 |
-
// Old settings
|
5404 |
-
$settings = get_option( $settings_id );
|
5405 |
-
|
5406 |
-
// Check for array keys
|
5407 |
-
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
5408 |
-
|
5409 |
-
update_option( ot_settings_id(), $settings );
|
5410 |
-
|
5411 |
-
}
|
5412 |
-
|
5413 |
-
}
|
5414 |
-
|
5415 |
-
}
|
5416 |
-
|
5417 |
-
}
|
5418 |
-
|
5419 |
-
/**
|
5420 |
-
* Maybe migrate Option
|
5421 |
-
*
|
5422 |
-
* @return void
|
5423 |
-
*
|
5424 |
-
* @access public
|
5425 |
-
* @since 2.3.3
|
5426 |
-
*/
|
5427 |
-
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
|
5428 |
-
|
5429 |
-
function ot_maybe_migrate_options() {
|
5430 |
-
|
5431 |
-
// Filter the ID to migrate from
|
5432 |
-
$options_id = apply_filters( 'ot_migrate_options_id', '' );
|
5433 |
-
|
5434 |
-
// Attempt to migrate Theme Options
|
5435 |
-
if ( ! empty( $options_id ) && get_option( ot_options_id() ) === false && ot_options_id() !== $options_id ) {
|
5436 |
-
|
5437 |
-
// Old options
|
5438 |
-
$options = get_option( $options_id );
|
5439 |
-
|
5440 |
-
// Migrate to new ID
|
5441 |
-
update_option( ot_options_id(), $options );
|
5442 |
-
|
5443 |
-
}
|
5444 |
-
|
5445 |
-
}
|
5446 |
-
|
5447 |
-
}
|
5448 |
-
|
5449 |
-
/**
|
5450 |
-
* Maybe migrate Layouts
|
5451 |
-
*
|
5452 |
-
* @return void
|
5453 |
-
*
|
5454 |
-
* @access public
|
5455 |
-
* @since 2.3.3
|
5456 |
-
*/
|
5457 |
if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
|
5458 |
|
5459 |
-
|
5460 |
-
|
5461 |
-
|
5462 |
-
|
5463 |
-
|
5464 |
-
|
5465 |
-
|
5466 |
|
5467 |
-
|
5468 |
-
|
5469 |
|
5470 |
-
|
5471 |
-
|
5472 |
|
5473 |
-
|
5474 |
-
|
5475 |
-
}
|
5476 |
|
|
|
|
|
|
|
|
|
5477 |
}
|
5478 |
|
5479 |
-
|
5480 |
-
|
5481 |
-
|
5482 |
-
|
5483 |
-
|
5484 |
-
|
5485 |
-
|
5486 |
-
|
5487 |
-
|
5488 |
-
|
5489 |
-
|
5490 |
-
|
5491 |
-
|
5492 |
-
|
5493 |
-
|
5494 |
-
|
5495 |
-
|
5496 |
-
|
5497 |
-
|
5498 |
-
|
5499 |
-
|
5500 |
-
|
5501 |
-
|
5502 |
-
|
5503 |
-
|
5504 |
-
|
5505 |
-
|
5506 |
-
|
5507 |
-
|
5508 |
-
|
5509 |
-
|
5510 |
-
|
5511 |
-
|
5512 |
-
|
5513 |
-
|
5514 |
-
|
5515 |
-
|
5516 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5517 |
}
|
5518 |
|
5519 |
-
|
5520 |
-
|
5521 |
-
|
5522 |
-
|
5523 |
-
|
5524 |
-
|
5525 |
-
|
5526 |
-
|
5527 |
-
|
5528 |
-
|
5529 |
-
|
5530 |
-
|
5531 |
-
|
5532 |
-
|
5533 |
-
|
5534 |
-
|
5535 |
-
|
5536 |
-
|
5537 |
-
|
5538 |
-
|
5539 |
-
|
5540 |
-
|
5541 |
-
|
5542 |
-
|
5543 |
-
|
5544 |
-
|
5545 |
-
|
5546 |
-
|
5547 |
-
|
5548 |
-
|
5549 |
-
|
5550 |
-
|
5551 |
-
|
5552 |
-
|
5553 |
-
|
5554 |
-
|
5555 |
-
|
5556 |
-
|
5557 |
-
|
5558 |
-
|
5559 |
-
|
5560 |
-
|
5561 |
-
|
5562 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5563 |
}
|
5564 |
|
5565 |
-
|
5566 |
-
|
5567 |
-
|
5568 |
-
|
5569 |
-
|
5570 |
-
|
5571 |
-
|
5572 |
-
|
5573 |
-
|
5574 |
-
|
5575 |
-
|
5576 |
-
|
5577 |
-
|
5578 |
-
|
5579 |
-
|
5580 |
-
|
5581 |
-
|
5582 |
-
|
5583 |
-
|
5584 |
-
|
5585 |
-
|
5586 |
-
|
5587 |
-
|
5588 |
-
|
5589 |
-
|
5590 |
-
|
5591 |
-
|
5592 |
-
|
5593 |
-
|
5594 |
-
|
5595 |
-
|
5596 |
-
|
5597 |
-
|
5598 |
-
|
5599 |
-
|
5600 |
-
|
5601 |
-
|
5602 |
-
|
5603 |
-
|
5604 |
-
|
5605 |
-
|
5606 |
-
|
5607 |
-
|
5608 |
-
|
5609 |
-
|
5610 |
-
|
5611 |
-
|
5612 |
-
|
5613 |
-
|
5614 |
-
|
5615 |
-
|
5616 |
-
|
5617 |
-
|
5618 |
-
|
5619 |
-
|
5620 |
-
|
5621 |
-
|
5622 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5623 |
}
|
5624 |
|
5625 |
-
|
5626 |
-
|
5627 |
-
|
5628 |
-
|
5629 |
-
|
5630 |
-
|
5631 |
-
|
5632 |
-
|
5633 |
-
|
5634 |
-
|
5635 |
-
|
5636 |
-
|
5637 |
-
|
5638 |
-
|
5639 |
-
|
5640 |
-
|
5641 |
-
|
5642 |
-
|
5643 |
-
|
5644 |
-
|
5645 |
-
|
5646 |
-
|
5647 |
-
|
5648 |
-
|
5649 |
-
|
5650 |
-
|
5651 |
-
|
5652 |
-
|
5653 |
-
|
5654 |
-
|
5655 |
-
|
5656 |
-
|
5657 |
-
|
5658 |
-
|
5659 |
-
|
5660 |
-
|
5661 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5662 |
}
|
5663 |
|
5664 |
-
|
5665 |
-
|
5666 |
-
|
5667 |
-
|
5668 |
-
|
5669 |
-
|
5670 |
-
|
5671 |
-
|
5672 |
-
|
5673 |
-
|
5674 |
-
|
5675 |
-
|
5676 |
-
|
5677 |
-
|
5678 |
-
|
5679 |
-
|
5680 |
-
|
5681 |
-
|
5682 |
-
|
5683 |
-
|
5684 |
-
|
5685 |
-
|
5686 |
-
|
5687 |
-
|
5688 |
-
|
5689 |
-
|
5690 |
-
|
5691 |
-
|
5692 |
-
|
5693 |
-
|
5694 |
-
|
5695 |
-
|
5696 |
-
|
5697 |
-
|
5698 |
-
|
5699 |
-
|
5700 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5701 |
}
|
5702 |
|
5703 |
-
/**
|
5704 |
-
* Returns the option type by ID.
|
5705 |
-
*
|
5706 |
-
* @param string $option_id The option ID
|
5707 |
-
* @return string $settings_id The settings array ID
|
5708 |
-
* @return string The option type.
|
5709 |
-
*
|
5710 |
-
* @access public
|
5711 |
-
* @since 2.4.2
|
5712 |
-
*/
|
5713 |
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
|
5714 |
|
5715 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5716 |
|
5717 |
-
|
|
|
|
|
5718 |
|
5719 |
-
|
5720 |
|
5721 |
-
|
5722 |
-
|
5723 |
-
$settings = get_option( $settings_id, array() );
|
5724 |
-
|
5725 |
-
if ( isset( $settings['settings'] ) ) {
|
5726 |
-
|
5727 |
-
foreach( $settings['settings'] as $value ) {
|
5728 |
-
|
5729 |
-
if ( $option_id == $value['id'] && isset( $value['type'] ) ) {
|
5730 |
-
|
5731 |
-
return $value['type'];
|
5732 |
-
|
5733 |
-
}
|
5734 |
-
|
5735 |
-
}
|
5736 |
|
5737 |
-
|
5738 |
-
|
5739 |
-
return false;
|
5740 |
|
5741 |
-
|
|
|
|
|
|
|
|
|
5742 |
|
|
|
|
|
5743 |
}
|
5744 |
|
5745 |
-
|
5746 |
-
|
5747 |
-
|
5748 |
-
|
5749 |
-
|
5750 |
-
|
5751 |
-
|
5752 |
-
|
5753 |
-
|
5754 |
-
|
5755 |
-
|
5756 |
-
|
5757 |
-
|
5758 |
-
|
5759 |
-
|
5760 |
-
|
5761 |
-
|
5762 |
-
|
5763 |
-
|
5764 |
-
|
5765 |
-
|
5766 |
-
|
5767 |
-
|
5768 |
-
|
5769 |
-
|
5770 |
-
|
5771 |
-
|
5772 |
-
|
5773 |
-
|
5774 |
-
|
5775 |
-
|
5776 |
-
|
5777 |
-
|
5778 |
-
|
5779 |
-
|
5780 |
-
|
5781 |
-
|
5782 |
-
|
5783 |
-
|
5784 |
-
|
5785 |
-
|
5786 |
-
|
5787 |
-
|
5788 |
-
|
5789 |
-
|
5790 |
-
|
5791 |
-
|
5792 |
-
|
5793 |
-
|
5794 |
-
|
5795 |
-
|
5796 |
-
|
5797 |
-
|
5798 |
-
|
5799 |
-
|
5800 |
-
|
5801 |
-
|
5802 |
-
|
5803 |
-
|
5804 |
-
|
5805 |
-
|
5806 |
-
|
5807 |
-
|
5808 |
-
|
5809 |
-
|
5810 |
-
|
5811 |
-
|
5812 |
-
|
5813 |
-
|
5814 |
-
|
5815 |
-
|
5816 |
-
|
5817 |
-
|
5818 |
-
return $options;
|
5819 |
-
|
5820 |
}
|
5821 |
|
5822 |
-
|
5823 |
-
|
5824 |
-
|
5825 |
-
|
5826 |
-
|
5827 |
-
|
5828 |
-
|
5829 |
-
|
5830 |
-
|
5831 |
-
|
5832 |
-
|
5833 |
-
|
5834 |
-
|
5835 |
-
|
5836 |
-
|
5837 |
-
|
5838 |
-
|
5839 |
-
|
5840 |
-
|
5841 |
-
|
5842 |
-
|
5843 |
-
|
5844 |
-
|
5845 |
-
|
5846 |
-
|
5847 |
-
|
5848 |
-
|
5849 |
-
|
5850 |
-
|
5851 |
-
|
5852 |
-
|
5853 |
-
|
5854 |
-
|
5855 |
-
|
5856 |
-
|
5857 |
-
|
5858 |
-
|
5859 |
-
|
5860 |
-
|
5861 |
-
|
5862 |
-
|
5863 |
-
|
5864 |
-
|
5865 |
-
|
5866 |
-
|
5867 |
-
|
5868 |
-
|
5869 |
-
|
5870 |
-
|
5871 |
-
|
5872 |
-
|
5873 |
-
|
5874 |
-
|
5875 |
-
|
5876 |
-
|
5877 |
-
|
5878 |
-
|
5879 |
-
|
5880 |
-
|
5881 |
-
|
5882 |
-
|
5883 |
-
|
5884 |
-
|
5885 |
-
|
5886 |
-
|
5887 |
-
}
|
5888 |
-
|
5889 |
-
}
|
5890 |
-
|
5891 |
-
}
|
5892 |
-
|
5893 |
-
return $options;
|
5894 |
-
|
5895 |
}
|
5896 |
|
5897 |
-
|
5898 |
-
|
5899 |
-
|
5900 |
-
|
5901 |
-
|
5902 |
-
|
5903 |
-
|
5904 |
-
|
5905 |
-
|
5906 |
-
|
5907 |
-
|
5908 |
-
|
5909 |
-
|
5910 |
-
|
5911 |
-
|
5912 |
-
|
5913 |
-
|
5914 |
-
|
5915 |
-
|
5916 |
-
|
5917 |
-
|
5918 |
-
|
5919 |
-
|
5920 |
-
|
5921 |
-
|
5922 |
-
|
5923 |
-
|
5924 |
-
|
5925 |
-
|
5926 |
-
|
5927 |
-
|
5928 |
-
|
5929 |
-
|
5930 |
-
|
5931 |
-
|
5932 |
-
|
5933 |
-
|
5934 |
-
if ( isset( $option['parent'] ) ) {
|
5935 |
-
|
5936 |
-
// Loop over the array
|
5937 |
-
foreach( $option['value'] as $key => $value ) {
|
5938 |
-
|
5939 |
-
// The value is an array of IDs
|
5940 |
-
if ( is_array( $value ) ) {
|
5941 |
-
|
5942 |
-
// Loop over the sub array
|
5943 |
-
foreach( $value as $sub_key => $sub_value ) {
|
5944 |
-
|
5945 |
-
if ( $sub_value == $term_id ) {
|
5946 |
-
|
5947 |
-
unset( $new_options[$option['parent']][$key][$option['id']][$sub_key] );
|
5948 |
-
$new_options[$option['parent']][$key][$option['id']][$new_term_id] = $new_term_id;
|
5949 |
-
|
5950 |
-
}
|
5951 |
-
|
5952 |
-
}
|
5953 |
-
|
5954 |
-
} else if ( $value == $term_id ) {
|
5955 |
-
|
5956 |
-
unset( $new_options[$option['parent']][$key][$option['id']] );
|
5957 |
-
$new_options[$option['parent']][$key][$option['id']] = $new_term_id;
|
5958 |
-
|
5959 |
-
}
|
5960 |
-
|
5961 |
-
}
|
5962 |
-
|
5963 |
-
} else {
|
5964 |
-
|
5965 |
-
// The value is an array of IDs
|
5966 |
-
if ( is_array( $option['value'] ) ) {
|
5967 |
-
|
5968 |
-
// Loop over the array
|
5969 |
-
foreach( $option['value'] as $key => $value ) {
|
5970 |
-
|
5971 |
-
// It's a single value, just replace it
|
5972 |
-
if ( $value == $term_id ) {
|
5973 |
-
|
5974 |
-
unset( $new_options[$option['id']][$key] );
|
5975 |
-
$new_options[$option['id']][$new_term_id] = $new_term_id;
|
5976 |
-
|
5977 |
-
}
|
5978 |
-
|
5979 |
-
}
|
5980 |
-
|
5981 |
-
// It's a single value, just replace it
|
5982 |
-
} else if ( $option['value'] == $term_id ) {
|
5983 |
-
|
5984 |
-
$new_options[$option['id']] = $new_term_id;
|
5985 |
-
|
5986 |
-
}
|
5987 |
-
|
5988 |
-
}
|
5989 |
-
|
5990 |
-
}
|
5991 |
-
|
5992 |
-
}
|
5993 |
-
|
5994 |
-
}
|
5995 |
-
|
5996 |
-
// Options need to be updated
|
5997 |
-
if ( $old_options !== $new_options ) {
|
5998 |
-
update_option( ot_options_id(), $new_options );
|
5999 |
-
}
|
6000 |
-
|
6001 |
-
// Process the Meta Boxes
|
6002 |
-
$meta_settings = _ot_meta_box_potential_shared_terms();
|
6003 |
-
$option_types = array(
|
6004 |
-
'category-checkbox',
|
6005 |
-
'category-select',
|
6006 |
-
'tag-checkbox',
|
6007 |
-
'tag-select',
|
6008 |
-
'taxonomy-checkbox',
|
6009 |
-
'taxonomy-select'
|
6010 |
-
);
|
6011 |
-
|
6012 |
-
if ( ! empty( $meta_settings ) ) {
|
6013 |
-
$old_meta = array();
|
6014 |
-
|
6015 |
-
foreach( $meta_settings as $option ) {
|
6016 |
-
|
6017 |
-
if ( ! is_array( $option['taxonomy'] ) ) {
|
6018 |
-
$option['taxonomy'] = explode( ',', $option['taxonomy'] );
|
6019 |
-
}
|
6020 |
-
|
6021 |
-
if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) {
|
6022 |
-
continue;
|
6023 |
-
}
|
6024 |
-
|
6025 |
-
if ( isset( $option['children'] ) ) {
|
6026 |
-
$post_ids = get_posts( array(
|
6027 |
-
'fields' => 'ids',
|
6028 |
-
'meta_key' => $option['id'],
|
6029 |
-
) );
|
6030 |
-
|
6031 |
-
if ( $post_ids ) {
|
6032 |
-
|
6033 |
-
foreach( $post_ids as $post_id ) {
|
6034 |
-
|
6035 |
-
// Get the meta
|
6036 |
-
$old_meta = get_post_meta( $post_id, $option['id'], true );
|
6037 |
-
$new_meta = $old_meta;
|
6038 |
-
|
6039 |
-
// Has a saved value
|
6040 |
-
if ( ! empty( $old_meta ) && is_array( $old_meta ) ) {
|
6041 |
-
|
6042 |
-
// Loop over the array
|
6043 |
-
foreach( $old_meta as $key => $value ) {
|
6044 |
-
|
6045 |
-
foreach( $value as $sub_key => $sub_value ) {
|
6046 |
-
|
6047 |
-
if ( in_array( $sub_key, $option['children'] ) ) {
|
6048 |
-
|
6049 |
-
// The value is an array of IDs
|
6050 |
-
if ( is_array( $sub_value ) ) {
|
6051 |
-
|
6052 |
-
// Loop over the array
|
6053 |
-
foreach( $sub_value as $sub_sub_key => $sub_sub_value ) {
|
6054 |
-
|
6055 |
-
// It's a single value, just replace it
|
6056 |
-
if ( $sub_sub_value == $term_id ) {
|
6057 |
-
|
6058 |
-
unset( $new_meta[$key][$sub_key][$sub_sub_key] );
|
6059 |
-
$new_meta[$key][$sub_key][$new_term_id] = $new_term_id;
|
6060 |
-
|
6061 |
-
}
|
6062 |
-
|
6063 |
-
}
|
6064 |
-
|
6065 |
-
// It's a single value, just replace it
|
6066 |
-
} else if ( $sub_value == $term_id ) {
|
6067 |
-
|
6068 |
-
$new_meta[$key][$sub_key] = $new_term_id;
|
6069 |
-
|
6070 |
-
}
|
6071 |
-
|
6072 |
-
}
|
6073 |
-
|
6074 |
-
}
|
6075 |
-
|
6076 |
-
}
|
6077 |
-
|
6078 |
-
// Update
|
6079 |
-
if ( $old_meta !== $new_meta ) {
|
6080 |
-
|
6081 |
-
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
6082 |
-
|
6083 |
-
}
|
6084 |
-
|
6085 |
-
}
|
6086 |
-
|
6087 |
-
}
|
6088 |
-
|
6089 |
-
}
|
6090 |
-
|
6091 |
-
} else {
|
6092 |
-
$post_ids = get_posts( array(
|
6093 |
-
'fields' => 'ids',
|
6094 |
-
'meta_query' => array(
|
6095 |
-
'key' => $option['id'],
|
6096 |
-
'value' => $term_id,
|
6097 |
-
'compare' => 'IN'
|
6098 |
-
),
|
6099 |
-
) );
|
6100 |
-
|
6101 |
-
if ( $post_ids ) {
|
6102 |
-
|
6103 |
-
foreach( $post_ids as $post_id ) {
|
6104 |
-
|
6105 |
-
// Get the meta
|
6106 |
-
$old_meta = get_post_meta( $post_id, $option['id'], true );
|
6107 |
-
$new_meta = $old_meta;
|
6108 |
-
|
6109 |
-
// Has a saved value
|
6110 |
-
if ( ! empty( $old_meta ) ) {
|
6111 |
-
|
6112 |
-
// The value is an array of IDs
|
6113 |
-
if ( is_array( $old_meta ) ) {
|
6114 |
-
|
6115 |
-
// Loop over the array
|
6116 |
-
foreach( $old_meta as $key => $value ) {
|
6117 |
-
|
6118 |
-
// It's a single value, just replace it
|
6119 |
-
if ( $value == $term_id ) {
|
6120 |
-
|
6121 |
-
unset( $new_meta[$key] );
|
6122 |
-
$new_meta[$new_term_id] = $new_term_id;
|
6123 |
-
|
6124 |
-
}
|
6125 |
-
|
6126 |
-
}
|
6127 |
-
|
6128 |
-
// It's a single value, just replace it
|
6129 |
-
} else if ( $old_meta == $term_id ) {
|
6130 |
-
|
6131 |
-
$new_meta = $new_term_id;
|
6132 |
-
|
6133 |
-
}
|
6134 |
-
|
6135 |
-
// Update
|
6136 |
-
if ( $old_meta !== $new_meta ) {
|
6137 |
-
|
6138 |
-
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
6139 |
-
|
6140 |
-
}
|
6141 |
-
|
6142 |
-
}
|
6143 |
-
|
6144 |
-
}
|
6145 |
-
|
6146 |
-
}
|
6147 |
-
|
6148 |
-
}
|
6149 |
-
|
6150 |
-
}
|
6151 |
-
|
6152 |
-
}
|
6153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6154 |
}
|
6155 |
-
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
|
6156 |
|
6157 |
-
/* End of file ot-functions-admin.php */
|
6158 |
-
/* Location: ./includes/ot-functions-admin.php */
|
1 |
+
<?php
|
2 |
/**
|
3 |
* Functions used only while viewing the admin UI.
|
4 |
*
|
5 |
* Limit loading these function only when needed
|
6 |
* and not in the front end.
|
7 |
*
|
8 |
+
* @package OptionTree
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
12 |
+
exit( 'No direct script access allowed' );
|
13 |
+
}
|
14 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
16 |
|
17 |
+
/**
|
18 |
+
* Registers the Theme Option page
|
19 |
+
*
|
20 |
+
* @uses ot_register_settings()
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @since 2.1
|
24 |
+
*/
|
25 |
+
function ot_register_theme_options_page() {
|
26 |
+
|
27 |
+
// Get the settings array.
|
28 |
+
$get_settings = get_option( ot_settings_id() );
|
29 |
+
|
30 |
+
// Sections array.
|
31 |
+
$sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
|
32 |
+
|
33 |
+
// Settings array.
|
34 |
+
$settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
|
35 |
+
|
36 |
+
// Contexual help array.
|
37 |
+
$contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
|
38 |
+
|
39 |
+
// Build the Theme Options.
|
40 |
+
if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) {
|
41 |
+
|
42 |
+
$caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' );
|
43 |
+
|
44 |
+
ot_register_settings(
|
45 |
+
array(
|
46 |
+
array(
|
47 |
+
'id' => ot_options_id(),
|
48 |
+
'pages' => array(
|
49 |
+
array(
|
50 |
+
'id' => 'niftycs_options',
|
51 |
+
'parent_slug' => apply_filters( 'niftycs_options_parent_slug', null ),
|
52 |
+
'page_title' => apply_filters( 'niftycs_options_page_title', __( 'Nifty Coming Soon, Maintenance & Under Construction Options', 'option-tree' ) ),
|
53 |
+
'menu_title' => apply_filters( 'niftycs_options_menu_title', __( 'Nifty Options', 'option-tree' ) ),
|
54 |
+
'capability' => $caps = apply_filters( 'niftycs_options_capability', 'edit_theme_options' ),
|
55 |
+
'menu_slug' => apply_filters( 'niftycs_options_menu_slug', 'niftycs-options' ),
|
56 |
+
'icon_url' => apply_filters( 'niftycs_options_icon_url', OT_URL .'/assets/images/nifty_ot.png' ),
|
57 |
+
'position' => apply_filters( 'niftycs_options_position', null ),
|
58 |
+
'updated_message' => apply_filters( 'niftycs_options_updated_message', __( 'Nifty Options updated.', 'option-tree' ) ),
|
59 |
+
'reset_message' => apply_filters( 'niftycs_options_reset_message', __( 'Nifty Options restored to default value.', 'option-tree' ) ),
|
60 |
+
'button_text' => apply_filters( 'niftycs_options_button_text', __( 'Save Changes', 'option-tree' ) ),
|
61 |
+
'contextual_help' => apply_filters( 'niftycs_options_contextual_help', $contextual_help ),
|
62 |
+
'sections' => apply_filters( 'niftycs_options_sections', $sections ),
|
63 |
+
'settings' => apply_filters( 'niftycs_options_settings', $settings )
|
64 |
+
),
|
65 |
+
),
|
66 |
+
),
|
67 |
+
)
|
68 |
+
);
|
69 |
+
|
70 |
+
// Filters the options.php to add the minimum user capabilities.
|
71 |
+
add_filter(
|
72 |
+
'option_page_capability_' . ot_options_id(),
|
73 |
+
function() use ( $caps ) {
|
74 |
+
return $caps;
|
75 |
+
},
|
76 |
+
999
|
77 |
+
);
|
78 |
|
79 |
}
|
80 |
|
82 |
|
83 |
}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
86 |
|
87 |
+
/**
|
88 |
+
* Registers the Settings page.
|
89 |
+
*
|
90 |
+
* @access public
|
91 |
+
* @since 2.1
|
92 |
+
*/
|
93 |
+
function ot_register_settings_page() {
|
94 |
+
global $ot_has_custom_theme_options;
|
95 |
+
|
96 |
+
$custom_options = ( true === $ot_has_custom_theme_options || has_action( 'admin_init', 'custom_theme_options' ) || has_action( 'init', 'custom_theme_options' ) );
|
97 |
+
|
98 |
+
// Display UI Builder admin notice.
|
99 |
+
if ( true === OT_SHOW_OPTIONS_UI && isset( $_REQUEST['page'] ) && 'ot-settings' === $_REQUEST['page'] && $custom_options ) { // phpcs:ignore
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Error message for custom theme options.
|
103 |
+
*/
|
104 |
+
function ot_has_custom_theme_options() {
|
105 |
+
echo '<div class="error"><p>' . esc_html__( 'The Theme Options UI Builder is being overridden by a custom file in your theme. Any changes you make via the UI Builder will not be saved.', 'option-tree' ) . '</p></div>';
|
106 |
+
}
|
107 |
+
|
108 |
+
add_action( 'admin_notices', 'ot_has_custom_theme_options' );
|
109 |
+
}
|
110 |
+
|
111 |
+
// Create the filterable pages array.
|
112 |
+
$ot_register_pages_array = array(
|
113 |
+
array(
|
114 |
+
'id' => 'ot',
|
115 |
+
'page_title' => esc_html__( 'OptionTree', 'option-tree' ),
|
116 |
+
'menu_title' => esc_html__( 'OptionTree', 'option-tree' ),
|
117 |
+
'capability' => 'edit_theme_options',
|
118 |
+
'menu_slug' => 'ot-settings',
|
119 |
+
'icon_url' => null,
|
120 |
+
'position' => 61,
|
121 |
+
'hidden_page' => true,
|
122 |
+
),
|
123 |
+
array(
|
124 |
+
'id' => 'settings',
|
125 |
+
'parent_slug' => 'ot-settings',
|
126 |
+
'page_title' => esc_html__( 'Settings', 'option-tree' ),
|
127 |
+
'menu_title' => esc_html__( 'Settings', 'option-tree' ),
|
128 |
+
'capability' => 'edit_theme_options',
|
129 |
+
'menu_slug' => 'ot-settings',
|
130 |
+
'icon_url' => null,
|
131 |
+
'position' => null,
|
132 |
+
'updated_message' => esc_html__( 'Theme Options updated.', 'option-tree' ),
|
133 |
+
'reset_message' => esc_html__( 'Theme Options reset.', 'option-tree' ),
|
134 |
+
'button_text' => esc_html__( 'Save Settings', 'option-tree' ),
|
135 |
+
'show_buttons' => false,
|
136 |
+
'sections' => array(
|
137 |
+
array(
|
138 |
+
'id' => 'create_setting',
|
139 |
+
'title' => esc_html__( 'Theme Options UI', 'option-tree' ),
|
140 |
+
),
|
141 |
+
array(
|
142 |
+
'id' => 'import',
|
143 |
+
'title' => esc_html__( 'Import', 'option-tree' ),
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
'id' => 'export',
|
147 |
+
'title' => esc_html__( 'Export', 'option-tree' ),
|
148 |
+
),
|
149 |
+
array(
|
150 |
+
'id' => 'layouts',
|
151 |
+
'title' => esc_html__( 'Layouts', 'option-tree' ),
|
152 |
+
),
|
153 |
+
),
|
154 |
+
'settings' => array(
|
155 |
+
array(
|
156 |
+
'id' => 'theme_options_ui_text',
|
157 |
+
'label' => esc_html__( 'Theme Options UI Builder', 'option-tree' ),
|
158 |
+
'type' => 'theme_options_ui',
|
159 |
+
'section' => 'create_setting',
|
160 |
+
),
|
161 |
+
array(
|
162 |
+
'id' => 'import_settings_text',
|
163 |
+
'label' => esc_html__( 'Settings', 'option-tree' ),
|
164 |
+
'type' => 'import-settings',
|
165 |
+
'section' => 'import',
|
166 |
+
),
|
167 |
+
array(
|
168 |
+
'id' => 'import_data_text',
|
169 |
+
'label' => esc_html__( 'Theme Options', 'option-tree' ),
|
170 |
+
'type' => 'import-data',
|
171 |
+
'section' => 'import',
|
172 |
+
),
|
173 |
+
array(
|
174 |
+
'id' => 'import_layouts_text',
|
175 |
+
'label' => esc_html__( 'Layouts', 'option-tree' ),
|
176 |
+
'type' => 'import-layouts',
|
177 |
+
'section' => 'import',
|
178 |
+
),
|
179 |
+
array(
|
180 |
+
'id' => 'export_settings_file_text',
|
181 |
+
'label' => esc_html__( 'Settings PHP File', 'option-tree' ),
|
182 |
+
'type' => 'export-settings-file',
|
183 |
+
'section' => 'export',
|
184 |
+
),
|
185 |
+
array(
|
186 |
+
'id' => 'export_settings_text',
|
187 |
+
'label' => esc_html__( 'Settings', 'option-tree' ),
|
188 |
+
'type' => 'export-settings',
|
189 |
+
'section' => 'export',
|
190 |
+
),
|
191 |
+
array(
|
192 |
+
'id' => 'export_data_text',
|
193 |
+
'label' => esc_html__( 'Theme Options', 'option-tree' ),
|
194 |
+
'type' => 'export-data',
|
195 |
+
'section' => 'export',
|
196 |
+
),
|
197 |
+
array(
|
198 |
+
'id' => 'export_layout_text',
|
199 |
+
'label' => esc_html__( 'Layouts', 'option-tree' ),
|
200 |
+
'type' => 'export-layouts',
|
201 |
+
'section' => 'export',
|
202 |
+
),
|
203 |
+
array(
|
204 |
+
'id' => 'modify_layouts_text',
|
205 |
+
'label' => esc_html__( 'Layout Management', 'option-tree' ),
|
206 |
+
'type' => 'modify-layouts',
|
207 |
+
'section' => 'layouts',
|
208 |
+
),
|
209 |
+
),
|
210 |
+
),
|
211 |
+
array(
|
212 |
+
'id' => 'documentation',
|
213 |
+
'parent_slug' => 'ot-settings',
|
214 |
+
'page_title' => esc_html__( 'Documentation', 'option-tree' ),
|
215 |
+
'menu_title' => esc_html__( 'Documentation', 'option-tree' ),
|
216 |
+
'capability' => 'edit_theme_options',
|
217 |
+
'menu_slug' => 'ot-documentation',
|
218 |
+
'icon_url' => null,
|
219 |
+
'position' => null,
|
220 |
+
'updated_message' => esc_html__( 'Theme Options updated.', 'option-tree' ),
|
221 |
+
'reset_message' => esc_html__( 'Theme Options reset.', 'option-tree' ),
|
222 |
+
'button_text' => esc_html__( 'Save Settings', 'option-tree' ),
|
223 |
+
'show_buttons' => false,
|
224 |
+
'sections' => array(
|
225 |
+
array(
|
226 |
+
'id' => 'creating_options',
|
227 |
+
'title' => esc_html__( 'Creating Options', 'option-tree' ),
|
228 |
+
),
|
229 |
+
array(
|
230 |
+
'id' => 'option_types',
|
231 |
+
'title' => esc_html__( 'Option Types', 'option-tree' ),
|
232 |
+
),
|
233 |
+
array(
|
234 |
+
'id' => 'functions',
|
235 |
+
'title' => esc_html__( 'Function References', 'option-tree' ),
|
236 |
+
),
|
237 |
+
array(
|
238 |
+
'id' => 'theme_mode',
|
239 |
+
'title' => esc_html__( 'Theme Mode', 'option-tree' ),
|
240 |
+
),
|
241 |
+
array(
|
242 |
+
'id' => 'meta_boxes',
|
243 |
+
'title' => esc_html__( 'Meta Boxes', 'option-tree' ),
|
244 |
+
),
|
245 |
+
array(
|
246 |
+
'id' => 'examples',
|
247 |
+
'title' => esc_html__( 'Code Examples', 'option-tree' ),
|
248 |
+
),
|
249 |
+
array(
|
250 |
+
'id' => 'layouts_overview',
|
251 |
+
'title' => esc_html__( 'Layouts Overview', 'option-tree' ),
|
252 |
+
),
|
253 |
+
),
|
254 |
+
'settings' => array(
|
255 |
+
array(
|
256 |
+
'id' => 'creating_options_text',
|
257 |
+
'label' => esc_html__( 'Overview of available Theme Option fields.', 'option-tree' ),
|
258 |
+
'type' => 'creating-options',
|
259 |
+
'section' => 'creating_options',
|
260 |
+
),
|
261 |
+
array(
|
262 |
+
'id' => 'option_types_text',
|
263 |
+
'label' => esc_html__( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ),
|
264 |
+
'type' => 'option-types',
|
265 |
+
'section' => 'option_types',
|
266 |
+
),
|
267 |
+
array(
|
268 |
+
'id' => 'functions_ot_get_option',
|
269 |
+
'label' => esc_html__( 'Function Reference:ot_get_option()', 'option-tree' ),
|
270 |
+
'type' => 'ot-get-option',
|
271 |
+
'section' => 'functions',
|
272 |
+
),
|
273 |
+
array(
|
274 |
+
'id' => 'functions_get_option_tree',
|
275 |
+
'label' => esc_html__( 'Function Reference:get_option_tree()', 'option-tree' ),
|
276 |
+
'type' => 'get-option-tree',
|
277 |
+
'section' => 'functions',
|
278 |
+
),
|
279 |
+
array(
|
280 |
+
'id' => 'theme_mode_text',
|
281 |
+
'label' => esc_html__( 'Theme Mode', 'option-tree' ),
|
282 |
+
'type' => 'theme-mode',
|
283 |
+
'section' => 'theme_mode',
|
284 |
+
),
|
285 |
+
array(
|
286 |
+
'id' => 'meta_boxes_text',
|
287 |
+
'label' => esc_html__( 'Meta Boxes', 'option-tree' ),
|
288 |
+
'type' => 'meta-boxes',
|
289 |
+
'section' => 'meta_boxes',
|
290 |
+
),
|
291 |
+
array(
|
292 |
+
'id' => 'example_text',
|
293 |
+
'label' => esc_html__( 'Code examples for front-end development.', 'option-tree' ),
|
294 |
+
'type' => 'examples',
|
295 |
+
'section' => 'examples',
|
296 |
+
),
|
297 |
+
array(
|
298 |
+
'id' => 'layouts_overview_text',
|
299 |
+
'label' => esc_html__( 'What\'s a layout anyhow?', 'option-tree' ),
|
300 |
+
'type' => 'layouts-overview',
|
301 |
+
'section' => 'layouts_overview',
|
302 |
+
),
|
303 |
+
),
|
304 |
+
),
|
305 |
+
);
|
306 |
+
|
307 |
+
// Loop over the settings and remove as needed.
|
308 |
+
foreach ( $ot_register_pages_array as $key => $page ) {
|
309 |
+
|
310 |
+
// Remove various options from the Settings UI.
|
311 |
+
if ( 'settings' === $page['id'] ) {
|
312 |
+
|
313 |
+
// Remove the Theme Options UI.
|
314 |
+
if ( false === OT_SHOW_OPTIONS_UI ) {
|
315 |
+
|
316 |
+
foreach ( $page['sections'] as $section_key => $section ) {
|
317 |
+
if ( 'create_setting' === $section['id'] ) {
|
318 |
+
unset( $ot_register_pages_array[ $key ]['sections'][ $section_key ] );
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
323 |
+
if ( 'create_setting' === $setting['section'] ) {
|
324 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
// Remove parts of the Imports UI.
|
330 |
+
if ( false === OT_SHOW_SETTINGS_IMPORT ) {
|
331 |
+
|
332 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
333 |
+
if ( 'import' === $setting['section'] && in_array( $setting['id'], array( 'import_xml_text', 'import_settings_text' ), true ) ) {
|
334 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
335 |
+
}
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
// Remove parts of the Export UI.
|
340 |
+
if ( false === OT_SHOW_SETTINGS_EXPORT ) {
|
341 |
+
|
342 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
343 |
+
if ( 'export' === $setting['section'] && in_array( $setting['id'], array( 'export_settings_file_text', 'export_settings_text' ), true ) ) {
|
344 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
345 |
+
}
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
// Remove the Layouts UI.
|
350 |
+
if ( false === OT_SHOW_NEW_LAYOUT ) {
|
351 |
+
|
352 |
+
foreach ( $page['sections'] as $section_key => $section ) {
|
353 |
+
if ( 'layouts' === $section['id'] ) {
|
354 |
+
unset( $ot_register_pages_array[ $key ]['sections'][ $section_key ] );
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
359 |
+
if ( 'layouts' === $setting['section'] ) {
|
360 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
361 |
+
}
|
362 |
+
}
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
// Remove the Documentation UI.
|
367 |
+
if ( false === OT_SHOW_DOCS && 'documentation' === $page['id'] ) {
|
368 |
+
unset( $ot_register_pages_array[ $key ] );
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
$ot_register_pages_array = apply_filters( 'ot_register_pages_array', $ot_register_pages_array );
|
373 |
+
|
374 |
+
// Register the pages.
|
375 |
+
ot_register_settings(
|
376 |
+
array(
|
377 |
+
array(
|
378 |
+
'id' => ot_settings_id(),
|
379 |
+
'pages' => $ot_register_pages_array,
|
380 |
+
),
|
381 |
+
)
|
382 |
+
);
|
383 |
+
|
384 |
+
}
|
385 |
+
}
|
386 |
|
387 |
+
if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
|
|
|
388 |
|
389 |
+
/**
|
390 |
+
* Runs directly after the Theme Options are save.
|
391 |
+
*
|
392 |
+
* @access public
|
393 |
+
* @since 2.0
|
394 |
+
*/
|
395 |
+
function ot_after_theme_options_save() {
|
396 |
|
397 |
+
$page = isset( $_REQUEST['page'] ) ? esc_attr( wp_unslash( $_REQUEST['page'] ) ) : ''; // phpcs:ignore
|
398 |
+
$updated = isset( $_REQUEST['settings-updated'] ) && true === filter_var( wp_unslash( $_REQUEST['settings-updated'] ), FILTER_VALIDATE_BOOLEAN ); // phpcs:ignore
|
399 |
|
400 |
+
// Only execute after the theme options are saved.
|
401 |
+
if ( apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) === $page && $updated ) {
|
402 |
|
403 |
+
// Grab a copy of the theme options.
|
404 |
+
$options = get_option( ot_options_id() );
|
405 |
|
406 |
+
// Execute the action hook and pass the theme options to it.
|
407 |
+
do_action( 'ot_after_theme_options_save', $options );
|
408 |
+
}
|
409 |
+
}
|
410 |
+
}
|
411 |
|
412 |
+
if ( ! function_exists( 'ot_validate_setting' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
|
414 |
+
/**
|
415 |
+
* Validate the options by type before saving.
|
416 |
+
*
|
417 |
+
* This function will run on only some of the option types
|
418 |
+
* as all of them don't need to be validated, just the
|
419 |
+
* ones users are going to input data into; because they
|
420 |
+
* can't be trusted.
|
421 |
+
*
|
422 |
+
* @param mixed $input Setting value.
|
423 |
+
* @param string $type Setting type.
|
424 |
+
* @param string $field_id Setting field ID.
|
425 |
+
* @param string $wmpl_id WPML field ID.
|
426 |
+
* @return mixed
|
427 |
+
*
|
428 |
+
* @access public
|
429 |
+
* @since 2.0
|
430 |
+
*/
|
431 |
+
function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
|
432 |
+
|
433 |
+
// Exit early if missing data.
|
434 |
+
if ( ! $input || ! $type || ! $field_id ) {
|
435 |
+
return $input;
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Filter to modify a setting field value before validation.
|
440 |
+
*
|
441 |
+
* This cannot be used to filter the returned value of a custom
|
442 |
+
* setting type. You must use the `ot_validate_setting_input_safe`
|
443 |
+
* filter to ensure custom setting types are saved to the database.
|
444 |
+
*
|
445 |
+
* @param mixed $input The setting field value.
|
446 |
+
* @param string $type The setting field type.
|
447 |
+
* @param string $field_id The setting field ID.
|
448 |
+
*/
|
449 |
+
$input = apply_filters( 'ot_validate_setting', $input, $type, $field_id );
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Filter to validate a setting field value.
|
453 |
+
*
|
454 |
+
* @param mixed $input_safe This is either null, or the filtered input value.
|
455 |
+
* @param mixed $input The setting field value.
|
456 |
+
* @param string $type The setting field type.
|
457 |
+
* @param string $field_id The setting field ID.
|
458 |
+
*/
|
459 |
+
$input_safe = apply_filters( 'ot_validate_setting_input_safe', null, $input, $type, $field_id );
|
460 |
+
|
461 |
+
// The value was filtered and is safe to return.
|
462 |
+
if ( ! is_null( $input_safe ) ) {
|
463 |
+
return $input_safe;
|
464 |
+
}
|
465 |
+
|
466 |
+
/* translators: %1$s: the input id, %2$s: the field id */
|
467 |
+
$string_nums = esc_html__( 'The %1$s input field for %2$s only allows numeric values.', 'option-tree' );
|
468 |
+
|
469 |
+
if ( 'background' === $type ) {
|
470 |
+
|
471 |
+
$input_safe = array();
|
472 |
+
|
473 |
+
// Loop over array and check for values.
|
474 |
+
foreach ( (array) $input as $key => $value ) {
|
475 |
+
if ( 'background-color' === $key ) {
|
476 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
477 |
+
} elseif ( 'background-image' === $key ) {
|
478 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'upload', $field_id );
|
479 |
+
} else {
|
480 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
481 |
+
}
|
482 |
+
}
|
483 |
+
} elseif ( 'border' === $type ) {
|
484 |
+
|
485 |
+
$input_safe = array();
|
486 |
+
|
487 |
+
// Loop over array and set errors or unset key from array.
|
488 |
+
foreach ( $input as $key => $value ) {
|
489 |
+
|
490 |
+
if ( empty( $value ) ) {
|
491 |
+
continue;
|
492 |
+
}
|
493 |
+
|
494 |
+
// Validate width.
|
495 |
+
if ( 'width' === $key ) {
|
496 |
+
if ( ! is_numeric( $value ) ) {
|
497 |
+
add_settings_error( 'option-tree', 'invalid_border_width', sprintf( $string_nums, '<code>width</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
498 |
+
} else {
|
499 |
+
$input_safe[ $key ] = absint( $value );
|
500 |
+
}
|
501 |
+
} elseif ( 'color' === $key ) {
|
502 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
503 |
+
} else {
|
504 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
505 |
+
}
|
506 |
+
}
|
507 |
+
} elseif ( 'box-shadow' === $type ) {
|
508 |
+
|
509 |
+
$input_safe = array();
|
510 |
+
|
511 |
+
// Loop over array and check for values.
|
512 |
+
foreach ( (array) $input as $key => $value ) {
|
513 |
+
if ( 'inset' === $key ) {
|
514 |
+
$input_safe[ $key ] = 'inset';
|
515 |
+
} elseif ( 'color' === $key ) {
|
516 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
517 |
+
} else {
|
518 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
519 |
+
}
|
520 |
+
}
|
521 |
+
} elseif ( 'checkbox' === $type ) {
|
522 |
+
|
523 |
+
$input_safe = array();
|
524 |
+
|
525 |
+
// Loop over array and check for values.
|
526 |
+
foreach ( (array) $input as $key => $value ) {
|
527 |
+
if ( ! empty( $value ) ) {
|
528 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
529 |
+
}
|
530 |
+
}
|
531 |
+
} elseif ( 'colorpicker' === $type ) {
|
532 |
+
|
533 |
+
$input_safe = '';
|
534 |
+
|
535 |
+
// Only strings are allowed.
|
536 |
+
if ( is_string( $input ) ) {
|
537 |
+
|
538 |
+
/* translators: %s: the field id */
|
539 |
+
$string_color = esc_html__( 'The %s Colorpicker only allows valid hexadecimal or rgba values depending on the setting type.', 'option-tree' );
|
540 |
+
|
541 |
+
if ( 0 === preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input ) && 0 === preg_match( '/^rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]{1,4})\s*\)/i', $input ) ) {
|
542 |
+
add_settings_error( 'option-tree', 'invalid_hex_or_rgba', sprintf( $string_color, '<code>' . $field_id . '</code>' ), 'error' );
|
543 |
+
} else {
|
544 |
+
$input_safe = $input;
|
545 |
+
}
|
546 |
+
}
|
547 |
+
} elseif ( 'colorpicker-opacity' === $type ) {
|
548 |
+
$input_safe = ot_validate_setting( $input, 'colorpicker', $field_id );
|
549 |
+
} elseif ( in_array( $type, array( 'category-checkbox', 'custom-post-type-checkbox', 'page-checkbox', 'post-checkbox', 'tag-checkbox', 'taxonomy-checkbox' ), true ) ) {
|
550 |
+
|
551 |
+
$input_safe = array();
|
552 |
+
|
553 |
+
// Loop over array and check for values.
|
554 |
+
foreach ( (array) $input as $key => $value ) {
|
555 |
+
if ( filter_var( $value, FILTER_VALIDATE_INT ) && 0 < $value ) {
|
556 |
+
$input_safe[ $key ] = absint( $value );
|
557 |
+
}
|
558 |
+
}
|
559 |
+
} elseif ( in_array( $type, array( 'category-select', 'custom-post-type-select', 'page-select', 'post-select', 'tag-select', 'taxonomy-select' ), true ) ) {
|
560 |
+
|
561 |
+
$input_safe = '';
|
562 |
+
|
563 |
+
if ( filter_var( $input, FILTER_VALIDATE_INT ) && 0 < $input ) {
|
564 |
+
$input_safe = absint( $input );
|
565 |
+
}
|
566 |
+
} elseif ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ), true ) ) {
|
567 |
+
if ( ! function_exists( '_filter_wp_kses_post' ) ) {
|
568 |
+
/**
|
569 |
+
* Filter the allowed HTML and safe CSS styles.
|
570 |
+
*
|
571 |
+
* @since 2.7.2
|
572 |
+
*
|
573 |
+
* @param bool $add Whether to add or remove the filter.
|
574 |
+
*/
|
575 |
+
function _filter_wp_kses_post( $add = true ) {
|
576 |
+
$css_filter = function ( $attr ) {
|
577 |
+
array_push( $attr, 'display', 'visibility' );
|
578 |
+
|
579 |
+
$attr = apply_filters( 'ot_safe_style_css', $attr );
|
580 |
+
|
581 |
+
return $attr;
|
582 |
+
};
|
583 |
+
|
584 |
+
$html_filter = function ( $tags, $context ) {
|
585 |
+
if ( 'post' === $context ) {
|
586 |
+
if ( current_user_can( 'unfiltered_html' ) || true === OT_ALLOW_UNFILTERED_HTML ) {
|
587 |
+
$tags['script'] = array_fill_keys( array( 'async', 'charset', 'defer', 'src', 'type' ), true );
|
588 |
+
$tags['style'] = array_fill_keys( array( 'media', 'type' ), true );
|
589 |
+
$tags['iframe'] = array_fill_keys( array( 'align', 'allowfullscreen', 'class', 'frameborder', 'height', 'id', 'longdesc', 'marginheight', 'marginwidth', 'name', 'sandbox', 'scrolling', 'src', 'srcdoc', 'style', 'width' ), true );
|
590 |
+
$tags['noscript'] = true;
|
591 |
+
|
592 |
+
$tags = apply_filters( 'ot_allowed_html', $tags );
|
593 |
+
}
|
594 |
+
}
|
595 |
+
|
596 |
+
return $tags;
|
597 |
+
};
|
598 |
+
|
599 |
+
if ( $add ) {
|
600 |
+
add_filter( 'safe_style_css', $css_filter );
|
601 |
+
add_filter( 'wp_kses_allowed_html', $html_filter, 10, 2 );
|
602 |
+
} else {
|
603 |
+
remove_filter( 'safe_style_css', $css_filter );
|
604 |
+
remove_filter( 'wp_kses_allowed_html', $html_filter );
|
605 |
+
}
|
606 |
+
}
|
607 |
+
}
|
608 |
+
|
609 |
+
_filter_wp_kses_post( true );
|
610 |
+
$input_safe = wp_kses_post( $input );
|
611 |
+
_filter_wp_kses_post( false );
|
612 |
+
} elseif ( 'date-picker' === $type || 'date-time-picker' === $type ) {
|
613 |
+
if ( ! empty( $input ) && (bool) strtotime( $input ) ) {
|
614 |
+
$input_safe = sanitize_text_field( $input );
|
615 |
+
}
|
616 |
+
} elseif ( 'dimension' === $type ) {
|
617 |
+
|
618 |
+
$input_safe = array();
|
619 |
+
|
620 |
+
// Loop over array and set errors.
|
621 |
+
foreach ( $input as $key => $value ) {
|
622 |
+
if ( ! empty( $value ) ) {
|
623 |
+
if ( ! is_numeric( $value ) && 'unit' !== $key ) {
|
624 |
+
add_settings_error( 'option-tree', 'invalid_dimension_' . $key, sprintf( $string_nums, '<code>' . $key . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
625 |
+
} else {
|
626 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
627 |
+
}
|
628 |
+
}
|
629 |
+
}
|
630 |
+
} elseif ( 'gallery' === $type ) {
|
631 |
+
|
632 |
+
$input_safe = '';
|
633 |
+
|
634 |
+
if ( '' !== trim( $input ) ) {
|
635 |
+
$input_safe = sanitize_text_field( $input );
|
636 |
+
}
|
637 |
+
} elseif ( 'google-fonts' === $type ) {
|
638 |
+
|
639 |
+
$input_safe = array();
|
640 |
+
|
641 |
+
// Loop over array.
|
642 |
+
foreach ( $input as $key => $value ) {
|
643 |
+
if ( '%key%' === $key ) {
|
644 |
+
continue;
|
645 |
+
}
|
646 |
+
|
647 |
+
foreach ( $value as $fk => $fvalue ) {
|
648 |
+
if ( is_array( $fvalue ) ) {
|
649 |
+
foreach ( $fvalue as $sk => $svalue ) {
|
650 |
+
$input_safe[ $key ][ $fk ][ $sk ] = sanitize_text_field( $svalue );
|
651 |
+
}
|
652 |
+
} else {
|
653 |
+
$input_safe[ $key ][ $fk ] = sanitize_text_field( $fvalue );
|
654 |
+
}
|
655 |
+
}
|
656 |
+
}
|
657 |
+
|
658 |
+
array_values( $input_safe );
|
659 |
+
} elseif ( 'link-color' === $type ) {
|
660 |
+
|
661 |
+
$input_safe = array();
|
662 |
+
|
663 |
+
// Loop over array and check for values.
|
664 |
+
if ( is_array( $input ) && ! empty( $input ) ) {
|
665 |
+
foreach ( $input as $key => $value ) {
|
666 |
+
if ( ! empty( $value ) ) {
|
667 |
+
$input_safe[ $key ] = ot_validate_setting( $input[ $key ], 'colorpicker', $field_id . '-' . $key );
|
668 |
+
}
|
669 |
+
}
|
670 |
+
}
|
671 |
+
|
672 |
+
array_filter( $input_safe );
|
673 |
+
} elseif ( 'measurement' === $type ) {
|
674 |
+
|
675 |
+
$input_safe = array();
|
676 |
+
|
677 |
+
foreach ( $input as $key => $value ) {
|
678 |
+
if ( ! empty( $value ) ) {
|
679 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
680 |
+
}
|
681 |
+
}
|
682 |
+
} elseif ( 'numeric-slider' === $type ) {
|
683 |
+
$input_safe = '';
|
684 |
+
|
685 |
+
if ( ! empty( $input ) ) {
|
686 |
+
if ( ! is_numeric( $input ) ) {
|
687 |
+
add_settings_error( 'option-tree', 'invalid_numeric_slider', sprintf( $string_nums, '<code>' . esc_html__( 'slider', 'option-tree' ) . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
688 |
+
} else {
|
689 |
+
$input_safe = sanitize_text_field( $input );
|
690 |
+
}
|
691 |
+
}
|
692 |
+
} elseif ( 'on-off' === $type ) {
|
693 |
+
$input_safe = '';
|
694 |
+
|
695 |
+
if ( ! empty( $input ) ) {
|
696 |
+
$input_safe = sanitize_text_field( $input );
|
697 |
+
}
|
698 |
+
} elseif ( 'radio' === $type || 'radio-image' === $type || 'select' === $type || 'sidebar-select' === $type ) {
|
699 |
+
$input_safe = '';
|
700 |
+
|
701 |
+
if ( ! empty( $input ) ) {
|
702 |
+
$input_safe = sanitize_text_field( $input );
|
703 |
+
}
|
704 |
+
} elseif ( 'spacing' === $type ) {
|
705 |
+
|
706 |
+
$input_safe = array();
|
707 |
+
|
708 |
+
// Loop over array and set errors.
|
709 |
+
foreach ( $input as $key => $value ) {
|
710 |
+
if ( ! empty( $value ) ) {
|
711 |
+
if ( ! is_numeric( $value ) && 'unit' !== $key ) {
|
712 |
+
add_settings_error( 'option-tree', 'invalid_spacing_' . $key, sprintf( $string_nums, '<code>' . $key . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
713 |
+
} else {
|
714 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
715 |
+
}
|
716 |
+
}
|
717 |
+
}
|
718 |
+
} elseif ( 'typography' === $type && isset( $input['font-color'] ) ) {
|
719 |
+
|
720 |
+
$input_safe = array();
|
721 |
+
|
722 |
+
// Loop over array and check for values.
|
723 |
+
foreach ( $input as $key => $value ) {
|
724 |
+
if ( 'font-color' === $key ) {
|
725 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
726 |
+
} else {
|
727 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
728 |
+
}
|
729 |
+
}
|
730 |
+
} elseif ( 'upload' === $type ) {
|
731 |
+
|
732 |
+
$input_safe = filter_var( $input, FILTER_VALIDATE_INT );
|
733 |
+
|
734 |
+
if ( false === $input_safe && is_string( $input ) ) {
|
735 |
+
$input_safe = esc_url_raw( $input );
|
736 |
+
}
|
737 |
+
} elseif ( 'url' === $type ) {
|
738 |
+
|
739 |
+
$input_safe = '';
|
740 |
+
|
741 |
+
if ( ! empty( $input ) ) {
|
742 |
+
$input_safe = esc_url_raw( $input );
|
743 |
+
}
|
744 |
+
} elseif ( 'weforms' === $type ) {
|
745 |
+
|
746 |
+
$input_safe = '';
|
747 |
+
|
748 |
+
if ( ! empty( $input ) ) {
|
749 |
+
$input_safe = (int)$input;
|
750 |
+
}
|
751 |
+
} else {
|
752 |
+
|
753 |
+
/* translators: %1$s: the calling function, %2$s the filter name, %3$s the option type, %4$s the version number */
|
754 |
+
$string_error = esc_html__( 'Notice: %1$s was called incorrectly. All stored data must be filtered through %2$s, the %3$s option type is not using this filter. This is required since version %4$s.', 'option-tree' );
|
755 |
+
|
756 |
+
// Log a user notice that things have changed since the last version.
|
757 |
+
add_settings_error( 'option-tree', 'ot_validate_setting_error', sprintf( $string_error, '<code>ot_validate_setting</code>', '<code>ot_validate_setting_input_safe</code>', '<code>' . $type . '</code>', '<code>2.7.0</code>' ), 'error' );
|
758 |
+
|
759 |
+
$input_safe = '';
|
760 |
+
|
761 |
+
/*
|
762 |
+
* We don't know what the setting type is, so fallback to `sanitize_textarea_field`
|
763 |
+
* on all values and do a best-effort sanitize of the user data before saving it.
|
764 |
+
*/
|
765 |
+
if ( ! is_object( $input ) ) {
|
766 |
+
|
767 |
+
// Contains an integer, float, string or boolean.
|
768 |
+
if ( is_scalar( $input ) ) {
|
769 |
+
$input_safe = sanitize_textarea_field( $input );
|
770 |
+
} else {
|
771 |
+
if ( ! function_exists( '_sanitize_recursive' ) ) {
|
772 |
+
/**
|
773 |
+
* Filter the array values recursively.
|
774 |
+
*
|
775 |
+
* @param array $values The value to sanitize.
|
776 |
+
*
|
777 |
+
* @return array
|
778 |
+
*/
|
779 |
+
function _sanitize_recursive( $values = array() ) {
|
780 |
+
$result = array();
|
781 |
+
foreach ( $values as $key => $value ) {
|
782 |
+
if ( ! is_object( $value ) ) {
|
783 |
+
if ( is_scalar( $value ) ) {
|
784 |
+
$result[ $key ] = sanitize_textarea_field( $value );
|
785 |
+
} else {
|
786 |
+
$result[ $key ] = _sanitize_recursive( $value );
|
787 |
+
}
|
788 |
+
}
|
789 |
+
}
|
790 |
+
|
791 |
+
return $result;
|
792 |
+
}
|
793 |
+
}
|
794 |
+
$input_safe = _sanitize_recursive( $input );
|
795 |
+
}
|
796 |
+
}
|
797 |
+
}
|
798 |
+
|
799 |
+
// WPML Register and Unregister strings.
|
800 |
+
if ( ! empty( $wmpl_id ) ) {
|
801 |
+
|
802 |
+
// Allow filtering on the WPML option types.
|
803 |
+
$single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) );
|
804 |
+
|
805 |
+
if ( in_array( $type, $single_string_types, true ) ) {
|
806 |
+
if ( ! empty( $input_safe ) ) {
|
807 |
+
ot_wpml_register_string( $wmpl_id, $input_safe );
|
808 |
+
} else {
|
809 |
+
ot_wpml_unregister_string( $wmpl_id );
|
810 |
+
}
|
811 |
+
}
|
812 |
+
}
|
813 |
+
|
814 |
+
/**
|
815 |
+
* Filter to modify the validated setting field value.
|
816 |
+
*
|
817 |
+
* It's important to note that the filter does not have access to
|
818 |
+
* the original value and can only modify the validated input value.
|
819 |
+
* This is a breaking change as of version 2.7.0.
|
820 |
+
*
|
821 |
+
* @param mixed $input_safe The setting field value.
|
822 |
+
* @param string $type The setting field type.
|
823 |
+
* @param string $field_id The setting field ID.
|
824 |
+
*/
|
825 |
+
$input_safe = apply_filters( 'ot_after_validate_setting', $input_safe, $type, $field_id );
|
826 |
+
|
827 |
+
return $input_safe;
|
828 |
+
}
|
829 |
+
}
|
830 |
|
831 |
+
if ( ! function_exists( 'ot_admin_styles' ) ) {
|
832 |
|
833 |
+
/**
|
834 |
+
* Setup the default admin styles
|
835 |
+
*
|
836 |
+
* @access public
|
837 |
+
* @since 2.0
|
838 |
+
*/
|
839 |
+
function ot_admin_styles() {
|
840 |
+
global $wp_styles, $post;
|
841 |
+
|
842 |
+
wp_enqueue_style('wp-jquery-ui-dialog');
|
843 |
+
|
844 |
+
// Execute styles before actions.
|
845 |
+
do_action( 'ot_admin_styles_before' );
|
846 |
+
|
847 |
+
// Load WP colorpicker.
|
848 |
+
wp_enqueue_style( 'wp-color-picker' );
|
849 |
+
|
850 |
+
|
851 |
+
// Load admin styles.
|
852 |
+
wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION );
|
853 |
+
|
854 |
+
// Load the RTL stylesheet.
|
855 |
+
$wp_styles->add_data( 'ot-admin-css', 'rtl', true );
|
856 |
+
|
857 |
+
// Remove styles added by the Easy Digital Downloads plugin.
|
858 |
+
if ( isset( $post->post_type ) && 'post' === $post->post_type ) {
|
859 |
+
wp_dequeue_style( 'jquery-ui-css' );
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Filter the screen IDs used to dequeue `jquery-ui-css`.
|
864 |
+
*
|
865 |
+
* @since 2.5.0
|
866 |
+
*
|
867 |
+
* @param array $screen_ids An array of screen IDs.
|
868 |
+
*/
|
869 |
+
$screen_ids = apply_filters(
|
870 |
+
'ot_dequeue_jquery_ui_css_screen_ids',
|
871 |
+
array(
|
872 |
+
'toplevel_page_ot-settings',
|
873 |
+
'optiontree_page_ot-documentation',
|
874 |
+
'appearance_page_ot-theme-options',
|
875 |
+
)
|
876 |
+
);
|
877 |
+
|
878 |
+
// Remove styles added by the WP Review plugin and any custom pages added through filtering.
|
879 |
+
if ( in_array( get_current_screen()->id, $screen_ids, true ) ) {
|
880 |
+
wp_dequeue_style( 'plugin_name-admin-ui-css' );
|
881 |
+
wp_dequeue_style( 'jquery-ui-css' );
|
882 |
+
}
|
883 |
+
|
884 |
+
// Execute styles after actions.
|
885 |
+
do_action( 'ot_admin_styles_after' );
|
886 |
+
}
|
887 |
+
}
|
888 |
|
889 |
+
if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
890 |
|
891 |
+
/**
|
892 |
+
* Setup the default admin scripts.
|
893 |
+
*
|
894 |
+
* @uses add_thickbox() Include Thickbox for file uploads.
|
895 |
+
* @uses wp_enqueue_script() Add OptionTree scripts.
|
896 |
+
* @uses wp_localize_script() Used to include arbitrary Javascript data.
|
897 |
+
*
|
898 |
+
* @access public
|
899 |
+
* @since 2.0
|
900 |
+
*/
|
901 |
+
function ot_admin_scripts() {
|
902 |
+
|
903 |
+
// Execute scripts before actions.
|
904 |
+
do_action( 'ot_admin_scripts_before' );
|
905 |
+
|
906 |
+
if ( function_exists( 'wp_enqueue_media' ) ) {
|
907 |
+
// WP 3.5 Media Uploader.
|
908 |
+
wp_enqueue_media();
|
909 |
+
} else {
|
910 |
+
// Legacy Thickbox.
|
911 |
+
add_thickbox();
|
912 |
+
}
|
913 |
+
|
914 |
+
// Load jQuery-ui slider.
|
915 |
+
wp_enqueue_script( 'jquery-ui-slider' );
|
916 |
+
|
917 |
+
// Load jQuery-ui datepicker.
|
918 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
919 |
+
|
920 |
+
// Load WP colorpicker.
|
921 |
+
wp_enqueue_script( 'wp-color-picker' );
|
922 |
+
|
923 |
+
// Load Ace Editor for CSS Editing.
|
924 |
+
wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js', null, '1.1.3', false );
|
925 |
+
|
926 |
+
// Load jQuery UI timepicker addon.
|
927 |
+
wp_enqueue_script( 'jquery-ui-timepicker', OT_URL . 'assets/js/vendor/jquery/jquery-ui-timepicker.js', array( 'jquery', 'jquery-ui-slider', 'jquery-ui-datepicker' ), '1.4.3', false );
|
928 |
+
|
929 |
+
// Load the post formats.
|
930 |
+
if ( true === OT_META_BOXES && true === OT_POST_FORMATS ) {
|
931 |
+
wp_enqueue_script( 'ot-postformats', OT_URL . 'assets/js/ot-postformats.js', array( 'jquery' ), '1.0.1', false );
|
932 |
+
}
|
933 |
+
|
934 |
+
|
935 |
+
|
936 |
+
|
937 |
+
// Load all the required scripts.
|
938 |
+
wp_enqueue_script('jquery-ui-dialog');
|
939 |
+
wp_enqueue_script( 'ot-admin-js', OT_URL . 'assets/js/ot-admin.js', array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-sortable', 'jquery-ui-slider', 'wp-color-picker', 'ace-editor', 'jquery-ui-datepicker', 'jquery-ui-timepicker' ), OT_VERSION, false );
|
940 |
+
|
941 |
+
// Create localized JS array.
|
942 |
+
$localized_array = array(
|
943 |
+
'ajax' => admin_url( 'admin-ajax.php' ),
|
944 |
+
'nonce' => wp_create_nonce( 'option_tree' ),
|
945 |
+
'upload_text' => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ),
|
946 |
+
'remove_media_text' => esc_html__( 'Remove Media', 'option-tree' ),
|
947 |
+
'reset_agree' => esc_html__( 'Are you sure you want to reset back to the defaults?', 'option-tree' ),
|
948 |
+
'remove_no' => esc_html__( 'You can\'t remove this! But you can edit the values.', 'option-tree' ),
|
949 |
+
'remove_agree' => esc_html__( 'Are you sure you want to remove this?', 'option-tree' ),
|
950 |
+
'activate_layout_agree' => esc_html__( 'Are you sure you want to activate this layout?', 'option-tree' ),
|
951 |
+
'setting_limit' => esc_html__( 'Sorry, you can\'t have settings three levels deep.', 'option-tree' ),
|
952 |
+
'delete' => esc_html__( 'Delete Gallery', 'option-tree' ),
|
953 |
+
'edit' => esc_html__( 'Edit Gallery', 'option-tree' ),
|
954 |
+
'create' => esc_html__( 'Create Gallery', 'option-tree' ),
|
955 |
+
'confirm' => esc_html__( 'Are you sure you want to delete this Gallery?', 'option-tree' ),
|
956 |
+
'date_current' => esc_html__( 'Today', 'option-tree' ),
|
957 |
+
'date_time_current' => esc_html__( 'Now', 'option-tree' ),
|
958 |
+
'date_close' => esc_html__( 'Close', 'option-tree' ),
|
959 |
+
'replace' => esc_html__( 'Featured Image', 'option-tree' ),
|
960 |
+
'with' => esc_html__( 'Image', 'option-tree' ),
|
961 |
+
'weforms_dialog_upsell_title' => '<img alt="' . __('weForms', 'option-tree') . '" title="' . __('weForms', 'option-tree') . '" src="' . OT_URL . '/assets/images/weforms-logo-white.png' . '">',
|
962 |
+
'weforms_install_url' => add_query_arg(array('action' => 'install_weforms'), admin_url('admin.php')),
|
963 |
+
);
|
964 |
+
|
965 |
+
// Localized script attached to 'option_tree'.
|
966 |
+
wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array );
|
967 |
+
|
968 |
+
// Execute scripts after actions.
|
969 |
+
do_action( 'ot_admin_scripts_after' );
|
970 |
+
}
|
971 |
}
|
972 |
|
973 |
+
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
974 |
|
975 |
+
/**
|
976 |
+
* Returns the ID of a custom post type by post_title.
|
977 |
+
*
|
978 |
+
* @return int
|
979 |
+
*
|
980 |
+
* @access public
|
981 |
+
* @since 2.0
|
982 |
+
* @updated 2.7.0
|
983 |
+
*/
|
984 |
+
function ot_get_media_post_ID() { // phpcs:ignore
|
985 |
+
|
986 |
+
// Option ID.
|
987 |
+
$option_id = 'ot_media_post_ID';
|
988 |
+
|
989 |
+
// Get the media post ID.
|
990 |
+
$post_ID = get_option( $option_id, false );
|
991 |
+
|
992 |
+
// Add $post_ID to the DB.
|
993 |
+
if ( false === $post_ID || empty( $post_ID ) || ! is_integer( $post_ID ) ) {
|
994 |
+
global $wpdb;
|
995 |
+
|
996 |
+
// Get the media post ID.
|
997 |
+
$post_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts p WHERE p.post_title = %s AND p.post_type = %s AND p.post_status = %s", 'Media', 'option-tree', 'private' ) ); // phpcs:ignore
|
998 |
+
|
999 |
+
// Add to the DB.
|
1000 |
+
if ( null !== $post_ID && 0 < $post_ID ) {
|
1001 |
+
update_option( $option_id, $post_ID );
|
1002 |
+
} else {
|
1003 |
+
$post_ID = 0;
|
1004 |
+
}
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
return $post_ID;
|
1008 |
+
}
|
1009 |
+
}
|
1010 |
|
1011 |
+
if ( ! function_exists( 'ot_create_media_post' ) ) {
|
|
|
1012 |
|
1013 |
+
/**
|
1014 |
+
* Register custom post type & create the media post used to attach images.
|
1015 |
+
*
|
1016 |
+
* @access public
|
1017 |
+
* @since 2.0
|
1018 |
+
*/
|
1019 |
+
function ot_create_media_post() {
|
1020 |
+
|
1021 |
+
register_post_type(
|
1022 |
+
'option-tree',
|
1023 |
+
array(
|
1024 |
+
'labels' => array( 'name' => esc_html__( 'Option Tree', 'option-tree' ) ),
|
1025 |
+
'public' => false,
|
1026 |
+
'show_ui' => false,
|
1027 |
+
'capability_type' => 'post',
|
1028 |
+
'exclude_from_search' => true,
|
1029 |
+
'hierarchical' => false,
|
1030 |
+
'rewrite' => false,
|
1031 |
+
'supports' => array( 'title', 'editor' ),
|
1032 |
+
'can_export' => false,
|
1033 |
+
'show_in_nav_menus' => false,
|
1034 |
+
)
|
1035 |
+
);
|
1036 |
+
|
1037 |
+
// Look for custom page.
|
1038 |
+
$post_id = ot_get_media_post_ID();
|
1039 |
+
|
1040 |
+
// No post exists.
|
1041 |
+
if ( 0 === $post_id ) {
|
1042 |
+
|
1043 |
+
// Insert the post into the database.
|
1044 |
+
wp_insert_post(
|
1045 |
+
array(
|
1046 |
+
'post_title' => 'Media',
|
1047 |
+
'post_name' => 'media',
|
1048 |
+
'post_status' => 'private',
|
1049 |
+
'post_type' => 'option-tree',
|
1050 |
+
'comment_status' => 'closed',
|
1051 |
+
'ping_status' => 'closed',
|
1052 |
+
)
|
1053 |
+
);
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
|
1058 |
+
if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
|
1059 |
|
1060 |
+
/**
|
1061 |
+
* Setup default settings array.
|
1062 |
+
*
|
1063 |
+
* @access public
|
1064 |
+
* @since 2.0
|
1065 |
+
*/
|
1066 |
+
function ot_default_settings() {
|
1067 |
+
global $wpdb;
|
1068 |
+
|
1069 |
+
if ( ! get_option( ot_settings_id() ) ) {
|
1070 |
+
|
1071 |
+
$section_count = 0;
|
1072 |
+
$settings_count = 0;
|
1073 |
+
$settings = array();
|
1074 |
+
$table_name = $wpdb->prefix . 'option_tree';
|
1075 |
+
|
1076 |
+
$find_table = wp_cache_get( 'find_table', 'option_tree' );
|
1077 |
+
if ( false === $find_table ) {
|
1078 |
+
$find_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ); // phpcs:ignore
|
1079 |
+
wp_cache_set( 'find_table', $find_table, 'option_tree', 86400 );
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
if ( $find_table === $table_name ) {
|
1083 |
+
|
1084 |
+
$old_settings = wp_cache_get( 'old_settings', 'option_tree' );
|
1085 |
+
if ( false === $old_settings ) {
|
1086 |
+
$old_settings = $wpdb->get_results( "SELECT * FROM ${table_name} ORDER BY item_sort ASC" ); // phpcs:ignore
|
1087 |
+
wp_cache_set( 'old_settings', $old_settings, 'option_tree', 86400 );
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
if ( ! $old_settings ) {
|
1091 |
+
return;
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
foreach ( $old_settings as $setting ) {
|
1095 |
+
|
1096 |
+
// Heading is a section now.
|
1097 |
+
if ( 'heading' === $setting->item_type ) {
|
1098 |
+
|
1099 |
+
// Add section to the sections array.
|
1100 |
+
$settings['sections'][ $section_count ]['id'] = $setting->item_id;
|
1101 |
+
$settings['sections'][ $section_count ]['title'] = $setting->item_title;
|
1102 |
+
|
1103 |
+
// Ssave the last section id to use in creating settings.
|
1104 |
+
$section = $setting->item_id;
|
1105 |
+
|
1106 |
+
// Increment the section count.
|
1107 |
+
$section_count++;
|
1108 |
+
|
1109 |
+
} else {
|
1110 |
+
|
1111 |
+
// Add setting to the settings array.
|
1112 |
+
$settings['settings'][ $settings_count ]['id'] = $setting->item_id;
|
1113 |
+
$settings['settings'][ $settings_count ]['label'] = $setting->item_title;
|
1114 |
+
$settings['settings'][ $settings_count ]['desc'] = $setting->item_desc;
|
1115 |
+
$settings['settings'][ $settings_count ]['section'] = $section;
|
1116 |
+
$settings['settings'][ $settings_count ]['type'] = ot_map_old_option_types( $setting->item_type );
|
1117 |
+
$settings['settings'][ $settings_count ]['std'] = '';
|
1118 |
+
$settings['settings'][ $settings_count ]['class'] = '';
|
1119 |
+
|
1120 |
+
// Textarea rows.
|
1121 |
+
$rows = '';
|
1122 |
+
if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'css', 'javascript', 'textarea' ), true ) ) {
|
1123 |
+
if ( (int) $setting->item_options > 0 ) {
|
1124 |
+
$rows = (int) $setting->item_options;
|
1125 |
+
} else {
|
1126 |
+
$rows = 15;
|
1127 |
+
}
|
1128 |
+
}
|
1129 |
+
$settings['settings'][ $settings_count ]['rows'] = $rows;
|
1130 |
+
|
1131 |
+
// Post type.
|
1132 |
+
$post_type = '';
|
1133 |
+
if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ), true ) ) {
|
1134 |
+
if ( '' !== $setting->item_options ) {
|
1135 |
+
$post_type = $setting->item_options;
|
1136 |
+
} else {
|
1137 |
+
$post_type = 'post';
|
1138 |
+
}
|
1139 |
+
}
|
1140 |
+
$settings['settings'][ $settings_count ]['post_type'] = $post_type;
|
1141 |
+
|
1142 |
+
// Cchoices.
|
1143 |
+
$choices = array();
|
1144 |
+
if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'checkbox', 'radio', 'select' ), true ) ) {
|
1145 |
+
if ( '' !== $setting->item_options ) {
|
1146 |
+
$choices = ot_convert_string_to_array( $setting->item_options );
|
1147 |
+
}
|
1148 |
+
}
|
1149 |
+
$settings['settings'][ $settings_count ]['choices'] = $choices;
|
1150 |
+
|
1151 |
+
$settings_count++;
|
1152 |
+
}
|
1153 |
+
}
|
1154 |
+
|
1155 |
+
// Make sure each setting has a section just in case.
|
1156 |
+
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
1157 |
+
foreach ( $settings['settings'] as $k => $setting ) {
|
1158 |
+
if ( '' === $setting['section'] ) {
|
1159 |
+
$settings['settings'][ $k ]['section'] = $settings['sections'][0]['id'];
|
1160 |
+
}
|
1161 |
+
}
|
1162 |
+
}
|
1163 |
+
}
|
1164 |
+
|
1165 |
+
// If array if not properly formed create fallback settings array.
|
1166 |
+
if ( ! isset( $settings['sections'] ) || ! isset( $settings['settings'] ) ) {
|
1167 |
+
|
1168 |
+
$settings = array(
|
1169 |
+
'sections' => array(
|
1170 |
+
array(
|
1171 |
+
'id' => 'general',
|
1172 |
+
'title' => esc_html__( 'General', 'option-tree' ),
|
1173 |
+
),
|
1174 |
+
),
|
1175 |
+
'settings' => array(
|
1176 |
+
array(
|
1177 |
+
'id' => 'sample_text',
|
1178 |
+
'label' => esc_html__( 'Sample Text Field Label', 'option-tree' ),
|
1179 |
+
'desc' => esc_html__( 'Description for the sample text field.', 'option-tree' ),
|
1180 |
+
'section' => 'general',
|
1181 |
+
'type' => 'text',
|
1182 |
+
'std' => '',
|
1183 |
+
'class' => '',
|
1184 |
+
'rows' => '',
|
1185 |
+
'post_type' => '',
|
1186 |
+
'choices' => array(),
|
1187 |
+
),
|
1188 |
+
),
|
1189 |
+
);
|
1190 |
+
}
|
1191 |
+
|
1192 |
+
// Update the settings array.
|
1193 |
+
update_option( ot_settings_id(), $settings );
|
1194 |
+
|
1195 |
+
// Get option tree array.
|
1196 |
+
$options = get_option( ot_options_id() );
|
1197 |
+
|
1198 |
+
$options_safe = array();
|
1199 |
+
|
1200 |
+
// Validate options.
|
1201 |
+
if ( is_array( $options ) ) {
|
1202 |
+
|
1203 |
+
foreach ( $settings['settings'] as $setting ) {
|
1204 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
1205 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
// Execute the action hook and pass the theme options to it.
|
1210 |
+
do_action( 'ot_before_theme_options_save', $options_safe );
|
1211 |
+
|
1212 |
+
// Update the option tree array.
|
1213 |
+
update_option( ot_options_id(), $options_safe );
|
1214 |
+
}
|
1215 |
+
}
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
|
1219 |
+
if ( ! function_exists( 'ot_save_css' ) ) {
|
1220 |
|
1221 |
+
/**
|
1222 |
+
* Helper function to update the CSS option type after save.
|
1223 |
+
*
|
1224 |
+
* This function is called during the `ot_after_theme_options_save` hook,
|
1225 |
+
* which is passed the currently stored options array.
|
1226 |
+
*
|
1227 |
+
* @param array $options The current stored options array.
|
1228 |
+
*
|
1229 |
+
* @access public
|
1230 |
+
* @since 2.0
|
1231 |
+
*/
|
1232 |
+
function ot_save_css( $options ) {
|
1233 |
+
|
1234 |
+
// Grab a copy of the settings.
|
1235 |
+
$settings = get_option( ot_settings_id() );
|
1236 |
+
|
1237 |
+
// Has settings.
|
1238 |
+
if ( isset( $settings['settings'] ) ) {
|
1239 |
+
|
1240 |
+
// Loop through sections and insert CSS when needed.
|
1241 |
+
foreach ( $settings['settings'] as $k => $setting ) {
|
1242 |
+
|
1243 |
+
// Is the CSS option type.
|
1244 |
+
if ( isset( $setting['type'] ) && 'css' === $setting['type'] ) {
|
1245 |
+
|
1246 |
+
// Insert CSS into dynamic.css.
|
1247 |
+
if ( isset( $options[ $setting['id'] ] ) && '' !== $options[ $setting['id'] ] ) {
|
1248 |
+
ot_insert_css_with_markers( $setting['id'], $options[ $setting['id'] ] );
|
1249 |
+
|
1250 |
+
// Remove old CSS from dynamic.css.
|
1251 |
+
} else {
|
1252 |
+
ot_remove_old_css( $setting['id'] );
|
1253 |
+
}
|
1254 |
+
}
|
1255 |
+
}
|
1256 |
+
}
|
1257 |
+
}
|
1258 |
}
|
1259 |
|
1260 |
+
if ( ! function_exists( 'ot_import' ) ) {
|
1261 |
+
|
1262 |
+
/**
|
1263 |
+
* Import before the screen is displayed.
|
1264 |
+
*
|
1265 |
+
* @access public
|
1266 |
+
* @since 2.0
|
1267 |
+
*/
|
1268 |
+
function ot_import() {
|
1269 |
+
|
1270 |
+
// Check and verify import settings nonce.
|
1271 |
+
if ( isset( $_POST['import_settings_nonce'] ) && wp_verify_nonce( $_POST['import_settings_nonce'], 'import_settings_form' ) ) { // phpcs:ignore
|
1272 |
+
|
1273 |
+
// Default message.
|
1274 |
+
$message = 'failed';
|
1275 |
+
|
1276 |
+
$settings = isset( $_POST['import_settings'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_settings'] ) ) ) : array();
|
1277 |
+
|
1278 |
+
if ( is_array( $settings ) && ! empty( $settings ) ) {
|
1279 |
+
|
1280 |
+
$settings_safe = ot_validate_settings( $settings );
|
1281 |
+
|
1282 |
+
// Save & show success message.
|
1283 |
+
if ( is_array( $settings_safe ) ) {
|
1284 |
+
update_option( ot_settings_id(), $settings_safe );
|
1285 |
+
$message = 'success';
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
// Redirect back to self.
|
1290 |
+
wp_safe_redirect(
|
1291 |
+
esc_url_raw(
|
1292 |
+
add_query_arg(
|
1293 |
+
array(
|
1294 |
+
'action' => 'import-settings',
|
1295 |
+
'message' => $message,
|
1296 |
+
),
|
1297 |
+
wp_get_referer()
|
1298 |
+
)
|
1299 |
+
)
|
1300 |
+
);
|
1301 |
+
exit;
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
// Check and verify import theme options data nonce.
|
1305 |
+
if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) { // phpcs:ignore
|
1306 |
+
|
1307 |
+
// Default message.
|
1308 |
+
$message = 'failed';
|
1309 |
+
$options = isset( $_POST['import_data'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_data'] ) ) ) : array();
|
1310 |
+
|
1311 |
+
if ( $options ) {
|
1312 |
+
|
1313 |
+
$options_safe = array();
|
1314 |
|
1315 |
+
// Get settings array.
|
1316 |
+
$settings = get_option( ot_settings_id() );
|
1317 |
+
|
1318 |
+
// Has options.
|
1319 |
+
if ( is_array( $options ) ) {
|
1320 |
+
|
1321 |
+
// Validate options.
|
1322 |
+
if ( is_array( $settings ) ) {
|
1323 |
+
foreach ( $settings['settings'] as $setting ) {
|
1324 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
1325 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
1326 |
+
}
|
1327 |
+
}
|
1328 |
+
}
|
1329 |
+
|
1330 |
+
// Execute the action hook and pass the theme options to it.
|
1331 |
+
do_action( 'ot_before_theme_options_save', $options_safe );
|
1332 |
+
|
1333 |
+
// Update the option tree array.
|
1334 |
+
update_option( ot_options_id(), $options_safe );
|
1335 |
+
|
1336 |
+
$message = 'success';
|
1337 |
+
}
|
1338 |
+
}
|
1339 |
+
|
1340 |
+
// Redirect back to self.
|
1341 |
+
wp_safe_redirect(
|
1342 |
+
esc_url_raw(
|
1343 |
+
add_query_arg(
|
1344 |
+
array(
|
1345 |
+
'action' => 'import-data',
|
1346 |
+
'message' => $message,
|
1347 |
+
),
|
1348 |
+
wp_get_referer()
|
1349 |
+
)
|
1350 |
+
)
|
1351 |
+
);
|
1352 |
+
exit;
|
1353 |
+
}
|
1354 |
+
|
1355 |
+
// Check and verify import layouts nonce.
|
1356 |
+
if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) { // phpcs:ignore
|
1357 |
+
|
1358 |
+
// Default message.
|
1359 |
+
$message = 'failed';
|
1360 |
+
$layouts = isset( $_POST['import_layouts'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_layouts'] ) ) ) : array();
|
1361 |
+
|
1362 |
+
if ( $layouts ) {
|
1363 |
+
|
1364 |
+
// Get settings array.
|
1365 |
+
$settings = get_option( ot_settings_id() );
|
1366 |
+
|
1367 |
+
// Has layouts.
|
1368 |
+
if ( is_array( $layouts ) && ! empty( $layouts ) && ! empty( $layouts['active_layout'] ) ) {
|
1369 |
+
|
1370 |
+
$layouts_safe = array(
|
1371 |
+
'active_layout' => esc_attr( $layouts['active_layout'] ),
|
1372 |
+
);
|
1373 |
+
|
1374 |
+
// Validate options.
|
1375 |
+
if ( is_array( $settings ) ) {
|
1376 |
+
|
1377 |
+
foreach ( $layouts as $key => $value ) {
|
1378 |
+
|
1379 |
+
if ( 'active_layout' === $key ) {
|
1380 |
+
continue;
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
// Convert the options to an array.
|
1384 |
+
$options = ot_decode( $value );
|
1385 |
+
|
1386 |
+
$options_safe = array();
|
1387 |
+
|
1388 |
+
foreach ( $settings['settings'] as $setting ) {
|
1389 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
1390 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
1391 |
+
}
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
// Store the sanitized values for later.
|
1395 |
+
if ( $key === $layouts['active_layout'] ) {
|
1396 |
+
$new_options_safe = $options_safe;
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
$layouts_safe[ $key ] = ot_encode( $options_safe );
|
1400 |
+
}
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
// Update the option tree array with sanitized values.
|
1404 |
+
if ( isset( $new_options_safe ) ) {
|
1405 |
+
|
1406 |
+
// Execute the action hook and pass the theme options to it.
|
1407 |
+
do_action( 'ot_before_theme_options_save', $new_options_safe );
|
1408 |
+
|
1409 |
+
update_option( ot_options_id(), $new_options_safe );
|
1410 |
+
}
|
1411 |
+
|
1412 |
+
// Update the option tree layouts array.
|
1413 |
+
update_option( ot_layouts_id(), $layouts_safe );
|
1414 |
+
|
1415 |
+
$message = 'success';
|
1416 |
+
}
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
// Redirect back to self.
|
1420 |
+
wp_safe_redirect(
|
1421 |
+
esc_url_raw(
|
1422 |
+
add_query_arg(
|
1423 |
+
array(
|
1424 |
+
'action' => 'import-layouts',
|
1425 |
+
'message' => $message,
|
1426 |
+
),
|
1427 |
+
wp_get_referer()
|
1428 |
+
)
|
1429 |
+
)
|
1430 |
+
);
|
1431 |
+
exit;
|
1432 |
+
}
|
1433 |
+
|
1434 |
+
return false;
|
1435 |
+
}
|
1436 |
+
}
|
1437 |
|
1438 |
+
if ( ! function_exists( 'ot_export' ) ) {
|
|
|
|
|
1439 |
|
1440 |
+
/**
|
1441 |
+
* Export before the screen is displayed.
|
1442 |
+
*
|
1443 |
+
* @return void
|
1444 |
+
*
|
1445 |
+
* @access public
|
1446 |
+
* @since 2.0.8
|
1447 |
+
*/
|
1448 |
+
function ot_export() {
|
1449 |
+
|
1450 |
+
// Check and verify export settings file nonce.
|
1451 |
+
if ( isset( $_POST['export_settings_file_nonce'] ) && wp_verify_nonce( $_POST['export_settings_file_nonce'], 'export_settings_file_form' ) ) { // phpcs:ignore
|
1452 |
+
ot_export_php_settings_array();
|
1453 |
+
}
|
1454 |
+
}
|
1455 |
+
}
|
1456 |
|
1457 |
+
if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
|
1458 |
|
1459 |
+
/**
|
1460 |
+
* Export the Theme Mode theme-options.php
|
1461 |
+
*
|
1462 |
+
* @access public
|
1463 |
+
* @since 2.0.8
|
1464 |
+
*/
|
1465 |
+
function ot_export_php_settings_array() {
|
1466 |
+
|
1467 |
+
$content = '';
|
1468 |
+
$build_settings = '';
|
1469 |
+
$contextual_help = '';
|
1470 |
+
$sections = '';
|
1471 |
+
$settings = '';
|
1472 |
+
$option_tree_settings = get_option( ot_settings_id(), array() );
|
1473 |
+
|
1474 |
+
/**
|
1475 |
+
* Domain string helper.
|
1476 |
+
*
|
1477 |
+
* @param string $string A string.
|
1478 |
+
* @return string
|
1479 |
+
*/
|
1480 |
+
function ot_i18n_string( $string ) {
|
1481 |
+
if ( ! empty( $string ) && isset( $_POST['domain'] ) && ! empty( $_POST['domain'] ) ) { // phpcs:ignore
|
1482 |
+
$domain = str_replace( ' ', '-', trim( sanitize_text_field( wp_unslash( $_POST['domain'] ) ) ) ); // phpcs:ignore
|
1483 |
+
return "esc_html__( '$string', '$domain' )";
|
1484 |
+
}
|
1485 |
+
return "'$string'";
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
header( 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' );
|
1489 |
+
header( 'Pragma: no-cache ' );
|
1490 |
+
header( 'Content-Description: File Transfer' );
|
1491 |
+
header( 'Content-Disposition: attachment; filename="theme-options.php"' );
|
1492 |
+
header( 'Content-Type: application/octet-stream' );
|
1493 |
+
header( 'Content-Transfer-Encoding: binary' );
|
1494 |
+
|
1495 |
+
// Build contextual help content.
|
1496 |
+
if ( isset( $option_tree_settings['contextual_help']['content'] ) ) {
|
1497 |
+
$help = '';
|
1498 |
+
foreach ( $option_tree_settings['contextual_help']['content'] as $value ) {
|
1499 |
+
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1500 |
+
$_title = ot_i18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
|
1501 |
+
$_content = ot_i18n_string( isset( $value['content'] ) ? html_entity_decode( str_replace( "'", "\'", $value['content'] ) ) : '' );
|
1502 |
+
$help .= "
|
1503 |
+
array(
|
1504 |
+
'id' => '$_id',
|
1505 |
+
'title' => $_title,
|
1506 |
+
'content' => $_content,
|
1507 |
+
),";
|
1508 |
+
}
|
1509 |
+
$contextual_help = "
|
1510 |
+
'content' => array($help
|
1511 |
+
),";
|
1512 |
+
}
|
1513 |
+
|
1514 |
+
// Build contextual help sidebar.
|
1515 |
+
if ( isset( $option_tree_settings['contextual_help']['sidebar'] ) ) {
|
1516 |
+
$_sidebar = ot_i18n_string( html_entity_decode( str_replace( "'", "\'", $option_tree_settings['contextual_help']['sidebar'] ) ) );
|
1517 |
+
$contextual_help .= "
|
1518 |
+
'sidebar' => $_sidebar,";
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
// Check that $contexual_help has a value and add to $build_settings.
|
1522 |
+
if ( '' !== $contextual_help ) {
|
1523 |
+
$build_settings .= "
|
1524 |
+
'contextual_help' => array($contextual_help
|
1525 |
+
),";
|
1526 |
+
}
|
1527 |
+
|
1528 |
+
// Build sections.
|
1529 |
+
if ( isset( $option_tree_settings['sections'] ) ) {
|
1530 |
+
foreach ( $option_tree_settings['sections'] as $value ) {
|
1531 |
+
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1532 |
+
$_title = ot_i18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
|
1533 |
+
$sections .= "
|
1534 |
+
array(
|
1535 |
+
'id' => '$_id',
|
1536 |
+
'title' => $_title,
|
1537 |
+
),";
|
1538 |
+
}
|
1539 |
+
}
|
1540 |
+
|
1541 |
+
// Check that $sections has a value and add to $build_settings.
|
1542 |
+
if ( '' !== $sections ) {
|
1543 |
+
$build_settings .= "
|
1544 |
+
'sections' => array($sections
|
1545 |
+
)";
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
/* build settings */
|
1549 |
+
if ( isset( $option_tree_settings['settings'] ) ) {
|
1550 |
+
foreach ( $option_tree_settings['settings'] as $value ) {
|
1551 |
+
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1552 |
+
$_label = ot_i18n_string( isset( $value['label'] ) ? str_replace( "'", "\'", $value['label'] ) : '' );
|
1553 |
+
$_desc = ot_i18n_string( isset( $value['desc'] ) ? str_replace( "'", "\'", $value['desc'] ) : '' );
|
1554 |
+
$_std = isset( $value['std'] ) ? str_replace( "'", "\'", $value['std'] ) : '';
|
1555 |
+
$_type = isset( $value['type'] ) ? $value['type'] : '';
|
1556 |
+
$_section = isset( $value['section'] ) ? $value['section'] : '';
|
1557 |
+
$_rows = isset( $value['rows'] ) ? $value['rows'] : '';
|
1558 |
+
$_post_type = isset( $value['post_type'] ) ? $value['post_type'] : '';
|
1559 |
+
$_taxonomy = isset( $value['taxonomy'] ) ? $value['taxonomy'] : '';
|
1560 |
+
$_min_max_step = isset( $value['min_max_step'] ) ? $value['min_max_step'] : '';
|
1561 |
+
$_class = isset( $value['class'] ) ? $value['class'] : '';
|
1562 |
+
$_condition = isset( $value['condition'] ) ? $value['condition'] : '';
|
1563 |
+
$_operator = isset( $value['operator'] ) ? $value['operator'] : '';
|
1564 |
+
|
1565 |
+
$choices = '';
|
1566 |
+
if ( isset( $value['choices'] ) && ! empty( $value['choices'] ) ) {
|
1567 |
+
foreach ( $value['choices'] as $choice ) {
|
1568 |
+
$_choice_value = isset( $choice['value'] ) ? str_replace( "'", "\'", $choice['value'] ) : '';
|
1569 |
+
$_choice_label = ot_i18n_string( isset( $choice['label'] ) ? str_replace( "'", "\'", $choice['label'] ) : '' );
|
1570 |
+
$_choice_src = isset( $choice['src'] ) ? str_replace( "'", "\'", $choice['src'] ) : '';
|
1571 |
+
$choices .= "
|
1572 |
+
array(
|
1573 |
+
'value' => '$_choice_value',
|
1574 |
+
'label' => $_choice_label,
|
1575 |
+
'src' => '$_choice_src',
|
1576 |
+
),";
|
1577 |
+
}
|
1578 |
+
$choices = "
|
1579 |
+
'choices' => array($choices
|
1580 |
+
),";
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
$std = "'$_std'";
|
1584 |
+
if ( is_array( $_std ) ) {
|
1585 |
+
$std_array = array();
|
1586 |
+
foreach ( $_std as $_sk => $_sv ) {
|
1587 |
+
$std_array[] = "'$_sk' => '$_sv',";
|
1588 |
+
}
|
1589 |
+
$std = 'array(
|
1590 |
+
' . implode( ",\n", $std_array ) . '
|
1591 |
+
)';
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
$setting_settings = '';
|
1595 |
+
if ( isset( $value['settings'] ) && ! empty( $value['settings'] ) ) {
|
1596 |
+
foreach ( $value['settings'] as $setting ) {
|
1597 |
+
$_setting_id = isset( $setting['id'] ) ? $setting['id'] : '';
|
1598 |
+
$_setting_label = ot_i18n_string( isset( $setting['label'] ) ? str_replace( "'", "\'", $setting['label'] ) : '' );
|
1599 |
+
$_setting_desc = ot_i18n_string( isset( $setting['desc'] ) ? str_replace( "'", "\'", $setting['desc'] ) : '' );
|
1600 |
+
$_setting_std = isset( $setting['std'] ) ? $setting['std'] : '';
|
1601 |
+
$_setting_type = isset( $setting['type'] ) ? $setting['type'] : '';
|
1602 |
+
$_setting_rows = isset( $setting['rows'] ) ? $setting['rows'] : '';
|
1603 |
+
$_setting_post_type = isset( $setting['post_type'] ) ? $setting['post_type'] : '';
|
1604 |
+
$_setting_taxonomy = isset( $setting['taxonomy'] ) ? $setting['taxonomy'] : '';
|
1605 |
+
$_setting_min_max_step = isset( $setting['min_max_step'] ) ? $setting['min_max_step'] : '';
|
1606 |
+
$_setting_class = isset( $setting['class'] ) ? $setting['class'] : '';
|
1607 |
+
$_setting_condition = isset( $setting['condition'] ) ? $setting['condition'] : '';
|
1608 |
+
$_setting_operator = isset( $setting['operator'] ) ? $setting['operator'] : '';
|
1609 |
+
|
1610 |
+
$setting_choices = '';
|
1611 |
+
if ( isset( $setting['choices'] ) && ! empty( $setting['choices'] ) ) {
|
1612 |
+
foreach ( $setting['choices'] as $setting_choice ) {
|
1613 |
+
$_setting_choice_value = isset( $setting_choice['value'] ) ? $setting_choice['value'] : '';
|
1614 |
+
$_setting_choice_label = ot_i18n_string( isset( $setting_choice['label'] ) ? str_replace( "'", "\'", $setting_choice['label'] ) : '' );
|
1615 |
+
$_setting_choice_src = isset( $setting_choice['src'] ) ? str_replace( "'", "\'", $setting_choice['src'] ) : '';
|
1616 |
+
$setting_choices .= "
|
1617 |
+
array(
|
1618 |
+
'value' => '$_setting_choice_value',
|
1619 |
+
'label' => $_setting_choice_label,
|
1620 |
+
'src' => '$_setting_choice_src',
|
1621 |
+
),";
|
1622 |
+
}
|
1623 |
+
$setting_choices = "
|
1624 |
+
'choices' => array($setting_choices
|
1625 |
+
),";
|
1626 |
+
}
|
1627 |
+
|
1628 |
+
$setting_std = "'$_setting_std'";
|
1629 |
+
if ( is_array( $_setting_std ) ) {
|
1630 |
+
$setting_std_array = array();
|
1631 |
+
foreach ( $_setting_std as $_ssk => $_ssv ) {
|
1632 |
+
$setting_std_array[] = "'$_ssk' => '$_ssv'";
|
1633 |
+
}
|
1634 |
+
$setting_std = 'array(
|
1635 |
+
' . implode( ",\n", $setting_std_array ) . '
|
1636 |
+
)';
|
1637 |
+
}
|
1638 |
+
|
1639 |
+
$setting_settings .= "
|
1640 |
+
array(
|
1641 |
+
'id' => '$_setting_id',
|
1642 |
+
'label' => $_setting_label,
|
1643 |
+
'desc' => $_setting_desc,
|
1644 |
+
'std' => $setting_std,
|
1645 |
+
'type' => '$_setting_type',
|
1646 |
+
'rows' => '$_setting_rows',
|
1647 |
+
'post_type' => '$_setting_post_type',
|
1648 |
+
'taxonomy' => '$_setting_taxonomy',
|
1649 |
+
'min_max_step' => '$_setting_min_max_step',
|
1650 |
+
'class' => '$_setting_class',
|
1651 |
+
'condition' => '$_setting_condition',
|
1652 |
+
'operator' => '$_setting_operator',$setting_choices
|
1653 |
+
),";
|
1654 |
+
}
|
1655 |
+
$setting_settings = "
|
1656 |
+
'settings' => array( $setting_settings
|
1657 |
+
),";
|
1658 |
+
}
|
1659 |
+
$settings .= "
|
1660 |
+
array(
|
1661 |
+
'id' => '$_id',
|
1662 |
+
'label' => $_label,
|
1663 |
+
'desc' => $_desc,
|
1664 |
+
'std' => $std,
|
1665 |
+
'type' => '$_type',
|
1666 |
+
'section' => '$_section',
|
1667 |
+
'rows' => '$_rows',
|
1668 |
+
'post_type' => '$_post_type',
|
1669 |
+
'taxonomy' => '$_taxonomy',
|
1670 |
+
'min_max_step' => '$_min_max_step',
|
1671 |
+
'class' => '$_class',
|
1672 |
+
'condition' => '$_condition',
|
1673 |
+
'operator' => '$_operator',$choices$setting_settings
|
1674 |
+
),";
|
1675 |
+
}
|
1676 |
+
}
|
1677 |
+
|
1678 |
+
// Check that $sections has a value and add to $build_settings.
|
1679 |
+
if ( '' !== $settings ) {
|
1680 |
+
$build_settings .= ",
|
1681 |
+
'settings' => array($settings
|
1682 |
+
)";
|
1683 |
+
}
|
1684 |
+
|
1685 |
+
$content .= "<?php
|
1686 |
+
/**
|
1687 |
+
* Initialize the custom theme options.
|
1688 |
+
*/
|
1689 |
+
add_action( 'init', 'custom_theme_options' );
|
1690 |
|
1691 |
+
/**
|
1692 |
+
* Build the custom settings & update OptionTree.
|
1693 |
+
*/
|
1694 |
+
function custom_theme_options() {
|
1695 |
+
|
1696 |
+
// OptionTree is not loaded yet, or this is not an admin request.
|
1697 |
+
if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() ) {
|
1698 |
+
return false;
|
1699 |
+
}
|
1700 |
+
|
1701 |
+
// Get a copy of the saved settings array.
|
1702 |
+
\$saved_settings = get_option( ot_settings_id(), array() );
|
1703 |
+
|
1704 |
+
// Custom settings array that will eventually be passes to the OptionTree Settings API Class.
|
1705 |
+
\$custom_settings = array($build_settings
|
1706 |
+
);
|
1707 |
+
|
1708 |
+
// Allow settings to be filtered before saving.
|
1709 |
+
\$custom_settings = apply_filters( ot_settings_id() . '_args', \$custom_settings );
|
1710 |
+
|
1711 |
+
// Settings are not the same update the DB.
|
1712 |
+
if ( \$saved_settings !== \$custom_settings ) {
|
1713 |
+
update_option( ot_settings_id(), \$custom_settings );
|
1714 |
+
}
|
1715 |
+
|
1716 |
+
// Lets OptionTree know the UI Builder is being overridden.
|
1717 |
+
global \$ot_has_custom_theme_options;
|
1718 |
+
\$ot_has_custom_theme_options = true;
|
1719 |
+
}
|
1720 |
+
";
|
1721 |
|
1722 |
+
echo $content; // phpcs:ignore
|
1723 |
+
die();
|
1724 |
+
}
|
1725 |
+
}
|
1726 |
|
1727 |
+
if ( ! function_exists( 'ot_save_settings' ) ) {
|
1728 |
|
1729 |
+
/**
|
1730 |
+
* Save settings array before the screen is displayed.
|
1731 |
+
*
|
1732 |
+
* @return bool Redirects on save, false on failure.
|
1733 |
+
*
|
1734 |
+
* @access public
|
1735 |
+
* @since 2.0
|
1736 |
+
*/
|
1737 |
+
function ot_save_settings() {
|
1738 |
+
|
1739 |
+
// Check and verify import settings nonce.
|
1740 |
+
if ( isset( $_POST['option_tree_settings_nonce'] ) && wp_verify_nonce( $_POST['option_tree_settings_nonce'], 'option_tree_settings_form' ) ) { // phpcs:ignore
|
1741 |
+
|
1742 |
+
// Settings value.
|
1743 |
+
$settings = isset( $_POST[ ot_settings_id() ] ) ? wp_unslash( $_POST[ ot_settings_id() ] ) : array(); // phpcs:ignore
|
1744 |
+
|
1745 |
+
$settings_safe = ot_validate_settings( $settings );
|
1746 |
+
|
1747 |
+
// Default message.
|
1748 |
+
$message = 'failed';
|
1749 |
+
|
1750 |
+
// Save & show success message.
|
1751 |
+
if ( ! empty( $settings_safe ) ) {
|
1752 |
+
ot_wpml_unregister( $settings_safe );
|
1753 |
+
|
1754 |
+
update_option( ot_settings_id(), $settings_safe );
|
1755 |
+
$message = 'success';
|
1756 |
+
}
|
1757 |
+
|
1758 |
+
// Redirect.
|
1759 |
+
wp_safe_redirect(
|
1760 |
+
esc_url_raw(
|
1761 |
+
add_query_arg(
|
1762 |
+
array(
|
1763 |
+
'action' => 'save-settings',
|
1764 |
+
'message' => $message,
|
1765 |
+
),
|
1766 |
+
wp_get_referer()
|
1767 |
+
)
|
1768 |
+
)
|
1769 |
+
);
|
1770 |
+
exit;
|
1771 |
+
}
|
1772 |
+
|
1773 |
+
return false;
|
1774 |
+
}
|
1775 |
+
}
|
1776 |
|
1777 |
+
if ( ! function_exists( 'ot_wpml_unregister' ) ) {
|
1778 |
+
|
1779 |
+
/**
|
1780 |
+
* Unregister WPML strings based on settings changing.
|
1781 |
+
*
|
1782 |
+
* @param array $settings The array of settings.
|
1783 |
+
*
|
1784 |
+
* @access public
|
1785 |
+
* @since 2.7.0
|
1786 |
+
*/
|
1787 |
+
function ot_wpml_unregister( $settings = array() ) {
|
1788 |
+
|
1789 |
+
// WPML unregister ID's that have been removed.
|
1790 |
+
if ( function_exists( 'icl_unregister_string' ) ) {
|
1791 |
+
|
1792 |
+
$current = get_option( ot_settings_id() );
|
1793 |
+
$options = get_option( ot_options_id() );
|
1794 |
+
|
1795 |
+
if ( isset( $current['settings'] ) ) {
|
1796 |
+
|
1797 |
+
// Empty ID array.
|
1798 |
+
$new_ids = array();
|
1799 |
+
|
1800 |
+
// Build the WPML IDs array.
|
1801 |
+
foreach ( $settings['settings'] as $setting ) {
|
1802 |
+
if ( $setting['id'] ) {
|
1803 |
+
$new_ids[] = $setting['id'];
|
1804 |
+
}
|
1805 |
+
}
|
1806 |
+
|
1807 |
+
// Remove missing IDs from WPML.
|
1808 |
+
foreach ( $current['settings'] as $current_setting ) {
|
1809 |
+
if ( ! in_array( $current_setting['id'], $new_ids, true ) ) {
|
1810 |
+
if ( ! empty( $options[ $current_setting['id'] ] ) && in_array( $current_setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
1811 |
+
foreach ( $options[ $current_setting['id'] ] as $key => $value ) {
|
1812 |
+
foreach ( $value as $ckey => $cvalue ) {
|
1813 |
+
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
1814 |
+
}
|
1815 |
+
}
|
1816 |
+
} elseif ( ! empty( $options[ $current_setting['id'] ] ) && 'social-icons' === $current_setting['type'] ) {
|
1817 |
+
foreach ( $options[ $current_setting['id'] ] as $key => $value ) {
|
1818 |
+
foreach ( $value as $ckey => $cvalue ) {
|
1819 |
+
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
1820 |
+
}
|
1821 |
+
}
|
1822 |
+
} else {
|
1823 |
+
ot_wpml_unregister_string( $current_setting['id'] );
|
1824 |
+
}
|
1825 |
+
}
|
1826 |
+
}
|
1827 |
+
}
|
1828 |
+
}
|
1829 |
+
}
|
1830 |
+
}
|
1831 |
|
1832 |
+
if ( ! function_exists( 'ot_validate_settings' ) ) {
|
1833 |
|
1834 |
+
/**
|
1835 |
+
* Helper function to validate all settings.
|
1836 |
+
*
|
1837 |
+
* This includes the `sections`, `settings`, and `contextual_help` arrays.
|
1838 |
+
*
|
1839 |
+
* @param array $settings The array of settings.
|
1840 |
+
*
|
1841 |
+
* @return array
|
1842 |
+
*
|
1843 |
+
* @access public
|
1844 |
+
* @since 2.7.0
|
1845 |
+
*/
|
1846 |
+
function ot_validate_settings( $settings = array() ) {
|
1847 |
|
1848 |
+
// Store the validated settings.
|
1849 |
+
$settings_safe = array();
|
1850 |
|
1851 |
+
// Validate sections.
|
1852 |
+
if ( isset( $settings['sections'] ) ) {
|
1853 |
|
1854 |
+
// Fix numeric keys since drag & drop will change them.
|
1855 |
+
$settings['sections'] = array_values( $settings['sections'] );
|
1856 |
|
1857 |
+
// Loop through sections.
|
1858 |
+
foreach ( $settings['sections'] as $k => $section ) {
|
1859 |
|
1860 |
+
// Skip if missing values.
|
1861 |
+
if ( ( ! isset( $section['title'] ) && ! isset( $section['id'] ) ) || ( '' === $section['title'] && '' === $section['id'] ) ) {
|
1862 |
+
continue;
|
1863 |
+
}
|
|
|
|
|
1864 |
|
1865 |
+
// Validate label.
|
1866 |
+
if ( '' !== $section['title'] ) {
|
1867 |
+
$settings_safe['sections'][ $k ]['title'] = wp_kses_post( $section['title'] );
|
1868 |
+
}
|
1869 |
|
1870 |
+
// Missing title set to unfiltered ID.
|
1871 |
+
if ( ! isset( $section['title'] ) || '' === $section['title'] ) {
|
1872 |
|
1873 |
+
$settings_safe['sections'][ $k ]['title'] = wp_kses_post( $section['id'] );
|
|
|
1874 |
|
1875 |
+
// Missing ID set to title.
|
1876 |
+
} elseif ( ! isset( $section['id'] ) || '' === $section['id'] ) {
|
1877 |
|
1878 |
+
$settings_safe['id'] = wp_kses_post( $section['title'] );
|
1879 |
+
}
|
1880 |
|
1881 |
+
// Sanitize ID once everything has been checked first.
|
1882 |
+
$settings_safe['sections'][ $k ]['id'] = ot_sanitize_option_id( wp_kses_post( $section['id'] ) );
|
1883 |
+
}
|
1884 |
+
}
|
1885 |
|
1886 |
+
// Validate settings by looping over array as many times as it takes.
|
1887 |
+
if ( isset( $settings['settings'] ) ) {
|
1888 |
+
$settings_safe['settings'] = ot_validate_settings_array( $settings['settings'] );
|
1889 |
+
}
|
1890 |
|
1891 |
+
// Validate contextual_help.
|
1892 |
+
if ( isset( $settings['contextual_help']['content'] ) ) {
|
1893 |
|
1894 |
+
// Fix numeric keys since drag & drop will change them.
|
1895 |
+
$settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] );
|
1896 |
|
1897 |
+
// Loop through content.
|
1898 |
+
foreach ( $settings['contextual_help']['content'] as $k => $content ) {
|
1899 |
|
1900 |
+
// Skip if missing values.
|
1901 |
+
if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' === $content['title'] && '' === $content['id'] ) ) {
|
1902 |
+
continue;
|
1903 |
+
}
|
1904 |
|
1905 |
+
// Validate label.
|
1906 |
+
if ( '' !== $content['title'] ) {
|
1907 |
+
$settings_safe['contextual_help']['content'][ $k ]['title'] = wp_kses_post( $content['title'] );
|
1908 |
+
}
|
1909 |
|
1910 |
+
// Missing title set to unfiltered ID.
|
1911 |
+
if ( ! isset( $content['title'] ) || '' === $content['title'] ) {
|
|
|
1912 |
|
1913 |
+
$settings_safe['contextual_help']['content'][ $k ]['title'] = wp_kses_post( $content['id'] );
|
1914 |
|
1915 |
+
// Missing ID set to title.
|
1916 |
+
} elseif ( ! isset( $content['id'] ) || '' === $content['id'] ) {
|
1917 |
|
1918 |
+
$content['id'] = wp_kses_post( $content['title'] );
|
1919 |
+
}
|
1920 |
|
1921 |
+
// Sanitize ID once everything has been checked first.
|
1922 |
+
$settings_safe['contextual_help']['content'][ $k ]['id'] = ot_sanitize_option_id( wp_kses_post( $content['id'] ) );
|
1923 |
|
1924 |
+
// Validate textarea description.
|
1925 |
+
if ( isset( $content['content'] ) ) {
|
1926 |
+
$settings_safe['contextual_help']['content'][ $k ]['content'] = wp_kses_post( $content['content'] );
|
1927 |
+
}
|
1928 |
+
}
|
1929 |
+
}
|
1930 |
|
1931 |
+
// Validate contextual_help sidebar.
|
1932 |
+
if ( isset( $settings['contextual_help']['sidebar'] ) ) {
|
1933 |
+
$settings_safe['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] );
|
1934 |
+
}
|
1935 |
|
1936 |
+
return $settings_safe;
|
1937 |
+
}
|
1938 |
+
}
|
1939 |
|
1940 |
+
if ( ! function_exists( 'ot_validate_settings_array' ) ) {
|
|
|
|
|
|
|
|
|
|
|
1941 |
|
1942 |
+
/**
|
1943 |
+
* Validate a settings array before save.
|
1944 |
+
*
|
1945 |
+
* This function will loop over a settings array as many
|
1946 |
+
* times as it takes to validate every sub setting.
|
1947 |
+
*
|
1948 |
+
* @param array $settings The array of settings.
|
1949 |
+
* @return array
|
1950 |
+
*
|
1951 |
+
* @access public
|
1952 |
+
* @since 2.0
|
1953 |
+
* @updated 2.7.0
|
1954 |
+
*/
|
1955 |
+
function ot_validate_settings_array( $settings = array() ) {
|
1956 |
+
|
1957 |
+
// Field types mapped to their sanitize function.
|
1958 |
+
$field_types = array(
|
1959 |
+
'label' => 'wp_kses_post',
|
1960 |
+
'id' => 'ot_sanitize_option_id',
|
1961 |
+
'type' => 'sanitize_text_field',
|
1962 |
+
'desc' => 'wp_kses_post',
|
1963 |
+
'settings' => 'ot_validate_settings_array',
|
1964 |
+
'choices' => array(
|
1965 |
+
'label' => 'wp_kses_post',
|
1966 |
+
'value' => 'sanitize_text_field',
|
1967 |
+
'src' => 'sanitize_text_field',
|
1968 |
+
),
|
1969 |
+
'std' => 'sanitize_text_field',
|
1970 |
+
'rows' => 'absint',
|
1971 |
+
'post_type' => 'sanitize_text_field',
|
1972 |
+
'taxonomy' => 'sanitize_text_field',
|
1973 |
+
'min_max_step' => 'sanitize_text_field',
|
1974 |
+
'class' => 'sanitize_text_field',
|
1975 |
+
'condition' => 'sanitize_text_field',
|
1976 |
+
'operator' => 'sanitize_text_field',
|
1977 |
+
'section' => 'sanitize_text_field',
|
1978 |
+
);
|
1979 |
+
|
1980 |
+
// Store the validated settings.
|
1981 |
+
$settings_safe = array();
|
1982 |
+
|
1983 |
+
// Validate settings.
|
1984 |
+
if ( 0 < count( $settings ) ) {
|
1985 |
+
|
1986 |
+
// Fix numeric keys since drag & drop will change them.
|
1987 |
+
$settings = array_values( $settings );
|
1988 |
+
|
1989 |
+
// Loop through settings.
|
1990 |
+
foreach ( $settings as $sk => $setting ) {
|
1991 |
+
foreach ( $setting as $fk => $field ) {
|
1992 |
+
if ( isset( $field_types[ $fk ] ) ) {
|
1993 |
+
if ( 'choices' === $fk ) {
|
1994 |
+
foreach ( $field as $ck => $choice ) {
|
1995 |
+
foreach ( $choice as $vk => $value ) {
|
1996 |
+
$settings_safe[ $sk ][ $fk ][ $ck ][ $vk ] = call_user_func( $field_types[ $fk ][ $vk ], $value );
|
1997 |
+
}
|
1998 |
+
}
|
1999 |
+
} elseif ( 'std' === $fk && is_array( $field ) ) {
|
2000 |
+
$callback = $field_types[ $fk ];
|
2001 |
+
$array_map = function( $item ) use ( $array_map, $callback ) {
|
2002 |
+
return is_array( $item ) ? array_map( $array_map, $item ) : call_user_func( $callback, $item );
|
2003 |
+
};
|
2004 |
+
|
2005 |
+
$settings_safe[ $sk ][ $fk ] = array_map( $array_map, $field );
|
2006 |
+
} else {
|
2007 |
+
$sanitized = call_user_func( $field_types[ $fk ], $field );
|
2008 |
+
if ( 'rows' === $fk && 0 === $sanitized ) {
|
2009 |
+
$sanitized = '';
|
2010 |
+
}
|
2011 |
+
$settings_safe[ $sk ][ $fk ] = $sanitized;
|
2012 |
+
}
|
2013 |
+
}
|
2014 |
+
}
|
2015 |
+
}
|
2016 |
+
}
|
2017 |
+
|
2018 |
+
return $settings_safe;
|
2019 |
+
}
|
2020 |
+
}
|
2021 |
|
2022 |
+
if ( ! function_exists( 'ot_modify_layouts' ) ) {
|
2023 |
|
2024 |
+
/**
|
2025 |
+
* Save layouts array before the screen is displayed.
|
2026 |
+
*
|
2027 |
+
* @return bool Returns false or redirects.
|
2028 |
+
*
|
2029 |
+
* @access public
|
2030 |
+
* @since 2.0
|
2031 |
+
*/
|
2032 |
+
function ot_modify_layouts() {
|
2033 |
|
2034 |
+
// Check and verify modify layouts nonce.
|
2035 |
+
if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) { // phpcs:ignore
|
2036 |
|
2037 |
+
// Previous layouts value.
|
2038 |
+
$option_tree_layouts = get_option( ot_layouts_id() );
|
2039 |
+
|
2040 |
+
// New layouts value.
|
2041 |
+
$layouts = isset( $_POST[ ot_layouts_id() ] ) ? $_POST[ ot_layouts_id() ] : ''; // phpcs:ignore
|
2042 |
+
|
2043 |
+
// Rebuild layout array.
|
2044 |
+
$rebuild = array();
|
2045 |
+
|
2046 |
+
// Validate layouts.
|
2047 |
+
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
2048 |
+
|
2049 |
+
// Setup active layout.
|
2050 |
+
if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
|
2051 |
+
$rebuild['active_layout'] = $layouts['active_layout'];
|
2052 |
+
}
|
2053 |
+
|
2054 |
+
// Add new and overwrite active layout.
|
2055 |
+
if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
|
2056 |
+
$rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] );
|
2057 |
+
$rebuild[ $rebuild['active_layout'] ] = ot_encode( get_option( ot_options_id(), array() ) );
|
2058 |
+
}
|
2059 |
+
|
2060 |
+
$first_layout = '';
|
2061 |
+
|
2062 |
+
// Loop through layouts.
|
2063 |
+
foreach ( $layouts as $key => $layout ) {
|
2064 |
+
|
2065 |
+
// Skip over active layout key.
|
2066 |
+
if ( 'active_layout' === $key ) {
|
2067 |
+
continue;
|
2068 |
+
}
|
2069 |
+
|
2070 |
+
// Check if the key exists then set value.
|
2071 |
+
if ( isset( $option_tree_layouts[ $key ] ) && ! empty( $option_tree_layouts[ $key ] ) ) {
|
2072 |
+
$rebuild[ $key ] = $option_tree_layouts[ $key ];
|
2073 |
+
if ( '' === $first_layout ) {
|
2074 |
+
$first_layout = $key;
|
2075 |
+
}
|
2076 |
+
}
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[ $rebuild['active_layout'] ] ) && ! empty( $first_layout ) ) {
|
2080 |
+
$rebuild['active_layout'] = $first_layout;
|
2081 |
+
}
|
2082 |
+
}
|
2083 |
+
|
2084 |
+
// Default message.
|
2085 |
+
$message = 'failed';
|
2086 |
+
|
2087 |
+
// Save & show success message.
|
2088 |
+
if ( is_array( $rebuild ) && 1 < count( $rebuild ) ) {
|
2089 |
+
|
2090 |
+
$options = ot_decode( $rebuild[ $rebuild['active_layout'] ] );
|
2091 |
+
|
2092 |
+
if ( $options ) {
|
2093 |
+
|
2094 |
+
$options_safe = array();
|
2095 |
+
|
2096 |
+
// Get settings array.
|
2097 |
+
$settings = get_option( ot_settings_id() );
|
2098 |
+
|
2099 |
+
// Has options.
|
2100 |
+
if ( is_array( $options ) ) {
|
2101 |
+
|
2102 |
+
// Validate options.
|
2103 |
+
if ( is_array( $settings ) ) {
|
2104 |
+
foreach ( $settings['settings'] as $setting ) {
|
2105 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
2106 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
2107 |
+
}
|
2108 |
+
}
|
2109 |
+
}
|
2110 |
+
|
2111 |
+
// Execute the action hook and pass the theme options to it.
|
2112 |
+
do_action( 'ot_before_theme_options_save', $options_safe );
|
2113 |
+
|
2114 |
+
update_option( ot_options_id(), $options_safe );
|
2115 |
+
}
|
2116 |
+
}
|
2117 |
+
|
2118 |
+
// Rebuild the layouts.
|
2119 |
+
update_option( ot_layouts_id(), $rebuild );
|
2120 |
+
|
2121 |
+
// Change message.
|
2122 |
+
$message = 'success';
|
2123 |
+
} elseif ( 1 >= count( $rebuild ) ) {
|
2124 |
+
|
2125 |
+
// Delete layouts option.
|
2126 |
+
delete_option( ot_layouts_id() );
|
2127 |
+
|
2128 |
+
// Change message.
|
2129 |
+
$message = 'deleted';
|
2130 |
+
}
|
2131 |
+
|
2132 |
+
// Redirect.
|
2133 |
+
if ( isset( $_REQUEST['page'] ) && apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) === $_REQUEST['page'] ) {
|
2134 |
+
$query_args = esc_url_raw(
|
2135 |
+
add_query_arg(
|
2136 |
+
array(
|
2137 |
+
'settings-updated' => 'layout',
|
2138 |
+
),
|
2139 |
+
remove_query_arg(
|
2140 |
+
array(
|
2141 |
+
'action',
|
2142 |
+
'message',
|
2143 |
+
),
|
2144 |
+
wp_get_referer()
|
2145 |
+
)
|
2146 |
+
)
|
2147 |
+
);
|
2148 |
+
} else {
|
2149 |
+
$query_args = esc_url_raw(
|
2150 |
+
add_query_arg(
|
2151 |
+
array(
|
2152 |
+
'action' => 'save-layouts',
|
2153 |
+
'message' => $message,
|
2154 |
+
),
|
2155 |
+
wp_get_referer()
|
2156 |
+
)
|
2157 |
+
);
|
2158 |
+
}
|
2159 |
+
wp_safe_redirect( $query_args );
|
2160 |
+
exit;
|
2161 |
+
}
|
2162 |
+
|
2163 |
+
return false;
|
2164 |
+
}
|
2165 |
+
}
|
2166 |
|
2167 |
+
if ( ! function_exists( 'ot_alert_message' ) ) {
|
2168 |
|
2169 |
+
/**
|
2170 |
+
* Helper function to display alert messages.
|
2171 |
+
*
|
2172 |
+
* @param array $page Page array.
|
2173 |
+
* @return mixed
|
2174 |
+
*
|
2175 |
+
* @access public
|
2176 |
+
* @since 2.0
|
2177 |
+
*/
|
2178 |
+
function ot_alert_message( $page = array() ) {
|
2179 |
|
2180 |
+
if ( empty( $page ) ) {
|
2181 |
+
return false;
|
2182 |
+
}
|
|
|
2183 |
|
2184 |
+
$before = apply_filters( 'ot_before_page_messages', '', $page );
|
|
|
2185 |
|
2186 |
+
if ( $before ) {
|
2187 |
+
return $before;
|
2188 |
+
}
|
2189 |
|
2190 |
+
$action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : ''; // phpcs:ignore
|
2191 |
+
$message = isset( $_REQUEST['message'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['message'] ) ) : ''; // phpcs:ignore
|
2192 |
+
$updated = isset( $_REQUEST['settings-updated'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings-updated'] ) ) : ''; // phpcs:ignore
|
2193 |
|
2194 |
+
if ( 'save-settings' === $action ) {
|
2195 |
|
2196 |
+
if ( 'success' === $message ) {
|
2197 |
|
2198 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Settings updated.', 'option-tree' ) . '</p></div>';
|
2199 |
|
2200 |
+
} elseif ( 'failed' === $message ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2201 |
|
2202 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Settings could not be saved.', 'option-tree' ) . '</p></div>';
|
|
|
2203 |
|
2204 |
+
}
|
2205 |
+
} elseif ( 'import-xml' === $action || 'import-settings' === $action ) {
|
2206 |
|
2207 |
+
if ( 'success' === $message ) {
|
2208 |
|
2209 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Settings Imported.', 'option-tree' ) . '</p></div>';
|
2210 |
|
2211 |
+
} elseif ( 'failed' === $message ) {
|
2212 |
|
2213 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Settings could not be imported.', 'option-tree' ) . '</p></div>';
|
2214 |
|
2215 |
+
}
|
2216 |
+
} elseif ( 'import-data' === $action ) {
|
|
|
2217 |
|
2218 |
+
if ( 'success' === $message ) {
|
2219 |
|
2220 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Data Imported.', 'option-tree' ) . '</p></div>';
|
2221 |
|
2222 |
+
} elseif ( 'failed' === $message ) {
|
|
|
|
|
|
|
2223 |
|
2224 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Data could not be imported.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
2225 |
|
2226 |
+
}
|
2227 |
+
} elseif ( 'import-layouts' === $action ) {
|
2228 |
|
2229 |
+
if ( 'success' === $message ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2230 |
|
2231 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layouts Imported.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
2232 |
|
2233 |
+
} elseif ( 'failed' === $message ) {
|
2234 |
|
2235 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Layouts could not be imported.', 'option-tree' ) . '</p></div>';
|
2236 |
|
2237 |
+
}
|
2238 |
+
} elseif ( 'save-layouts' === $action ) {
|
|
|
|
|
2239 |
|
2240 |
+
if ( 'success' === $message ) {
|
2241 |
|
2242 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layouts Updated.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2243 |
|
2244 |
+
} elseif ( 'failed' === $message ) {
|
|
|
2245 |
|
2246 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Layouts could not be updated.', 'option-tree' ) . '</p></div>';
|
2247 |
|
2248 |
+
} elseif ( 'deleted' === $message ) {
|
2249 |
|
2250 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layouts have been deleted.', 'option-tree' ) . '</p></div>';
|
2251 |
|
2252 |
+
}
|
2253 |
+
} elseif ( 'layout' === $updated ) {
|
2254 |
|
2255 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layout activated.', 'option-tree' ) . '</p></div>';
|
2256 |
|
2257 |
+
} elseif ( 'reset' === $action ) {
|
|
|
|
|
2258 |
|
2259 |
+
return '<div id="message" class="updated fade below-h2"><p>' . $page['reset_message'] . '</p></div>';
|
2260 |
|
2261 |
+
}
|
2262 |
|
2263 |
+
do_action( 'ot_custom_page_messages', $page );
|
|
|
|
|
|
|
|
|
|
|
2264 |
|
2265 |
+
if ( 'true' === $updated || true === $updated ) {
|
2266 |
+
return '<div id="message" class="updated fade below-h2"><p>' . $page['updated_message'] . '</p></div>';
|
2267 |
+
}
|
|
|
2268 |
|
2269 |
+
return false;
|
2270 |
+
}
|
2271 |
+
}
|
2272 |
|
2273 |
+
if ( ! function_exists( 'ot_option_types_array' ) ) {
|
|
|
|
|
2274 |
|
2275 |
+
/**
|
2276 |
+
* Setup the default option types.
|
2277 |
+
*
|
2278 |
+
* The returned option types are filterable so you can add your own.
|
2279 |
+
* This is not a task for a beginner as you'll need to add the function
|
2280 |
+
* that displays the option to the user and validate the saved data.
|
2281 |
+
*
|
2282 |
+
* @return array
|
2283 |
+
*
|
2284 |
+
* @access public
|
2285 |
+
* @since 2.0
|
2286 |
+
*/
|
2287 |
+
function ot_option_types_array() {
|
2288 |
+
|
2289 |
+
return apply_filters(
|
2290 |
+
'ot_option_types_array',
|
2291 |
+
array(
|
2292 |
+
'background' => esc_html__( 'Background', 'option-tree' ),
|
2293 |
+
'border' => esc_html__( 'Border', 'option-tree' ),
|
2294 |
+
'box-shadow' => esc_html__( 'Box Shadow', 'option-tree' ),
|
2295 |
+
'category-checkbox' => esc_html__( 'Category Checkbox', 'option-tree' ),
|
2296 |
+
'category-select' => esc_html__( 'Category Select', 'option-tree' ),
|
2297 |
+
'checkbox' => esc_html__( 'Checkbox', 'option-tree' ),
|
2298 |
+
'colorpicker' => esc_html__( 'Colorpicker', 'option-tree' ),
|
2299 |
+
'colorpicker-opacity' => esc_html__( 'Colorpicker Opacity', 'option-tree' ),
|
2300 |
+
'css' => esc_html__( 'CSS', 'option-tree' ),
|
2301 |
+
'custom-post-type-checkbox' => esc_html__( 'Custom Post Type Checkbox', 'option-tree' ),
|
2302 |
+
'custom-post-type-select' => esc_html__( 'Custom Post Type Select', 'option-tree' ),
|
2303 |
+
'date-picker' => esc_html__( 'Date Picker', 'option-tree' ),
|
2304 |
+
'date-time-picker' => esc_html__( 'Date Time Picker', 'option-tree' ),
|
2305 |
+
'dimension' => esc_html__( 'Dimension', 'option-tree' ),
|
2306 |
+
'gallery' => esc_html__( 'Gallery', 'option-tree' ),
|
2307 |
+
'google-fonts' => esc_html__( 'Google Fonts', 'option-tree' ),
|
2308 |
+
'javascript' => esc_html__( 'JavaScript', 'option-tree' ),
|
2309 |
+
'link-color' => esc_html__( 'Link Color', 'option-tree' ),
|
2310 |
+
'list-item' => esc_html__( 'List Item', 'option-tree' ),
|
2311 |
+
'measurement' => esc_html__( 'Measurement', 'option-tree' ),
|
2312 |
+
'numeric-slider' => esc_html__( 'Numeric Slider', 'option-tree' ),
|
2313 |
+
'on-off' => esc_html__( 'On/Off', 'option-tree' ),
|
2314 |
+
'page-checkbox' => esc_html__( 'Page Checkbox', 'option-tree' ),
|
2315 |
+
'page-select' => esc_html__( 'Page Select', 'option-tree' ),
|
2316 |
+
'post-checkbox' => esc_html__( 'Post Checkbox', 'option-tree' ),
|
2317 |
+
'post-select' => esc_html__( 'Post Select', 'option-tree' ),
|
2318 |
+
'radio' => esc_html__( 'Radio', 'option-tree' ),
|
2319 |
+
'radio-image' => esc_html__( 'Radio Image', 'option-tree' ),
|
2320 |
+
'select' => esc_html__( 'Select', 'option-tree' ),
|
2321 |
+
'sidebar-select' => esc_html__( 'Sidebar Select', 'option-tree' ),
|
2322 |
+
'slider' => esc_html__( 'Slider', 'option-tree' ),
|
2323 |
+
'social-links' => esc_html__( 'Social Links', 'option-tree' ),
|
2324 |
+
'spacing' => esc_html__( 'Spacing', 'option-tree' ),
|
2325 |
+
'tab' => esc_html__( 'Tab', 'option-tree' ),
|
2326 |
+
'tag-checkbox' => esc_html__( 'Tag Checkbox', 'option-tree' ),
|
2327 |
+
'tag-select' => esc_html__( 'Tag Select', 'option-tree' ),
|
2328 |
+
'taxonomy-checkbox' => esc_html__( 'Taxonomy Checkbox', 'option-tree' ),
|
2329 |
+
'taxonomy-select' => esc_html__( 'Taxonomy Select', 'option-tree' ),
|
2330 |
+
'text' => esc_html__( 'Text', 'option-tree' ),
|
2331 |
+
'textarea' => esc_html__( 'Textarea', 'option-tree' ),
|
2332 |
+
'textarea-simple' => esc_html__( 'Textarea Simple', 'option-tree' ),
|
2333 |
+
'textblock' => esc_html__( 'Textblock', 'option-tree' ),
|
2334 |
+
'textblock-titled' => esc_html__( 'Textblock Titled', 'option-tree' ),
|
2335 |
+
'typography' => esc_html__( 'Typography', 'option-tree' ),
|
2336 |
+
'upload' => esc_html__( 'Upload', 'option-tree' ),
|
2337 |
+
)
|
2338 |
+
);
|
2339 |
+
}
|
2340 |
+
}
|
2341 |
|
2342 |
+
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
2343 |
|
2344 |
+
/**
|
2345 |
+
* Map old option types for rebuilding XML and Table data.
|
2346 |
+
*
|
2347 |
+
* @param string $type The old option type.
|
2348 |
+
* @return string The new option type
|
2349 |
+
*
|
2350 |
+
* @access public
|
2351 |
+
* @since 2.0
|
2352 |
+
*/
|
2353 |
+
function ot_map_old_option_types( $type = '' ) {
|
2354 |
+
|
2355 |
+
if ( empty( $type ) ) {
|
2356 |
+
return 'text';
|
2357 |
+
}
|
2358 |
+
|
2359 |
+
$types = array(
|
2360 |
+
'background' => 'background',
|
2361 |
+
'category' => 'category-select',
|
2362 |
+
'categories' => 'category-checkbox',
|
2363 |
+
'checkbox' => 'checkbox',
|
2364 |
+
'colorpicker' => 'colorpicker',
|
2365 |
+
'css' => 'css',
|
2366 |
+
'custom_post' => 'custom-post-type-select',
|
2367 |
+
'custom_posts' => 'custom-post-type-checkbox',
|
2368 |
+
'input' => 'text',
|
2369 |
+
'image' => 'upload',
|
2370 |
+
'measurement' => 'measurement',
|
2371 |
+
'page' => 'page-select',
|
2372 |
+
'pages' => 'page-checkbox',
|
2373 |
+
'post' => 'post-select',
|
2374 |
+
'posts' => 'post-checkbox',
|
2375 |
+
'radio' => 'radio',
|
2376 |
+
'select' => 'select',
|
2377 |
+
'slider' => 'slider',
|
2378 |
+
'tag' => 'tag-select',
|
2379 |
+
'tags' => 'tag-checkbox',
|
2380 |
+
'textarea' => 'textarea',
|
2381 |
+
'textblock' => 'textblock',
|
2382 |
+
'typography' => 'typography',
|
2383 |
+
'upload' => 'upload',
|
2384 |
+
);
|
2385 |
+
|
2386 |
+
if ( isset( $types[ $type ] ) ) {
|
2387 |
+
return $types[ $type ];
|
2388 |
+
}
|
2389 |
+
|
2390 |
+
return false;
|
2391 |
+
}
|
2392 |
+
}
|
2393 |
|
2394 |
+
if ( ! function_exists( 'ot_google_font_stack' ) ) {
|
2395 |
+
|
2396 |
+
/**
|
2397 |
+
* Filters the typography font-family to add Google fonts dynamically.
|
2398 |
+
*
|
2399 |
+
* @param array $families An array of all recognized font families.
|
2400 |
+
* @param string $field_id ID of the field being filtered.
|
2401 |
+
*
|
2402 |
+
* @return array
|
2403 |
+
*
|
2404 |
+
* @access public
|
2405 |
+
* @since 2.5.0
|
2406 |
+
*/
|
2407 |
+
function ot_google_font_stack( $families, $field_id ) {
|
2408 |
+
|
2409 |
+
if ( ! is_array( $families ) ) {
|
2410 |
+
return array();
|
2411 |
+
}
|
2412 |
+
|
2413 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
2414 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
2415 |
+
|
2416 |
+
if ( ! empty( $ot_set_google_fonts ) ) {
|
2417 |
+
foreach ( $ot_set_google_fonts as $id => $sets ) {
|
2418 |
+
foreach ( $sets as $value ) {
|
2419 |
+
$family = isset( $value['family'] ) ? $value['family'] : '';
|
2420 |
+
if ( $family && isset( $ot_google_fonts[ $family ] ) ) {
|
2421 |
+
$spaces = explode( ' ', $ot_google_fonts[ $family ]['family'] );
|
2422 |
+
$font_stack = count( $spaces ) > 1 ? '"' . $ot_google_fonts[ $family ]['family'] . '"' : $ot_google_fonts[ $family ]['family'];
|
2423 |
+
$families[ $family ] = apply_filters( 'ot_google_font_stack', $font_stack, $family, $field_id );
|
2424 |
+
}
|
2425 |
+
}
|
2426 |
+
}
|
2427 |
+
}
|
2428 |
+
|
2429 |
+
return $families;
|
2430 |
+
}
|
2431 |
+
|
2432 |
+
add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
|
2433 |
+
}
|
2434 |
|
2435 |
+
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
|
|
|
|
|
|
2436 |
|
2437 |
+
/**
|
2438 |
+
* Recognized font families
|
2439 |
+
*
|
2440 |
+
* Returns an array of all recognized font families.
|
2441 |
+
* Keys are intended to be stored in the database
|
2442 |
+
* while values are ready for display in html.
|
2443 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2444 |
+
*
|
2445 |
+
* @uses apply_filters()
|
2446 |
+
*
|
2447 |
+
* @param string $field_id ID that's passed to the filter.
|
2448 |
+
*
|
2449 |
+
* @return array
|
2450 |
+
*
|
2451 |
+
* @access public
|
2452 |
+
* @since 1.1.8
|
2453 |
+
* @updated 2.0
|
2454 |
+
*/
|
2455 |
+
function ot_recognized_font_families( $field_id ) {
|
2456 |
+
|
2457 |
+
$families = array(
|
2458 |
+
'arial' => 'Arial',
|
2459 |
+
'georgia' => 'Georgia',
|
2460 |
+
'helvetica' => 'Helvetica',
|
2461 |
+
'palatino' => 'Palatino',
|
2462 |
+
'tahoma' => 'Tahoma',
|
2463 |
+
'times' => '"Times New Roman", sans-serif',
|
2464 |
+
'trebuchet' => 'Trebuchet',
|
2465 |
+
'verdana' => 'Verdana',
|
2466 |
+
);
|
2467 |
+
|
2468 |
+
return apply_filters( 'ot_recognized_font_families', $families, $field_id );
|
2469 |
+
}
|
2470 |
+
}
|
2471 |
|
2472 |
+
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
|
2473 |
|
2474 |
+
/**
|
2475 |
+
* Recognized font sizes
|
2476 |
+
*
|
2477 |
+
* Returns an array of all recognized font sizes.
|
2478 |
+
*
|
2479 |
+
* @uses apply_filters()
|
2480 |
+
*
|
2481 |
+
* @param string $field_id ID that's passed to the filter.
|
2482 |
+
*
|
2483 |
+
* @return array
|
2484 |
+
*
|
2485 |
+
* @access public
|
2486 |
+
* @since 2.0.12
|
2487 |
+
*/
|
2488 |
+
function ot_recognized_font_sizes( $field_id ) {
|
2489 |
+
|
2490 |
+
$range = ot_range(
|
2491 |
+
apply_filters( 'ot_font_size_low_range', 0, $field_id ),
|
2492 |
+
apply_filters( 'ot_font_size_high_range', 150, $field_id ),
|
2493 |
+
apply_filters( 'ot_font_size_range_interval', 1, $field_id )
|
2494 |
+
);
|
2495 |
+
|
2496 |
+
$unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
|
2497 |
+
|
2498 |
+
foreach ( $range as $k => $v ) {
|
2499 |
+
$range[ $k ] = $v . $unit;
|
2500 |
+
}
|
2501 |
+
|
2502 |
+
return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
|
2503 |
+
}
|
2504 |
+
}
|
2505 |
|
2506 |
+
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
|
2507 |
|
2508 |
+
/**
|
2509 |
+
* Recognized font styles
|
2510 |
+
*
|
2511 |
+
* Returns an array of all recognized font styles.
|
2512 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2513 |
+
*
|
2514 |
+
* @uses apply_filters()
|
2515 |
+
*
|
2516 |
+
* @param string $field_id ID that's passed to the filter.
|
2517 |
+
*
|
2518 |
+
* @return array
|
2519 |
+
*
|
2520 |
+
* @access public
|
2521 |
+
* @since 1.1.8
|
2522 |
+
* @updated 2.0
|
2523 |
+
*/
|
2524 |
+
function ot_recognized_font_styles( $field_id ) {
|
2525 |
+
|
2526 |
+
return apply_filters(
|
2527 |
+
'ot_recognized_font_styles',
|
2528 |
+
array(
|
2529 |
+
'normal' => 'Normal',
|
2530 |
+
'italic' => 'Italic',
|
2531 |
+
'oblique' => 'Oblique',
|
2532 |
+
'inherit' => 'Inherit',
|
2533 |
+
),
|
2534 |
+
$field_id
|
2535 |
+
);
|
2536 |
+
}
|
2537 |
}
|
2538 |
|
2539 |
+
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
|
2540 |
+
|
2541 |
+
/**
|
2542 |
+
* Recognized font variants
|
2543 |
+
*
|
2544 |
+
* Returns an array of all recognized font variants.
|
2545 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2546 |
+
*
|
2547 |
+
* @uses apply_filters()
|
2548 |
+
*
|
2549 |
+
* @param string $field_id ID that's passed to the filter.
|
2550 |
+
*
|
2551 |
+
* @return array
|
2552 |
+
*
|
2553 |
+
* @access public
|
2554 |
+
* @since 1.1.8
|
2555 |
+
* @updated 2.0
|
2556 |
+
*/
|
2557 |
+
function ot_recognized_font_variants( $field_id ) {
|
2558 |
+
|
2559 |
+
return apply_filters(
|
2560 |
+
'ot_recognized_font_variants',
|
2561 |
+
array(
|
2562 |
+
'normal' => 'Normal',
|
2563 |
+
'small-caps' => 'Small Caps',
|
2564 |
+
'inherit' => 'Inherit',
|
2565 |
+
),
|
2566 |
+
$field_id
|
2567 |
+
);
|
2568 |
+
}
|
2569 |
+
}
|
2570 |
|
2571 |
+
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
|
|
2572 |
|
2573 |
+
/**
|
2574 |
+
* Recognized font weights
|
2575 |
+
*
|
2576 |
+
* Returns an array of all recognized font weights.
|
2577 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2578 |
+
*
|
2579 |
+
* @uses apply_filters()
|
2580 |
+
*
|
2581 |
+
* @param string $field_id ID that's passed to the filter.
|
2582 |
+
*
|
2583 |
+
* @return array
|
2584 |
+
*
|
2585 |
+
* @access public
|
2586 |
+
* @since 1.1.8
|
2587 |
+
* @updated 2.0
|
2588 |
+
*/
|
2589 |
+
function ot_recognized_font_weights( $field_id ) {
|
2590 |
+
|
2591 |
+
return apply_filters(
|
2592 |
+
'ot_recognized_font_weights',
|
2593 |
+
array(
|
2594 |
+
'normal' => 'Normal',
|
2595 |
+
'bold' => 'Bold',
|
2596 |
+
'bolder' => 'Bolder',
|
2597 |
+
'lighter' => 'Lighter',
|
2598 |
+
'100' => '100',
|
2599 |
+
'200' => '200',
|
2600 |
+
'300' => '300',
|
2601 |
+
'400' => '400',
|
2602 |
+
'500' => '500',
|
2603 |
+
'600' => '600',
|
2604 |
+
'700' => '700',
|
2605 |
+
'800' => '800',
|
2606 |
+
'900' => '900',
|
2607 |
+
'inherit' => 'Inherit',
|
2608 |
+
),
|
2609 |
+
$field_id
|
2610 |
+
);
|
2611 |
+
}
|
2612 |
+
}
|
2613 |
|
2614 |
+
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
|
|
|
2615 |
|
2616 |
+
/**
|
2617 |
+
* Recognized letter spacing
|
2618 |
+
*
|
2619 |
+
* Returns an array of all recognized line heights.
|
2620 |
+
*
|
2621 |
+
* @uses apply_filters()
|
2622 |
+
*
|
2623 |
+
* @param string $field_id ID that's passed to the filter.
|
2624 |
+
*
|
2625 |
+
* @return array
|
2626 |
+
*
|
2627 |
+
* @access public
|
2628 |
+
* @since 2.0.12
|
2629 |
+
*/
|
2630 |
+
function ot_recognized_letter_spacing( $field_id ) {
|
2631 |
+
|
2632 |
+
$range = ot_range(
|
2633 |
+
apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ),
|
2634 |
+
apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ),
|
2635 |
+
apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
|
2636 |
+
);
|
2637 |
+
|
2638 |
+
$unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
|
2639 |
+
|
2640 |
+
foreach ( $range as $k => $v ) {
|
2641 |
+
$range[ $k ] = $v . $unit;
|
2642 |
+
}
|
2643 |
+
|
2644 |
+
return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
|
2645 |
+
}
|
2646 |
+
}
|
2647 |
|
2648 |
+
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
|
|
|
2649 |
|
2650 |
+
/**
|
2651 |
+
* Recognized line heights
|
2652 |
+
*
|
2653 |
+
* Returns an array of all recognized line heights.
|
2654 |
+
*
|
2655 |
+
* @uses apply_filters()
|
2656 |
+
*
|
2657 |
+
* @param string $field_id ID that's passed to the filter.
|
2658 |
+
*
|
2659 |
+
* @return array
|
2660 |
+
*
|
2661 |
+
* @access public
|
2662 |
+
* @since 2.0.12
|
2663 |
+
*/
|
2664 |
+
function ot_recognized_line_heights( $field_id ) {
|
2665 |
+
|
2666 |
+
$range = ot_range(
|
2667 |
+
apply_filters( 'ot_line_height_low_range', 0, $field_id ),
|
2668 |
+
apply_filters( 'ot_line_height_high_range', 150, $field_id ),
|
2669 |
+
apply_filters( 'ot_line_height_range_interval', 1, $field_id )
|
2670 |
+
);
|
2671 |
+
|
2672 |
+
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
|
2673 |
+
|
2674 |
+
foreach ( $range as $k => $v ) {
|
2675 |
+
$range[ $k ] = $v . $unit;
|
2676 |
+
}
|
2677 |
+
|
2678 |
+
return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
|
2679 |
+
}
|
2680 |
+
}
|
2681 |
|
2682 |
+
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
|
|
|
|
2683 |
|
2684 |
+
/**
|
2685 |
+
* Recognized text decorations
|
2686 |
+
*
|
2687 |
+
* Returns an array of all recognized text decorations.
|
2688 |
+
* Keys are intended to be stored in the database
|
2689 |
+
* while values are ready for display in html.
|
2690 |
+
*
|
2691 |
+
* @uses apply_filters()
|
2692 |
+
*
|
2693 |
+
* @param string $field_id ID that's passed to the filter.
|
2694 |
+
*
|
2695 |
+
* @return array
|
2696 |
+
*
|
2697 |
+
* @access public
|
2698 |
+
* @since 2.0.10
|
2699 |
+
*/
|
2700 |
+
function ot_recognized_text_decorations( $field_id ) {
|
2701 |
+
|
2702 |
+
return apply_filters(
|
2703 |
+
'ot_recognized_text_decorations',
|
2704 |
+
array(
|
2705 |
+
'blink' => 'Blink',
|
2706 |
+
'inherit' => 'Inherit',
|
2707 |
+
'line-through' => 'Line Through',
|
2708 |
+
'none' => 'None',
|
2709 |
+
'overline' => 'Overline',
|
2710 |
+
'underline' => 'Underline',
|
2711 |
+
),
|
2712 |
+
$field_id
|
2713 |
+
);
|
2714 |
+
}
|
2715 |
+
}
|
2716 |
|
2717 |
+
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
|
|
|
|
|
|
|
|
2718 |
|
2719 |
+
/**
|
2720 |
+
* Recognized text transformations
|
2721 |
+
*
|
2722 |
+
* Returns an array of all recognized text transformations.
|
2723 |
+
* Keys are intended to be stored in the database
|
2724 |
+
* while values are ready for display in html.
|
2725 |
+
*
|
2726 |
+
* @uses apply_filters()
|
2727 |
+
*
|
2728 |
+
* @param string $field_id ID that's passed to the filter.
|
2729 |
+
*
|
2730 |
+
* @return array
|
2731 |
+
*
|
2732 |
+
* @access public
|
2733 |
+
* @since 2.0.10
|
2734 |
+
*/
|
2735 |
+
function ot_recognized_text_transformations( $field_id ) {
|
2736 |
+
|
2737 |
+
return apply_filters(
|
2738 |
+
'ot_recognized_text_transformations',
|
2739 |
+
array(
|
2740 |
+
'capitalize' => 'Capitalize',
|
2741 |
+
'inherit' => 'Inherit',
|
2742 |
+
'lowercase' => 'Lowercase',
|
2743 |
+
'none' => 'None',
|
2744 |
+
'uppercase' => 'Uppercase',
|
2745 |
+
),
|
2746 |
+
$field_id
|
2747 |
+
);
|
2748 |
+
}
|
2749 |
+
}
|
2750 |
|
2751 |
+
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
2752 |
|
2753 |
+
/**
|
2754 |
+
* Recognized background repeat
|
2755 |
+
*
|
2756 |
+
* Returns an array of all recognized background repeat values.
|
2757 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2758 |
+
*
|
2759 |
+
* @uses apply_filters()
|
2760 |
+
*
|
2761 |
+
* @param string $field_id ID that's passed to the filter.
|
2762 |
+
*
|
2763 |
+
* @return array
|
2764 |
+
*
|
2765 |
+
* @access public
|
2766 |
+
* @since 1.1.8
|
2767 |
+
* @updated 2.0
|
2768 |
+
*/
|
2769 |
+
function ot_recognized_background_repeat( $field_id ) {
|
2770 |
+
|
2771 |
+
return apply_filters(
|
2772 |
+
'ot_recognized_background_repeat',
|
2773 |
+
array(
|
2774 |
+
'no-repeat' => 'No Repeat',
|
2775 |
+
'repeat' => 'Repeat All',
|
2776 |
+
'repeat-x' => 'Repeat Horizontally',
|
2777 |
+
'repeat-y' => 'Repeat Vertically',
|
2778 |
+
'inherit' => 'Inherit',
|
2779 |
+
),
|
2780 |
+
$field_id
|
2781 |
+
);
|
2782 |
+
}
|
2783 |
}
|
2784 |
|
2785 |
+
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2786 |
|
2787 |
+
/**
|
2788 |
+
* Recognized background attachment
|
2789 |
+
*
|
2790 |
+
* Returns an array of all recognized background attachment values.
|
2791 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2792 |
+
*
|
2793 |
+
* @uses apply_filters()
|
2794 |
+
*
|
2795 |
+
* @param string $field_id ID that's passed to the filter.
|
2796 |
+
*
|
2797 |
+
* @return array
|
2798 |
+
*
|
2799 |
+
* @access public
|
2800 |
+
* @since 1.1.8
|
2801 |
+
* @updated 2.0
|
2802 |
+
*/
|
2803 |
+
function ot_recognized_background_attachment( $field_id ) {
|
2804 |
+
|
2805 |
+
return apply_filters(
|
2806 |
+
'ot_recognized_background_attachment',
|
2807 |
+
array(
|
2808 |
+
'fixed' => 'Fixed',
|
2809 |
+
'scroll' => 'Scroll',
|
2810 |
+
'inherit' => 'Inherit',
|
2811 |
+
),
|
2812 |
+
$field_id
|
2813 |
+
);
|
2814 |
+
}
|
2815 |
+
}
|
2816 |
|
2817 |
+
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
|
|
|
2818 |
|
2819 |
+
/**
|
2820 |
+
* Recognized background position
|
2821 |
+
*
|
2822 |
+
* Returns an array of all recognized background position values.
|
2823 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2824 |
+
*
|
2825 |
+
* @uses apply_filters()
|
2826 |
+
*
|
2827 |
+
* @param string $field_id ID that's passed to the filter.
|
2828 |
+
*
|
2829 |
+
* @return array
|
2830 |
+
*
|
2831 |
+
* @access public
|
2832 |
+
* @since 1.1.8
|
2833 |
+
* @updated 2.0
|
2834 |
+
*/
|
2835 |
+
function ot_recognized_background_position( $field_id ) {
|
2836 |
+
|
2837 |
+
return apply_filters(
|
2838 |
+
'ot_recognized_background_position',
|
2839 |
+
array(
|
2840 |
+
'left top' => 'Left Top',
|
2841 |
+
'left center' => 'Left Center',
|
2842 |
+
'left bottom' => 'Left Bottom',
|
2843 |
+
'center top' => 'Center Top',
|
2844 |
+
'center center' => 'Center Center',
|
2845 |
+
'center bottom' => 'Center Bottom',
|
2846 |
+
'right top' => 'Right Top',
|
2847 |
+
'right center' => 'Right Center',
|
2848 |
+
'right bottom' => 'Right Bottom',
|
2849 |
+
),
|
2850 |
+
$field_id
|
2851 |
+
);
|
2852 |
+
|
2853 |
+
}
|
2854 |
+
}
|
2855 |
|
2856 |
+
if ( ! function_exists( 'ot_recognized_border_style_types' ) ) {
|
|
|
2857 |
|
2858 |
+
/**
|
2859 |
+
* Returns an array of all available border style types.
|
2860 |
+
*
|
2861 |
+
* @uses apply_filters()
|
2862 |
+
*
|
2863 |
+
* @param string $field_id ID that's passed to the filter.
|
2864 |
+
*
|
2865 |
+
* @return array
|
2866 |
+
*
|
2867 |
+
* @access public
|
2868 |
+
* @since 2.5.0
|
2869 |
+
*/
|
2870 |
+
function ot_recognized_border_style_types( $field_id ) {
|
2871 |
+
|
2872 |
+
return apply_filters(
|
2873 |
+
'ot_recognized_border_style_types',
|
2874 |
+
array(
|
2875 |
+
'hidden' => 'Hidden',
|
2876 |
+
'dashed' => 'Dashed',
|
2877 |
+
'solid' => 'Solid',
|
2878 |
+
'double' => 'Double',
|
2879 |
+
'groove' => 'Groove',
|
2880 |
+
'ridge' => 'Ridge',
|
2881 |
+
'inset' => 'Inset',
|
2882 |
+
'outset' => 'Outset',
|
2883 |
+
),
|
2884 |
+
$field_id
|
2885 |
+
);
|
2886 |
+
|
2887 |
+
}
|
2888 |
+
}
|
2889 |
|
2890 |
+
if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) {
|
|
|
2891 |
|
2892 |
+
/**
|
2893 |
+
* Returns an array of all available border unit types.
|
2894 |
+
*
|
2895 |
+
* @uses apply_filters()
|
2896 |
+
*
|
2897 |
+
* @param string $field_id ID that's passed to the filter.
|
2898 |
+
*
|
2899 |
+
* @return array
|
2900 |
+
*
|
2901 |
+
* @access public
|
2902 |
+
* @since 2.5.0
|
2903 |
+
*/
|
2904 |
+
function ot_recognized_border_unit_types( $field_id ) {
|
2905 |
+
|
2906 |
+
return apply_filters(
|
2907 |
+
'ot_recognized_border_unit_types',
|
2908 |
+
array(
|
2909 |
+
'px' => 'px',
|
2910 |
+
'%' => '%',
|
2911 |
+
'em' => 'em',
|
2912 |
+
'pt' => 'pt',
|
2913 |
+
),
|
2914 |
+
$field_id
|
2915 |
+
);
|
2916 |
+
}
|
2917 |
+
}
|
2918 |
|
2919 |
+
if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) {
|
|
|
2920 |
|
2921 |
+
/**
|
2922 |
+
* Returns an array of all available dimension unit types.
|
2923 |
+
*
|
2924 |
+
* @uses apply_filters()
|
2925 |
+
*
|
2926 |
+
* @param string $field_id ID that's passed to the filter.
|
2927 |
+
*
|
2928 |
+
* @return array
|
2929 |
+
*
|
2930 |
+
* @access public
|
2931 |
+
* @since 2.5.0
|
2932 |
+
*/
|
2933 |
+
function ot_recognized_dimension_unit_types( $field_id = '' ) {
|
2934 |
+
|
2935 |
+
return apply_filters(
|
2936 |
+
'ot_recognized_dimension_unit_types',
|
2937 |
+
array(
|
2938 |
+
'px' => 'px',
|
2939 |
+
'%' => '%',
|
2940 |
+
'em' => 'em',
|
2941 |
+
'pt' => 'pt',
|
2942 |
+
),
|
2943 |
+
$field_id
|
2944 |
+
);
|
2945 |
+
}
|
2946 |
+
}
|
2947 |
|
2948 |
+
if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) {
|
2949 |
|
2950 |
+
/**
|
2951 |
+
* Returns an array of all available spacing unit types.
|
2952 |
+
*
|
2953 |
+
* @uses apply_filters()
|
2954 |
+
*
|
2955 |
+
* @param string $field_id ID that's passed to the filter.
|
2956 |
+
*
|
2957 |
+
* @return array
|
2958 |
+
*
|
2959 |
+
* @access public
|
2960 |
+
* @since 2.5.0
|
2961 |
+
*/
|
2962 |
+
function ot_recognized_spacing_unit_types( $field_id ) {
|
2963 |
+
|
2964 |
+
return apply_filters(
|
2965 |
+
'ot_recognized_spacing_unit_types',
|
2966 |
+
array(
|
2967 |
+
'px' => 'px',
|
2968 |
+
'%' => '%',
|
2969 |
+
'em' => 'em',
|
2970 |
+
'pt' => 'pt',
|
2971 |
+
),
|
2972 |
+
$field_id
|
2973 |
+
);
|
2974 |
+
|
2975 |
+
}
|
2976 |
+
}
|
2977 |
|
2978 |
+
if ( ! function_exists( 'ot_recognized_google_font_families' ) ) {
|
|
|
2979 |
|
2980 |
+
/**
|
2981 |
+
* Recognized Google font families
|
2982 |
+
*
|
2983 |
+
* @uses apply_filters()
|
2984 |
+
*
|
2985 |
+
* @param string $field_id ID that's passed to the filter.
|
2986 |
+
*
|
2987 |
+
* @return array
|
2988 |
+
*
|
2989 |
+
* @access public
|
2990 |
+
* @since 2.5.0
|
2991 |
+
*/
|
2992 |
+
function ot_recognized_google_font_families( $field_id ) {
|
2993 |
+
|
2994 |
+
$families = array();
|
2995 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
2996 |
+
|
2997 |
+
// Forces an array rebuild when we switch themes.
|
2998 |
+
if ( empty( $ot_google_fonts ) ) {
|
2999 |
+
$ot_google_fonts = ot_fetch_google_fonts( true, true );
|
3000 |
+
}
|
3001 |
+
|
3002 |
+
foreach ( (array) $ot_google_fonts as $key => $item ) {
|
3003 |
+
|
3004 |
+
if ( isset( $item['family'] ) ) {
|
3005 |
+
$families[ $key ] = $item['family'];
|
3006 |
+
}
|
3007 |
+
}
|
3008 |
+
|
3009 |
+
return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
|
3010 |
+
}
|
3011 |
+
}
|
3012 |
|
3013 |
+
if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) {
|
3014 |
|
3015 |
+
/**
|
3016 |
+
* Recognized Google font variants
|
3017 |
+
*
|
3018 |
+
* @uses apply_filters()
|
3019 |
+
*
|
3020 |
+
* @param string $field_id ID that's passed to the filter.
|
3021 |
+
* @param string $family The font family.
|
3022 |
+
*
|
3023 |
+
* @return array
|
3024 |
+
*
|
3025 |
+
* @access public
|
3026 |
+
* @since 2.5.0
|
3027 |
+
*/
|
3028 |
+
function ot_recognized_google_font_variants( $field_id, $family ) {
|
3029 |
+
|
3030 |
+
$variants = array();
|
3031 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3032 |
+
|
3033 |
+
if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
|
3034 |
+
$variants = $ot_google_fonts[ $family ]['variants'];
|
3035 |
+
}
|
3036 |
+
|
3037 |
+
return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family );
|
3038 |
+
}
|
3039 |
+
}
|
3040 |
|
3041 |
+
if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
|
3042 |
|
3043 |
+
/**
|
3044 |
+
* Recognized Google font subsets
|
3045 |
+
*
|
3046 |
+
* @uses apply_filters()
|
3047 |
+
*
|
3048 |
+
* @param string $field_id ID that's passed to the filter.
|
3049 |
+
* @param string $family The font family.
|
3050 |
+
*
|
3051 |
+
* @return array
|
3052 |
+
*
|
3053 |
+
* @access public
|
3054 |
+
* @since 2.5.0
|
3055 |
+
*/
|
3056 |
+
function ot_recognized_google_font_subsets( $field_id, $family ) {
|
3057 |
+
|
3058 |
+
$subsets = array();
|
3059 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3060 |
+
|
3061 |
+
if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
|
3062 |
+
$subsets = $ot_google_fonts[ $family ]['subsets'];
|
3063 |
+
}
|
3064 |
+
|
3065 |
+
return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family );
|
3066 |
+
}
|
3067 |
+
}
|
3068 |
|
3069 |
+
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
|
|
|
3070 |
|
3071 |
+
/**
|
3072 |
+
* Measurement Units
|
3073 |
+
*
|
3074 |
+
* Returns an array of all available unit types.
|
3075 |
+
* Renamed in version 2.0 to avoid name collisions.
|
3076 |
+
*
|
3077 |
+
* @uses apply_filters()
|
3078 |
+
*
|
3079 |
+
* @param string $field_id ID that's passed to the filter.
|
3080 |
+
*
|
3081 |
+
* @return array
|
3082 |
+
*
|
3083 |
+
* @access public
|
3084 |
+
* @since 1.1.8
|
3085 |
+
* @since 2.0
|
3086 |
+
*/
|
3087 |
+
function ot_measurement_unit_types( $field_id = '' ) {
|
3088 |
+
|
3089 |
+
return apply_filters(
|
3090 |
+
'ot_measurement_unit_types',
|
3091 |
+
array(
|
3092 |
+
'px' => 'px',
|
3093 |
+
'%' => '%',
|
3094 |
+
'em' => 'em',
|
3095 |
+
'pt' => 'pt',
|
3096 |
+
),
|
3097 |
+
$field_id
|
3098 |
+
);
|
3099 |
+
|
3100 |
+
}
|
3101 |
+
}
|
3102 |
|
3103 |
+
if ( ! function_exists( 'ot_radio_images' ) ) {
|
3104 |
|
3105 |
+
/**
|
3106 |
+
* Radio Images default array.
|
3107 |
+
*
|
3108 |
+
* Returns an array of all available radio images.
|
3109 |
+
* You can filter this function to change the images
|
3110 |
+
* on a per option basis.
|
3111 |
+
*
|
3112 |
+
* @uses apply_filters()
|
3113 |
+
*
|
3114 |
+
* @param string $field_id ID that's passed to the filter.
|
3115 |
+
*
|
3116 |
+
* @return array
|
3117 |
+
*
|
3118 |
+
* @access public
|
3119 |
+
* @since 2.0
|
3120 |
+
*/
|
3121 |
+
function ot_radio_images( $field_id ) {
|
3122 |
+
|
3123 |
+
return apply_filters(
|
3124 |
+
'ot_radio_images',
|
3125 |
+
array(
|
3126 |
+
array(
|
3127 |
+
'value' => 'left-sidebar',
|
3128 |
+
'label' => esc_html__( 'Left Sidebar', 'option-tree' ),
|
3129 |
+
'src' => OT_URL . 'assets/images/layout/left-sidebar.png',
|
3130 |
+
),
|
3131 |
+
array(
|
3132 |
+
'value' => 'right-sidebar',
|
3133 |
+
'label' => esc_html__( 'Right Sidebar', 'option-tree' ),
|
3134 |
+
'src' => OT_URL . 'assets/images/layout/right-sidebar.png',
|
3135 |
+
),
|
3136 |
+
array(
|
3137 |
+
'value' => 'full-width',
|
3138 |
+
'label' => esc_html__( 'Full Width (no sidebar)', 'option-tree' ),
|
3139 |
+
'src' => OT_URL . 'assets/images/layout/full-width.png',
|
3140 |
+
),
|
3141 |
+
array(
|
3142 |
+
'value' => 'dual-sidebar',
|
3143 |
+
'label' => esc_html__( 'Dual Sidebar', 'option-tree' ),
|
3144 |
+
'src' => OT_URL . 'assets/images/layout/dual-sidebar.png',
|
3145 |
+
),
|
3146 |
+
array(
|
3147 |
+
'value' => 'left-dual-sidebar',
|
3148 |
+
'label' => esc_html__( 'Left Dual Sidebar', 'option-tree' ),
|
3149 |
+
'src' => OT_URL . 'assets/images/layout/left-dual-sidebar.png',
|
3150 |
+
),
|
3151 |
+
array(
|
3152 |
+
'value' => 'right-dual-sidebar',
|
3153 |
+
'label' => esc_html__( 'Right Dual Sidebar', 'option-tree' ),
|
3154 |
+
'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png',
|
3155 |
+
),
|
3156 |
+
),
|
3157 |
+
$field_id
|
3158 |
+
);
|
3159 |
+
|
3160 |
+
}
|
3161 |
}
|
3162 |
|
3163 |
+
if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3164 |
|
3165 |
+
/**
|
3166 |
+
* Default List Item Settings array.
|
3167 |
+
*
|
3168 |
+
* Returns an array of the default list item settings.
|
3169 |
+
* You can filter this function to change the settings
|
3170 |
+
* on a per option basis.
|
3171 |
+
*
|
3172 |
+
* @uses apply_filters()
|
3173 |
+
*
|
3174 |
+
* @param string $field_id ID that's passed to the filter.
|
3175 |
+
*
|
3176 |
+
* @return array
|
3177 |
+
*
|
3178 |
+
* @access public
|
3179 |
+
* @since 2.0
|
3180 |
+
*/
|
3181 |
+
function ot_list_item_settings( $field_id ) {
|
3182 |
+
|
3183 |
+
$settings = apply_filters(
|
3184 |
+
'ot_list_item_settings',
|
3185 |
+
array(
|
3186 |
+
array(
|
3187 |
+
'id' => 'image',
|
3188 |
+
'label' => esc_html__( 'Image', 'option-tree' ),
|
3189 |
+
'desc' => '',
|
3190 |
+
'std' => '',
|
3191 |
+
'type' => 'upload',
|
3192 |
+
'rows' => '',
|
3193 |
+
'class' => '',
|
3194 |
+
'post_type' => '',
|
3195 |
+
'choices' => array(),
|
3196 |
+
),
|
3197 |
+
array(
|
3198 |
+
'id' => 'link',
|
3199 |
+
'label' => esc_html__( 'Link', 'option-tree' ),
|
3200 |
+
'desc' => '',
|
3201 |
+
'std' => '',
|
3202 |
+
'type' => 'text',
|
3203 |
+
'rows' => '',
|
3204 |
+
'class' => '',
|
3205 |
+
'post_type' => '',
|
3206 |
+
'choices' => array(),
|
3207 |
+
),
|
3208 |
+
array(
|
3209 |
+
'id' => 'description',
|
3210 |
+
'label' => esc_html__( 'Description', 'option-tree' ),
|
3211 |
+
'desc' => '',
|
3212 |
+
'std' => '',
|
3213 |
+
'type' => 'textarea-simple',
|
3214 |
+
'rows' => 10,
|
3215 |
+
'class' => '',
|
3216 |
+
'post_type' => '',
|
3217 |
+
'choices' => array(),
|
3218 |
+
),
|
3219 |
+
),
|
3220 |
+
$field_id
|
3221 |
+
);
|
3222 |
+
|
3223 |
+
return $settings;
|
3224 |
+
}
|
3225 |
+
}
|
3226 |
|
3227 |
+
if ( ! function_exists( 'ot_slider_settings' ) ) {
|
|
|
3228 |
|
3229 |
+
/**
|
3230 |
+
* Default Slider Settings array.
|
3231 |
+
*
|
3232 |
+
* Returns an array of the default slider settings.
|
3233 |
+
* You can filter this function to change the settings
|
3234 |
+
* on a per option basis.
|
3235 |
+
*
|
3236 |
+
* @uses apply_filters()
|
3237 |
+
*
|
3238 |
+
* @param string $field_id ID that's passed to the filter.
|
3239 |
+
*
|
3240 |
+
* @return array
|
3241 |
+
*
|
3242 |
+
* @access public
|
3243 |
+
* @since 2.0
|
3244 |
+
*/
|
3245 |
+
function ot_slider_settings( $field_id ) {
|
3246 |
+
|
3247 |
+
$settings = apply_filters(
|
3248 |
+
'image_slider_fields',
|
3249 |
+
array(
|
3250 |
+
array(
|
3251 |
+
'name' => 'image',
|
3252 |
+
'type' => 'image',
|
3253 |
+
'label' => esc_html__( 'Image', 'option-tree' ),
|
3254 |
+
'class' => '',
|
3255 |
+
),
|
3256 |
+
array(
|
3257 |
+
'name' => 'link',
|
3258 |
+
'type' => 'text',
|
3259 |
+
'label' => esc_html__( 'Link', 'option-tree' ),
|
3260 |
+
'class' => '',
|
3261 |
+
),
|
3262 |
+
array(
|
3263 |
+
'name' => 'description',
|
3264 |
+
'type' => 'textarea',
|
3265 |
+
'label' => esc_html__( 'Description', 'option-tree' ),
|
3266 |
+
'class' => '',
|
3267 |
+
),
|
3268 |
+
),
|
3269 |
+
$field_id
|
3270 |
+
);
|
3271 |
+
|
3272 |
+
// Fix the array keys, values, and just get it 2.0 ready.
|
3273 |
+
foreach ( $settings as $_k => $setting ) {
|
3274 |
+
|
3275 |
+
foreach ( $setting as $s_key => $s_value ) {
|
3276 |
+
|
3277 |
+
if ( 'name' === $s_key ) {
|
3278 |
+
|
3279 |
+
$settings[ $_k ]['id'] = $s_value;
|
3280 |
+
unset( $settings[ $_k ]['name'] );
|
3281 |
+
} elseif ( 'type' === $s_key ) {
|
3282 |
+
|
3283 |
+
if ( 'input' === $s_value ) {
|
3284 |
+
|
3285 |
+
$settings[ $_k ]['type'] = 'text';
|
3286 |
+
} elseif ( 'textarea' === $s_value ) {
|
3287 |
+
|
3288 |
+
$settings[ $_k ]['type'] = 'textarea-simple';
|
3289 |
+
} elseif ( 'image' === $s_value ) {
|
3290 |
+
|
3291 |
+
$settings[ $_k ]['type'] = 'upload';
|
3292 |
+
}
|
3293 |
+
}
|
3294 |
+
}
|
3295 |
+
}
|
3296 |
+
|
3297 |
+
return $settings;
|
3298 |
+
}
|
3299 |
+
}
|
3300 |
|
3301 |
+
if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
|
|
|
|
3302 |
|
3303 |
+
/**
|
3304 |
+
* Default Social Links Settings array.
|
3305 |
+
*
|
3306 |
+
* Returns an array of the default social links settings.
|
3307 |
+
* You can filter this function to change the settings
|
3308 |
+
* on a per option basis.
|
3309 |
+
*
|
3310 |
+
* @uses apply_filters()
|
3311 |
+
*
|
3312 |
+
* @param string $field_id ID that's passed to the filter.
|
3313 |
+
*
|
3314 |
+
* @return array
|
3315 |
+
*
|
3316 |
+
* @access public
|
3317 |
+
* @since 2.4.0
|
3318 |
+
*/
|
3319 |
+
function ot_social_links_settings( $field_id ) {
|
3320 |
+
|
3321 |
+
/* translators: %s: the http protocol */
|
3322 |
+
$string = esc_html__( 'Enter a link to the profile or page on the social website. Remember to add the %s part to the front of the link.', 'option-tree' );
|
3323 |
+
$settings = apply_filters(
|
3324 |
+
'ot_social_links_settings',
|
3325 |
+
array(
|
3326 |
+
array(
|
3327 |
+
'id' => 'name',
|
3328 |
+
'label' => esc_html__( 'Name', 'option-tree' ),
|
3329 |
+
'desc' => esc_html__( 'Enter the name of the social website.', 'option-tree' ),
|
3330 |
+
'std' => '',
|
3331 |
+
'type' => 'text',
|
3332 |
+
'class' => 'option-tree-setting-title',
|
3333 |
+
),
|
3334 |
+
array(
|
3335 |
+
'id' => 'title',
|
3336 |
+
'label' => 'Title',
|
3337 |
+
'desc' => esc_html__( 'Enter the text shown in the title attribute of the link.', 'option-tree' ),
|
3338 |
+
'type' => 'text',
|
3339 |
+
),
|
3340 |
+
array(
|
3341 |
+
'id' => 'href',
|
3342 |
+
'label' => 'Link',
|
3343 |
+
'desc' => sprintf( $string, '<code>http:// or https://</code>' ),
|
3344 |
+
'type' => 'text',
|
3345 |
+
),
|
3346 |
+
),
|
3347 |
+
$field_id
|
3348 |
+
);
|
3349 |
+
|
3350 |
+
return $settings;
|
3351 |
+
}
|
3352 |
+
}
|
3353 |
|
3354 |
+
if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
|
|
|
|
|
3355 |
|
3356 |
+
/**
|
3357 |
+
* Inserts CSS with field_id markers.
|
3358 |
+
*
|
3359 |
+
* Inserts CSS into a dynamic.css file, placing it between
|
3360 |
+
* BEGIN and END field_id markers. Replaces existing marked info,
|
3361 |
+
* but still retains surrounding data.
|
3362 |
+
*
|
3363 |
+
* @param string $field_id The CSS option field ID.
|
3364 |
+
* @param string $insertion The current option_tree array.
|
3365 |
+
* @param bool $meta Whether or not the value is stored in meta.
|
3366 |
+
* @return bool True on write success, false on failure.
|
3367 |
+
*
|
3368 |
+
* @access public
|
3369 |
+
* @since 1.1.8
|
3370 |
+
* @updated 2.5.3
|
3371 |
+
*/
|
3372 |
+
function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = false ) {
|
3373 |
+
|
3374 |
+
// Missing $field_id or $insertion exit early.
|
3375 |
+
if ( '' === $field_id || '' === $insertion ) {
|
3376 |
+
return;
|
3377 |
+
}
|
3378 |
+
|
3379 |
+
// Path to the dynamic.css file.
|
3380 |
+
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3381 |
+
if ( is_multisite() ) {
|
3382 |
+
$multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
|
3383 |
+
if ( file_exists( $multisite_filepath ) ) {
|
3384 |
+
$filepath = $multisite_filepath;
|
3385 |
+
}
|
3386 |
+
}
|
3387 |
+
|
3388 |
+
// Allow filter on path.
|
3389 |
+
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3390 |
+
|
3391 |
+
// Grab a copy of the paths array.
|
3392 |
+
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
3393 |
+
if ( is_multisite() ) {
|
3394 |
+
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3395 |
+
}
|
3396 |
+
|
3397 |
+
// Set the path for this field.
|
3398 |
+
$ot_css_file_paths[ $field_id ] = $filepath;
|
3399 |
+
|
3400 |
+
/* update the paths */
|
3401 |
+
if ( is_multisite() ) {
|
3402 |
+
update_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3403 |
+
} else {
|
3404 |
+
update_option( 'ot_css_file_paths', $ot_css_file_paths );
|
3405 |
+
}
|
3406 |
+
|
3407 |
+
// Remove CSS from file, but ensure the file is actually CSS first.
|
3408 |
+
$file_parts = explode( '.', basename( $filepath ) );
|
3409 |
+
$file_ext = end( $file_parts );
|
3410 |
+
if ( is_writeable( $filepath ) && 'css' === $file_ext ) {
|
3411 |
+
|
3412 |
+
$insertion = ot_normalize_css( $insertion );
|
3413 |
+
$regex = '/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/';
|
3414 |
+
$marker = $field_id;
|
3415 |
+
|
3416 |
+
// Match custom CSS.
|
3417 |
+
preg_match_all( $regex, $insertion, $matches );
|
3418 |
+
|
3419 |
+
// Loop through CSS.
|
3420 |
+
foreach ( $matches[0] as $option ) {
|
3421 |
+
|
3422 |
+
$value = '';
|
3423 |
+
$option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) );
|
3424 |
+
$option_id = isset( $option_array[0] ) ? $option_array[0] : '';
|
3425 |
+
$option_key = isset( $option_array[1] ) ? $option_array[1] : '';
|
3426 |
+
$option_type = ot_get_option_type_by_id( $option_id );
|
3427 |
+
$fallback = '';
|
3428 |
+
|
3429 |
+
// Get the meta array value.
|
3430 |
+
if ( $meta ) {
|
3431 |
+
global $post;
|
3432 |
+
|
3433 |
+
$value = get_post_meta( $post->ID, $option_id, true );
|
3434 |
+
|
3435 |
+
// Get the options array value.
|
3436 |
+
} else {
|
3437 |
+
$options = get_option( ot_options_id() );
|
3438 |
+
|
3439 |
+
if ( isset( $options[ $option_id ] ) ) {
|
3440 |
+
$value = $options[ $option_id ];
|
3441 |
+
}
|
3442 |
+
}
|
3443 |
+
|
3444 |
+
// This in an array of values.
|
3445 |
+
if ( is_array( $value ) ) {
|
3446 |
+
|
3447 |
+
if ( empty( $option_key ) ) {
|
3448 |
+
|
3449 |
+
// Measurement.
|
3450 |
+
if ( 'measurement' === $option_type ) {
|
3451 |
+
$unit = ! empty( $value[1] ) ? $value[1] : 'px';
|
3452 |
+
|
3453 |
+
// Set $value with measurement properties.
|
3454 |
+
if ( isset( $value[0] ) && strlen( $value[0] ) > 0 ) {
|
3455 |
+
$value = $value[0] . $unit;
|
3456 |
+
}
|
3457 |
+
|
3458 |
+
// Border.
|
3459 |
+
} elseif ( 'border' === $option_type ) {
|
3460 |
+
$border = array();
|
3461 |
+
|
3462 |
+
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3463 |
+
|
3464 |
+
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) {
|
3465 |
+
$border[] = $value['width'] . $unit;
|
3466 |
+
}
|
3467 |
+
|
3468 |
+
if ( ! empty( $value['style'] ) ) {
|
3469 |
+
$border[] = $value['style'];
|
3470 |
+
}
|
3471 |
+
|
3472 |
+
if ( ! empty( $value['color'] ) ) {
|
3473 |
+
$border[] = $value['color'];
|
3474 |
+
}
|
3475 |
+
|
3476 |
+
// Set $value with border properties or empty string.
|
3477 |
+
$value = ! empty( $border ) ? implode( ' ', $border ) : '';
|
3478 |
+
|
3479 |
+
// Box Shadow.
|
3480 |
+
} elseif ( 'box-shadow' === $option_type ) {
|
3481 |
+
|
3482 |
+
$value_safe = array();
|
3483 |
+
foreach ( $value as $val ) {
|
3484 |
+
if ( ! empty( $val ) ) {
|
3485 |
+
$value_safe[] = $val;
|
3486 |
+
}
|
3487 |
+
}
|
3488 |
+
// Set $value with box-shadow properties or empty string.
|
3489 |
+
$value = ! empty( $value_safe ) ? implode( ' ', $value_safe ) : '';
|
3490 |
|
3491 |
+
// Dimension.
|
3492 |
+
} elseif ( 'dimension' === $option_type ) {
|
3493 |
+
$dimension = array();
|
3494 |
|
3495 |
+
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3496 |
|
3497 |
+
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) {
|
3498 |
+
$dimension[] = $value['width'] . $unit;
|
3499 |
+
}
|
3500 |
|
3501 |
+
if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 ) {
|
3502 |
+
$dimension[] = $value['height'] . $unit;
|
3503 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3504 |
|
3505 |
+
// Set $value with dimension properties or empty string.
|
3506 |
+
$value = ! empty( $dimension ) ? implode( ' ', $dimension ) : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3507 |
|
3508 |
+
// Spacing.
|
3509 |
+
} elseif ( 'spacing' === $option_type ) {
|
3510 |
+
$spacing = array();
|
3511 |
|
3512 |
+
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3513 |
|
3514 |
+
if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 ) {
|
3515 |
+
$spacing[] = $value['top'] . $unit;
|
3516 |
+
}
|
3517 |
|
3518 |
+
if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 ) {
|
3519 |
+
$spacing[] = $value['right'] . $unit;
|
3520 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
3521 |
|
3522 |
+
if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 ) {
|
3523 |
+
$spacing[] = $value['bottom'] . $unit;
|
3524 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3525 |
|
3526 |
+
if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 ) {
|
3527 |
+
$spacing[] = $value['left'] . $unit;
|
3528 |
+
}
|
3529 |
|
3530 |
+
// Set $value with spacing properties or empty string.
|
3531 |
+
$value = ! empty( $spacing ) ? implode( ' ', $spacing ) : '';
|
3532 |
|
3533 |
+
// Typography.
|
3534 |
+
} elseif ( 'typography' === $option_type ) {
|
3535 |
+
$font = array();
|
3536 |
|
3537 |
+
if ( ! empty( $value['font-color'] ) ) {
|
3538 |
+
$font[] = 'color: ' . $value['font-color'] . ';';
|
3539 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
3540 |
|
3541 |
+
if ( ! empty( $value['font-family'] ) ) {
|
3542 |
+
foreach ( ot_recognized_font_families( $marker ) as $key => $v ) {
|
3543 |
+
if ( $key === $value['font-family'] ) {
|
3544 |
+
$font[] = 'font-family: ' . $v . ';';
|
3545 |
+
}
|
3546 |
+
}
|
3547 |
+
}
|
3548 |
|
3549 |
+
if ( ! empty( $value['font-size'] ) ) {
|
3550 |
+
$font[] = 'font-size: ' . $value['font-size'] . ';';
|
3551 |
+
}
|
3552 |
|
3553 |
+
if ( ! empty( $value['font-style'] ) ) {
|
3554 |
+
$font[] = 'font-style: ' . $value['font-style'] . ';';
|
3555 |
+
}
|
3556 |
|
3557 |
+
if ( ! empty( $value['font-variant'] ) ) {
|
3558 |
+
$font[] = 'font-variant: ' . $value['font-variant'] . ';';
|
3559 |
+
}
|
3560 |
|
3561 |
+
if ( ! empty( $value['font-weight'] ) ) {
|
3562 |
+
$font[] = 'font-weight: ' . $value['font-weight'] . ';';
|
3563 |
+
}
|
3564 |
+
|
3565 |
+
if ( ! empty( $value['letter-spacing'] ) ) {
|
3566 |
+
$font[] = 'letter-spacing: ' . $value['letter-spacing'] . ';';
|
3567 |
+
}
|
3568 |
+
|
3569 |
+
if ( ! empty( $value['line-height'] ) ) {
|
3570 |
+
$font[] = 'line-height: ' . $value['line-height'] . ';';
|
3571 |
+
}
|
3572 |
+
|
3573 |
+
if ( ! empty( $value['text-decoration'] ) ) {
|
3574 |
+
$font[] = 'text-decoration: ' . $value['text-decoration'] . ';';
|
3575 |
+
}
|
3576 |
+
|
3577 |
+
if ( ! empty( $value['text-transform'] ) ) {
|
3578 |
+
$font[] = 'text-transform: ' . $value['text-transform'] . ';';
|
3579 |
+
}
|
3580 |
+
|
3581 |
+
// Set $value with font properties or empty string.
|
3582 |
+
$value = ! empty( $font ) ? implode( "\n", $font ) : '';
|
3583 |
+
|
3584 |
+
// Background.
|
3585 |
+
} elseif ( 'background' === $option_type ) {
|
3586 |
+
$bg = array();
|
3587 |
+
|
3588 |
+
if ( ! empty( $value['background-color'] ) ) {
|
3589 |
+
$bg[] = $value['background-color'];
|
3590 |
+
}
|
3591 |
+
|
3592 |
+
if ( ! empty( $value['background-image'] ) ) {
|
3593 |
+
|
3594 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
3595 |
+
if ( wp_attachment_is_image( $value['background-image'] ) ) {
|
3596 |
+
|
3597 |
+
$attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' );
|
3598 |
+
|
3599 |
+
// Check for attachment data.
|
3600 |
+
if ( $attachment_data ) {
|
3601 |
+
$value['background-image'] = $attachment_data[0];
|
3602 |
+
}
|
3603 |
+
}
|
3604 |
+
|
3605 |
+
$bg[] = 'url("' . $value['background-image'] . '")';
|
3606 |
+
}
|
3607 |
+
|
3608 |
+
if ( ! empty( $value['background-repeat'] ) ) {
|
3609 |
+
$bg[] = $value['background-repeat'];
|
3610 |
+
}
|
3611 |
+
|
3612 |
+
if ( ! empty( $value['background-attachment'] ) ) {
|
3613 |
+
$bg[] = $value['background-attachment'];
|
3614 |
+
}
|
3615 |
+
|
3616 |
+
if ( ! empty( $value['background-position'] ) ) {
|
3617 |
+
$bg[] = $value['background-position'];
|
3618 |
+
}
|
3619 |
+
|
3620 |
+
if ( ! empty( $value['background-size'] ) ) {
|
3621 |
+
$size = $value['background-size'];
|
3622 |
+
}
|
3623 |
+
|
3624 |
+
// Set $value with background properties or empty string.
|
3625 |
+
$value = ! empty( $bg ) ? 'background: ' . implode( ' ', $bg ) . ';' : '';
|
3626 |
+
|
3627 |
+
if ( isset( $size ) ) {
|
3628 |
+
if ( ! empty( $bg ) ) {
|
3629 |
+
$value .= apply_filters( 'ot_insert_css_with_markers_bg_size_white_space', "\n\x20\x20", $option_id );
|
3630 |
+
}
|
3631 |
+
$value .= "background-size: $size;";
|
3632 |
+
}
|
3633 |
+
}
|
3634 |
+
} elseif ( ! empty( $value[ $option_key ] ) ) {
|
3635 |
+
$value = $value[ $option_key ];
|
3636 |
+
}
|
3637 |
+
}
|
3638 |
+
|
3639 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
3640 |
+
if ( 'upload' === $option_type && wp_attachment_is_image( $value ) ) {
|
3641 |
+
|
3642 |
+
$attachment_data = wp_get_attachment_image_src( $value, 'original' );
|
3643 |
+
|
3644 |
+
// Check for attachment data.
|
3645 |
+
if ( $attachment_data ) {
|
3646 |
+
$value = $attachment_data[0];
|
3647 |
+
}
|
3648 |
+
}
|
3649 |
+
|
3650 |
+
// Attempt to fallback when `$value` is empty.
|
3651 |
+
if ( empty( $value ) ) {
|
3652 |
+
|
3653 |
+
// We're trying to access a single array key.
|
3654 |
+
if ( ! empty( $option_key ) ) {
|
3655 |
+
|
3656 |
+
// Link Color `inherit`.
|
3657 |
+
if ( 'link-color' === $option_type ) {
|
3658 |
+
$fallback = 'inherit';
|
3659 |
+
}
|
3660 |
+
} else {
|
3661 |
+
|
3662 |
+
// Border.
|
3663 |
+
if ( 'border' === $option_type ) {
|
3664 |
+
$fallback = 'inherit';
|
3665 |
+
}
|
3666 |
+
|
3667 |
+
// Box Shadow.
|
3668 |
+
if ( 'box-shadow' === $option_type ) {
|
3669 |
+
$fallback = 'none';
|
3670 |
+
}
|
3671 |
+
|
3672 |
+
// Colorpicker.
|
3673 |
+
if ( 'colorpicker' === $option_type ) {
|
3674 |
+
$fallback = 'inherit';
|
3675 |
+
}
|
3676 |
+
|
3677 |
+
// Colorpicker Opacity.
|
3678 |
+
if ( 'colorpicker-opacity' === $option_type ) {
|
3679 |
+
$fallback = 'inherit';
|
3680 |
+
}
|
3681 |
+
}
|
3682 |
+
|
3683 |
+
/**
|
3684 |
+
* Filter the `dynamic.css` fallback value.
|
3685 |
+
*
|
3686 |
+
* @since 2.5.3
|
3687 |
+
*
|
3688 |
+
* @param string $fallback The default CSS fallback value.
|
3689 |
+
* @param string $option_id The option ID.
|
3690 |
+
* @param string $option_type The option type.
|
3691 |
+
* @param string $option_key The option array key.
|
3692 |
+
*/
|
3693 |
+
$fallback = apply_filters( 'ot_insert_css_with_markers_fallback', $fallback, $option_id, $option_type, $option_key );
|
3694 |
+
}
|
3695 |
+
|
3696 |
+
// Let's fallback!
|
3697 |
+
if ( ! empty( $fallback ) ) {
|
3698 |
+
$value = $fallback;
|
3699 |
+
}
|
3700 |
+
|
3701 |
+
// Filter the CSS.
|
3702 |
+
$value = apply_filters( 'ot_insert_css_with_markers_value', $value, $option_id );
|
3703 |
+
|
3704 |
+
// Insert CSS, even if the value is empty.
|
3705 |
+
$insertion = stripslashes( str_replace( $option, $value, $insertion ) );
|
3706 |
+
}
|
3707 |
+
|
3708 |
+
// Can't write to the file so we error out.
|
3709 |
+
if ( ! is_writable( $filepath ) ) {
|
3710 |
+
/* translators: %s: file path */
|
3711 |
+
$string = esc_html__( 'Unable to write to file %s.', 'option-tree' );
|
3712 |
+
add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '<code>' . $filepath . '</code>' ), 'error' );
|
3713 |
+
return false;
|
3714 |
+
}
|
3715 |
+
|
3716 |
+
// Open file.
|
3717 |
+
$f = @fopen( $filepath, 'w' ); // phpcs:ignore
|
3718 |
+
|
3719 |
+
// Can't write to the file return false.
|
3720 |
+
if ( ! $f ) {
|
3721 |
+
/* translators: %s: file path */
|
3722 |
+
$string = esc_html__( 'Unable to open the %s file in write mode.', 'option-tree' );
|
3723 |
+
add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '<code>' . $filepath . '</code>' ), 'error' );
|
3724 |
+
return false;
|
3725 |
+
}
|
3726 |
+
|
3727 |
+
// Create array from the lines of code.
|
3728 |
+
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3729 |
+
|
3730 |
+
$searching = true;
|
3731 |
+
$foundit = false;
|
3732 |
+
|
3733 |
+
// Has array of lines.
|
3734 |
+
if ( ! empty( $markerdata ) ) {
|
3735 |
+
|
3736 |
+
// Foreach line of code.
|
3737 |
+
foreach ( $markerdata as $n => $markerline ) {
|
3738 |
+
|
3739 |
+
// Found begining of marker, set $searching to false.
|
3740 |
+
if ( "/* BEGIN {$marker} */" === $markerline ) {
|
3741 |
+
$searching = false;
|
3742 |
+
}
|
3743 |
+
|
3744 |
+
// Keep searching each line of CSS.
|
3745 |
+
if ( true === $searching ) {
|
3746 |
+
if ( $n + 1 < count( $markerdata ) ) {
|
3747 |
+
fwrite( $f, "{$markerline}\n" ); // phpcs:ignore
|
3748 |
+
} else {
|
3749 |
+
fwrite( $f, "{$markerline}" ); // phpcs:ignore
|
3750 |
+
}
|
3751 |
+
}
|
3752 |
+
|
3753 |
+
// Found end marker write code.
|
3754 |
+
if ( "/* END {$marker} */" === $markerline ) {
|
3755 |
+
fwrite( $f, "/* BEGIN {$marker} */\n" ); // phpcs:ignore
|
3756 |
+
fwrite( $f, "{$insertion}\n" ); // phpcs:ignore
|
3757 |
+
fwrite( $f, "/* END {$marker} */\n" ); // phpcs:ignore
|
3758 |
+
$searching = true;
|
3759 |
+
$foundit = true;
|
3760 |
+
}
|
3761 |
+
}
|
3762 |
+
}
|
3763 |
+
|
3764 |
+
// Nothing inserted, write code. DO IT, DO IT!
|
3765 |
+
if ( ! $foundit ) {
|
3766 |
+
fwrite( $f, "/* BEGIN {$marker} */\n" ); // phpcs:ignore
|
3767 |
+
fwrite( $f, "{$insertion}\n" ); // phpcs:ignore
|
3768 |
+
fwrite( $f, "/* END {$marker} */\n" ); // phpcs:ignore
|
3769 |
+
}
|
3770 |
+
|
3771 |
+
// Close file.
|
3772 |
+
fclose( $f ); // phpcs:ignore
|
3773 |
+
return true;
|
3774 |
+
}
|
3775 |
+
|
3776 |
+
return false;
|
3777 |
+
}
|
3778 |
+
}
|
3779 |
|
3780 |
+
if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
|
|
3781 |
|
3782 |
+
/**
|
3783 |
+
* Remove old CSS.
|
3784 |
+
*
|
3785 |
+
* Removes CSS when the textarea is empty, but still retains surrounding styles.
|
3786 |
+
*
|
3787 |
+
* @param string $field_id The CSS option field ID.
|
3788 |
+
* @return bool True on write success, false on failure.
|
3789 |
+
*
|
3790 |
+
* @access public
|
3791 |
+
* @since 2.0
|
3792 |
+
*/
|
3793 |
+
function ot_remove_old_css( $field_id = '' ) {
|
3794 |
+
|
3795 |
+
// Missing $field_id string.
|
3796 |
+
if ( '' === $field_id ) {
|
3797 |
+
return false;
|
3798 |
+
}
|
3799 |
+
|
3800 |
+
// Path to the dynamic.css file.
|
3801 |
+
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3802 |
+
|
3803 |
+
// Allow filter on path.
|
3804 |
+
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3805 |
+
|
3806 |
+
// Remove CSS from file, but ensure the file is actually CSS first.
|
3807 |
+
if ( is_writeable( $filepath ) && 'css' === end( explode( '.', basename( $filepath ) ) ) ) {
|
3808 |
+
|
3809 |
+
// Open the file.
|
3810 |
+
$f = @fopen( $filepath, 'w' ); // phpcs:ignore
|
3811 |
+
|
3812 |
+
// Can't write to the file return false.
|
3813 |
+
if ( ! $f ) {
|
3814 |
+
/* translators: %s: file path */
|
3815 |
+
$string = esc_html__( 'Unable to open the %s file in write mode.', 'option-tree' );
|
3816 |
+
add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '<code>' . $filepath . '</code>' ), 'error' );
|
3817 |
+
return false;
|
3818 |
+
}
|
3819 |
+
|
3820 |
+
// Get each line in the file.
|
3821 |
+
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3822 |
+
|
3823 |
+
$searching = true;
|
3824 |
+
|
3825 |
+
// Has array of lines.
|
3826 |
+
if ( ! empty( $markerdata ) ) {
|
3827 |
+
|
3828 |
+
// Foreach line of code.
|
3829 |
+
foreach ( $markerdata as $n => $markerline ) {
|
3830 |
+
|
3831 |
+
// Found beginning of marker, set $searching to false.
|
3832 |
+
if ( "/* BEGIN {$field_id} */" === $markerline ) {
|
3833 |
+
$searching = false;
|
3834 |
+
}
|
3835 |
+
|
3836 |
+
// Searching is true, keep writing each line of CSS.
|
3837 |
+
if ( true === $searching ) {
|
3838 |
+
if ( $n + 1 < count( $markerdata ) ) {
|
3839 |
+
fwrite( $f, "{$markerline}\n" ); // phpcs:ignore
|
3840 |
+
} else {
|
3841 |
+
fwrite( $f, "{$markerline}" ); // phpcs:ignore
|
3842 |
+
}
|
3843 |
+
}
|
3844 |
+
|
3845 |
+
// Found end marker delete old CSS.
|
3846 |
+
if ( "/* END {$field_id} */" === $markerline ) {
|
3847 |
+
fwrite( $f, '' ); // phpcs:ignore
|
3848 |
+
$searching = true;
|
3849 |
+
}
|
3850 |
+
}
|
3851 |
+
}
|
3852 |
+
|
3853 |
+
// Close file.
|
3854 |
+
fclose( $f ); // phpcs:ignore
|
3855 |
+
return true;
|
3856 |
+
}
|
3857 |
+
|
3858 |
+
return false;
|
3859 |
+
}
|
3860 |
+
}
|
3861 |
|
3862 |
+
if ( ! function_exists( 'ot_normalize_css' ) ) {
|
|
|
3863 |
|
3864 |
+
/**
|
3865 |
+
* Normalize CSS
|
3866 |
+
*
|
3867 |
+
* Normalize & Convert all line-endings to UNIX format.
|
3868 |
+
*
|
3869 |
+
* @param string $css The CSS styles.
|
3870 |
+
*
|
3871 |
+
* @return string
|
3872 |
+
*
|
3873 |
+
* @access public
|
3874 |
+
* @since 1.1.8
|
3875 |
+
* @updated 2.0
|
3876 |
+
*/
|
3877 |
+
function ot_normalize_css( $css ) {
|
3878 |
+
|
3879 |
+
// Normalize & Convert.
|
3880 |
+
$css = str_replace( "\r\n", "\n", $css );
|
3881 |
+
$css = str_replace( "\r", "\n", $css );
|
3882 |
+
|
3883 |
+
// Don't allow out-of-control blank lines .
|
3884 |
+
$css = preg_replace( "/\n{2,}/", "\n\n", $css );
|
3885 |
+
|
3886 |
+
return $css;
|
3887 |
+
}
|
3888 |
+
}
|
3889 |
|
3890 |
+
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
|
3891 |
|
3892 |
+
/**
|
3893 |
+
* Helper function to loop over the option types.
|
3894 |
+
*
|
3895 |
+
* @param string $type The current option type.
|
3896 |
+
* @param bool $child Whether of not there are children elements.
|
3897 |
+
*
|
3898 |
+
* @return string
|
3899 |
+
*
|
3900 |
+
* @access public
|
3901 |
+
* @since 2.0
|
3902 |
+
*/
|
3903 |
+
function ot_loop_through_option_types( $type = '', $child = false ) {
|
3904 |
+
|
3905 |
+
$content = '';
|
3906 |
+
$types = ot_option_types_array();
|
3907 |
+
|
3908 |
+
if ( $child ) {
|
3909 |
+
unset( $types['list-item'] );
|
3910 |
+
}
|
3911 |
+
|
3912 |
+
foreach ( $types as $key => $value ) {
|
3913 |
+
$content .= '<option value="' . esc_attr( $key ) . '" ' . selected( $type, $key, false ) . '>' . esc_html( $value ) . '</option>';
|
3914 |
+
}
|
3915 |
+
|
3916 |
+
return $content;
|
3917 |
+
|
3918 |
+
}
|
3919 |
+
}
|
3920 |
|
3921 |
+
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
|
3922 |
|
3923 |
+
/**
|
3924 |
+
* Helper function to loop over choices.
|
3925 |
+
*
|
3926 |
+
* @param string $name The form element name.
|
3927 |
+
* @param array $choices The array of choices.
|
3928 |
+
*
|
3929 |
+
* @return string
|
3930 |
+
*
|
3931 |
+
* @access public
|
3932 |
+
* @since 2.0
|
3933 |
+
*/
|
3934 |
+
function ot_loop_through_choices( $name, $choices = array() ) {
|
3935 |
+
|
3936 |
+
$content = '';
|
3937 |
+
|
3938 |
+
foreach ( (array) $choices as $key => $choice ) {
|
3939 |
+
if ( is_array( $choice ) ) {
|
3940 |
+
$content .= '<li class="ui-state-default list-choice">' . ot_choices_view( $name, $key, $choice ) . '</li>';
|
3941 |
+
}
|
3942 |
+
}
|
3943 |
+
|
3944 |
+
return $content;
|
3945 |
+
}
|
3946 |
+
}
|
3947 |
|
3948 |
+
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
|
3949 |
|
3950 |
+
/**
|
3951 |
+
* Helper function to loop over sub settings.
|
3952 |
+
*
|
3953 |
+
* @param string $name The form element name.
|
3954 |
+
* @param array $settings The array of settings.
|
3955 |
+
*
|
3956 |
+
* @return string
|
3957 |
+
*
|
3958 |
+
* @access public
|
3959 |
+
* @since 2.0
|
3960 |
+
*/
|
3961 |
+
function ot_loop_through_sub_settings( $name, $settings = array() ) {
|
3962 |
+
|
3963 |
+
$content = '';
|
3964 |
+
|
3965 |
+
foreach ( $settings as $key => $setting ) {
|
3966 |
+
if ( is_array( $setting ) ) {
|
3967 |
+
$content .= '<li class="ui-state-default list-sub-setting">' . ot_settings_view( $name, $key, $setting ) . '</li>';
|
3968 |
+
}
|
3969 |
+
}
|
3970 |
+
|
3971 |
+
return $content;
|
3972 |
+
}
|
3973 |
}
|
3974 |
|
3975 |
+
if ( ! function_exists( 'ot_sections_view' ) ) {
|
3976 |
+
|
3977 |
+
/**
|
3978 |
+
* Helper function to display sections.
|
3979 |
+
*
|
3980 |
+
* This function is used in AJAX to add a new section
|
3981 |
+
* and when section have already been added and saved.
|
3982 |
+
*
|
3983 |
+
* @param string $name The form element name.
|
3984 |
+
* @param int $key The array key for the current element.
|
3985 |
+
* @param array $section An array of values for the current section.
|
3986 |
+
*
|
3987 |
+
* @return string
|
3988 |
+
*
|
3989 |
+
* @access public
|
3990 |
+
* @since 2.0
|
3991 |
+
*/
|
3992 |
+
function ot_sections_view( $name, $key, $section = array() ) {
|
3993 |
+
|
3994 |
+
/* translators: %s: Section Title emphasized */
|
3995 |
+
$str_title = esc_html__( '%s: Displayed as a menu item on the Theme Options page.', 'option-tree' );
|
3996 |
+
|
3997 |
+
/* translators: %s: Section ID emphasized */
|
3998 |
+
$str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' );
|
3999 |
+
|
4000 |
+
return '
|
4001 |
+
<div class="option-tree-setting is-section">
|
4002 |
+
<div class="open">' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( absint( $key ) + 1 ) ) . '</div>
|
4003 |
+
<div class="button-section">
|
4004 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'edit', 'option-tree' ) . '">
|
4005 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4006 |
+
</a>
|
4007 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4008 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4009 |
+
</a>
|
4010 |
+
</div>
|
4011 |
+
<div class="option-tree-setting-body">
|
4012 |
+
<div class="format-settings">
|
4013 |
+
<div class="format-setting type-text">
|
4014 |
+
<div class="description">' . sprintf( $str_title, '<strong>' . esc_html__( 'Section Title', 'option-tree' ) . '</strong>', 'option-tree' ) . '</div>
|
4015 |
+
<div class="format-setting-inner">
|
4016 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title section-title" autocomplete="off" />
|
4017 |
+
</div>
|
4018 |
+
</div>
|
4019 |
+
</div>
|
4020 |
+
<div class="format-settings">
|
4021 |
+
<div class="format-setting type-text">
|
4022 |
+
<div class="description">' . sprintf( $str_id, '<strong>' . esc_html__( 'Section ID', 'option-tree' ) . '</strong>', 'option-tree' ) . '</div>
|
4023 |
+
<div class="format-setting-inner">
|
4024 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $section['id'] ) ? esc_attr( $section['id'] ) : '' ) . '" class="widefat option-tree-ui-input section-id" autocomplete="off" />
|
4025 |
+
</div>
|
4026 |
+
</div>
|
4027 |
+
</div>
|
4028 |
+
</div>
|
4029 |
+
</div>';
|
4030 |
+
}
|
4031 |
+
}
|
4032 |
|
4033 |
+
if ( ! function_exists( 'ot_settings_view' ) ) {
|
4034 |
|
4035 |
+
/**
|
4036 |
+
* Helper function to display settings.
|
4037 |
+
*
|
4038 |
+
* This function is used in AJAX to add a new setting
|
4039 |
+
* and when settings have already been added and saved.
|
4040 |
+
*
|
4041 |
+
* @param string $name The form element name.
|
4042 |
+
* @param int $key The array key for the current element.
|
4043 |
+
* @param array $setting An array of values for the current setting.
|
4044 |
+
*
|
4045 |
+
* @return string
|
4046 |
+
*
|
4047 |
+
* @access public
|
4048 |
+
* @since 2.0
|
4049 |
+
*/
|
4050 |
+
function ot_settings_view( $name, $key, $setting = array() ) {
|
4051 |
+
|
4052 |
+
$child = ( false !== strpos( $name, '][settings]' ) ) ? true : false;
|
4053 |
+
$type = isset( $setting['type'] ) ? $setting['type'] : '';
|
4054 |
+
$std = isset( $setting['std'] ) ? $setting['std'] : '';
|
4055 |
+
$operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
|
4056 |
+
|
4057 |
+
// Serialize the standard value just in case.
|
4058 |
+
if ( is_array( $std ) ) {
|
4059 |
+
$std = maybe_serialize( $std );
|
4060 |
+
}
|
4061 |
+
|
4062 |
+
if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ), true ) ) {
|
4063 |
+
$std_form_element = '<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]">' . esc_html( $std ) . '</textarea>';
|
4064 |
+
} else {
|
4065 |
+
$std_form_element = '<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]" value="' . esc_attr( $std ) . '" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4066 |
+
}
|
4067 |
+
|
4068 |
+
/* translators: %s: Label emphasized */
|
4069 |
+
$str_label = esc_html__( '%s: Displayed as the label of a form element on the Theme Options page.', 'option-tree' );
|
4070 |
+
|
4071 |
+
/* translators: %s: ID emphasized */
|
4072 |
+
$str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' );
|
4073 |
+
|
4074 |
+
/* translators: %s: Type emphasized */
|
4075 |
+
$str_type = esc_html__( '%s: Choose one of the available option types from the dropdown.', 'option-tree' );
|
4076 |
+
|
4077 |
+
/* translators: %s: Description emphasized */
|
4078 |
+
$str_desc = esc_html__( '%s: 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' );
|
4079 |
+
|
4080 |
+
/* translators: %s: Choices emphasized */
|
4081 |
+
$str_choices = esc_html__( '%s: This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' );
|
4082 |
+
|
4083 |
+
/* translators: %s: Settings emphasized */
|
4084 |
+
$str_settings = esc_html__( '%s: This will only affect the List Item option type.', 'option-tree' );
|
4085 |
+
|
4086 |
+
/* translators: %1$s: Standard emphasized, %2$s: visual path to documentation */
|
4087 |
+
$str_standard = esc_html__( '%1$s: Setting the standard value for your option only works for some option types. Read the %2$s for more information on which ones.', 'option-tree' );
|
4088 |
+
|
4089 |
+
/* translators: %s: Rows emphasized */
|
4090 |
+
$str_rows = esc_html__( '%s: 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' );
|
4091 |
+
|
4092 |
+
/* translators: %s: Post Type emphasized */
|
4093 |
+
$str_post_type = esc_html__( '%s: Add a comma separated list of post type like \'post,page\'. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select.', 'option-tree' );
|
4094 |
+
|
4095 |
+
/* translators: %s: Taxonomy emphasized */
|
4096 |
+
$str_taxonomy = esc_html__( '%s: Add a comma separated list of any registered taxonomy like \'category,post_tag\'. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' );
|
4097 |
+
|
4098 |
+
/* translators: %1$s: Min, Max, & Step emphasized, %2$s: format, %3$s: range, %4$s: minimum interval */
|
4099 |
+
$str_min_max_step = esc_html__( '%1$s: Add a comma separated list of options in the following format %2$s (slide from %3$s in intervals of %4$s). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' );
|
4100 |
+
|
4101 |
+
/* translators: %s: CSS Class emphasized */
|
4102 |
+
$str_css_class = esc_html__( '%s: Add and optional class to this option type.', 'option-tree' );
|
4103 |
+
|
4104 |
+
/* translators: %1$s: Condition emphasized, %2$s: example value, %3$s: list of valid conditions */
|
4105 |
+
$str_condition = esc_html__( '%1$s: Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, %2$s is a placeholder for your condition, which can be in the form of %3$s.', 'option-tree' );
|
4106 |
+
|
4107 |
+
/* translators: %s: Operator emphasized */
|
4108 |
+
$str_operator = esc_html__( '%s: Choose the logical operator to compute the result of the conditions.', 'option-tree' );
|
4109 |
+
|
4110 |
+
return '
|
4111 |
+
<div class="option-tree-setting">
|
4112 |
+
<div class="open">' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( absint( $key ) + 1 ) ) . '</div>
|
4113 |
+
<div class="button-section">
|
4114 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4115 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4116 |
+
</a>
|
4117 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4118 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4119 |
+
</a>
|
4120 |
+
</div>
|
4121 |
+
<div class="option-tree-setting-body">
|
4122 |
+
<div class="format-settings">
|
4123 |
+
<div class="format-setting type-text wide-desc">
|
4124 |
+
<div class="description">' . sprintf( $str_label, '<strong>' . esc_html__( 'Label', 'option-tree' ) . '</strong>' ) . '</div>
|
4125 |
+
<div class="format-setting-inner">
|
4126 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][label]" value="' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4127 |
+
</div>
|
4128 |
+
</div>
|
4129 |
+
</div>
|
4130 |
+
<div class="format-settings">
|
4131 |
+
<div class="format-setting type-text wide-desc">
|
4132 |
+
<div class="description">' . sprintf( $str_id, '<strong>' . esc_html__( 'ID', 'option-tree' ) . '</strong>' ) . '</div>
|
4133 |
+
<div class="format-setting-inner">
|
4134 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $setting['id'] ) ? esc_attr( $setting['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4135 |
+
</div>
|
4136 |
+
</div>
|
4137 |
+
</div>
|
4138 |
+
<div class="format-settings">
|
4139 |
+
<div class="format-setting type-select wide-desc">
|
4140 |
+
<div class="description">' . sprintf( $str_type, '<strong>' . esc_html__( 'Type', 'option-tree' ) . '</strong>' ) . '</div>
|
4141 |
+
<div class="format-setting-inner">
|
4142 |
+
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][type]" value="' . esc_attr( $type ) . '" class="option-tree-ui-select">
|
4143 |
+
' . ot_loop_through_option_types( $type, $child ) . '
|
4144 |
+
</select>
|
4145 |
+
</div>
|
4146 |
+
</div>
|
4147 |
+
</div>
|
4148 |
+
<div class="format-settings">
|
4149 |
+
<div class="format-setting type-textarea wide-desc">
|
4150 |
+
<div class="description">' . sprintf( $str_desc, '<strong>' . esc_html__( 'Description', 'option-tree' ) . '</strong>' ) . '</div>
|
4151 |
+
<div class="format-setting-inner">
|
4152 |
+
<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][desc]">' . ( isset( $setting['desc'] ) ? esc_html( $setting['desc'] ) : '' ) . '</textarea>
|
4153 |
+
</div>
|
4154 |
+
</div>
|
4155 |
+
</div>
|
4156 |
+
<div class="format-settings">
|
4157 |
+
<div class="format-setting type-textblock wide-desc">
|
4158 |
+
<div class="description">' . sprintf( $str_choices, '<strong>' . esc_html__( 'Choices', 'option-tree' ) . '</strong>' ) . '</div>
|
4159 |
+
<div class="format-setting-inner">
|
4160 |
+
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4161 |
+
' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . '
|
4162 |
+
</ul>
|
4163 |
+
<a href="javascript:void(0);" class="option-tree-choice-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Choice', 'option-tree' ) . '</a>
|
4164 |
+
</div>
|
4165 |
+
</div>
|
4166 |
+
</div>
|
4167 |
+
<div class="format-settings">
|
4168 |
+
<div class="format-setting type-textblock wide-desc">
|
4169 |
+
<div class="description">' . sprintf( $str_settings, '<strong>' . esc_html__( 'Settings', 'option-tree' ) . '</strong>' ) . '</div>
|
4170 |
+
<div class="format-setting-inner">
|
4171 |
+
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4172 |
+
' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . '
|
4173 |
+
</ul>
|
4174 |
+
<a href="javascript:void(0);" class="option-tree-list-item-setting-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Setting', 'option-tree' ) . '</a>
|
4175 |
+
</div>
|
4176 |
+
</div>
|
4177 |
+
</div>
|
4178 |
+
<div class="format-settings">
|
4179 |
+
<div class="format-setting type-text wide-desc">
|
4180 |
+
<div class="description">' . sprintf( $str_standard, '<strong>' . esc_html__( 'Standard', 'option-tree' ) . '</strong>', '<code>' . esc_html__( 'OptionTree->Documentation', 'option-tree' ) . '</code>' ) . '</div>
|
4181 |
+
<div class="format-setting-inner">
|
4182 |
+
' . $std_form_element . '
|
4183 |
+
</div>
|
4184 |
+
</div>
|
4185 |
+
</div>
|
4186 |
+
<div class="format-settings">
|
4187 |
+
<div class="format-setting type-text wide-desc">
|
4188 |
+
<div class="description">' . sprintf( $str_rows, '<strong>' . esc_html__( 'Rows', 'option-tree' ) . '</strong>' ) . '</div>
|
4189 |
+
<div class="format-setting-inner">
|
4190 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][rows]" value="' . ( isset( $setting['rows'] ) ? esc_attr( $setting['rows'] ) : '' ) . '" class="widefat option-tree-ui-input" />
|
4191 |
+
</div>
|
4192 |
+
</div>
|
4193 |
+
</div>
|
4194 |
+
<div class="format-settings">
|
4195 |
+
<div class="format-setting type-text wide-desc">
|
4196 |
+
<div class="description">' . sprintf( $str_post_type, '<strong>' . esc_html__( 'Post Type', 'option-tree' ) . '</strong>' ) . '</div>
|
4197 |
+
<div class="format-setting-inner">
|
4198 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][post_type]" value="' . ( isset( $setting['post_type'] ) ? esc_attr( $setting['post_type'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4199 |
+
</div>
|
4200 |
+
</div>
|
4201 |
+
</div>
|
4202 |
+
<div class="format-settings">
|
4203 |
+
<div class="format-setting type-text wide-desc">
|
4204 |
+
<div class="description">' . sprintf( $str_taxonomy, '<strong>' . esc_html__( 'Taxonomy', 'option-tree' ) . '</strong>' ) . '</div>
|
4205 |
+
<div class="format-setting-inner">
|
4206 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][taxonomy]" value="' . ( isset( $setting['taxonomy'] ) ? esc_attr( $setting['taxonomy'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4207 |
+
</div>
|
4208 |
+
</div>
|
4209 |
+
</div>
|
4210 |
+
<div class="format-settings">
|
4211 |
+
<div class="format-setting type-text wide-desc">
|
4212 |
+
<div class="description">' . sprintf( $str_min_max_step, '<strong>' . esc_html__( 'Min, Max, & Step', 'option-tree' ) . '</strong>', '<code>0,100,1</code>', '<code>0-100</code>', '<code>1</code>' ) . '</div>
|
4213 |
+
<div class="format-setting-inner">
|
4214 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][min_max_step]" value="' . ( isset( $setting['min_max_step'] ) ? esc_attr( $setting['min_max_step'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4215 |
+
</div>
|
4216 |
+
</div>
|
4217 |
+
</div>
|
4218 |
+
<div class="format-settings">
|
4219 |
+
<div class="format-setting type-text wide-desc">
|
4220 |
+
<div class="description">' . sprintf( $str_css_class, '<strong>' . esc_html__( 'CSS Class', 'option-tree' ) . '</strong>' ) . '</div>
|
4221 |
+
<div class="format-setting-inner">
|
4222 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][class]" value="' . ( isset( $setting['class'] ) ? esc_attr( $setting['class'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4223 |
+
</div>
|
4224 |
+
</div>
|
4225 |
+
</div>
|
4226 |
+
<div class="format-settings">
|
4227 |
+
<div class="format-setting type-text wide-desc">
|
4228 |
+
<div class="description">' . sprintf( $str_condition, '<strong>' . esc_html__( 'Condition', 'option-tree' ) . '</strong>', '<code>value</code>', '<code>field_id:is(value)</code>, <code>field_id:not(value)</code>, <code>field_id:contains(value)</code>, <code>field_id:less_than(value)</code>, <code>field_id:less_than_or_equal_to(value)</code>, <code>field_id:greater_than(value)</code>, or <code>field_id:greater_than_or_equal_to(value)</code>' ) . '</div>
|
4229 |
+
<div class="format-setting-inner">
|
4230 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][condition]" value="' . ( isset( $setting['condition'] ) ? esc_attr( $setting['condition'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4231 |
+
</div>
|
4232 |
+
</div>
|
4233 |
+
</div>
|
4234 |
+
<div class="format-settings">
|
4235 |
+
<div class="format-setting type-select wide-desc">
|
4236 |
+
<div class="description">' . sprintf( $str_operator, '<strong>' . esc_html__( 'Operator', 'option-tree' ) . '</strong>' ) . '</div>
|
4237 |
+
<div class="format-setting-inner">
|
4238 |
+
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][operator]" value="' . esc_attr( $operator ) . '" class="option-tree-ui-select">
|
4239 |
+
<option value="and" ' . selected( $operator, 'and', false ) . '>' . esc_html__( 'and', 'option-tree' ) . '</option>
|
4240 |
+
<option value="or" ' . selected( $operator, 'or', false ) . '>' . esc_html__( 'or', 'option-tree' ) . '</option>
|
4241 |
+
</select>
|
4242 |
+
</div>
|
4243 |
+
</div>
|
4244 |
+
</div>
|
4245 |
+
</div>
|
4246 |
+
</div>
|
4247 |
+
' . ( ! $child ? '<input type="hidden" class="hidden-section" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][section]" value="' . ( isset( $setting['section'] ) ? esc_attr( $setting['section'] ) : '' ) . '" />' : '' );
|
4248 |
+
}
|
4249 |
+
}
|
4250 |
|
4251 |
+
if ( ! function_exists( 'ot_choices_view' ) ) {
|
4252 |
|
4253 |
+
/**
|
4254 |
+
* Helper function to display setting choices.
|
4255 |
+
*
|
4256 |
+
* This function is used in AJAX to add a new choice
|
4257 |
+
* and when choices have already been added and saved.
|
4258 |
+
*
|
4259 |
+
* @param string $name The form element name.
|
4260 |
+
* @param int $key The array key for the current element.
|
4261 |
+
* @param array $choice An array of values for the current choice.
|
4262 |
+
*
|
4263 |
+
* @return string
|
4264 |
+
*
|
4265 |
+
* @access public
|
4266 |
+
* @since 2.0
|
4267 |
+
*/
|
4268 |
+
function ot_choices_view( $name, $key, $choice = array() ) {
|
4269 |
+
|
4270 |
+
return '
|
4271 |
+
<div class="option-tree-setting">
|
4272 |
+
<div class="open">' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( absint( $key ) + 1 ) ) . '</div>
|
4273 |
+
<div class="button-section">
|
4274 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4275 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4276 |
+
</a>
|
4277 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4278 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4279 |
+
</a>
|
4280 |
+
</div>
|
4281 |
+
<div class="option-tree-setting-body">
|
4282 |
+
<div class="format-settings">
|
4283 |
+
<div class="format-setting-label">
|
4284 |
+
<h5>' . esc_html__( 'Label', 'option-tree' ) . '</h5>
|
4285 |
+
</div>
|
4286 |
+
<div class="format-setting type-text wide-desc">
|
4287 |
+
<div class="format-setting-inner">
|
4288 |
+
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][label]" value="' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4289 |
+
</div>
|
4290 |
+
</div>
|
4291 |
+
</div>
|
4292 |
+
<div class="format-settings">
|
4293 |
+
<div class="format-setting-label">
|
4294 |
+
<h5>' . esc_html__( 'Value', 'option-tree' ) . '</h5>
|
4295 |
+
</div>
|
4296 |
+
<div class="format-setting type-text wide-desc">
|
4297 |
+
<div class="format-setting-inner">
|
4298 |
+
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][value]" value="' . ( isset( $choice['value'] ) ? esc_attr( $choice['value'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4299 |
+
</div>
|
4300 |
+
</div>
|
4301 |
+
</div>
|
4302 |
+
<div class="format-settings">
|
4303 |
+
<div class="format-setting-label">
|
4304 |
+
<h5>' . esc_html__( 'Image Source (Radio Image only)', 'option-tree' ) . '</h5>
|
4305 |
+
</div>
|
4306 |
+
<div class="format-setting type-text wide-desc">
|
4307 |
+
<div class="format-setting-inner">
|
4308 |
+
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][src]" value="' . ( isset( $choice['src'] ) ? esc_attr( $choice['src'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4309 |
+
</div>
|
4310 |
+
</div>
|
4311 |
+
</div>
|
4312 |
+
</div>
|
4313 |
+
</div>';
|
4314 |
+
|
4315 |
+
}
|
4316 |
}
|
4317 |
|
4318 |
+
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4319 |
|
4320 |
+
/**
|
4321 |
+
* Helper function to display sections.
|
4322 |
+
*
|
4323 |
+
* This function is used in AJAX to add a new section
|
4324 |
+
* and when section have already been added and saved.
|
4325 |
+
*
|
4326 |
+
* @param string $name The name/ID of the help page.
|
4327 |
+
* @param int $key The array key for the current element.
|
4328 |
+
* @param array $content An array of values for the current section.
|
4329 |
+
*
|
4330 |
+
* @return string
|
4331 |
+
*
|
4332 |
+
* @access public
|
4333 |
+
* @since 2.0
|
4334 |
+
*/
|
4335 |
+
function ot_contextual_help_view( $name, $key, $content = array() ) {
|
4336 |
+
|
4337 |
+
/* translators: %s: Title emphasized */
|
4338 |
+
$str_title = esc_html__( '%s: Displayed as a contextual help menu item on the Theme Options page.', 'option-tree' );
|
4339 |
+
|
4340 |
+
/* translators: %s: ID emphasized */
|
4341 |
+
$str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' );
|
4342 |
+
|
4343 |
+
/* translators: %s: Content emphasized */
|
4344 |
+
$str_content = esc_html__( '%s: Enter the HTML content about this contextual help item displayed on the Theme Option page for end users to read.', 'option-tree' );
|
4345 |
+
|
4346 |
+
return '
|
4347 |
+
<div class="option-tree-setting">
|
4348 |
+
<div class="open">' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( absint( $key ) + 1 ) ) . '</div>
|
4349 |
+
<div class="button-section">
|
4350 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4351 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4352 |
+
</a>
|
4353 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4354 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4355 |
+
</a>
|
4356 |
+
</div>
|
4357 |
+
<div class="option-tree-setting-body">
|
4358 |
+
<div class="format-settings">
|
4359 |
+
<div class="format-setting type-text no-desc">
|
4360 |
+
<div class="description">' . sprintf( $str_title, '<strong>' . esc_html__( 'Title', 'option-tree' ) . '</strong>' ) . '</div>
|
4361 |
+
<div class="format-setting-inner">
|
4362 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4363 |
+
</div>
|
4364 |
+
</div>
|
4365 |
+
</div>
|
4366 |
+
<div class="format-settings">
|
4367 |
+
<div class="format-setting type-text no-desc">
|
4368 |
+
<div class="description">' . sprintf( $str_id, '<strong>' . esc_html__( 'ID', 'option-tree' ) . '</strong>' ) . '</div>
|
4369 |
+
<div class="format-setting-inner">
|
4370 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $content['id'] ) ? esc_attr( $content['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4371 |
+
</div>
|
4372 |
+
</div>
|
4373 |
+
</div>
|
4374 |
+
<div class="format-settings">
|
4375 |
+
<div class="format-setting type-textarea no-desc">
|
4376 |
+
<div class="description">' . sprintf( $str_content, '<strong>' . esc_html__( 'Content', 'option-tree' ) . '</strong>' ) . '</div>
|
4377 |
+
<div class="format-setting-inner">
|
4378 |
+
<textarea class="textarea" rows="15" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][content]">' . ( isset( $content['content'] ) ? esc_textarea( $content['content'] ) : '' ) . '</textarea>
|
4379 |
+
</div>
|
4380 |
+
</div>
|
4381 |
+
</div>
|
4382 |
+
</div>
|
4383 |
+
</div>';
|
4384 |
+
|
4385 |
+
}
|
4386 |
+
}
|
4387 |
|
4388 |
+
if ( ! function_exists( 'ot_layout_view' ) ) {
|
4389 |
|
4390 |
+
/**
|
4391 |
+
* Helper function to display sections.
|
4392 |
+
*
|
4393 |
+
* @param string $key Layout ID.
|
4394 |
+
* @param string $data Layout encoded value.
|
4395 |
+
* @param string $active_layout Active layout ID.
|
4396 |
+
*
|
4397 |
+
* @return string
|
4398 |
+
*
|
4399 |
+
* @access public
|
4400 |
+
* @since 2.0
|
4401 |
+
*/
|
4402 |
+
function ot_layout_view( $key, $data = '', $active_layout = '' ) {
|
4403 |
+
|
4404 |
+
return '
|
4405 |
+
<div class="option-tree-setting">
|
4406 |
+
<div class="open">' . ( isset( $key ) ? esc_attr( $key ) : esc_html__( 'Layout', 'option-tree' ) ) . '</div>
|
4407 |
+
<div class="button-section">
|
4408 |
+
<a href="javascript:void(0);" class="option-tree-layout-activate option-tree-ui-button button left-item' . ( $active_layout === $key ? ' active' : '' ) . '" title="' . esc_html__( 'Activate', 'option-tree' ) . '">
|
4409 |
+
<span class="icon ot-icon-square-o"></span>' . esc_html__( 'Activate', 'option-tree' ) . '
|
4410 |
+
</a>
|
4411 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4412 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4413 |
+
</a>
|
4414 |
+
</div>
|
4415 |
+
<input type="hidden" name="' . esc_attr( ot_layouts_id() ) . '[' . esc_attr( $key ) . ']" value="' . esc_attr( $data ) . '" />
|
4416 |
+
</div>';
|
4417 |
+
}
|
4418 |
+
}
|
4419 |
|
4420 |
+
if ( ! function_exists( 'ot_list_item_view' ) ) {
|
4421 |
|
4422 |
+
/**
|
4423 |
+
* Helper function to display list items.
|
4424 |
+
*
|
4425 |
+
* This function is used in AJAX to add a new list items
|
4426 |
+
* and when they have already been added and saved.
|
4427 |
+
*
|
4428 |
+
* @param string $name The form field name.
|
4429 |
+
* @param int $key The array key for the current element.
|
4430 |
+
* @param array $list_item An array of values for the current list item.
|
4431 |
+
* @param int $post_id The post ID.
|
4432 |
+
* @param string $get_option The option page ID.
|
4433 |
+
* @param array $settings The settings.
|
4434 |
+
* @param string $type The list type.
|
4435 |
+
*
|
4436 |
+
* @access public
|
4437 |
+
* @since 2.0
|
4438 |
+
*/
|
4439 |
+
function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
4440 |
+
|
4441 |
+
// Required title setting.
|
4442 |
+
$required_setting = array(
|
4443 |
+
array(
|
4444 |
+
'id' => 'title',
|
4445 |
+
'label' => __( 'Title', 'option-tree' ),
|
4446 |
+
'desc' => '',
|
4447 |
+
'std' => '',
|
4448 |
+
'type' => 'text',
|
4449 |
+
'rows' => '',
|
4450 |
+
'class' => 'option-tree-setting-title',
|
4451 |
+
'post_type' => '',
|
4452 |
+
'choices' => array(),
|
4453 |
+
),
|
4454 |
+
);
|
4455 |
+
|
4456 |
+
// Load the old filterable slider settings.
|
4457 |
+
if ( 'slider' === $type ) {
|
4458 |
+
$settings = ot_slider_settings( $name );
|
4459 |
+
}
|
4460 |
+
|
4461 |
+
// If no settings array load the filterable list item settings.
|
4462 |
+
if ( empty( $settings ) ) {
|
4463 |
+
$settings = ot_list_item_settings( $name );
|
4464 |
+
}
|
4465 |
+
|
4466 |
+
// Merge the two settings array.
|
4467 |
+
$settings = array_merge( $required_setting, $settings );
|
4468 |
+
|
4469 |
+
echo '
|
4470 |
+
<div class="option-tree-setting">
|
4471 |
+
<div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
|
4472 |
+
<div class="button-section">
|
4473 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4474 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4475 |
+
</a>
|
4476 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4477 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4478 |
+
</a>
|
4479 |
+
</div>
|
4480 |
+
<div class="option-tree-setting-body">
|
4481 |
+
';
|
4482 |
+
|
4483 |
+
foreach ( $settings as $field ) {
|
4484 |
+
|
4485 |
+
// Set field value.
|
4486 |
+
$field_value = isset( $list_item[ $field['id'] ] ) ? $list_item[ $field['id'] ] : '';
|
4487 |
+
|
4488 |
+
// Set default to standard value.
|
4489 |
+
if ( isset( $field['std'] ) ) {
|
4490 |
+
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4491 |
+
}
|
4492 |
+
|
4493 |
+
// filter the title label and description.
|
4494 |
+
if ( 'title' === $field['id'] ) {
|
4495 |
+
|
4496 |
+
// filter the label.
|
4497 |
+
$field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name );
|
4498 |
+
|
4499 |
+
// filter the description.
|
4500 |
+
$field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name );
|
4501 |
+
}
|
4502 |
+
|
4503 |
+
// Make life easier.
|
4504 |
+
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4505 |
+
|
4506 |
+
// Build the arguments array.
|
4507 |
+
$_args = array(
|
4508 |
+
'type' => $field['type'],
|
4509 |
+
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4510 |
+
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4511 |
+
'field_value' => $field_value,
|
4512 |
+
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4513 |
+
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4514 |
+
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4515 |
+
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4516 |
+
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4517 |
+
'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4518 |
+
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4519 |
+
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4520 |
+
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4521 |
+
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4522 |
+
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4523 |
+
'post_id' => $post_id,
|
4524 |
+
'get_option' => $get_option,
|
4525 |
+
);
|
4526 |
+
|
4527 |
+
$conditions = '';
|
4528 |
+
|
4529 |
+
// Setup the conditions.
|
4530 |
+
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4531 |
+
|
4532 |
+
/* doing magic on the conditions so they work in a list item */
|
4533 |
+
$conditionals = explode( ',', $field['condition'] );
|
4534 |
+
foreach ( $conditionals as $condition ) {
|
4535 |
+
$parts = explode( ':', $condition );
|
4536 |
+
if ( isset( $parts[0] ) ) {
|
4537 |
+
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4538 |
+
}
|
4539 |
+
}
|
4540 |
+
|
4541 |
+
$conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"';
|
4542 |
+
$conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : '';
|
4543 |
+
}
|
4544 |
+
|
4545 |
+
// Build the setting CSS class.
|
4546 |
+
if ( ! empty( $_args['field_class'] ) ) {
|
4547 |
+
$classes = explode( ' ', $_args['field_class'] );
|
4548 |
+
|
4549 |
+
foreach ( $classes as $_key => $value ) {
|
4550 |
+
$classes[ $_key ] = $value . '-wrap';
|
4551 |
+
}
|
4552 |
+
|
4553 |
+
$class = 'format-settings ' . implode( ' ', $classes );
|
4554 |
+
} else {
|
4555 |
+
$class = 'format-settings';
|
4556 |
+
}
|
4557 |
+
|
4558 |
+
// Option label.
|
4559 |
+
echo '<div id="setting_' . esc_attr( $_args['field_id'] ) . '" class="' . esc_attr( $class ) . '"' . $conditions . '>'; // phpcs:ignore
|
4560 |
+
|
4561 |
+
// Don't show title with textblocks.
|
4562 |
+
if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) {
|
4563 |
+
echo '<div class="format-setting-label">';
|
4564 |
+
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4565 |
+
echo '</div>';
|
4566 |
+
}
|
4567 |
+
|
4568 |
+
// Only allow simple textarea inside a list-item due to known DOM issues with wp_editor().
|
4569 |
+
if ( false === apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) && 'textarea' === $_args['type'] ) {
|
4570 |
+
$_args['type'] = 'textarea-simple';
|
4571 |
+
}
|
4572 |
+
|
4573 |
+
// Option body, list-item is not allowed inside another list-item.
|
4574 |
+
if ( 'list-item' !== $_args['type'] && 'slider' !== $_args['type'] ) {
|
4575 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
4576 |
+
}
|
4577 |
+
|
4578 |
+
echo '</div>';
|
4579 |
+
}
|
4580 |
+
|
4581 |
+
echo '</div>';
|
4582 |
+
|
4583 |
+
echo '</div>';
|
4584 |
+
}
|
4585 |
}
|
4586 |
|
4587 |
+
if ( ! function_exists( 'ot_social_links_view' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4588 |
|
4589 |
+
/**
|
4590 |
+
* Helper function to display social links.
|
4591 |
+
*
|
4592 |
+
* This function is used in AJAX to add a new list items
|
4593 |
+
* and when they have already been added and saved.
|
4594 |
+
*
|
4595 |
+
* @param string $name The form field name.
|
4596 |
+
* @param int $key The array key for the current element.
|
4597 |
+
* @param array $list_item An array of values for the current list item.
|
4598 |
+
* @param int $post_id The post ID.
|
4599 |
+
* @param string $get_option The option page ID.
|
4600 |
+
* @param array $settings The settings.
|
4601 |
+
*
|
4602 |
+
* @access public
|
4603 |
+
* @since 2.4.0
|
4604 |
+
*/
|
4605 |
+
function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array() ) {
|
4606 |
+
|
4607 |
+
// If no settings array load the filterable social links settings.
|
4608 |
+
if ( empty( $settings ) ) {
|
4609 |
+
$settings = ot_social_links_settings( $name );
|
4610 |
+
}
|
4611 |
+
|
4612 |
+
echo '
|
4613 |
+
<div class="option-tree-setting">
|
4614 |
+
<div class="open">' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '</div>
|
4615 |
+
<div class="button-section">
|
4616 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4617 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4618 |
+
</a>
|
4619 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4620 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4621 |
+
</a>
|
4622 |
+
</div>
|
4623 |
+
<div class="option-tree-setting-body">
|
4624 |
+
';
|
4625 |
+
|
4626 |
+
foreach ( $settings as $field ) {
|
4627 |
+
|
4628 |
+
// Set field value.
|
4629 |
+
$field_value = isset( $list_item[ $field['id'] ] ) ? $list_item[ $field['id'] ] : '';
|
4630 |
+
|
4631 |
+
// Set default to standard value.
|
4632 |
+
if ( isset( $field['std'] ) ) {
|
4633 |
+
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4634 |
+
}
|
4635 |
+
|
4636 |
+
// Make life easier.
|
4637 |
+
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4638 |
+
|
4639 |
+
// Build the arguments array.
|
4640 |
+
$_args = array(
|
4641 |
+
'type' => $field['type'],
|
4642 |
+
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4643 |
+
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4644 |
+
'field_value' => $field_value,
|
4645 |
+
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4646 |
+
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4647 |
+
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4648 |
+
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4649 |
+
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4650 |
+
'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4651 |
+
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4652 |
+
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4653 |
+
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4654 |
+
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4655 |
+
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4656 |
+
'post_id' => $post_id,
|
4657 |
+
'get_option' => $get_option,
|
4658 |
+
);
|
4659 |
+
|
4660 |
+
$conditions = '';
|
4661 |
+
|
4662 |
+
// Setup the conditions.
|
4663 |
+
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4664 |
+
|
4665 |
+
// Doing magic on the conditions so they work in a list item.
|
4666 |
+
$conditionals = explode( ',', $field['condition'] );
|
4667 |
+
foreach ( $conditionals as $condition ) {
|
4668 |
+
$parts = explode( ':', $condition );
|
4669 |
+
if ( isset( $parts[0] ) ) {
|
4670 |
+
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4671 |
+
}
|
4672 |
+
}
|
4673 |
+
|
4674 |
+
$conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"';
|
4675 |
+
$conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : '';
|
4676 |
+
}
|
4677 |
+
|
4678 |
+
// Option label.
|
4679 |
+
echo '<div id="setting_' . esc_attr( $_args['field_id'] ) . '" class="format-settings"' . $conditions . '>'; // phpcs:ignore
|
4680 |
+
|
4681 |
+
// Don't show title with textblocks.
|
4682 |
+
if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) {
|
4683 |
+
echo '<div class="format-setting-label">';
|
4684 |
+
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4685 |
+
echo '</div>';
|
4686 |
+
}
|
4687 |
+
|
4688 |
+
// Only allow simple textarea inside a list-item due to known DOM issues with wp_editor().
|
4689 |
+
if ( 'textarea' === $_args['type'] ) {
|
4690 |
+
$_args['type'] = 'textarea-simple';
|
4691 |
+
}
|
4692 |
+
|
4693 |
+
// Option body, list-item is not allowed inside another list-item.
|
4694 |
+
if ( 'list-item' !== $_args['type'] && 'slider' !== $_args['type'] && 'social-links' !== $_args['type'] ) {
|
4695 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
4696 |
+
}
|
4697 |
+
|
4698 |
+
echo '</div>';
|
4699 |
+
}
|
4700 |
+
|
4701 |
+
echo '</div>';
|
4702 |
+
|
4703 |
+
echo '</div>';
|
4704 |
+
}
|
4705 |
+
}
|
4706 |
|
4707 |
+
if ( ! function_exists( 'ot_theme_options_layouts_form' ) ) {
|
|
|
4708 |
|
4709 |
+
/**
|
4710 |
+
* Helper function to display Theme Options layouts form.
|
4711 |
+
*
|
4712 |
+
* @access public
|
4713 |
+
* @since 2.0
|
4714 |
+
*/
|
4715 |
+
function ot_theme_options_layouts_form() {
|
4716 |
|
4717 |
+
echo '<form method="post" id="option-tree-options-layouts-form">';
|
4718 |
|
4719 |
+
// Form nonce.
|
4720 |
+
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
4721 |
|
4722 |
+
// Get the saved layouts.
|
4723 |
+
$layouts = get_option( ot_layouts_id() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4724 |
|
4725 |
+
// Set active layout.
|
4726 |
+
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
4727 |
|
4728 |
+
if ( is_array( $layouts ) && 1 < count( $layouts ) ) {
|
|
|
4729 |
|
4730 |
+
$active_layout = $layouts['active_layout'];
|
|
|
4731 |
|
4732 |
+
echo '<input type="hidden" id="the_current_layout" value="' . esc_attr( $active_layout ) . '" />';
|
|
|
4733 |
|
4734 |
+
echo '<div class="option-tree-active-layout">';
|
4735 |
|
4736 |
+
echo '<select name="' . esc_attr( ot_layouts_id() ) . '[active_layout]" class="option-tree-ui-select">';
|
4737 |
|
4738 |
+
$hidden = '';
|
|
|
4739 |
|
4740 |
+
foreach ( $layouts as $key => $data ) {
|
|
|
4741 |
|
4742 |
+
if ( 'active_layout' === $key ) {
|
4743 |
+
continue;
|
4744 |
+
}
|
|
|
|
|
|
|
4745 |
|
4746 |
+
echo '<option ' . selected( $key, $active_layout, false ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $key ) . '</option>';
|
4747 |
+
$hidden_safe .= '<input type="hidden" name="' . esc_attr( ot_layouts_id() ) . '[' . esc_attr( $key ) . ']" value="' . esc_attr( isset( $data ) ? $data : '' ) . '" />';
|
4748 |
+
}
|
4749 |
|
4750 |
+
echo '</select>';
|
|
|
4751 |
|
4752 |
+
echo '</div>';
|
4753 |
|
4754 |
+
echo $hidden_safe; // phpcs:ignore
|
4755 |
+
}
|
|
|
4756 |
|
4757 |
+
/* new layout wrapper */
|
4758 |
+
echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
|
4759 |
|
4760 |
+
/* add new layout */
|
4761 |
+
echo '<input type="text" name="' . esc_attr( ot_layouts_id() ) . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4762 |
|
4763 |
+
echo '<button type="submit" class="option-tree-ui-button button button-primary save-layout" title="' . esc_html__( 'New Layout', 'option-tree' ) . '">' . esc_html__( 'New Layout', 'option-tree' ) . '</button>';
|
|
|
4764 |
|
4765 |
+
echo '</div>';
|
|
|
4766 |
|
4767 |
+
echo '</form>';
|
4768 |
+
}
|
4769 |
+
}
|
|
|
|
|
4770 |
|
4771 |
+
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
|
|
|
|
|
4772 |
|
4773 |
+
/**
|
4774 |
+
* Helper function to sanitize the option ID's.
|
4775 |
+
*
|
4776 |
+
* @param string $input The string to sanitize.
|
4777 |
+
* @return string
|
4778 |
+
*
|
4779 |
+
* @access public
|
4780 |
+
* @since 2.0
|
4781 |
+
*/
|
4782 |
+
function ot_sanitize_option_id( $input ) {
|
4783 |
+
return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
|
4784 |
+
}
|
4785 |
+
}
|
4786 |
|
4787 |
+
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
|
|
|
4788 |
|
4789 |
+
/**
|
4790 |
+
* Helper function to sanitize the layout ID's.
|
4791 |
+
*
|
4792 |
+
* @param string $input The string to sanitize.
|
4793 |
+
* @return string
|
4794 |
+
*
|
4795 |
+
* @access public
|
4796 |
+
* @since 2.0
|
4797 |
+
*/
|
4798 |
+
function ot_sanitize_layout_id( $input ) {
|
4799 |
+
return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
|
4800 |
+
}
|
4801 |
+
}
|
4802 |
|
4803 |
+
if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
|
|
|
4804 |
|
4805 |
+
/**
|
4806 |
+
* Convert choices array to string.
|
4807 |
+
*
|
4808 |
+
* @param array $input The array to convert to a string.
|
4809 |
+
*
|
4810 |
+
* @return bool|string
|
4811 |
+
*
|
4812 |
+
* @access public
|
4813 |
+
* @since 2.0
|
4814 |
+
*/
|
4815 |
+
function ot_convert_array_to_string( $input ) {
|
4816 |
+
|
4817 |
+
if ( is_array( $input ) ) {
|
4818 |
+
|
4819 |
+
foreach ( $input as $k => $choice ) {
|
4820 |
+
$choices[ $k ] = $choice['value'] . '|' . $choice['label'];
|
4821 |
+
|
4822 |
+
if ( isset( $choice['src'] ) ) {
|
4823 |
+
$choices[ $k ] .= '|' . $choice['src'];
|
4824 |
+
}
|
4825 |
+
}
|
4826 |
+
|
4827 |
+
return implode( ',', $choices );
|
4828 |
+
}
|
4829 |
+
|
4830 |
+
return false;
|
4831 |
+
}
|
4832 |
+
}
|
4833 |
|
4834 |
+
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
|
|
|
4835 |
|
4836 |
+
/**
|
4837 |
+
* Convert choices string to array.
|
4838 |
+
*
|
4839 |
+
* @param string $input The string to convert to an array.
|
4840 |
+
*
|
4841 |
+
* @return bool|array
|
4842 |
+
*
|
4843 |
+
* @access public
|
4844 |
+
* @since 2.0
|
4845 |
+
*/
|
4846 |
+
function ot_convert_string_to_array( $input ) {
|
4847 |
+
|
4848 |
+
if ( '' !== $input ) {
|
4849 |
+
|
4850 |
+
// Empty choices array.
|
4851 |
+
$choices = array();
|
4852 |
+
|
4853 |
+
// Exlode the string into an array.
|
4854 |
+
foreach ( explode( ',', $input ) as $k => $choice ) {
|
4855 |
+
|
4856 |
+
// If ":" is splitting the string go deeper.
|
4857 |
+
if ( preg_match( '/\|/', $choice ) ) {
|
4858 |
+
$split = explode( '|', $choice );
|
4859 |
+
|
4860 |
+
if ( 2 > count( $split ) ) {
|
4861 |
+
continue;
|
4862 |
+
}
|
4863 |
+
|
4864 |
+
$choices[ $k ]['value'] = trim( $split[0] );
|
4865 |
+
$choices[ $k ]['label'] = trim( $split[1] );
|
4866 |
+
|
4867 |
+
// If radio image there are three values.
|
4868 |
+
if ( isset( $split[2] ) ) {
|
4869 |
+
$choices[ $k ]['src'] = trim( $split[2] );
|
4870 |
+
}
|
4871 |
+
} else {
|
4872 |
+
$choices[ $k ]['value'] = trim( $choice );
|
4873 |
+
$choices[ $k ]['label'] = trim( $choice );
|
4874 |
+
}
|
4875 |
+
}
|
4876 |
+
|
4877 |
+
// Return a formatted choices array.
|
4878 |
+
return $choices;
|
4879 |
+
}
|
4880 |
+
|
4881 |
+
return false;
|
4882 |
+
}
|
4883 |
+
}
|
4884 |
|
4885 |
+
if ( ! function_exists( 'ot_strpos_array' ) ) {
|
4886 |
|
4887 |
+
/**
|
4888 |
+
* Helper function - strpos() in array recursively.
|
4889 |
+
*
|
4890 |
+
* @param string $haystack The string to search in.
|
4891 |
+
* @param array $needles Keys to search for.
|
4892 |
+
* @return bool
|
4893 |
+
*
|
4894 |
+
* @access public
|
4895 |
+
* @since 2.0
|
4896 |
+
*/
|
4897 |
+
function ot_strpos_array( $haystack, $needles = array() ) {
|
4898 |
+
|
4899 |
+
foreach ( $needles as $needle ) {
|
4900 |
+
if ( false !== strpos( $haystack, $needle ) ) {
|
4901 |
+
return true;
|
4902 |
+
}
|
4903 |
+
}
|
4904 |
+
|
4905 |
+
return false;
|
4906 |
+
}
|
4907 |
+
}
|
4908 |
|
4909 |
+
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
|
4910 |
|
4911 |
+
/**
|
4912 |
+
* Helper function - array_key_exists() recursively.
|
4913 |
+
*
|
4914 |
+
* @param array $haystack The array to search in.
|
4915 |
+
* @param array $needles Keys to search for.
|
4916 |
+
* @return bool
|
4917 |
+
*
|
4918 |
+
* @access public
|
4919 |
+
* @since 2.0
|
4920 |
+
*/
|
4921 |
+
function ot_array_keys_exists( $haystack, $needles = array() ) {
|
4922 |
+
|
4923 |
+
foreach ( $needles as $k ) {
|
4924 |
+
if ( isset( $haystack[ $k ] ) ) {
|
4925 |
+
return true;
|
4926 |
+
}
|
4927 |
+
}
|
4928 |
+
|
4929 |
+
return false;
|
4930 |
+
}
|
4931 |
+
}
|
4932 |
|
4933 |
+
if ( ! function_exists( 'ot_stripslashes' ) ) {
|
4934 |
|
4935 |
+
/**
|
4936 |
+
* Custom stripslashes from single value or array.
|
4937 |
+
*
|
4938 |
+
* @param mixed $input The string or array to stripslashes from.
|
4939 |
+
* @return mixed
|
4940 |
+
*
|
4941 |
+
* @access public
|
4942 |
+
* @since 2.0
|
4943 |
+
*/
|
4944 |
+
function ot_stripslashes( $input ) {
|
4945 |
+
|
4946 |
+
if ( is_array( $input ) ) {
|
4947 |
+
|
4948 |
+
foreach ( $input as &$val ) {
|
4949 |
+
|
4950 |
+
if ( is_array( $val ) ) {
|
4951 |
+
$val = ot_stripslashes( $val );
|
4952 |
+
} else {
|
4953 |
+
$val = stripslashes( trim( $val ) );
|
4954 |
+
}
|
4955 |
+
}
|
4956 |
+
} else {
|
4957 |
+
$input = stripslashes( trim( $input ) );
|
4958 |
+
}
|
4959 |
+
|
4960 |
+
return $input;
|
4961 |
+
}
|
4962 |
+
}
|
4963 |
|
4964 |
+
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
4965 |
|
4966 |
+
/**
|
4967 |
+
* Reverse wpautop.
|
4968 |
+
*
|
4969 |
+
* @param string $string The string to be filtered.
|
4970 |
+
* @return string
|
4971 |
+
*
|
4972 |
+
* @access public
|
4973 |
+
* @since 2.0.9
|
4974 |
+
*/
|
4975 |
+
function ot_reverse_wpautop( $string = '' ) {
|
4976 |
+
|
4977 |
+
// Return if string is empty.
|
4978 |
+
if ( '' === trim( $string ) ) {
|
4979 |
+
return '';
|
4980 |
+
}
|
4981 |
+
|
4982 |
+
// Remove all new lines & <p> tags.
|
4983 |
+
$string = str_replace( array( "\n", '<p>' ), '', $string );
|
4984 |
+
|
4985 |
+
// Replace <br /> with \r.
|
4986 |
+
$string = str_replace( array( '<br />', '<br>', '<br/>' ), "\r", $string );
|
4987 |
+
|
4988 |
+
// Replace </p> with \r\n.
|
4989 |
+
$string = str_replace( '</p>', "\r\n", $string );
|
4990 |
+
|
4991 |
+
// Return clean string.
|
4992 |
+
return trim( $string );
|
4993 |
+
}
|
4994 |
+
}
|
4995 |
|
4996 |
+
if ( ! function_exists( 'ot_range' ) ) {
|
4997 |
+
|
4998 |
+
/**
|
4999 |
+
* Returns an array of elements from start to limit, inclusive.
|
5000 |
+
*
|
5001 |
+
* Occasionally zero will be some impossibly large number to
|
5002 |
+
* the "E" power when creating a range from negative to positive.
|
5003 |
+
* This function attempts to fix that by setting that number back to "0".
|
5004 |
+
*
|
5005 |
+
* @param string $start First value of the sequence.
|
5006 |
+
* @param string $limit The sequence is ended upon reaching the limit value.
|
5007 |
+
* @param int $step If a step value is given, it will be used as the increment
|
5008 |
+
* between elements in the sequence. step should be given as a
|
5009 |
+
* positive number. If not specified, step will default to 1.
|
5010 |
+
*
|
5011 |
+
* @return array
|
5012 |
+
*
|
5013 |
+
* @access public
|
5014 |
+
* @since 2.0.12
|
5015 |
+
*/
|
5016 |
+
function ot_range( $start, $limit, $step = 1 ) {
|
5017 |
+
|
5018 |
+
if ( $step < 0 ) {
|
5019 |
+
$step = 1;
|
5020 |
+
}
|
5021 |
+
|
5022 |
+
$range = range( $start, $limit, $step );
|
5023 |
+
|
5024 |
+
foreach ( $range as $k => $v ) {
|
5025 |
+
if ( strpos( $v, 'E' ) ) {
|
5026 |
+
$range[ $k ] = 0;
|
5027 |
+
}
|
5028 |
+
}
|
5029 |
+
|
5030 |
+
return $range;
|
5031 |
+
}
|
5032 |
+
}
|
5033 |
|
5034 |
+
if ( ! function_exists( 'ot_encode' ) ) {
|
5035 |
+
|
5036 |
+
/**
|
5037 |
+
* Helper function to return encoded strings.
|
5038 |
+
*
|
5039 |
+
* @param array $value The array to encode.
|
5040 |
+
*
|
5041 |
+
* @return string|bool
|
5042 |
+
*
|
5043 |
+
* @access public
|
5044 |
+
* @since 2.0.13
|
5045 |
+
* @updated 2.7.0
|
5046 |
+
*/
|
5047 |
+
function ot_encode( $value ) {
|
5048 |
+
if ( is_array( $value ) ) {
|
5049 |
+
return base64_encode( maybe_serialize( $value ) ); // phpcs:ignore
|
5050 |
+
}
|
5051 |
+
|
5052 |
+
return false;
|
5053 |
+
}
|
5054 |
+
}
|
5055 |
|
5056 |
+
if ( ! function_exists( 'ot_decode' ) ) {
|
5057 |
|
5058 |
+
/**
|
5059 |
+
* Helper function to return decoded arrays.
|
5060 |
+
*
|
5061 |
+
* @param string $value Encoded serialized array.
|
5062 |
+
*
|
5063 |
+
* @return array
|
5064 |
+
*
|
5065 |
+
* @access public
|
5066 |
+
* @since 2.0.13
|
5067 |
+
*/
|
5068 |
+
function ot_decode( $value ) {
|
5069 |
|
5070 |
+
$fallback = array();
|
5071 |
+
$decoded = base64_decode( $value ); // phpcs:ignore
|
5072 |
|
5073 |
+
// Search for an array.
|
5074 |
+
preg_match( '/a:\d+:{.*?}/', $decoded, $array_matches, PREG_OFFSET_CAPTURE, 0 );
|
5075 |
|
5076 |
+
// Search for an object.
|
5077 |
+
preg_match( '/O|C:\+?\d+:"[a-z0-9_]+”:\+?\d+:/i', $decoded, $obj_matches, PREG_OFFSET_CAPTURE, 0 );
|
5078 |
|
5079 |
+
// Prevent object injection or non arrays.
|
5080 |
+
if ( $obj_matches || ! $array_matches ) {
|
5081 |
+
return $fallback;
|
5082 |
+
}
|
5083 |
|
5084 |
+
// Convert the options to an array.
|
5085 |
+
$decoded = maybe_unserialize( $decoded );
|
5086 |
|
5087 |
+
if ( is_array( $decoded ) ) {
|
5088 |
+
return $decoded;
|
5089 |
+
}
|
5090 |
|
5091 |
+
return $fallback;
|
5092 |
+
}
|
5093 |
+
}
|
5094 |
|
5095 |
+
if ( ! function_exists( 'ot_filter_std_value' ) ) {
|
5096 |
+
|
5097 |
+
/**
|
5098 |
+
* Helper function to filter standard option values.
|
5099 |
+
*
|
5100 |
+
* @param mixed $value Saved string or array value.
|
5101 |
+
* @param mixed $std Standard string or array value.
|
5102 |
+
*
|
5103 |
+
* @return mixed String or array.
|
5104 |
+
*
|
5105 |
+
* @access public
|
5106 |
+
* @since 2.0.15
|
5107 |
+
*/
|
5108 |
+
function ot_filter_std_value( $value = '', $std = '' ) {
|
5109 |
+
|
5110 |
+
if ( is_string( $std ) && ! empty( $std ) ) {
|
5111 |
+
|
5112 |
+
// Search for an array.
|
5113 |
+
preg_match( '/a:\d+:{.*?}/', $std, $array_matches, PREG_OFFSET_CAPTURE, 0 );
|
5114 |
+
|
5115 |
+
// Search for an object.
|
5116 |
+
preg_match( '/O:\d+:"[a-z0-9_]+":\d+:{.*?}/i', $std, $obj_matches, PREG_OFFSET_CAPTURE, 0 );
|
5117 |
+
|
5118 |
+
// Prevent object injection.
|
5119 |
+
if ( $array_matches && ! $obj_matches ) {
|
5120 |
+
$std = maybe_unserialize( $std );
|
5121 |
+
} elseif ( $obj_matches ) {
|
5122 |
+
$std = '';
|
5123 |
+
}
|
5124 |
+
}
|
5125 |
+
|
5126 |
+
if ( is_array( $value ) && is_array( $std ) ) {
|
5127 |
+
foreach ( $value as $k => $v ) {
|
5128 |
+
if ( '' === $value[ $k ] && isset( $std[ $k ] ) ) {
|
5129 |
+
$value[ $k ] = $std[ $k ];
|
5130 |
+
}
|
5131 |
+
}
|
5132 |
+
} elseif ( '' === $value && ! empty( $std ) ) {
|
5133 |
+
$value = $std;
|
5134 |
+
}
|
5135 |
+
|
5136 |
+
return $value;
|
5137 |
+
}
|
5138 |
+
}
|
5139 |
|
5140 |
+
if ( ! function_exists( 'ot_set_google_fonts' ) ) {
|
5141 |
+
|
5142 |
+
/**
|
5143 |
+
* Helper function to set the Google fonts array.
|
5144 |
+
*
|
5145 |
+
* @param string $id The option ID.
|
5146 |
+
* @param bool $value The option value.
|
5147 |
+
*
|
5148 |
+
* @access public
|
5149 |
+
* @since 2.5.0
|
5150 |
+
*/
|
5151 |
+
function ot_set_google_fonts( $id = '', $value = '' ) {
|
5152 |
+
|
5153 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
5154 |
+
|
5155 |
+
if ( is_array( $value ) && ! empty( $value ) ) {
|
5156 |
+
$ot_set_google_fonts[ $id ] = $value;
|
5157 |
+
} elseif ( isset( $ot_set_google_fonts[ $id ] ) ) {
|
5158 |
+
unset( $ot_set_google_fonts[ $id ] );
|
5159 |
+
}
|
5160 |
+
|
5161 |
+
set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
|
5162 |
+
}
|
5163 |
+
}
|
5164 |
|
5165 |
+
if ( ! function_exists( 'ot_update_google_fonts_after_save' ) ) {
|
5166 |
+
|
5167 |
+
/**
|
5168 |
+
* Helper function to remove unused options from the Google fonts array.
|
5169 |
+
*
|
5170 |
+
* @param array $options The array of saved options.
|
5171 |
+
*
|
5172 |
+
* @access public
|
5173 |
+
* @since 2.5.0
|
5174 |
+
*/
|
5175 |
+
function ot_update_google_fonts_after_save( $options = array() ) {
|
5176 |
+
|
5177 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
5178 |
+
|
5179 |
+
foreach ( $ot_set_google_fonts as $key => $set ) {
|
5180 |
+
if ( ! isset( $options[ $key ] ) ) {
|
5181 |
+
unset( $ot_set_google_fonts[ $key ] );
|
5182 |
+
}
|
5183 |
+
}
|
5184 |
+
set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
|
5185 |
+
}
|
5186 |
+
|
5187 |
+
add_action( 'ot_after_theme_options_save', 'ot_update_google_fonts_after_save', 1 );
|
5188 |
+
}
|
5189 |
|
5190 |
+
if ( ! function_exists( 'ot_fetch_google_fonts' ) ) {
|
5191 |
+
|
5192 |
+
/**
|
5193 |
+
* Helper function to fetch the Google fonts array.
|
5194 |
+
*
|
5195 |
+
* @param bool $normalize Whether or not to return a normalized array. Default 'true'.
|
5196 |
+
* @param bool $force_rebuild Whether or not to force the array to be rebuilt. Default 'false'.
|
5197 |
+
*
|
5198 |
+
* @return array
|
5199 |
+
*
|
5200 |
+
* @access public
|
5201 |
+
* @since 2.5.0
|
5202 |
+
*/
|
5203 |
+
function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
|
5204 |
+
|
5205 |
+
// Google Fonts cache key.
|
5206 |
+
$ot_google_fonts_cache_key = apply_filters( 'ot_google_fonts_cache_key', 'ot_google_fonts_cache' );
|
5207 |
+
|
5208 |
+
// Get the fonts from cache.
|
5209 |
+
$ot_google_fonts = apply_filters( 'ot_google_fonts_cache', get_transient( $ot_google_fonts_cache_key ) );
|
5210 |
+
|
5211 |
+
if ( $force_rebuild || ! is_array( $ot_google_fonts ) || empty( $ot_google_fonts ) ) {
|
5212 |
+
|
5213 |
+
$ot_google_fonts = array();
|
5214 |
+
|
5215 |
+
// API url and key.
|
5216 |
+
$ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' );
|
5217 |
+
$ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', false );
|
5218 |
+
|
5219 |
+
if ( false === $ot_google_fonts_api_key ) {
|
5220 |
+
return array();
|
5221 |
+
}
|
5222 |
+
|
5223 |
+
// API arguments.
|
5224 |
+
$ot_google_fonts_fields = apply_filters(
|
5225 |
+
'ot_google_fonts_fields',
|
5226 |
+
array(
|
5227 |
+
'family',
|
5228 |
+
'variants',
|
5229 |
+
'subsets',
|
5230 |
+
)
|
5231 |
+
);
|
5232 |
+
$ot_google_fonts_sort = apply_filters( 'ot_google_fonts_sort', 'alpha' );
|
5233 |
+
|
5234 |
+
// Initiate API request.
|
5235 |
+
$ot_google_fonts_query_args = array(
|
5236 |
+
'key' => $ot_google_fonts_api_key,
|
5237 |
+
'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')',
|
5238 |
+
'sort' => $ot_google_fonts_sort,
|
5239 |
+
);
|
5240 |
+
|
5241 |
+
// Build and make the request.
|
5242 |
+
$ot_google_fonts_query = esc_url_raw( add_query_arg( $ot_google_fonts_query_args, $ot_google_fonts_api_url ) );
|
5243 |
+
$ot_google_fonts_response = wp_safe_remote_get(
|
5244 |
+
$ot_google_fonts_query,
|
5245 |
+
array(
|
5246 |
+
'sslverify' => false,
|
5247 |
+
'timeout' => 15,
|
5248 |
+
)
|
5249 |
+
);
|
5250 |
+
|
5251 |
+
// Continue if we got a valid response.
|
5252 |
+
if ( 200 === wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) {
|
5253 |
+
|
5254 |
+
$response_body = wp_remote_retrieve_body( $ot_google_fonts_response );
|
5255 |
+
|
5256 |
+
if ( $response_body ) {
|
5257 |
+
|
5258 |
+
// JSON decode the response body and cache the result.
|
5259 |
+
$ot_google_fonts_data = json_decode( trim( $response_body ), true );
|
5260 |
+
|
5261 |
+
if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) {
|
5262 |
+
|
5263 |
+
$ot_google_fonts = $ot_google_fonts_data['items'];
|
5264 |
+
|
5265 |
+
// Normalize the array key.
|
5266 |
+
$ot_google_fonts_tmp = array();
|
5267 |
+
foreach ( $ot_google_fonts as $key => $value ) {
|
5268 |
+
if ( ! isset( $value['family'] ) ) {
|
5269 |
+
continue;
|
5270 |
+
}
|
5271 |
+
|
5272 |
+
$id = preg_replace( '/[^a-z0-9_\-]/', '', strtolower( remove_accents( $value['family'] ) ) );
|
5273 |
+
|
5274 |
+
if ( $id ) {
|
5275 |
+
$ot_google_fonts_tmp[ $id ] = $value;
|
5276 |
+
}
|
5277 |
+
}
|
5278 |
+
|
5279 |
+
$ot_google_fonts = $ot_google_fonts_tmp;
|
5280 |
+
set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
|
5281 |
+
set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS );
|
5282 |
+
}
|
5283 |
+
}
|
5284 |
+
}
|
5285 |
+
}
|
5286 |
+
|
5287 |
+
return $normalize ? ot_normalize_google_fonts( $ot_google_fonts ) : $ot_google_fonts;
|
5288 |
+
}
|
5289 |
+
}
|
5290 |
|
5291 |
+
if ( ! function_exists( 'ot_normalize_google_fonts' ) ) {
|
5292 |
|
5293 |
+
/**
|
5294 |
+
* Helper function to normalize the Google fonts array.
|
5295 |
+
*
|
5296 |
+
* @param array $google_fonts An array of fonts to normalize.
|
5297 |
+
*
|
5298 |
+
* @return array
|
5299 |
+
*
|
5300 |
+
* @access public
|
5301 |
+
* @since 2.5.0
|
5302 |
+
*/
|
5303 |
+
function ot_normalize_google_fonts( $google_fonts ) {
|
5304 |
|
5305 |
+
$ot_normalized_google_fonts = array();
|
5306 |
|
5307 |
+
if ( is_array( $google_fonts ) && ! empty( $google_fonts ) ) {
|
5308 |
|
5309 |
+
foreach ( $google_fonts as $google_font ) {
|
5310 |
|
5311 |
+
if ( isset( $google_font['family'] ) ) {
|
5312 |
|
5313 |
+
$id = str_replace( ' ', '+', $google_font['family'] );
|
5314 |
|
5315 |
+
$ot_normalized_google_fonts[ $id ] = array(
|
5316 |
+
'family' => $google_font['family'],
|
5317 |
+
);
|
5318 |
|
5319 |
+
if ( isset( $google_font['variants'] ) ) {
|
5320 |
+
$ot_normalized_google_fonts[ $id ]['variants'] = $google_font['variants'];
|
5321 |
+
}
|
5322 |
|
5323 |
+
if ( isset( $google_font['subsets'] ) ) {
|
5324 |
+
$ot_normalized_google_fonts[ $id ]['subsets'] = $google_font['subsets'];
|
5325 |
+
}
|
5326 |
+
}
|
5327 |
+
}
|
5328 |
+
}
|
5329 |
|
5330 |
+
return $ot_normalized_google_fonts;
|
5331 |
+
}
|
5332 |
+
}
|
5333 |
|
5334 |
+
if ( ! function_exists( 'ot_wpml_register_string' ) ) {
|
5335 |
+
|
5336 |
+
/**
|
5337 |
+
* Helper function to register a WPML string.
|
5338 |
+
*
|
5339 |
+
* @param string $id The string ID.
|
5340 |
+
* @param string $value The string value.
|
5341 |
+
*
|
5342 |
+
* @access public
|
5343 |
+
* @since 2.1
|
5344 |
+
*/
|
5345 |
+
function ot_wpml_register_string( $id, $value ) {
|
5346 |
+
if ( function_exists( 'icl_register_string' ) ) {
|
5347 |
+
icl_register_string( 'Theme Options', $id, $value );
|
5348 |
+
}
|
5349 |
+
}
|
5350 |
+
}
|
5351 |
|
5352 |
+
if ( ! function_exists( 'ot_wpml_unregister_string' ) ) {
|
5353 |
+
|
5354 |
+
/**
|
5355 |
+
* Helper function to unregister a WPML string.
|
5356 |
+
*
|
5357 |
+
* @param string $id The string ID.
|
5358 |
+
*
|
5359 |
+
* @access public
|
5360 |
+
* @since 2.1
|
5361 |
+
*/
|
5362 |
+
function ot_wpml_unregister_string( $id ) {
|
5363 |
+
if ( function_exists( 'icl_unregister_string' ) ) {
|
5364 |
+
icl_unregister_string( 'Theme Options', $id );
|
5365 |
+
}
|
5366 |
+
}
|
5367 |
+
}
|
5368 |
|
5369 |
+
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
|
|
|
5370 |
|
5371 |
+
/**
|
5372 |
+
* Maybe migrate Settings.
|
5373 |
+
*
|
5374 |
+
* @access public
|
5375 |
+
* @since 2.3.3
|
5376 |
+
*/
|
5377 |
+
function ot_maybe_migrate_settings() {
|
5378 |
+
|
5379 |
+
// Filter the ID to migrate from.
|
5380 |
+
$settings_id = apply_filters( 'ot_migrate_settings_id', '' );
|
5381 |
+
|
5382 |
+
// Attempt to migrate Settings.
|
5383 |
+
if ( ! empty( $settings_id ) && false === get_option( ot_settings_id() ) && ot_settings_id() !== $settings_id ) {
|
5384 |
+
|
5385 |
+
// Old settings.
|
5386 |
+
$settings = get_option( $settings_id );
|
5387 |
+
|
5388 |
+
// Check for array keys.
|
5389 |
+
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
5390 |
+
update_option( ot_settings_id(), $settings );
|
5391 |
+
}
|
5392 |
+
}
|
5393 |
+
}
|
5394 |
+
}
|
5395 |
|
5396 |
+
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
|
5397 |
|
5398 |
+
/**
|
5399 |
+
* Maybe migrate Option.
|
5400 |
+
*
|
5401 |
+
* @access public
|
5402 |
+
* @since 2.3.3
|
5403 |
+
*/
|
5404 |
+
function ot_maybe_migrate_options() {
|
5405 |
|
5406 |
+
// Filter the ID to migrate from.
|
5407 |
+
$options_id = apply_filters( 'ot_migrate_options_id', '' );
|
5408 |
|
5409 |
+
// Attempt to migrate Theme Options.
|
5410 |
+
if ( ! empty( $options_id ) && false === get_option( ot_options_id() ) && ot_options_id() !== $options_id ) {
|
5411 |
|
5412 |
+
// Old options.
|
5413 |
+
$options = get_option( $options_id );
|
5414 |
|
5415 |
+
// Migrate to new ID.
|
5416 |
+
update_option( ot_options_id(), $options );
|
5417 |
+
}
|
5418 |
+
}
|
5419 |
}
|
5420 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5421 |
if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
|
5422 |
|
5423 |
+
/**
|
5424 |
+
* Maybe migrate Layouts.
|
5425 |
+
*
|
5426 |
+
* @access public
|
5427 |
+
* @since 2.3.3
|
5428 |
+
*/
|
5429 |
+
function ot_maybe_migrate_layouts() {
|
5430 |
|
5431 |
+
// Filter the ID to migrate from.
|
5432 |
+
$layouts_id = apply_filters( 'ot_migrate_layouts_id', '' );
|
5433 |
|
5434 |
+
// Attempt to migrate Layouts.
|
5435 |
+
if ( ! empty( $layouts_id ) && false === get_option( ot_layouts_id() ) && ot_layouts_id() !== $layouts_id ) {
|
5436 |
|
5437 |
+
// Old options.
|
5438 |
+
$layouts = get_option( $layouts_id );
|
|
|
5439 |
|
5440 |
+
// Migrate to new ID.
|
5441 |
+
update_option( ot_layouts_id(), $layouts );
|
5442 |
+
}
|
5443 |
+
}
|
5444 |
}
|
5445 |
|
5446 |
+
if ( ! function_exists( 'ot_meta_box_post_format_gallery' ) ) {
|
5447 |
+
|
5448 |
+
/**
|
5449 |
+
* Returns an array with the post format gallery meta box.
|
5450 |
+
*
|
5451 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5452 |
+
* post_types and is what tells the metabox where to
|
5453 |
+
* display. Default 'post'.
|
5454 |
+
* @return array
|
5455 |
+
*
|
5456 |
+
* @access public
|
5457 |
+
* @since 2.4.0
|
5458 |
+
*/
|
5459 |
+
function ot_meta_box_post_format_gallery( $pages = 'post' ) {
|
5460 |
+
|
5461 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'gallery', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5462 |
+
return false;
|
5463 |
+
}
|
5464 |
+
|
5465 |
+
if ( is_string( $pages ) ) {
|
5466 |
+
$pages = explode( ',', $pages );
|
5467 |
+
}
|
5468 |
+
|
5469 |
+
return apply_filters(
|
5470 |
+
'ot_meta_box_post_format_gallery',
|
5471 |
+
array(
|
5472 |
+
'id' => 'ot-post-format-gallery',
|
5473 |
+
'title' => esc_html__( 'Gallery', 'option-tree' ),
|
5474 |
+
'desc' => '',
|
5475 |
+
'pages' => $pages,
|
5476 |
+
'context' => 'side',
|
5477 |
+
'priority' => 'low',
|
5478 |
+
'fields' => array(
|
5479 |
+
array(
|
5480 |
+
'id' => '_format_gallery',
|
5481 |
+
'label' => '',
|
5482 |
+
'desc' => '',
|
5483 |
+
'std' => '',
|
5484 |
+
'type' => 'gallery',
|
5485 |
+
'class' => 'ot-gallery-shortcode',
|
5486 |
+
),
|
5487 |
+
),
|
5488 |
+
),
|
5489 |
+
$pages
|
5490 |
+
);
|
5491 |
+
}
|
5492 |
}
|
5493 |
|
5494 |
+
if ( ! function_exists( 'ot_meta_box_post_format_link' ) ) {
|
5495 |
+
|
5496 |
+
/**
|
5497 |
+
* Returns an array with the post format link metabox.
|
5498 |
+
*
|
5499 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5500 |
+
* post_types and is what tells the metabox where to
|
5501 |
+
* display. Default 'post'.
|
5502 |
+
* @return array
|
5503 |
+
*
|
5504 |
+
* @access public
|
5505 |
+
* @since 2.4.0
|
5506 |
+
*/
|
5507 |
+
function ot_meta_box_post_format_link( $pages = 'post' ) {
|
5508 |
+
|
5509 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5510 |
+
return false;
|
5511 |
+
}
|
5512 |
+
|
5513 |
+
if ( is_string( $pages ) ) {
|
5514 |
+
$pages = explode( ',', $pages );
|
5515 |
+
}
|
5516 |
+
|
5517 |
+
return apply_filters(
|
5518 |
+
'ot_meta_box_post_format_link',
|
5519 |
+
array(
|
5520 |
+
'id' => 'ot-post-format-link',
|
5521 |
+
'title' => esc_html__( 'Link', 'option-tree' ),
|
5522 |
+
'desc' => '',
|
5523 |
+
'pages' => $pages,
|
5524 |
+
'context' => 'side',
|
5525 |
+
'priority' => 'low',
|
5526 |
+
'fields' => array(
|
5527 |
+
array(
|
5528 |
+
'id' => '_format_link_url',
|
5529 |
+
'label' => '',
|
5530 |
+
'desc' => esc_html__( 'Link URL', 'option-tree' ),
|
5531 |
+
'std' => '',
|
5532 |
+
'type' => 'text',
|
5533 |
+
),
|
5534 |
+
array(
|
5535 |
+
'id' => '_format_link_title',
|
5536 |
+
'label' => '',
|
5537 |
+
'desc' => esc_html__( 'Link Title', 'option-tree' ),
|
5538 |
+
'std' => '',
|
5539 |
+
'type' => 'text',
|
5540 |
+
),
|
5541 |
+
),
|
5542 |
+
),
|
5543 |
+
$pages
|
5544 |
+
);
|
5545 |
+
}
|
5546 |
}
|
5547 |
|
5548 |
+
if ( ! function_exists( 'ot_meta_box_post_format_quote' ) ) {
|
5549 |
+
|
5550 |
+
/**
|
5551 |
+
* Returns an array with the post format quote metabox.
|
5552 |
+
*
|
5553 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5554 |
+
* post_types and is what tells the metabox where to
|
5555 |
+
* display. Default 'post'.
|
5556 |
+
* @return array
|
5557 |
+
*
|
5558 |
+
* @access public
|
5559 |
+
* @since 2.4.0
|
5560 |
+
*/
|
5561 |
+
function ot_meta_box_post_format_quote( $pages = 'post' ) {
|
5562 |
+
|
5563 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5564 |
+
return false;
|
5565 |
+
}
|
5566 |
+
|
5567 |
+
if ( is_string( $pages ) ) {
|
5568 |
+
$pages = explode( ',', $pages );
|
5569 |
+
}
|
5570 |
+
|
5571 |
+
return apply_filters(
|
5572 |
+
'ot_meta_box_post_format_quote',
|
5573 |
+
array(
|
5574 |
+
'id' => 'ot-post-format-quote',
|
5575 |
+
'title' => esc_html__( 'Quote', 'option-tree' ),
|
5576 |
+
'desc' => '',
|
5577 |
+
'pages' => $pages,
|
5578 |
+
'context' => 'side',
|
5579 |
+
'priority' => 'low',
|
5580 |
+
'fields' => array(
|
5581 |
+
array(
|
5582 |
+
'id' => '_format_quote_source_name',
|
5583 |
+
'label' => '',
|
5584 |
+
'desc' => esc_html__( 'Source Name (ex. author, singer, actor)', 'option-tree' ),
|
5585 |
+
'std' => '',
|
5586 |
+
'type' => 'text',
|
5587 |
+
),
|
5588 |
+
array(
|
5589 |
+
'id' => '_format_quote_source_url',
|
5590 |
+
'label' => '',
|
5591 |
+
'desc' => esc_html__( 'Source URL', 'option-tree' ),
|
5592 |
+
'std' => '',
|
5593 |
+
'type' => 'text',
|
5594 |
+
),
|
5595 |
+
array(
|
5596 |
+
'id' => '_format_quote_source_title',
|
5597 |
+
'label' => '',
|
5598 |
+
'desc' => esc_html__( 'Source Title (ex. book, song, movie)', 'option-tree' ),
|
5599 |
+
'std' => '',
|
5600 |
+
'type' => 'text',
|
5601 |
+
),
|
5602 |
+
array(
|
5603 |
+
'id' => '_format_quote_source_date',
|
5604 |
+
'label' => '',
|
5605 |
+
'desc' => esc_html__( 'Source Date', 'option-tree' ),
|
5606 |
+
'std' => '',
|
5607 |
+
'type' => 'text',
|
5608 |
+
),
|
5609 |
+
),
|
5610 |
+
),
|
5611 |
+
$pages
|
5612 |
+
);
|
5613 |
+
|
5614 |
+
}
|
5615 |
}
|
5616 |
|
5617 |
+
if ( ! function_exists( 'ot_meta_box_post_format_video' ) ) {
|
5618 |
+
|
5619 |
+
/**
|
5620 |
+
* Returns an array with the post format video metabox.
|
5621 |
+
*
|
5622 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5623 |
+
* post_types and is what tells the metabox where to
|
5624 |
+
* display. Default 'post'.
|
5625 |
+
* @return array
|
5626 |
+
*
|
5627 |
+
* @access public
|
5628 |
+
* @since 2.4.0
|
5629 |
+
*/
|
5630 |
+
function ot_meta_box_post_format_video( $pages = 'post' ) {
|
5631 |
+
|
5632 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5633 |
+
return false;
|
5634 |
+
}
|
5635 |
+
|
5636 |
+
if ( is_string( $pages ) ) {
|
5637 |
+
$pages = explode( ',', $pages );
|
5638 |
+
}
|
5639 |
+
|
5640 |
+
/* translators: %1$s: link to WorPress Codex, %2$s: video shortcode */
|
5641 |
+
$string = esc_html__( 'Embed video from services like Youtube, Vimeo, or Hulu. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' );
|
5642 |
+
|
5643 |
+
return apply_filters(
|
5644 |
+
'ot_meta_box_post_format_video',
|
5645 |
+
array(
|
5646 |
+
'id' => 'ot-post-format-video',
|
5647 |
+
'title' => __( 'Video', 'option-tree' ),
|
5648 |
+
'desc' => '',
|
5649 |
+
'pages' => $pages,
|
5650 |
+
'context' => 'side',
|
5651 |
+
'priority' => 'low',
|
5652 |
+
'fields' => array(
|
5653 |
+
array(
|
5654 |
+
'id' => '_format_video_embed',
|
5655 |
+
'label' => '',
|
5656 |
+
'desc' => sprintf( $string, '<a href="https://codex.wordpress.org/Embeds" target="_blank">' . esc_html__( 'WordPress Codex', 'option-tree' ) . '</a>', '<code>[video]</code>' ),
|
5657 |
+
'std' => '',
|
5658 |
+
'type' => 'textarea',
|
5659 |
+
),
|
5660 |
+
),
|
5661 |
+
),
|
5662 |
+
$pages
|
5663 |
+
);
|
5664 |
+
}
|
5665 |
}
|
5666 |
|
5667 |
+
if ( ! function_exists( 'ot_meta_box_post_format_audio' ) ) {
|
5668 |
+
|
5669 |
+
/**
|
5670 |
+
* Returns an array with the post format audio metabox.
|
5671 |
+
*
|
5672 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5673 |
+
* post_types and is what tells the metabox where to
|
5674 |
+
* display. Default 'post'.
|
5675 |
+
* @return array
|
5676 |
+
*
|
5677 |
+
* @access public
|
5678 |
+
* @since 2.4.0
|
5679 |
+
*/
|
5680 |
+
function ot_meta_box_post_format_audio( $pages = 'post' ) {
|
5681 |
+
|
5682 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5683 |
+
return false;
|
5684 |
+
}
|
5685 |
+
|
5686 |
+
if ( is_string( $pages ) ) {
|
5687 |
+
$pages = explode( ',', $pages );
|
5688 |
+
}
|
5689 |
+
|
5690 |
+
/* translators: %1$s: link to WorPress Codex, %2$s: audio shortcode */
|
5691 |
+
$string = esc_html__( 'Embed audio from services like SoundCloud and Radio. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' );
|
5692 |
+
|
5693 |
+
return apply_filters(
|
5694 |
+
'ot_meta_box_post_format_audio',
|
5695 |
+
array(
|
5696 |
+
'id' => 'ot-post-format-audio',
|
5697 |
+
'title' => esc_html__( 'Audio', 'option-tree' ),
|
5698 |
+
'desc' => '',
|
5699 |
+
'pages' => $pages,
|
5700 |
+
'context' => 'side',
|
5701 |
+
'priority' => 'low',
|
5702 |
+
'fields' => array(
|
5703 |
+
array(
|
5704 |
+
'id' => '_format_audio_embed',
|
5705 |
+
'label' => '',
|
5706 |
+
'desc' => sprintf( $string, '<a href="https://codex.wordpress.org/Embeds" target="_blank">' . esc_html__( 'WordPress Codex', 'option-tree' ) . '</a>', '<code>[audio]</code>' ),
|
5707 |
+
'std' => '',
|
5708 |
+
'type' => 'textarea',
|
5709 |
+
),
|
5710 |
+
),
|
5711 |
+
),
|
5712 |
+
$pages
|
5713 |
+
);
|
5714 |
+
|
5715 |
+
}
|
5716 |
}
|
5717 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5718 |
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
|
5719 |
|
5720 |
+
/**
|
5721 |
+
* Returns the option type by ID.
|
5722 |
+
*
|
5723 |
+
* @param string $option_id The option ID.
|
5724 |
+
* @param string $settings_id The settings array ID.
|
5725 |
+
* @return string The option type.
|
5726 |
+
*
|
5727 |
+
* @access public
|
5728 |
+
* @since 2.4.2
|
5729 |
+
*/
|
5730 |
+
function ot_get_option_type_by_id( $option_id, $settings_id = '' ) {
|
5731 |
|
5732 |
+
if ( empty( $settings_id ) ) {
|
5733 |
+
$settings_id = ot_settings_id();
|
5734 |
+
}
|
5735 |
|
5736 |
+
$settings = get_option( $settings_id, array() );
|
5737 |
|
5738 |
+
if ( isset( $settings['settings'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5739 |
|
5740 |
+
foreach ( $settings['settings'] as $value ) {
|
|
|
|
|
5741 |
|
5742 |
+
if ( $option_id === $value['id'] && isset( $value['type'] ) ) {
|
5743 |
+
return $value['type'];
|
5744 |
+
}
|
5745 |
+
}
|
5746 |
+
}
|
5747 |
|
5748 |
+
return false;
|
5749 |
+
}
|
5750 |
}
|
5751 |
|
5752 |
+
if ( ! function_exists( '_ot_settings_potential_shared_terms' ) ) {
|
5753 |
+
|
5754 |
+
/**
|
5755 |
+
* Build an array of potential Theme Options that could share terms.
|
5756 |
+
*
|
5757 |
+
* @return array
|
5758 |
+
*
|
5759 |
+
* @access private
|
5760 |
+
* @since 2.5.4
|
5761 |
+
*/
|
5762 |
+
function _ot_settings_potential_shared_terms() {
|
5763 |
+
|
5764 |
+
$options = array();
|
5765 |
+
$settings = get_option( ot_settings_id(), array() );
|
5766 |
+
$option_types = array(
|
5767 |
+
'category-checkbox',
|
5768 |
+
'category-select',
|
5769 |
+
'tag-checkbox',
|
5770 |
+
'tag-select',
|
5771 |
+
'taxonomy-checkbox',
|
5772 |
+
'taxonomy-select',
|
5773 |
+
);
|
5774 |
+
|
5775 |
+
if ( isset( $settings['settings'] ) ) {
|
5776 |
+
|
5777 |
+
foreach ( $settings['settings'] as $value ) {
|
5778 |
+
|
5779 |
+
if ( isset( $value['type'] ) ) {
|
5780 |
+
|
5781 |
+
if ( 'list-item' === $value['type'] && isset( $value['settings'] ) ) {
|
5782 |
+
|
5783 |
+
$saved = ot_get_option( $value['id'] );
|
5784 |
+
|
5785 |
+
foreach ( $value['settings'] as $item ) {
|
5786 |
+
|
5787 |
+
if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types, true ) ) {
|
5788 |
+
$sub_options = array();
|
5789 |
+
|
5790 |
+
foreach ( $saved as $sub_key => $sub_value ) {
|
5791 |
+
if ( isset( $sub_value[ $item['id'] ] ) ) {
|
5792 |
+
$sub_options[ $sub_key ] = $sub_value[ $item['id'] ];
|
5793 |
+
}
|
5794 |
+
}
|
5795 |
+
|
5796 |
+
if ( ! empty( $sub_options ) ) {
|
5797 |
+
$options[] = array(
|
5798 |
+
'id' => $item['id'],
|
5799 |
+
'taxonomy' => $value['taxonomy'],
|
5800 |
+
'parent' => $value['id'],
|
5801 |
+
'value' => $sub_options,
|
5802 |
+
);
|
5803 |
+
}
|
5804 |
+
}
|
5805 |
+
}
|
5806 |
+
}
|
5807 |
+
|
5808 |
+
if ( in_array( $value['type'], $option_types, true ) ) {
|
5809 |
+
$saved = ot_get_option( $value['id'] );
|
5810 |
+
if ( ! empty( $saved ) ) {
|
5811 |
+
$options[] = array(
|
5812 |
+
'id' => $value['id'],
|
5813 |
+
'taxonomy' => $value['taxonomy'],
|
5814 |
+
'value' => $saved,
|
5815 |
+
);
|
5816 |
+
}
|
5817 |
+
}
|
5818 |
+
}
|
5819 |
+
}
|
5820 |
+
}
|
5821 |
+
|
5822 |
+
return $options;
|
5823 |
+
}
|
|
|
|
|
|
|
5824 |
}
|
5825 |
|
5826 |
+
if ( ! function_exists( '_ot_meta_box_potential_shared_terms' ) ) {
|
5827 |
+
|
5828 |
+
/**
|
5829 |
+
* Build an array of potential Meta Box options that could share terms.
|
5830 |
+
*
|
5831 |
+
* @return array
|
5832 |
+
*
|
5833 |
+
* @access private
|
5834 |
+
* @since 2.5.4
|
5835 |
+
*/
|
5836 |
+
function _ot_meta_box_potential_shared_terms() {
|
5837 |
+
global $ot_meta_boxes;
|
5838 |
+
|
5839 |
+
$options = array();
|
5840 |
+
$settings = $ot_meta_boxes;
|
5841 |
+
$option_types = array(
|
5842 |
+
'category-checkbox',
|
5843 |
+
'category-select',
|
5844 |
+
'tag-checkbox',
|
5845 |
+
'tag-select',
|
5846 |
+
'taxonomy-checkbox',
|
5847 |
+
'taxonomy-select',
|
5848 |
+
);
|
5849 |
+
|
5850 |
+
foreach ( $settings as $setting ) {
|
5851 |
+
|
5852 |
+
if ( isset( $setting['fields'] ) ) {
|
5853 |
+
|
5854 |
+
foreach ( $setting['fields'] as $value ) {
|
5855 |
+
|
5856 |
+
if ( isset( $value['type'] ) ) {
|
5857 |
+
|
5858 |
+
if ( 'list-item' === $value['type'] && isset( $value['settings'] ) ) {
|
5859 |
+
|
5860 |
+
$children = array();
|
5861 |
+
|
5862 |
+
foreach ( $value['settings'] as $item ) {
|
5863 |
+
|
5864 |
+
if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types, true ) ) {
|
5865 |
+
$children[ $value['id'] ][] = $item['id'];
|
5866 |
+
}
|
5867 |
+
}
|
5868 |
+
|
5869 |
+
if ( ! empty( $children[ $value['id'] ] ) ) {
|
5870 |
+
$options[] = array(
|
5871 |
+
'id' => $value['id'],
|
5872 |
+
'children' => $children[ $value['id'] ],
|
5873 |
+
'taxonomy' => $value['taxonomy'],
|
5874 |
+
);
|
5875 |
+
}
|
5876 |
+
}
|
5877 |
+
|
5878 |
+
if ( in_array( $value['type'], $option_types, true ) ) {
|
5879 |
+
$options[] = array(
|
5880 |
+
'id' => $value['id'],
|
5881 |
+
'taxonomy' => $value['taxonomy'],
|
5882 |
+
);
|
5883 |
+
}
|
5884 |
+
}
|
5885 |
+
}
|
5886 |
+
}
|
5887 |
+
}
|
5888 |
+
|
5889 |
+
return $options;
|
5890 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5891 |
}
|
5892 |
|
5893 |
+
if ( ! function_exists( 'ot_split_shared_term' ) ) {
|
5894 |
+
|
5895 |
+
/**
|
5896 |
+
* Update terms when a term gets split.
|
5897 |
+
*
|
5898 |
+
* @param int $term_id ID of the formerly shared term.
|
5899 |
+
* @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
|
5900 |
+
* @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
|
5901 |
+
* @param string $taxonomy Taxonomy for the split term.
|
5902 |
+
*
|
5903 |
+
* @access public
|
5904 |
+
* @since 2.5.4
|
5905 |
+
*/
|
5906 |
+
function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
|
5907 |
+
unset( $term_taxonomy_id );
|
5908 |
+
|
5909 |
+
// Process the Theme Options.
|
5910 |
+
$settings = _ot_settings_potential_shared_terms();
|
5911 |
+
$old_options = get_option( ot_options_id(), array() );
|
5912 |
+
$new_options = $old_options;
|
5913 |
+
|
5914 |
+
// Process the saved settings.
|
5915 |
+
if ( ! empty( $settings ) && ! empty( $old_options ) ) {
|
5916 |
+
|
5917 |
+
// Loop over the Theme Options.
|
5918 |
+
foreach ( $settings as $option ) {
|
5919 |
+
|
5920 |
+
if ( ! is_array( $option['taxonomy'] ) ) {
|
5921 |
+
$option['taxonomy'] = explode( ',', $option['taxonomy'] );
|
5922 |
+
}
|
5923 |
+
|
5924 |
+
if ( ! in_array( $taxonomy, $option['taxonomy'], true ) ) {
|
5925 |
+
continue;
|
5926 |
+
}
|
5927 |
+
|
5928 |
+
// The option ID was found.
|
5929 |
+
if ( array_key_exists( $option['id'], $old_options ) || ( isset( $option['parent'] ) && array_key_exists( $option['parent'], $old_options ) ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5930 |
|
5931 |
+
// This is a list item, we have to go deeper.
|
5932 |
+
if ( isset( $option['parent'] ) ) {
|
5933 |
+
|
5934 |
+
// Loop over the array.
|
5935 |
+
foreach ( $option['value'] as $key => $value ) {
|
5936 |
+
|
5937 |
+
// The value is an array of IDs.
|
5938 |
+
if ( is_array( $value ) ) {
|
5939 |
+
|
5940 |
+
// Loop over the sub array.
|
5941 |
+
foreach ( $value as $sub_key => $sub_value ) {
|
5942 |
+
|
5943 |
+
if ( $sub_value === $term_id ) {
|
5944 |
+
unset( $new_options[ $option['parent'] ][ $key ][ $option['id'] ][ $sub_key ] );
|
5945 |
+
$new_options[ $option['parent'] ][ $key ][ $option['id'] ][ $new_term_id ] = $new_term_id;
|
5946 |
+
}
|
5947 |
+
}
|
5948 |
+
} elseif ( $value === $term_id ) {
|
5949 |
+
unset( $new_options[ $option['parent'] ][ $key ][ $option['id'] ] );
|
5950 |
+
$new_options[ $option['parent'] ][ $key ][ $option['id'] ] = $new_term_id;
|
5951 |
+
}
|
5952 |
+
}
|
5953 |
+
} else {
|
5954 |
+
|
5955 |
+
// The value is an array of IDs.
|
5956 |
+
if ( is_array( $option['value'] ) ) {
|
5957 |
+
|
5958 |
+
// Loop over the array.
|
5959 |
+
foreach ( $option['value'] as $key => $value ) {
|
5960 |
+
|
5961 |
+
// It's a single value, just replace it.
|
5962 |
+
if ( $value === $term_id ) {
|
5963 |
+
unset( $new_options[ $option['id'] ][ $key ] );
|
5964 |
+
$new_options[ $option['id'] ][ $new_term_id ] = $new_term_id;
|
5965 |
+
}
|
5966 |
+
}
|
5967 |
+
|
5968 |
+
// It's a single value, just replace it.
|
5969 |
+
} elseif ( $option['value'] === $term_id ) {
|
5970 |
+
$new_options[ $option['id'] ] = $new_term_id;
|
5971 |
+
}
|
5972 |
+
}
|
5973 |
+
}
|
5974 |
+
}
|
5975 |
+
}
|
5976 |
+
|
5977 |
+
// Options need to be updated.
|
5978 |
+
if ( $old_options !== $new_options ) {
|
5979 |
+
update_option( ot_options_id(), $new_options );
|
5980 |
+
}
|
5981 |
+
|
5982 |
+
// Process the Meta Boxes.
|
5983 |
+
$meta_settings = _ot_meta_box_potential_shared_terms();
|
5984 |
+
|
5985 |
+
if ( ! empty( $meta_settings ) ) {
|
5986 |
+
|
5987 |
+
foreach ( $meta_settings as $option ) {
|
5988 |
+
|
5989 |
+
if ( ! is_array( $option['taxonomy'] ) ) {
|
5990 |
+
$option['taxonomy'] = explode( ',', $option['taxonomy'] );
|
5991 |
+
}
|
5992 |
+
|
5993 |
+
if ( ! in_array( $taxonomy, $option['taxonomy'], true ) ) {
|
5994 |
+
continue;
|
5995 |
+
}
|
5996 |
+
|
5997 |
+
if ( isset( $option['children'] ) ) {
|
5998 |
+
$post_ids = get_posts(
|
5999 |
+
array(
|
6000 |
+
'fields' => 'ids',
|
6001 |
+
'meta_key' => $option['id'], // phpcs:ignore
|
6002 |
+
)
|
6003 |
+
);
|
6004 |
+
|
6005 |
+
if ( $post_ids ) {
|
6006 |
+
|
6007 |
+
foreach ( $post_ids as $post_id ) {
|
6008 |
+
|
6009 |
+
// Get the meta.
|
6010 |
+
$old_meta = get_post_meta( $post_id, $option['id'], true );
|
6011 |
+
$new_meta = $old_meta;
|
6012 |
+
|
6013 |
+
// Has a saved value.
|
6014 |
+
if ( ! empty( $old_meta ) && is_array( $old_meta ) ) {
|
6015 |
+
|
6016 |
+
// Loop over the array.
|
6017 |
+
foreach ( $old_meta as $key => $value ) {
|
6018 |
+
|
6019 |
+
foreach ( $value as $sub_key => $sub_value ) {
|
6020 |
+
|
6021 |
+
if ( in_array( $sub_key, $option['children'], true ) ) {
|
6022 |
+
|
6023 |
+
// The value is an array of IDs.
|
6024 |
+
if ( is_array( $sub_value ) ) {
|
6025 |
+
|
6026 |
+
// Loop over the array.
|
6027 |
+
foreach ( $sub_value as $sub_sub_key => $sub_sub_value ) {
|
6028 |
+
|
6029 |
+
// It's a single value, just replace it.
|
6030 |
+
if ( $sub_sub_value === $term_id ) {
|
6031 |
+
unset( $new_meta[ $key ][ $sub_key ][ $sub_sub_key ] );
|
6032 |
+
$new_meta[ $key ][ $sub_key ][ $new_term_id ] = $new_term_id;
|
6033 |
+
}
|
6034 |
+
}
|
6035 |
+
|
6036 |
+
// It's a single value, just replace it.
|
6037 |
+
} elseif ( $sub_value === $term_id ) {
|
6038 |
+
$new_meta[ $key ][ $sub_key ] = $new_term_id;
|
6039 |
+
}
|
6040 |
+
}
|
6041 |
+
}
|
6042 |
+
}
|
6043 |
+
|
6044 |
+
// Update.
|
6045 |
+
if ( $old_meta !== $new_meta ) {
|
6046 |
+
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
6047 |
+
}
|
6048 |
+
}
|
6049 |
+
}
|
6050 |
+
}
|
6051 |
+
} else {
|
6052 |
+
$post_ids = get_posts(
|
6053 |
+
array(
|
6054 |
+
'fields' => 'ids',
|
6055 |
+
'meta_query' => array( // phpcs:ignore
|
6056 |
+
'key' => $option['id'],
|
6057 |
+
'value' => $term_id,
|
6058 |
+
'compare' => 'IN',
|
6059 |
+
),
|
6060 |
+
)
|
6061 |
+
);
|
6062 |
+
|
6063 |
+
if ( $post_ids ) {
|
6064 |
+
|
6065 |
+
foreach ( $post_ids as $post_id ) {
|
6066 |
+
|
6067 |
+
// Get the meta.
|
6068 |
+
$old_meta = get_post_meta( $post_id, $option['id'], true );
|
6069 |
+
$new_meta = $old_meta;
|
6070 |
+
|
6071 |
+
// Has a saved value.
|
6072 |
+
if ( ! empty( $old_meta ) ) {
|
6073 |
+
|
6074 |
+
// The value is an array of IDs.
|
6075 |
+
if ( is_array( $old_meta ) ) {
|
6076 |
+
|
6077 |
+
// Loop over the array.
|
6078 |
+
foreach ( $old_meta as $key => $value ) {
|
6079 |
+
|
6080 |
+
// It's a single value, just replace it.
|
6081 |
+
if ( $value === $term_id ) {
|
6082 |
+
unset( $new_meta[ $key ] );
|
6083 |
+
$new_meta[ $new_term_id ] = $new_term_id;
|
6084 |
+
}
|
6085 |
+
}
|
6086 |
+
|
6087 |
+
// It's a single value, just replace it.
|
6088 |
+
} elseif ( $old_meta === $term_id ) {
|
6089 |
+
$new_meta = $new_term_id;
|
6090 |
+
}
|
6091 |
+
|
6092 |
+
// Update.
|
6093 |
+
if ( $old_meta !== $new_meta ) {
|
6094 |
+
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
6095 |
+
}
|
6096 |
+
}
|
6097 |
+
}
|
6098 |
+
}
|
6099 |
+
}
|
6100 |
+
}
|
6101 |
+
}
|
6102 |
+
}
|
6103 |
+
|
6104 |
+
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
|
6105 |
}
|
|
|
6106 |
|
|
|
|
admin/includes/ot-functions-deprecated.php
CHANGED
@@ -1,99 +1,94 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* OptionTree
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
* @param array $options
|
16 |
-
* @param bool $echo
|
17 |
-
* @param bool $is_array
|
18 |
-
* @param int $offset
|
19 |
-
* @return mixed array or comma seperated lists of values
|
20 |
-
*
|
21 |
-
* @access public
|
22 |
-
* @since 1.0.0
|
23 |
-
* @updated 2.0
|
24 |
-
* @deprecated 2.0
|
25 |
-
*/
|
26 |
if ( ! function_exists( 'get_option_tree' ) ) {
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$content = explode( ',', $content );
|
45 |
-
|
46 |
-
/* get an array value using an offset */
|
47 |
-
if ( is_numeric( $offset ) && $offset >= 0 ) {
|
48 |
-
$content = $content[$offset];
|
49 |
-
} else if ( ! is_numeric( $offset ) && isset( $content[$offset] ) ) {
|
50 |
-
$content = $content[$offset];
|
51 |
-
}
|
52 |
-
|
53 |
-
/* not an array */
|
54 |
-
} else if ( $is_array == false ) {
|
55 |
-
/* saved as array, implode and return a comma seperated lists of values */
|
56 |
-
if ( is_array( $content ) )
|
57 |
-
$content = implode( ',', $content ); /* This is fucked */
|
58 |
-
}
|
59 |
-
|
60 |
-
/* echo content */
|
61 |
-
if ( $echo )
|
62 |
-
echo $content;
|
63 |
-
|
64 |
-
return $content;
|
65 |
-
}
|
66 |
|
67 |
-
|
|
|
|
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$input = stripslashes( $input );
|
92 |
-
}
|
93 |
-
return $input;
|
94 |
-
}
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Deprecated Functions.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
if ( ! function_exists( 'get_option_tree' ) ) {
|
13 |
|
14 |
+
/**
|
15 |
+
* Displays or returns a value from the 'option_tree' array.
|
16 |
+
*
|
17 |
+
* @param string $item_id The item ID.
|
18 |
+
* @param array $options Options array.
|
19 |
+
* @param bool $echo Whether to echo or return value.
|
20 |
+
* @param bool $is_array Whether the value option is an array or string.
|
21 |
+
* @param int $offset The array key.
|
22 |
+
* @return mixed Array or comma separated lists of values.
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @since 1.0.0
|
26 |
+
* @updated 2.0
|
27 |
+
* @deprecated 2.0
|
28 |
+
*/
|
29 |
+
function get_option_tree( $item_id = '', $options = array(), $echo = false, $is_array = false, $offset = -1 ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
// Load saved options.
|
32 |
+
if ( ! $options ) {
|
33 |
+
$options = get_option( ot_options_id() );
|
34 |
+
}
|
35 |
|
36 |
+
// No value return.
|
37 |
+
if ( ! isset( $options[ $item_id ] ) || empty( $options[ $item_id ] ) ) {
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
|
41 |
+
// Set content value & strip slashes.
|
42 |
+
$content = option_tree_stripslashes( $options[ $item_id ] );
|
43 |
+
|
44 |
+
if ( true === $is_array ) {
|
45 |
+
if ( ! is_array( $content ) ) {
|
46 |
+
$content = explode( ',', $content );
|
47 |
+
}
|
48 |
|
49 |
+
if ( is_numeric( $offset ) && 0 <= $offset ) {
|
50 |
+
$content = $content[ $offset ];
|
51 |
+
} elseif ( ! is_numeric( $offset ) && isset( $content[ $offset ] ) ) {
|
52 |
+
$content = $content[ $offset ];
|
53 |
+
}
|
54 |
+
} else {
|
55 |
+
if ( is_array( $content ) ) {
|
56 |
+
$content = implode( ',', $content );
|
57 |
+
}
|
58 |
+
}
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
if ( $echo ) {
|
61 |
+
echo $content; // phpcs:ignore
|
62 |
+
}
|
63 |
+
|
64 |
+
return $content;
|
65 |
+
}
|
66 |
}
|
67 |
|
68 |
+
if ( ! function_exists( 'option_tree_stripslashes' ) ) {
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Custom stripslashes from single value or array.
|
72 |
+
*
|
73 |
+
* @param mixed $input Input string or array.
|
74 |
+
* @return mixed
|
75 |
+
*
|
76 |
+
* @access public
|
77 |
+
* @since 1.1.3
|
78 |
+
* @deprecated 2.0
|
79 |
+
*/
|
80 |
+
function option_tree_stripslashes( $input ) {
|
81 |
+
if ( is_array( $input ) ) {
|
82 |
+
foreach ( $input as &$val ) {
|
83 |
+
if ( is_array( $val ) ) {
|
84 |
+
$val = option_tree_stripslashes( $val );
|
85 |
+
} else {
|
86 |
+
$val = stripslashes( $val );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
} else {
|
90 |
+
$input = stripslashes( $input );
|
91 |
+
}
|
92 |
+
return $input;
|
93 |
+
}
|
94 |
+
}
|
admin/includes/ot-functions-option-types.php
CHANGED
@@ -1,3234 +1,3170 @@
|
|
1 |
-
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Functions used to build each option type.
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
* All fields are required!
|
16 |
-
*
|
17 |
-
* @param array $args The array of arguments are as follows:
|
18 |
-
* @param string $type Type of option.
|
19 |
-
* @param string $field_id The field ID.
|
20 |
-
* @param string $field_name The field Name.
|
21 |
-
* @param mixed $field_value The field value is a string or an array of values.
|
22 |
-
* @param string $field_desc The field description.
|
23 |
-
* @param string $field_std The standard value.
|
24 |
-
* @param string $field_class Extra CSS classes.
|
25 |
-
* @param array $field_choices The array of option choices.
|
26 |
-
* @param array $field_settings The array of settings for a list item.
|
27 |
-
* @return string
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @since 2.0
|
31 |
-
*/
|
32 |
if ( ! function_exists( 'ot_display_by_type' ) ) {
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
$args = apply_filters( 'ot_display_by_type', $args );
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
|
49 |
-
|
|
|
50 |
|
51 |
-
|
|
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
*
|
56 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
57 |
-
*
|
58 |
-
* @param array An array of arguments.
|
59 |
-
* @return string
|
60 |
-
*
|
61 |
-
* @access public
|
62 |
-
* @since 2.0
|
63 |
-
*/
|
64 |
-
if ( ! function_exists( 'ot_type_background' ) ) {
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
$has_desc = $field_desc ? true : false;
|
73 |
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
|
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
93 |
|
94 |
-
|
95 |
-
echo '<div class="format-setting-inner">';
|
96 |
|
97 |
-
|
98 |
-
$ot_recognized_background_fields = apply_filters( 'ot_recognized_background_fields', array(
|
99 |
-
'background-color',
|
100 |
-
'background-repeat',
|
101 |
-
'background-attachment',
|
102 |
-
'background-position',
|
103 |
-
'background-size',
|
104 |
-
'background-image'
|
105 |
-
), $field_id );
|
106 |
|
107 |
-
|
108 |
|
109 |
-
|
110 |
-
|
111 |
|
112 |
-
|
|
|
113 |
|
114 |
-
|
115 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
116 |
|
117 |
-
|
118 |
-
$background_color = isset( $field_value['background-color'] ) ? esc_attr( $field_value['background-color'] ) : '';
|
119 |
|
120 |
-
|
121 |
-
|
122 |
|
123 |
-
|
|
|
124 |
|
125 |
-
|
|
|
126 |
|
127 |
-
|
128 |
-
|
129 |
|
130 |
-
|
131 |
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
foreach ( ot_recognized_background_repeat( $field_id ) as $key => $value ) {
|
136 |
|
137 |
-
|
138 |
|
139 |
-
|
|
|
140 |
|
141 |
-
|
|
|
142 |
|
143 |
-
|
|
|
144 |
|
145 |
-
|
146 |
-
if ( in_array( 'background-attachment', $ot_recognized_background_fields ) ) {
|
147 |
|
148 |
-
|
149 |
|
150 |
-
|
151 |
|
152 |
-
|
153 |
|
154 |
-
|
|
|
155 |
|
156 |
-
|
|
|
157 |
|
158 |
-
|
|
|
159 |
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
-
|
163 |
|
164 |
-
|
165 |
-
|
166 |
|
167 |
-
|
|
|
|
|
|
|
|
|
168 |
|
169 |
-
|
|
|
170 |
|
171 |
-
|
|
|
|
|
172 |
|
173 |
-
|
174 |
|
175 |
-
|
|
|
176 |
|
177 |
-
|
178 |
|
179 |
-
|
|
|
180 |
|
181 |
-
|
|
|
182 |
|
183 |
-
|
184 |
-
if ( in_array( 'background-size', $ot_recognized_background_fields ) ) {
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Use this filter to create a select instead of an text input.
|
188 |
-
* Be sure to return the array in the correct format. Add an empty
|
189 |
-
* value to the first choice so the user can leave it blank.
|
190 |
-
*
|
191 |
-
array(
|
192 |
-
array(
|
193 |
-
'label' => 'background-size',
|
194 |
-
'value' => ''
|
195 |
-
),
|
196 |
-
array(
|
197 |
-
'label' => 'cover',
|
198 |
-
'value' => 'cover'
|
199 |
-
),
|
200 |
-
array(
|
201 |
-
'label' => 'contain',
|
202 |
-
'value' => 'contain'
|
203 |
-
)
|
204 |
-
)
|
205 |
-
*
|
206 |
-
*/
|
207 |
-
$choices = apply_filters( 'ot_type_background_size_choices', '', $field_id );
|
208 |
-
|
209 |
-
if ( is_array( $choices ) && ! empty( $choices ) ) {
|
210 |
-
|
211 |
-
/* build select */
|
212 |
-
echo '<select name="' . esc_attr( $field_name ) . '[background-size]" id="' . esc_attr( $field_id ) . '-size" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
213 |
-
|
214 |
-
foreach ( (array) $choices as $choice ) {
|
215 |
-
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
216 |
-
echo '<option value="' . esc_attr( $choice['value'] ) . '"' . selected( ( isset( $field_value['background-size'] ) ? $field_value['background-size'] : '' ), $choice['value'], false ) . '>' . esc_attr( $choice['label'] ) . '</option>';
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
echo '</select>';
|
221 |
-
|
222 |
-
} else {
|
223 |
-
|
224 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '[background-size]" id="' . esc_attr( $field_id ) . '-size" value="' . ( isset( $field_value['background-size'] ) ? esc_attr( $field_value['background-size'] ) : '' ) . '" class="widefat ot-background-size-input option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . __( 'background-size', 'option-tree' ) . '" />';
|
225 |
|
226 |
-
|
|
|
227 |
|
228 |
-
|
|
|
|
|
|
|
229 |
|
230 |
-
|
231 |
|
232 |
-
|
233 |
-
|
|
|
234 |
|
235 |
-
|
236 |
|
237 |
-
|
238 |
-
|
|
|
239 |
|
240 |
-
|
241 |
-
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . $post_id . '" title="' . __( 'Add Media', 'option-tree' ) . '"><span class="icon ot-icon-plus-circle"></span>' . __( 'Add Media', 'option-tree' ) . '</a>';
|
242 |
|
243 |
-
|
|
|
|
|
244 |
|
245 |
-
|
246 |
-
if ( isset( $field_value['background-image'] ) && $field_value['background-image'] !== '' ) {
|
247 |
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
-
|
|
|
253 |
|
254 |
-
|
255 |
-
|
256 |
|
257 |
-
|
|
|
258 |
|
259 |
-
|
|
|
260 |
|
261 |
-
|
|
|
262 |
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
|
265 |
-
|
|
|
266 |
|
267 |
-
|
268 |
|
269 |
-
|
|
|
270 |
|
271 |
-
|
|
|
272 |
|
273 |
-
|
274 |
-
* Border Option Type
|
275 |
-
*
|
276 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
277 |
-
*
|
278 |
-
* @param array The options arguments
|
279 |
-
* @return string The markup.
|
280 |
-
*
|
281 |
-
* @access public
|
282 |
-
* @since 2.5.0
|
283 |
-
*/
|
284 |
-
if ( ! function_exists( 'ot_type_border' ) ) {
|
285 |
|
286 |
-
|
287 |
|
288 |
-
|
289 |
-
extract( $args );
|
290 |
|
291 |
-
|
292 |
-
|
|
|
293 |
|
294 |
-
|
295 |
-
echo '<div class="format-setting type-border ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
296 |
|
297 |
-
|
298 |
-
|
299 |
|
300 |
-
|
301 |
-
|
302 |
|
303 |
-
|
304 |
-
$ot_recognized_border_fields = apply_filters( 'ot_recognized_border_fields', array(
|
305 |
-
'width',
|
306 |
-
'unit',
|
307 |
-
'style',
|
308 |
-
'color'
|
309 |
-
), $field_id );
|
310 |
|
311 |
-
|
312 |
-
if ( in_array( 'width', $ot_recognized_border_fields ) ) {
|
313 |
|
314 |
-
|
315 |
|
316 |
-
|
|
|
|
|
317 |
|
318 |
-
|
319 |
|
320 |
-
|
321 |
-
|
322 |
|
323 |
-
|
|
|
324 |
|
325 |
-
|
326 |
|
327 |
-
|
328 |
|
329 |
-
|
330 |
-
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
331 |
-
}
|
332 |
|
333 |
-
|
334 |
|
335 |
-
|
|
|
336 |
|
337 |
-
|
338 |
|
339 |
-
|
340 |
-
|
|
|
341 |
|
342 |
-
|
343 |
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
|
346 |
-
|
|
|
347 |
|
348 |
-
|
349 |
-
|
350 |
-
}
|
351 |
|
352 |
-
|
|
|
353 |
|
354 |
-
|
|
|
355 |
|
356 |
-
|
|
|
357 |
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
-
|
|
|
362 |
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
365 |
|
366 |
-
|
367 |
-
|
368 |
|
369 |
-
|
370 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '[color]" id="' . $field_id . '-picker" value="' . $color . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
371 |
|
372 |
-
|
|
|
373 |
|
374 |
-
|
|
|
375 |
|
376 |
-
|
377 |
|
378 |
-
|
|
|
379 |
|
380 |
-
|
|
|
381 |
|
382 |
-
|
383 |
|
384 |
-
|
385 |
-
|
386 |
-
*
|
387 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
388 |
-
*
|
389 |
-
* @param array The options arguments
|
390 |
-
* @return string The markup.
|
391 |
-
*
|
392 |
-
* @access public
|
393 |
-
* @since 2.5.0
|
394 |
-
*/
|
395 |
-
if ( ! function_exists( 'ot_type_box_shadow' ) ) {
|
396 |
|
397 |
-
|
|
|
398 |
|
399 |
-
|
400 |
-
extract( $args );
|
401 |
|
402 |
-
|
403 |
-
|
404 |
|
405 |
-
|
406 |
-
|
407 |
|
408 |
-
|
409 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
410 |
|
411 |
-
|
412 |
-
echo '<div class="format-setting-inner">';
|
413 |
|
414 |
-
|
415 |
-
$ot_recognized_box_shadow_fields = apply_filters( 'ot_recognized_box_shadow_fields', array(
|
416 |
-
'inset',
|
417 |
-
'offset-x',
|
418 |
-
'offset-y',
|
419 |
-
'blur-radius',
|
420 |
-
'spread-radius',
|
421 |
-
'color'
|
422 |
-
), $field_id );
|
423 |
|
424 |
-
|
425 |
-
if ( in_array( 'inset', $ot_recognized_box_shadow_fields ) ) {
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
echo '<label for="' . esc_attr( $field_id ) . '-inset">inset</label>';
|
430 |
-
echo '</p></div>';
|
431 |
|
432 |
-
|
433 |
|
434 |
-
|
435 |
-
|
|
|
436 |
|
437 |
-
|
438 |
|
439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
|
441 |
-
|
442 |
|
443 |
-
|
444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
|
446 |
-
|
|
|
447 |
|
448 |
-
|
|
|
449 |
|
450 |
-
|
|
|
451 |
|
452 |
-
|
453 |
-
|
454 |
|
455 |
-
|
|
|
456 |
|
457 |
-
|
|
|
458 |
|
459 |
-
|
|
|
460 |
|
461 |
-
|
462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
|
464 |
-
|
465 |
|
466 |
-
|
467 |
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
-
|
471 |
-
if ( in_array( 'color', $ot_recognized_box_shadow_fields ) ) {
|
472 |
|
473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
|
475 |
-
|
476 |
-
|
477 |
|
478 |
-
|
479 |
-
|
480 |
|
481 |
-
|
482 |
-
|
483 |
|
484 |
-
|
|
|
485 |
|
486 |
-
|
|
|
487 |
|
488 |
-
|
|
|
489 |
|
490 |
-
|
|
|
491 |
|
492 |
-
|
|
|
|
|
|
|
|
|
|
|
493 |
|
|
|
|
|
494 |
}
|
495 |
|
496 |
-
|
497 |
-
* Category Checkbox option type.
|
498 |
-
*
|
499 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
500 |
-
*
|
501 |
-
* @param array An array of arguments.
|
502 |
-
* @return string
|
503 |
-
*
|
504 |
-
* @access public
|
505 |
-
* @since 2.0
|
506 |
-
*/
|
507 |
-
if ( ! function_exists( 'ot_type_category_checkbox' ) ) {
|
508 |
|
509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
-
|
512 |
-
extract( $args );
|
513 |
|
514 |
-
|
515 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
|
517 |
-
|
518 |
-
|
519 |
|
520 |
-
|
521 |
-
|
522 |
|
523 |
-
|
524 |
-
|
525 |
|
526 |
-
|
527 |
-
|
528 |
|
529 |
-
|
530 |
-
|
531 |
-
foreach ( $categories as $category ) {
|
532 |
-
echo '<p>';
|
533 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $category->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $category->term_id ) . '" value="' . esc_attr( $category->term_id ) . '" ' . ( isset( $field_value[$category->term_id] ) ? checked( $field_value[$category->term_id], $category->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
534 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $category->term_id ) . '">' . esc_attr( $category->name ) . '</label>';
|
535 |
-
echo '</p>';
|
536 |
-
}
|
537 |
-
} else {
|
538 |
-
echo '<p>' . __( 'No Categories Found', 'option-tree' ) . '</p>';
|
539 |
-
}
|
540 |
|
541 |
-
|
|
|
542 |
|
543 |
-
|
|
|
544 |
|
545 |
-
|
546 |
|
|
|
|
|
547 |
}
|
548 |
|
549 |
-
|
550 |
-
* Category Select option type.
|
551 |
-
*
|
552 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
553 |
-
*
|
554 |
-
* @param array An array of arguments.
|
555 |
-
* @return string
|
556 |
-
*
|
557 |
-
* @access public
|
558 |
-
* @since 2.0
|
559 |
-
*/
|
560 |
-
if ( ! function_exists( 'ot_type_category_select' ) ) {
|
561 |
|
562 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
|
564 |
-
|
565 |
-
extract( $args );
|
566 |
|
567 |
-
|
568 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
569 |
|
570 |
-
|
571 |
-
echo '<div class="format-setting type-category-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
572 |
|
573 |
-
|
574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
|
576 |
-
|
577 |
-
|
578 |
|
579 |
-
|
580 |
-
|
581 |
|
582 |
-
|
583 |
-
|
584 |
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
|
595 |
-
|
|
|
596 |
|
597 |
-
|
|
|
598 |
|
599 |
-
|
|
|
600 |
|
601 |
-
|
|
|
|
|
|
|
|
|
602 |
|
|
|
|
|
|
|
|
|
603 |
}
|
604 |
|
605 |
-
|
606 |
-
* Checkbox option type.
|
607 |
-
*
|
608 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
609 |
-
*
|
610 |
-
* @param array An array of arguments.
|
611 |
-
* @return string
|
612 |
-
*
|
613 |
-
* @access public
|
614 |
-
* @since 2.0
|
615 |
-
*/
|
616 |
-
if ( ! function_exists( 'ot_type_checkbox' ) ) {
|
617 |
|
618 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
|
620 |
-
|
621 |
-
|
622 |
|
623 |
-
|
624 |
-
|
625 |
|
626 |
-
|
627 |
-
|
628 |
|
629 |
-
|
630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
631 |
|
632 |
-
|
633 |
-
|
634 |
|
635 |
-
|
636 |
-
|
637 |
-
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
638 |
-
echo '<p>';
|
639 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . ( isset( $field_value[$key] ) ? checked( $field_value[$key], $choice['value'], false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
640 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label>';
|
641 |
-
echo '</p>';
|
642 |
-
}
|
643 |
-
}
|
644 |
|
645 |
-
|
|
|
646 |
|
647 |
-
|
|
|
648 |
|
649 |
-
|
|
|
650 |
|
|
|
|
|
|
|
|
|
651 |
}
|
652 |
|
653 |
-
|
654 |
-
* Colorpicker option type.
|
655 |
-
*
|
656 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
657 |
-
*
|
658 |
-
* @param array An array of arguments.
|
659 |
-
* @return string
|
660 |
-
*
|
661 |
-
* @access public
|
662 |
-
* @since 2.0
|
663 |
-
* @updated 2.2.0
|
664 |
-
*/
|
665 |
-
if ( ! function_exists( 'ot_type_colorpicker' ) ) {
|
666 |
|
667 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
|
669 |
-
|
670 |
-
|
671 |
|
672 |
-
|
673 |
-
|
674 |
|
675 |
-
|
676 |
-
|
677 |
|
678 |
-
|
679 |
-
|
680 |
|
681 |
-
|
682 |
-
|
683 |
|
684 |
-
|
685 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
|
687 |
-
|
688 |
-
|
689 |
|
690 |
-
|
691 |
-
|
|
|
692 |
|
693 |
-
|
694 |
-
|
695 |
|
696 |
-
|
|
|
|
|
697 |
|
698 |
-
|
|
|
699 |
|
700 |
-
|
701 |
|
702 |
-
|
703 |
|
704 |
-
|
705 |
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
710 |
-
*
|
711 |
-
* @param array An array of arguments.
|
712 |
-
* @return string
|
713 |
-
*
|
714 |
-
* @access public
|
715 |
-
* @since 2.5.0
|
716 |
-
*/
|
717 |
-
if ( ! function_exists( 'ot_type_colorpicker_opacity' ) ) {
|
718 |
|
719 |
-
|
720 |
|
721 |
-
|
722 |
-
|
723 |
|
724 |
-
|
725 |
|
|
|
|
|
726 |
}
|
727 |
|
728 |
-
|
729 |
-
* CSS option type.
|
730 |
-
*
|
731 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
732 |
-
*
|
733 |
-
* @param array An array of arguments.
|
734 |
-
* @return string
|
735 |
-
*
|
736 |
-
* @access public
|
737 |
-
* @since 2.0
|
738 |
-
*/
|
739 |
-
if ( ! function_exists( 'ot_type_css' ) ) {
|
740 |
|
741 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
|
743 |
-
|
744 |
-
|
745 |
|
746 |
-
|
747 |
-
|
748 |
|
749 |
-
|
750 |
-
|
751 |
|
752 |
-
|
753 |
-
|
754 |
|
755 |
-
|
756 |
-
|
757 |
|
758 |
-
|
759 |
-
echo '<textarea class="hidden" id="textarea_' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) .'">' . esc_attr( $field_value ) . '</textarea>';
|
760 |
|
761 |
-
|
762 |
-
|
763 |
|
764 |
-
|
|
|
765 |
|
766 |
-
|
|
|
767 |
|
768 |
-
|
769 |
-
|
770 |
-
}
|
771 |
-
|
772 |
-
/**
|
773 |
-
* Custom Post Type Checkbox option type.
|
774 |
-
*
|
775 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
776 |
-
*
|
777 |
-
* @param array An array of arguments.
|
778 |
-
* @return string
|
779 |
-
*
|
780 |
-
* @access public
|
781 |
-
* @since 2.0
|
782 |
-
*/
|
783 |
-
if ( ! function_exists( 'ot_type_custom_post_type_checkbox' ) ) {
|
784 |
-
|
785 |
-
function ot_type_custom_post_type_checkbox( $args = array() ) {
|
786 |
-
|
787 |
-
/* turns arguments array into variables */
|
788 |
-
extract( $args );
|
789 |
-
|
790 |
-
/* verify a description */
|
791 |
-
$has_desc = $field_desc ? true : false;
|
792 |
-
|
793 |
-
/* format setting outer wrapper */
|
794 |
-
echo '<div class="format-setting type-custom-post-type-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
795 |
-
|
796 |
-
/* description */
|
797 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
798 |
-
|
799 |
-
/* format setting inner wrapper */
|
800 |
-
echo '<div class="format-setting-inner">';
|
801 |
-
|
802 |
-
/* setup the post types */
|
803 |
-
$post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' );
|
804 |
-
|
805 |
-
/* query posts array */
|
806 |
-
$my_posts = get_posts( apply_filters( 'ot_type_custom_post_type_checkbox_query', array( 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) );
|
807 |
-
|
808 |
-
/* has posts */
|
809 |
-
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
810 |
-
foreach( $my_posts as $my_post ) {
|
811 |
-
$post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled';
|
812 |
-
echo '<p>';
|
813 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[$my_post->ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
814 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . $post_title . '</label>';
|
815 |
-
echo '</p>';
|
816 |
-
}
|
817 |
-
} else {
|
818 |
-
echo '<p>' . __( 'No Posts Found', 'option-tree' ) . '</p>';
|
819 |
-
}
|
820 |
-
|
821 |
-
echo '</div>';
|
822 |
-
|
823 |
-
echo '</div>';
|
824 |
-
|
825 |
-
}
|
826 |
-
|
827 |
-
}
|
828 |
-
|
829 |
-
/**
|
830 |
-
* Custom Post Type Select option type.
|
831 |
-
*
|
832 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
833 |
-
*
|
834 |
-
* @param array An array of arguments.
|
835 |
-
* @return string
|
836 |
-
*
|
837 |
-
* @access public
|
838 |
-
* @since 2.0
|
839 |
-
*/
|
840 |
-
if ( ! function_exists( 'ot_type_custom_post_type_select' ) ) {
|
841 |
-
|
842 |
-
function ot_type_custom_post_type_select( $args = array() ) {
|
843 |
-
|
844 |
-
/* turns arguments array into variables */
|
845 |
-
extract( $args );
|
846 |
-
|
847 |
-
/* verify a description */
|
848 |
-
$has_desc = $field_desc ? true : false;
|
849 |
-
|
850 |
-
/* format setting outer wrapper */
|
851 |
-
echo '<div class="format-setting type-custom-post-type-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
852 |
-
|
853 |
-
/* description */
|
854 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
855 |
-
|
856 |
-
/* format setting inner wrapper */
|
857 |
-
echo '<div class="format-setting-inner">';
|
858 |
-
|
859 |
-
/* build category */
|
860 |
-
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . $field_class . '">';
|
861 |
-
|
862 |
-
/* setup the post types */
|
863 |
-
$post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' );
|
864 |
-
|
865 |
-
/* query posts array */
|
866 |
-
$my_posts = get_posts( apply_filters( 'ot_type_custom_post_type_select_query', array( 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) );
|
867 |
-
|
868 |
-
/* has posts */
|
869 |
-
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
870 |
-
echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
|
871 |
-
foreach( $my_posts as $my_post ) {
|
872 |
-
$post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled';
|
873 |
-
echo '<option value="' . esc_attr( $my_post->ID ) . '"' . selected( $field_value, $my_post->ID, false ) . '>' . $post_title . '</option>';
|
874 |
-
}
|
875 |
-
} else {
|
876 |
-
echo '<option value="">' . __( 'No Posts Found', 'option-tree' ) . '</option>';
|
877 |
-
}
|
878 |
-
|
879 |
-
echo '</select>';
|
880 |
-
|
881 |
-
echo '</div>';
|
882 |
-
|
883 |
-
echo '</div>';
|
884 |
-
|
885 |
-
}
|
886 |
-
|
887 |
-
}
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
/**
|
892 |
-
* Date Picker option type.
|
893 |
-
*
|
894 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
895 |
-
*
|
896 |
-
* @param array An array of arguments.
|
897 |
-
* @return string
|
898 |
-
*
|
899 |
-
* @access public
|
900 |
-
* @since 2.3
|
901 |
-
*/
|
902 |
-
if ( ! function_exists( 'ot_type_date_picker' ) ) {
|
903 |
-
|
904 |
-
function ot_type_date_picker( $args = array() ) {
|
905 |
-
|
906 |
-
/* turns arguments array into variables */
|
907 |
-
extract( $args );
|
908 |
-
|
909 |
-
/* verify a description */
|
910 |
-
$has_desc = $field_desc ? true : false;
|
911 |
-
|
912 |
-
/* filter date format */
|
913 |
-
$date_format = apply_filters( 'ot_type_date_picker_date_format', 'yy-mm-dd', $field_id );
|
914 |
-
|
915 |
-
/**
|
916 |
-
* Filter the addition of the readonly attribute.
|
917 |
-
*
|
918 |
-
* @since 2.5.0
|
919 |
-
*
|
920 |
-
* @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'.
|
921 |
-
* @param string $field_id The field ID.
|
922 |
-
*/
|
923 |
-
$is_readonly = apply_filters( 'ot_type_date_picker_readonly', false, $field_id );
|
924 |
-
|
925 |
-
/* format setting outer wrapper */
|
926 |
-
echo '<div class="format-setting type-date-picker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
927 |
-
|
928 |
-
/* date picker JS */
|
929 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_date_picker("' . esc_attr( $field_id ) . '", "' . esc_attr( $date_format ) . '"); });</script>';
|
930 |
-
|
931 |
-
/* description */
|
932 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
933 |
-
|
934 |
-
/* format setting inner wrapper */
|
935 |
-
echo '<div class="format-setting-inner">';
|
936 |
-
|
937 |
-
/* build date picker */
|
938 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '"' . ( $is_readonly == true ? ' readonly' : '' ) . ' />';
|
939 |
-
|
940 |
-
echo '</div>';
|
941 |
-
|
942 |
-
echo '</div>';
|
943 |
-
|
944 |
-
}
|
945 |
-
|
946 |
-
}
|
947 |
-
|
948 |
-
/**
|
949 |
-
* Date Time Picker option type.
|
950 |
-
*
|
951 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
952 |
-
*
|
953 |
-
* @param array An array of arguments.
|
954 |
-
* @return string
|
955 |
-
*
|
956 |
-
* @access public
|
957 |
-
* @since 2.3
|
958 |
-
*/
|
959 |
-
if ( ! function_exists( 'ot_type_date_time_picker' ) ) {
|
960 |
-
|
961 |
-
function ot_type_date_time_picker( $args = array() ) {
|
962 |
-
|
963 |
-
/* turns arguments array into variables */
|
964 |
-
extract( $args );
|
965 |
-
|
966 |
-
/* verify a description */
|
967 |
-
$has_desc = $field_desc ? true : false;
|
968 |
-
|
969 |
-
/* filter date format */
|
970 |
-
$date_format = apply_filters( 'ot_type_date_time_picker_date_format', 'yy-mm-dd', $field_id );
|
971 |
-
|
972 |
-
/**
|
973 |
-
* Filter the addition of the readonly attribute.
|
974 |
-
*
|
975 |
-
* @since 2.5.0
|
976 |
-
*
|
977 |
-
* @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'.
|
978 |
-
* @param string $field_id The field ID.
|
979 |
-
*/
|
980 |
-
$is_readonly = apply_filters( 'ot_type_date_time_picker_readonly', false, $field_id );
|
981 |
-
|
982 |
-
/* format setting outer wrapper */
|
983 |
-
echo '<div class="format-setting type-date-time-picker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
984 |
-
|
985 |
-
/* date time picker JS */
|
986 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_date_time_picker("' . esc_attr( $field_id ) . '", "' . esc_attr( $date_format ) . '"); });</script>';
|
987 |
-
|
988 |
-
/* description */
|
989 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
990 |
-
|
991 |
-
/* format setting inner wrapper */
|
992 |
-
echo '<div class="format-setting-inner">';
|
993 |
-
|
994 |
-
/* build date time picker */
|
995 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '"' . ( $is_readonly == true ? ' readonly' : '' ) . ' />';
|
996 |
-
|
997 |
-
echo '</div>';
|
998 |
-
|
999 |
-
echo '</div>';
|
1000 |
-
|
1001 |
-
}
|
1002 |
-
|
1003 |
-
}
|
1004 |
-
|
1005 |
-
/**
|
1006 |
-
* Dimension Option Type
|
1007 |
-
*
|
1008 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1009 |
-
*
|
1010 |
-
* @param array The options arguments
|
1011 |
-
* @return string The markup.
|
1012 |
-
*
|
1013 |
-
* @access public
|
1014 |
-
* @since 2.5.0
|
1015 |
-
*/
|
1016 |
-
if ( ! function_exists( 'ot_type_dimension' ) ) {
|
1017 |
-
|
1018 |
-
function ot_type_dimension( $args = array() ) {
|
1019 |
-
|
1020 |
-
/* turns arguments array into variables */
|
1021 |
-
extract( $args );
|
1022 |
-
|
1023 |
-
/* verify a description */
|
1024 |
-
$has_desc = $field_desc ? true : false;
|
1025 |
-
|
1026 |
-
/* format setting outer wrapper */
|
1027 |
-
echo '<div class="format-setting type-dimension ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1028 |
-
|
1029 |
-
/* description */
|
1030 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1031 |
-
|
1032 |
-
/* format setting inner wrapper */
|
1033 |
-
echo '<div class="format-setting-inner">';
|
1034 |
-
|
1035 |
-
/* allow fields to be filtered */
|
1036 |
-
$ot_recognized_dimension_fields = apply_filters( 'ot_recognized_dimension_fields', array(
|
1037 |
-
'width',
|
1038 |
-
'height',
|
1039 |
-
'unit'
|
1040 |
-
), $field_id );
|
1041 |
-
|
1042 |
-
/* build width dimension */
|
1043 |
-
if ( in_array( 'width', $ot_recognized_dimension_fields ) ) {
|
1044 |
-
|
1045 |
-
$width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : '';
|
1046 |
-
|
1047 |
-
echo '<div class="ot-option-group ot-option-group--one-third"><span class="ot-icon-arrows-h ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[width]" id="' . esc_attr( $field_id ) . '-width" value="' . esc_attr( $width ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . __( 'width', 'option-tree' ) . '" /></div>';
|
1048 |
-
|
1049 |
-
}
|
1050 |
-
|
1051 |
-
/* build height dimension */
|
1052 |
-
if ( in_array( 'height', $ot_recognized_dimension_fields ) ) {
|
1053 |
-
|
1054 |
-
$height = isset( $field_value['height'] ) ? esc_attr( $field_value['height'] ) : '';
|
1055 |
-
|
1056 |
-
echo '<div class="ot-option-group ot-option-group--one-third"><span class="ot-icon-arrows-v ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[height]" id="' . esc_attr( $field_id ) . '-height" value="' . esc_attr( $height ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . __( 'height', 'option-tree' ) . '" /></div>';
|
1057 |
-
|
1058 |
-
}
|
1059 |
-
|
1060 |
-
/* build unit dropdown */
|
1061 |
-
if ( in_array( 'unit', $ot_recognized_dimension_fields ) ) {
|
1062 |
-
|
1063 |
-
echo '<div class="ot-option-group ot-option-group--one-third ot-option-group--is-last">';
|
1064 |
-
|
1065 |
-
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1066 |
-
|
1067 |
-
echo '<option value="">' . __( 'unit', 'option-tree' ) . '</option>';
|
1068 |
-
|
1069 |
-
foreach ( ot_recognized_dimension_unit_types( $field_id ) as $unit ) {
|
1070 |
-
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1071 |
-
}
|
1072 |
-
|
1073 |
-
echo '</select>';
|
1074 |
-
|
1075 |
-
echo '</div>';
|
1076 |
-
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
echo '</div>';
|
1080 |
-
|
1081 |
-
echo '</div>';
|
1082 |
-
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
}
|
1086 |
-
|
1087 |
-
/**
|
1088 |
-
* Gallery option type.
|
1089 |
-
*
|
1090 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1091 |
-
*
|
1092 |
-
* @param array The options arguments
|
1093 |
-
* @return string The gallery metabox markup.
|
1094 |
-
*
|
1095 |
-
* @access public
|
1096 |
-
* @since 2.2.0
|
1097 |
-
*/
|
1098 |
-
if ( ! function_exists( 'ot_type_gallery' ) ) {
|
1099 |
-
|
1100 |
-
function ot_type_gallery( $args = array() ) {
|
1101 |
-
|
1102 |
-
// Turns arguments array into variables
|
1103 |
-
extract( $args );
|
1104 |
-
|
1105 |
-
// Verify a description
|
1106 |
-
$has_desc = $field_desc ? true : false;
|
1107 |
-
|
1108 |
-
// Format setting outer wrapper
|
1109 |
-
echo '<div class="format-setting type-gallery ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1110 |
-
|
1111 |
-
// Description
|
1112 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1113 |
-
|
1114 |
-
// Format setting inner wrapper
|
1115 |
-
echo '<div class="format-setting-inner">';
|
1116 |
-
|
1117 |
-
// Setup the post type
|
1118 |
-
$post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' );
|
1119 |
-
|
1120 |
-
$field_value = trim( $field_value );
|
1121 |
-
|
1122 |
-
// Saved values
|
1123 |
-
echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="ot-gallery-value ' . esc_attr( $field_class ) . '" />';
|
1124 |
-
|
1125 |
-
// Search the string for the IDs
|
1126 |
-
preg_match( '/ids=\'(.*?)\'/', $field_value, $matches );
|
1127 |
-
|
1128 |
-
// Turn the field value into an array of IDs
|
1129 |
-
if ( isset( $matches[1] ) ) {
|
1130 |
-
|
1131 |
-
// Found the IDs in the shortcode
|
1132 |
-
$ids = explode( ',', $matches[1] );
|
1133 |
-
|
1134 |
-
} else {
|
1135 |
-
|
1136 |
-
// The string is only IDs
|
1137 |
-
$ids = ! empty( $field_value ) && $field_value != '' ? explode( ',', $field_value ) : array();
|
1138 |
-
|
1139 |
-
}
|
1140 |
-
|
1141 |
-
// Has attachment IDs
|
1142 |
-
if ( ! empty( $ids ) ) {
|
1143 |
-
|
1144 |
-
echo '<ul class="ot-gallery-list">';
|
1145 |
-
|
1146 |
-
foreach( $ids as $id ) {
|
1147 |
-
|
1148 |
-
if ( $id == '' )
|
1149 |
-
continue;
|
1150 |
-
|
1151 |
-
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
|
1152 |
-
|
1153 |
-
echo '<li><img src="' . $thumbnail[0] . '" width="75" height="75" /></li>';
|
1154 |
-
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
echo '</ul>';
|
1158 |
-
|
1159 |
-
echo '
|
1160 |
-
<div class="ot-gallery-buttons">
|
1161 |
-
<a href="#" class="option-tree-ui-button button button-secondary hug-left ot-gallery-delete">' . __( 'Delete Gallery', 'option-tree' ) . '</a>
|
1162 |
-
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . __( 'Edit Gallery', 'option-tree' ) . '</a>
|
1163 |
-
</div>';
|
1164 |
-
|
1165 |
-
} else {
|
1166 |
-
|
1167 |
-
echo '
|
1168 |
-
<div class="ot-gallery-buttons">
|
1169 |
-
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . __( 'Create Gallery', 'option-tree' ) . '</a>
|
1170 |
-
</div>';
|
1171 |
-
|
1172 |
-
}
|
1173 |
-
|
1174 |
-
echo '</div>';
|
1175 |
-
|
1176 |
-
echo '</div>';
|
1177 |
-
|
1178 |
-
}
|
1179 |
-
|
1180 |
-
}
|
1181 |
-
|
1182 |
-
/**
|
1183 |
-
* Google Fonts option type.
|
1184 |
-
*
|
1185 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1186 |
-
*
|
1187 |
-
* @param array An array of arguments.
|
1188 |
-
* @return string
|
1189 |
-
*
|
1190 |
-
* @access public
|
1191 |
-
* @since 2.5.0
|
1192 |
-
*/
|
1193 |
-
if ( ! function_exists( 'ot_type_google_fonts' ) ) {
|
1194 |
-
|
1195 |
-
function ot_type_google_fonts( $args = array() ) {
|
1196 |
-
|
1197 |
-
/* turns arguments array into variables */
|
1198 |
-
extract( $args );
|
1199 |
-
|
1200 |
-
/* verify a description */
|
1201 |
-
$has_desc = $field_desc ? true : false;
|
1202 |
-
|
1203 |
-
/* format setting outer wrapper */
|
1204 |
-
echo '<div class="format-setting type-google-font ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1205 |
-
|
1206 |
-
/* description */
|
1207 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1208 |
-
|
1209 |
-
/* format setting inner wrapper */
|
1210 |
-
echo '<div class="format-setting-inner">';
|
1211 |
-
|
1212 |
-
/* allow fields to be filtered */
|
1213 |
-
$ot_recognized_google_fonts_fields = apply_filters( 'ot_recognized_google_font_fields', array(
|
1214 |
-
'variants',
|
1215 |
-
'subsets'
|
1216 |
-
), $field_id );
|
1217 |
-
|
1218 |
-
// Set a default to show at least one item.
|
1219 |
-
if ( ! is_array( $field_value ) || empty( $field_value ) ) {
|
1220 |
-
$field_value = array( array(
|
1221 |
-
'family' => '',
|
1222 |
-
'variants' => array(),
|
1223 |
-
'subsets' => array()
|
1224 |
-
) );
|
1225 |
-
}
|
1226 |
-
|
1227 |
-
foreach( $field_value as $key => $value ) {
|
1228 |
-
|
1229 |
-
echo '<div class="type-google-font-group">';
|
1230 |
-
|
1231 |
-
/* build font family */
|
1232 |
-
$family = isset( $value['family'] ) ? $value['family'] : '';
|
1233 |
-
echo '<div class="option-tree-google-font-family">';
|
1234 |
-
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . __( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . __( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1235 |
-
echo '<select name="' . esc_attr( $field_name ) . '[' . $key . '][family]" id="' . esc_attr( $field_id ) . '-' . $key . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1236 |
-
echo '<option value="">' . __( '-- Choose One --', 'option-tree' ) . '</option>';
|
1237 |
-
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1238 |
-
echo '<option value="' . esc_attr( $family_key ) . '" ' . selected( $family, $family_key, false ) . '>' . esc_html( $family_value ) . '</option>';
|
1239 |
-
}
|
1240 |
-
echo '</select>';
|
1241 |
-
echo '</div>';
|
1242 |
-
|
1243 |
-
/* build font variants */
|
1244 |
-
if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) {
|
1245 |
-
$variants = isset( $value['variants'] ) ? $value['variants'] : array();
|
1246 |
-
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . $key . '-" data-field-name="' . esc_attr( $field_name ) . '[' . $key . '][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1247 |
-
foreach ( ot_recognized_google_font_variants( $field_id, $family ) as $variant_key => $variant ) {
|
1248 |
-
echo '<p class="checkbox-wrap">';
|
1249 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . $key . '][variants][]" id="' . esc_attr( $field_id ) . '-' . $key . '-' . $variant . '" value="' . esc_attr( $variant ) . '" ' . checked( in_array( $variant, $variants ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1250 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . $key . '-' . $variant . '">' . esc_html( $variant ) . '</label>';
|
1251 |
-
echo '</p>';
|
1252 |
-
}
|
1253 |
-
echo '</div>';
|
1254 |
-
}
|
1255 |
-
|
1256 |
-
/* build font subsets */
|
1257 |
-
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) {
|
1258 |
-
$subsets = isset( $value['subsets'] ) ? $value['subsets'] : array();
|
1259 |
-
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . $key . '-" data-field-name="' . esc_attr( $field_name ) . '[' . $key . '][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1260 |
-
foreach ( ot_recognized_google_font_subsets( $field_id, $family ) as $subset_key => $subset ) {
|
1261 |
-
echo '<p class="checkbox-wrap">';
|
1262 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . $key . '][subsets][]" id="' . esc_attr( $field_id ) . '-' . $key . '-' . $subset . '" value="' . esc_attr( $subset ) . '" ' . checked( in_array( $subset, $subsets ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1263 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . $key . '-' . $subset . '">' . esc_html( $subset ) . '</label>';
|
1264 |
-
echo '</p>';
|
1265 |
-
}
|
1266 |
-
echo '</div>';
|
1267 |
-
}
|
1268 |
-
|
1269 |
-
echo '</div>';
|
1270 |
-
|
1271 |
-
}
|
1272 |
-
|
1273 |
-
echo '<div class="type-google-font-group-clone">';
|
1274 |
-
|
1275 |
-
/* build font family */
|
1276 |
-
echo '<div class="option-tree-google-font-family">';
|
1277 |
-
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . __( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . __( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1278 |
-
echo '<select name="' . esc_attr( $field_name ) . '[%key%][family]" id="' . esc_attr( $field_id ) . '-%key%" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1279 |
-
echo '<option value="">' . __( '-- Choose One --', 'option-tree' ) . '</option>';
|
1280 |
-
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1281 |
-
echo '<option value="' . esc_attr( $family_key ) . '">' . esc_html( $family_value ) . '</option>';
|
1282 |
-
}
|
1283 |
-
echo '</select>';
|
1284 |
-
echo '</div>';
|
1285 |
-
|
1286 |
-
/* build font variants */
|
1287 |
-
if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) {
|
1288 |
-
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1289 |
-
echo '</div>';
|
1290 |
-
}
|
1291 |
-
|
1292 |
-
/* build font subsets */
|
1293 |
-
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) {
|
1294 |
-
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1295 |
-
echo '</div>';
|
1296 |
-
}
|
1297 |
-
|
1298 |
-
echo '</div>';
|
1299 |
-
|
1300 |
-
echo '<a href="javascript:void(0);" class="js-add-google-font option-tree-ui-button button button-primary right hug-right" title="' . __( 'Add Google Font', 'option-tree' ) . '">' . __( 'Add Google Font', 'option-tree' ) . '</a>';
|
1301 |
-
|
1302 |
-
echo '</div>';
|
1303 |
-
|
1304 |
-
echo '</div>';
|
1305 |
-
|
1306 |
-
}
|
1307 |
-
|
1308 |
-
}
|
1309 |
-
|
1310 |
-
/**
|
1311 |
-
* JavaScript option type.
|
1312 |
-
*
|
1313 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1314 |
-
*
|
1315 |
-
* @param array An array of arguments.
|
1316 |
-
* @return string
|
1317 |
-
*
|
1318 |
-
* @access public
|
1319 |
-
* @since 2.5.0
|
1320 |
-
*/
|
1321 |
-
if ( ! function_exists( 'ot_type_javascript' ) ) {
|
1322 |
-
|
1323 |
-
function ot_type_javascript( $args = array() ) {
|
1324 |
-
|
1325 |
-
/* turns arguments array into variables */
|
1326 |
-
extract( $args );
|
1327 |
-
|
1328 |
-
/* verify a description */
|
1329 |
-
$has_desc = $field_desc ? true : false;
|
1330 |
-
|
1331 |
-
/* format setting outer wrapper */
|
1332 |
-
echo '<div class="format-setting type-javascript simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1333 |
-
|
1334 |
-
/* description */
|
1335 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1336 |
-
|
1337 |
-
/* format setting inner wrapper */
|
1338 |
-
echo '<div class="format-setting-inner">';
|
1339 |
-
|
1340 |
-
/* build textarea for CSS */
|
1341 |
-
echo '<textarea class="hidden" id="textarea_' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) .'">' . esc_attr( $field_value ) . '</textarea>';
|
1342 |
-
|
1343 |
-
/* build pre to convert it into ace editor later */
|
1344 |
-
echo '<pre class="ot-javascript-editor ' . esc_attr( $field_class ) . '" id="' . esc_attr( $field_id ) . '">' . esc_textarea( $field_value ) . '</pre>';
|
1345 |
-
|
1346 |
-
echo '</div>';
|
1347 |
-
|
1348 |
-
echo '</div>';
|
1349 |
-
|
1350 |
-
}
|
1351 |
-
|
1352 |
-
}
|
1353 |
-
|
1354 |
-
/**
|
1355 |
-
* Link Color option type.
|
1356 |
-
*
|
1357 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1358 |
-
*
|
1359 |
-
* @param array The options arguments
|
1360 |
-
* @return string The markup.
|
1361 |
-
*
|
1362 |
-
* @access public
|
1363 |
-
* @since 2.5.0
|
1364 |
-
*/
|
1365 |
-
if ( ! function_exists( 'ot_type_link_color' ) ) {
|
1366 |
-
|
1367 |
-
function ot_type_link_color( $args = array() ) {
|
1368 |
-
|
1369 |
-
/* turns arguments array into variables */
|
1370 |
-
extract( $args );
|
1371 |
-
|
1372 |
-
/* verify a description */
|
1373 |
-
$has_desc = $field_desc ? true : false;
|
1374 |
-
|
1375 |
-
/* format setting outer wrapper */
|
1376 |
-
echo '<div class="format-setting type-link-color ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1377 |
-
|
1378 |
-
/* description */
|
1379 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1380 |
-
|
1381 |
-
/* format setting inner wrapper */
|
1382 |
-
echo '<div class="format-setting-inner">';
|
1383 |
-
|
1384 |
-
/* allow fields to be filtered */
|
1385 |
-
$ot_recognized_link_color_fields = apply_filters( 'ot_recognized_link_color_fields', array(
|
1386 |
-
'link' => _x( 'Standard', 'color picker', 'option-tree' ),
|
1387 |
-
'hover' => _x( 'Hover', 'color picker', 'option-tree' ),
|
1388 |
-
'active' => _x( 'Active', 'color picker', 'option-tree' ),
|
1389 |
-
'visited' => _x( 'Visited', 'color picker', 'option-tree' ),
|
1390 |
-
'focus' => _x( 'Focus', 'color picker', 'option-tree' )
|
1391 |
-
), $field_id );
|
1392 |
-
|
1393 |
-
/* build link color fields */
|
1394 |
-
foreach( $ot_recognized_link_color_fields as $type => $label ) {
|
1395 |
-
|
1396 |
-
if ( array_key_exists( $type, $ot_recognized_link_color_fields ) ) {
|
1397 |
-
|
1398 |
-
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
1399 |
-
|
1400 |
-
echo '<label for="' . esc_attr( $field_id ) . '-picker-' . $type . '" class="option-tree-ui-colorpicker-label">' . esc_attr( $label ) . '</label>';
|
1401 |
-
|
1402 |
-
/* colorpicker JS */
|
1403 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker-' . $type . '"); });</script>';
|
1404 |
-
|
1405 |
-
/* set color */
|
1406 |
-
$color = isset( $field_value[ $type ] ) ? esc_attr( $field_value[ $type ] ) : '';
|
1407 |
-
|
1408 |
-
/* set default color */
|
1409 |
-
$std = isset( $field_std[ $type ] ) ? 'data-default-color="' . $field_std[ $type ] . '"' : '';
|
1410 |
-
|
1411 |
-
/* input */
|
1412 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '[' . $type . ']" id="' . esc_attr( $field_id ) . '-picker-' . $type . '" value="' . $color . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" ' . $std . ' />';
|
1413 |
-
|
1414 |
-
echo '</div>';
|
1415 |
-
|
1416 |
-
}
|
1417 |
-
|
1418 |
-
}
|
1419 |
-
|
1420 |
-
echo '</div>';
|
1421 |
-
|
1422 |
-
echo '</div>';
|
1423 |
-
|
1424 |
-
}
|
1425 |
-
|
1426 |
-
}
|
1427 |
-
|
1428 |
-
/**
|
1429 |
-
* List Item option type.
|
1430 |
-
*
|
1431 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1432 |
-
*
|
1433 |
-
* @param array An array of arguments.
|
1434 |
-
* @return string
|
1435 |
-
*
|
1436 |
-
* @access public
|
1437 |
-
* @since 2.0
|
1438 |
-
*/
|
1439 |
-
if ( ! function_exists( 'ot_type_list_item' ) ) {
|
1440 |
-
|
1441 |
-
function ot_type_list_item( $args = array() ) {
|
1442 |
-
|
1443 |
-
/* turns arguments array into variables */
|
1444 |
-
extract( $args );
|
1445 |
-
|
1446 |
-
/* verify a description */
|
1447 |
-
$has_desc = $field_desc ? true : false;
|
1448 |
-
|
1449 |
-
// Default
|
1450 |
-
$sortable = true;
|
1451 |
-
|
1452 |
-
// Check if the list can be sorted
|
1453 |
-
if ( ! empty( $field_class ) ) {
|
1454 |
-
$classes = explode( ' ', $field_class );
|
1455 |
-
if ( in_array( 'not-sortable', $classes ) ) {
|
1456 |
-
$sortable = false;
|
1457 |
-
str_replace( 'not-sortable', '', $field_class );
|
1458 |
-
}
|
1459 |
-
}
|
1460 |
-
|
1461 |
-
/* format setting outer wrapper */
|
1462 |
-
echo '<div class="format-setting type-list-item ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1463 |
-
|
1464 |
-
/* description */
|
1465 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1466 |
-
|
1467 |
-
/* format setting inner wrapper */
|
1468 |
-
echo '<div class="format-setting-inner">';
|
1469 |
-
|
1470 |
-
/* pass the settings array arround */
|
1471 |
-
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . ot_encode( serialize( $field_settings ) ) . '" />';
|
1472 |
-
|
1473 |
-
/**
|
1474 |
-
* settings pages have array wrappers like 'option_tree'.
|
1475 |
-
* So we need that value to create a proper array to save to.
|
1476 |
-
* This is only for NON metabox settings.
|
1477 |
-
*/
|
1478 |
-
if ( ! isset( $get_option ) )
|
1479 |
-
$get_option = '';
|
1480 |
-
|
1481 |
-
/* build list items */
|
1482 |
-
echo '<ul class="option-tree-setting-wrap' . ( $sortable ? ' option-tree-sortable' : '' ) .'" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
1483 |
-
|
1484 |
-
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
1485 |
-
|
1486 |
-
foreach( $field_value as $key => $list_item ) {
|
1487 |
-
|
1488 |
-
echo '<li class="ui-state-default list-list-item">';
|
1489 |
-
ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type );
|
1490 |
-
echo '</li>';
|
1491 |
-
|
1492 |
-
}
|
1493 |
-
|
1494 |
-
}
|
1495 |
-
|
1496 |
-
echo '</ul>';
|
1497 |
-
|
1498 |
-
/* button */
|
1499 |
-
echo '<a href="javascript:void(0);" class="option-tree-list-item-add option-tree-ui-button button button-primary right hug-right" title="' . __( 'Add New', 'option-tree' ) . '">' . __( 'Add New', 'option-tree' ) . '</a>';
|
1500 |
-
|
1501 |
-
/* description */
|
1502 |
-
$list_desc = $sortable ? __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) : '';
|
1503 |
-
echo '<div class="list-item-description">' . apply_filters( 'ot_list_item_description', $list_desc, $field_id ) . '</div>';
|
1504 |
-
|
1505 |
-
echo '</div>';
|
1506 |
-
|
1507 |
-
echo '</div>';
|
1508 |
-
|
1509 |
-
}
|
1510 |
-
|
1511 |
-
}
|
1512 |
-
|
1513 |
-
/**
|
1514 |
-
* Measurement option type.
|
1515 |
-
*
|
1516 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1517 |
-
*
|
1518 |
-
* @param array An array of arguments.
|
1519 |
-
* @return string
|
1520 |
-
*
|
1521 |
-
* @access public
|
1522 |
-
* @since 2.0
|
1523 |
-
*/
|
1524 |
-
if ( ! function_exists( 'ot_type_measurement' ) ) {
|
1525 |
-
|
1526 |
-
function ot_type_measurement( $args = array() ) {
|
1527 |
-
|
1528 |
-
/* turns arguments array into variables */
|
1529 |
-
extract( $args );
|
1530 |
-
|
1531 |
-
/* verify a description */
|
1532 |
-
$has_desc = $field_desc ? true : false;
|
1533 |
-
|
1534 |
-
/* format setting outer wrapper */
|
1535 |
-
echo '<div class="format-setting type-measurement ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1536 |
-
|
1537 |
-
/* description */
|
1538 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1539 |
-
|
1540 |
-
/* format setting inner wrapper */
|
1541 |
-
echo '<div class="format-setting-inner">';
|
1542 |
-
|
1543 |
-
echo '<div class="option-tree-ui-measurement-input-wrap">';
|
1544 |
-
|
1545 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '[0]" id="' . esc_attr( $field_id ) . '-0" value="' . ( isset( $field_value[0] ) ? esc_attr( $field_value[0] ) : '' ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" />';
|
1546 |
-
|
1547 |
-
echo '</div>';
|
1548 |
-
|
1549 |
-
/* build measurement */
|
1550 |
-
echo '<select name="' . esc_attr( $field_name ) . '[1]" id="' . esc_attr( $field_id ) . '-1" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1551 |
-
|
1552 |
-
echo '<option value="">' . __( 'unit', 'option-tree' ) . '</option>';
|
1553 |
-
|
1554 |
-
foreach ( ot_measurement_unit_types( $field_id ) as $unit ) {
|
1555 |
-
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value[1] ) ? selected( $field_value[1], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1556 |
-
}
|
1557 |
-
|
1558 |
-
echo '</select>';
|
1559 |
-
|
1560 |
-
echo '</div>';
|
1561 |
-
|
1562 |
-
echo '</div>';
|
1563 |
-
|
1564 |
-
}
|
1565 |
-
|
1566 |
-
}
|
1567 |
-
|
1568 |
-
/**
|
1569 |
-
* Numeric Slider option type.
|
1570 |
-
*
|
1571 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1572 |
-
*
|
1573 |
-
* @param array An array of arguments.
|
1574 |
-
* @return string
|
1575 |
-
*
|
1576 |
-
* @access public
|
1577 |
-
* @since 2.1
|
1578 |
-
*/
|
1579 |
-
if ( ! function_exists( 'ot_type_numeric_slider' ) ) {
|
1580 |
-
|
1581 |
-
function ot_type_numeric_slider( $args = array() ) {
|
1582 |
-
|
1583 |
-
/* turns arguments array into variables */
|
1584 |
-
extract( $args );
|
1585 |
-
|
1586 |
-
/* verify a description */
|
1587 |
-
$has_desc = $field_desc ? true : false;
|
1588 |
-
|
1589 |
-
$_options = explode( ',', $field_min_max_step );
|
1590 |
-
$min = isset( $_options[0] ) ? $_options[0] : 0;
|
1591 |
-
$max = isset( $_options[1] ) ? $_options[1] : 100;
|
1592 |
-
$step = isset( $_options[2] ) ? $_options[2] : 1;
|
1593 |
-
|
1594 |
-
/* format setting outer wrapper */
|
1595 |
-
echo '<div class="format-setting type-numeric-slider ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1596 |
-
|
1597 |
-
/* description */
|
1598 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1599 |
-
|
1600 |
-
/* format setting inner wrapper */
|
1601 |
-
echo '<div class="format-setting-inner">';
|
1602 |
-
|
1603 |
-
echo '<div class="ot-numeric-slider-wrap">';
|
1604 |
-
|
1605 |
-
echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="ot-numeric-slider-hidden-input" value="' . esc_attr( $field_value ) . '" data-min="' . esc_attr( $min ) . '" data-max="' . esc_attr( $max ) . '" data-step="' . esc_attr( $step ) . '">';
|
1606 |
-
|
1607 |
-
echo '<input type="text" class="ot-numeric-slider-helper-input widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" value="' . esc_attr( $field_value ) . '" readonly>';
|
1608 |
-
|
1609 |
-
echo '<div id="ot_numeric_slider_' . esc_attr( $field_id ) . '" class="ot-numeric-slider"></div>';
|
1610 |
-
|
1611 |
-
echo '</div>';
|
1612 |
-
|
1613 |
-
echo '</div>';
|
1614 |
-
|
1615 |
-
echo '</div>';
|
1616 |
-
}
|
1617 |
-
|
1618 |
-
}
|
1619 |
-
|
1620 |
-
/**
|
1621 |
-
* On/Off option type
|
1622 |
-
*
|
1623 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1624 |
-
*
|
1625 |
-
* @param array The options arguments
|
1626 |
-
* @return string The gallery metabox markup.
|
1627 |
-
*
|
1628 |
-
* @access public
|
1629 |
-
* @since 2.2.0
|
1630 |
-
*/
|
1631 |
-
if ( ! function_exists( 'ot_type_on_off' ) ) {
|
1632 |
-
|
1633 |
-
function ot_type_on_off( $args = array() ) {
|
1634 |
-
|
1635 |
-
/* turns arguments array into variables */
|
1636 |
-
extract( $args );
|
1637 |
-
|
1638 |
-
/* verify a description */
|
1639 |
-
$has_desc = $field_desc ? true : false;
|
1640 |
-
|
1641 |
-
/* format setting outer wrapper */
|
1642 |
-
echo '<div class="format-setting type-radio ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1643 |
-
|
1644 |
-
/* description */
|
1645 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1646 |
-
|
1647 |
-
/* format setting inner wrapper */
|
1648 |
-
echo '<div class="format-setting-inner">';
|
1649 |
-
|
1650 |
-
/* Force only two choices, and allowing filtering on the choices value & label */
|
1651 |
-
$field_choices = array(
|
1652 |
-
array(
|
1653 |
-
/**
|
1654 |
-
* Filter the value of the On button.
|
1655 |
-
*
|
1656 |
-
* @since 2.5.0
|
1657 |
-
*
|
1658 |
-
* @param string The On button value. Default 'on'.
|
1659 |
-
* @param string $field_id The field ID.
|
1660 |
-
* @param string $filter_id For filtering both on/off value with one function.
|
1661 |
-
*/
|
1662 |
-
'value' => apply_filters( 'ot_on_off_switch_on_value', 'on', $field_id, 'on' ),
|
1663 |
-
/**
|
1664 |
-
* Filter the label of the On button.
|
1665 |
-
*
|
1666 |
-
* @since 2.5.0
|
1667 |
-
*
|
1668 |
-
* @param string The On button label. Default 'On'.
|
1669 |
-
* @param string $field_id The field ID.
|
1670 |
-
* @param string $filter_id For filtering both on/off label with one function.
|
1671 |
-
*/
|
1672 |
-
'label' => apply_filters( 'ot_on_off_switch_on_label', __( 'On', 'option-tree' ), $field_id, 'on' )
|
1673 |
-
),
|
1674 |
-
array(
|
1675 |
-
/**
|
1676 |
-
* Filter the value of the Off button.
|
1677 |
-
*
|
1678 |
-
* @since 2.5.0
|
1679 |
-
*
|
1680 |
-
* @param string The Off button value. Default 'off'.
|
1681 |
-
* @param string $field_id The field ID.
|
1682 |
-
* @param string $filter_id For filtering both on/off value with one function.
|
1683 |
-
*/
|
1684 |
-
'value' => apply_filters( 'ot_on_off_switch_off_value', 'off', $field_id, 'off' ),
|
1685 |
-
/**
|
1686 |
-
* Filter the label of the Off button.
|
1687 |
-
*
|
1688 |
-
* @since 2.5.0
|
1689 |
-
*
|
1690 |
-
* @param string The Off button label. Default 'Off'.
|
1691 |
-
* @param string $field_id The field ID.
|
1692 |
-
* @param string $filter_id For filtering both on/off label with one function.
|
1693 |
-
*/
|
1694 |
-
'label' => apply_filters( 'ot_on_off_switch_off_label', __( 'Off', 'option-tree' ), $field_id, 'off' )
|
1695 |
-
)
|
1696 |
-
);
|
1697 |
-
|
1698 |
-
/**
|
1699 |
-
* Filter the width of the On/Off switch.
|
1700 |
-
*
|
1701 |
-
* @since 2.5.0
|
1702 |
-
*
|
1703 |
-
* @param string The switch width. Default '100px'.
|
1704 |
-
* @param string $field_id The field ID.
|
1705 |
-
*/
|
1706 |
-
$switch_width = apply_filters( 'ot_on_off_switch_width', '100px', $field_id );
|
1707 |
-
|
1708 |
-
echo '<div class="on-off-switch"' . ( $switch_width != '100px' ? sprintf( ' style="width:%s"', $switch_width ) : '' ) . '>';
|
1709 |
-
|
1710 |
-
/* build radio */
|
1711 |
-
foreach ( (array) $field_choices as $key => $choice ) {
|
1712 |
-
echo '
|
1713 |
-
<input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '"' . checked( $field_value, $choice['value'], false ) . ' class="radio option-tree-ui-radio ' . esc_attr( $field_class ) . '" />
|
1714 |
-
<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" onclick="">' . esc_attr( $choice['label'] ) . '</label>';
|
1715 |
-
}
|
1716 |
-
|
1717 |
-
echo '<span class="slide-button"></span>';
|
1718 |
-
|
1719 |
-
echo '</div>';
|
1720 |
-
|
1721 |
-
echo '</div>';
|
1722 |
-
|
1723 |
-
echo '</div>';
|
1724 |
-
|
1725 |
-
}
|
1726 |
-
|
1727 |
-
}
|
1728 |
-
|
1729 |
-
/**
|
1730 |
-
* Page Checkbox option type.
|
1731 |
-
*
|
1732 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1733 |
-
*
|
1734 |
-
* @param array An array of arguments.
|
1735 |
-
* @return string
|
1736 |
-
*
|
1737 |
-
* @access public
|
1738 |
-
* @since 2.0
|
1739 |
-
*/
|
1740 |
-
if ( ! function_exists( 'ot_type_page_checkbox' ) ) {
|
1741 |
-
|
1742 |
-
function ot_type_page_checkbox( $args = array() ) {
|
1743 |
-
|
1744 |
-
/* turns arguments array into variables */
|
1745 |
-
extract( $args );
|
1746 |
-
|
1747 |
-
/* verify a description */
|
1748 |
-
$has_desc = $field_desc ? true : false;
|
1749 |
-
|
1750 |
-
/* format setting outer wrapper */
|
1751 |
-
echo '<div class="format-setting type-page-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1752 |
-
|
1753 |
-
/* description */
|
1754 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1755 |
-
|
1756 |
-
/* format setting inner wrapper */
|
1757 |
-
echo '<div class="format-setting-inner">';
|
1758 |
-
|
1759 |
-
/* query pages array */
|
1760 |
-
$my_posts = get_posts( apply_filters( 'ot_type_page_checkbox_query', array( 'post_type' => array( 'page' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) );
|
1761 |
-
|
1762 |
-
/* has pages */
|
1763 |
-
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1764 |
-
foreach( $my_posts as $my_post ) {
|
1765 |
-
$post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled';
|
1766 |
-
echo '<p>';
|
1767 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[$my_post->ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1768 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . $post_title . '</label>';
|
1769 |
-
echo '</p>';
|
1770 |
-
}
|
1771 |
-
} else {
|
1772 |
-
echo '<p>' . __( 'No Pages Found', 'option-tree' ) . '</p>';
|
1773 |
-
}
|
1774 |
-
|
1775 |
-
echo '</div>';
|
1776 |
-
|
1777 |
-
echo '</div>';
|
1778 |
-
|
1779 |
-
}
|
1780 |
-
|
1781 |
-
}
|
1782 |
-
|
1783 |
-
/**
|
1784 |
-
* Page Select option type.
|
1785 |
-
*
|
1786 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1787 |
-
*
|
1788 |
-
* @param array An array of arguments.
|
1789 |
-
* @return string
|
1790 |
-
*
|
1791 |
-
* @access public
|
1792 |
-
* @since 2.0
|
1793 |
-
*/
|
1794 |
-
if ( ! function_exists( 'ot_type_page_select' ) ) {
|
1795 |
-
|
1796 |
-
function ot_type_page_select( $args = array() ) {
|
1797 |
-
|
1798 |
-
/* turns arguments array into variables */
|
1799 |
-
extract( $args );
|
1800 |
-
|
1801 |
-
/* verify a description */
|
1802 |
-
$has_desc = $field_desc ? true : false;
|
1803 |
-
|
1804 |
-
/* format setting outer wrapper */
|
1805 |
-
echo '<div class="format-setting type-page-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1806 |
-
|
1807 |
-
/* description */
|
1808 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1809 |
-
|
1810 |
-
/* format setting inner wrapper */
|
1811 |
-
echo '<div class="format-setting-inner">';
|
1812 |
-
|
1813 |
-
/* build page select */
|
1814 |
-
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . $field_class . '">';
|
1815 |
-
|
1816 |
-
/* query pages array */
|
1817 |
-
$my_posts = get_posts( apply_filters( 'ot_type_page_select_query', array( 'post_type' => array( 'page' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) );
|
1818 |
-
|
1819 |
-
/* has pages */
|
1820 |
-
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1821 |
-
echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
|
1822 |
-
foreach( $my_posts as $my_post ) {
|
1823 |
-
$post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled';
|
1824 |
-
echo '<option value="' . esc_attr( $my_post->ID ) . '"' . selected( $field_value, $my_post->ID, false ) . '>' . $post_title . '</option>';
|
1825 |
-
}
|
1826 |
-
} else {
|
1827 |
-
echo '<option value="">' . __( 'No Pages Found', 'option-tree' ) . '</option>';
|
1828 |
-
}
|
1829 |
-
|
1830 |
-
echo '</select>';
|
1831 |
-
|
1832 |
-
echo '</div>';
|
1833 |
-
|
1834 |
-
echo '</div>';
|
1835 |
-
|
1836 |
-
}
|
1837 |
-
|
1838 |
-
}
|
1839 |
-
|
1840 |
-
/**
|
1841 |
-
* Post Checkbox option type.
|
1842 |
-
*
|
1843 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1844 |
-
*
|
1845 |
-
* @param array An array of arguments.
|
1846 |
-
* @return string
|
1847 |
-
*
|
1848 |
-
* @access public
|
1849 |
-
* @since 2.0
|
1850 |
-
*/
|
1851 |
-
if ( ! function_exists( 'ot_type_post_checkbox' ) ) {
|
1852 |
-
|
1853 |
-
function ot_type_post_checkbox( $args = array() ) {
|
1854 |
-
|
1855 |
-
/* turns arguments array into variables */
|
1856 |
-
extract( $args );
|
1857 |
-
|
1858 |
-
/* verify a description */
|
1859 |
-
$has_desc = $field_desc ? true : false;
|
1860 |
-
|
1861 |
-
/* format setting outer wrapper */
|
1862 |
-
echo '<div class="format-setting type-post-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1863 |
-
|
1864 |
-
/* description */
|
1865 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1866 |
-
|
1867 |
-
/* format setting inner wrapper */
|
1868 |
-
echo '<div class="format-setting-inner">';
|
1869 |
-
|
1870 |
-
/* query posts array */
|
1871 |
-
$my_posts = get_posts( apply_filters( 'ot_type_post_checkbox_query', array( 'post_type' => array( 'post' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) );
|
1872 |
-
|
1873 |
-
/* has posts */
|
1874 |
-
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1875 |
-
foreach( $my_posts as $my_post ) {
|
1876 |
-
$post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled';
|
1877 |
-
echo '<p>';
|
1878 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[$my_post->ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1879 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . $post_title . '</label>';
|
1880 |
-
echo '</p>';
|
1881 |
-
}
|
1882 |
-
} else {
|
1883 |
-
echo '<p>' . __( 'No Posts Found', 'option-tree' ) . '</p>';
|
1884 |
-
}
|
1885 |
-
|
1886 |
-
echo '</div>';
|
1887 |
-
|
1888 |
-
echo '</div>';
|
1889 |
-
|
1890 |
-
}
|
1891 |
-
|
1892 |
-
}
|
1893 |
-
|
1894 |
-
/**
|
1895 |
-
* Post Select option type.
|
1896 |
-
*
|
1897 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1898 |
-
*
|
1899 |
-
* @param array An array of arguments.
|
1900 |
-
* @return string
|
1901 |
-
*
|
1902 |
-
* @access public
|
1903 |
-
* @since 2.0
|
1904 |
-
*/
|
1905 |
-
if ( ! function_exists( 'ot_type_post_select' ) ) {
|
1906 |
-
|
1907 |
-
function ot_type_post_select( $args = array() ) {
|
1908 |
-
|
1909 |
-
/* turns arguments array into variables */
|
1910 |
-
extract( $args );
|
1911 |
-
|
1912 |
-
/* verify a description */
|
1913 |
-
$has_desc = $field_desc ? true : false;
|
1914 |
-
|
1915 |
-
/* format setting outer wrapper */
|
1916 |
-
echo '<div class="format-setting type-post-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1917 |
-
|
1918 |
-
/* description */
|
1919 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1920 |
-
|
1921 |
-
/* format setting inner wrapper */
|
1922 |
-
echo '<div class="format-setting-inner">';
|
1923 |
-
|
1924 |
-
/* build page select */
|
1925 |
-
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . $field_class . '">';
|
1926 |
-
|
1927 |
-
/* query posts array */
|
1928 |
-
$my_posts = get_posts( apply_filters( 'ot_type_post_select_query', array( 'post_type' => array( 'post' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) );
|
1929 |
-
|
1930 |
-
/* has posts */
|
1931 |
-
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1932 |
-
echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
|
1933 |
-
foreach( $my_posts as $my_post ) {
|
1934 |
-
$post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled';
|
1935 |
-
echo '<option value="' . esc_attr( $my_post->ID ) . '"' . selected( $field_value, $my_post->ID, false ) . '>' . $post_title . '</option>';
|
1936 |
-
}
|
1937 |
-
} else {
|
1938 |
-
echo '<option value="">' . __( 'No Posts Found', 'option-tree' ) . '</option>';
|
1939 |
-
}
|
1940 |
-
|
1941 |
-
echo '</select>';
|
1942 |
-
|
1943 |
-
echo '</div>';
|
1944 |
-
|
1945 |
-
echo '</div>';
|
1946 |
-
|
1947 |
-
}
|
1948 |
-
|
1949 |
-
}
|
1950 |
-
|
1951 |
-
/**
|
1952 |
-
* Radio option type.
|
1953 |
-
*
|
1954 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1955 |
-
*
|
1956 |
-
* @param array An array of arguments.
|
1957 |
-
* @return string
|
1958 |
-
*
|
1959 |
-
* @access public
|
1960 |
-
* @since 2.0
|
1961 |
-
*/
|
1962 |
-
if ( ! function_exists( 'ot_type_radio' ) ) {
|
1963 |
-
|
1964 |
-
function ot_type_radio( $args = array() ) {
|
1965 |
-
|
1966 |
-
/* turns arguments array into variables */
|
1967 |
-
extract( $args );
|
1968 |
-
|
1969 |
-
/* verify a description */
|
1970 |
-
$has_desc = $field_desc ? true : false;
|
1971 |
-
|
1972 |
-
/* format setting outer wrapper */
|
1973 |
-
echo '<div class="format-setting type-radio ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1974 |
-
|
1975 |
-
/* description */
|
1976 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1977 |
-
|
1978 |
-
/* format setting inner wrapper */
|
1979 |
-
echo '<div class="format-setting-inner">';
|
1980 |
-
|
1981 |
-
/* build radio */
|
1982 |
-
foreach ( (array) $field_choices as $key => $choice ) {
|
1983 |
-
echo '<p><input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '"' . checked( $field_value, $choice['value'], false ) . ' class="radio option-tree-ui-radio ' . esc_attr( $field_class ) . '" /><label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label></p>';
|
1984 |
-
}
|
1985 |
-
|
1986 |
-
echo '</div>';
|
1987 |
-
|
1988 |
-
echo '</div>';
|
1989 |
-
|
1990 |
-
}
|
1991 |
-
|
1992 |
-
}
|
1993 |
-
|
1994 |
-
/**
|
1995 |
-
* Radio Images option type.
|
1996 |
-
*
|
1997 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1998 |
-
*
|
1999 |
-
* @param array An array of arguments.
|
2000 |
-
* @return string
|
2001 |
-
*
|
2002 |
-
* @access public
|
2003 |
-
* @since 2.0
|
2004 |
-
*/
|
2005 |
-
if ( ! function_exists( 'ot_type_radio_image' ) ) {
|
2006 |
-
|
2007 |
-
function ot_type_radio_image( $args = array() ) {
|
2008 |
-
|
2009 |
-
/* turns arguments array into variables */
|
2010 |
-
extract( $args );
|
2011 |
-
|
2012 |
-
/* verify a description */
|
2013 |
-
$has_desc = $field_desc ? true : false;
|
2014 |
-
|
2015 |
-
/* format setting outer wrapper */
|
2016 |
-
echo '<div class="format-setting type-radio-image ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2017 |
-
|
2018 |
-
/* description */
|
2019 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
2020 |
-
|
2021 |
-
/* format setting inner wrapper */
|
2022 |
-
echo '<div class="format-setting-inner">';
|
2023 |
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
*/
|
2028 |
-
if ( empty( $field_choices ) )
|
2029 |
-
$field_choices = ot_radio_images( $field_id );
|
2030 |
-
|
2031 |
-
/* build radio image */
|
2032 |
-
foreach ( (array) $field_choices as $key => $choice ) {
|
2033 |
-
|
2034 |
-
$src = str_replace( 'OT_URL', OT_URL, $choice['src'] );
|
2035 |
-
$src = str_replace( 'OT_THEME_URL', OT_THEME_URL, $src );
|
2036 |
-
|
2037 |
-
/* make radio image source filterable */
|
2038 |
-
$src = apply_filters( 'ot_type_radio_image_src', $src, $field_id );
|
2039 |
-
|
2040 |
-
/**
|
2041 |
-
* Filter the image attributes.
|
2042 |
-
*
|
2043 |
-
* @since 2.5.3
|
2044 |
-
*
|
2045 |
-
* @param string $attributes The image attributes.
|
2046 |
-
* @param string $field_id The field ID.
|
2047 |
-
* @param array $choice The choice.
|
2048 |
-
*/
|
2049 |
-
$attributes = apply_filters( 'ot_type_radio_image_attributes', '', $field_id, $choice );
|
2050 |
-
|
2051 |
-
echo '<div class="option-tree-ui-radio-images">';
|
2052 |
-
echo '<p style="display:none"><input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '"' . checked( $field_value, $choice['value'], false ) . ' class="option-tree-ui-radio option-tree-ui-images" /><label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label></p>';
|
2053 |
-
echo '<img ' . $attributes . ' src="' . esc_url( $src ) . '" alt="' . esc_attr( $choice['label'] ) .'" title="' . esc_attr( $choice['label'] ) .'" class="option-tree-ui-radio-image ' . esc_attr( $field_class ) . ( $field_value == $choice['value'] ? ' option-tree-ui-radio-image-selected' : '' ) . '" />';
|
2054 |
-
echo '</div>';
|
2055 |
-
}
|
2056 |
-
|
2057 |
-
echo '</div>';
|
2058 |
-
|
2059 |
-
echo '</div>';
|
2060 |
-
|
2061 |
-
}
|
2062 |
-
|
2063 |
-
}
|
2064 |
-
|
2065 |
-
/**
|
2066 |
-
* Select option type.
|
2067 |
-
*
|
2068 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2069 |
-
*
|
2070 |
-
* @param array An array of arguments.
|
2071 |
-
* @return string
|
2072 |
-
*
|
2073 |
-
* @access public
|
2074 |
-
* @since 2.0
|
2075 |
-
*/
|
2076 |
-
if ( ! function_exists( 'ot_type_select' ) ) {
|
2077 |
|
2078 |
-
|
|
|
2079 |
|
2080 |
-
|
2081 |
-
extract( $args );
|
2082 |
|
2083 |
-
|
2084 |
-
$has_desc = $field_desc ? true : false;
|
2085 |
|
2086 |
-
|
2087 |
-
|
|
|
2088 |
|
2089 |
-
|
2090 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
2091 |
|
2092 |
-
|
2093 |
-
|
2094 |
|
2095 |
-
|
2096 |
-
echo '<div class="format-setting-inner">';
|
2097 |
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
}
|
2104 |
-
}
|
2105 |
|
2106 |
-
|
2107 |
|
2108 |
-
|
|
|
|
|
|
|
2109 |
|
2110 |
-
|
2111 |
|
2112 |
-
|
2113 |
|
|
|
|
|
2114 |
}
|
2115 |
|
2116 |
-
|
2117 |
-
* Sidebar Select option type.
|
2118 |
-
*
|
2119 |
-
* This option type makes it possible for users to select a WordPress registered sidebar
|
2120 |
-
* to use on a specific area. By using the two provided filters, 'ot_recognized_sidebars',
|
2121 |
-
* and 'ot_recognized_sidebars_{$field_id}' we can be selective about which sidebars are
|
2122 |
-
* available on a specific content area.
|
2123 |
-
*
|
2124 |
-
* For example, if we create a WordPress theme that provides the ability to change the
|
2125 |
-
* Blog Sidebar and we don't want to have the footer sidebars available on this area,
|
2126 |
-
* we can unset those sidebars either manually or by using a regular expression if we
|
2127 |
-
* have a common name like footer-sidebar-$i.
|
2128 |
-
*
|
2129 |
-
* @param array An array of arguments.
|
2130 |
-
* @return string
|
2131 |
-
*
|
2132 |
-
* @access public
|
2133 |
-
* @since 2.1
|
2134 |
-
*/
|
2135 |
-
if ( ! function_exists( 'ot_type_sidebar_select' ) ) {
|
2136 |
-
|
2137 |
-
function ot_type_sidebar_select( $args = array() ) {
|
2138 |
-
|
2139 |
-
/* turns arguments array into variables */
|
2140 |
-
extract( $args );
|
2141 |
-
|
2142 |
-
/* verify a description */
|
2143 |
-
$has_desc = $field_desc ? true : false;
|
2144 |
-
|
2145 |
-
/* format setting outer wrapper */
|
2146 |
-
echo '<div class="format-setting type-sidebar-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2147 |
|
2148 |
-
|
2149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2150 |
|
2151 |
-
|
2152 |
-
echo '<div class="format-setting-inner">';
|
2153 |
|
2154 |
-
|
2155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2156 |
|
2157 |
-
|
2158 |
-
|
2159 |
|
2160 |
-
|
2161 |
-
|
2162 |
-
$sidebars[ $id ] = $sidebar[ 'name' ];
|
2163 |
-
}
|
2164 |
|
2165 |
-
|
2166 |
-
|
2167 |
-
$sidebars = apply_filters( 'ot_recognized_sidebars_' . $field_id, $sidebars );
|
2168 |
|
2169 |
-
|
2170 |
-
|
2171 |
-
echo '<option value="">-- ' . __( 'Choose Sidebar', 'option-tree' ) . ' --</option>';
|
2172 |
-
foreach ( $sidebars as $id => $sidebar ) {
|
2173 |
-
echo '<option value="' . esc_attr( $id ) . '"' . selected( $field_value, $id, false ) . '>' . esc_attr( $sidebar ) . '</option>';
|
2174 |
-
}
|
2175 |
-
} else {
|
2176 |
-
echo '<option value="">' . __( 'No Sidebars', 'option-tree' ) . '</option>';
|
2177 |
-
}
|
2178 |
|
2179 |
-
|
|
|
2180 |
|
2181 |
-
|
|
|
2182 |
|
2183 |
-
|
|
|
2184 |
|
2185 |
-
|
2186 |
|
|
|
|
|
2187 |
}
|
2188 |
|
2189 |
-
|
2190 |
-
* List Item option type.
|
2191 |
-
*
|
2192 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2193 |
-
*
|
2194 |
-
* @param array An array of arguments.
|
2195 |
-
* @return string
|
2196 |
-
*
|
2197 |
-
* @access public
|
2198 |
-
* @since 2.0
|
2199 |
-
*/
|
2200 |
-
if ( ! function_exists( 'ot_type_slider' ) ) {
|
2201 |
-
|
2202 |
-
function ot_type_slider( $args = array() ) {
|
2203 |
-
|
2204 |
-
/* turns arguments array into variables */
|
2205 |
-
extract( $args );
|
2206 |
|
2207 |
-
|
2208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2209 |
|
2210 |
-
|
2211 |
-
|
2212 |
|
2213 |
-
|
2214 |
-
|
2215 |
|
2216 |
-
|
2217 |
-
|
2218 |
|
2219 |
-
|
2220 |
-
|
2221 |
|
2222 |
-
|
2223 |
-
|
2224 |
-
* So we need that value to create a proper array to save to.
|
2225 |
-
* This is only for NON metabox settings.
|
2226 |
-
*/
|
2227 |
-
if ( ! isset( $get_option ) )
|
2228 |
-
$get_option = '';
|
2229 |
|
2230 |
-
|
2231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2232 |
|
2233 |
-
|
|
|
2234 |
|
2235 |
-
|
2236 |
|
2237 |
-
|
2238 |
-
ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type );
|
2239 |
-
echo '</li>';
|
2240 |
|
2241 |
-
|
2242 |
|
2243 |
-
|
|
|
2244 |
|
2245 |
-
|
|
|
2246 |
|
2247 |
-
|
2248 |
-
|
2249 |
|
2250 |
-
|
2251 |
-
|
2252 |
|
2253 |
-
|
2254 |
|
2255 |
-
|
|
|
2256 |
|
2257 |
-
|
2258 |
|
|
|
|
|
2259 |
}
|
2260 |
|
2261 |
-
|
2262 |
-
* Social Links option type.
|
2263 |
-
*
|
2264 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2265 |
-
*
|
2266 |
-
* @param array An array of arguments.
|
2267 |
-
* @return string
|
2268 |
-
*
|
2269 |
-
* @access public
|
2270 |
-
* @since 2.4.0
|
2271 |
-
*/
|
2272 |
-
if ( ! function_exists( 'ot_type_social_links' ) ) {
|
2273 |
-
|
2274 |
-
function ot_type_social_links( $args = array() ) {
|
2275 |
-
|
2276 |
-
/* turns arguments array into variables */
|
2277 |
-
extract( $args );
|
2278 |
-
|
2279 |
-
/* Load the default social links */
|
2280 |
-
if ( empty( $field_value ) && apply_filters( 'ot_type_social_links_load_defaults', true, $field_id ) ) {
|
2281 |
-
|
2282 |
-
$field_value = apply_filters( 'ot_type_social_links_defaults', array(
|
2283 |
-
array(
|
2284 |
-
'name' => __( 'Facebook', 'option-tree' ),
|
2285 |
-
'title' => '',
|
2286 |
-
'href' => ''
|
2287 |
-
),
|
2288 |
-
array(
|
2289 |
-
'name' => __( 'Twitter', 'option-tree' ),
|
2290 |
-
'title' => '',
|
2291 |
-
'href' => ''
|
2292 |
-
),
|
2293 |
-
array(
|
2294 |
-
'name' => __( 'Google+', 'option-tree' ),
|
2295 |
-
'title' => '',
|
2296 |
-
'href' => ''
|
2297 |
-
),
|
2298 |
-
array(
|
2299 |
-
'name' => __( 'LinkedIn', 'option-tree' ),
|
2300 |
-
'title' => '',
|
2301 |
-
'href' => ''
|
2302 |
-
),
|
2303 |
-
array(
|
2304 |
-
'name' => __( 'Pinterest', 'option-tree' ),
|
2305 |
-
'title' => '',
|
2306 |
-
'href' => ''
|
2307 |
-
),
|
2308 |
-
array(
|
2309 |
-
'name' => __( 'Youtube', 'option-tree' ),
|
2310 |
-
'title' => '',
|
2311 |
-
'href' => ''
|
2312 |
-
),
|
2313 |
-
array(
|
2314 |
-
'name' => __( 'Dribbble', 'option-tree' ),
|
2315 |
-
'title' => '',
|
2316 |
-
'href' => ''
|
2317 |
-
),
|
2318 |
-
array(
|
2319 |
-
'name' => __( 'Github', 'option-tree' ),
|
2320 |
-
'title' => '',
|
2321 |
-
'href' => ''
|
2322 |
-
),
|
2323 |
-
array(
|
2324 |
-
'name' => __( 'Forrst', 'option-tree' ),
|
2325 |
-
'title' => '',
|
2326 |
-
'href' => ''
|
2327 |
-
),
|
2328 |
-
array(
|
2329 |
-
'name' => __( 'Digg', 'option-tree' ),
|
2330 |
-
'title' => '',
|
2331 |
-
'href' => ''
|
2332 |
-
),
|
2333 |
-
array(
|
2334 |
-
'name' => __( 'Delicious', 'option-tree' ),
|
2335 |
-
'title' => '',
|
2336 |
-
'href' => ''
|
2337 |
-
),
|
2338 |
-
array(
|
2339 |
-
'name' => __( 'Tumblr', 'option-tree' ),
|
2340 |
-
'title' => '',
|
2341 |
-
'href' => ''
|
2342 |
-
),
|
2343 |
-
array(
|
2344 |
-
'name' => __( 'Skype', 'option-tree' ),
|
2345 |
-
'title' => '',
|
2346 |
-
'href' => ''
|
2347 |
-
),
|
2348 |
-
array(
|
2349 |
-
'name' => __( 'SoundCloud', 'option-tree' ),
|
2350 |
-
'title' => '',
|
2351 |
-
'href' => ''
|
2352 |
-
),
|
2353 |
-
array(
|
2354 |
-
'name' => __( 'Vimeo', 'option-tree' ),
|
2355 |
-
'title' => '',
|
2356 |
-
'href' => ''
|
2357 |
-
),
|
2358 |
-
array(
|
2359 |
-
'name' => __( 'Flickr', 'option-tree' ),
|
2360 |
-
'title' => '',
|
2361 |
-
'href' => ''
|
2362 |
-
),
|
2363 |
-
array(
|
2364 |
-
'name' => __( 'VK.com', 'option-tree' ),
|
2365 |
-
'title' => '',
|
2366 |
-
'href' => ''
|
2367 |
-
)
|
2368 |
-
), $field_id );
|
2369 |
-
|
2370 |
-
}
|
2371 |
|
2372 |
-
|
2373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2374 |
|
2375 |
-
|
2376 |
-
|
2377 |
|
2378 |
-
|
2379 |
-
|
2380 |
|
2381 |
-
|
2382 |
-
|
2383 |
|
2384 |
-
|
2385 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2386 |
|
2387 |
-
|
2388 |
-
|
2389 |
-
* So we need that value to create a proper array to save to.
|
2390 |
-
* This is only for NON metabox settings.
|
2391 |
-
*/
|
2392 |
-
if ( ! isset( $get_option ) )
|
2393 |
-
$get_option = '';
|
2394 |
|
2395 |
-
|
2396 |
-
|
2397 |
|
2398 |
-
|
|
|
2399 |
|
2400 |
-
|
|
|
2401 |
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
|
|
|
|
|
|
|
|
|
|
2405 |
|
2406 |
-
|
|
|
2407 |
|
2408 |
-
|
2409 |
|
2410 |
-
|
2411 |
|
2412 |
-
|
2413 |
-
|
|
|
|
|
|
|
2414 |
|
2415 |
-
|
2416 |
-
echo '<div class="list-item-description">' . apply_filters( 'ot_social_links_description', __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ), $field_id ) . '</div>';
|
2417 |
|
2418 |
-
|
|
|
2419 |
|
2420 |
-
|
|
|
|
|
2421 |
|
2422 |
-
|
2423 |
|
|
|
|
|
2424 |
}
|
2425 |
|
2426 |
-
|
2427 |
-
* Spacing Option Type.
|
2428 |
-
*
|
2429 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2430 |
-
*
|
2431 |
-
* @param array An array of arguments.
|
2432 |
-
* @return string
|
2433 |
-
*
|
2434 |
-
* @access public
|
2435 |
-
* @since 2.5.0
|
2436 |
-
*/
|
2437 |
-
if ( ! function_exists( 'ot_type_spacing' ) ) {
|
2438 |
-
|
2439 |
-
function ot_type_spacing( $args = array() ) {
|
2440 |
-
|
2441 |
-
/* turns arguments array into variables */
|
2442 |
-
extract( $args );
|
2443 |
-
|
2444 |
-
/* verify a description */
|
2445 |
-
$has_desc = $field_desc ? true : false;
|
2446 |
-
|
2447 |
-
/* format setting outer wrapper */
|
2448 |
-
echo '<div class="format-setting type-spacing ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2449 |
-
|
2450 |
-
/* description */
|
2451 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
2452 |
|
2453 |
-
|
2454 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2455 |
|
2456 |
-
|
2457 |
-
|
2458 |
-
'top',
|
2459 |
-
'right',
|
2460 |
-
'bottom',
|
2461 |
-
'left',
|
2462 |
-
'unit'
|
2463 |
-
), $field_id );
|
2464 |
|
2465 |
-
|
2466 |
-
|
2467 |
|
2468 |
-
|
|
|
2469 |
|
2470 |
-
|
|
|
2471 |
|
2472 |
-
|
|
|
2473 |
|
2474 |
-
|
2475 |
-
if ( in_array( 'right', $ot_recognized_spacing_fields ) ) {
|
2476 |
|
2477 |
-
|
2478 |
|
2479 |
-
|
2480 |
|
2481 |
-
|
|
|
2482 |
|
2483 |
-
|
2484 |
-
if ( in_array( 'bottom', $ot_recognized_spacing_fields ) ) {
|
2485 |
|
2486 |
-
|
|
|
|
|
2487 |
|
2488 |
-
|
2489 |
|
2490 |
-
|
2491 |
|
2492 |
-
|
2493 |
-
|
|
|
2494 |
|
2495 |
-
|
2496 |
|
2497 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2498 |
|
2499 |
-
|
|
|
2500 |
|
2501 |
-
|
2502 |
-
|
2503 |
|
2504 |
-
|
|
|
|
|
|
|
2505 |
|
2506 |
-
|
|
|
2507 |
|
2508 |
-
|
|
|
2509 |
|
2510 |
-
|
2511 |
-
|
2512 |
-
}
|
2513 |
|
2514 |
-
|
2515 |
|
2516 |
-
|
2517 |
|
2518 |
-
|
2519 |
|
2520 |
-
|
2521 |
|
2522 |
-
|
2523 |
|
2524 |
-
|
2525 |
|
|
|
|
|
2526 |
}
|
2527 |
|
2528 |
-
|
2529 |
-
* Tab option type.
|
2530 |
-
*
|
2531 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2532 |
-
*
|
2533 |
-
* @param array An array of arguments.
|
2534 |
-
* @return string
|
2535 |
-
*
|
2536 |
-
* @access public
|
2537 |
-
* @since 2.3.0
|
2538 |
-
*/
|
2539 |
-
if ( ! function_exists( 'ot_type_tab' ) ) {
|
2540 |
-
|
2541 |
-
function ot_type_tab( $args = array() ) {
|
2542 |
|
2543 |
-
|
2544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2545 |
|
2546 |
-
|
2547 |
-
echo '<div class="format-setting type-tab">';
|
2548 |
|
2549 |
-
|
2550 |
|
2551 |
-
|
2552 |
|
2553 |
-
|
2554 |
|
|
|
2555 |
}
|
2556 |
|
2557 |
-
|
2558 |
-
* Tag Checkbox option type.
|
2559 |
-
*
|
2560 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2561 |
-
*
|
2562 |
-
* @param array An array of arguments.
|
2563 |
-
* @return string
|
2564 |
-
*
|
2565 |
-
* @access public
|
2566 |
-
* @since 2.0
|
2567 |
-
*/
|
2568 |
-
if ( ! function_exists( 'ot_type_tag_checkbox' ) ) {
|
2569 |
-
|
2570 |
-
function ot_type_tag_checkbox( $args = array() ) {
|
2571 |
-
|
2572 |
-
/* turns arguments array into variables */
|
2573 |
-
extract( $args );
|
2574 |
-
|
2575 |
-
/* verify a description */
|
2576 |
-
$has_desc = $field_desc ? true : false;
|
2577 |
-
|
2578 |
-
/* format setting outer wrapper */
|
2579 |
-
echo '<div class="format-setting type-tag-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2580 |
-
|
2581 |
-
/* description */
|
2582 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
2583 |
-
|
2584 |
-
/* format setting inner wrapper */
|
2585 |
-
echo '<div class="format-setting-inner">';
|
2586 |
-
|
2587 |
-
/* get tags */
|
2588 |
-
$tags = get_tags( array( 'hide_empty' => false ) );
|
2589 |
-
|
2590 |
-
/* has tags */
|
2591 |
-
if ( $tags ) {
|
2592 |
-
foreach( $tags as $tag ) {
|
2593 |
-
echo '<p>';
|
2594 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $tag->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $tag->term_id ) . '" value="' . esc_attr( $tag->term_id ) . '" ' . ( isset( $field_value[$tag->term_id] ) ? checked( $field_value[$tag->term_id], $tag->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
2595 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $tag->term_id ) . '">' . esc_attr( $tag->name ) . '</label>';
|
2596 |
-
echo '</p>';
|
2597 |
-
}
|
2598 |
-
} else {
|
2599 |
-
echo '<p>' . __( 'No Tags Found', 'option-tree' ) . '</p>';
|
2600 |
-
}
|
2601 |
-
|
2602 |
-
echo '</div>';
|
2603 |
|
2604 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2605 |
|
2606 |
-
|
2607 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2608 |
}
|
2609 |
|
2610 |
-
|
2611 |
-
* Tag Select option type.
|
2612 |
-
*
|
2613 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2614 |
-
*
|
2615 |
-
* @param array An array of arguments.
|
2616 |
-
* @return string
|
2617 |
-
*
|
2618 |
-
* @access public
|
2619 |
-
* @since 2.0
|
2620 |
-
*/
|
2621 |
-
if ( ! function_exists( 'ot_type_tag_select' ) ) {
|
2622 |
-
|
2623 |
-
function ot_type_tag_select( $args = array() ) {
|
2624 |
|
2625 |
-
|
2626 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2627 |
|
2628 |
-
|
2629 |
-
$has_desc = $field_desc ? true : false;
|
2630 |
|
2631 |
-
|
2632 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2633 |
|
2634 |
-
|
2635 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
2636 |
|
2637 |
-
|
2638 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2639 |
|
2640 |
-
|
2641 |
-
|
2642 |
|
2643 |
-
|
2644 |
-
|
2645 |
|
2646 |
-
|
2647 |
-
|
2648 |
-
echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
|
2649 |
-
foreach( $tags as $tag ) {
|
2650 |
-
echo '<option value="' . esc_attr( $tag->term_id ) . '"' . selected( $field_value, $tag->term_id, false ) . '>' . esc_attr( $tag->name ) . '</option>';
|
2651 |
-
}
|
2652 |
-
} else {
|
2653 |
-
echo '<option value="">' . __( 'No Tags Found', 'option-tree' ) . '</option>';
|
2654 |
-
}
|
2655 |
|
2656 |
-
|
|
|
2657 |
|
2658 |
-
|
|
|
2659 |
|
2660 |
-
|
|
|
|
|
|
|
2661 |
|
2662 |
-
|
2663 |
|
|
|
|
|
2664 |
}
|
2665 |
|
2666 |
-
|
2667 |
-
* Taxonomy Checkbox option type.
|
2668 |
-
*
|
2669 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2670 |
-
*
|
2671 |
-
* @param array An array of arguments.
|
2672 |
-
* @return string
|
2673 |
-
*
|
2674 |
-
* @access public
|
2675 |
-
* @since 2.0
|
2676 |
-
*/
|
2677 |
-
if ( ! function_exists( 'ot_type_taxonomy_checkbox' ) ) {
|
2678 |
|
2679 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2680 |
|
2681 |
-
|
2682 |
-
extract( $args );
|
2683 |
|
2684 |
-
|
2685 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2686 |
|
2687 |
-
|
2688 |
-
|
2689 |
|
2690 |
-
|
2691 |
-
|
2692 |
|
2693 |
-
|
2694 |
-
|
2695 |
|
2696 |
-
|
2697 |
-
|
2698 |
|
2699 |
-
|
2700 |
-
|
2701 |
|
2702 |
-
|
2703 |
-
|
2704 |
-
foreach( $taxonomies as $taxonomy ) {
|
2705 |
-
echo '<p>';
|
2706 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $taxonomy->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $taxonomy->term_id ) . '" value="' . esc_attr( $taxonomy->term_id ) . '" ' . ( isset( $field_value[$taxonomy->term_id] ) ? checked( $field_value[$taxonomy->term_id], $taxonomy->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
2707 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $taxonomy->term_id ) . '">' . esc_attr( $taxonomy->name ) . '</label>';
|
2708 |
-
echo '</p>';
|
2709 |
-
}
|
2710 |
-
} else {
|
2711 |
-
echo '<p>' . __( 'No Taxonomies Found', 'option-tree' ) . '</p>';
|
2712 |
-
}
|
2713 |
|
2714 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2715 |
|
2716 |
-
|
2717 |
|
2718 |
-
|
2719 |
|
|
|
|
|
2720 |
}
|
2721 |
|
2722 |
-
|
2723 |
-
* Taxonomy Select option type.
|
2724 |
-
*
|
2725 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2726 |
-
*
|
2727 |
-
* @param array An array of arguments.
|
2728 |
-
* @return string
|
2729 |
-
*
|
2730 |
-
* @access public
|
2731 |
-
* @since 2.0
|
2732 |
-
*/
|
2733 |
-
if ( ! function_exists( 'ot_type_taxonomy_select' ) ) {
|
2734 |
-
|
2735 |
-
function ot_type_taxonomy_select( $args = array() ) {
|
2736 |
|
2737 |
-
|
2738 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2739 |
|
2740 |
-
|
2741 |
-
$has_desc = $field_desc ? true : false;
|
2742 |
|
2743 |
-
|
2744 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2745 |
|
2746 |
-
|
2747 |
-
|
2748 |
|
2749 |
-
|
2750 |
-
|
2751 |
|
2752 |
-
|
2753 |
-
|
2754 |
|
2755 |
-
|
2756 |
-
|
2757 |
|
2758 |
-
|
2759 |
-
|
2760 |
|
2761 |
-
|
2762 |
-
|
2763 |
-
echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
|
2764 |
-
foreach( $taxonomies as $taxonomy ) {
|
2765 |
-
echo '<option value="' . esc_attr( $taxonomy->term_id ) . '"' . selected( $field_value, $taxonomy->term_id, false ) . '>' . esc_attr( $taxonomy->name ) . '</option>';
|
2766 |
-
}
|
2767 |
-
} else {
|
2768 |
-
echo '<option value="">' . __( 'No Taxonomies Found', 'option-tree' ) . '</option>';
|
2769 |
-
}
|
2770 |
|
2771 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2772 |
|
2773 |
-
|
|
|
2774 |
|
2775 |
-
|
2776 |
|
2777 |
-
|
2778 |
|
2779 |
-
|
|
|
|
|
|
|
|
|
2780 |
|
2781 |
-
|
2782 |
-
* Text option type.
|
2783 |
-
*
|
2784 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2785 |
-
*
|
2786 |
-
* @param array An array of arguments.
|
2787 |
-
* @return string
|
2788 |
-
*
|
2789 |
-
* @access public
|
2790 |
-
* @since 2.0
|
2791 |
-
*/
|
2792 |
-
if ( ! function_exists( 'ot_type_text' ) ) {
|
2793 |
|
2794 |
-
|
|
|
2795 |
|
2796 |
-
|
2797 |
-
|
2798 |
|
2799 |
-
|
2800 |
-
$has_desc = $field_desc ? true : false;
|
2801 |
|
2802 |
-
|
2803 |
-
|
|
|
2804 |
|
2805 |
-
|
2806 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
2807 |
|
2808 |
-
|
2809 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2810 |
|
2811 |
-
|
2812 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" />';
|
2813 |
|
2814 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2815 |
|
2816 |
-
|
|
|
2817 |
|
2818 |
-
|
|
|
2819 |
|
2820 |
-
|
|
|
2821 |
|
2822 |
-
|
2823 |
-
|
2824 |
-
*
|
2825 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2826 |
-
*
|
2827 |
-
* @param array An array of arguments.
|
2828 |
-
* @return string
|
2829 |
-
*
|
2830 |
-
* @access public
|
2831 |
-
* @since 2.0
|
2832 |
-
*/
|
2833 |
-
if ( ! function_exists( 'ot_type_textarea' ) ) {
|
2834 |
|
2835 |
-
|
|
|
2836 |
|
2837 |
-
|
2838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2839 |
|
2840 |
-
|
2841 |
-
|
2842 |
|
2843 |
-
|
2844 |
-
echo '<div class="format-setting type-textarea ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . ' fill-area">';
|
2845 |
|
2846 |
-
|
2847 |
-
|
2848 |
|
2849 |
-
|
2850 |
-
|
2851 |
|
2852 |
-
|
2853 |
-
wp_editor(
|
2854 |
-
$field_value,
|
2855 |
-
esc_attr( $field_id ),
|
2856 |
-
array(
|
2857 |
-
'editor_class' => esc_attr( $field_class ),
|
2858 |
-
'wpautop' => apply_filters( 'ot_wpautop', false, $field_id ),
|
2859 |
-
'media_buttons' => apply_filters( 'ot_media_buttons', true, $field_id ),
|
2860 |
-
'textarea_name' => esc_attr( $field_name ),
|
2861 |
-
'textarea_rows' => esc_attr( $field_rows ),
|
2862 |
-
'tinymce' => apply_filters( 'ot_tinymce', true, $field_id ),
|
2863 |
-
'quicktags' => apply_filters( 'ot_quicktags', array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ), $field_id )
|
2864 |
-
)
|
2865 |
-
);
|
2866 |
|
2867 |
-
|
|
|
2868 |
|
2869 |
-
|
|
|
2870 |
|
2871 |
-
|
2872 |
|
2873 |
-
|
|
|
2874 |
|
2875 |
-
|
2876 |
-
|
2877 |
-
*
|
2878 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2879 |
-
*
|
2880 |
-
* @param array An array of arguments.
|
2881 |
-
* @return string
|
2882 |
-
*
|
2883 |
-
* @access public
|
2884 |
-
* @since 2.0
|
2885 |
-
*/
|
2886 |
-
if ( ! function_exists( 'ot_type_textarea_simple' ) ) {
|
2887 |
|
2888 |
-
|
2889 |
|
2890 |
-
|
2891 |
-
|
2892 |
|
2893 |
-
|
2894 |
-
|
2895 |
|
2896 |
-
|
2897 |
-
echo '<div class="format-setting type-textarea simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2898 |
|
2899 |
-
|
2900 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
2901 |
|
2902 |
-
|
2903 |
-
echo '<div class="format-setting-inner">';
|
2904 |
|
2905 |
-
|
2906 |
-
|
|
|
2907 |
|
2908 |
-
|
2909 |
-
if ( $wpautop == true )
|
2910 |
-
$field_value = wpautop( $field_value );
|
2911 |
|
2912 |
-
|
2913 |
-
|
2914 |
|
2915 |
-
|
2916 |
|
2917 |
-
|
|
|
|
|
2918 |
|
2919 |
-
|
2920 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2921 |
}
|
2922 |
|
2923 |
-
|
2924 |
-
* Textblock option type.
|
2925 |
-
*
|
2926 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2927 |
-
*
|
2928 |
-
* @param array An array of arguments.
|
2929 |
-
* @return string
|
2930 |
-
*
|
2931 |
-
* @access public
|
2932 |
-
* @since 2.0
|
2933 |
-
*/
|
2934 |
-
if ( ! function_exists( 'ot_type_textblock' ) ) {
|
2935 |
|
2936 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2937 |
|
2938 |
-
|
2939 |
-
extract( $args );
|
2940 |
|
2941 |
-
|
2942 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2943 |
|
2944 |
-
|
2945 |
-
|
2946 |
|
2947 |
-
|
|
|
2948 |
|
2949 |
-
|
|
|
2950 |
|
2951 |
-
|
|
|
2952 |
|
2953 |
-
|
2954 |
-
|
2955 |
-
*
|
2956 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2957 |
-
*
|
2958 |
-
* @param array An array of arguments.
|
2959 |
-
* @return string
|
2960 |
-
*
|
2961 |
-
* @access public
|
2962 |
-
* @since 2.0
|
2963 |
-
*/
|
2964 |
-
if ( ! function_exists( 'ot_type_textblock_titled' ) ) {
|
2965 |
|
2966 |
-
|
|
|
2967 |
|
2968 |
-
|
2969 |
-
|
2970 |
|
2971 |
-
|
2972 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2973 |
|
2974 |
-
|
2975 |
-
echo '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>';
|
2976 |
|
2977 |
-
|
2978 |
|
2979 |
-
|
|
|
|
|
|
|
|
|
2980 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2981 |
}
|
2982 |
|
2983 |
-
|
2984 |
-
* Typography option type.
|
2985 |
-
*
|
2986 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2987 |
-
*
|
2988 |
-
* @param array An array of arguments.
|
2989 |
-
* @return string
|
2990 |
-
*
|
2991 |
-
* @access public
|
2992 |
-
* @since 2.0
|
2993 |
-
*/
|
2994 |
-
if ( ! function_exists( 'ot_type_typography' ) ) {
|
2995 |
|
2996 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2997 |
|
2998 |
-
|
2999 |
-
extract( $args );
|
3000 |
|
3001 |
-
|
3002 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3003 |
|
3004 |
-
|
3005 |
-
|
3006 |
|
3007 |
-
|
3008 |
-
|
3009 |
|
3010 |
-
|
3011 |
-
|
3012 |
|
3013 |
-
|
3014 |
-
|
3015 |
-
'font-color',
|
3016 |
-
'font-family',
|
3017 |
-
'font-size',
|
3018 |
-
'font-style',
|
3019 |
-
'font-variant',
|
3020 |
-
'font-weight',
|
3021 |
-
'letter-spacing',
|
3022 |
-
'line-height',
|
3023 |
-
'text-decoration',
|
3024 |
-
'text-transform'
|
3025 |
-
), $field_id );
|
3026 |
|
3027 |
-
|
3028 |
-
|
3029 |
|
3030 |
-
|
3031 |
-
|
3032 |
|
3033 |
-
|
3034 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
3035 |
|
3036 |
-
|
3037 |
-
|
|
|
3038 |
|
3039 |
-
|
3040 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '[font-color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $background_color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
3041 |
|
3042 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3043 |
|
3044 |
-
|
3045 |
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
|
|
3056 |
|
3057 |
-
|
3058 |
-
|
3059 |
-
$font_size = isset( $field_value['font-size'] ) ? esc_attr( $field_value['font-size'] ) : '';
|
3060 |
-
echo '<select name="' . esc_attr( $field_name ) . '[font-size]" id="' . esc_attr( $field_id ) . '-font-size" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3061 |
-
echo '<option value="">font-size</option>';
|
3062 |
-
foreach( ot_recognized_font_sizes( $field_id ) as $option ) {
|
3063 |
-
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $font_size, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3064 |
-
}
|
3065 |
-
echo '</select>';
|
3066 |
-
}
|
3067 |
|
3068 |
-
|
3069 |
-
|
3070 |
-
$font_style = isset( $field_value['font-style'] ) ? esc_attr( $field_value['font-style'] ) : '';
|
3071 |
-
echo '<select name="' . esc_attr( $field_name ) . '[font-style]" id="' . esc_attr( $field_id ) . '-font-style" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3072 |
-
echo '<option value="">font-style</option>';
|
3073 |
-
foreach ( ot_recognized_font_styles( $field_id ) as $key => $value ) {
|
3074 |
-
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_style, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3075 |
-
}
|
3076 |
-
echo '</select>';
|
3077 |
-
}
|
3078 |
|
3079 |
-
|
3080 |
-
|
3081 |
-
$font_variant = isset( $field_value['font-variant'] ) ? esc_attr( $field_value['font-variant'] ) : '';
|
3082 |
-
echo '<select name="' . esc_attr( $field_name ) . '[font-variant]" id="' . esc_attr( $field_id ) . '-font-variant" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3083 |
-
echo '<option value="">font-variant</option>';
|
3084 |
-
foreach ( ot_recognized_font_variants( $field_id ) as $key => $value ) {
|
3085 |
-
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_variant, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3086 |
-
}
|
3087 |
-
echo '</select>';
|
3088 |
-
}
|
3089 |
|
3090 |
-
|
3091 |
-
|
3092 |
-
$font_weight = isset( $field_value['font-weight'] ) ? esc_attr( $field_value['font-weight'] ) : '';
|
3093 |
-
echo '<select name="' . esc_attr( $field_name ) . '[font-weight]" id="' . esc_attr( $field_id ) . '-font-weight" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3094 |
-
echo '<option value="">font-weight</option>';
|
3095 |
-
foreach ( ot_recognized_font_weights( $field_id ) as $key => $value ) {
|
3096 |
-
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_weight, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3097 |
-
}
|
3098 |
-
echo '</select>';
|
3099 |
-
}
|
3100 |
|
3101 |
-
|
3102 |
-
|
3103 |
-
$letter_spacing = isset( $field_value['letter-spacing'] ) ? esc_attr( $field_value['letter-spacing'] ) : '';
|
3104 |
-
echo '<select name="' . esc_attr( $field_name ) . '[letter-spacing]" id="' . esc_attr( $field_id ) . '-letter-spacing" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3105 |
-
echo '<option value="">letter-spacing</option>';
|
3106 |
-
foreach( ot_recognized_letter_spacing( $field_id ) as $option ) {
|
3107 |
-
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $letter_spacing, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3108 |
-
}
|
3109 |
-
echo '</select>';
|
3110 |
-
}
|
3111 |
|
3112 |
-
|
3113 |
-
|
3114 |
-
$line_height = isset( $field_value['line-height'] ) ? esc_attr( $field_value['line-height'] ) : '';
|
3115 |
-
echo '<select name="' . esc_attr( $field_name ) . '[line-height]" id="' . esc_attr( $field_id ) . '-line-height" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3116 |
-
echo '<option value="">line-height</option>';
|
3117 |
-
foreach( ot_recognized_line_heights( $field_id ) as $option ) {
|
3118 |
-
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $line_height, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3119 |
-
}
|
3120 |
-
echo '</select>';
|
3121 |
-
}
|
3122 |
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
echo '<option value="">text-decoration</option>';
|
3128 |
-
foreach ( ot_recognized_text_decorations( $field_id ) as $key => $value ) {
|
3129 |
-
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $text_decoration, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3130 |
-
}
|
3131 |
-
echo '</select>';
|
3132 |
-
}
|
3133 |
|
3134 |
-
|
3135 |
-
|
3136 |
-
$text_transform = isset( $field_value['text-transform'] ) ? esc_attr( $field_value['text-transform'] ) : '';
|
3137 |
-
echo '<select name="' . esc_attr( $field_name ) . '[text-transform]" id="' . esc_attr( $field_id ) . '-text-transform" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3138 |
-
echo '<option value="">text-transform</option>';
|
3139 |
-
foreach ( ot_recognized_text_transformations( $field_id ) as $key => $value ) {
|
3140 |
-
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $text_transform, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3141 |
-
}
|
3142 |
-
echo '</select>';
|
3143 |
-
}
|
3144 |
|
3145 |
-
|
3146 |
|
3147 |
-
|
|
|
|
|
3148 |
|
3149 |
-
|
3150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3151 |
}
|
3152 |
|
3153 |
-
|
3154 |
-
* Upload option type.
|
3155 |
-
*
|
3156 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
3157 |
-
*
|
3158 |
-
* @param array An array of arguments.
|
3159 |
-
* @return string
|
3160 |
-
*
|
3161 |
-
* @access public
|
3162 |
-
* @since 2.0
|
3163 |
-
*/
|
3164 |
-
if ( ! function_exists( 'ot_type_upload' ) ) {
|
3165 |
|
3166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3167 |
|
3168 |
-
|
3169 |
-
extract( $args );
|
3170 |
|
3171 |
-
|
3172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3173 |
|
3174 |
-
|
3175 |
-
if ( $field_value && wp_attachment_is_image( $field_value ) ) {
|
3176 |
|
3177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3178 |
|
3179 |
-
|
3180 |
-
|
3181 |
|
3182 |
-
|
|
|
3183 |
|
3184 |
-
|
|
|
3185 |
|
3186 |
-
|
3187 |
|
3188 |
-
|
3189 |
-
|
3190 |
|
3191 |
-
|
3192 |
-
|
|
|
3193 |
|
3194 |
-
|
3195 |
-
|
3196 |
|
3197 |
-
|
3198 |
-
|
3199 |
|
3200 |
-
|
3201 |
-
|
3202 |
|
3203 |
-
|
3204 |
-
|
3205 |
|
3206 |
-
|
3207 |
|
3208 |
-
|
3209 |
-
|
3210 |
|
3211 |
-
|
3212 |
|
3213 |
-
|
3214 |
-
|
3215 |
-
$field_value = $field_src;
|
3216 |
|
3217 |
-
|
3218 |
-
echo '<div class="option-tree-ui-image-wrap"><img src="' . esc_url( $field_value ) . '" alt="" /></div>';
|
3219 |
|
3220 |
-
|
|
|
|
|
|
|
3221 |
|
3222 |
-
|
|
|
|
|
3223 |
|
3224 |
-
|
3225 |
|
3226 |
-
|
3227 |
|
3228 |
-
|
3229 |
|
3230 |
-
|
3231 |
|
|
|
|
|
3232 |
}
|
3233 |
|
3234 |
|
@@ -3289,8 +3225,3 @@ if ( ! function_exists( 'ot_type_weforms' ) ) {
|
|
3289 |
}
|
3290 |
|
3291 |
}
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
/* End of file ot-functions-option-types.php */
|
3296 |
-
/* Location: ./includes/ot-functions-option-types.php */
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Option Type Functions.
|
4 |
+
*
|
5 |
* Functions used to build each option type.
|
6 |
*
|
7 |
+
* @package OptionTree
|
|
|
|
|
|
|
8 |
*/
|
9 |
|
10 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
11 |
+
exit( 'No direct script access allowed' );
|
12 |
+
}
|
13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
if ( ! function_exists( 'ot_display_by_type' ) ) {
|
15 |
|
16 |
+
/**
|
17 |
+
* Builds the HTML for each of the available option types by calling those
|
18 |
+
* function with call_user_func and passing the arguments to the second param.
|
19 |
+
*
|
20 |
+
* All fields are required!
|
21 |
+
*
|
22 |
+
* @param array $args The array of arguments are as follows.
|
23 |
+
* @var string $type Type of option.
|
24 |
+
* @var string $field_id The field ID.
|
25 |
+
* @var string $field_name The field Name.
|
26 |
+
* @var mixed $field_value The field value is a string or an array of values.
|
27 |
+
* @var string $field_desc The field description.
|
28 |
+
* @var string $field_std The standard value.
|
29 |
+
* @var string $field_class Extra CSS classes.
|
30 |
+
* @var array $field_choices The array of option choices.
|
31 |
+
* @var array $field_settings The array of settings for a list item.
|
32 |
+
*
|
33 |
+
* @access public
|
34 |
+
* @since 2.0
|
35 |
+
*/
|
36 |
+
function ot_display_by_type( $args = array() ) {
|
37 |
+
|
38 |
+
// Allow filters to be executed on the array.
|
39 |
+
$args = apply_filters( 'ot_display_by_type', $args );
|
40 |
+
|
41 |
+
if ( empty( $args['type'] ) ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
// Build the function name.
|
46 |
+
$function_name_by_type = str_replace( '-', '_', 'ot_type_' . $args['type'] );
|
47 |
+
|
48 |
+
// Call the function & pass in arguments array.
|
49 |
+
if ( function_exists( $function_name_by_type ) ) {
|
50 |
+
call_user_func( $function_name_by_type, $args );
|
51 |
+
} else {
|
52 |
+
echo '<p>' . esc_html__( 'Sorry, this function does not exist', 'option-tree' ) . '</p>';
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
}
|
57 |
|
58 |
+
if ( ! function_exists( 'ot_type_background' ) ) {
|
|
|
59 |
|
60 |
+
/**
|
61 |
+
* Background option type.
|
62 |
+
*
|
63 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
64 |
+
*
|
65 |
+
* @param array $args An array of arguments.
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @since 2.0
|
69 |
+
*/
|
70 |
+
function ot_type_background( $args = array() ) {
|
71 |
|
72 |
+
// Turns arguments array into variables.
|
73 |
+
extract( $args ); // phpcs:ignore
|
74 |
|
75 |
+
// Verify a description.
|
76 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
77 |
|
78 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
79 |
+
if ( isset( $field_value['background-image'] ) && wp_attachment_is_image( $field_value['background-image'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
+
$attachment_data = wp_get_attachment_image_src( $field_value['background-image'], 'original' );
|
82 |
|
83 |
+
/* check for attachment data */
|
84 |
+
if ( $attachment_data ) {
|
85 |
|
86 |
+
$field_src = $attachment_data[0];
|
|
|
87 |
|
88 |
+
}
|
89 |
+
}
|
90 |
|
91 |
+
// Format setting outer wrapper.
|
92 |
+
echo '<div class="format-setting type-background ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
93 |
|
94 |
+
// Description.
|
95 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
96 |
|
97 |
+
// Format setting inner wrapper.
|
98 |
+
echo '<div class="format-setting-inner">';
|
99 |
|
100 |
+
// Allow fields to be filtered.
|
101 |
+
$ot_recognized_background_fields = apply_filters(
|
102 |
+
'ot_recognized_background_fields',
|
103 |
+
array(
|
104 |
+
'background-color',
|
105 |
+
'background-repeat',
|
106 |
+
'background-attachment',
|
107 |
+
'background-position',
|
108 |
+
'background-size',
|
109 |
+
'background-image',
|
110 |
+
),
|
111 |
+
$field_id
|
112 |
+
);
|
113 |
|
114 |
+
echo '<div class="ot-background-group">';
|
115 |
|
116 |
+
// Build background color.
|
117 |
+
if ( in_array( 'background-color', $ot_recognized_background_fields, true ) ) {
|
118 |
|
119 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
|
|
120 |
|
121 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
|
|
122 |
|
123 |
+
$background_color = isset( $field_value['background-color'] ) ? $field_value['background-color'] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[background-color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $background_color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
126 |
|
127 |
+
echo '</div>';
|
128 |
+
}
|
129 |
|
130 |
+
// Build background repeat.
|
131 |
+
if ( in_array( 'background-repeat', $ot_recognized_background_fields, true ) ) {
|
132 |
|
133 |
+
$background_repeat = isset( $field_value['background-repeat'] ) ? esc_attr( $field_value['background-repeat'] ) : '';
|
|
|
134 |
|
135 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-repeat]" id="' . esc_attr( $field_id ) . '-repeat" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
|
|
136 |
|
137 |
+
echo '<option value="">' . esc_html__( 'background-repeat', 'option-tree' ) . '</option>';
|
138 |
+
foreach ( ot_recognized_background_repeat( $field_id ) as $key => $value ) {
|
139 |
|
140 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $background_repeat, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
141 |
+
}
|
142 |
|
143 |
+
echo '</select>';
|
144 |
+
}
|
145 |
|
146 |
+
// Build background attachment.
|
147 |
+
if ( in_array( 'background-attachment', $ot_recognized_background_fields, true ) ) {
|
148 |
|
149 |
+
$background_attachment = isset( $field_value['background-attachment'] ) ? $field_value['background-attachment'] : '';
|
150 |
|
151 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-attachment]" id="' . esc_attr( $field_id ) . '-attachment" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
152 |
|
153 |
+
echo '<option value="">' . esc_html__( 'background-attachment', 'option-tree' ) . '</option>';
|
|
|
154 |
|
155 |
+
foreach ( ot_recognized_background_attachment( $field_id ) as $key => $value ) {
|
156 |
|
157 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $background_attachment, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
158 |
+
}
|
159 |
|
160 |
+
echo '</select>';
|
161 |
+
}
|
162 |
|
163 |
+
// Build background position.
|
164 |
+
if ( in_array( 'background-position', $ot_recognized_background_fields, true ) ) {
|
165 |
|
166 |
+
$background_position = isset( $field_value['background-position'] ) ? $field_value['background-position'] : '';
|
|
|
167 |
|
168 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-position]" id="' . esc_attr( $field_id ) . '-position" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
169 |
|
170 |
+
echo '<option value="">' . esc_html__( 'background-position', 'option-tree' ) . '</option>';
|
171 |
|
172 |
+
foreach ( ot_recognized_background_position( $field_id ) as $key => $value ) {
|
173 |
|
174 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $background_position, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
175 |
+
}
|
176 |
|
177 |
+
echo '</select>';
|
178 |
+
}
|
179 |
|
180 |
+
// Build background size .
|
181 |
+
if ( in_array( 'background-size', $ot_recognized_background_fields, true ) ) {
|
182 |
|
183 |
+
/**
|
184 |
+
* Use this filter to create a select instead of an text input.
|
185 |
+
* Be sure to return the array in the correct format. Add an empty
|
186 |
+
* value to the first choice so the user can leave it blank.
|
187 |
+
*
|
188 |
+
* Example: array(
|
189 |
+
* array(
|
190 |
+
* 'label' => 'background-size',
|
191 |
+
* 'value' => ''
|
192 |
+
* ),
|
193 |
+
* array(
|
194 |
+
* 'label' => 'cover',
|
195 |
+
* 'value' => 'cover'
|
196 |
+
* ),
|
197 |
+
* array(
|
198 |
+
* 'label' => 'contain',
|
199 |
+
* 'value' => 'contain'
|
200 |
+
* )
|
201 |
+
* )
|
202 |
+
*/
|
203 |
+
$choices = apply_filters( 'ot_type_background_size_choices', '', $field_id );
|
204 |
|
205 |
+
if ( is_array( $choices ) && ! empty( $choices ) ) {
|
206 |
|
207 |
+
// Build select.
|
208 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-size]" id="' . esc_attr( $field_id ) . '-size" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
209 |
|
210 |
+
foreach ( (array) $choices as $choice ) {
|
211 |
+
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
212 |
+
echo '<option value="' . esc_attr( $choice['value'] ) . '" ' . selected( ( isset( $field_value['background-size'] ) ? $field_value['background-size'] : '' ), $choice['value'], false ) . '>' . esc_attr( $choice['label'] ) . '</option>';
|
213 |
+
}
|
214 |
+
}
|
215 |
|
216 |
+
echo '</select>';
|
217 |
+
} else {
|
218 |
|
219 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[background-size]" id="' . esc_attr( $field_id ) . '-size" value="' . esc_attr( isset( $field_value['background-size'] ) ? $field_value['background-size'] : '' ) . '" class="widefat ot-background-size-input option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'background-size', 'option-tree' ) . '" />';
|
220 |
+
}
|
221 |
+
}
|
222 |
|
223 |
+
echo '</div>';
|
224 |
|
225 |
+
// Build background image.
|
226 |
+
if ( in_array( 'background-image', $ot_recognized_background_fields, true ) ) {
|
227 |
|
228 |
+
echo '<div class="option-tree-ui-upload-parent">';
|
229 |
|
230 |
+
// Input.
|
231 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[background-image]" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( isset( $field_value['background-image'] ) ? $field_value['background-image'] : '' ) . '" class="widefat option-tree-ui-upload-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'background-image', 'option-tree' ) . '" />';
|
232 |
|
233 |
+
// Add media button.
|
234 |
+
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . esc_attr( $post_id ) . '" title="' . esc_html__( 'Add Media', 'option-tree' ) . '"><span class="icon ot-icon-plus-circle"></span>' . esc_html__( 'Add Media', 'option-tree' ) . '</a>';
|
235 |
|
236 |
+
echo '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
|
238 |
+
// Media.
|
239 |
+
if ( isset( $field_value['background-image'] ) && '' !== $field_value['background-image'] ) {
|
240 |
|
241 |
+
/* replace image src */
|
242 |
+
if ( isset( $field_src ) ) {
|
243 |
+
$field_value['background-image'] = $field_src;
|
244 |
+
}
|
245 |
|
246 |
+
echo '<div class="option-tree-ui-media-wrap" id="' . esc_attr( $field_id ) . '_media">';
|
247 |
|
248 |
+
if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value['background-image'] ) ) {
|
249 |
+
echo '<div class="option-tree-ui-image-wrap"><img src="' . esc_url_raw( $field_value['background-image'] ) . '" alt="" /></div>';
|
250 |
+
}
|
251 |
|
252 |
+
echo '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Media', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"></span>' . esc_html__( 'Remove Media', 'option-tree' ) . '</a>';
|
253 |
|
254 |
+
echo '</div>';
|
255 |
+
}
|
256 |
+
}
|
257 |
|
258 |
+
echo '</div>';
|
|
|
259 |
|
260 |
+
echo '</div>';
|
261 |
+
}
|
262 |
+
}
|
263 |
|
264 |
+
if ( ! function_exists( 'ot_type_border' ) ) {
|
|
|
265 |
|
266 |
+
/**
|
267 |
+
* Border Option Type
|
268 |
+
*
|
269 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
270 |
+
*
|
271 |
+
* @param array $args The options arguments.
|
272 |
+
*
|
273 |
+
* @access public
|
274 |
+
* @since 2.5.0
|
275 |
+
*/
|
276 |
+
function ot_type_border( $args = array() ) {
|
277 |
|
278 |
+
// Turns arguments array into variables.
|
279 |
+
extract( $args ); // phpcs:ignore
|
280 |
|
281 |
+
// Verify a description.
|
282 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
283 |
|
284 |
+
// Format setting outer wrapper.
|
285 |
+
echo '<div class="format-setting type-border ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
286 |
|
287 |
+
// Description.
|
288 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
289 |
|
290 |
+
// Format setting inner wrapper.
|
291 |
+
echo '<div class="format-setting-inner">';
|
292 |
|
293 |
+
// Allow fields to be filtered.
|
294 |
+
$ot_recognized_border_fields = apply_filters(
|
295 |
+
'ot_recognized_border_fields',
|
296 |
+
array(
|
297 |
+
'width',
|
298 |
+
'unit',
|
299 |
+
'style',
|
300 |
+
'color',
|
301 |
+
),
|
302 |
+
$field_id
|
303 |
+
);
|
304 |
|
305 |
+
// Build border width.
|
306 |
+
if ( in_array( 'width', $ot_recognized_border_fields, true ) ) {
|
307 |
|
308 |
+
$width = isset( $field_value['width'] ) ? $field_value['width'] : '';
|
309 |
|
310 |
+
echo '<div class="ot-option-group ot-option-group--one-sixth"><input type="text" name="' . esc_attr( $field_name ) . '[width]" id="' . esc_attr( $field_id ) . '-width" value="' . esc_attr( $width ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'width', 'option-tree' ) . '" /></div>';
|
311 |
+
}
|
312 |
|
313 |
+
// Build unit dropdown.
|
314 |
+
if ( in_array( 'unit', $ot_recognized_border_fields, true ) ) {
|
315 |
|
316 |
+
echo '<div class="ot-option-group ot-option-group--one-fourth">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
+
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
319 |
|
320 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
|
|
321 |
|
322 |
+
foreach ( ot_recognized_border_unit_types( $field_id ) as $unit ) {
|
323 |
+
echo '<option value="' . esc_attr( $unit ) . '" ' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
324 |
+
}
|
325 |
|
326 |
+
echo '</select>';
|
|
|
327 |
|
328 |
+
echo '</div>';
|
329 |
+
}
|
330 |
|
331 |
+
// Build style dropdown.
|
332 |
+
if ( in_array( 'style', $ot_recognized_border_fields, true ) ) {
|
333 |
|
334 |
+
echo '<div class="ot-option-group ot-option-group--one-fourth">';
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
+
echo '<select name="' . esc_attr( $field_name ) . '[style]" id="' . esc_attr( $field_id ) . '-style" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
|
|
337 |
|
338 |
+
echo '<option value="">' . esc_html__( 'style', 'option-tree' ) . '</option>';
|
339 |
|
340 |
+
foreach ( ot_recognized_border_style_types( $field_id ) as $key => $style ) {
|
341 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . ( isset( $field_value['style'] ) ? selected( $field_value['style'], $key, false ) : '' ) . '>' . esc_attr( $style ) . '</option>';
|
342 |
+
}
|
343 |
|
344 |
+
echo '</select>';
|
345 |
|
346 |
+
echo '</div>';
|
347 |
+
}
|
348 |
|
349 |
+
// Build color.
|
350 |
+
if ( in_array( 'color', $ot_recognized_border_fields, true ) ) {
|
351 |
|
352 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
353 |
|
354 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
355 |
|
356 |
+
$color = isset( $field_value['color'] ) ? $field_value['color'] : '';
|
|
|
|
|
357 |
|
358 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
359 |
|
360 |
+
echo '</div>';
|
361 |
+
}
|
362 |
|
363 |
+
echo '</div>';
|
364 |
|
365 |
+
echo '</div>';
|
366 |
+
}
|
367 |
+
}
|
368 |
|
369 |
+
if ( ! function_exists( 'ot_type_box_shadow' ) ) {
|
370 |
|
371 |
+
/**
|
372 |
+
* Box Shadow Option Type
|
373 |
+
*
|
374 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
375 |
+
*
|
376 |
+
* @param array $args The options arguments.
|
377 |
+
*
|
378 |
+
* @access public
|
379 |
+
* @since 2.5.0
|
380 |
+
*/
|
381 |
+
function ot_type_box_shadow( $args = array() ) {
|
382 |
|
383 |
+
// Turns arguments array into variables.
|
384 |
+
extract( $args ); // phpcs:ignore
|
385 |
|
386 |
+
// Verify a description.
|
387 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
|
|
388 |
|
389 |
+
// Format setting outer wrapper.
|
390 |
+
echo '<div class="format-setting type-box-shadow ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
391 |
|
392 |
+
// Description.
|
393 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
394 |
|
395 |
+
// Format setting inner wrapper.
|
396 |
+
echo '<div class="format-setting-inner">';
|
397 |
|
398 |
+
// Allow fields to be filtered.
|
399 |
+
$ot_recognized_box_shadow_fields = apply_filters(
|
400 |
+
'ot_recognized_box_shadow_fields',
|
401 |
+
array(
|
402 |
+
'inset',
|
403 |
+
'offset-x',
|
404 |
+
'offset-y',
|
405 |
+
'blur-radius',
|
406 |
+
'spread-radius',
|
407 |
+
'color',
|
408 |
+
),
|
409 |
+
$field_id
|
410 |
+
);
|
411 |
|
412 |
+
// Build inset.
|
413 |
+
if ( in_array( 'inset', $ot_recognized_box_shadow_fields, true ) ) {
|
414 |
|
415 |
+
echo '<div class="ot-option-group ot-option-group--checkbox"><p>';
|
416 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[inset]" id="' . esc_attr( $field_id ) . '-inset" value="inset" ' . ( isset( $field_value['inset'] ) ? checked( $field_value['inset'], 'inset', false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
417 |
+
echo '<label for="' . esc_attr( $field_id ) . '-inset">inset</label>';
|
418 |
+
echo '</p></div>';
|
419 |
+
}
|
420 |
|
421 |
+
// Build horizontal offset.
|
422 |
+
if ( in_array( 'offset-x', $ot_recognized_box_shadow_fields, true ) ) {
|
423 |
|
424 |
+
$offset_x = isset( $field_value['offset-x'] ) ? esc_attr( $field_value['offset-x'] ) : '';
|
|
|
425 |
|
426 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-arrows-h ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[offset-x]" id="' . esc_attr( $field_id ) . '-offset-x" value="' . esc_attr( $offset_x ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'offset-x', 'option-tree' ) . '" /></div>';
|
427 |
+
}
|
428 |
|
429 |
+
// Build vertical offset.
|
430 |
+
if ( in_array( 'offset-y', $ot_recognized_box_shadow_fields, true ) ) {
|
431 |
|
432 |
+
$offset_y = isset( $field_value['offset-y'] ) ? esc_attr( $field_value['offset-y'] ) : '';
|
433 |
|
434 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-arrows-v ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[offset-y]" id="' . esc_attr( $field_id ) . '-offset-y" value="' . esc_attr( $offset_y ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'offset-y', 'option-tree' ) . '" /></div>';
|
435 |
+
}
|
436 |
|
437 |
+
// Build blur-radius radius.
|
438 |
+
if ( in_array( 'blur-radius', $ot_recognized_box_shadow_fields, true ) ) {
|
439 |
|
440 |
+
$blur_radius = isset( $field_value['blur-radius'] ) ? esc_attr( $field_value['blur-radius'] ) : '';
|
441 |
|
442 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-circle ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[blur-radius]" id="' . esc_attr( $field_id ) . '-blur-radius" value="' . esc_attr( $blur_radius ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'blur-radius', 'option-tree' ) . '" /></div>';
|
443 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
|
445 |
+
// Build spread-radius radius.
|
446 |
+
if ( in_array( 'spread-radius', $ot_recognized_box_shadow_fields, true ) ) {
|
447 |
|
448 |
+
$spread_radius = isset( $field_value['spread-radius'] ) ? esc_attr( $field_value['spread-radius'] ) : '';
|
|
|
449 |
|
450 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-arrows-alt ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[spread-radius]" id="' . esc_attr( $field_id ) . '-spread-radius" value="' . esc_attr( $spread_radius ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'spread-radius', 'option-tree' ) . '" /></div>';
|
451 |
+
}
|
452 |
|
453 |
+
// Build color.
|
454 |
+
if ( in_array( 'color', $ot_recognized_box_shadow_fields, true ) ) {
|
455 |
|
456 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
|
|
457 |
|
458 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
|
|
459 |
|
460 |
+
$color = isset( $field_value['color'] ) ? $field_value['color'] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
|
462 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
|
|
463 |
|
464 |
+
echo '</div>';
|
465 |
+
}
|
|
|
|
|
466 |
|
467 |
+
echo '</div>';
|
468 |
|
469 |
+
echo '</div>';
|
470 |
+
}
|
471 |
+
}
|
472 |
|
473 |
+
if ( ! function_exists( 'ot_type_category_checkbox' ) ) {
|
474 |
|
475 |
+
/**
|
476 |
+
* Category Checkbox option type.
|
477 |
+
*
|
478 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
479 |
+
*
|
480 |
+
* @param array $args An array of arguments.
|
481 |
+
*
|
482 |
+
* @access public
|
483 |
+
* @since 2.0
|
484 |
+
*/
|
485 |
+
function ot_type_category_checkbox( $args = array() ) {
|
486 |
+
|
487 |
+
// Turns arguments array into variables.
|
488 |
+
extract( $args );// phpcs:ignore
|
489 |
+
|
490 |
+
// Verify a description.
|
491 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
492 |
+
|
493 |
+
// Format setting outer wrapper.
|
494 |
+
echo '<div class="format-setting type-category-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
495 |
+
|
496 |
+
// Description.
|
497 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
498 |
+
|
499 |
+
// Format setting inner wrapper.
|
500 |
+
echo '<div class="format-setting-inner">';
|
501 |
+
|
502 |
+
// Get category array.
|
503 |
+
$categories = get_categories( apply_filters( 'ot_type_category_checkbox_query', array( 'hide_empty' => false ), $field_id ) );
|
504 |
+
|
505 |
+
// Build categories.
|
506 |
+
if ( ! empty( $categories ) ) {
|
507 |
+
foreach ( $categories as $category ) {
|
508 |
+
echo '<p>';
|
509 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $category->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $category->term_id ) . '" value="' . esc_attr( $category->term_id ) . '" ' . ( isset( $field_value[ $category->term_id ] ) ? checked( $field_value[ $category->term_id ], $category->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
510 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $category->term_id ) . '">' . esc_attr( $category->name ) . '</label>';
|
511 |
+
echo '</p>';
|
512 |
+
}
|
513 |
+
} else {
|
514 |
+
echo '<p>' . esc_html__( 'No Categories Found', 'option-tree' ) . '</p>';
|
515 |
+
}
|
516 |
+
|
517 |
+
echo '</div>';
|
518 |
+
|
519 |
+
echo '</div>';
|
520 |
+
}
|
521 |
+
}
|
522 |
|
523 |
+
if ( ! function_exists( 'ot_type_category_select' ) ) {
|
524 |
|
525 |
+
/**
|
526 |
+
* Category Select option type.
|
527 |
+
*
|
528 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
529 |
+
*
|
530 |
+
* @param array $args An array of arguments.
|
531 |
+
*
|
532 |
+
* @access public
|
533 |
+
* @since 2.0
|
534 |
+
*/
|
535 |
+
function ot_type_category_select( $args = array() ) {
|
536 |
|
537 |
+
// Turns arguments array into variables.
|
538 |
+
extract( $args ); // phpcs:ignore
|
539 |
|
540 |
+
// Verify a description.
|
541 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
542 |
|
543 |
+
// Format setting outer wrapper.
|
544 |
+
echo '<div class="format-setting type-category-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
545 |
|
546 |
+
// Description.
|
547 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
548 |
|
549 |
+
// Format setting inner wrapper.
|
550 |
+
echo '<div class="format-setting-inner">';
|
551 |
|
552 |
+
// Build category.
|
553 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
554 |
|
555 |
+
// Get category array.
|
556 |
+
$categories = get_categories( apply_filters( 'ot_type_category_select_query', array( 'hide_empty' => false ), $field_id ) );
|
557 |
|
558 |
+
// Has cats.
|
559 |
+
if ( ! empty( $categories ) ) {
|
560 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
561 |
+
foreach ( $categories as $category ) {
|
562 |
+
echo '<option value="' . esc_attr( $category->term_id ) . '" ' . selected( $field_value, $category->term_id, false ) . '>' . esc_attr( $category->name ) . '</option>';
|
563 |
+
}
|
564 |
+
} else {
|
565 |
+
echo '<option value="">' . esc_html__( 'No Categories Found', 'option-tree' ) . '</option>';
|
566 |
+
}
|
567 |
|
568 |
+
echo '</select>';
|
569 |
|
570 |
+
echo '</div>';
|
571 |
|
572 |
+
echo '</div>';
|
573 |
+
}
|
574 |
+
}
|
575 |
+
|
576 |
+
if ( ! function_exists( 'ot_type_checkbox' ) ) {
|
577 |
+
|
578 |
+
/**
|
579 |
+
* Checkbox option type.
|
580 |
+
*
|
581 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
582 |
+
*
|
583 |
+
* @param array $args An array of arguments.
|
584 |
+
*
|
585 |
+
* @access public
|
586 |
+
* @since 2.0
|
587 |
+
*/
|
588 |
+
function ot_type_checkbox( $args = array() ) {
|
589 |
+
|
590 |
+
// Turns arguments array into variables.
|
591 |
+
extract( $args ); // phpcs:ignore
|
592 |
+
|
593 |
+
// Verify a description.
|
594 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
595 |
+
|
596 |
+
// Format setting outer wrapper.
|
597 |
+
echo '<div class="format-setting type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
598 |
+
|
599 |
+
// Description.
|
600 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
601 |
+
|
602 |
+
// Format setting inner wrapper.
|
603 |
+
echo '<div class="format-setting-inner">';
|
604 |
+
|
605 |
+
// Build checkbox.
|
606 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
607 |
+
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
608 |
+
echo '<p>';
|
609 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . ( isset( $field_value[ $key ] ) ? checked( $field_value[ $key ], $choice['value'], false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
610 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label>';
|
611 |
+
echo '</p>';
|
612 |
+
}
|
613 |
+
}
|
614 |
+
|
615 |
+
echo '</div>';
|
616 |
+
|
617 |
+
echo '</div>';
|
618 |
+
}
|
619 |
+
}
|
620 |
|
621 |
+
if ( ! function_exists( 'ot_type_colorpicker' ) ) {
|
|
|
622 |
|
623 |
+
/**
|
624 |
+
* Colorpicker option type.
|
625 |
+
*
|
626 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
627 |
+
*
|
628 |
+
* @param array $args An array of arguments.
|
629 |
+
*
|
630 |
+
* @access public
|
631 |
+
* @since 2.0
|
632 |
+
* @updated 2.2.0
|
633 |
+
*/
|
634 |
+
function ot_type_colorpicker( $args = array() ) {
|
635 |
|
636 |
+
// Turns arguments array into variables.
|
637 |
+
extract( $args ); // phpcs:ignore
|
638 |
|
639 |
+
// Verify a description.
|
640 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
641 |
|
642 |
+
// Format setting outer wrapper.
|
643 |
+
echo '<div class="format-setting type-colorpicker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
644 |
|
645 |
+
// Description.
|
646 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
647 |
|
648 |
+
// Format setting inner wrapper.
|
649 |
+
echo '<div class="format-setting-inner">';
|
650 |
|
651 |
+
// Build colorpicker.
|
652 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
653 |
|
654 |
+
// Colorpicker JS.
|
655 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '"); });</script>';
|
656 |
|
657 |
+
// Input.
|
658 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '"' . ( ! empty( $field_std ) ? ' data-default-color="' . esc_attr( $field_std ) . '"' : '' ) . ' />';
|
659 |
+
|
660 |
+
echo '</div>';
|
661 |
+
|
662 |
+
echo '</div>';
|
663 |
|
664 |
+
echo '</div>';
|
665 |
+
}
|
666 |
}
|
667 |
|
668 |
+
if ( ! function_exists( 'ot_type_colorpicker_opacity' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
669 |
|
670 |
+
/**
|
671 |
+
* Colorpicker Opacity option type.
|
672 |
+
*
|
673 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
674 |
+
*
|
675 |
+
* @param array $args An array of arguments.
|
676 |
+
*
|
677 |
+
* @access public
|
678 |
+
* @since 2.5.0
|
679 |
+
*/
|
680 |
+
function ot_type_colorpicker_opacity( $args = array() ) {
|
681 |
+
|
682 |
+
$args['field_class'] = isset( $args['field_class'] ) ? $args['field_class'] . ' ot-colorpicker-opacity' : 'ot-colorpicker-opacity';
|
683 |
+
ot_type_colorpicker( $args );
|
684 |
+
}
|
685 |
+
}
|
686 |
|
687 |
+
if ( ! function_exists( 'ot_type_css' ) ) {
|
|
|
688 |
|
689 |
+
/**
|
690 |
+
* CSS option type.
|
691 |
+
*
|
692 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
693 |
+
*
|
694 |
+
* @param array $args An array of arguments.
|
695 |
+
*
|
696 |
+
* @access public
|
697 |
+
* @since 2.0
|
698 |
+
*/
|
699 |
+
function ot_type_css( $args = array() ) {
|
700 |
|
701 |
+
// Turns arguments array into variables.
|
702 |
+
extract( $args ); // phpcs:ignore
|
703 |
|
704 |
+
// Verify a description.
|
705 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
706 |
|
707 |
+
// Format setting outer wrapper.
|
708 |
+
echo '<div class="format-setting type-css simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
709 |
|
710 |
+
// Description.
|
711 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
712 |
|
713 |
+
// Format setting inner wrapper.
|
714 |
+
echo '<div class="format-setting-inner">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
715 |
|
716 |
+
// Build textarea for CSS.
|
717 |
+
echo '<textarea class="hidden" id="textarea_' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '">' . esc_textarea( $field_value ) . '</textarea>';
|
718 |
|
719 |
+
// Build pre to convert it into ace editor later.
|
720 |
+
echo '<pre class="ot-css-editor ' . esc_attr( $field_class ) . '" id="' . esc_attr( $field_id ) . '">' . esc_textarea( $field_value ) . '</pre>';
|
721 |
|
722 |
+
echo '</div>';
|
723 |
|
724 |
+
echo '</div>';
|
725 |
+
}
|
726 |
}
|
727 |
|
728 |
+
if ( ! function_exists( 'ot_type_custom_post_type_checkbox' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
729 |
|
730 |
+
/**
|
731 |
+
* Custom Post Type Checkbox option type.
|
732 |
+
*
|
733 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
734 |
+
*
|
735 |
+
* @param array $args An array of arguments.
|
736 |
+
*
|
737 |
+
* @access public
|
738 |
+
* @since 2.0
|
739 |
+
*/
|
740 |
+
function ot_type_custom_post_type_checkbox( $args = array() ) {
|
741 |
+
|
742 |
+
// Turns arguments array into variables.
|
743 |
+
extract( $args ); // phpcs:ignore
|
744 |
+
|
745 |
+
// Verify a description.
|
746 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
747 |
+
|
748 |
+
// Format setting outer wrapper.
|
749 |
+
echo '<div class="format-setting type-custom-post-type-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
750 |
+
|
751 |
+
// Description.
|
752 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
753 |
+
|
754 |
+
// Format setting inner wrapper.
|
755 |
+
echo '<div class="format-setting-inner">';
|
756 |
+
|
757 |
+
// Setup the post types.
|
758 |
+
$post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' );
|
759 |
+
|
760 |
+
// Query posts array.
|
761 |
+
$my_posts = get_posts(
|
762 |
+
apply_filters(
|
763 |
+
'ot_type_custom_post_type_checkbox_query',
|
764 |
+
array(
|
765 |
+
'post_type' => $post_type,
|
766 |
+
'posts_per_page' => -1,
|
767 |
+
'orderby' => 'title',
|
768 |
+
'order' => 'ASC',
|
769 |
+
'post_status' => 'any',
|
770 |
+
),
|
771 |
+
$field_id
|
772 |
+
)
|
773 |
+
);
|
774 |
+
|
775 |
+
// Has posts.
|
776 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
777 |
+
foreach ( $my_posts as $my_post ) {
|
778 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
779 |
+
echo '<p>';
|
780 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[ $my_post->ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
781 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . esc_html( $post_title ) . '</label>';
|
782 |
+
echo '</p>';
|
783 |
+
}
|
784 |
+
} else {
|
785 |
+
echo '<p>' . esc_html__( 'No Posts Found', 'option-tree' ) . '</p>';
|
786 |
+
}
|
787 |
+
|
788 |
+
echo '</div>';
|
789 |
+
|
790 |
+
echo '</div>';
|
791 |
+
}
|
792 |
+
}
|
793 |
|
794 |
+
if ( ! function_exists( 'ot_type_custom_post_type_select' ) ) {
|
|
|
795 |
|
796 |
+
/**
|
797 |
+
* Custom Post Type Select option type.
|
798 |
+
*
|
799 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
800 |
+
*
|
801 |
+
* @param array $args An array of arguments.
|
802 |
+
*
|
803 |
+
* @access public
|
804 |
+
* @since 2.0
|
805 |
+
*/
|
806 |
+
function ot_type_custom_post_type_select( $args = array() ) {
|
807 |
+
|
808 |
+
// Turns arguments array into variables.
|
809 |
+
extract( $args ); // phpcs:ignore
|
810 |
+
|
811 |
+
// Verify a description.
|
812 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
813 |
+
|
814 |
+
// Format setting outer wrapper.
|
815 |
+
echo '<div class="format-setting type-custom-post-type-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
816 |
+
|
817 |
+
// Description.
|
818 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
819 |
+
|
820 |
+
// Format setting inner wrapper.
|
821 |
+
echo '<div class="format-setting-inner">';
|
822 |
+
|
823 |
+
// Build category.
|
824 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
825 |
+
|
826 |
+
// Setup the post types.
|
827 |
+
$post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' );
|
828 |
+
|
829 |
+
// Query posts array.
|
830 |
+
$my_posts = get_posts(
|
831 |
+
apply_filters(
|
832 |
+
'ot_type_custom_post_type_select_query',
|
833 |
+
array(
|
834 |
+
'post_type' => $post_type,
|
835 |
+
'posts_per_page' => -1,
|
836 |
+
'orderby' => 'title',
|
837 |
+
'order' => 'ASC',
|
838 |
+
'post_status' => 'any',
|
839 |
+
),
|
840 |
+
$field_id
|
841 |
+
)
|
842 |
+
);
|
843 |
+
|
844 |
+
// Has posts.
|
845 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
846 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
847 |
+
foreach ( $my_posts as $my_post ) {
|
848 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
849 |
+
echo '<option value="' . esc_attr( $my_post->ID ) . '" ' . selected( $field_value, $my_post->ID, false ) . '>' . esc_html( $post_title ) . '</option>';
|
850 |
+
}
|
851 |
+
} else {
|
852 |
+
echo '<option value="">' . esc_html__( 'No Posts Found', 'option-tree' ) . '</option>';
|
853 |
+
}
|
854 |
+
|
855 |
+
echo '</select>';
|
856 |
+
|
857 |
+
echo '</div>';
|
858 |
+
|
859 |
+
echo '</div>';
|
860 |
+
}
|
861 |
+
}
|
862 |
|
863 |
+
if ( ! function_exists( 'ot_type_date_picker' ) ) {
|
|
|
864 |
|
865 |
+
/**
|
866 |
+
* Date Picker option type.
|
867 |
+
*
|
868 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
869 |
+
*
|
870 |
+
* @param array $args An array of arguments.
|
871 |
+
*
|
872 |
+
* @access public
|
873 |
+
* @since 2.3
|
874 |
+
*/
|
875 |
+
function ot_type_date_picker( $args = array() ) {
|
876 |
|
877 |
+
// Turns arguments array into variables.
|
878 |
+
extract( $args ); // phpcs:ignore
|
879 |
|
880 |
+
// Verify a description.
|
881 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
882 |
|
883 |
+
// Filter date format.
|
884 |
+
$date_format = apply_filters( 'ot_type_date_picker_date_format', 'yy-mm-dd', $field_id );
|
885 |
|
886 |
+
/**
|
887 |
+
* Filter the addition of the readonly attribute.
|
888 |
+
*
|
889 |
+
* @since 2.5.0
|
890 |
+
*
|
891 |
+
* @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'.
|
892 |
+
* @param string $field_id The field ID.
|
893 |
+
*/
|
894 |
+
$is_readonly = apply_filters( 'ot_type_date_picker_readonly', false, $field_id );
|
895 |
|
896 |
+
// Format setting outer wrapper.
|
897 |
+
echo '<div class="format-setting type-date-picker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
898 |
|
899 |
+
// Date picker JS.
|
900 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_date_picker("' . esc_attr( $field_id ) . '", "' . esc_attr( $date_format ) . '"); });</script>';
|
901 |
|
902 |
+
// Description.
|
903 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
904 |
|
905 |
+
// Format setting inner wrapper.
|
906 |
+
echo '<div class="format-setting-inner">';
|
907 |
+
|
908 |
+
// Build date picker.
|
909 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '"' . ( true === $is_readonly ? ' readonly' : '' ) . ' />';
|
910 |
|
911 |
+
echo '</div>';
|
912 |
+
|
913 |
+
echo '</div>';
|
914 |
+
}
|
915 |
}
|
916 |
|
917 |
+
if ( ! function_exists( 'ot_type_date_time_picker' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
|
919 |
+
/**
|
920 |
+
* Date Time Picker option type.
|
921 |
+
*
|
922 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
923 |
+
*
|
924 |
+
* @param array $args An array of arguments.
|
925 |
+
*
|
926 |
+
* @access public
|
927 |
+
* @since 2.3
|
928 |
+
*/
|
929 |
+
function ot_type_date_time_picker( $args = array() ) {
|
930 |
|
931 |
+
// Turns arguments array into variables.
|
932 |
+
extract( $args ); // phpcs:ignore
|
933 |
|
934 |
+
// Verify a description.
|
935 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
936 |
|
937 |
+
// Filter date format.
|
938 |
+
$date_format = apply_filters( 'ot_type_date_time_picker_date_format', 'yy-mm-dd', $field_id );
|
939 |
|
940 |
+
/**
|
941 |
+
* Filter the addition of the readonly attribute.
|
942 |
+
*
|
943 |
+
* @since 2.5.0
|
944 |
+
*
|
945 |
+
* @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'.
|
946 |
+
* @param string $field_id The field ID.
|
947 |
+
*/
|
948 |
+
$is_readonly = apply_filters( 'ot_type_date_time_picker_readonly', false, $field_id );
|
949 |
|
950 |
+
// Format setting outer wrapper.
|
951 |
+
echo '<div class="format-setting type-date-time-picker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
952 |
|
953 |
+
// Date time picker JS.
|
954 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_date_time_picker("' . esc_attr( $field_id ) . '", "' . esc_attr( $date_format ) . '"); });</script>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
955 |
|
956 |
+
// Description.
|
957 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
958 |
|
959 |
+
// Format setting inner wrapper.
|
960 |
+
echo '<div class="format-setting-inner">';
|
961 |
|
962 |
+
// Build date time picker.
|
963 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '"' . ( true === $is_readonly ? ' readonly' : '' ) . ' />';
|
964 |
|
965 |
+
echo '</div>';
|
966 |
+
|
967 |
+
echo '</div>';
|
968 |
+
}
|
969 |
}
|
970 |
|
971 |
+
if ( ! function_exists( 'ot_type_dimension' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
972 |
|
973 |
+
/**
|
974 |
+
* Dimension Option Type
|
975 |
+
*
|
976 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
977 |
+
*
|
978 |
+
* @param array $args The options arguments.
|
979 |
+
*
|
980 |
+
* @access public
|
981 |
+
* @since 2.5.0
|
982 |
+
*/
|
983 |
+
function ot_type_dimension( $args = array() ) {
|
984 |
|
985 |
+
// Turns arguments array into variables.
|
986 |
+
extract( $args ); // phpcs:ignore
|
987 |
|
988 |
+
// Verify a description.
|
989 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
990 |
|
991 |
+
// Format setting outer wrapper.
|
992 |
+
echo '<div class="format-setting type-dimension ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
993 |
|
994 |
+
// Description.
|
995 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
996 |
|
997 |
+
// Format setting inner wrapper.
|
998 |
+
echo '<div class="format-setting-inner">';
|
999 |
|
1000 |
+
// Allow fields to be filtered.
|
1001 |
+
$ot_recognized_dimension_fields = apply_filters(
|
1002 |
+
'ot_recognized_dimension_fields',
|
1003 |
+
array(
|
1004 |
+
'width',
|
1005 |
+
'height',
|
1006 |
+
'unit',
|
1007 |
+
),
|
1008 |
+
$field_id
|
1009 |
+
);
|
1010 |
|
1011 |
+
// Build width dimension.
|
1012 |
+
if ( in_array( 'width', $ot_recognized_dimension_fields, true ) ) {
|
1013 |
|
1014 |
+
$width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : '';
|
1015 |
+
echo '<div class="ot-option-group ot-option-group--one-third"><span class="ot-icon-arrows-h ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[width]" id="' . esc_attr( $field_id ) . '-width" value="' . esc_attr( $width ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'width', 'option-tree' ) . '" /></div>';
|
1016 |
+
}
|
1017 |
|
1018 |
+
// Build height dimension.
|
1019 |
+
if ( in_array( 'height', $ot_recognized_dimension_fields, true ) ) {
|
1020 |
|
1021 |
+
$height = isset( $field_value['height'] ) ? esc_attr( $field_value['height'] ) : '';
|
1022 |
+
echo '<div class="ot-option-group ot-option-group--one-third"><span class="ot-icon-arrows-v ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[height]" id="' . esc_attr( $field_id ) . '-height" value="' . esc_attr( $height ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'height', 'option-tree' ) . '" /></div>';
|
1023 |
+
}
|
1024 |
|
1025 |
+
// Build unit dropdown.
|
1026 |
+
if ( in_array( 'unit', $ot_recognized_dimension_fields, true ) ) {
|
1027 |
|
1028 |
+
echo '<div class="ot-option-group ot-option-group--one-third ot-option-group--is-last">';
|
1029 |
|
1030 |
+
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1031 |
|
1032 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
1033 |
|
1034 |
+
foreach ( ot_recognized_dimension_unit_types( $field_id ) as $unit ) {
|
1035 |
+
echo '<option value="' . esc_attr( $unit ) . '" ' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1036 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1037 |
|
1038 |
+
echo '</select>';
|
1039 |
|
1040 |
+
echo '</div>';
|
1041 |
+
}
|
1042 |
|
1043 |
+
echo '</div>';
|
1044 |
|
1045 |
+
echo '</div>';
|
1046 |
+
}
|
1047 |
}
|
1048 |
|
1049 |
+
if ( ! function_exists( 'ot_type_gallery' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1050 |
|
1051 |
+
/**
|
1052 |
+
* Gallery option type.
|
1053 |
+
*
|
1054 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1055 |
+
*
|
1056 |
+
* @param array $args The options arguments.
|
1057 |
+
*
|
1058 |
+
* @access public
|
1059 |
+
* @since 2.2.0
|
1060 |
+
*/
|
1061 |
+
function ot_type_gallery( $args = array() ) {
|
1062 |
|
1063 |
+
// Turns arguments array into variables.
|
1064 |
+
extract( $args ); // phpcs:ignore
|
1065 |
|
1066 |
+
// Verify a description.
|
1067 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1068 |
|
1069 |
+
// Format setting outer wrapper.
|
1070 |
+
echo '<div class="format-setting type-gallery ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1071 |
|
1072 |
+
// Description.
|
1073 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1074 |
|
1075 |
+
// Format setting inner wrapper.
|
1076 |
+
echo '<div class="format-setting-inner">';
|
1077 |
|
1078 |
+
$field_value = trim( $field_value );
|
|
|
1079 |
|
1080 |
+
// Saved values.
|
1081 |
+
echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="ot-gallery-value ' . esc_attr( $field_class ) . '" />';
|
1082 |
|
1083 |
+
// Search the string for the IDs.
|
1084 |
+
preg_match( '/ids=\'(.*?)\'/', $field_value, $matches );
|
1085 |
|
1086 |
+
// Turn the field value into an array of IDs.
|
1087 |
+
if ( isset( $matches[1] ) ) {
|
1088 |
|
1089 |
+
// Found the IDs in the shortcode.
|
1090 |
+
$ids = explode( ',', $matches[1] );
|
1091 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1092 |
|
1093 |
+
// The string is only IDs.
|
1094 |
+
$ids = ! empty( $field_value ) && '' !== $field_value ? explode( ',', $field_value ) : array();
|
1095 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1096 |
|
1097 |
+
// Has attachment IDs.
|
1098 |
+
if ( ! empty( $ids ) ) {
|
1099 |
|
1100 |
+
echo '<ul class="ot-gallery-list">';
|
|
|
1101 |
|
1102 |
+
foreach ( $ids as $id ) {
|
|
|
1103 |
|
1104 |
+
if ( '' === $id ) {
|
1105 |
+
continue;
|
1106 |
+
}
|
1107 |
|
1108 |
+
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
|
|
|
1109 |
|
1110 |
+
echo '<li><img src="' . esc_url_raw( $thumbnail[0] ) . '" width="75" height="75" /></li>';
|
1111 |
+
}
|
1112 |
|
1113 |
+
echo '</ul>';
|
|
|
1114 |
|
1115 |
+
echo '
|
1116 |
+
<div class="ot-gallery-buttons">
|
1117 |
+
<a href="#" class="option-tree-ui-button button button-secondary hug-left ot-gallery-delete">' . esc_html__( 'Delete Gallery', 'option-tree' ) . '</a>
|
1118 |
+
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . esc_html__( 'Edit Gallery', 'option-tree' ) . '</a>
|
1119 |
+
</div>';
|
|
|
|
|
1120 |
|
1121 |
+
} else {
|
1122 |
|
1123 |
+
echo '
|
1124 |
+
<div class="ot-gallery-buttons">
|
1125 |
+
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . esc_html__( 'Create Gallery', 'option-tree' ) . '</a>
|
1126 |
+
</div>';
|
1127 |
|
1128 |
+
}
|
1129 |
|
1130 |
+
echo '</div>';
|
1131 |
|
1132 |
+
echo '</div>';
|
1133 |
+
}
|
1134 |
}
|
1135 |
|
1136 |
+
if ( ! function_exists( 'ot_type_google_fonts' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1137 |
|
1138 |
+
/**
|
1139 |
+
* Google Fonts option type.
|
1140 |
+
*
|
1141 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1142 |
+
*
|
1143 |
+
* @param array $args An array of arguments.
|
1144 |
+
*
|
1145 |
+
* @access public
|
1146 |
+
* @since 2.5.0
|
1147 |
+
*/
|
1148 |
+
function ot_type_google_fonts( $args = array() ) {
|
1149 |
+
|
1150 |
+
// Turns arguments array into variables.
|
1151 |
+
extract( $args ); // phpcs:ignore
|
1152 |
+
|
1153 |
+
// Verify a description.
|
1154 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1155 |
+
|
1156 |
+
// Format setting outer wrapper.
|
1157 |
+
echo '<div class="format-setting type-google-font ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1158 |
+
|
1159 |
+
// Description.
|
1160 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1161 |
+
|
1162 |
+
// Format setting inner wrapper.
|
1163 |
+
echo '<div class="format-setting-inner">';
|
1164 |
+
|
1165 |
+
// Allow fields to be filtered.
|
1166 |
+
$ot_recognized_google_fonts_fields = apply_filters(
|
1167 |
+
'ot_recognized_google_font_fields',
|
1168 |
+
array(
|
1169 |
+
'variants',
|
1170 |
+
'subsets',
|
1171 |
+
),
|
1172 |
+
$field_id
|
1173 |
+
);
|
1174 |
+
|
1175 |
+
// Set a default to show at least one item.
|
1176 |
+
if ( ! is_array( $field_value ) || empty( $field_value ) ) {
|
1177 |
+
$field_value = array(
|
1178 |
+
array(
|
1179 |
+
'family' => '',
|
1180 |
+
'variants' => array(),
|
1181 |
+
'subsets' => array(),
|
1182 |
+
),
|
1183 |
+
);
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
foreach ( $field_value as $key => $value ) {
|
1187 |
+
|
1188 |
+
echo '<div class="type-google-font-group">';
|
1189 |
+
|
1190 |
+
// Build font family.
|
1191 |
+
$family = isset( $value['family'] ) ? $value['family'] : '';
|
1192 |
+
echo '<div class="option-tree-google-font-family">';
|
1193 |
+
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . esc_html__( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1194 |
+
echo '<select name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][family]" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1195 |
+
echo '<option value="">' . esc_html__( '-- Choose One --', 'option-tree' ) . '</option>';
|
1196 |
+
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1197 |
+
echo '<option value="' . esc_attr( $family_key ) . '" ' . selected( $family, $family_key, false ) . '>' . esc_html( $family_value ) . '</option>';
|
1198 |
+
}
|
1199 |
+
echo '</select>';
|
1200 |
+
echo '</div>';
|
1201 |
+
|
1202 |
+
// Build font variants.
|
1203 |
+
if ( in_array( 'variants', $ot_recognized_google_fonts_fields, true ) ) {
|
1204 |
+
$variants = isset( $value['variants'] ) ? $value['variants'] : array();
|
1205 |
+
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-" data-field-name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1206 |
+
foreach ( ot_recognized_google_font_variants( $field_id, $family ) as $variant_key => $variant ) {
|
1207 |
+
echo '<p class="checkbox-wrap">';
|
1208 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][variants][]" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $variant ) . '" value="' . esc_attr( $variant ) . '" ' . checked( in_array( $variant, $variants, true ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1209 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $variant ) . '">' . esc_html( $variant ) . '</label>';
|
1210 |
+
echo '</p>';
|
1211 |
+
}
|
1212 |
+
echo '</div>';
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
// Build font subsets.
|
1216 |
+
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields, true ) ) {
|
1217 |
+
$subsets = isset( $value['subsets'] ) ? $value['subsets'] : array();
|
1218 |
+
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-" data-field-name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1219 |
+
foreach ( ot_recognized_google_font_subsets( $field_id, $family ) as $subset_key => $subset ) {
|
1220 |
+
echo '<p class="checkbox-wrap">';
|
1221 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][subsets][]" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $subset ) . '" value="' . esc_attr( $subset ) . '" ' . checked( in_array( $subset, $subsets, true ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1222 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $subset ) . '">' . esc_html( $subset ) . '</label>';
|
1223 |
+
echo '</p>';
|
1224 |
+
}
|
1225 |
+
echo '</div>';
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
echo '</div>';
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
echo '<div class="type-google-font-group-clone">';
|
1232 |
+
|
1233 |
+
/* build font family */
|
1234 |
+
echo '<div class="option-tree-google-font-family">';
|
1235 |
+
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . esc_html__( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1236 |
+
echo '<select name="' . esc_attr( $field_name ) . '[%key%][family]" id="' . esc_attr( $field_id ) . '-%key%" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1237 |
+
echo '<option value="">' . esc_html__( '-- Choose One --', 'option-tree' ) . '</option>';
|
1238 |
+
|
1239 |
+
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1240 |
+
echo '<option value="' . esc_attr( $family_key ) . '">' . esc_html( $family_value ) . '</option>';
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
echo '</select>';
|
1244 |
+
echo '</div>';
|
1245 |
+
|
1246 |
+
// Build font variants.
|
1247 |
+
if ( in_array( 'variants', $ot_recognized_google_fonts_fields, true ) ) {
|
1248 |
+
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1249 |
+
echo '</div>';
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
// Build font subsets.
|
1253 |
+
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields, true ) ) {
|
1254 |
+
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1255 |
+
echo '</div>';
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
echo '</div>';
|
1259 |
+
|
1260 |
+
echo '<a href="javascript:void(0);" class="js-add-google-font option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add Google Font', 'option-tree' ) . '">' . esc_html__( 'Add Google Font', 'option-tree' ) . '</a>';
|
1261 |
+
|
1262 |
+
echo '</div>';
|
1263 |
+
|
1264 |
+
echo '</div>';
|
1265 |
+
}
|
1266 |
+
}
|
1267 |
|
1268 |
+
if ( ! function_exists( 'ot_type_javascript' ) ) {
|
|
|
1269 |
|
1270 |
+
/**
|
1271 |
+
* JavaScript option type.
|
1272 |
+
*
|
1273 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1274 |
+
*
|
1275 |
+
* @param array $args An array of arguments.
|
1276 |
+
*
|
1277 |
+
* @access public
|
1278 |
+
* @since 2.5.0
|
1279 |
+
*/
|
1280 |
+
function ot_type_javascript( $args = array() ) {
|
1281 |
|
1282 |
+
// Turns arguments array into variables.
|
1283 |
+
extract( $args ); // phpcs:ignore
|
1284 |
|
1285 |
+
// Verify a description.
|
1286 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
|
|
|
|
1287 |
|
1288 |
+
// Format setting outer wrapper.
|
1289 |
+
echo '<div class="format-setting type-javascript simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
|
|
1290 |
|
1291 |
+
// Description.
|
1292 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1293 |
|
1294 |
+
// Format setting inner wrapper.
|
1295 |
+
echo '<div class="format-setting-inner">';
|
1296 |
|
1297 |
+
// Build textarea for CSS.
|
1298 |
+
echo '<textarea class="hidden" id="textarea_' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '">' . esc_textarea( $field_value ) . '</textarea>';
|
1299 |
|
1300 |
+
// Build pre to convert it into ace editor later.
|
1301 |
+
echo '<pre class="ot-javascript-editor ' . esc_attr( $field_class ) . '" id="' . esc_attr( $field_id ) . '">' . esc_textarea( $field_value ) . '</pre>';
|
1302 |
|
1303 |
+
echo '</div>';
|
1304 |
|
1305 |
+
echo '</div>';
|
1306 |
+
}
|
1307 |
}
|
1308 |
|
1309 |
+
if ( ! function_exists( 'ot_type_link_color' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1310 |
|
1311 |
+
/**
|
1312 |
+
* Link Color option type.
|
1313 |
+
*
|
1314 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1315 |
+
*
|
1316 |
+
* @param array $args The options arguments.
|
1317 |
+
*
|
1318 |
+
* @access public
|
1319 |
+
* @since 2.5.0
|
1320 |
+
*/
|
1321 |
+
function ot_type_link_color( $args = array() ) {
|
1322 |
|
1323 |
+
// Turns arguments array into variables.
|
1324 |
+
extract( $args ); // phpcs:ignore
|
1325 |
|
1326 |
+
// Verify a description.
|
1327 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1328 |
|
1329 |
+
// Format setting outer wrapper.
|
1330 |
+
echo '<div class="format-setting type-link-color ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1331 |
|
1332 |
+
// Description.
|
1333 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1334 |
|
1335 |
+
// Format setting inner wrapper.
|
1336 |
+
echo '<div class="format-setting-inner">';
|
|
|
|
|
|
|
|
|
|
|
1337 |
|
1338 |
+
// Allow fields to be filtered.
|
1339 |
+
$ot_recognized_link_color_fields = apply_filters(
|
1340 |
+
'ot_recognized_link_color_fields',
|
1341 |
+
array(
|
1342 |
+
'link' => _x( 'Standard', 'color picker', 'option-tree' ),
|
1343 |
+
'hover' => _x( 'Hover', 'color picker', 'option-tree' ),
|
1344 |
+
'active' => _x( 'Active', 'color picker', 'option-tree' ),
|
1345 |
+
'visited' => _x( 'Visited', 'color picker', 'option-tree' ),
|
1346 |
+
'focus' => _x( 'Focus', 'color picker', 'option-tree' ),
|
1347 |
+
),
|
1348 |
+
$field_id
|
1349 |
+
);
|
1350 |
|
1351 |
+
// Build link color fields.
|
1352 |
+
foreach ( $ot_recognized_link_color_fields as $type => $label ) {
|
1353 |
|
1354 |
+
if ( array_key_exists( $type, $ot_recognized_link_color_fields ) ) {
|
1355 |
|
1356 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
|
|
|
|
1357 |
|
1358 |
+
echo '<label for="' . esc_attr( $field_id ) . '-picker-' . esc_attr( $type ) . '" class="option-tree-ui-colorpicker-label">' . esc_attr( $label ) . '</label>';
|
1359 |
|
1360 |
+
// Colorpicker JS.
|
1361 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker-' . esc_attr( $type ) . '"); });</script>';
|
1362 |
|
1363 |
+
// Set color.
|
1364 |
+
$color = isset( $field_value[ $type ] ) ? esc_attr( $field_value[ $type ] ) : '';
|
1365 |
|
1366 |
+
// Set default color.
|
1367 |
+
$std = isset( $field_std[ $type ] ) ? 'data-default-color="' . $field_std[ $type ] . '"' : '';
|
1368 |
|
1369 |
+
// Input.
|
1370 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[' . esc_attr( $type ) . ']" id="' . esc_attr( $field_id ) . '-picker-' . esc_attr( $type ) . '" value="' . esc_attr( $color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" ' . esc_attr( $std ) . ' />';
|
1371 |
|
1372 |
+
echo '</div>';
|
1373 |
|
1374 |
+
}
|
1375 |
+
}
|
1376 |
|
1377 |
+
echo '</div>';
|
1378 |
|
1379 |
+
echo '</div>';
|
1380 |
+
}
|
1381 |
}
|
1382 |
|
1383 |
+
if ( ! function_exists( 'ot_type_list_item' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1384 |
|
1385 |
+
/**
|
1386 |
+
* List Item option type.
|
1387 |
+
*
|
1388 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1389 |
+
*
|
1390 |
+
* @param array $args An array of arguments.
|
1391 |
+
*
|
1392 |
+
* @access public
|
1393 |
+
* @since 2.0
|
1394 |
+
*/
|
1395 |
+
function ot_type_list_item( $args = array() ) {
|
1396 |
|
1397 |
+
// Turns arguments array into variables.
|
1398 |
+
extract( $args ); // phpcs:ignore
|
1399 |
|
1400 |
+
// Verify a description.
|
1401 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1402 |
|
1403 |
+
// Default.
|
1404 |
+
$sortable = true;
|
1405 |
|
1406 |
+
// Check if the list can be sorted.
|
1407 |
+
if ( ! empty( $field_class ) ) {
|
1408 |
+
$classes = explode( ' ', $field_class );
|
1409 |
+
if ( in_array( 'not-sortable', $classes, true ) ) {
|
1410 |
+
$sortable = false;
|
1411 |
+
str_replace( 'not-sortable', '', $field_class );
|
1412 |
+
}
|
1413 |
+
}
|
1414 |
|
1415 |
+
// Format setting outer wrapper.
|
1416 |
+
echo '<div class="format-setting type-list-item ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
|
|
|
|
|
|
|
|
|
|
1417 |
|
1418 |
+
// Description.
|
1419 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1420 |
|
1421 |
+
// Format setting inner wrapper.
|
1422 |
+
echo '<div class="format-setting-inner">';
|
1423 |
|
1424 |
+
// Pass the settings array arround.
|
1425 |
+
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . esc_attr( ot_encode( $field_settings ) ) . '" />';
|
1426 |
|
1427 |
+
/**
|
1428 |
+
* Settings pages have array wrappers like 'option_tree'.
|
1429 |
+
* So we need that value to create a proper array to save to.
|
1430 |
+
* This is only for NON metabox settings.
|
1431 |
+
*/
|
1432 |
+
if ( ! isset( $get_option ) ) {
|
1433 |
+
$get_option = '';
|
1434 |
+
}
|
1435 |
|
1436 |
+
// Build list items.
|
1437 |
+
echo '<ul class="option-tree-setting-wrap' . ( $sortable ? ' option-tree-sortable' : '' ) . '" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
1438 |
|
1439 |
+
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
1440 |
|
1441 |
+
foreach ( $field_value as $key => $list_item ) {
|
1442 |
|
1443 |
+
echo '<li class="ui-state-default list-list-item">';
|
1444 |
+
ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type );
|
1445 |
+
echo '</li>';
|
1446 |
+
}
|
1447 |
+
}
|
1448 |
|
1449 |
+
echo '</ul>';
|
|
|
1450 |
|
1451 |
+
// Button.
|
1452 |
+
echo '<a href="javascript:void(0);" class="option-tree-list-item-add option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add New', 'option-tree' ) . '">' . esc_html__( 'Add New', 'option-tree' ) . '</a>';
|
1453 |
|
1454 |
+
// Description.
|
1455 |
+
$list_desc = $sortable ? __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) : '';
|
1456 |
+
echo '<div class="list-item-description">' . esc_html( apply_filters( 'ot_list_item_description', $list_desc, $field_id ) ) . '</div>';
|
1457 |
|
1458 |
+
echo '</div>';
|
1459 |
|
1460 |
+
echo '</div>';
|
1461 |
+
}
|
1462 |
}
|
1463 |
|
1464 |
+
if ( ! function_exists( 'ot_type_measurement' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1465 |
|
1466 |
+
/**
|
1467 |
+
* Measurement option type.
|
1468 |
+
*
|
1469 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1470 |
+
*
|
1471 |
+
* @param array $args An array of arguments.
|
1472 |
+
*
|
1473 |
+
* @access public
|
1474 |
+
* @since 2.0
|
1475 |
+
*/
|
1476 |
+
function ot_type_measurement( $args = array() ) {
|
1477 |
|
1478 |
+
// Turns arguments array into variables.
|
1479 |
+
extract( $args ); // phpcs:ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
1480 |
|
1481 |
+
// Verify a description.
|
1482 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1483 |
|
1484 |
+
// Format setting outer wrapper.
|
1485 |
+
echo '<div class="format-setting type-measurement ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1486 |
|
1487 |
+
// Description.
|
1488 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1489 |
|
1490 |
+
// Format setting inner wrapper.
|
1491 |
+
echo '<div class="format-setting-inner">';
|
1492 |
|
1493 |
+
echo '<div class="option-tree-ui-measurement-input-wrap">';
|
|
|
1494 |
|
1495 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[0]" id="' . esc_attr( $field_id ) . '-0" value="' . esc_attr( ( isset( $field_value[0] ) ? $field_value[0] : '' ) ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" />';
|
1496 |
|
1497 |
+
echo '</div>';
|
1498 |
|
1499 |
+
// Build measurement.
|
1500 |
+
echo '<select name="' . esc_attr( $field_name ) . '[1]" id="' . esc_attr( $field_id ) . '-1" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1501 |
|
1502 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
|
|
1503 |
|
1504 |
+
foreach ( ot_measurement_unit_types( $field_id ) as $unit ) {
|
1505 |
+
echo '<option value="' . esc_attr( $unit ) . '" ' . ( isset( $field_value[1] ) ? selected( $field_value[1], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1506 |
+
}
|
1507 |
|
1508 |
+
echo '</select>';
|
1509 |
|
1510 |
+
echo '</div>';
|
1511 |
|
1512 |
+
echo '</div>';
|
1513 |
+
}
|
1514 |
+
}
|
1515 |
|
1516 |
+
if ( ! function_exists( 'ot_type_numeric_slider' ) ) {
|
1517 |
|
1518 |
+
/**
|
1519 |
+
* Numeric Slider option type.
|
1520 |
+
*
|
1521 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1522 |
+
*
|
1523 |
+
* @param array $args An array of arguments.
|
1524 |
+
*
|
1525 |
+
* @access public
|
1526 |
+
* @since 2.1
|
1527 |
+
*/
|
1528 |
+
function ot_type_numeric_slider( $args = array() ) {
|
1529 |
|
1530 |
+
// Turns arguments array into variables.
|
1531 |
+
extract( $args ); // phpcs:ignore
|
1532 |
|
1533 |
+
// Verify a description.
|
1534 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1535 |
|
1536 |
+
$_options = explode( ',', $field_min_max_step );
|
1537 |
+
$min = isset( $_options[0] ) ? $_options[0] : 0;
|
1538 |
+
$max = isset( $_options[1] ) ? $_options[1] : 100;
|
1539 |
+
$step = isset( $_options[2] ) ? $_options[2] : 1;
|
1540 |
|
1541 |
+
// Format setting outer wrapper.
|
1542 |
+
echo '<div class="format-setting type-numeric-slider ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1543 |
|
1544 |
+
// Description.
|
1545 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1546 |
|
1547 |
+
// Format setting inner wrapper.
|
1548 |
+
echo '<div class="format-setting-inner">';
|
|
|
1549 |
|
1550 |
+
echo '<div class="ot-numeric-slider-wrap">';
|
1551 |
|
1552 |
+
echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="ot-numeric-slider-hidden-input" value="' . esc_attr( $field_value ) . '" data-min="' . esc_attr( $min ) . '" data-max="' . esc_attr( $max ) . '" data-step="' . esc_attr( $step ) . '">';
|
1553 |
|
1554 |
+
echo '<input type="text" class="ot-numeric-slider-helper-input widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" value="' . esc_attr( $field_value ) . '" readonly>';
|
1555 |
|
1556 |
+
echo '<div id="ot_numeric_slider_' . esc_attr( $field_id ) . '" class="ot-numeric-slider"></div>';
|
1557 |
|
1558 |
+
echo '</div>';
|
1559 |
|
1560 |
+
echo '</div>';
|
1561 |
|
1562 |
+
echo '</div>';
|
1563 |
+
}
|
1564 |
}
|
1565 |
|
1566 |
+
if ( ! function_exists( 'ot_type_on_off' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1567 |
|
1568 |
+
/**
|
1569 |
+
* On/Off option type
|
1570 |
+
*
|
1571 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1572 |
+
*
|
1573 |
+
* @param array $args The options arguments.
|
1574 |
+
*
|
1575 |
+
* @access public
|
1576 |
+
* @since 2.2.0
|
1577 |
+
*/
|
1578 |
+
function ot_type_on_off( $args = array() ) {
|
1579 |
+
|
1580 |
+
// Turns arguments array into variables.
|
1581 |
+
extract( $args ); // phpcs:ignore
|
1582 |
+
|
1583 |
+
// Verify a description.
|
1584 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1585 |
+
|
1586 |
+
// Format setting outer wrapper.
|
1587 |
+
echo '<div class="format-setting type-radio ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1588 |
+
|
1589 |
+
// Description.
|
1590 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1591 |
+
|
1592 |
+
// Format setting inner wrapper.
|
1593 |
+
echo '<div class="format-setting-inner">';
|
1594 |
+
|
1595 |
+
// Force only two choices, and allowing filtering on the choices value & label.
|
1596 |
+
$field_choices = array(
|
1597 |
+
array(
|
1598 |
+
/**
|
1599 |
+
* Filter the value of the On button.
|
1600 |
+
*
|
1601 |
+
* @since 2.5.0
|
1602 |
+
*
|
1603 |
+
* @param string $value The On button value. Default 'on'.
|
1604 |
+
* @param string $field_id The field ID.
|
1605 |
+
* @param string $filter_id For filtering both on/off value with one function.
|
1606 |
+
*/
|
1607 |
+
'value' => apply_filters( 'ot_on_off_switch_on_value', 'on', $field_id, 'on' ),
|
1608 |
+
/**
|
1609 |
+
* Filter the label of the On button.
|
1610 |
+
*
|
1611 |
+
* @since 2.5.0
|
1612 |
+
*
|
1613 |
+
* @param string $label The On button label. Default 'On'.
|
1614 |
+
* @param string $field_id The field ID.
|
1615 |
+
* @param string $filter_id For filtering both on/off label with one function.
|
1616 |
+
*/
|
1617 |
+
'label' => apply_filters( 'ot_on_off_switch_on_label', esc_html__( 'On', 'option-tree' ), $field_id, 'on' ),
|
1618 |
+
),
|
1619 |
+
array(
|
1620 |
+
/**
|
1621 |
+
* Filter the value of the Off button.
|
1622 |
+
*
|
1623 |
+
* @since 2.5.0
|
1624 |
+
*
|
1625 |
+
* @param string $value The Off button value. Default 'off'.
|
1626 |
+
* @param string $field_id The field ID.
|
1627 |
+
* @param string $filter_id For filtering both on/off value with one function.
|
1628 |
+
*/
|
1629 |
+
'value' => apply_filters( 'ot_on_off_switch_off_value', 'off', $field_id, 'off' ),
|
1630 |
+
/**
|
1631 |
+
* Filter the label of the Off button.
|
1632 |
+
*
|
1633 |
+
* @since 2.5.0
|
1634 |
+
*
|
1635 |
+
* @param string $label The Off button label. Default 'Off'.
|
1636 |
+
* @param string $field_id The field ID.
|
1637 |
+
* @param string $filter_id For filtering both on/off label with one function.
|
1638 |
+
*/
|
1639 |
+
'label' => apply_filters( 'ot_on_off_switch_off_label', esc_html__( 'Off', 'option-tree' ), $field_id, 'off' ),
|
1640 |
+
),
|
1641 |
+
);
|
1642 |
+
|
1643 |
+
/**
|
1644 |
+
* Filter the width of the On/Off switch.
|
1645 |
+
*
|
1646 |
+
* @since 2.5.0
|
1647 |
+
*
|
1648 |
+
* @param string $switch_width The switch width. Default '100px'.
|
1649 |
+
* @param string $field_id The field ID.
|
1650 |
+
*/
|
1651 |
+
$switch_width = apply_filters( 'ot_on_off_switch_width', '100px', $field_id );
|
1652 |
+
|
1653 |
+
echo '<div class="on-off-switch"' . ( '100px' !== $switch_width ? sprintf( ' style="width:%s"', esc_attr( $switch_width ) ) : '' ) . '>'; // phpcs:ignore
|
1654 |
+
|
1655 |
+
// Build radio.
|
1656 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
1657 |
+
echo '
|
1658 |
+
<input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . checked( $field_value, $choice['value'], false ) . ' class="radio option-tree-ui-radio ' . esc_attr( $field_class ) . '" />
|
1659 |
+
<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" onclick="">' . esc_attr( $choice['label'] ) . '</label>';
|
1660 |
+
}
|
1661 |
|
1662 |
+
echo '<span class="slide-button"></span>';
|
|
|
1663 |
|
1664 |
+
echo '</div>';
|
1665 |
|
1666 |
+
echo '</div>';
|
1667 |
|
1668 |
+
echo '</div>';
|
1669 |
|
1670 |
+
}
|
1671 |
}
|
1672 |
|
1673 |
+
if ( ! function_exists( 'ot_type_page_checkbox' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1674 |
|
1675 |
+
/**
|
1676 |
+
* Page Checkbox option type.
|
1677 |
+
*
|
1678 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1679 |
+
*
|
1680 |
+
* @param array $args An array of arguments.
|
1681 |
+
*
|
1682 |
+
* @access public
|
1683 |
+
* @since 2.0
|
1684 |
+
*/
|
1685 |
+
function ot_type_page_checkbox( $args = array() ) {
|
1686 |
+
|
1687 |
+
// Turns arguments array into variables.
|
1688 |
+
extract( $args ); // phpcs:ignore
|
1689 |
+
|
1690 |
+
// Verify a description.
|
1691 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1692 |
+
|
1693 |
+
// Format setting outer wrapper.
|
1694 |
+
echo '<div class="format-setting type-page-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1695 |
+
|
1696 |
+
// Description.
|
1697 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1698 |
+
|
1699 |
+
// Format setting inner wrapper.
|
1700 |
+
echo '<div class="format-setting-inner">';
|
1701 |
+
|
1702 |
+
// Query pages array.
|
1703 |
+
$my_posts = get_posts(
|
1704 |
+
apply_filters(
|
1705 |
+
'ot_type_page_checkbox_query',
|
1706 |
+
array(
|
1707 |
+
'post_type' => array( 'page' ),
|
1708 |
+
'posts_per_page' => -1,
|
1709 |
+
'orderby' => 'title',
|
1710 |
+
'order' => 'ASC',
|
1711 |
+
'post_status' => 'any',
|
1712 |
+
),
|
1713 |
+
$field_id
|
1714 |
+
)
|
1715 |
+
);
|
1716 |
+
|
1717 |
+
// Has pages.
|
1718 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1719 |
+
foreach ( $my_posts as $my_post ) {
|
1720 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1721 |
+
echo '<p>';
|
1722 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[ $my_post->ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1723 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . esc_html( $post_title ) . '</label>';
|
1724 |
+
echo '</p>';
|
1725 |
+
}
|
1726 |
+
} else {
|
1727 |
+
echo '<p>' . esc_html__( 'No Pages Found', 'option-tree' ) . '</p>';
|
1728 |
+
}
|
1729 |
+
|
1730 |
+
echo '</div>';
|
1731 |
+
|
1732 |
+
echo '</div>';
|
1733 |
+
}
|
1734 |
+
}
|
1735 |
|
1736 |
+
if ( ! function_exists( 'ot_type_page_select' ) ) {
|
1737 |
|
1738 |
+
/**
|
1739 |
+
* Page Select option type.
|
1740 |
+
*
|
1741 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1742 |
+
*
|
1743 |
+
* @param array $args An array of arguments.
|
1744 |
+
*
|
1745 |
+
* @access public
|
1746 |
+
* @since 2.0
|
1747 |
+
*/
|
1748 |
+
function ot_type_page_select( $args = array() ) {
|
1749 |
+
|
1750 |
+
// Turns arguments array into variables.
|
1751 |
+
extract( $args ); // phpcs:ignore
|
1752 |
+
|
1753 |
+
// Verify a description.
|
1754 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1755 |
+
|
1756 |
+
// Format setting outer wrapper.
|
1757 |
+
echo '<div class="format-setting type-page-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1758 |
+
|
1759 |
+
// Description.
|
1760 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1761 |
+
|
1762 |
+
// Format setting inner wrapper.
|
1763 |
+
echo '<div class="format-setting-inner">';
|
1764 |
+
|
1765 |
+
// Build page select.
|
1766 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1767 |
+
|
1768 |
+
// Query pages array.
|
1769 |
+
$my_posts = get_posts(
|
1770 |
+
apply_filters(
|
1771 |
+
'ot_type_page_select_query',
|
1772 |
+
array(
|
1773 |
+
'post_type' => array( 'page' ),
|
1774 |
+
'posts_per_page' => -1,
|
1775 |
+
'orderby' => 'title',
|
1776 |
+
'order' => 'ASC',
|
1777 |
+
'post_status' => 'any',
|
1778 |
+
),
|
1779 |
+
$field_id
|
1780 |
+
)
|
1781 |
+
);
|
1782 |
+
|
1783 |
+
// Has pages.
|
1784 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1785 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
1786 |
+
foreach ( $my_posts as $my_post ) {
|
1787 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1788 |
+
echo '<option value="' . esc_attr( $my_post->ID ) . '" ' . selected( $field_value, $my_post->ID, false ) . '>' . esc_html( $post_title ) . '</option>';
|
1789 |
+
}
|
1790 |
+
} else {
|
1791 |
+
echo '<option value="">' . esc_html__( 'No Pages Found', 'option-tree' ) . '</option>';
|
1792 |
+
}
|
1793 |
+
|
1794 |
+
echo '</select>';
|
1795 |
+
|
1796 |
+
echo '</div>';
|
1797 |
+
|
1798 |
+
echo '</div>';
|
1799 |
+
}
|
1800 |
}
|
1801 |
|
1802 |
+
if ( ! function_exists( 'ot_type_post_checkbox' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1803 |
|
1804 |
+
/**
|
1805 |
+
* Post Checkbox option type.
|
1806 |
+
*
|
1807 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1808 |
+
*
|
1809 |
+
* @param array $args An array of arguments.
|
1810 |
+
*
|
1811 |
+
* @access public
|
1812 |
+
* @since 2.0
|
1813 |
+
*/
|
1814 |
+
function ot_type_post_checkbox( $args = array() ) {
|
1815 |
+
|
1816 |
+
// Turns arguments array into variables.
|
1817 |
+
extract( $args ); // phpcs:ignore
|
1818 |
+
|
1819 |
+
// Verify a description.
|
1820 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1821 |
+
|
1822 |
+
// Format setting outer wrapper.
|
1823 |
+
echo '<div class="format-setting type-post-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1824 |
+
|
1825 |
+
// Description.
|
1826 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1827 |
+
|
1828 |
+
// Format setting inner wrapper.
|
1829 |
+
echo '<div class="format-setting-inner">';
|
1830 |
+
|
1831 |
+
// Query posts array.
|
1832 |
+
$my_posts = get_posts(
|
1833 |
+
apply_filters(
|
1834 |
+
'ot_type_post_checkbox_query',
|
1835 |
+
array(
|
1836 |
+
'post_type' => array( 'post' ),
|
1837 |
+
'posts_per_page' => -1,
|
1838 |
+
'orderby' => 'title',
|
1839 |
+
'order' => 'ASC',
|
1840 |
+
'post_status' => 'any',
|
1841 |
+
),
|
1842 |
+
$field_id
|
1843 |
+
)
|
1844 |
+
);
|
1845 |
+
|
1846 |
+
// Has posts.
|
1847 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1848 |
+
foreach ( $my_posts as $my_post ) {
|
1849 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1850 |
+
echo '<p>';
|
1851 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[ $my_post->ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1852 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . esc_html( $post_title ) . '</label>';
|
1853 |
+
echo '</p>';
|
1854 |
+
}
|
1855 |
+
} else {
|
1856 |
+
echo '<p>' . esc_html__( 'No Posts Found', 'option-tree' ) . '</p>';
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
echo '</div>';
|
1860 |
+
|
1861 |
+
echo '</div>';
|
1862 |
+
}
|
1863 |
+
}
|
1864 |
|
1865 |
+
if ( ! function_exists( 'ot_type_post_select' ) ) {
|
|
|
1866 |
|
1867 |
+
/**
|
1868 |
+
* Post Select option type.
|
1869 |
+
*
|
1870 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1871 |
+
*
|
1872 |
+
* @param array $args An array of arguments.
|
1873 |
+
*
|
1874 |
+
* @access public
|
1875 |
+
* @since 2.0
|
1876 |
+
*/
|
1877 |
+
function ot_type_post_select( $args = array() ) {
|
1878 |
+
|
1879 |
+
// Turns arguments array into variables.
|
1880 |
+
extract( $args ); // phpcs:ignore
|
1881 |
+
|
1882 |
+
// Verify a description.
|
1883 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1884 |
+
|
1885 |
+
// Format setting outer wrapper.
|
1886 |
+
echo '<div class="format-setting type-post-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1887 |
+
|
1888 |
+
/* description */
|
1889 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1890 |
+
|
1891 |
+
// Format setting inner wrapper.
|
1892 |
+
echo '<div class="format-setting-inner">';
|
1893 |
+
|
1894 |
+
// Build page select.
|
1895 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1896 |
+
|
1897 |
+
// Query posts array.
|
1898 |
+
$my_posts = get_posts(
|
1899 |
+
apply_filters(
|
1900 |
+
'ot_type_post_select_query',
|
1901 |
+
array(
|
1902 |
+
'post_type' => array( 'post' ),
|
1903 |
+
'posts_per_page' => -1,
|
1904 |
+
'orderby' => 'title',
|
1905 |
+
'order' => 'ASC',
|
1906 |
+
'post_status' => 'any',
|
1907 |
+
),
|
1908 |
+
$field_id
|
1909 |
+
)
|
1910 |
+
);
|
1911 |
+
|
1912 |
+
// Has posts.
|
1913 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1914 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
1915 |
+
foreach ( $my_posts as $my_post ) {
|
1916 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1917 |
+
echo '<option value="' . esc_attr( $my_post->ID ) . '" ' . selected( $field_value, $my_post->ID, false ) . '>' . esc_html( $post_title ) . '</option>';
|
1918 |
+
}
|
1919 |
+
} else {
|
1920 |
+
echo '<option value="">' . esc_html__( 'No Posts Found', 'option-tree' ) . '</option>';
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
echo '</select>';
|
1924 |
+
|
1925 |
+
echo '</div>';
|
1926 |
+
|
1927 |
+
echo '</div>';
|
1928 |
+
}
|
1929 |
+
}
|
1930 |
|
1931 |
+
if ( ! function_exists( 'ot_type_radio' ) ) {
|
|
|
1932 |
|
1933 |
+
/**
|
1934 |
+
* Radio option type.
|
1935 |
+
*
|
1936 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1937 |
+
*
|
1938 |
+
* @param array $args An array of arguments.
|
1939 |
+
*
|
1940 |
+
* @access public
|
1941 |
+
* @since 2.0
|
1942 |
+
*/
|
1943 |
+
function ot_type_radio( $args = array() ) {
|
1944 |
|
1945 |
+
// Turns arguments array into variables.
|
1946 |
+
extract( $args ); // phpcs:ignore
|
1947 |
|
1948 |
+
// Verify a description.
|
1949 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1950 |
|
1951 |
+
// Format setting outer wrapper.
|
1952 |
+
echo '<div class="format-setting type-radio ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1953 |
|
1954 |
+
// Description.
|
1955 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1956 |
|
1957 |
+
// Format setting inner wrapper.
|
1958 |
+
echo '<div class="format-setting-inner">';
|
1959 |
|
1960 |
+
// Build radio.
|
1961 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
1962 |
+
echo '<p><input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . checked( $field_value, $choice['value'], false ) . ' class="radio option-tree-ui-radio ' . esc_attr( $field_class ) . '" /><label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label></p>';
|
1963 |
+
}
|
1964 |
|
1965 |
+
echo '</div>';
|
1966 |
|
1967 |
+
echo '</div>';
|
1968 |
+
}
|
1969 |
}
|
1970 |
|
1971 |
+
if ( ! function_exists( 'ot_type_radio_image' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1972 |
|
1973 |
+
/**
|
1974 |
+
* Radio Images option type.
|
1975 |
+
*
|
1976 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1977 |
+
*
|
1978 |
+
* @param array $args An array of arguments.
|
1979 |
+
*
|
1980 |
+
* @access public
|
1981 |
+
* @since 2.0
|
1982 |
+
*/
|
1983 |
+
function ot_type_radio_image( $args = array() ) {
|
1984 |
+
|
1985 |
+
// Turns arguments array into variables.
|
1986 |
+
extract( $args ); // phpcs:ignore
|
1987 |
+
|
1988 |
+
// Verify a description.
|
1989 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1990 |
+
|
1991 |
+
// Format setting outer wrapper.
|
1992 |
+
echo '<div class="format-setting type-radio-image ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1993 |
+
|
1994 |
+
// Description.
|
1995 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1996 |
+
|
1997 |
+
// Format setting inner wrapper.
|
1998 |
+
echo '<div class="format-setting-inner">';
|
1999 |
+
|
2000 |
+
/**
|
2001 |
+
* Load the default filterable images if nothing
|
2002 |
+
* has been set in the choices array.
|
2003 |
+
*/
|
2004 |
+
if ( empty( $field_choices ) ) {
|
2005 |
+
$field_choices = ot_radio_images( $field_id );
|
2006 |
+
}
|
2007 |
+
|
2008 |
+
// Build radio image.
|
2009 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
2010 |
+
|
2011 |
+
$src = str_replace( 'OT_URL', OT_URL, $choice['src'] );
|
2012 |
+
$src = str_replace( 'OT_THEME_URL', OT_THEME_URL, $src );
|
2013 |
+
|
2014 |
+
// Make radio image source filterable.
|
2015 |
+
$src = apply_filters( 'ot_type_radio_image_src', $src, $field_id );
|
2016 |
+
|
2017 |
+
/**
|
2018 |
+
* Filter the image attributes.
|
2019 |
+
*
|
2020 |
+
* @since 2.5.3
|
2021 |
+
*
|
2022 |
+
* @param string $attributes The image attributes.
|
2023 |
+
* @param string $field_id The field ID.
|
2024 |
+
* @param array $choice The choice.
|
2025 |
+
*/
|
2026 |
+
$attributes = apply_filters( 'ot_type_radio_image_attributes', '', $field_id, $choice );
|
2027 |
+
|
2028 |
+
echo '<div class="option-tree-ui-radio-images">';
|
2029 |
+
echo '<p style="display:none"><input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . checked( $field_value, $choice['value'], false ) . ' class="option-tree-ui-radio option-tree-ui-images" /><label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label></p>';
|
2030 |
+
echo '<img ' . sanitize_text_field( $attributes ) . ' src="' . esc_url( $src ) . '" alt="' . esc_attr( $choice['label'] ) . '" title="' . esc_attr( $choice['label'] ) . '" class="option-tree-ui-radio-image ' . esc_attr( $field_class ) . ( $field_value === $choice['value'] ? ' option-tree-ui-radio-image-selected' : '' ) . '" />'; // phpcs:ignore
|
2031 |
+
echo '</div>';
|
2032 |
+
}
|
2033 |
+
|
2034 |
+
echo '</div>';
|
2035 |
+
|
2036 |
+
echo '</div>';
|
2037 |
+
}
|
2038 |
+
}
|
2039 |
|
2040 |
+
if ( ! function_exists( 'ot_type_select' ) ) {
|
|
|
2041 |
|
2042 |
+
/**
|
2043 |
+
* Select option type.
|
2044 |
+
*
|
2045 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2046 |
+
*
|
2047 |
+
* @param array $args An array of arguments.
|
2048 |
+
*
|
2049 |
+
* @access public
|
2050 |
+
* @since 2.0
|
2051 |
+
*/
|
2052 |
+
function ot_type_select( $args = array() ) {
|
2053 |
|
2054 |
+
// Turns arguments array into variables.
|
2055 |
+
extract( $args ); // phpcs:ignore
|
2056 |
|
2057 |
+
// Verify a description.
|
2058 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2059 |
|
2060 |
+
// Format setting outer wrapper.
|
2061 |
+
echo '<div class="format-setting type-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2062 |
|
2063 |
+
// Description.
|
2064 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2065 |
|
2066 |
+
// Filter choices array.
|
2067 |
+
$field_choices = apply_filters( 'ot_type_select_choices', $field_choices, $field_id );
|
2068 |
|
2069 |
+
// Format setting inner wrapper.
|
2070 |
+
echo '<div class="format-setting-inner">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2071 |
|
2072 |
+
// Build select.
|
2073 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2074 |
+
foreach ( (array) $field_choices as $choice ) {
|
2075 |
+
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
2076 |
+
echo '<option value="' . esc_attr( $choice['value'] ) . '"' . selected( $field_value, $choice['value'], false ) . '>' . esc_attr( $choice['label'] ) . '</option>';
|
2077 |
+
}
|
2078 |
+
}
|
2079 |
|
2080 |
+
echo '</select>';
|
2081 |
|
2082 |
+
echo '</div>';
|
2083 |
|
2084 |
+
echo '</div>';
|
2085 |
+
}
|
2086 |
}
|
2087 |
|
2088 |
+
if ( ! function_exists( 'ot_type_sidebar_select' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2089 |
|
2090 |
+
/**
|
2091 |
+
* Sidebar Select option type.
|
2092 |
+
*
|
2093 |
+
* This option type makes it possible for users to select a WordPress registered sidebar
|
2094 |
+
* to use on a specific area. By using the two provided filters, 'ot_recognized_sidebars',
|
2095 |
+
* and 'ot_recognized_sidebars_{$field_id}' we can be selective about which sidebars are
|
2096 |
+
* available on a specific content area.
|
2097 |
+
*
|
2098 |
+
* For example, if we create a WordPress theme that provides the ability to change the
|
2099 |
+
* Blog Sidebar and we don't want to have the footer sidebars available on this area,
|
2100 |
+
* we can unset those sidebars either manually or by using a regular expression if we
|
2101 |
+
* have a common name like footer-sidebar-$i.
|
2102 |
+
*
|
2103 |
+
* @param array $args An array of arguments.
|
2104 |
+
*
|
2105 |
+
* @access public
|
2106 |
+
* @since 2.1
|
2107 |
+
*/
|
2108 |
+
function ot_type_sidebar_select( $args = array() ) {
|
2109 |
+
|
2110 |
+
// Turns arguments array into variables.
|
2111 |
+
extract( $args ); // phpcs:ignore
|
2112 |
+
|
2113 |
+
// Verify a description.
|
2114 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2115 |
+
|
2116 |
+
// Format setting outer wrapper.
|
2117 |
+
echo '<div class="format-setting type-sidebar-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2118 |
+
|
2119 |
+
// Description.
|
2120 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2121 |
+
|
2122 |
+
// Format setting inner wrapper.
|
2123 |
+
echo '<div class="format-setting-inner">';
|
2124 |
+
|
2125 |
+
// Build page select.
|
2126 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2127 |
+
|
2128 |
+
// Get the registered sidebars.
|
2129 |
+
global $wp_registered_sidebars;
|
2130 |
+
|
2131 |
+
$sidebars = array();
|
2132 |
+
foreach ( $wp_registered_sidebars as $id => $sidebar ) {
|
2133 |
+
$sidebars[ $id ] = $sidebar['name'];
|
2134 |
+
}
|
2135 |
+
|
2136 |
+
// Filters to restrict which sidebars are allowed to be selected, for example we can restrict footer sidebars to be selectable on a blog page.
|
2137 |
+
$sidebars = apply_filters( 'ot_recognized_sidebars', $sidebars );
|
2138 |
+
$sidebars = apply_filters( 'ot_recognized_sidebars_' . $field_id, $sidebars );
|
2139 |
+
|
2140 |
+
// Has sidebars.
|
2141 |
+
if ( count( $sidebars ) ) {
|
2142 |
+
echo '<option value="">-- ' . esc_html__( 'Choose Sidebar', 'option-tree' ) . ' --</option>';
|
2143 |
+
foreach ( $sidebars as $id => $sidebar ) {
|
2144 |
+
echo '<option value="' . esc_attr( $id ) . '" ' . selected( $field_value, $id, false ) . '>' . esc_attr( $sidebar ) . '</option>';
|
2145 |
+
}
|
2146 |
+
} else {
|
2147 |
+
echo '<option value="">' . esc_html__( 'No Sidebars', 'option-tree' ) . '</option>';
|
2148 |
+
}
|
2149 |
+
|
2150 |
+
echo '</select>';
|
2151 |
+
|
2152 |
+
echo '</div>';
|
2153 |
+
|
2154 |
+
echo '</div>';
|
2155 |
+
}
|
2156 |
+
}
|
2157 |
|
2158 |
+
if ( ! function_exists( 'ot_type_slider' ) ) {
|
|
|
2159 |
|
2160 |
+
/**
|
2161 |
+
* List Item option type.
|
2162 |
+
*
|
2163 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2164 |
+
*
|
2165 |
+
* @param array $args An array of arguments.
|
2166 |
+
*
|
2167 |
+
* @access public
|
2168 |
+
* @since 2.0
|
2169 |
+
*/
|
2170 |
+
function ot_type_slider( $args = array() ) {
|
2171 |
|
2172 |
+
// Turns arguments array into variables.
|
2173 |
+
extract( $args ); // phpcs:ignore
|
2174 |
|
2175 |
+
// Verify a description.
|
2176 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2177 |
|
2178 |
+
// Format setting outer wrapper.
|
2179 |
+
echo '<div class="format-setting type-slider ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2180 |
|
2181 |
+
// Description.
|
2182 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2183 |
|
2184 |
+
// Format setting inner wrapper.
|
2185 |
+
echo '<div class="format-setting-inner">';
|
2186 |
|
2187 |
+
// Pass the settings array around.
|
2188 |
+
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . esc_attr( ot_encode( $field_settings ) ) . '" />';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2189 |
|
2190 |
+
/**
|
2191 |
+
* Settings pages have array wrappers like 'option_tree'.
|
2192 |
+
* So we need that value to create a proper array to save to.
|
2193 |
+
* This is only for NON metabox settings.
|
2194 |
+
*/
|
2195 |
+
if ( ! isset( $get_option ) ) {
|
2196 |
+
$get_option = '';
|
2197 |
+
}
|
2198 |
|
2199 |
+
// Build list items.
|
2200 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
2201 |
|
2202 |
+
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
2203 |
|
2204 |
+
foreach ( $field_value as $key => $list_item ) {
|
2205 |
|
2206 |
+
echo '<li class="ui-state-default list-list-item">';
|
2207 |
+
ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type );
|
2208 |
+
echo '</li>';
|
2209 |
+
}
|
2210 |
+
}
|
2211 |
|
2212 |
+
echo '</ul>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2213 |
|
2214 |
+
// Button.
|
2215 |
+
echo '<a href="javascript:void(0);" class="option-tree-list-item-add option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add New', 'option-tree' ) . '">' . esc_html__( 'Add New', 'option-tree' ) . '</a>'; // phpcs:ignore
|
2216 |
|
2217 |
+
// Description.
|
2218 |
+
echo '<div class="list-item-description">' . esc_html__( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) . '</div>';
|
2219 |
|
2220 |
+
echo '</div>';
|
|
|
2221 |
|
2222 |
+
echo '</div>';
|
2223 |
+
}
|
2224 |
+
}
|
2225 |
|
2226 |
+
if ( ! function_exists( 'ot_type_social_links' ) ) {
|
|
|
2227 |
|
2228 |
+
/**
|
2229 |
+
* Social Links option type.
|
2230 |
+
*
|
2231 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2232 |
+
*
|
2233 |
+
* @param array $args An array of arguments.
|
2234 |
+
*
|
2235 |
+
* @access public
|
2236 |
+
* @since 2.4.0
|
2237 |
+
*/
|
2238 |
+
function ot_type_social_links( $args = array() ) {
|
2239 |
+
|
2240 |
+
// Turns arguments array into variables.
|
2241 |
+
extract( $args ); // phpcs:ignore
|
2242 |
+
|
2243 |
+
// Load the default social links.
|
2244 |
+
if ( empty( $field_value ) && apply_filters( 'ot_type_social_links_load_defaults', true, $field_id ) ) {
|
2245 |
+
|
2246 |
+
$field_value = apply_filters(
|
2247 |
+
'ot_type_social_links_defaults',
|
2248 |
+
array(
|
2249 |
+
array(
|
2250 |
+
'name' => __( 'Facebook', 'option-tree' ),
|
2251 |
+
'title' => '',
|
2252 |
+
'href' => '',
|
2253 |
+
),
|
2254 |
+
array(
|
2255 |
+
'name' => __( 'Twitter', 'option-tree' ),
|
2256 |
+
'title' => '',
|
2257 |
+
'href' => '',
|
2258 |
+
),
|
2259 |
+
array(
|
2260 |
+
'name' => __( 'Google+', 'option-tree' ),
|
2261 |
+
'title' => '',
|
2262 |
+
'href' => '',
|
2263 |
+
),
|
2264 |
+
array(
|
2265 |
+
'name' => __( 'LinkedIn', 'option-tree' ),
|
2266 |
+
'title' => '',
|
2267 |
+
'href' => '',
|
2268 |
+
),
|
2269 |
+
array(
|
2270 |
+
'name' => __( 'Pinterest', 'option-tree' ),
|
2271 |
+
'title' => '',
|
2272 |
+
'href' => '',
|
2273 |
+
),
|
2274 |
+
array(
|
2275 |
+
'name' => __( 'Youtube', 'option-tree' ),
|
2276 |
+
'title' => '',
|
2277 |
+
'href' => '',
|
2278 |
+
),
|
2279 |
+
array(
|
2280 |
+
'name' => __( 'Dribbble', 'option-tree' ),
|
2281 |
+
'title' => '',
|
2282 |
+
'href' => '',
|
2283 |
+
),
|
2284 |
+
array(
|
2285 |
+
'name' => __( 'Github', 'option-tree' ),
|
2286 |
+
'title' => '',
|
2287 |
+
'href' => '',
|
2288 |
+
),
|
2289 |
+
array(
|
2290 |
+
'name' => __( 'Forrst', 'option-tree' ),
|
2291 |
+
'title' => '',
|
2292 |
+
'href' => '',
|
2293 |
+
),
|
2294 |
+
array(
|
2295 |
+
'name' => __( 'Digg', 'option-tree' ),
|
2296 |
+
'title' => '',
|
2297 |
+
'href' => '',
|
2298 |
+
),
|
2299 |
+
array(
|
2300 |
+
'name' => __( 'Delicious', 'option-tree' ),
|
2301 |
+
'title' => '',
|
2302 |
+
'href' => '',
|
2303 |
+
),
|
2304 |
+
array(
|
2305 |
+
'name' => __( 'Tumblr', 'option-tree' ),
|
2306 |
+
'title' => '',
|
2307 |
+
'href' => '',
|
2308 |
+
),
|
2309 |
+
array(
|
2310 |
+
'name' => __( 'Skype', 'option-tree' ),
|
2311 |
+
'title' => '',
|
2312 |
+
'href' => '',
|
2313 |
+
),
|
2314 |
+
array(
|
2315 |
+
'name' => __( 'SoundCloud', 'option-tree' ),
|
2316 |
+
'title' => '',
|
2317 |
+
'href' => '',
|
2318 |
+
),
|
2319 |
+
array(
|
2320 |
+
'name' => __( 'Vimeo', 'option-tree' ),
|
2321 |
+
'title' => '',
|
2322 |
+
'href' => '',
|
2323 |
+
),
|
2324 |
+
array(
|
2325 |
+
'name' => __( 'Flickr', 'option-tree' ),
|
2326 |
+
'title' => '',
|
2327 |
+
'href' => '',
|
2328 |
+
),
|
2329 |
+
array(
|
2330 |
+
'name' => __( 'VK.com', 'option-tree' ),
|
2331 |
+
'title' => '',
|
2332 |
+
'href' => '',
|
2333 |
+
),
|
2334 |
+
),
|
2335 |
+
$field_id
|
2336 |
+
);
|
2337 |
+
|
2338 |
+
}
|
2339 |
+
|
2340 |
+
// Verify a description.
|
2341 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2342 |
+
|
2343 |
+
// Format setting outer wrapper.
|
2344 |
+
echo '<div class="format-setting type-social-list-item ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2345 |
+
|
2346 |
+
// Description.
|
2347 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2348 |
+
|
2349 |
+
// Format setting inner wrapper.
|
2350 |
+
echo '<div class="format-setting-inner">';
|
2351 |
+
|
2352 |
+
// Pass the settings array around.
|
2353 |
+
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . esc_attr( ot_encode( $field_settings ) ) . '" />';
|
2354 |
+
|
2355 |
+
/**
|
2356 |
+
* Settings pages have array wrappers like 'option_tree'.
|
2357 |
+
* So we need that value to create a proper array to save to.
|
2358 |
+
* This is only for NON metabox settings.
|
2359 |
+
*/
|
2360 |
+
if ( ! isset( $get_option ) ) {
|
2361 |
+
$get_option = '';
|
2362 |
+
}
|
2363 |
+
|
2364 |
+
// Build list items.
|
2365 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
2366 |
+
|
2367 |
+
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
2368 |
+
|
2369 |
+
foreach ( $field_value as $key => $link ) {
|
2370 |
+
|
2371 |
+
echo '<li class="ui-state-default list-list-item">';
|
2372 |
+
ot_social_links_view( $field_id, $key, $link, $post_id, $get_option, $field_settings );
|
2373 |
+
echo '</li>';
|
2374 |
+
}
|
2375 |
+
}
|
2376 |
+
|
2377 |
+
echo '</ul>';
|
2378 |
+
|
2379 |
+
// Button.
|
2380 |
+
echo '<a href="javascript:void(0);" class="option-tree-social-links-add option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add New', 'option-tree' ) . '">' . esc_html__( 'Add New', 'option-tree' ) . '</a>'; // phpcs:ignore
|
2381 |
+
|
2382 |
+
// Description.
|
2383 |
+
echo '<div class="list-item-description">' . esc_html( apply_filters( 'ot_social_links_description', __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ), $field_id ) ) . '</div>';
|
2384 |
+
|
2385 |
+
echo '</div>';
|
2386 |
+
|
2387 |
+
echo '</div>';
|
2388 |
+
}
|
2389 |
+
}
|
2390 |
|
2391 |
+
if ( ! function_exists( 'ot_type_spacing' ) ) {
|
|
|
2392 |
|
2393 |
+
/**
|
2394 |
+
* Spacing Option Type.
|
2395 |
+
*
|
2396 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2397 |
+
*
|
2398 |
+
* @param array $args An array of arguments.
|
2399 |
+
*
|
2400 |
+
* @access public
|
2401 |
+
* @since 2.5.0
|
2402 |
+
*/
|
2403 |
+
function ot_type_spacing( $args = array() ) {
|
2404 |
|
2405 |
+
// Turns arguments array into variables.
|
2406 |
+
extract( $args ); // phpcs:ignore
|
2407 |
|
2408 |
+
// Verify a description.
|
2409 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2410 |
|
2411 |
+
// Format setting outer wrapper.
|
2412 |
+
echo '<div class="format-setting type-spacing ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2413 |
|
2414 |
+
// Description.
|
2415 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2416 |
|
2417 |
+
// Format setting inner wrapper.
|
2418 |
+
echo '<div class="format-setting-inner">';
|
2419 |
|
2420 |
+
// Allow fields to be filtered.
|
2421 |
+
$ot_recognized_spacing_fields = apply_filters(
|
2422 |
+
'ot_recognized_spacing_fields',
|
2423 |
+
array(
|
2424 |
+
'top',
|
2425 |
+
'right',
|
2426 |
+
'bottom',
|
2427 |
+
'left',
|
2428 |
+
'unit',
|
2429 |
+
),
|
2430 |
+
$field_id
|
2431 |
+
);
|
2432 |
|
2433 |
+
// Build top spacing.
|
2434 |
+
if ( in_array( 'top', $ot_recognized_spacing_fields, true ) ) {
|
2435 |
|
2436 |
+
$top = isset( $field_value['top'] ) ? $field_value['top'] : '';
|
|
|
2437 |
|
2438 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-up ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[top]" id="' . esc_attr( $field_id ) . '-top" value="' . esc_attr( $top ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'top', 'option-tree' ) . '" /></div>';
|
2439 |
+
}
|
2440 |
|
2441 |
+
// Build right spacing.
|
2442 |
+
if ( in_array( 'right', $ot_recognized_spacing_fields, true ) ) {
|
2443 |
|
2444 |
+
$right = isset( $field_value['right'] ) ? $field_value['right'] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2445 |
|
2446 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-right ot-option-group--icon"></span></span><input type="text" name="' . esc_attr( $field_name ) . '[right]" id="' . esc_attr( $field_id ) . '-right" value="' . esc_attr( $right ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'right', 'option-tree' ) . '" /></div>';
|
2447 |
+
}
|
2448 |
|
2449 |
+
// Build bottom spacing.
|
2450 |
+
if ( in_array( 'bottom', $ot_recognized_spacing_fields, true ) ) {
|
2451 |
|
2452 |
+
$bottom = isset( $field_value['bottom'] ) ? $field_value['bottom'] : '';
|
2453 |
|
2454 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-down ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[bottom]" id="' . esc_attr( $field_id ) . '-bottom" value="' . esc_attr( $bottom ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'bottom', 'option-tree' ) . '" /></div>';
|
2455 |
+
}
|
2456 |
|
2457 |
+
// Build left spacing.
|
2458 |
+
if ( in_array( 'left', $ot_recognized_spacing_fields, true ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2459 |
|
2460 |
+
$left = isset( $field_value['left'] ) ? $field_value['left'] : '';
|
2461 |
|
2462 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-left ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[left]" id="' . esc_attr( $field_id ) . '-left" value="' . esc_attr( $left ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'left', 'option-tree' ) . '" /></div>';
|
2463 |
+
}
|
2464 |
|
2465 |
+
// Build unit dropdown.
|
2466 |
+
if ( in_array( 'unit', $ot_recognized_spacing_fields, true ) ) {
|
2467 |
|
2468 |
+
echo '<div class="ot-option-group ot-option-group--is-last">';
|
|
|
2469 |
|
2470 |
+
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
|
|
2471 |
|
2472 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
|
|
2473 |
|
2474 |
+
foreach ( ot_recognized_spacing_unit_types( $field_id ) as $unit ) {
|
2475 |
+
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
2476 |
+
}
|
2477 |
|
2478 |
+
echo '</select>';
|
|
|
|
|
2479 |
|
2480 |
+
echo '</div>';
|
2481 |
+
}
|
2482 |
|
2483 |
+
echo '</div>';
|
2484 |
|
2485 |
+
echo '</div>';
|
2486 |
+
}
|
2487 |
+
}
|
2488 |
|
2489 |
+
if ( ! function_exists( 'ot_type_tab' ) ) {
|
2490 |
|
2491 |
+
/**
|
2492 |
+
* Tab option type.
|
2493 |
+
*
|
2494 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2495 |
+
*
|
2496 |
+
* @access public
|
2497 |
+
* @since 2.3.0
|
2498 |
+
*/
|
2499 |
+
function ot_type_tab() {
|
2500 |
+
echo '<div class="format-setting type-tab"><br /></div>';
|
2501 |
+
}
|
2502 |
}
|
2503 |
|
2504 |
+
if ( ! function_exists( 'ot_type_tag_checkbox' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2505 |
|
2506 |
+
/**
|
2507 |
+
* Tag Checkbox option type.
|
2508 |
+
*
|
2509 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2510 |
+
*
|
2511 |
+
* @param array $args An array of arguments.
|
2512 |
+
*
|
2513 |
+
* @access public
|
2514 |
+
* @since 2.0
|
2515 |
+
*/
|
2516 |
+
function ot_type_tag_checkbox( $args = array() ) {
|
2517 |
+
|
2518 |
+
// Turns arguments array into variables.
|
2519 |
+
extract( $args ); // phpcs:ignore
|
2520 |
+
|
2521 |
+
// Verify a description.
|
2522 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2523 |
+
|
2524 |
+
// Format setting outer wrapper.
|
2525 |
+
echo '<div class="format-setting type-tag-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2526 |
+
|
2527 |
+
// Description.
|
2528 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2529 |
+
|
2530 |
+
// Format setting inner wrapper.
|
2531 |
+
echo '<div class="format-setting-inner">';
|
2532 |
+
|
2533 |
+
// Get tags.
|
2534 |
+
$tags = get_tags( array( 'hide_empty' => false ) );
|
2535 |
+
|
2536 |
+
// Has tags.
|
2537 |
+
if ( $tags ) {
|
2538 |
+
foreach ( $tags as $tag ) {
|
2539 |
+
echo '<p>';
|
2540 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $tag->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $tag->term_id ) . '" value="' . esc_attr( $tag->term_id ) . '" ' . ( isset( $field_value[ $tag->term_id ] ) ? checked( $field_value[ $tag->term_id ], $tag->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
2541 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $tag->term_id ) . '">' . esc_attr( $tag->name ) . '</label>';
|
2542 |
+
echo '</p>';
|
2543 |
+
}
|
2544 |
+
} else {
|
2545 |
+
echo '<p>' . esc_html__( 'No Tags Found', 'option-tree' ) . '</p>';
|
2546 |
+
}
|
2547 |
+
|
2548 |
+
echo '</div>';
|
2549 |
+
|
2550 |
+
echo '</div>';
|
2551 |
+
}
|
2552 |
+
}
|
2553 |
|
2554 |
+
if ( ! function_exists( 'ot_type_tag_select' ) ) {
|
|
|
2555 |
|
2556 |
+
/**
|
2557 |
+
* Tag Select option type.
|
2558 |
+
*
|
2559 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2560 |
+
*
|
2561 |
+
* @param array $args An array of arguments.
|
2562 |
+
*
|
2563 |
+
* @access public
|
2564 |
+
* @since 2.0
|
2565 |
+
*/
|
2566 |
+
function ot_type_tag_select( $args = array() ) {
|
2567 |
|
2568 |
+
// Turns arguments array into variables.
|
2569 |
+
extract( $args ); // phpcs:ignore
|
2570 |
|
2571 |
+
// Verify a description.
|
2572 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2573 |
|
2574 |
+
// Format setting outer wrapper.
|
2575 |
+
echo '<div class="format-setting type-tag-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2576 |
|
2577 |
+
// Description.
|
2578 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2579 |
|
2580 |
+
// Format setting inner wrapper.
|
2581 |
+
echo '<div class="format-setting-inner">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2582 |
|
2583 |
+
// Build tag select.
|
2584 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2585 |
|
2586 |
+
// Get tags.
|
2587 |
+
$tags = get_tags( array( 'hide_empty' => false ) );
|
2588 |
|
2589 |
+
// Has tags.
|
2590 |
+
if ( $tags ) {
|
2591 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
2592 |
+
foreach ( $tags as $tag ) {
|
2593 |
+
echo '<option value="' . esc_attr( $tag->term_id ) . '"' . selected( $field_value, $tag->term_id, false ) . '>' . esc_attr( $tag->name ) . '</option>';
|
2594 |
+
}
|
2595 |
+
} else {
|
2596 |
+
echo '<option value="">' . esc_html__( 'No Tags Found', 'option-tree' ) . '</option>';
|
2597 |
+
}
|
2598 |
|
2599 |
+
echo '</select>';
|
|
|
2600 |
|
2601 |
+
echo '</div>';
|
2602 |
|
2603 |
+
echo '</div>';
|
2604 |
+
}
|
2605 |
+
}
|
2606 |
+
|
2607 |
+
if ( ! function_exists( 'ot_type_taxonomy_checkbox' ) ) {
|
2608 |
|
2609 |
+
/**
|
2610 |
+
* Taxonomy Checkbox option type.
|
2611 |
+
*
|
2612 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2613 |
+
*
|
2614 |
+
* @param array $args An array of arguments.
|
2615 |
+
*
|
2616 |
+
* @access public
|
2617 |
+
* @since 2.0
|
2618 |
+
*/
|
2619 |
+
function ot_type_taxonomy_checkbox( $args = array() ) {
|
2620 |
+
|
2621 |
+
// Turns arguments array into variables.
|
2622 |
+
extract( $args ); // phpcs:ignore
|
2623 |
+
|
2624 |
+
// Verify a description.
|
2625 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2626 |
+
|
2627 |
+
// Format setting outer wrapper.
|
2628 |
+
echo '<div class="format-setting type-taxonomy-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2629 |
+
|
2630 |
+
// Description.
|
2631 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2632 |
+
|
2633 |
+
// Format setting inner wrapper.
|
2634 |
+
echo '<div class="format-setting-inner">';
|
2635 |
+
|
2636 |
+
// Setup the taxonomy.
|
2637 |
+
$taxonomy = isset( $field_taxonomy ) ? explode( ',', $field_taxonomy ) : array( 'category' );
|
2638 |
+
|
2639 |
+
// Get taxonomies.
|
2640 |
+
$taxonomies = get_categories(
|
2641 |
+
apply_filters(
|
2642 |
+
'ot_type_taxonomy_checkbox_query',
|
2643 |
+
array(
|
2644 |
+
'hide_empty' => false,
|
2645 |
+
'taxonomy' => $taxonomy,
|
2646 |
+
),
|
2647 |
+
$field_id
|
2648 |
+
)
|
2649 |
+
);
|
2650 |
+
|
2651 |
+
// Has tags.
|
2652 |
+
if ( $taxonomies ) {
|
2653 |
+
foreach ( $taxonomies as $taxonomy ) {
|
2654 |
+
echo '<p>';
|
2655 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $taxonomy->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $taxonomy->term_id ) . '" value="' . esc_attr( $taxonomy->term_id ) . '" ' . ( isset( $field_value[ $taxonomy->term_id ] ) ? checked( $field_value[ $taxonomy->term_id ], $taxonomy->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
2656 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $taxonomy->term_id ) . '">' . esc_attr( $taxonomy->name ) . '</label>';
|
2657 |
+
echo '</p>';
|
2658 |
+
}
|
2659 |
+
} else {
|
2660 |
+
echo '<p>' . esc_html__( 'No Taxonomies Found', 'option-tree' ) . '</p>';
|
2661 |
+
}
|
2662 |
+
|
2663 |
+
echo '</div>';
|
2664 |
+
|
2665 |
+
echo '</div>';
|
2666 |
+
}
|
2667 |
}
|
2668 |
|
2669 |
+
if ( ! function_exists( 'ot_type_taxonomy_select' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2670 |
|
2671 |
+
/**
|
2672 |
+
* Taxonomy Select option type.
|
2673 |
+
*
|
2674 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2675 |
+
*
|
2676 |
+
* @param array $args An array of arguments.
|
2677 |
+
*
|
2678 |
+
* @access public
|
2679 |
+
* @since 2.0
|
2680 |
+
*/
|
2681 |
+
function ot_type_taxonomy_select( $args = array() ) {
|
2682 |
+
|
2683 |
+
// Turns arguments array into variables.
|
2684 |
+
extract( $args ); // phpcs:ignore
|
2685 |
+
|
2686 |
+
// Verify a description.
|
2687 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2688 |
+
|
2689 |
+
// Format setting outer wrapper.
|
2690 |
+
echo '<div class="format-setting type-tag-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2691 |
+
|
2692 |
+
// Description.
|
2693 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2694 |
+
|
2695 |
+
// Format setting inner wrapper.
|
2696 |
+
echo '<div class="format-setting-inner">';
|
2697 |
+
|
2698 |
+
// Build tag select.
|
2699 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2700 |
+
|
2701 |
+
// Setup the taxonomy.
|
2702 |
+
$taxonomy = isset( $field_taxonomy ) ? explode( ',', $field_taxonomy ) : array( 'category' );
|
2703 |
+
|
2704 |
+
// Get taxonomies.
|
2705 |
+
$taxonomies = get_categories(
|
2706 |
+
apply_filters(
|
2707 |
+
'ot_type_taxonomy_select_query',
|
2708 |
+
array(
|
2709 |
+
'hide_empty' => false,
|
2710 |
+
'taxonomy' => $taxonomy,
|
2711 |
+
),
|
2712 |
+
$field_id
|
2713 |
+
)
|
2714 |
+
);
|
2715 |
+
|
2716 |
+
// Has tags.
|
2717 |
+
if ( $taxonomies ) {
|
2718 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
2719 |
+
foreach ( $taxonomies as $taxonomy ) {
|
2720 |
+
echo '<option value="' . esc_attr( $taxonomy->term_id ) . '"' . selected( $field_value, $taxonomy->term_id, false ) . '>' . esc_attr( $taxonomy->name ) . '</option>';
|
2721 |
+
}
|
2722 |
+
} else {
|
2723 |
+
echo '<option value="">' . esc_html__( 'No Taxonomies Found', 'option-tree' ) . '</option>';
|
2724 |
+
}
|
2725 |
+
|
2726 |
+
echo '</select>';
|
2727 |
+
|
2728 |
+
echo '</div>';
|
2729 |
+
|
2730 |
+
echo '</div>';
|
2731 |
+
}
|
2732 |
+
}
|
2733 |
|
2734 |
+
if ( ! function_exists( 'ot_type_text' ) ) {
|
|
|
2735 |
|
2736 |
+
/**
|
2737 |
+
* Text option type.
|
2738 |
+
*
|
2739 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2740 |
+
*
|
2741 |
+
* @param array $args An array of arguments.
|
2742 |
+
*
|
2743 |
+
* @access public
|
2744 |
+
* @since 2.0
|
2745 |
+
*/
|
2746 |
+
function ot_type_text( $args = array() ) {
|
2747 |
|
2748 |
+
// Turns arguments array into variables.
|
2749 |
+
extract( $args ); // phpcs:ignore
|
2750 |
|
2751 |
+
// Verify a description.
|
2752 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2753 |
|
2754 |
+
// Format setting outer wrapper.
|
2755 |
+
echo '<div class="format-setting type-text ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2756 |
|
2757 |
+
// Description.
|
2758 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2759 |
|
2760 |
+
// Format setting inner wrapper.
|
2761 |
+
echo '<div class="format-setting-inner">';
|
2762 |
|
2763 |
+
// Build text input.
|
2764 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" />';
|
2765 |
|
2766 |
+
echo '</div>';
|
|
|
2767 |
|
2768 |
+
echo '</div>';
|
2769 |
+
}
|
2770 |
+
}
|
2771 |
|
2772 |
+
if ( ! function_exists( 'ot_type_textarea' ) ) {
|
|
|
2773 |
|
2774 |
+
/**
|
2775 |
+
* Textarea option type.
|
2776 |
+
*
|
2777 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2778 |
+
*
|
2779 |
+
* @param array $args An array of arguments.
|
2780 |
+
*
|
2781 |
+
* @access public
|
2782 |
+
* @since 2.0
|
2783 |
+
*/
|
2784 |
+
function ot_type_textarea( $args = array() ) {
|
2785 |
+
|
2786 |
+
// Turns arguments array into variables.
|
2787 |
+
extract( $args ); // phpcs:ignore
|
2788 |
+
|
2789 |
+
// Verify a description.
|
2790 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2791 |
+
|
2792 |
+
// Format setting outer wrapper.
|
2793 |
+
echo '<div class="format-setting type-textarea ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . ' fill-area">';
|
2794 |
+
|
2795 |
+
// Description.
|
2796 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2797 |
+
|
2798 |
+
// Format setting inner wrapper.
|
2799 |
+
echo '<div class="format-setting-inner">';
|
2800 |
+
|
2801 |
+
// Build textarea.
|
2802 |
+
wp_editor(
|
2803 |
+
$field_value,
|
2804 |
+
esc_attr( $field_id ),
|
2805 |
+
array(
|
2806 |
+
'editor_class' => esc_attr( $field_class ),
|
2807 |
+
'wpautop' => apply_filters( 'ot_wpautop', false, $field_id ),
|
2808 |
+
'media_buttons' => apply_filters( 'ot_media_buttons', true, $field_id ),
|
2809 |
+
'textarea_name' => esc_attr( $field_name ),
|
2810 |
+
'textarea_rows' => esc_attr( $field_rows ),
|
2811 |
+
'tinymce' => apply_filters( 'ot_tinymce', true, $field_id ),
|
2812 |
+
'quicktags' => apply_filters( 'ot_quicktags', array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ), $field_id ),
|
2813 |
+
)
|
2814 |
+
);
|
2815 |
+
|
2816 |
+
echo '</div>';
|
2817 |
+
|
2818 |
+
echo '</div>';
|
2819 |
+
}
|
2820 |
+
}
|
2821 |
|
2822 |
+
if ( ! function_exists( 'ot_type_textarea_simple' ) ) {
|
2823 |
|
2824 |
+
/**
|
2825 |
+
* Textarea Simple option type.
|
2826 |
+
*
|
2827 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2828 |
+
*
|
2829 |
+
* @param array $args An array of arguments.
|
2830 |
+
*
|
2831 |
+
* @access public
|
2832 |
+
* @since 2.0
|
2833 |
+
*/
|
2834 |
+
function ot_type_textarea_simple( $args = array() ) {
|
2835 |
|
2836 |
+
// Turns arguments array into variables.
|
2837 |
+
extract( $args ); // phpcs:ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2838 |
|
2839 |
+
// Verify a description.
|
2840 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2841 |
|
2842 |
+
// Format setting outer wrapper.
|
2843 |
+
echo '<div class="format-setting type-textarea simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2844 |
|
2845 |
+
// Description.
|
2846 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2847 |
|
2848 |
+
// Format setting inner wrapper.
|
2849 |
+
echo '<div class="format-setting-inner">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2850 |
|
2851 |
+
// Filter to allow wpautop.
|
2852 |
+
$wpautop = apply_filters( 'ot_wpautop', false, $field_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2853 |
|
2854 |
+
// Wpautop $field_value.
|
2855 |
+
if ( true === $wpautop ) {
|
2856 |
+
$field_value = wpautop( $field_value );
|
2857 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2858 |
|
2859 |
+
// Build textarea simple.
|
2860 |
+
echo '<textarea class="textarea ' . esc_attr( $field_class ) . '" rows="' . esc_attr( $field_rows ) . '" cols="40" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '">' . esc_textarea( $field_value ) . '</textarea>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2861 |
|
2862 |
+
echo '</div>';
|
2863 |
|
2864 |
+
echo '</div>';
|
2865 |
+
}
|
2866 |
+
}
|
2867 |
|
2868 |
+
if ( ! function_exists( 'ot_type_textblock' ) ) {
|
2869 |
|
2870 |
+
/**
|
2871 |
+
* Textblock option type.
|
2872 |
+
*
|
2873 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2874 |
+
*
|
2875 |
+
* @param array $args An array of arguments.
|
2876 |
+
*
|
2877 |
+
* @access public
|
2878 |
+
* @since 2.0
|
2879 |
+
*/
|
2880 |
+
function ot_type_textblock( $args = array() ) {
|
2881 |
+
|
2882 |
+
// Turns arguments array into variables.
|
2883 |
+
extract( $args ); // phpcs:ignore
|
2884 |
+
|
2885 |
+
// Format setting outer wrapper.
|
2886 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
2887 |
+
|
2888 |
+
// Description.
|
2889 |
+
echo '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>';
|
2890 |
+
|
2891 |
+
echo '</div>';
|
2892 |
+
}
|
2893 |
}
|
2894 |
|
2895 |
+
if ( ! function_exists( 'ot_type_textblock_titled' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2896 |
|
2897 |
+
/**
|
2898 |
+
* Textblock Titled option type.
|
2899 |
+
*
|
2900 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2901 |
+
*
|
2902 |
+
* @param array $args An array of arguments.
|
2903 |
+
*
|
2904 |
+
* @access public
|
2905 |
+
* @since 2.0
|
2906 |
+
*/
|
2907 |
+
function ot_type_textblock_titled( $args = array() ) {
|
2908 |
+
|
2909 |
+
// Turns arguments array into variables.
|
2910 |
+
extract( $args ); // phpcs:ignore
|
2911 |
+
|
2912 |
+
// Format setting outer wrapper.
|
2913 |
+
echo '<div class="format-setting type-textblock titled wide-desc">';
|
2914 |
+
|
2915 |
+
// Description.
|
2916 |
+
echo '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>';
|
2917 |
+
|
2918 |
+
echo '</div>';
|
2919 |
+
}
|
2920 |
+
}
|
2921 |
|
2922 |
+
if ( ! function_exists( 'ot_type_typography' ) ) {
|
|
|
2923 |
|
2924 |
+
/**
|
2925 |
+
* Typography option type.
|
2926 |
+
*
|
2927 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2928 |
+
*
|
2929 |
+
* @param array $args An array of arguments.
|
2930 |
+
*
|
2931 |
+
* @access public
|
2932 |
+
* @since 2.0
|
2933 |
+
*/
|
2934 |
+
function ot_type_typography( $args = array() ) {
|
2935 |
+
|
2936 |
+
// Turns arguments array into variables.
|
2937 |
+
extract( $args ); // phpcs:ignore
|
2938 |
+
|
2939 |
+
// Verify a description.
|
2940 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2941 |
+
|
2942 |
+
// Format setting outer wrapper.
|
2943 |
+
echo '<div class="format-setting type-typography ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2944 |
+
|
2945 |
+
// Description.
|
2946 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2947 |
+
|
2948 |
+
// Format setting inner wrapper.
|
2949 |
+
echo '<div class="format-setting-inner">';
|
2950 |
+
|
2951 |
+
// Allow fields to be filtered.
|
2952 |
+
$ot_recognized_typography_fields = apply_filters(
|
2953 |
+
'ot_recognized_typography_fields',
|
2954 |
+
array(
|
2955 |
+
'font-color',
|
2956 |
+
'font-family',
|
2957 |
+
'font-size',
|
2958 |
+
'font-style',
|
2959 |
+
'font-variant',
|
2960 |
+
'font-weight',
|
2961 |
+
'letter-spacing',
|
2962 |
+
'line-height',
|
2963 |
+
'text-decoration',
|
2964 |
+
'text-transform',
|
2965 |
+
),
|
2966 |
+
$field_id
|
2967 |
+
);
|
2968 |
+
|
2969 |
+
// Build font color.
|
2970 |
+
if ( in_array( 'font-color', $ot_recognized_typography_fields, true ) ) {
|
2971 |
+
|
2972 |
+
// Build colorpicker.
|
2973 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
2974 |
+
|
2975 |
+
// Colorpicker JS.
|
2976 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
2977 |
+
|
2978 |
+
// Set background color.
|
2979 |
+
$background_color = isset( $field_value['font-color'] ) ? esc_attr( $field_value['font-color'] ) : '';
|
2980 |
+
|
2981 |
+
/* input */
|
2982 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[font-color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $background_color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
2983 |
+
|
2984 |
+
echo '</div>';
|
2985 |
+
}
|
2986 |
+
|
2987 |
+
// Build font family.
|
2988 |
+
if ( in_array( 'font-family', $ot_recognized_typography_fields, true ) ) {
|
2989 |
+
$font_family = isset( $field_value['font-family'] ) ? $field_value['font-family'] : '';
|
2990 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-family]" id="' . esc_attr( $field_id ) . '-font-family" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2991 |
+
echo '<option value="">font-family</option>';
|
2992 |
+
foreach ( ot_recognized_font_families( $field_id ) as $key => $value ) {
|
2993 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_family, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
2994 |
+
}
|
2995 |
+
echo '</select>';
|
2996 |
+
}
|
2997 |
+
|
2998 |
+
// Build font size.
|
2999 |
+
if ( in_array( 'font-size', $ot_recognized_typography_fields, true ) ) {
|
3000 |
+
$font_size = isset( $field_value['font-size'] ) ? esc_attr( $field_value['font-size'] ) : '';
|
3001 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-size]" id="' . esc_attr( $field_id ) . '-font-size" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3002 |
+
echo '<option value="">font-size</option>';
|
3003 |
+
foreach ( ot_recognized_font_sizes( $field_id ) as $option ) {
|
3004 |
+
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $font_size, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3005 |
+
}
|
3006 |
+
echo '</select>';
|
3007 |
+
}
|
3008 |
+
|
3009 |
+
// Build font style.
|
3010 |
+
if ( in_array( 'font-style', $ot_recognized_typography_fields, true ) ) {
|
3011 |
+
$font_style = isset( $field_value['font-style'] ) ? esc_attr( $field_value['font-style'] ) : '';
|
3012 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-style]" id="' . esc_attr( $field_id ) . '-font-style" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3013 |
+
echo '<option value="">font-style</option>';
|
3014 |
+
foreach ( ot_recognized_font_styles( $field_id ) as $key => $value ) {
|
3015 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_style, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3016 |
+
}
|
3017 |
+
echo '</select>';
|
3018 |
+
}
|
3019 |
+
|
3020 |
+
// Build font variant.
|
3021 |
+
if ( in_array( 'font-variant', $ot_recognized_typography_fields, true ) ) {
|
3022 |
+
$font_variant = isset( $field_value['font-variant'] ) ? esc_attr( $field_value['font-variant'] ) : '';
|
3023 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-variant]" id="' . esc_attr( $field_id ) . '-font-variant" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3024 |
+
echo '<option value="">font-variant</option>';
|
3025 |
+
foreach ( ot_recognized_font_variants( $field_id ) as $key => $value ) {
|
3026 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_variant, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3027 |
+
}
|
3028 |
+
echo '</select>';
|
3029 |
+
}
|
3030 |
+
|
3031 |
+
// Build font weight.
|
3032 |
+
if ( in_array( 'font-weight', $ot_recognized_typography_fields, true ) ) {
|
3033 |
+
$font_weight = isset( $field_value['font-weight'] ) ? esc_attr( $field_value['font-weight'] ) : '';
|
3034 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-weight]" id="' . esc_attr( $field_id ) . '-font-weight" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3035 |
+
echo '<option value="">font-weight</option>';
|
3036 |
+
foreach ( ot_recognized_font_weights( $field_id ) as $key => $value ) {
|
3037 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_weight, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3038 |
+
}
|
3039 |
+
echo '</select>';
|
3040 |
+
}
|
3041 |
+
|
3042 |
+
// Build letter spacing.
|
3043 |
+
if ( in_array( 'letter-spacing', $ot_recognized_typography_fields, true ) ) {
|
3044 |
+
$letter_spacing = isset( $field_value['letter-spacing'] ) ? esc_attr( $field_value['letter-spacing'] ) : '';
|
3045 |
+
echo '<select name="' . esc_attr( $field_name ) . '[letter-spacing]" id="' . esc_attr( $field_id ) . '-letter-spacing" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3046 |
+
echo '<option value="">letter-spacing</option>';
|
3047 |
+
foreach ( ot_recognized_letter_spacing( $field_id ) as $option ) {
|
3048 |
+
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $letter_spacing, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3049 |
+
}
|
3050 |
+
echo '</select>';
|
3051 |
+
}
|
3052 |
+
|
3053 |
+
// Build line height.
|
3054 |
+
if ( in_array( 'line-height', $ot_recognized_typography_fields, true ) ) {
|
3055 |
+
$line_height = isset( $field_value['line-height'] ) ? esc_attr( $field_value['line-height'] ) : '';
|
3056 |
+
echo '<select name="' . esc_attr( $field_name ) . '[line-height]" id="' . esc_attr( $field_id ) . '-line-height" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3057 |
+
echo '<option value="">line-height</option>';
|
3058 |
+
foreach ( ot_recognized_line_heights( $field_id ) as $option ) {
|
3059 |
+
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $line_height, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3060 |
+
}
|
3061 |
+
echo '</select>';
|
3062 |
+
}
|
3063 |
+
|
3064 |
+
// Build text decoration.
|
3065 |
+
if ( in_array( 'text-decoration', $ot_recognized_typography_fields, true ) ) {
|
3066 |
+
$text_decoration = isset( $field_value['text-decoration'] ) ? esc_attr( $field_value['text-decoration'] ) : '';
|
3067 |
+
echo '<select name="' . esc_attr( $field_name ) . '[text-decoration]" id="' . esc_attr( $field_id ) . '-text-decoration" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3068 |
+
echo '<option value="">text-decoration</option>';
|
3069 |
+
foreach ( ot_recognized_text_decorations( $field_id ) as $key => $value ) {
|
3070 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $text_decoration, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3071 |
+
}
|
3072 |
+
echo '</select>';
|
3073 |
+
}
|
3074 |
+
|
3075 |
+
// Build text transform.
|
3076 |
+
if ( in_array( 'text-transform', $ot_recognized_typography_fields, true ) ) {
|
3077 |
+
$text_transform = isset( $field_value['text-transform'] ) ? esc_attr( $field_value['text-transform'] ) : '';
|
3078 |
+
echo '<select name="' . esc_attr( $field_name ) . '[text-transform]" id="' . esc_attr( $field_id ) . '-text-transform" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3079 |
+
echo '<option value="">text-transform</option>';
|
3080 |
+
foreach ( ot_recognized_text_transformations( $field_id ) as $key => $value ) {
|
3081 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $text_transform, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3082 |
+
}
|
3083 |
+
echo '</select>';
|
3084 |
+
}
|
3085 |
+
|
3086 |
+
echo '</div>';
|
3087 |
+
|
3088 |
+
echo '</div>';
|
3089 |
+
|
3090 |
+
}
|
3091 |
+
}
|
3092 |
|
3093 |
+
if ( ! function_exists( 'ot_type_upload' ) ) {
|
|
|
3094 |
|
3095 |
+
/**
|
3096 |
+
* Upload option type.
|
3097 |
+
*
|
3098 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
3099 |
+
*
|
3100 |
+
* @param array $args An array of arguments.
|
3101 |
+
*
|
3102 |
+
* @access public
|
3103 |
+
* @since 2.0
|
3104 |
+
*/
|
3105 |
+
function ot_type_upload( $args = array() ) {
|
3106 |
|
3107 |
+
// Turns arguments array into variables.
|
3108 |
+
extract( $args ); // phpcs:ignore
|
3109 |
|
3110 |
+
// Verify a description.
|
3111 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
3112 |
|
3113 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
3114 |
+
if ( $field_value && wp_attachment_is_image( $field_value ) ) {
|
3115 |
|
3116 |
+
$attachment_data = wp_get_attachment_image_src( $field_value, 'original' );
|
3117 |
|
3118 |
+
// Check for attachment data.
|
3119 |
+
if ( $attachment_data ) {
|
3120 |
|
3121 |
+
$field_src = $attachment_data[0];
|
3122 |
+
}
|
3123 |
+
}
|
3124 |
|
3125 |
+
// Format setting outer wrapper.
|
3126 |
+
echo '<div class="format-setting type-upload ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
3127 |
|
3128 |
+
// Description.
|
3129 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : ''; // phpcs:ignore
|
3130 |
|
3131 |
+
// Format setting inner wrapper.
|
3132 |
+
echo '<div class="format-setting-inner">';
|
3133 |
|
3134 |
+
// Build upload.
|
3135 |
+
echo '<div class="option-tree-ui-upload-parent">';
|
3136 |
|
3137 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-upload-input ' . esc_attr( $field_class ) . '" />';
|
3138 |
|
3139 |
+
// Add media button.
|
3140 |
+
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . esc_attr( $post_id ) . '" title="' . esc_html__( 'Add Media', 'option-tree' ) . '"><span class="icon ot-icon-plus-circle"></span>' . esc_html__( 'Add Media', 'option-tree' ) . '</a>'; // phpcs:ignore
|
3141 |
|
3142 |
+
echo '</div>';
|
3143 |
|
3144 |
+
// Media.
|
3145 |
+
if ( $field_value ) {
|
|
|
3146 |
|
3147 |
+
echo '<div class="option-tree-ui-media-wrap" id="' . esc_attr( $field_id ) . '_media">';
|
|
|
3148 |
|
3149 |
+
// Replace image src.
|
3150 |
+
if ( isset( $field_src ) ) {
|
3151 |
+
$field_value = $field_src;
|
3152 |
+
}
|
3153 |
|
3154 |
+
if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value ) ) {
|
3155 |
+
echo '<div class="option-tree-ui-image-wrap"><img src="' . esc_url( $field_value ) . '" alt="" /></div>';
|
3156 |
+
}
|
3157 |
|
3158 |
+
echo '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Media', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"></span>' . esc_html__( 'Remove Media', 'option-tree' ) . '</a>';
|
3159 |
|
3160 |
+
echo '</div>';
|
3161 |
|
3162 |
+
}
|
3163 |
|
3164 |
+
echo '</div>';
|
3165 |
|
3166 |
+
echo '</div>';
|
3167 |
+
}
|
3168 |
}
|
3169 |
|
3170 |
|
3225 |
}
|
3226 |
|
3227 |
}
|
|
|
|
|
|
|
|
|
|
admin/includes/ot-functions-settings-page.php
CHANGED
@@ -1,575 +1,487 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* OptionTree
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
* @return string
|
15 |
-
*
|
16 |
-
* @access public
|
17 |
-
* @since 2.0
|
18 |
-
*/
|
19 |
-
if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
|
20 |
-
|
21 |
-
function ot_type_theme_options_ui() {
|
22 |
-
global $blog_id;
|
23 |
-
|
24 |
-
echo '<form method="post" id="option-tree-settings-form">';
|
25 |
-
|
26 |
-
/* form nonce */
|
27 |
-
wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
|
28 |
-
|
29 |
-
/* format setting outer wrapper */
|
30 |
-
echo '<div class="format-setting type-textblock has-desc">';
|
31 |
-
|
32 |
-
/* description */
|
33 |
-
echo '<div class="description">';
|
34 |
-
|
35 |
-
echo '<h4>'. __( 'Warning!', 'option-tree' ) . '</h4>';
|
36 |
-
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, apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) . '"><code>Appearance->Theme Options</code></a>' ) . '</p>';
|
37 |
-
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>';
|
38 |
-
echo '<h4>'. __( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
|
39 |
-
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>';
|
40 |
-
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>';
|
41 |
-
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>';
|
42 |
-
|
43 |
-
echo '</div>';
|
44 |
-
|
45 |
-
/* get the saved settings */
|
46 |
-
$settings = get_option( ot_settings_id() );
|
47 |
-
|
48 |
-
/* wrap settings array */
|
49 |
-
echo '<div class="format-setting-inner">';
|
50 |
-
|
51 |
-
/* set count to zero */
|
52 |
-
$count = 0;
|
53 |
-
|
54 |
-
/* loop through each section and its settings */
|
55 |
-
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="' . ot_settings_id() . '[settings]">';
|
56 |
-
|
57 |
-
if ( isset( $settings['sections'] ) ) {
|
58 |
-
|
59 |
-
foreach( $settings['sections'] as $section ) {
|
60 |
-
|
61 |
-
/* section */
|
62 |
-
echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '</li>';
|
63 |
-
|
64 |
-
/* increment item count */
|
65 |
-
$count++;
|
66 |
-
|
67 |
-
/* settings in this section */
|
68 |
-
if ( isset( $settings['settings'] ) ) {
|
69 |
-
|
70 |
-
foreach( $settings['settings'] as $setting ) {
|
71 |
-
|
72 |
-
if ( isset( $setting['section'] ) && $setting['section'] == $section['id'] ) {
|
73 |
-
|
74 |
-
echo '<li class="ui-state-default list-setting">' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '</li>';
|
75 |
-
|
76 |
-
/* increment item count */
|
77 |
-
$count++;
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
-
}
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
echo '</ul>';
|
90 |
-
|
91 |
-
/* buttons */
|
92 |
-
echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button button hug-left">' . __( 'Add Section', 'option-tree' ) . '</a>';
|
93 |
-
echo '<a href="javascript:void(0);" class="option-tree-setting-add option-tree-ui-button button">' . __( 'Add Setting', 'option-tree' ) . '</a>';
|
94 |
-
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
|
95 |
-
|
96 |
-
/* sidebar textarea */
|
97 |
-
echo '
|
98 |
-
<div class="format-setting-label" id="contextual-help-label">
|
99 |
-
<h3 class="label">' . __( 'Contextual Help', 'option-tree' ) . '</h3>
|
100 |
-
</div>
|
101 |
-
<div class="format-settings" id="contextual-help-setting">
|
102 |
-
<div class="format-setting type-textarea no-desc">
|
103 |
-
<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>
|
104 |
-
<div class="format-setting-inner">
|
105 |
-
<textarea class="textarea" rows="10" cols="40" name="' . ot_settings_id(). '[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
|
106 |
-
</div>
|
107 |
-
</div>
|
108 |
-
</div>';
|
109 |
-
|
110 |
-
/* set count to zero */
|
111 |
-
$count = 0;
|
112 |
-
|
113 |
-
/* loop through each contextual_help content section */
|
114 |
-
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="' . ot_settings_id(). '[contextual_help][content]">';
|
115 |
-
|
116 |
-
if ( isset( $settings['contextual_help']['content'] ) ) {
|
117 |
-
|
118 |
-
foreach( $settings['contextual_help']['content'] as $content ) {
|
119 |
-
|
120 |
-
/* content */
|
121 |
-
echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]', $count, $content ) . '</li>';
|
122 |
-
|
123 |
-
/* increment content count */
|
124 |
-
$count++;
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
echo '</ul>';
|
131 |
-
|
132 |
-
echo '<a href="javascript:void(0);" class="option-tree-help-add option-tree-ui-button button hug-left">' . __( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
|
133 |
-
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
|
134 |
-
|
135 |
-
echo '</div>';
|
136 |
-
|
137 |
-
echo '</div>';
|
138 |
-
|
139 |
-
echo '</form>';
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
-
/**
|
204 |
-
* Import Settings option type.
|
205 |
-
*
|
206 |
-
* @return string
|
207 |
-
*
|
208 |
-
* @access public
|
209 |
-
* @since 2.0
|
210 |
-
*/
|
211 |
if ( ! function_exists( 'ot_type_import_settings' ) ) {
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
|
|
|
|
|
|
246 |
}
|
247 |
|
248 |
-
/**
|
249 |
-
* Import Data option type.
|
250 |
-
*
|
251 |
-
* @return string
|
252 |
-
*
|
253 |
-
* @access public
|
254 |
-
* @since 2.0
|
255 |
-
*/
|
256 |
if ( ! function_exists( 'ot_type_import_data' ) ) {
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
293 |
}
|
294 |
|
295 |
-
/**
|
296 |
-
* Import Layouts option type.
|
297 |
-
*
|
298 |
-
* @return string
|
299 |
-
*
|
300 |
-
* @access public
|
301 |
-
* @since 2.0
|
302 |
-
*/
|
303 |
if ( ! function_exists( 'ot_type_import_layouts' ) ) {
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
340 |
}
|
341 |
|
342 |
-
/**
|
343 |
-
* Export Settings File option type.
|
344 |
-
*
|
345 |
-
* @return string
|
346 |
-
*
|
347 |
-
* @access public
|
348 |
-
* @since 2.0.8
|
349 |
-
*/
|
350 |
if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
385 |
}
|
386 |
|
387 |
-
/**
|
388 |
-
* Export Settings option type.
|
389 |
-
*
|
390 |
-
* @return string
|
391 |
-
*
|
392 |
-
* @access public
|
393 |
-
* @since 2.0
|
394 |
-
*/
|
395 |
if ( ! function_exists( 'ot_type_export_settings' ) ) {
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
}
|
422 |
|
423 |
-
/**
|
424 |
-
* Export Data option type.
|
425 |
-
*
|
426 |
-
* @return string
|
427 |
-
*
|
428 |
-
* @access public
|
429 |
-
* @since 2.0
|
430 |
-
*/
|
431 |
if ( ! function_exists( 'ot_type_export_data' ) ) {
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
}
|
458 |
|
459 |
-
/**
|
460 |
-
* Export Layouts option type.
|
461 |
-
*
|
462 |
-
* @return string
|
463 |
-
*
|
464 |
-
* @access public
|
465 |
-
* @since 2.0
|
466 |
-
*/
|
467 |
if ( ! function_exists( 'ot_type_export_layouts' ) ) {
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
|
496 |
-
/**
|
497 |
-
* Modify Layouts option type.
|
498 |
-
*
|
499 |
-
* @return string
|
500 |
-
*
|
501 |
-
* @access public
|
502 |
-
* @since 2.0
|
503 |
-
*/
|
504 |
if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
|
505 |
-
|
506 |
-
function ot_type_modify_layouts() {
|
507 |
-
|
508 |
-
echo '<form method="post" id="option-tree-settings-form">';
|
509 |
-
|
510 |
-
/* form nonce */
|
511 |
-
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
512 |
-
|
513 |
-
/* format setting outer wrapper */
|
514 |
-
echo '<div class="format-setting type-textarea has-desc">';
|
515 |
-
|
516 |
-
/* description */
|
517 |
-
echo '<div class="description">';
|
518 |
-
|
519 |
-
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>';
|
520 |
-
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>';
|
521 |
-
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>';
|
522 |
-
if ( OT_SHOW_DOCS ) 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>';
|
523 |
-
|
524 |
-
echo '</div>';
|
525 |
-
|
526 |
-
echo '<div class="format-setting-inner">';
|
527 |
-
|
528 |
-
/* get the saved layouts */
|
529 |
-
$layouts = get_option( ot_layouts_id() );
|
530 |
-
|
531 |
-
/* set active layout */
|
532 |
-
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
533 |
-
|
534 |
-
echo '<input type="hidden" name="' . ot_layouts_id() . '[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
|
535 |
-
|
536 |
-
/* add new layout */
|
537 |
-
echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
538 |
-
|
539 |
-
/* loop through each layout */
|
540 |
-
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
|
541 |
-
|
542 |
-
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
543 |
-
|
544 |
-
foreach( $layouts as $key => $data ) {
|
545 |
-
|
546 |
-
/* skip active layout array */
|
547 |
-
if ( $key == 'active_layout' )
|
548 |
-
continue;
|
549 |
-
|
550 |
-
/* content */
|
551 |
-
echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>';
|
552 |
-
|
553 |
-
}
|
554 |
-
|
555 |
-
}
|
556 |
-
|
557 |
-
echo '</ul>';
|
558 |
-
|
559 |
-
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Layouts', 'option-tree' ) . '</button>';
|
560 |
-
|
561 |
-
echo '</div>';
|
562 |
-
|
563 |
-
echo '</div>';
|
564 |
-
|
565 |
-
echo '</form>';
|
566 |
-
|
567 |
-
}
|
568 |
-
|
569 |
-
}
|
570 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
|
|
|
|
|
572 |
|
|
|
573 |
|
574 |
-
|
575 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Settings Page Functions.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
11 |
|
12 |
+
if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Create option type.
|
16 |
+
*
|
17 |
+
* @access public
|
18 |
+
* @since 2.0
|
19 |
+
*/
|
20 |
+
function ot_type_theme_options_ui() {
|
21 |
+
global $blog_id;
|
22 |
+
|
23 |
+
echo '<form method="post" id="option-tree-settings-form">';
|
24 |
+
|
25 |
+
// Form nonce.
|
26 |
+
wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
|
27 |
+
|
28 |
+
// Format setting outer wrapper.
|
29 |
+
echo '<div class="format-setting type-textblock has-desc">';
|
30 |
+
|
31 |
+
// Description.
|
32 |
+
echo '<div class="description">';
|
33 |
+
|
34 |
+
echo '<h4>' . esc_html__( 'Warning!', 'option-tree' ) . '</h4>';
|
35 |
+
|
36 |
+
/* translators: %s: link to theme options */
|
37 |
+
$string = esc_html__( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' );
|
38 |
+
echo '<p class="warning">' . sprintf( $string, '<a href="' . esc_url_raw( get_admin_url( $blog_id, apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) . '"><code>' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '</code></a>' ) . '</p>'; // phpcs:ignore
|
39 |
+
|
40 |
+
/* translators: %s: link to documentation */
|
41 |
+
$string = esc_html__( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' );
|
42 |
+
echo '<p class="warning">' . sprintf( $string, '<a href="' . esc_url_raw( get_admin_url( $blog_id, 'admin.php?page=ot-documentation' ) ) . '"><code>' . esc_html__( 'OptionTree->Documentation', 'option-tree' ) . '</code></a>' ) . '</p>'; // phpcs:ignore
|
43 |
+
|
44 |
+
echo '<h4>' . esc_html__( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
|
45 |
+
echo '<p class="warning">' . esc_html__( '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>';
|
46 |
+
echo '<p>' . esc_html__( '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>';
|
47 |
+
echo '<p>' . esc_html__( '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>';
|
48 |
+
|
49 |
+
echo '</div>';
|
50 |
+
|
51 |
+
// Get the saved settings.
|
52 |
+
$settings = get_option( ot_settings_id() );
|
53 |
+
|
54 |
+
// Wrap settings array.
|
55 |
+
echo '<div class="format-setting-inner">';
|
56 |
+
|
57 |
+
// Set count to zero.
|
58 |
+
$count = 0;
|
59 |
+
|
60 |
+
// Loop through each section and its settings.
|
61 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="' . esc_attr( ot_settings_id() ) . '[settings]">';
|
62 |
+
|
63 |
+
if ( isset( $settings['sections'] ) ) {
|
64 |
+
|
65 |
+
foreach ( $settings['sections'] as $section ) {
|
66 |
+
|
67 |
+
// Section.
|
68 |
+
echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '</li>'; // phpcs:ignore
|
69 |
+
|
70 |
+
// Increment item count.
|
71 |
+
$count++;
|
72 |
+
|
73 |
+
// Settings in this section.
|
74 |
+
if ( isset( $settings['settings'] ) ) {
|
75 |
+
|
76 |
+
foreach ( $settings['settings'] as $setting ) {
|
77 |
+
|
78 |
+
if ( isset( $setting['section'] ) && $setting['section'] === $section['id'] ) {
|
79 |
+
|
80 |
+
echo '<li class="ui-state-default list-setting">' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '</li>'; // phpcs:ignore
|
81 |
+
|
82 |
+
// Increment item count.
|
83 |
+
$count++;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
echo '</ul>';
|
91 |
+
|
92 |
+
// Buttons.
|
93 |
+
echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Section', 'option-tree' ) . '</a>';
|
94 |
+
echo '<a href="javascript:void(0);" class="option-tree-setting-add option-tree-ui-button button">' . esc_html__( 'Add Setting', 'option-tree' ) . '</a>';
|
95 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Changes', 'option-tree' ) . '</button>';
|
96 |
+
|
97 |
+
// Sidebar textarea.
|
98 |
+
echo '
|
99 |
+
<div class="format-setting-label" id="contextual-help-label">
|
100 |
+
<h3 class="label">' . esc_html__( 'Contextual Help', 'option-tree' ) . '</h3>
|
101 |
+
</div>
|
102 |
+
<div class="format-settings" id="contextual-help-setting">
|
103 |
+
<div class="format-setting type-textarea no-desc">
|
104 |
+
<div class="description"><strong>' . esc_html__( 'Contextual Help Sidebar', 'option-tree' ) . '</strong>: ' . esc_html__( '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>
|
105 |
+
<div class="format-setting-inner">
|
106 |
+
<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( ot_settings_id() ) . '[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
</div>';
|
110 |
+
|
111 |
+
// Set count to zero.
|
112 |
+
$count = 0;
|
113 |
+
|
114 |
+
// Loop through each contextual_help content section.
|
115 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="' . esc_attr( ot_settings_id() ) . '[contextual_help][content]">';
|
116 |
+
|
117 |
+
if ( isset( $settings['contextual_help']['content'] ) ) {
|
118 |
+
|
119 |
+
foreach ( $settings['contextual_help']['content'] as $content ) {
|
120 |
+
|
121 |
+
// Content.
|
122 |
+
echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]', $count, $content ) . '</li>'; // phpcs:ignore
|
123 |
+
|
124 |
+
// Increment content count.
|
125 |
+
$count++;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
echo '</ul>';
|
130 |
+
|
131 |
+
echo '<a href="javascript:void(0);" class="option-tree-help-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
|
132 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Changes', 'option-tree' ) . '</button>';
|
133 |
+
|
134 |
+
echo '</div>';
|
135 |
+
|
136 |
+
echo '</div>';
|
137 |
+
|
138 |
+
echo '</form>';
|
139 |
+
}
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
if ( ! function_exists( 'ot_type_import_settings' ) ) {
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Import Settings option type.
|
146 |
+
*
|
147 |
+
* @access public
|
148 |
+
* @since 2.0
|
149 |
+
*/
|
150 |
+
function ot_type_import_settings() {
|
151 |
+
|
152 |
+
echo '<form method="post" id="import-settings-form">';
|
153 |
+
|
154 |
+
// Form nonce.
|
155 |
+
wp_nonce_field( 'import_settings_form', 'import_settings_nonce' );
|
156 |
+
|
157 |
+
// Format setting outer wrapper.
|
158 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
159 |
+
|
160 |
+
// Description.
|
161 |
+
echo '<div class="description">';
|
162 |
+
|
163 |
+
echo '<p>' . esc_html__( '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>';
|
164 |
+
|
165 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Settings', 'option-tree' ) . '</button>';
|
166 |
+
|
167 |
+
echo '</div>';
|
168 |
+
|
169 |
+
echo '<div class="format-setting-inner">';
|
170 |
+
|
171 |
+
echo '<textarea rows="10" cols="40" name="import_settings" id="import_settings" class="textarea"></textarea>';
|
172 |
+
|
173 |
+
echo '</div>';
|
174 |
+
|
175 |
+
echo '</div>';
|
176 |
+
|
177 |
+
echo '</form>';
|
178 |
+
|
179 |
+
}
|
180 |
}
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
if ( ! function_exists( 'ot_type_import_data' ) ) {
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Import Data option type.
|
186 |
+
*
|
187 |
+
* @access public
|
188 |
+
* @since 2.0
|
189 |
+
*/
|
190 |
+
function ot_type_import_data() {
|
191 |
+
|
192 |
+
echo '<form method="post" id="import-data-form">';
|
193 |
+
|
194 |
+
// Form nonce.
|
195 |
+
wp_nonce_field( 'import_data_form', 'import_data_nonce' );
|
196 |
+
|
197 |
+
// Format setting outer wrapper.
|
198 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
199 |
+
|
200 |
+
// Description.
|
201 |
+
echo '<div class="description">';
|
202 |
+
|
203 |
+
if ( OT_SHOW_SETTINGS_IMPORT ) {
|
204 |
+
echo '<p>' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
|
205 |
+
}
|
206 |
+
|
207 |
+
echo '<p>' . esc_html__( '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>';
|
208 |
+
|
209 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Theme Options', 'option-tree' ) . '</button>';
|
210 |
+
|
211 |
+
echo '</div>';
|
212 |
+
|
213 |
+
echo '<div class="format-setting-inner">';
|
214 |
+
|
215 |
+
echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
|
216 |
+
|
217 |
+
echo '</div>';
|
218 |
+
|
219 |
+
echo '</div>';
|
220 |
+
|
221 |
+
echo '</form>';
|
222 |
+
}
|
223 |
}
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
if ( ! function_exists( 'ot_type_import_layouts' ) ) {
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Import Layouts option type.
|
229 |
+
*
|
230 |
+
* @access public
|
231 |
+
* @since 2.0
|
232 |
+
*/
|
233 |
+
function ot_type_import_layouts() {
|
234 |
+
|
235 |
+
echo '<form method="post" id="import-layouts-form">';
|
236 |
+
|
237 |
+
// Form nonce.
|
238 |
+
wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' );
|
239 |
+
|
240 |
+
// Format setting outer wrapper.
|
241 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
242 |
+
|
243 |
+
// Description.
|
244 |
+
echo '<div class="description">';
|
245 |
+
|
246 |
+
if ( OT_SHOW_SETTINGS_IMPORT ) {
|
247 |
+
echo '<p>' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '</p>';
|
248 |
+
}
|
249 |
+
|
250 |
+
echo '<p>' . esc_html__( '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>';
|
251 |
+
|
252 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Layouts', 'option-tree' ) . '</button>';
|
253 |
+
|
254 |
+
echo '</div>';
|
255 |
+
|
256 |
+
echo '<div class="format-setting-inner">';
|
257 |
+
|
258 |
+
echo '<textarea rows="10" cols="40" name="import_layouts" id="import_layouts" class="textarea"></textarea>';
|
259 |
+
|
260 |
+
echo '</div>';
|
261 |
+
|
262 |
+
echo '</div>';
|
263 |
+
|
264 |
+
echo '</form>';
|
265 |
+
}
|
266 |
}
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Export Settings File option type.
|
272 |
+
*
|
273 |
+
* @access public
|
274 |
+
* @since 2.0.8
|
275 |
+
*/
|
276 |
+
function ot_type_export_settings_file() {
|
277 |
+
global $blog_id;
|
278 |
+
|
279 |
+
echo '<form method="post" id="export-settings-file-form">';
|
280 |
+
|
281 |
+
// Form nonce.
|
282 |
+
wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' );
|
283 |
+
|
284 |
+
// Format setting outer wrapper.
|
285 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
286 |
+
|
287 |
+
// Description.
|
288 |
+
echo '<div class="description">';
|
289 |
+
|
290 |
+
/* translators: %1$s: file name, %2$s: link to I18n docs, %3$s: link to internal docs */
|
291 |
+
$string = esc_html__( 'Export your Settings into a fully functional %1$s file. If you want to add your own custom %2$s text domain to the file, enter it into the text field before exporting. For more information on how to use this file read the documentation on %3$s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' );
|
292 |
+
echo '<p>' . sprintf( $string, '<code>theme-options.php</code>', '<a href="http://codex.wordpress.org/I18n_for_WordPress_Developers" target="_blank">I18n</a>', '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation#section_theme_mode' ) . '">' . esc_html__( 'Theme Mode', 'option-tree' ) . '</a>' ) . '</p>'; // phpcs:ignore
|
293 |
+
|
294 |
+
echo '</div>';
|
295 |
+
|
296 |
+
echo '<div class="format-setting-inner">';
|
297 |
+
|
298 |
+
echo '<input type="text" name="domain" value="" class="widefat option-tree-ui-input" placeholder="text-domain" autocomplete="off" />';
|
299 |
+
|
300 |
+
echo '<button class="option-tree-ui-button button button-primary hug-left">' . esc_html__( 'Export Settings File', 'option-tree' ) . '</button>';
|
301 |
+
|
302 |
+
echo '</div>';
|
303 |
+
|
304 |
+
echo '</div>';
|
305 |
+
|
306 |
+
echo '</form>';
|
307 |
+
}
|
308 |
}
|
309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
if ( ! function_exists( 'ot_type_export_settings' ) ) {
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Export Settings option type.
|
314 |
+
*
|
315 |
+
* @access public
|
316 |
+
* @since 2.0
|
317 |
+
*/
|
318 |
+
function ot_type_export_settings() {
|
319 |
+
|
320 |
+
// Format setting outer wrapper.
|
321 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
322 |
+
|
323 |
+
// Description.
|
324 |
+
echo '<div class="description">';
|
325 |
+
|
326 |
+
/* translators: %1$s: visual path to import, %2$s: visual path to settings */
|
327 |
+
$string = esc_html__( '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 %1$s %1$s textarea on another web site.', 'option-tree' );
|
328 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Settings', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
329 |
+
|
330 |
+
echo '</div>';
|
331 |
+
|
332 |
+
// Get theme options data.
|
333 |
+
$settings = get_option( ot_settings_id(), array() );
|
334 |
+
$settings = ! empty( $settings ) ? ot_encode( $settings ) : '';
|
335 |
+
|
336 |
+
echo '<div class="format-setting-inner">';
|
337 |
+
echo '<textarea rows="10" cols="40" name="export_settings" id="export_settings" class="textarea">' . $settings . '</textarea>'; // phpcs:ignore
|
338 |
+
echo '</div>';
|
339 |
+
|
340 |
+
echo '</div>';
|
341 |
+
|
342 |
+
}
|
343 |
}
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
if ( ! function_exists( 'ot_type_export_data' ) ) {
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Export Data option type.
|
349 |
+
*
|
350 |
+
* @access public
|
351 |
+
* @since 2.0
|
352 |
+
*/
|
353 |
+
function ot_type_export_data() {
|
354 |
+
|
355 |
+
// Format setting outer wrapper.
|
356 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
357 |
+
|
358 |
+
// Description.
|
359 |
+
echo '<div class="description">';
|
360 |
+
|
361 |
+
/* translators: %1$s: visual path to import, %2$s: visual path to theme options */
|
362 |
+
$string = esc_html__( '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 %1$s %2$s textarea on another web site.', 'option-tree' );
|
363 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Theme Options', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
364 |
+
|
365 |
+
echo '</div>';
|
366 |
+
|
367 |
+
// Get theme options data.
|
368 |
+
$data = get_option( ot_options_id(), array() );
|
369 |
+
$data = ! empty( $data ) ? ot_encode( $data ) : '';
|
370 |
+
|
371 |
+
echo '<div class="format-setting-inner">';
|
372 |
+
echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>'; // phpcs:ignore
|
373 |
+
echo '</div>';
|
374 |
+
|
375 |
+
echo '</div>';
|
376 |
+
|
377 |
+
}
|
378 |
}
|
379 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
if ( ! function_exists( 'ot_type_export_layouts' ) ) {
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Export Layouts option type.
|
384 |
+
*
|
385 |
+
* @access public
|
386 |
+
* @since 2.0
|
387 |
+
*/
|
388 |
+
function ot_type_export_layouts() {
|
389 |
+
|
390 |
+
// Format setting outer wrapper.
|
391 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
392 |
+
|
393 |
+
// Description.
|
394 |
+
echo '<div class="description">';
|
395 |
+
|
396 |
+
/* translators: %1$s: visual path to import, %2$s: visual path to layouts */
|
397 |
+
$string = esc_html__( '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 %1$s %2$s textarea on another web site.', 'option-tree' );
|
398 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Layouts', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
399 |
+
|
400 |
+
echo '</div>';
|
401 |
+
|
402 |
+
// Get layout data.
|
403 |
+
$layouts = get_option( ot_layouts_id(), array() );
|
404 |
+
$layouts = ! empty( $layouts ) ? ot_encode( $layouts ) : '';
|
405 |
+
|
406 |
+
echo '<div class="format-setting-inner">';
|
407 |
+
echo '<textarea rows="10" cols="40" name="export_layouts" id="export_layouts" class="textarea">' . $layouts . '</textarea>'; // phpcs:ignore
|
408 |
+
echo '</div>';
|
409 |
+
|
410 |
+
echo '</div>';
|
411 |
+
}
|
412 |
}
|
413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
|
416 |
+
/**
|
417 |
+
* Modify Layouts option type.
|
418 |
+
*
|
419 |
+
* @access public
|
420 |
+
* @since 2.0
|
421 |
+
*/
|
422 |
+
function ot_type_modify_layouts() {
|
423 |
+
|
424 |
+
echo '<form method="post" id="option-tree-settings-form">';
|
425 |
+
|
426 |
+
// Form nonce.
|
427 |
+
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
428 |
+
|
429 |
+
// Format setting outer wrapper.
|
430 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
431 |
+
|
432 |
+
// Description.
|
433 |
+
echo '<div class="description">';
|
434 |
+
|
435 |
+
echo '<p>' . esc_html__( '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>';
|
436 |
+
echo '<p>' . esc_html__( '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>';
|
437 |
+
echo '<p>' . esc_html__( '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>';
|
438 |
+
|
439 |
+
if ( OT_SHOW_DOCS ) {
|
440 |
+
/* translators: %s: visual path to layouts overview */
|
441 |
+
$string = esc_html__( 'Visit %s to see a more in-depth description of what layouts are and how to use them.', 'option-tree' );
|
442 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Documentation->Layouts Overview', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
443 |
+
}
|
444 |
+
|
445 |
+
echo '</div>';
|
446 |
+
|
447 |
+
echo '<div class="format-setting-inner">';
|
448 |
+
|
449 |
+
// Get the saved layouts.
|
450 |
+
$layouts = get_option( ot_layouts_id() );
|
451 |
|
452 |
+
// Set active layout.
|
453 |
+
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
454 |
|
455 |
+
echo '<input type="hidden" name="' . esc_attr( ot_layouts_id() ) . '[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
|
456 |
|
457 |
+
// Add new layout.
|
458 |
+
echo '<input type="text" name="' . esc_attr( ot_layouts_id() ) . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
459 |
+
|
460 |
+
// Loop through each layout.
|
461 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
|
462 |
+
|
463 |
+
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
464 |
+
|
465 |
+
foreach ( $layouts as $key => $data ) {
|
466 |
+
|
467 |
+
// Skip active layout array.
|
468 |
+
if ( 'active_layout' === $key ) {
|
469 |
+
continue;
|
470 |
+
}
|
471 |
+
|
472 |
+
// Content.
|
473 |
+
echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>'; // phpcs:ignore
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
echo '</ul>';
|
478 |
+
|
479 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Layouts', 'option-tree' ) . '</button>';
|
480 |
+
|
481 |
+
echo '</div>';
|
482 |
+
|
483 |
+
echo '</div>';
|
484 |
+
|
485 |
+
echo '</form>';
|
486 |
+
}
|
487 |
+
}
|
admin/includes/ot-functions.php
CHANGED
@@ -1,373 +1,363 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* OptionTree
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
*
|
16 |
-
* @access public
|
17 |
-
* @since 2.3.0
|
18 |
-
*/
|
19 |
if ( ! function_exists( 'ot_options_id' ) ) {
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
-
/**
|
30 |
-
* Theme Settings ID
|
31 |
-
*
|
32 |
-
* @return string
|
33 |
-
*
|
34 |
-
* @access public
|
35 |
-
* @since 2.3.0
|
36 |
-
*/
|
37 |
if ( ! function_exists( 'ot_settings_id' ) ) {
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
-
/**
|
48 |
-
* Theme Layouts ID
|
49 |
-
*
|
50 |
-
* @return string
|
51 |
-
*
|
52 |
-
* @access public
|
53 |
-
* @since 2.3.0
|
54 |
-
*/
|
55 |
if ( ! function_exists( 'ot_layouts_id' ) ) {
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
-
/**
|
66 |
-
* Get Option.
|
67 |
-
*
|
68 |
-
* Helper function to return the option value.
|
69 |
-
* If no value has been saved, it returns $default.
|
70 |
-
*
|
71 |
-
* @param string The option ID.
|
72 |
-
* @param string The default option value.
|
73 |
-
* @return mixed
|
74 |
-
*
|
75 |
-
* @access public
|
76 |
-
* @since 2.0
|
77 |
-
*/
|
78 |
if ( ! function_exists( 'ot_get_option' ) ) {
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
}
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
*
|
101 |
-
* Helper function to echo the option value.
|
102 |
-
* If no value has been saved, it echos $default.
|
103 |
-
*
|
104 |
-
* @param string The option ID.
|
105 |
-
* @param string The default option value.
|
106 |
-
* @return mixed
|
107 |
-
*
|
108 |
-
* @access public
|
109 |
-
* @since 2.2.0
|
110 |
-
*/
|
111 |
-
if ( ! function_exists( 'ot_echo_option' ) ) {
|
112 |
-
|
113 |
-
function ot_echo_option( $option_id, $default = '' ) {
|
114 |
-
|
115 |
-
echo ot_get_option( $option_id, $default );
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
-
}
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
*
|
124 |
-
* @param array $options The current options
|
125 |
-
* @param string $option_id The option ID
|
126 |
-
* @return mixed
|
127 |
-
*
|
128 |
-
* @access public
|
129 |
-
* @since 2.1
|
130 |
-
*/
|
131 |
-
if ( ! function_exists( 'ot_wpml_filter' ) ) {
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
// Return translated strings using WMPL
|
136 |
-
if ( function_exists('icl_t') ) {
|
137 |
-
|
138 |
-
$settings = get_option( ot_settings_id() );
|
139 |
-
|
140 |
-
if ( isset( $settings['settings'] ) ) {
|
141 |
-
|
142 |
-
foreach( $settings['settings'] as $setting ) {
|
143 |
-
|
144 |
-
// List Item & Slider
|
145 |
-
if ( $option_id == $setting['id'] && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) {
|
146 |
-
|
147 |
-
foreach( $options[$option_id] as $key => $value ) {
|
148 |
-
|
149 |
-
foreach( $value as $ckey => $cvalue ) {
|
150 |
-
|
151 |
-
$id = $option_id . '_' . $ckey . '_' . $key;
|
152 |
-
$_string = icl_t( 'Nifty Options', $id, $cvalue );
|
153 |
-
|
154 |
-
if ( ! empty( $_string ) ) {
|
155 |
-
|
156 |
-
$options[$option_id][$key][$ckey] = $_string;
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
// List Item & Slider
|
165 |
-
} else if ( $option_id == $setting['id'] && $setting['type'] == 'social-links' ) {
|
166 |
-
|
167 |
-
foreach( $options[$option_id] as $key => $value ) {
|
168 |
-
|
169 |
-
foreach( $value as $ckey => $cvalue ) {
|
170 |
-
|
171 |
-
$id = $option_id . '_' . $ckey . '_' . $key;
|
172 |
-
$_string = icl_t( 'Nifty Options', $id, $cvalue );
|
173 |
-
|
174 |
-
if ( ! empty( $_string ) ) {
|
175 |
-
|
176 |
-
$options[$option_id][$key][$ckey] = $_string;
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
}
|
181 |
-
|
182 |
-
}
|
183 |
-
|
184 |
-
// All other acceptable option types
|
185 |
-
} else if ( $option_id == $setting['id'] && in_array( $setting['type'], apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ) ) ) {
|
186 |
-
|
187 |
-
$_string = icl_t( 'Theme Options', $option_id, $options[$option_id] );
|
188 |
-
|
189 |
-
if ( ! empty( $_string ) ) {
|
190 |
-
|
191 |
-
$options[$option_id] = $_string;
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
196 |
-
|
197 |
-
}
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
return $options[$option_id];
|
204 |
-
|
205 |
-
}
|
206 |
|
|
|
|
|
|
|
|
|
|
|
207 |
}
|
208 |
|
209 |
-
|
210 |
-
* Enqueue the dynamic CSS.
|
211 |
-
*
|
212 |
-
* @return void
|
213 |
-
*
|
214 |
-
* @access public
|
215 |
-
* @since 2.0
|
216 |
-
*/
|
217 |
-
if ( ! function_exists( 'ot_load_dynamic_css' ) ) {
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
*/
|
238 |
-
if ( false === (bool) apply_filters( 'ot_load_dynamic_css', true ) ) {
|
239 |
-
return;
|
240 |
-
}
|
241 |
-
|
242 |
-
/* grab a copy of the paths */
|
243 |
-
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
244 |
-
if ( is_multisite() ) {
|
245 |
-
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
246 |
-
}
|
247 |
-
|
248 |
-
if ( ! empty( $ot_css_file_paths ) ) {
|
249 |
-
|
250 |
-
$last_css = '';
|
251 |
-
|
252 |
-
/* loop through paths */
|
253 |
-
foreach( $ot_css_file_paths as $key => $path ) {
|
254 |
-
|
255 |
-
if ( '' != $path && file_exists( $path ) ) {
|
256 |
-
|
257 |
-
$parts = explode( '/wp-content', $path );
|
258 |
-
|
259 |
-
if ( isset( $parts[1] ) ) {
|
260 |
-
|
261 |
-
$sub_parts = explode( '/', $parts[1] );
|
262 |
-
|
263 |
-
if ( isset( $sub_parts[1] ) && isset( $sub_parts[2] ) ) {
|
264 |
-
if ( $sub_parts[1] == 'themes' && $sub_parts[2] != get_stylesheet() ) {
|
265 |
-
continue;
|
266 |
-
}
|
267 |
-
}
|
268 |
-
|
269 |
-
$css = set_url_scheme( WP_CONTENT_URL ) . $parts[1];
|
270 |
-
|
271 |
-
if ( $last_css !== $css ) {
|
272 |
-
|
273 |
-
/* enqueue filtered file */
|
274 |
-
wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION );
|
275 |
-
|
276 |
-
$last_css = $css;
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
}
|
281 |
-
|
282 |
-
}
|
283 |
-
|
284 |
-
}
|
285 |
-
|
286 |
-
}
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
}
|
291 |
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
|
|
301 |
|
302 |
-
|
|
|
303 |
|
304 |
-
|
305 |
-
if ( is_admin() )
|
306 |
-
return;
|
307 |
|
308 |
-
|
309 |
-
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
310 |
-
$families = array();
|
311 |
-
$subsets = array();
|
312 |
-
$append = '';
|
313 |
|
314 |
-
|
315 |
|
316 |
-
|
|
|
317 |
|
318 |
-
|
319 |
|
320 |
-
|
321 |
-
if ( ! isset( $ot_google_fonts[$font['family']]['family'] ) ) {
|
322 |
-
continue;
|
323 |
-
}
|
324 |
|
325 |
-
|
326 |
-
|
327 |
|
328 |
-
|
329 |
-
$variants = ':' . implode( ',', $font['variants'] );
|
330 |
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
}
|
336 |
-
}
|
337 |
|
338 |
-
|
|
|
339 |
|
340 |
-
|
341 |
-
if ( isset( $variants ) ) {
|
342 |
-
$families[] = str_replace( ' ', '+', $ot_google_fonts[$font['family']]['family'] ) . $variants;
|
343 |
-
}
|
344 |
|
345 |
-
|
346 |
|
347 |
-
|
|
|
348 |
|
349 |
-
|
350 |
|
351 |
-
|
|
|
|
|
|
|
352 |
|
353 |
-
|
|
|
354 |
|
355 |
-
|
356 |
-
if ( ! empty( $subsets ) ) {
|
357 |
-
$subsets = implode( ',', array_unique( $subsets ) );
|
358 |
-
if ( $subsets != 'latin' ) {
|
359 |
-
$append = '&subset=' . $subsets;
|
360 |
-
}
|
361 |
-
}
|
362 |
|
363 |
-
|
364 |
-
}
|
365 |
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
367 |
|
|
|
|
|
368 |
}
|
369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
|
|
371 |
|
372 |
-
|
373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Function.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
|
|
|
|
|
|
|
|
12 |
if ( ! function_exists( 'ot_options_id' ) ) {
|
13 |
|
14 |
+
/**
|
15 |
+
* Theme Options ID
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*
|
19 |
+
* @access public
|
20 |
+
* @since 2.3.0
|
21 |
+
*/
|
22 |
+
function ot_options_id() {
|
23 |
+
|
24 |
+
return apply_filters( 'ot_options_id', 'option_tree' );
|
25 |
+
|
26 |
+
}
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
if ( ! function_exists( 'ot_settings_id' ) ) {
|
30 |
|
31 |
+
/**
|
32 |
+
* Theme Settings ID
|
33 |
+
*
|
34 |
+
* @return string
|
35 |
+
*
|
36 |
+
* @access public
|
37 |
+
* @since 2.3.0
|
38 |
+
*/
|
39 |
+
function ot_settings_id() {
|
40 |
+
|
41 |
+
return apply_filters( 'ot_settings_id', 'option_tree_settings' );
|
42 |
+
|
43 |
+
}
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
if ( ! function_exists( 'ot_layouts_id' ) ) {
|
47 |
|
48 |
+
/**
|
49 |
+
* Theme Layouts ID
|
50 |
+
*
|
51 |
+
* @return string
|
52 |
+
*
|
53 |
+
* @access public
|
54 |
+
* @since 2.3.0
|
55 |
+
*/
|
56 |
+
function ot_layouts_id() {
|
57 |
+
|
58 |
+
return apply_filters( 'ot_layouts_id', 'option_tree_layouts' );
|
59 |
+
|
60 |
+
}
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
if ( ! function_exists( 'ot_get_option' ) ) {
|
64 |
|
65 |
+
/**
|
66 |
+
* Get Option.
|
67 |
+
*
|
68 |
+
* Helper function to return the option value.
|
69 |
+
* If no value has been saved, it returns $default.
|
70 |
+
*
|
71 |
+
* @param string $option_id The option ID.
|
72 |
+
* @param string $default The default option value.
|
73 |
+
* @return mixed
|
74 |
+
*
|
75 |
+
* @access public
|
76 |
+
* @since 2.0
|
77 |
+
*/
|
78 |
+
function ot_get_option( $option_id, $default = '' ) {
|
|
|
|
|
|
|
79 |
|
80 |
+
// Get the saved options.
|
81 |
+
$options = get_option( ot_options_id() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
// Look for the saved value.
|
84 |
+
if ( isset( $options[ $option_id ] ) && '' !== $options[ $option_id ] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
+
return ot_wpml_filter( $options, $option_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
+
}
|
89 |
+
|
90 |
+
return $default;
|
91 |
+
|
92 |
+
}
|
93 |
}
|
94 |
|
95 |
+
if ( ! function_exists( 'ot_echo_option' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
+
/**
|
98 |
+
* Echo Option.
|
99 |
+
*
|
100 |
+
* Helper function to echo the option value.
|
101 |
+
* If no value has been saved, it echos $default.
|
102 |
+
*
|
103 |
+
* @param string $option_id The option ID.
|
104 |
+
* @param string $default The default option value.
|
105 |
+
* @return mixed
|
106 |
+
*
|
107 |
+
* @access public
|
108 |
+
* @since 2.2.0
|
109 |
+
*/
|
110 |
+
function ot_echo_option( $option_id, $default = '' ) {
|
111 |
+
|
112 |
+
echo ot_get_option( $option_id, $default ); // phpcs:ignore
|
113 |
+
|
114 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
|
117 |
+
if ( ! function_exists( 'ot_wpml_filter' ) ) {
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Filter the return values through WPML
|
121 |
+
*
|
122 |
+
* @param array $options The current options.
|
123 |
+
* @param string $option_id The option ID.
|
124 |
+
* @return mixed
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @since 2.1
|
128 |
+
*/
|
129 |
+
function ot_wpml_filter( $options, $option_id ) {
|
130 |
|
131 |
+
// Return translated strings using WMPL.
|
132 |
+
if ( function_exists( 'icl_t' ) ) {
|
133 |
|
134 |
+
$settings = get_option( ot_settings_id() );
|
|
|
|
|
135 |
|
136 |
+
if ( isset( $settings['settings'] ) ) {
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
foreach ( $settings['settings'] as $setting ) {
|
139 |
|
140 |
+
// List Item & Slider.
|
141 |
+
if ( $option_id === $setting['id'] && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
142 |
|
143 |
+
foreach ( $options[ $option_id ] as $key => $value ) {
|
144 |
|
145 |
+
foreach ( $value as $ckey => $cvalue ) {
|
|
|
|
|
|
|
146 |
|
147 |
+
$id = $option_id . '_' . $ckey . '_' . $key;
|
148 |
+
$_string = icl_t( 'Nifty Options', $id, $cvalue );
|
149 |
|
150 |
+
if ( ! empty( $_string ) ) {
|
|
|
151 |
|
152 |
+
$options[ $option_id ][ $key ][ $ckey ] = $_string;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
|
|
|
|
156 |
|
157 |
+
// List Item & Slider.
|
158 |
+
} elseif ( $option_id === $setting['id'] && 'social-links' === $setting['type'] ) {
|
159 |
|
160 |
+
foreach ( $options[ $option_id ] as $key => $value ) {
|
|
|
|
|
|
|
161 |
|
162 |
+
foreach ( $value as $ckey => $cvalue ) {
|
163 |
|
164 |
+
$id = $option_id . '_' . $ckey . '_' . $key;
|
165 |
+
$_string = icl_t( 'Nifty Options', $id, $cvalue );
|
166 |
|
167 |
+
if ( ! empty( $_string ) ) {
|
168 |
|
169 |
+
$options[ $option_id ][ $key ][ $ckey ] = $_string;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
|
174 |
+
// All other acceptable option types.
|
175 |
+
} elseif ( $option_id === $setting['id'] && in_array( $setting['type'], apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ), true ) ) {
|
176 |
|
177 |
+
$_string = icl_t( 'Nifty Options', $option_id, $options[ $option_id ] );
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
+
if ( ! empty( $_string ) ) {
|
|
|
180 |
|
181 |
+
$options[ $option_id ] = $_string;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
|
188 |
+
return $options[ $option_id ];
|
189 |
+
}
|
190 |
}
|
191 |
|
192 |
+
if ( ! function_exists( 'ot_load_dynamic_css' ) ) {
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Enqueue the dynamic CSS.
|
196 |
+
*
|
197 |
+
* @access public
|
198 |
+
* @since 2.0
|
199 |
+
*/
|
200 |
+
function ot_load_dynamic_css() {
|
201 |
+
|
202 |
+
// Don't load in the admin.
|
203 |
+
if ( is_admin() ) {
|
204 |
+
return;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Filter whether or not to enqueue a `dynamic.css` file at the theme level.
|
209 |
+
*
|
210 |
+
* By filtering this to `false` OptionTree will not attempt to enqueue any CSS files.
|
211 |
+
*
|
212 |
+
* Example: add_filter( 'ot_load_dynamic_css', '__return_false' );
|
213 |
+
*
|
214 |
+
* @since 2.5.5
|
215 |
+
*
|
216 |
+
* @param bool $load_dynamic_css Default is `true`.
|
217 |
+
* @return bool
|
218 |
+
*/
|
219 |
+
if ( false === (bool) apply_filters( 'ot_load_dynamic_css', true ) ) {
|
220 |
+
return;
|
221 |
+
}
|
222 |
+
|
223 |
+
// Grab a copy of the paths.
|
224 |
+
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
225 |
+
if ( is_multisite() ) {
|
226 |
+
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( ! empty( $ot_css_file_paths ) ) {
|
230 |
+
|
231 |
+
$last_css = '';
|
232 |
+
|
233 |
+
// Loop through paths.
|
234 |
+
foreach ( $ot_css_file_paths as $key => $path ) {
|
235 |
+
|
236 |
+
if ( '' !== $path && file_exists( $path ) ) {
|
237 |
+
|
238 |
+
$parts = explode( '/wp-content', $path );
|
239 |
+
|
240 |
+
if ( isset( $parts[1] ) ) {
|
241 |
+
|
242 |
+
$sub_parts = explode( '/', $parts[1] );
|
243 |
+
|
244 |
+
if ( isset( $sub_parts[1] ) && isset( $sub_parts[2] ) ) {
|
245 |
+
if ( 'themes' !== $sub_parts[1] && get_stylesheet() !== $sub_parts[2] ) {
|
246 |
+
continue;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
$css = set_url_scheme( WP_CONTENT_URL ) . $parts[1];
|
251 |
+
|
252 |
+
if ( $last_css !== $css ) {
|
253 |
+
|
254 |
+
// Enqueue filtered file.
|
255 |
+
wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION );
|
256 |
+
|
257 |
+
$last_css = $css;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
265 |
+
}
|
266 |
|
267 |
+
if ( ! function_exists( 'ot_load_google_fonts_css' ) ) {
|
268 |
|
269 |
+
/**
|
270 |
+
* Enqueue the Google Fonts CSS.
|
271 |
+
*
|
272 |
+
* @access public
|
273 |
+
* @since 2.5.0
|
274 |
+
*/
|
275 |
+
function ot_load_google_fonts_css() {
|
276 |
+
|
277 |
+
/* don't load in the admin */
|
278 |
+
if ( is_admin() ) {
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
|
282 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
283 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
284 |
+
$families = array();
|
285 |
+
$subsets = array();
|
286 |
+
$append = '';
|
287 |
+
|
288 |
+
if ( ! empty( $ot_set_google_fonts ) ) {
|
289 |
+
|
290 |
+
foreach ( $ot_set_google_fonts as $id => $fonts ) {
|
291 |
+
|
292 |
+
foreach ( $fonts as $font ) {
|
293 |
+
|
294 |
+
// Can't find the font, bail!
|
295 |
+
if ( ! isset( $ot_google_fonts[ $font['family'] ]['family'] ) ) {
|
296 |
+
continue;
|
297 |
+
}
|
298 |
+
|
299 |
+
// Set variants & subsets.
|
300 |
+
if ( ! empty( $font['variants'] ) && is_array( $font['variants'] ) ) {
|
301 |
+
|
302 |
+
// Variants string.
|
303 |
+
$variants = ':' . implode( ',', $font['variants'] );
|
304 |
+
|
305 |
+
// Add subsets to array.
|
306 |
+
if ( ! empty( $font['subsets'] ) && is_array( $font['subsets'] ) ) {
|
307 |
+
foreach ( $font['subsets'] as $subset ) {
|
308 |
+
$subsets[] = $subset;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
}
|
312 |
+
|
313 |
+
// Add family & variants to array.
|
314 |
+
if ( isset( $variants ) ) {
|
315 |
+
$families[] = str_replace( ' ', '+', $ot_google_fonts[ $font['family'] ]['family'] ) . $variants;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
if ( ! empty( $families ) ) {
|
322 |
+
|
323 |
+
$families = array_unique( $families );
|
324 |
+
|
325 |
+
// Append all subsets to the path, unless the only subset is latin.
|
326 |
+
if ( ! empty( $subsets ) ) {
|
327 |
+
$subsets = implode( ',', array_unique( $subsets ) );
|
328 |
+
if ( 'latin' !== $subsets ) {
|
329 |
+
$append = '&subset=' . $subsets;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
wp_enqueue_style( 'ot-google-fonts', esc_url( '//fonts.googleapis.com/css?family=' . implode( '%7C', $families ) ) . $append, false, null ); // phpcs:ignore
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
if ( ! function_exists( 'ot_register_theme_options_admin_bar_menu' ) ) {
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Registers the Theme Option page link for the admin bar.
|
342 |
+
*
|
343 |
+
* @access public
|
344 |
+
* @since 2.1
|
345 |
+
*
|
346 |
+
* @param object $wp_admin_bar The WP_Admin_Bar object.
|
347 |
+
*/
|
348 |
+
function ot_register_theme_options_admin_bar_menu( $wp_admin_bar ) {
|
349 |
+
|
350 |
+
if ( ! current_user_can( apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ) ) || ! is_admin_bar_showing() ) {
|
351 |
+
return;
|
352 |
+
}
|
353 |
+
|
354 |
+
$wp_admin_bar->add_node(
|
355 |
+
array(
|
356 |
+
'parent' => 'appearance',
|
357 |
+
'id' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ),
|
358 |
+
'title' => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ),
|
359 |
+
'href' => admin_url( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ),
|
360 |
+
)
|
361 |
+
);
|
362 |
+
}
|
363 |
+
}
|
admin/ot-loader.php
CHANGED
@@ -3,804 +3,734 @@
|
|
3 |
* Plugin Name: OptionTree
|
4 |
* Plugin URI: https://github.com/valendesigns/option-tree/
|
5 |
* Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
|
6 |
-
* Version: 2.
|
7 |
* Author: Derek Herman
|
8 |
* Author URI: http://valendesigns.com
|
9 |
-
* License:
|
10 |
* Text Domain: option-tree
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Forces Plugin Mode when OptionTree is already loaded and displays an admin notice.
|
15 |
-
*/
|
16 |
-
if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && OT_PLUGIN_MODE == true ) {
|
17 |
-
|
18 |
-
add_filter( 'ot_theme_mode', '__return_false', 999 );
|
19 |
-
|
20 |
-
function ot_conflict_notice() {
|
21 |
-
|
22 |
-
echo '<div class="error"><p>' . __( 'OptionTree is installed as a plugin and also embedded in your current theme. Please deactivate the plugin to load the theme dependent version of OptionTree, and remove this warning.', 'option-tree' ) . '</p></div>';
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
add_action( 'admin_notices', 'ot_conflict_notice' );
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* This is the OptionTree loader class.
|
32 |
*
|
33 |
-
* @package
|
34 |
-
* @author Derek Herman <derek@valendesigns.com>
|
35 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
36 |
*/
|
37 |
-
if ( ! class_exists( 'OT_Loader' ) ) {
|
38 |
-
|
39 |
-
class OT_Loader {
|
40 |
-
|
41 |
-
/**
|
42 |
-
* PHP5 constructor method.
|
43 |
-
*
|
44 |
-
* This method loads other methods of the class.
|
45 |
-
*
|
46 |
-
* @return void
|
47 |
-
*
|
48 |
-
* @access public
|
49 |
-
* @since 2.0
|
50 |
-
*/
|
51 |
-
public function __construct() {
|
52 |
-
|
53 |
-
/* load languages */
|
54 |
-
$this->load_languages();
|
55 |
-
|
56 |
-
/* load OptionTree */
|
57 |
-
add_action( 'after_setup_theme', array( $this, 'load_option_tree' ), 1 );
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Load the languages before everything else.
|
63 |
-
*
|
64 |
-
* @return void
|
65 |
-
*
|
66 |
-
* @access private
|
67 |
-
* @since 2.1.3
|
68 |
-
*/
|
69 |
-
private function load_languages() {
|
70 |
-
|
71 |
-
/**
|
72 |
-
* A quick check to see if we're in plugin mode.
|
73 |
-
*
|
74 |
-
* @since 2.1.3
|
75 |
-
*/
|
76 |
-
define( 'OT_PLUGIN_MODE', strpos( dirname( __FILE__ ), 'plugins' . DIRECTORY_SEPARATOR . basename( dirname( __FILE__ ) ) ) !== false ? true : false );
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Path to the languages directory.
|
80 |
-
*
|
81 |
-
* This path will be relative in plugin mode and absolute in theme mode.
|
82 |
-
*
|
83 |
-
* @since 2.0.10
|
84 |
-
* @updated 2.4.1
|
85 |
-
*/
|
86 |
-
if ( OT_PLUGIN_MODE ) {
|
87 |
-
|
88 |
-
define( 'OT_LANG_DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . trailingslashit( 'languages' ) );
|
89 |
-
|
90 |
-
} else {
|
91 |
-
|
92 |
-
if ( apply_filters( 'ot_child_theme_mode', false ) == true ) {
|
93 |
-
|
94 |
-
$path = @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
95 |
-
$path = ltrim( end( $path ), '/' );
|
96 |
-
define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' );
|
97 |
-
|
98 |
-
} else {
|
99 |
-
|
100 |
-
$path = @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
101 |
-
$path = ltrim( end( $path ), '/' );
|
102 |
-
define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' );
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
/* load the text domain */
|
109 |
-
if ( OT_PLUGIN_MODE ) {
|
110 |
-
|
111 |
-
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
112 |
-
|
113 |
-
} else {
|
114 |
-
|
115 |
-
add_action( 'after_setup_theme', array( $this, 'load_textdomain' ) );
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Load the text domain.
|
123 |
-
*
|
124 |
-
* @return void
|
125 |
-
*
|
126 |
-
* @access private
|
127 |
-
* @since 2.0
|
128 |
-
*/
|
129 |
-
public function load_textdomain() {
|
130 |
-
|
131 |
-
if ( OT_PLUGIN_MODE ) {
|
132 |
-
|
133 |
-
load_plugin_textdomain( 'option-tree', false, OT_LANG_DIR );
|
134 |
-
|
135 |
-
} else {
|
136 |
-
|
137 |
-
load_theme_textdomain( 'option-tree', OT_LANG_DIR );
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Load OptionTree on the 'after_setup_theme' action. Then filters will
|
145 |
-
* be availble to the theme, and not only when in Theme Mode.
|
146 |
-
*
|
147 |
-
* @return void
|
148 |
-
*
|
149 |
-
* @access public
|
150 |
-
* @since 2.1.2
|
151 |
-
*/
|
152 |
-
public function load_option_tree() {
|
153 |
-
|
154 |
-
/* setup the constants */
|
155 |
-
$this->constants();
|
156 |
-
|
157 |
-
/* include the required admin files */
|
158 |
-
$this->admin_includes();
|
159 |
-
|
160 |
-
/* include the required files */
|
161 |
-
$this->includes();
|
162 |
-
|
163 |
-
/* hook into WordPress */
|
164 |
-
$this->hooks();
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Constants
|
170 |
-
*
|
171 |
-
* Defines the constants for use within OptionTree. Constants
|
172 |
-
* are prefixed with 'OT_' to avoid any naming collisions.
|
173 |
-
*
|
174 |
-
* @return void
|
175 |
-
*
|
176 |
-
* @access private
|
177 |
-
* @since 2.0
|
178 |
-
*/
|
179 |
-
private function constants() {
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Current Version number.
|
183 |
-
*/
|
184 |
-
define( 'OT_VERSION', '1.1.2' );
|
185 |
-
|
186 |
-
/**
|
187 |
-
* For developers: Theme mode.
|
188 |
-
*
|
189 |
-
* Run a filter and set to true to enable OptionTree theme mode.
|
190 |
-
* You must have this files parent directory inside of
|
191 |
-
* your themes root directory. As well, you must include
|
192 |
-
* a reference to this file in your themes functions.php.
|
193 |
-
*
|
194 |
-
* @since 2.0
|
195 |
-
*/
|
196 |
-
define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) );
|
197 |
-
|
198 |
-
/**
|
199 |
-
* For developers: Child Theme mode. TODO document
|
200 |
-
*
|
201 |
-
* Run a filter and set to true to enable OptionTree child theme mode.
|
202 |
-
* You must have this files parent directory inside of
|
203 |
-
* your themes root directory. As well, you must include
|
204 |
-
* a reference to this file in your themes functions.php.
|
205 |
-
*
|
206 |
-
* @since 2.0.15
|
207 |
-
*/
|
208 |
-
define( 'OT_CHILD_THEME_MODE', apply_filters( 'ot_child_theme_mode', false ) );
|
209 |
-
|
210 |
-
/**
|
211 |
-
* For developers: Show Pages.
|
212 |
-
*
|
213 |
-
* Run a filter and set to false if you don't want to load the
|
214 |
-
* settings & documentation pages in the admin area of WordPress.
|
215 |
-
*
|
216 |
-
* @since 2.0
|
217 |
-
*/
|
218 |
-
define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) );
|
219 |
-
|
220 |
-
/**
|
221 |
-
* For developers: Show Theme Options UI Builder
|
222 |
-
*
|
223 |
-
* Run a filter and set to false if you want to hide the
|
224 |
-
* Theme Options UI page in the admin area of WordPress.
|
225 |
-
*
|
226 |
-
* @since 2.1
|
227 |
-
*/
|
228 |
-
define( 'OT_SHOW_OPTIONS_UI', apply_filters( 'ot_show_options_ui', true ) );
|
229 |
-
|
230 |
-
/**
|
231 |
-
* For developers: Show Settings Import
|
232 |
-
*
|
233 |
-
* Run a filter and set to false if you want to hide the
|
234 |
-
* Settings Import options on the Import page.
|
235 |
-
*
|
236 |
-
* @since 2.1
|
237 |
-
*/
|
238 |
-
define( 'OT_SHOW_SETTINGS_IMPORT', apply_filters( 'ot_show_settings_import', true ) );
|
239 |
-
|
240 |
-
/**
|
241 |
-
* For developers: Show Settings Export
|
242 |
-
*
|
243 |
-
* Run a filter and set to false if you want to hide the
|
244 |
-
* Settings Import options on the Import page.
|
245 |
-
*
|
246 |
-
* @since 2.1
|
247 |
-
*/
|
248 |
-
define( 'OT_SHOW_SETTINGS_EXPORT', apply_filters( 'ot_show_settings_export', true ) );
|
249 |
-
|
250 |
-
/**
|
251 |
-
* For developers: Show New Layout.
|
252 |
-
*
|
253 |
-
* Run a filter and set to false if you don't want to show the
|
254 |
-
* "New Layout" section at the top of the theme options page.
|
255 |
-
*
|
256 |
-
* @since 2.0.10
|
257 |
-
*/
|
258 |
-
define( 'OT_SHOW_NEW_LAYOUT', apply_filters( 'ot_show_new_layout', true ) );
|
259 |
-
|
260 |
-
/**
|
261 |
-
* For developers: Show Documentation
|
262 |
-
*
|
263 |
-
* Run a filter and set to false if you want to hide the Documentation.
|
264 |
-
*
|
265 |
-
* @since 2.1
|
266 |
-
*/
|
267 |
-
define( 'OT_SHOW_DOCS', apply_filters( 'ot_show_docs', true ) );
|
268 |
-
|
269 |
-
/**
|
270 |
-
* For developers: Custom Theme Option page
|
271 |
-
*
|
272 |
-
* Run a filter and set to false if you want to hide the OptionTree
|
273 |
-
* Theme Option page and build your own.
|
274 |
-
*
|
275 |
-
* @since 2.1
|
276 |
-
*/
|
277 |
-
define( 'OT_USE_THEME_OPTIONS', apply_filters( 'ot_use_theme_options', true ) );
|
278 |
-
|
279 |
-
/**
|
280 |
-
* For developers: Meta Boxes.
|
281 |
-
*
|
282 |
-
* Run a filter and set to false to keep OptionTree from
|
283 |
-
* loading the meta box resources.
|
284 |
-
*
|
285 |
-
* @since 2.0
|
286 |
-
*/
|
287 |
-
define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) );
|
288 |
-
|
289 |
-
/**
|
290 |
-
* For developers: Allow Unfiltered HTML in all the textareas.
|
291 |
-
*
|
292 |
-
* Run a filter and set to true if you want all the
|
293 |
-
* users to be able to post anything in the textareas.
|
294 |
-
* WARNING: This opens a security hole for low level users
|
295 |
-
* to be able to post malicious scripts, you've been warned.
|
296 |
-
*
|
297 |
-
* @since 2.0
|
298 |
-
*/
|
299 |
-
define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) );
|
300 |
-
|
301 |
-
/**
|
302 |
-
* For developers: Post Formats.
|
303 |
-
*
|
304 |
-
* Run a filter and set to true if you want OptionTree
|
305 |
-
* to load meta boxes for post formats.
|
306 |
-
*
|
307 |
-
* @since 2.4.0
|
308 |
-
*/
|
309 |
-
define( 'OT_POST_FORMATS', apply_filters( 'ot_post_formats', false ) );
|
310 |
-
|
311 |
-
/**
|
312 |
-
* Check if in theme mode.
|
313 |
-
*
|
314 |
-
* If OT_THEME_MODE and OT_CHILD_THEME_MODE is false, set the
|
315 |
-
* directory path & URL like any other plugin. Otherwise, use
|
316 |
-
* the parent or child themes root directory.
|
317 |
-
*
|
318 |
-
* @since 2.0
|
319 |
-
*/
|
320 |
-
if ( false == OT_THEME_MODE && false == OT_CHILD_THEME_MODE ) {
|
321 |
-
define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
|
322 |
-
define( 'OT_URL', plugin_dir_url( __FILE__ ) );
|
323 |
-
} else {
|
324 |
-
if ( true == OT_CHILD_THEME_MODE ) {
|
325 |
-
$path = ltrim( end( @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
|
326 |
-
define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) );
|
327 |
-
define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) );
|
328 |
-
} else {
|
329 |
-
$path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
|
330 |
-
define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) );
|
331 |
-
define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) );
|
332 |
-
}
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Template directory URI for the current theme.
|
337 |
-
*
|
338 |
-
* @since 2.1
|
339 |
-
*/
|
340 |
-
if ( true == OT_CHILD_THEME_MODE ) {
|
341 |
-
define( 'OT_THEME_URL', get_stylesheet_directory_uri() );
|
342 |
-
} else {
|
343 |
-
define( 'OT_THEME_URL', get_template_directory_uri() );
|
344 |
-
}
|
345 |
-
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* Include admin files
|
350 |
-
*
|
351 |
-
* These functions are included on admin pages only.
|
352 |
-
*
|
353 |
-
* @return void
|
354 |
-
*
|
355 |
-
* @access private
|
356 |
-
* @since 2.0
|
357 |
-
*/
|
358 |
-
private function admin_includes() {
|
359 |
-
|
360 |
-
/* exit early if we're not on an admin page */
|
361 |
-
if ( ! is_admin() )
|
362 |
-
return false;
|
363 |
-
|
364 |
-
/* global include files */
|
365 |
-
$files = array(
|
366 |
-
'ot-functions-admin',
|
367 |
-
'ot-functions-option-types',
|
368 |
-
'ot-functions-compat',
|
369 |
-
'ot-settings-api'
|
370 |
-
);
|
371 |
-
|
372 |
-
/* include the meta box api */
|
373 |
-
if ( OT_META_BOXES == true ) {
|
374 |
-
$files[] = 'ot-meta-box-api';
|
375 |
-
}
|
376 |
-
|
377 |
-
/* include the post formats api */
|
378 |
-
if ( OT_META_BOXES == true && OT_POST_FORMATS == true ) {
|
379 |
-
$files[] = 'ot-post-formats-api';
|
380 |
-
}
|
381 |
-
|
382 |
-
/* include the settings & docs pages */
|
383 |
-
if ( OT_SHOW_PAGES == true ) {
|
384 |
-
$files[] = 'ot-functions-settings-page';
|
385 |
-
$files[] = 'ot-functions-docs-page';
|
386 |
-
}
|
387 |
-
|
388 |
-
/* include the cleanup api */
|
389 |
-
$files[] = 'ot-cleanup-api';
|
390 |
-
|
391 |
-
/* require the files */
|
392 |
-
foreach ( $files as $file ) {
|
393 |
-
$this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" );
|
394 |
-
}
|
395 |
-
|
396 |
-
/* Registers the Theme Option page */
|
397 |
-
add_action( 'init', 'ot_register_theme_options_page' );
|
398 |
-
|
399 |
-
/* Registers the Settings page */
|
400 |
-
if ( OT_SHOW_PAGES == true ) {
|
401 |
-
add_action( 'init', 'ot_register_settings_page' );
|
402 |
-
|
403 |
-
/* global CSS */
|
404 |
-
add_action( 'admin_head', array( $this, 'global_admin_css' ) );
|
405 |
-
}
|
406 |
-
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Include front-end files
|
411 |
-
*
|
412 |
-
* These functions are included on every page load
|
413 |
-
* incase other plugins need to access them.
|
414 |
-
*
|
415 |
-
* @return void
|
416 |
-
*
|
417 |
-
* @access private
|
418 |
-
* @since 2.0
|
419 |
-
*/
|
420 |
-
private function includes() {
|
421 |
-
|
422 |
-
$files = array(
|
423 |
-
'ot-functions',
|
424 |
-
'ot-functions-deprecated'
|
425 |
-
);
|
426 |
-
|
427 |
-
/* require the files */
|
428 |
-
foreach ( $files as $file ) {
|
429 |
-
$this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" );
|
430 |
-
}
|
431 |
-
|
432 |
-
}
|
433 |
-
|
434 |
-
/**
|
435 |
-
* Execute the WordPress Hooks
|
436 |
-
*
|
437 |
-
* @return void
|
438 |
-
*
|
439 |
-
* @access public
|
440 |
-
* @since 2.0
|
441 |
-
*/
|
442 |
-
private function hooks() {
|
443 |
|
444 |
-
|
445 |
-
if ( function_exists( 'ot_maybe_migrate_settings' ) )
|
446 |
-
add_action( 'init', 'ot_maybe_migrate_settings', 1 );
|
447 |
|
448 |
-
|
449 |
-
if ( function_exists( 'ot_maybe_migrate_options' ) )
|
450 |
-
add_action( 'init', 'ot_maybe_migrate_options', 1 );
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
/* add scripts for metaboxes to post-new.php & post.php */
|
460 |
-
add_action( 'admin_print_scripts-post-new.php', 'ot_admin_scripts', 11 );
|
461 |
-
add_action( 'admin_print_scripts-post.php', 'ot_admin_scripts', 11 );
|
462 |
-
|
463 |
-
/* add styles for metaboxes to post-new.php & post.php */
|
464 |
-
add_action( 'admin_print_styles-post-new.php', 'ot_admin_styles', 11 );
|
465 |
-
add_action( 'admin_print_styles-post.php', 'ot_admin_styles', 11 );
|
466 |
-
|
467 |
-
}
|
468 |
-
|
469 |
-
/* Adds the Theme Option page to the admin bar */
|
470 |
-
|
471 |
-
|
472 |
-
/* prepares the after save do_action */
|
473 |
-
add_action( 'admin_init', 'ot_after_theme_options_save', 1 );
|
474 |
-
|
475 |
-
/* default settings */
|
476 |
-
add_action( 'admin_init', 'ot_default_settings', 2 );
|
477 |
-
|
478 |
-
/* add xml to upload filetypes array */
|
479 |
-
add_action( 'admin_init', 'ot_add_xml_to_upload_filetypes', 3 );
|
480 |
-
|
481 |
-
/* import */
|
482 |
-
add_action( 'admin_init', 'ot_import', 4 );
|
483 |
-
|
484 |
-
/* export */
|
485 |
-
add_action( 'admin_init', 'ot_export', 5 );
|
486 |
-
|
487 |
-
/* save settings */
|
488 |
-
add_action( 'admin_init', 'ot_save_settings', 6 );
|
489 |
-
|
490 |
-
/* save layouts */
|
491 |
-
add_action( 'admin_init', 'ot_modify_layouts', 7 );
|
492 |
-
|
493 |
-
/* create media post */
|
494 |
-
add_action( 'admin_init', 'ot_create_media_post', 8 );
|
495 |
-
|
496 |
-
/* Google Fonts front-end CSS */
|
497 |
-
add_action( 'wp_enqueue_scripts', 'ot_load_google_fonts_css', 1 );
|
498 |
-
|
499 |
-
/* dynamic front-end CSS */
|
500 |
-
add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 );
|
501 |
-
|
502 |
-
/* insert theme CSS dynamically */
|
503 |
-
add_action( 'ot_after_theme_options_save', 'ot_save_css' );
|
504 |
-
|
505 |
-
/* AJAX call to create a new section */
|
506 |
-
add_action( 'wp_ajax_add_section', array( $this, 'add_section' ) );
|
507 |
-
|
508 |
-
/* AJAX call to create a new setting */
|
509 |
-
add_action( 'wp_ajax_add_setting', array( $this, 'add_setting' ) );
|
510 |
-
|
511 |
-
/* AJAX call to create a new contextual help */
|
512 |
-
add_action( 'wp_ajax_add_the_contextual_help', array( $this, 'add_the_contextual_help' ) );
|
513 |
-
|
514 |
-
/* AJAX call to create a new choice */
|
515 |
-
add_action( 'wp_ajax_add_choice', array( $this, 'add_choice' ) );
|
516 |
-
|
517 |
-
/* AJAX call to create a new list item setting */
|
518 |
-
add_action( 'wp_ajax_add_list_item_setting', array( $this, 'add_list_item_setting' ) );
|
519 |
-
|
520 |
-
/* AJAX call to create a new layout */
|
521 |
-
add_action( 'wp_ajax_add_layout', array( $this, 'add_layout' ) );
|
522 |
-
|
523 |
-
/* AJAX call to create a new list item */
|
524 |
-
add_action( 'wp_ajax_add_list_item', array( $this, 'add_list_item' ) );
|
525 |
-
|
526 |
-
/* AJAX call to create a new social link */
|
527 |
-
add_action( 'wp_ajax_add_social_links', array( $this, 'add_social_links' ) );
|
528 |
-
|
529 |
-
/* AJAX call to retrieve Google Font data */
|
530 |
-
add_action( 'wp_ajax_ot_google_font', array( $this, 'retrieve_google_font' ) );
|
531 |
-
|
532 |
-
// Adds the temporary hacktastic shortcode
|
533 |
-
add_filter( 'media_view_settings', array( $this, 'shortcode' ), 10, 2 );
|
534 |
-
|
535 |
-
// AJAX update
|
536 |
-
add_action( 'wp_ajax_gallery_update', array( $this, 'ajax_gallery_update' ) );
|
537 |
-
|
538 |
-
/* Modify the media uploader button */
|
539 |
-
add_filter( 'gettext', array( $this, 'change_image_button' ), 10, 3 );
|
540 |
-
|
541 |
-
}
|
542 |
-
|
543 |
-
/**
|
544 |
-
* Load a file
|
545 |
-
*
|
546 |
-
* @return void
|
547 |
-
*
|
548 |
-
* @access private
|
549 |
-
* @since 2.0.15
|
550 |
-
*/
|
551 |
-
private function load_file( $file ){
|
552 |
-
|
553 |
-
include_once( $file );
|
554 |
-
|
555 |
-
}
|
556 |
-
|
557 |
-
/**
|
558 |
-
* Adds the global CSS to fix the menu icon.
|
559 |
-
*/
|
560 |
-
public function global_admin_css() {
|
561 |
-
global $wp_version;
|
562 |
-
|
563 |
-
$wp_38plus = version_compare( $wp_version, '3.8', '>=' ) ? true : false;
|
564 |
-
$fontsize = $wp_38plus ? '20px' : '16px';
|
565 |
-
$wp_38minus = '';
|
566 |
-
|
567 |
-
if ( ! $wp_38plus ) {
|
568 |
-
$wp_38minus = '
|
569 |
-
#adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image {
|
570 |
-
background: none;
|
571 |
-
}
|
572 |
-
#adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
|
573 |
-
padding-left: 6px;
|
574 |
-
}';
|
575 |
-
}
|
576 |
-
|
577 |
-
echo '
|
578 |
-
<style>
|
579 |
-
@font-face {
|
580 |
-
font-family: "option-tree-font";
|
581 |
-
src:url("' . OT_URL . 'assets/fonts/option-tree-font.eot");
|
582 |
-
src:url("' . OT_URL . 'assets/fonts/option-tree-font.eot?#iefix") format("embedded-opentype"),
|
583 |
-
url("' . OT_URL . 'assets/fonts/option-tree-font.woff") format("woff"),
|
584 |
-
url("' . OT_URL . 'assets/fonts/option-tree-font.ttf") format("truetype"),
|
585 |
-
url("' . OT_URL . 'assets/fonts/option-tree-font.svg#option-tree-font") format("svg");
|
586 |
-
font-weight: normal;
|
587 |
-
font-style: normal;
|
588 |
-
}
|
589 |
-
#adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
|
590 |
-
font: normal ' . $fontsize . '/1 "option-tree-font" !important;
|
591 |
-
speak: none;
|
592 |
-
padding: 6px 0;
|
593 |
-
height: 34px;
|
594 |
-
width: 20px;
|
595 |
-
display: inline-block;
|
596 |
-
-webkit-font-smoothing: antialiased;
|
597 |
-
-moz-osx-font-smoothing: grayscale;
|
598 |
-
-webkit-transition: all .1s ease-in-out;
|
599 |
-
-moz-transition: all .1s ease-in-out;
|
600 |
-
transition: all .1s ease-in-out;
|
601 |
-
}
|
602 |
-
#adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
|
603 |
-
content: "\e785";
|
604 |
-
}' . $wp_38minus . '
|
605 |
-
</style>
|
606 |
-
';
|
607 |
-
}
|
608 |
-
|
609 |
-
/**
|
610 |
-
* AJAX utility function for adding a new section.
|
611 |
-
*/
|
612 |
-
public function add_section() {
|
613 |
-
echo ot_sections_view( ot_settings_id() . '[sections]', $_REQUEST['count'] );
|
614 |
-
die();
|
615 |
-
}
|
616 |
-
|
617 |
-
/**
|
618 |
-
* AJAX utility function for adding a new setting.
|
619 |
-
*/
|
620 |
-
public function add_setting() {
|
621 |
-
echo ot_settings_view( $_REQUEST['name'], $_REQUEST['count'] );
|
622 |
-
die();
|
623 |
-
}
|
624 |
-
|
625 |
-
/**
|
626 |
-
* AJAX utility function for adding a new list item setting.
|
627 |
-
*/
|
628 |
-
public function add_list_item_setting() {
|
629 |
-
echo ot_settings_view( $_REQUEST['name'] . '[settings]', $_REQUEST['count'] );
|
630 |
-
die();
|
631 |
-
}
|
632 |
-
|
633 |
-
/**
|
634 |
-
* AJAX utility function for adding new contextual help content.
|
635 |
-
*/
|
636 |
-
public function add_the_contextual_help() {
|
637 |
-
echo ot_contextual_help_view( $_REQUEST['name'], $_REQUEST['count'] );
|
638 |
-
die();
|
639 |
-
}
|
640 |
-
|
641 |
-
/**
|
642 |
-
* AJAX utility function for adding a new choice.
|
643 |
-
*/
|
644 |
-
public function add_choice() {
|
645 |
-
echo ot_choices_view( $_REQUEST['name'], $_REQUEST['count'] );
|
646 |
-
die();
|
647 |
-
}
|
648 |
-
|
649 |
-
/**
|
650 |
-
* AJAX utility function for adding a new layout.
|
651 |
-
*/
|
652 |
-
public function add_layout() {
|
653 |
-
echo ot_layout_view( $_REQUEST['count'] );
|
654 |
-
die();
|
655 |
-
}
|
656 |
-
|
657 |
-
/**
|
658 |
-
* AJAX utility function for adding a new list item.
|
659 |
-
*/
|
660 |
-
public function add_list_item() {
|
661 |
-
check_ajax_referer( 'option_tree', 'nonce' );
|
662 |
-
ot_list_item_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
|
663 |
-
die();
|
664 |
-
}
|
665 |
-
|
666 |
-
/**
|
667 |
-
* AJAX utility function for adding a new social link.
|
668 |
-
*/
|
669 |
-
public function add_social_links() {
|
670 |
-
check_ajax_referer( 'option_tree', 'nonce' );
|
671 |
-
ot_social_links_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
|
672 |
-
die();
|
673 |
-
}
|
674 |
-
|
675 |
-
/**
|
676 |
-
* Fake the gallery shortcode
|
677 |
-
*
|
678 |
-
* The JS takes over and creates the actual shortcode with
|
679 |
-
* the real attachment IDs on the fly. Here we just need to
|
680 |
-
* pass in the post ID to get the ball rolling.
|
681 |
-
*
|
682 |
-
* @param array The current settings
|
683 |
-
* @param object The post object
|
684 |
-
* @return array
|
685 |
-
*
|
686 |
-
* @access public
|
687 |
-
* @since 2.2.0
|
688 |
-
*/
|
689 |
-
public function shortcode( $settings, $post ) {
|
690 |
-
global $pagenow;
|
691 |
-
|
692 |
-
if ( in_array( $pagenow, array( 'upload.php', 'customize.php' ) ) ) {
|
693 |
-
return $settings;
|
694 |
-
}
|
695 |
-
|
696 |
-
// Set the OptionTree post ID
|
697 |
-
if ( ! is_object( $post ) ) {
|
698 |
-
$post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_GET['post_ID'] ) ? $_GET['post_ID'] : 0 );
|
699 |
-
if ( $post_id == 0 && function_exists( 'ot_get_media_post_ID' ) ) {
|
700 |
-
$post_id = ot_get_media_post_ID();
|
701 |
-
}
|
702 |
-
$settings['post']['id'] = $post_id;
|
703 |
-
}
|
704 |
-
|
705 |
-
// No ID return settings
|
706 |
-
if ( $settings['post']['id'] == 0 )
|
707 |
-
return $settings;
|
708 |
-
|
709 |
-
// Set the fake shortcode
|
710 |
-
$settings['ot_gallery'] = array( 'shortcode' => "[gallery id='{$settings['post']['id']}']" );
|
711 |
-
|
712 |
-
// Return settings
|
713 |
-
return $settings;
|
714 |
-
|
715 |
-
}
|
716 |
-
|
717 |
-
/**
|
718 |
-
* Returns the AJAX images
|
719 |
-
*
|
720 |
-
* @return string
|
721 |
-
*
|
722 |
-
* @access public
|
723 |
-
* @since 2.2.0
|
724 |
-
*/
|
725 |
-
public function ajax_gallery_update() {
|
726 |
-
|
727 |
-
if ( ! empty( $_POST['ids'] ) ) {
|
728 |
-
|
729 |
-
$return = '';
|
730 |
-
|
731 |
-
foreach( $_POST['ids'] as $id ) {
|
732 |
-
|
733 |
-
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
|
734 |
-
|
735 |
-
$return .= '<li><img src="' . $thumbnail[0] . '" width="75" height="75" /></li>';
|
736 |
-
|
737 |
-
}
|
738 |
-
|
739 |
-
echo $return;
|
740 |
-
exit();
|
741 |
-
|
742 |
-
}
|
743 |
-
|
744 |
-
}
|
745 |
-
|
746 |
-
/**
|
747 |
-
* Returns a JSON encoded Google fonts array.
|
748 |
-
*
|
749 |
-
* @return array
|
750 |
-
*
|
751 |
-
* @access public
|
752 |
-
* @since 2.5.0
|
753 |
-
*/
|
754 |
-
public function retrieve_google_font() {
|
755 |
-
|
756 |
-
if ( isset( $_POST['field_id'], $_POST['family'] ) ) {
|
757 |
-
|
758 |
-
ot_fetch_google_fonts();
|
759 |
-
|
760 |
-
echo json_encode( array(
|
761 |
-
'variants' => ot_recognized_google_font_variants( $_POST['field_id'], $_POST['family'] ),
|
762 |
-
'subsets' => ot_recognized_google_font_subsets( $_POST['field_id'], $_POST['family'] )
|
763 |
-
) );
|
764 |
-
exit();
|
765 |
-
|
766 |
-
}
|
767 |
-
|
768 |
-
}
|
769 |
-
|
770 |
-
/**
|
771 |
-
* Filters the media uploader button.
|
772 |
-
*
|
773 |
-
* @return string
|
774 |
-
*
|
775 |
-
* @access public
|
776 |
-
* @since 2.1
|
777 |
-
*/
|
778 |
-
public function change_image_button( $translation, $text, $domain ) {
|
779 |
-
global $pagenow;
|
780 |
-
|
781 |
-
if ( $pagenow == apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) && 'default' == $domain && 'Insert into post' == $text ) {
|
782 |
-
|
783 |
-
// Once is enough.
|
784 |
-
remove_filter( 'gettext', array( $this, 'ot_change_image_button' ) );
|
785 |
-
return apply_filters( 'ot_upload_text', __( 'Add to coming soon page', 'option-tree' ) );
|
786 |
-
|
787 |
-
}
|
788 |
-
|
789 |
-
return $translation;
|
790 |
-
|
791 |
-
}
|
792 |
-
|
793 |
-
|
794 |
-
}
|
795 |
-
|
796 |
-
/**
|
797 |
-
* Instantiate the OptionTree loader class.
|
798 |
-
*
|
799 |
-
* @since 2.0
|
800 |
-
*/
|
801 |
-
$ot_loader = new OT_Loader();
|
802 |
|
|
|
803 |
}
|
804 |
|
805 |
-
|
806 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
* Plugin Name: OptionTree
|
4 |
* Plugin URI: https://github.com/valendesigns/option-tree/
|
5 |
* Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
|
6 |
+
* Version: 2.7.3
|
7 |
* Author: Derek Herman
|
8 |
* Author URI: http://valendesigns.com
|
9 |
+
* License: GPLv2 or later
|
10 |
* Text Domain: option-tree
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
*
|
12 |
+
* @package OptionTree
|
|
|
|
|
13 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && true === OT_PLUGIN_MODE && defined( 'ABSPATH' ) ) {
|
|
|
|
|
16 |
|
17 |
+
add_filter( 'ot_theme_mode', '__return_false', 999 );
|
|
|
|
|
18 |
|
19 |
+
/**
|
20 |
+
* Forces Plugin Mode when OptionTree is already loaded and displays an admin notice.
|
21 |
+
*/
|
22 |
+
function ot_conflict_notice() {
|
23 |
+
echo '<div class="error"><p>' . esc_html__( 'OptionTree is installed as a plugin and also embedded in your current theme. Please deactivate the plugin to load the theme dependent version of OptionTree, and remove this warning.', 'option-tree' ) . '</p></div>';
|
24 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
add_action( 'admin_notices', 'ot_conflict_notice' );
|
27 |
}
|
28 |
|
29 |
+
if ( ! class_exists( 'OT_Loader' ) && defined( 'ABSPATH' ) ) {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* OptionTree loader class.
|
33 |
+
*/
|
34 |
+
class OT_Loader {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Class constructor.
|
38 |
+
*
|
39 |
+
* This method loads other methods of the class.
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @since 2.0
|
43 |
+
*/
|
44 |
+
public function __construct() {
|
45 |
+
|
46 |
+
// Load OptionTree.
|
47 |
+
add_action( 'after_setup_theme', array( $this, 'load_option_tree' ), 1 );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* OptionTree loads on the 'after_setup_theme' action.
|
52 |
+
*
|
53 |
+
* @todo Load immediately.
|
54 |
+
*
|
55 |
+
* @access public
|
56 |
+
* @since 2.1.2
|
57 |
+
*/
|
58 |
+
public function load_option_tree() {
|
59 |
+
|
60 |
+
// Setup the constants.
|
61 |
+
$this->constants();
|
62 |
+
|
63 |
+
// Include the required admin files.
|
64 |
+
$this->admin_includes();
|
65 |
+
|
66 |
+
// Include the required files.
|
67 |
+
$this->includes();
|
68 |
+
|
69 |
+
// Hook into WordPress.
|
70 |
+
$this->hooks();
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Constants.
|
75 |
+
*
|
76 |
+
* Defines the constants for use within OptionTree. Constants
|
77 |
+
* are prefixed with 'OT_' to avoid any naming collisions.
|
78 |
+
*
|
79 |
+
* @access private
|
80 |
+
* @since 2.0
|
81 |
+
*/
|
82 |
+
private function constants() {
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Current Version number.
|
86 |
+
*/
|
87 |
+
define( 'OT_VERSION', '2.7.3' );
|
88 |
+
|
89 |
+
/**
|
90 |
+
* For developers: Theme mode.
|
91 |
+
*
|
92 |
+
* Run a filter and set to true to enable OptionTree theme mode.
|
93 |
+
* You must have this files parent directory inside of
|
94 |
+
* your themes root directory. As well, you must include
|
95 |
+
* a reference to this file in your themes functions.php.
|
96 |
+
*
|
97 |
+
* @since 2.0
|
98 |
+
*/
|
99 |
+
define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) );
|
100 |
+
|
101 |
+
/**
|
102 |
+
* For developers: Child Theme mode. TODO document
|
103 |
+
*
|
104 |
+
* Run a filter and set to true to enable OptionTree child theme mode.
|
105 |
+
* You must have this files parent directory inside of
|
106 |
+
* your themes root directory. As well, you must include
|
107 |
+
* a reference to this file in your themes functions.php.
|
108 |
+
*
|
109 |
+
* @since 2.0.15
|
110 |
+
*/
|
111 |
+
define( 'OT_CHILD_THEME_MODE', apply_filters( 'ot_child_theme_mode', false ) );
|
112 |
+
|
113 |
+
/**
|
114 |
+
* For developers: Show Pages.
|
115 |
+
*
|
116 |
+
* Run a filter and set to false if you don't want to load the
|
117 |
+
* settings & documentation pages in the admin area of WordPress.
|
118 |
+
*
|
119 |
+
* @since 2.0
|
120 |
+
*/
|
121 |
+
define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) );
|
122 |
+
|
123 |
+
/**
|
124 |
+
* For developers: Show Theme Options UI Builder
|
125 |
+
*
|
126 |
+
* Run a filter and set to false if you want to hide the
|
127 |
+
* Theme Options UI page in the admin area of WordPress.
|
128 |
+
*
|
129 |
+
* @since 2.1
|
130 |
+
*/
|
131 |
+
define( 'OT_SHOW_OPTIONS_UI', apply_filters( 'ot_show_options_ui', true ) );
|
132 |
+
|
133 |
+
/**
|
134 |
+
* For developers: Show Settings Import
|
135 |
+
*
|
136 |
+
* Run a filter and set to false if you want to hide the
|
137 |
+
* Settings Import options on the Import page.
|
138 |
+
*
|
139 |
+
* @since 2.1
|
140 |
+
*/
|
141 |
+
define( 'OT_SHOW_SETTINGS_IMPORT', apply_filters( 'ot_show_settings_import', true ) );
|
142 |
+
|
143 |
+
/**
|
144 |
+
* For developers: Show Settings Export
|
145 |
+
*
|
146 |
+
* Run a filter and set to false if you want to hide the
|
147 |
+
* Settings Import options on the Import page.
|
148 |
+
*
|
149 |
+
* @since 2.1
|
150 |
+
*/
|
151 |
+
define( 'OT_SHOW_SETTINGS_EXPORT', apply_filters( 'ot_show_settings_export', true ) );
|
152 |
+
|
153 |
+
/**
|
154 |
+
* For developers: Show New Layout.
|
155 |
+
*
|
156 |
+
* Run a filter and set to false if you don't want to show the
|
157 |
+
* "New Layout" section at the top of the theme options page.
|
158 |
+
*
|
159 |
+
* @since 2.0.10
|
160 |
+
*/
|
161 |
+
define( 'OT_SHOW_NEW_LAYOUT', apply_filters( 'ot_show_new_layout', true ) );
|
162 |
+
|
163 |
+
/**
|
164 |
+
* For developers: Show Documentation
|
165 |
+
*
|
166 |
+
* Run a filter and set to false if you want to hide the Documentation.
|
167 |
+
*
|
168 |
+
* @since 2.1
|
169 |
+
*/
|
170 |
+
define( 'OT_SHOW_DOCS', apply_filters( 'ot_show_docs', true ) );
|
171 |
+
|
172 |
+
/**
|
173 |
+
* For developers: Custom Theme Option page
|
174 |
+
*
|
175 |
+
* Run a filter and set to false if you want to hide the OptionTree
|
176 |
+
* Theme Option page and build your own.
|
177 |
+
*
|
178 |
+
* @since 2.1
|
179 |
+
*/
|
180 |
+
define( 'OT_USE_THEME_OPTIONS', apply_filters( 'ot_use_theme_options', true ) );
|
181 |
+
|
182 |
+
/**
|
183 |
+
* For developers: Meta Boxes.
|
184 |
+
*
|
185 |
+
* Run a filter and set to false to keep OptionTree from
|
186 |
+
* loading the meta box resources.
|
187 |
+
*
|
188 |
+
* @since 2.0
|
189 |
+
*/
|
190 |
+
define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) );
|
191 |
+
|
192 |
+
/**
|
193 |
+
* For developers: Allow Unfiltered HTML in all the textareas.
|
194 |
+
*
|
195 |
+
* Run a filter and set to true if you want all the users to be
|
196 |
+
* able to add script, style, and iframe tags in the textareas.
|
197 |
+
* WARNING: This opens a security hole for low level users
|
198 |
+
* to be able to post malicious scripts, you've been warned.
|
199 |
+
*
|
200 |
+
* If a user can already post `unfiltered_html` then the tags
|
201 |
+
* above will be available to them without setting this to `true`.
|
202 |
+
*
|
203 |
+
* @since 2.0
|
204 |
+
*/
|
205 |
+
define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) );
|
206 |
+
|
207 |
+
/**
|
208 |
+
* For developers: Post Formats.
|
209 |
+
*
|
210 |
+
* Run a filter and set to true if you want OptionTree
|
211 |
+
* to load meta boxes for post formats.
|
212 |
+
*
|
213 |
+
* @since 2.4.0
|
214 |
+
*/
|
215 |
+
define( 'OT_POST_FORMATS', apply_filters( 'ot_post_formats', false ) );
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Check if in theme mode.
|
219 |
+
*
|
220 |
+
* If OT_THEME_MODE and OT_CHILD_THEME_MODE is false, set the
|
221 |
+
* directory path & URL like any other plugin. Otherwise, use
|
222 |
+
* the parent or child themes root directory.
|
223 |
+
*
|
224 |
+
* @since 2.0
|
225 |
+
*/
|
226 |
+
if ( false === OT_THEME_MODE && false === OT_CHILD_THEME_MODE ) {
|
227 |
+
define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
|
228 |
+
define( 'OT_URL', plugin_dir_url( __FILE__ ) );
|
229 |
+
} else {
|
230 |
+
if ( true === OT_CHILD_THEME_MODE ) {
|
231 |
+
$temp_path = explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
232 |
+
$path = ltrim( end( $temp_path ), '/' );
|
233 |
+
define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) );
|
234 |
+
define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) );
|
235 |
+
} else {
|
236 |
+
$temp_path = explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
237 |
+
$path = ltrim( end( $temp_path ), '/' );
|
238 |
+
define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) );
|
239 |
+
define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Template directory URI for the current theme.
|
245 |
+
*
|
246 |
+
* @since 2.1
|
247 |
+
*/
|
248 |
+
if ( true === OT_CHILD_THEME_MODE ) {
|
249 |
+
define( 'OT_THEME_URL', get_stylesheet_directory_uri() );
|
250 |
+
} else {
|
251 |
+
define( 'OT_THEME_URL', get_template_directory_uri() );
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Include admin files.
|
257 |
+
*
|
258 |
+
* These functions are included on admin pages only.
|
259 |
+
*
|
260 |
+
* @access private
|
261 |
+
* @since 2.0
|
262 |
+
*/
|
263 |
+
private function admin_includes() {
|
264 |
+
|
265 |
+
// Exit early if we're not on an admin page.
|
266 |
+
if ( ! is_admin() ) {
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
|
270 |
+
// Global include files.
|
271 |
+
$files = array(
|
272 |
+
'ot-functions-admin',
|
273 |
+
'ot-functions-option-types',
|
274 |
+
'ot-functions-compat',
|
275 |
+
'class-ot-settings',
|
276 |
+
);
|
277 |
+
|
278 |
+
// Include the meta box api.
|
279 |
+
if ( true === OT_META_BOXES ) {
|
280 |
+
$files[] = 'class-ot-meta-box';
|
281 |
+
}
|
282 |
+
|
283 |
+
// Include the post formats api.
|
284 |
+
if ( true === OT_META_BOXES && true === OT_POST_FORMATS ) {
|
285 |
+
$files[] = 'class-ot-post-formats';
|
286 |
+
}
|
287 |
+
|
288 |
+
// Include the settings & docs pages.
|
289 |
+
if ( true === OT_SHOW_PAGES ) {
|
290 |
+
$files[] = 'ot-functions-settings-page';
|
291 |
+
$files[] = 'ot-functions-docs-page';
|
292 |
+
}
|
293 |
+
|
294 |
+
// Include the cleanup api.
|
295 |
+
$files[] = 'class-ot-cleanup';
|
296 |
+
|
297 |
+
// Require the files.
|
298 |
+
foreach ( $files as $file ) {
|
299 |
+
$this->load_file( OT_DIR . 'includes' . DIRECTORY_SEPARATOR . "{$file}.php" );
|
300 |
+
}
|
301 |
+
|
302 |
+
// Registers the Theme Option page.
|
303 |
+
add_action( 'init', 'ot_register_theme_options_page' );
|
304 |
+
|
305 |
+
// Registers the Settings page.
|
306 |
+
if ( true === OT_SHOW_PAGES ) {
|
307 |
+
add_action( 'init', 'ot_register_settings_page' );
|
308 |
+
|
309 |
+
// Global CSS.
|
310 |
+
add_action( 'admin_head', array( $this, 'global_admin_css' ) );
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Include front-end files.
|
316 |
+
*
|
317 |
+
* These functions are included on every page load
|
318 |
+
* incase other plugins need to access them.
|
319 |
+
*
|
320 |
+
* @access private
|
321 |
+
* @since 2.0
|
322 |
+
*/
|
323 |
+
private function includes() {
|
324 |
+
|
325 |
+
$files = array(
|
326 |
+
'ot-functions',
|
327 |
+
'ot-functions-deprecated',
|
328 |
+
);
|
329 |
+
|
330 |
+
// Require the files.
|
331 |
+
foreach ( $files as $file ) {
|
332 |
+
$this->load_file( OT_DIR . 'includes' . DIRECTORY_SEPARATOR . "{$file}.php" );
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* Execute the WordPress Hooks.
|
338 |
+
*
|
339 |
+
* @access public
|
340 |
+
* @since 2.0
|
341 |
+
*/
|
342 |
+
private function hooks() {
|
343 |
+
|
344 |
+
// Attempt to migrate the settings.
|
345 |
+
if ( function_exists( 'ot_maybe_migrate_settings' ) ) {
|
346 |
+
add_action( 'init', 'ot_maybe_migrate_settings', 1 );
|
347 |
+
}
|
348 |
+
|
349 |
+
// Attempt to migrate the Options.
|
350 |
+
if ( function_exists( 'ot_maybe_migrate_options' ) ) {
|
351 |
+
add_action( 'init', 'ot_maybe_migrate_options', 1 );
|
352 |
+
}
|
353 |
+
|
354 |
+
// Attempt to migrate the Layouts.
|
355 |
+
if ( function_exists( 'ot_maybe_migrate_layouts' ) ) {
|
356 |
+
add_action( 'init', 'ot_maybe_migrate_layouts', 1 );
|
357 |
+
}
|
358 |
+
|
359 |
+
// Load the Meta Box assets.
|
360 |
+
if ( true === OT_META_BOXES ) {
|
361 |
+
|
362 |
+
// Add scripts for metaboxes to post-new.php & post.php.
|
363 |
+
add_action( 'admin_print_scripts-post-new.php', 'ot_admin_scripts', 11 );
|
364 |
+
add_action( 'admin_print_scripts-post.php', 'ot_admin_scripts', 11 );
|
365 |
+
|
366 |
+
// Add styles for metaboxes to post-new.php & post.php.
|
367 |
+
add_action( 'admin_print_styles-post-new.php', 'ot_admin_styles', 11 );
|
368 |
+
add_action( 'admin_print_styles-post.php', 'ot_admin_styles', 11 );
|
369 |
+
|
370 |
+
}
|
371 |
+
|
372 |
+
// Adds the Theme Option page to the admin bar.
|
373 |
+
add_action( 'admin_bar_menu', 'ot_register_theme_options_admin_bar_menu', 999 );
|
374 |
+
|
375 |
+
// Prepares the after save do_action.
|
376 |
+
add_action( 'admin_init', 'ot_after_theme_options_save', 1 );
|
377 |
+
|
378 |
+
// default settings.
|
379 |
+
add_action( 'admin_init', 'ot_default_settings', 2 );
|
380 |
+
|
381 |
+
// Import.
|
382 |
+
add_action( 'admin_init', 'ot_import', 4 );
|
383 |
+
|
384 |
+
// Export.
|
385 |
+
add_action( 'admin_init', 'ot_export', 5 );
|
386 |
+
|
387 |
+
// Save settings.
|
388 |
+
add_action( 'admin_init', 'ot_save_settings', 6 );
|
389 |
+
|
390 |
+
// Save layouts.
|
391 |
+
add_action( 'admin_init', 'ot_modify_layouts', 7 );
|
392 |
+
|
393 |
+
// Create media post.
|
394 |
+
add_action( 'admin_init', 'ot_create_media_post', 8 );
|
395 |
+
|
396 |
+
// Google Fonts front-end CSS.
|
397 |
+
add_action( 'wp_enqueue_scripts', 'ot_load_google_fonts_css', 1 );
|
398 |
+
|
399 |
+
// Dynamic front-end CSS.
|
400 |
+
add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 );
|
401 |
+
|
402 |
+
// Insert theme CSS dynamically.
|
403 |
+
add_action( 'ot_after_theme_options_save', 'ot_save_css' );
|
404 |
+
|
405 |
+
// AJAX call to create a new section.
|
406 |
+
add_action( 'wp_ajax_add_section', array( $this, 'add_section' ) );
|
407 |
+
|
408 |
+
// AJAX call to create a new setting.
|
409 |
+
add_action( 'wp_ajax_add_setting', array( $this, 'add_setting' ) );
|
410 |
+
|
411 |
+
// AJAX call to create a new contextual help.
|
412 |
+
add_action( 'wp_ajax_add_the_contextual_help', array( $this, 'add_the_contextual_help' ) );
|
413 |
+
|
414 |
+
// AJAX call to create a new choice.
|
415 |
+
add_action( 'wp_ajax_add_choice', array( $this, 'add_choice' ) );
|
416 |
+
|
417 |
+
// AJAX call to create a new list item setting.
|
418 |
+
add_action( 'wp_ajax_add_list_item_setting', array( $this, 'add_list_item_setting' ) );
|
419 |
+
|
420 |
+
// AJAX call to create a new layout.
|
421 |
+
add_action( 'wp_ajax_add_layout', array( $this, 'add_layout' ) );
|
422 |
+
|
423 |
+
// AJAX call to create a new list item.
|
424 |
+
add_action( 'wp_ajax_add_list_item', array( $this, 'add_list_item' ) );
|
425 |
+
|
426 |
+
// AJAX call to create a new social link.
|
427 |
+
add_action( 'wp_ajax_add_social_links', array( $this, 'add_social_links' ) );
|
428 |
+
|
429 |
+
// AJAX call to retrieve Google Font data.
|
430 |
+
add_action( 'wp_ajax_ot_google_font', array( $this, 'retrieve_google_font' ) );
|
431 |
+
|
432 |
+
// Adds the temporary hacktastic shortcode.
|
433 |
+
add_filter( 'media_view_settings', array( $this, 'shortcode' ), 10, 2 );
|
434 |
+
|
435 |
+
// AJAX update.
|
436 |
+
add_action( 'wp_ajax_gallery_update', array( $this, 'ajax_gallery_update' ) );
|
437 |
+
|
438 |
+
// Modify the media uploader button.
|
439 |
+
add_filter( 'gettext', array( $this, 'change_image_button' ), 10, 3 );
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Load a file.
|
444 |
+
*
|
445 |
+
* @access private
|
446 |
+
* @since 2.0.15
|
447 |
+
*
|
448 |
+
* @param string $file Path to the file being included.
|
449 |
+
*/
|
450 |
+
private function load_file( $file ) {
|
451 |
+
include_once $file;
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Adds CSS for the menu icon.
|
456 |
+
*/
|
457 |
+
public function global_admin_css() {
|
458 |
+
?>
|
459 |
+
<style>
|
460 |
+
@font-face {
|
461 |
+
font-family: "option-tree-font";
|
462 |
+
src:url("<?php echo esc_url_raw( OT_URL ); ?>assets/fonts/option-tree-font.eot");
|
463 |
+
src:url("<?php echo esc_url_raw( OT_URL ); ?>assets/fonts/option-tree-font.eot?#iefix") format("embedded-opentype"),
|
464 |
+
url("<?php echo esc_url_raw( OT_URL ); ?>assets/fonts/option-tree-font.woff") format("woff"),
|
465 |
+
url("<?php echo esc_url_raw( OT_URL ); ?>assets/fonts/option-tree-font.ttf") format("truetype"),
|
466 |
+
url("<?php echo esc_url_raw( OT_URL ); ?>assets/fonts/option-tree-font.svg#option-tree-font") format("svg");
|
467 |
+
font-weight: normal;
|
468 |
+
font-style: normal;
|
469 |
+
}
|
470 |
+
#adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
|
471 |
+
font: normal 20px/1 "option-tree-font" !important;
|
472 |
+
speak: none;
|
473 |
+
padding: 6px 0;
|
474 |
+
height: 34px;
|
475 |
+
width: 20px;
|
476 |
+
display: inline-block;
|
477 |
+
-webkit-font-smoothing: antialiased;
|
478 |
+
-moz-osx-font-smoothing: grayscale;
|
479 |
+
-webkit-transition: all .1s ease-in-out;
|
480 |
+
-moz-transition: all .1s ease-in-out;
|
481 |
+
transition: all .1s ease-in-out;
|
482 |
+
}
|
483 |
+
#adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
|
484 |
+
content: "\e785";
|
485 |
+
}
|
486 |
+
</style>
|
487 |
+
<?php
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* AJAX utility function for adding a new section.
|
492 |
+
*/
|
493 |
+
public function add_section() {
|
494 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
495 |
+
|
496 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
497 |
+
$output = ot_sections_view( ot_settings_id() . '[sections]', $count );
|
498 |
+
|
499 |
+
echo $output; // phpcs:ignore
|
500 |
+
wp_die();
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* AJAX utility function for adding a new setting.
|
505 |
+
*/
|
506 |
+
public function add_setting() {
|
507 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
508 |
+
|
509 |
+
$name = isset( $_REQUEST['name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['name'] ) ) : '';
|
510 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
511 |
+
$output = ot_settings_view( $name, $count );
|
512 |
+
|
513 |
+
echo $output; // phpcs:ignore
|
514 |
+
wp_die();
|
515 |
+
}
|
516 |
+
|
517 |
+
/**
|
518 |
+
* AJAX utility function for adding a new list item setting.
|
519 |
+
*/
|
520 |
+
public function add_list_item_setting() {
|
521 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
522 |
+
|
523 |
+
$name = isset( $_REQUEST['name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['name'] ) ) : '';
|
524 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
525 |
+
$output = ot_settings_view( $name . '[settings]', $count );
|
526 |
+
|
527 |
+
echo $output; // phpcs:ignore
|
528 |
+
wp_die();
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* AJAX utility function for adding new contextual help content.
|
533 |
+
*/
|
534 |
+
public function add_the_contextual_help() {
|
535 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
536 |
+
|
537 |
+
$name = isset( $_REQUEST['name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['name'] ) ) : '';
|
538 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
539 |
+
$output = ot_contextual_help_view( $name, $count );
|
540 |
+
|
541 |
+
echo $output; // phpcs:ignore
|
542 |
+
wp_die();
|
543 |
+
}
|
544 |
+
|
545 |
+
/**
|
546 |
+
* AJAX utility function for adding a new choice.
|
547 |
+
*/
|
548 |
+
public function add_choice() {
|
549 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
550 |
+
|
551 |
+
$name = isset( $_REQUEST['name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['name'] ) ) : '';
|
552 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
553 |
+
$output = ot_choices_view( $name, $count );
|
554 |
+
|
555 |
+
echo $output; // phpcs:ignore
|
556 |
+
wp_die();
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* AJAX utility function for adding a new layout.
|
561 |
+
*/
|
562 |
+
public function add_layout() {
|
563 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
564 |
+
|
565 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
566 |
+
$output = ot_layout_view( $count );
|
567 |
+
|
568 |
+
echo $output; // phpcs:ignore
|
569 |
+
wp_die();
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* AJAX utility function for adding a new list item.
|
574 |
+
*/
|
575 |
+
public function add_list_item() {
|
576 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
577 |
+
|
578 |
+
$name = isset( $_REQUEST['name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['name'] ) ) : '';
|
579 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
580 |
+
$post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0;
|
581 |
+
$get_option = isset( $_REQUEST['get_option'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['get_option'] ) ) : '';
|
582 |
+
$type = isset( $_REQUEST['type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) : '';
|
583 |
+
$settings = isset( $_REQUEST['settings'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) ) : array();
|
584 |
+
|
585 |
+
ot_list_item_view( $name, $count, array(), $post_id, $get_option, $settings, $type );
|
586 |
+
wp_die();
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* AJAX utility function for adding a new social link.
|
591 |
+
*/
|
592 |
+
public function add_social_links() {
|
593 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
594 |
+
|
595 |
+
$name = isset( $_REQUEST['name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['name'] ) ) : '';
|
596 |
+
$count = isset( $_REQUEST['count'] ) ? absint( $_REQUEST['count'] ) : 0;
|
597 |
+
$post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0;
|
598 |
+
$get_option = isset( $_REQUEST['get_option'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['get_option'] ) ) : '';
|
599 |
+
$type = isset( $_REQUEST['type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) : '';
|
600 |
+
$settings = isset( $_REQUEST['settings'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) ) : array();
|
601 |
+
|
602 |
+
ot_social_links_view( $name, $count, array(), $post_id, $get_option, $settings, $type );
|
603 |
+
wp_die();
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Fake the gallery shortcode.
|
608 |
+
*
|
609 |
+
* The JS takes over and creates the actual shortcode with
|
610 |
+
* the real attachment IDs on the fly. Here we just need to
|
611 |
+
* pass in the post ID to get the ball rolling.
|
612 |
+
*
|
613 |
+
* @access public
|
614 |
+
* @since 2.2.0
|
615 |
+
*
|
616 |
+
* @param array $settings The current settings.
|
617 |
+
* @param object $post The post object.
|
618 |
+
* @return array
|
619 |
+
*/
|
620 |
+
public function shortcode( $settings, $post ) {
|
621 |
+
global $pagenow;
|
622 |
+
|
623 |
+
if ( in_array( $pagenow, array( 'upload.php', 'customize.php' ), true ) ) {
|
624 |
+
return $settings;
|
625 |
+
}
|
626 |
+
|
627 |
+
// Set the OptionTree post ID.
|
628 |
+
if ( ! is_object( $post ) ) {
|
629 |
+
$post_id = isset( $_GET['post'] ) ? absint( $_GET['post'] ) : ( isset( $_GET['post_ID'] ) ? absint( $_GET['post_ID'] ) : 0 ); // phpcs:ignore
|
630 |
+
if ( 0 >= $post_id && function_exists( 'ot_get_media_post_ID' ) ) {
|
631 |
+
$post_id = ot_get_media_post_ID();
|
632 |
+
}
|
633 |
+
$settings['post']['id'] = $post_id;
|
634 |
+
}
|
635 |
+
|
636 |
+
// No ID return settings.
|
637 |
+
if ( 0 >= $settings['post']['id'] ) {
|
638 |
+
return $settings;
|
639 |
+
}
|
640 |
+
|
641 |
+
// Set the fake shortcode.
|
642 |
+
$settings['ot_gallery'] = array( 'shortcode' => "[gallery id='{$settings['post']['id']}']" );
|
643 |
+
|
644 |
+
// Return settings.
|
645 |
+
return $settings;
|
646 |
+
}
|
647 |
+
|
648 |
+
/**
|
649 |
+
* AJAX to generate HTML for a list of gallery images.
|
650 |
+
*
|
651 |
+
* @access public
|
652 |
+
* @since 2.2.0
|
653 |
+
*/
|
654 |
+
public function ajax_gallery_update() {
|
655 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
656 |
+
|
657 |
+
if ( ! empty( $_POST['ids'] ) && is_array( $_POST['ids'] ) ) {
|
658 |
+
|
659 |
+
$html = '';
|
660 |
+
$ids = array_filter( $_POST['ids'], 'absint' ); // phpcs:ignore
|
661 |
+
|
662 |
+
foreach ( $ids as $id ) {
|
663 |
+
|
664 |
+
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
|
665 |
+
|
666 |
+
$html .= '<li><img src="' . esc_url_raw( $thumbnail[0] ) . '" width="75" height="75" /></li>';
|
667 |
+
}
|
668 |
+
|
669 |
+
echo $html; // phpcs:ignore
|
670 |
+
}
|
671 |
+
|
672 |
+
wp_die();
|
673 |
+
}
|
674 |
+
|
675 |
+
/**
|
676 |
+
* The JSON encoded Google fonts data, or false if it cannot be encoded.
|
677 |
+
*
|
678 |
+
* @access public
|
679 |
+
* @since 2.5.0
|
680 |
+
*/
|
681 |
+
public function retrieve_google_font() {
|
682 |
+
check_ajax_referer( 'option_tree', 'nonce' );
|
683 |
+
|
684 |
+
if ( isset( $_POST['field_id'], $_POST['family'] ) ) {
|
685 |
+
|
686 |
+
ot_fetch_google_fonts();
|
687 |
+
|
688 |
+
$field_id = isset( $_POST['field_id'] ) ? sanitize_text_field( wp_unslash( $_POST['field_id'] ) ) : '';
|
689 |
+
$family = isset( $_POST['family'] ) ? sanitize_text_field( wp_unslash( $_POST['family'] ) ) : '';
|
690 |
+
$html = wp_json_encode(
|
691 |
+
array(
|
692 |
+
'variants' => ot_recognized_google_font_variants( $field_id, $family ),
|
693 |
+
'subsets' => ot_recognized_google_font_subsets( $field_id, $family ),
|
694 |
+
)
|
695 |
+
);
|
696 |
+
|
697 |
+
echo $html; // phpcs:ignore
|
698 |
+
}
|
699 |
+
|
700 |
+
wp_die();
|
701 |
+
}
|
702 |
+
|
703 |
+
/**
|
704 |
+
* Filters the media uploader button.
|
705 |
+
*
|
706 |
+
* @access public
|
707 |
+
* @since 2.1
|
708 |
+
*
|
709 |
+
* @param string $translation Translated text.
|
710 |
+
* @param string $text Text to translate.
|
711 |
+
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
712 |
+
*
|
713 |
+
* @return string
|
714 |
+
*/
|
715 |
+
public function change_image_button( $translation, $text, $domain ) {
|
716 |
+
global $pagenow;
|
717 |
+
|
718 |
+
if ( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) === $pagenow && 'default' === $domain && 'Insert into post' === $text ) {
|
719 |
+
|
720 |
+
// Once is enough.
|
721 |
+
remove_filter( 'gettext', array( $this, 'ot_change_image_button' ) );
|
722 |
+
return apply_filters( 'ot_upload_text', esc_html__( 'Send to OptionTree', 'option-tree' ) );
|
723 |
+
|
724 |
+
}
|
725 |
+
|
726 |
+
return $translation;
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
/**
|
731 |
+
* Instantiate the OptionTree loader class.
|
732 |
+
*
|
733 |
+
* @since 2.0
|
734 |
+
*/
|
735 |
+
new OT_Loader();
|
736 |
+
}
|
nifty-coming-soon.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Nifty Coming Soon & Maintenance page
|
4 |
Plugin URI: https://wordpress.org/plugins/nifty-coming-soon-and-under-construction-page/
|
5 |
Description: Easy to set up Coming Soon, Maintenance and Under Construction page. It features Responsive design, Countdown timer, Animations, Live Preview, Background Slider, Subscription form and more.
|
6 |
-
Version: 1.
|
7 |
Author: WebFactory Ltd
|
8 |
Author URI: https://webfactoryltd.com/
|
9 |
License: GPLv3
|
3 |
Plugin Name: Nifty Coming Soon & Maintenance page
|
4 |
Plugin URI: https://wordpress.org/plugins/nifty-coming-soon-and-under-construction-page/
|
5 |
Description: Easy to set up Coming Soon, Maintenance and Under Construction page. It features Responsive design, Countdown timer, Animations, Live Preview, Background Slider, Subscription form and more.
|
6 |
+
Version: 1.50
|
7 |
Author: WebFactory Ltd
|
8 |
Author URI: https://webfactoryltd.com/
|
9 |
License: GPLv3
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Coming Soon, Under Construction & Maintenance Page ===
|
2 |
-
Contributors: WebFactory
|
3 |
Tags: coming soon, coming soon page, launch page, maintenance mode, maintenance page, coming soon mode, under construction, maintenance mode page, landing page, offline page, subscribe form, maintenance
|
4 |
-
Tested up to: 5.
|
5 |
License: GPLv3
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
-
Stable tag: 1.
|
8 |
Requires PHP: 5.2
|
9 |
|
10 |
Nifty Coming Soon, Under Construction & Maintenance page creates awesome Coming Soon & Maintenance Pages with premium features for free.
|
@@ -88,6 +88,10 @@ As from the update of 1.0.9, the plugin offers the way to Live Preview you're Co
|
|
88 |
|
89 |
== Changelog ==
|
90 |
|
|
|
|
|
|
|
|
|
91 |
= 1.45 =
|
92 |
* 2019/02/19
|
93 |
* 20k installs hit on 2018/12/18 with 101,500 downloads
|
1 |
=== Coming Soon, Under Construction & Maintenance Page ===
|
2 |
+
Contributors: WebFactory
|
3 |
Tags: coming soon, coming soon page, launch page, maintenance mode, maintenance page, coming soon mode, under construction, maintenance mode page, landing page, offline page, subscribe form, maintenance
|
4 |
+
Tested up to: 5.2
|
5 |
License: GPLv3
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
+
Stable tag: 1.50
|
8 |
Requires PHP: 5.2
|
9 |
|
10 |
Nifty Coming Soon, Under Construction & Maintenance page creates awesome Coming Soon & Maintenance Pages with premium features for free.
|
88 |
|
89 |
== Changelog ==
|
90 |
|
91 |
+
= 1.50 =
|
92 |
+
* 2019/05/19
|
93 |
+
* OptionTree security fix
|
94 |
+
|
95 |
= 1.45 =
|
96 |
* 2019/02/19
|
97 |
* 20k installs hit on 2018/12/18 with 101,500 downloads
|