Version Description
- 2018/11/27
- minor vulnerability removed
- few bugs fixed
Download this release
Release Info
| Developer | WebFactory |
| Plugin | |
| Version | 1.42 |
| Comparing to | |
| See all releases | |
Code changes from version 1.40 to 1.42
- admin/includes/ot-cleanup-api.php +19 -19
- admin/includes/ot-functions-admin.php +943 -943
- admin/includes/ot-settings-api.php +6 -1
- admin/main-options.php +11 -5
- nifty-coming-soon.php +8 -6
- readme.txt +7 -2
admin/includes/ot-cleanup-api.php
CHANGED
|
@@ -11,7 +11,7 @@
|
|
| 11 |
if ( ! class_exists( 'OT_Cleanup' ) ) {
|
| 12 |
|
| 13 |
class OT_Cleanup {
|
| 14 |
-
|
| 15 |
/**
|
| 16 |
* PHP5 constructor method.
|
| 17 |
*
|
|
@@ -30,15 +30,15 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 30 |
|
| 31 |
// Load styles
|
| 32 |
add_action( 'admin_head', array( $this, 'styles' ), 1 );
|
| 33 |
-
|
| 34 |
// Maybe Clean up OptionTree
|
| 35 |
add_action( 'admin_menu', array( $this, 'maybe_cleanup' ), 100 );
|
| 36 |
-
|
| 37 |
// Increase timeout if allowed
|
| 38 |
add_action( 'ot_pre_consolidate_posts', array( $this, 'increase_timeout' ) );
|
| 39 |
-
|
| 40 |
}
|
| 41 |
-
|
| 42 |
/**
|
| 43 |
* Adds the cleanup styles to the admin head
|
| 44 |
*
|
|
@@ -52,7 +52,7 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 52 |
echo '<style>#toplevel_page_ot-cleanup{display:none;}</style>';
|
| 53 |
|
| 54 |
}
|
| 55 |
-
|
| 56 |
/**
|
| 57 |
* Check if OptionTree needs to be cleaned up from a previous install.
|
| 58 |
*
|
|
@@ -70,12 +70,12 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 70 |
$ot_maybe_cleanup_table = $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) == $table_name;
|
| 71 |
|
| 72 |
if ( ! $ot_maybe_cleanup_posts && ! $ot_maybe_cleanup_table && $page == 'ot-cleanup' ) {
|
| 73 |
-
|
| 74 |
exit;
|
| 75 |
}
|
| 76 |
|
| 77 |
if ( $ot_maybe_cleanup_posts || $ot_maybe_cleanup_table ) {
|
| 78 |
-
|
| 79 |
if ( $page != 'ot-cleanup' )
|
| 80 |
add_action( 'admin_notices', array( $this, 'cleanup_notice' ) );
|
| 81 |
|
|
@@ -84,9 +84,9 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 84 |
$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' ) );
|
| 85 |
|
| 86 |
}
|
| 87 |
-
|
| 88 |
}
|
| 89 |
-
|
| 90 |
/**
|
| 91 |
* Adds an admin nag.
|
| 92 |
*
|
|
@@ -99,7 +99,7 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 99 |
|
| 100 |
if ( get_current_screen()->id != 'appearance_page_ot-cleanup' )
|
| 101 |
echo '<div class="update-nag">' . sprintf( __( 'OptionTree has outdated data that should be removed. Please go to %s for more information.', 'option-tree' ), sprintf( '<a href="%s">%s</a>', admin_url( 'themes.php?page=ot-cleanup' ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ) ) ) . '</div>';
|
| 102 |
-
|
| 103 |
}
|
| 104 |
|
| 105 |
/**
|
|
@@ -181,7 +181,7 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 181 |
</script>';
|
| 182 |
break;
|
| 183 |
}
|
| 184 |
-
|
| 185 |
// Get the attachements
|
| 186 |
$attachments = get_children( 'post_type=attachment&post_parent=' . $post->ID );
|
| 187 |
|
|
@@ -191,7 +191,7 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 191 |
echo 'Updating Attachments parent ID for <tt>option-tree</tt> post <tt>#' . $post->ID . '</tt>.<br />';
|
| 192 |
|
| 193 |
foreach( $attachments as $attachment_id => $attachment ) {
|
| 194 |
-
wp_update_post(
|
| 195 |
array(
|
| 196 |
'ID' => $attachment_id,
|
| 197 |
'post_parent' => $post_ID
|
|
@@ -260,7 +260,7 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 260 |
}
|
| 261 |
|
| 262 |
}
|
| 263 |
-
|
| 264 |
echo '</div>';
|
| 265 |
|
| 266 |
}
|
|
@@ -276,13 +276,13 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 276 |
* @since 2.4.6
|
| 277 |
*/
|
| 278 |
public function increase_timeout() {
|
| 279 |
-
|
| 280 |
if ( ! ini_get( 'safe_mode' ) ) {
|
| 281 |
-
|
| 282 |
@set_time_limit( 0 );
|
| 283 |
-
|
| 284 |
}
|
| 285 |
-
|
| 286 |
}
|
| 287 |
|
| 288 |
}
|
|
@@ -292,4 +292,4 @@ if ( ! class_exists( 'OT_Cleanup' ) ) {
|
|
| 292 |
new OT_Cleanup();
|
| 293 |
|
| 294 |
/* End of file ot-cleanup-api.php */
|
| 295 |
-
/* Location: ./includes/ot-cleanup-api.php */
|
| 11 |
if ( ! class_exists( 'OT_Cleanup' ) ) {
|
| 12 |
|
| 13 |
class OT_Cleanup {
|
| 14 |
+
|
| 15 |
/**
|
| 16 |
* PHP5 constructor method.
|
| 17 |
*
|
| 30 |
|
| 31 |
// Load styles
|
| 32 |
add_action( 'admin_head', array( $this, 'styles' ), 1 );
|
| 33 |
+
|
| 34 |
// Maybe Clean up OptionTree
|
| 35 |
add_action( 'admin_menu', array( $this, 'maybe_cleanup' ), 100 );
|
| 36 |
+
|
| 37 |
// Increase timeout if allowed
|
| 38 |
add_action( 'ot_pre_consolidate_posts', array( $this, 'increase_timeout' ) );
|
| 39 |
+
|
| 40 |
}
|
| 41 |
+
|
| 42 |
/**
|
| 43 |
* Adds the cleanup styles to the admin head
|
| 44 |
*
|
| 52 |
echo '<style>#toplevel_page_ot-cleanup{display:none;}</style>';
|
| 53 |
|
| 54 |
}
|
| 55 |
+
|
| 56 |
/**
|
| 57 |
* Check if OptionTree needs to be cleaned up from a previous install.
|
| 58 |
*
|
| 70 |
$ot_maybe_cleanup_table = $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) == $table_name;
|
| 71 |
|
| 72 |
if ( ! $ot_maybe_cleanup_posts && ! $ot_maybe_cleanup_table && $page == 'ot-cleanup' ) {
|
| 73 |
+
wp_safe_redirect( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) );
|
| 74 |
exit;
|
| 75 |
}
|
| 76 |
|
| 77 |
if ( $ot_maybe_cleanup_posts || $ot_maybe_cleanup_table ) {
|
| 78 |
+
|
| 79 |
if ( $page != 'ot-cleanup' )
|
| 80 |
add_action( 'admin_notices', array( $this, 'cleanup_notice' ) );
|
| 81 |
|
| 84 |
$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' ) );
|
| 85 |
|
| 86 |
}
|
| 87 |
+
|
| 88 |
}
|
| 89 |
+
|
| 90 |
/**
|
| 91 |
* Adds an admin nag.
|
| 92 |
*
|
| 99 |
|
| 100 |
if ( get_current_screen()->id != 'appearance_page_ot-cleanup' )
|
| 101 |
echo '<div class="update-nag">' . sprintf( __( 'OptionTree has outdated data that should be removed. Please go to %s for more information.', 'option-tree' ), sprintf( '<a href="%s">%s</a>', admin_url( 'themes.php?page=ot-cleanup' ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ) ) ) . '</div>';
|
| 102 |
+
|
| 103 |
}
|
| 104 |
|
| 105 |
/**
|
| 181 |
</script>';
|
| 182 |
break;
|
| 183 |
}
|
| 184 |
+
|
| 185 |
// Get the attachements
|
| 186 |
$attachments = get_children( 'post_type=attachment&post_parent=' . $post->ID );
|
| 187 |
|
| 191 |
echo 'Updating Attachments parent ID for <tt>option-tree</tt> post <tt>#' . $post->ID . '</tt>.<br />';
|
| 192 |
|
| 193 |
foreach( $attachments as $attachment_id => $attachment ) {
|
| 194 |
+
wp_update_post(
|
| 195 |
array(
|
| 196 |
'ID' => $attachment_id,
|
| 197 |
'post_parent' => $post_ID
|
| 260 |
}
|
| 261 |
|
| 262 |
}
|
| 263 |
+
|
| 264 |
echo '</div>';
|
| 265 |
|
| 266 |
}
|
| 276 |
* @since 2.4.6
|
| 277 |
*/
|
| 278 |
public function increase_timeout() {
|
| 279 |
+
|
| 280 |
if ( ! ini_get( 'safe_mode' ) ) {
|
| 281 |
+
|
| 282 |
@set_time_limit( 0 );
|
| 283 |
+
|
| 284 |
}
|
| 285 |
+
|
| 286 |
}
|
| 287 |
|
| 288 |
}
|
| 292 |
new OT_Cleanup();
|
| 293 |
|
| 294 |
/* End of file ot-cleanup-api.php */
|
| 295 |
+
/* Location: ./includes/ot-cleanup-api.php */
|
admin/includes/ot-functions-admin.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 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
|
|
@@ -24,26 +24,26 @@
|
|
| 24 |
if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
| 25 |
|
| 26 |
function ot_register_theme_options_page() {
|
| 27 |
-
|
| 28 |
/* get the settings array */
|
| 29 |
$get_settings = get_option( ot_settings_id() );
|
| 30 |
-
|
| 31 |
/* sections array */
|
| 32 |
$sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
|
| 33 |
-
|
| 34 |
/* settings array */
|
| 35 |
$settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
|
| 36 |
-
|
| 37 |
/* contexual_help array */
|
| 38 |
$contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
|
| 39 |
-
|
| 40 |
/* build the Theme Options */
|
| 41 |
if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) {
|
| 42 |
-
|
| 43 |
ot_register_settings( array(
|
| 44 |
array(
|
| 45 |
'id' => ot_options_id(),
|
| 46 |
-
'pages' => array(
|
| 47 |
array(
|
| 48 |
'id' => 'niftycs_options',
|
| 49 |
'parent_slug' => apply_filters( 'niftycs_options_parent_slug', null ),
|
|
@@ -62,14 +62,14 @@ if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
|
| 62 |
)
|
| 63 |
)
|
| 64 |
)
|
| 65 |
-
)
|
| 66 |
);
|
| 67 |
-
|
| 68 |
// Filters the options.php to add the minimum user capabilities.
|
| 69 |
add_filter( 'option_page_capability_' . ot_options_id(), create_function( '$caps', "return '$caps';" ), 999 );
|
| 70 |
-
|
| 71 |
}
|
| 72 |
-
|
| 73 |
}
|
| 74 |
|
| 75 |
}
|
|
@@ -88,23 +88,23 @@ if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
|
| 88 |
|
| 89 |
function ot_register_settings_page() {
|
| 90 |
global $ot_has_custom_theme_options;
|
| 91 |
-
|
| 92 |
// Display UI Builder admin notice
|
| 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 |
function ot_has_custom_theme_options() {
|
| 96 |
-
|
| 97 |
echo '<div class="error"><p>' . __( '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>';
|
| 98 |
-
|
| 99 |
}
|
| 100 |
-
|
| 101 |
add_action( 'admin_notices', 'ot_has_custom_theme_options' );
|
| 102 |
-
|
| 103 |
}
|
| 104 |
-
|
| 105 |
// Create the filterable pages array
|
| 106 |
-
$ot_register_pages_array = array(
|
| 107 |
-
array(
|
| 108 |
'id' => 'ot',
|
| 109 |
'page_title' => __( 'OptionTree', 'option-tree' ),
|
| 110 |
'menu_title' => __( 'OptionTree', 'option-tree' ),
|
|
@@ -303,82 +303,82 @@ if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
|
| 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 |
$ot_register_pages_array = apply_filters( 'ot_register_pages_array', $ot_register_pages_array );
|
| 381 |
-
|
| 382 |
// Register the pages.
|
| 383 |
ot_register_settings( array(
|
| 384 |
array(
|
|
@@ -387,7 +387,7 @@ if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
|
| 387 |
)
|
| 388 |
)
|
| 389 |
);
|
| 390 |
-
|
| 391 |
}
|
| 392 |
|
| 393 |
}
|
|
@@ -403,21 +403,21 @@ if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
|
| 403 |
if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
|
| 404 |
|
| 405 |
function ot_after_theme_options_save() {
|
| 406 |
-
|
| 407 |
$page = isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '';
|
| 408 |
$updated = isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ? true : false;
|
| 409 |
-
|
| 410 |
/* only execute after the theme options are saved */
|
| 411 |
if ( apply_filters( 'niftycs_options_menu_slug', 'niftycs-options' ) == $page && $updated ) {
|
| 412 |
-
|
| 413 |
/* grab a copy of the theme options */
|
| 414 |
$options = get_option( ot_options_id() );
|
| 415 |
-
|
| 416 |
/* execute the action hook and pass the theme options to it */
|
| 417 |
do_action( 'ot_after_theme_options_save', $options );
|
| 418 |
-
|
| 419 |
}
|
| 420 |
-
|
| 421 |
}
|
| 422 |
|
| 423 |
}
|
|
@@ -442,128 +442,128 @@ if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
|
|
| 442 |
if ( ! function_exists( 'ot_validate_setting' ) ) {
|
| 443 |
|
| 444 |
function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
|
| 445 |
-
|
| 446 |
/* exit early if missing data */
|
| 447 |
if ( ! $input || ! $type || ! $field_id )
|
| 448 |
return $input;
|
| 449 |
-
|
| 450 |
$input = apply_filters( 'ot_validate_setting', $input, $type, $field_id );
|
| 451 |
-
|
| 452 |
/* WPML Register and Unregister strings */
|
| 453 |
if ( ! empty( $wmpl_id ) ) {
|
| 454 |
-
|
| 455 |
/* Allow filtering on the WPML option types */
|
| 456 |
$single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) );
|
| 457 |
-
|
| 458 |
if ( in_array( $type, $single_string_types ) ) {
|
| 459 |
-
|
| 460 |
if ( ! empty( $input ) ) {
|
| 461 |
-
|
| 462 |
ot_wpml_register_string( $wmpl_id, $input );
|
| 463 |
-
|
| 464 |
} else {
|
| 465 |
-
|
| 466 |
ot_wpml_unregister_string( $wmpl_id );
|
| 467 |
-
|
| 468 |
}
|
| 469 |
-
|
| 470 |
}
|
| 471 |
-
|
| 472 |
}
|
| 473 |
-
|
| 474 |
if ( 'background' == $type ) {
|
| 475 |
|
| 476 |
$input['background-color'] = ot_validate_setting( $input['background-color'], 'colorpicker', $field_id );
|
| 477 |
-
|
| 478 |
$input['background-image'] = ot_validate_setting( $input['background-image'], 'upload', $field_id );
|
| 479 |
-
|
| 480 |
// Loop over array and check for values
|
| 481 |
foreach( (array) $input as $key => $value ) {
|
| 482 |
if ( ! empty( $value ) ) {
|
| 483 |
$has_value = true;
|
| 484 |
}
|
| 485 |
}
|
| 486 |
-
|
| 487 |
// No value; set to empty
|
| 488 |
if ( ! isset( $has_value ) ) {
|
| 489 |
$input = '';
|
| 490 |
}
|
| 491 |
-
|
| 492 |
} else if ( 'border' == $type ) {
|
| 493 |
-
|
| 494 |
// Loop over array and set errors or unset key from array.
|
| 495 |
foreach( $input as $key => $value ) {
|
| 496 |
-
|
| 497 |
// Validate width
|
| 498 |
if ( $key == 'width' && ! empty( $value ) && ! is_numeric( $value ) ) {
|
| 499 |
-
|
| 500 |
$input[$key] = '0';
|
| 501 |
-
|
| 502 |
add_settings_error( 'option-tree', 'invalid_border_width', sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '<code>width</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
| 503 |
-
|
| 504 |
}
|
| 505 |
-
|
| 506 |
// Validate color
|
| 507 |
if ( $key == 'color' && ! empty( $value ) ) {
|
| 508 |
|
| 509 |
$input[$key] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
| 510 |
-
|
| 511 |
}
|
| 512 |
-
|
| 513 |
// Unset keys with empty values.
|
| 514 |
if ( empty( $value ) && strlen( $value ) == 0 ) {
|
| 515 |
unset( $input[$key] );
|
| 516 |
}
|
| 517 |
-
|
| 518 |
}
|
| 519 |
-
|
| 520 |
if ( empty( $input ) ) {
|
| 521 |
$input = '';
|
| 522 |
}
|
| 523 |
-
|
| 524 |
} else if ( 'box-shadow' == $type ) {
|
| 525 |
-
|
| 526 |
// Validate inset
|
| 527 |
$input['inset'] = isset( $input['inset'] ) ? 'inset' : '';
|
| 528 |
-
|
| 529 |
// Validate offset-x
|
| 530 |
$input['offset-x'] = ot_validate_setting( $input['offset-x'], 'text', $field_id );
|
| 531 |
-
|
| 532 |
// Validate offset-y
|
| 533 |
$input['offset-y'] = ot_validate_setting( $input['offset-y'], 'text', $field_id );
|
| 534 |
-
|
| 535 |
// Validate blur-radius
|
| 536 |
$input['blur-radius'] = ot_validate_setting( $input['blur-radius'], 'text', $field_id );
|
| 537 |
-
|
| 538 |
// Validate spread-radius
|
| 539 |
$input['spread-radius'] = ot_validate_setting( $input['spread-radius'], 'text', $field_id );
|
| 540 |
-
|
| 541 |
// Validate color
|
| 542 |
$input['color'] = ot_validate_setting( $input['color'], 'colorpicker', $field_id );
|
| 543 |
-
|
| 544 |
// Unset keys with empty values.
|
| 545 |
foreach( $input as $key => $value ) {
|
| 546 |
if ( empty( $value ) && strlen( $value ) == 0 ) {
|
| 547 |
unset( $input[$key] );
|
| 548 |
}
|
| 549 |
}
|
| 550 |
-
|
| 551 |
// Set empty array to empty string.
|
| 552 |
if ( empty( $input ) ) {
|
| 553 |
$input = '';
|
| 554 |
}
|
| 555 |
-
|
| 556 |
} else if ( 'colorpicker' == $type ) {
|
| 557 |
|
| 558 |
/* return empty & set error */
|
| 559 |
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 ) ) {
|
| 560 |
-
|
| 561 |
$input = '';
|
| 562 |
-
|
| 563 |
add_settings_error( 'option-tree', 'invalid_hex', sprintf( __( 'The %s Colorpicker only allows valid hexadecimal or rgba values.', 'option-tree' ), '<code>' . $field_id . '</code>' ), 'error' );
|
| 564 |
-
|
| 565 |
}
|
| 566 |
-
|
| 567 |
} else if ( 'colorpicker-opacity' == $type ) {
|
| 568 |
|
| 569 |
// Not allowed
|
|
@@ -575,15 +575,15 @@ if ( ! function_exists( 'ot_validate_setting' ) ) {
|
|
| 575 |
$input = ot_validate_setting( $input, 'colorpicker', $field_id );
|
| 576 |
|
| 577 |
} else if ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ) ) ) {
|
| 578 |
-
|
| 579 |
if ( ! current_user_can( 'unfiltered_html' ) && OT_ALLOW_UNFILTERED_HTML == false ) {
|
| 580 |
-
|
| 581 |
$input = wp_kses_post( $input );
|
| 582 |
-
|
| 583 |
}
|
| 584 |
-
|
| 585 |
} else if ( 'dimension' == $type ) {
|
| 586 |
-
|
| 587 |
// Loop over array and set error keys or unset key from array.
|
| 588 |
foreach( $input as $key => $value ) {
|
| 589 |
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
|
|
@@ -596,25 +596,25 @@ if ( ! function_exists( 'ot_validate_setting' ) ) {
|
|
| 596 |
|
| 597 |
/* return 0 & set error */
|
| 598 |
if ( isset( $errors ) ) {
|
| 599 |
-
|
| 600 |
foreach( $errors as $error ) {
|
| 601 |
-
|
| 602 |
$input[$error] = '0';
|
| 603 |
-
|
| 604 |
add_settings_error( 'option-tree', 'invalid_dimension_' . $error, sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '<code>' . $error . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
| 605 |
-
|
| 606 |
}
|
| 607 |
-
|
| 608 |
}
|
| 609 |
-
|
| 610 |
if ( empty( $input ) ) {
|
| 611 |
$input = '';
|
| 612 |
}
|
| 613 |
-
|
| 614 |
} else if ( 'google-fonts' == $type ) {
|
| 615 |
-
|
| 616 |
unset($input['%key%']);
|
| 617 |
-
|
| 618 |
// Loop over array and check for values
|
| 619 |
if ( is_array( $input ) && ! empty( $input ) ) {
|
| 620 |
$input = array_values( $input );
|
|
@@ -624,9 +624,9 @@ if ( ! function_exists( 'ot_validate_setting' ) ) {
|
|
| 624 |
if ( empty( $input ) ) {
|
| 625 |
$input = '';
|
| 626 |
}
|
| 627 |
-
|
| 628 |
} else if ( 'link-color' == $type ) {
|
| 629 |
-
|
| 630 |
// Loop over array and check for values
|
| 631 |
if ( is_array( $input ) && ! empty( $input ) ) {
|
| 632 |
foreach( $input as $key => $value ) {
|
|
@@ -636,23 +636,23 @@ if ( ! function_exists( 'ot_validate_setting' ) ) {
|
|
| 636 |
}
|
| 637 |
}
|
| 638 |
}
|
| 639 |
-
|
| 640 |
// No value; set to empty
|
| 641 |
if ( ! isset( $has_value ) ) {
|
| 642 |
$input = '';
|
| 643 |
}
|
| 644 |
-
|
| 645 |
} else if ( 'measurement' == $type ) {
|
| 646 |
-
|
| 647 |
$input[0] = sanitize_text_field( $input[0] );
|
| 648 |
-
|
| 649 |
// No value; set to empty
|
| 650 |
if ( empty( $input[0] ) && strlen( $input[0] ) == 0 && empty( $input[1] ) ) {
|
| 651 |
$input = '';
|
| 652 |
}
|
| 653 |
-
|
| 654 |
} else if ( 'spacing' == $type ) {
|
| 655 |
-
|
| 656 |
// Loop over array and set error keys or unset key from array.
|
| 657 |
foreach( $input as $key => $value ) {
|
| 658 |
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
|
|
@@ -665,49 +665,49 @@ if ( ! function_exists( 'ot_validate_setting' ) ) {
|
|
| 665 |
|
| 666 |
/* return 0 & set error */
|
| 667 |
if ( isset( $errors ) ) {
|
| 668 |
-
|
| 669 |
foreach( $errors as $error ) {
|
| 670 |
-
|
| 671 |
$input[$error] = '0';
|
| 672 |
-
|
| 673 |
add_settings_error( 'option-tree', 'invalid_spacing_' . $error, sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '<code>' . $error . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
| 674 |
-
|
| 675 |
}
|
| 676 |
-
|
| 677 |
}
|
| 678 |
-
|
| 679 |
if ( empty( $input ) ) {
|
| 680 |
$input = '';
|
| 681 |
}
|
| 682 |
-
|
| 683 |
} else if ( 'typography' == $type && isset( $input['font-color'] ) ) {
|
| 684 |
-
|
| 685 |
$input['font-color'] = ot_validate_setting( $input['font-color'], 'colorpicker', $field_id );
|
| 686 |
-
|
| 687 |
// Loop over array and check for values
|
| 688 |
foreach( $input as $key => $value ) {
|
| 689 |
if ( ! empty( $value ) ) {
|
| 690 |
$has_value = true;
|
| 691 |
}
|
| 692 |
}
|
| 693 |
-
|
| 694 |
// No value; set to empty
|
| 695 |
if ( ! isset( $has_value ) ) {
|
| 696 |
$input = '';
|
| 697 |
}
|
| 698 |
-
|
| 699 |
} else if ( 'upload' == $type ) {
|
| 700 |
|
| 701 |
if( filter_var( $input, FILTER_VALIDATE_INT ) === FALSE ) {
|
| 702 |
$input = esc_url_raw( $input );
|
| 703 |
}
|
| 704 |
-
|
| 705 |
} else if ( 'gallery' == $type ) {
|
| 706 |
|
| 707 |
$input = trim( $input );
|
| 708 |
-
|
| 709 |
} else if ( 'social-links' == $type ) {
|
| 710 |
-
|
| 711 |
// Loop over array and check for values, plus sanitize the text field
|
| 712 |
foreach( (array) $input as $key => $value ) {
|
| 713 |
if ( ! empty( $value ) && is_array( $value ) ) {
|
|
@@ -719,18 +719,18 @@ if ( ! function_exists( 'ot_validate_setting' ) ) {
|
|
| 719 |
}
|
| 720 |
}
|
| 721 |
}
|
| 722 |
-
|
| 723 |
// No value; set to empty
|
| 724 |
if ( ! isset( $has_value ) ) {
|
| 725 |
$input = '';
|
| 726 |
}
|
| 727 |
-
|
| 728 |
}
|
| 729 |
-
|
| 730 |
$input = apply_filters( 'ot_after_validate_setting', $input, $type, $field_id );
|
| 731 |
-
|
| 732 |
return $input;
|
| 733 |
-
|
| 734 |
}
|
| 735 |
|
| 736 |
}
|
|
@@ -747,21 +747,21 @@ if ( ! function_exists( 'ot_admin_styles' ) ) {
|
|
| 747 |
|
| 748 |
function ot_admin_styles() {
|
| 749 |
global $wp_styles, $post;
|
| 750 |
-
|
| 751 |
/* execute styles before actions */
|
| 752 |
do_action( 'ot_admin_styles_before' );
|
| 753 |
-
|
| 754 |
/* load WP colorpicker */
|
| 755 |
wp_enqueue_style( 'wp-color-picker' );
|
| 756 |
-
|
| 757 |
wp_enqueue_style('wp-jquery-ui-dialog');
|
| 758 |
-
|
| 759 |
/* load admin styles */
|
| 760 |
wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION );
|
| 761 |
-
|
| 762 |
/* load the RTL stylesheet */
|
| 763 |
$wp_styles->add_data( 'ot-admin-css','rtl', true );
|
| 764 |
-
|
| 765 |
/* Remove styles added by the Easy Digital Downloads plugin */
|
| 766 |
if ( isset( $post->post_type ) && $post->post_type == 'post' )
|
| 767 |
wp_dequeue_style( 'jquery-ui-css' );
|
|
@@ -773,23 +773,23 @@ if ( ! function_exists( 'ot_admin_styles' ) ) {
|
|
| 773 |
*
|
| 774 |
* @param array $screen_ids An array of screen IDs.
|
| 775 |
*/
|
| 776 |
-
$screen_ids = apply_filters( 'ot_dequeue_jquery_ui_css_screen_ids', array(
|
| 777 |
-
'toplevel_page_ot-settings',
|
| 778 |
-
'optiontree_page_ot-documentation',
|
| 779 |
-
'appearance_page_niftycs-options'
|
| 780 |
) );
|
| 781 |
-
|
| 782 |
/* Remove styles added by the WP Review plugin and any custom pages added through filtering */
|
| 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 |
/* execute styles after actions */
|
| 789 |
do_action( 'ot_admin_styles_after' );
|
| 790 |
|
| 791 |
}
|
| 792 |
-
|
| 793 |
}
|
| 794 |
|
| 795 |
/**
|
|
@@ -807,10 +807,10 @@ if ( ! function_exists( 'ot_admin_styles' ) ) {
|
|
| 807 |
if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
| 808 |
|
| 809 |
function ot_admin_scripts() {
|
| 810 |
-
|
| 811 |
/* execute scripts before actions */
|
| 812 |
do_action( 'ot_admin_scripts_before' );
|
| 813 |
-
|
| 814 |
if ( function_exists( 'wp_enqueue_media' ) ) {
|
| 815 |
/* WP 3.5 Media Uploader */
|
| 816 |
wp_enqueue_media();
|
|
@@ -829,7 +829,7 @@ if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
|
| 829 |
wp_enqueue_script( 'wp-color-picker' );
|
| 830 |
|
| 831 |
/* load Ace Editor for CSS Editing */
|
| 832 |
-
wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js', null, '1.1.3' );
|
| 833 |
|
| 834 |
/* load jQuery UI timepicker addon */
|
| 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' );
|
|
@@ -841,16 +841,16 @@ if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
|
| 841 |
|
| 842 |
|
| 843 |
/* load all the required scripts */
|
| 844 |
-
|
| 845 |
wp_enqueue_script('jquery-ui-dialog');
|
| 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 |
/* create localized JS array */
|
| 853 |
-
$localized_array = array(
|
| 854 |
'ajax' => admin_url( 'admin-ajax.php' ),
|
| 855 |
'nonce' => wp_create_nonce( 'option_tree' ),
|
| 856 |
'upload_text' => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ),
|
|
@@ -860,9 +860,9 @@ if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
|
| 860 |
'remove_agree' => __( 'Are you sure you want to remove this?', 'option-tree' ),
|
| 861 |
'activate_layout_agree' => __( 'Are you sure you want to activate this layout?', 'option-tree' ),
|
| 862 |
'setting_limit' => __( 'Sorry, you can\'t have settings three levels deep.', 'option-tree' ),
|
| 863 |
-
'delete' => __( 'Delete Gallery', 'option-tree' ),
|
| 864 |
-
'edit' => __( 'Edit Gallery', 'option-tree' ),
|
| 865 |
-
'create' => __( 'Create Gallery', 'option-tree' ),
|
| 866 |
'confirm' => __( 'Are you sure you want to delete this Gallery?', 'option-tree' ),
|
| 867 |
'date_current' => __( 'Today', 'option-tree' ),
|
| 868 |
'date_time_current' => __( 'Now', 'option-tree' ),
|
|
@@ -872,15 +872,15 @@ if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
|
| 872 |
'weforms_dialog_upsell_title' => '<img alt="' . __('weForms', 'option-tree') . '" title="' . __('weForms', 'option-tree') . '" src="' . OT_URL . '/assets/images/weforms-logo-white.png' . '">',
|
| 873 |
'weforms_install_url' => add_query_arg(array('action' => 'install_weforms'), admin_url('admin.php')),
|
| 874 |
);
|
| 875 |
-
|
| 876 |
/* localized script attached to 'option_tree' */
|
| 877 |
wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array );
|
| 878 |
-
|
| 879 |
/* execute scripts after actions */
|
| 880 |
do_action( 'ot_admin_scripts_after' );
|
| 881 |
|
| 882 |
}
|
| 883 |
-
|
| 884 |
}
|
| 885 |
|
| 886 |
/**
|
|
@@ -896,28 +896,28 @@ if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
|
| 896 |
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
|
| 897 |
|
| 898 |
function ot_get_media_post_ID() {
|
| 899 |
-
|
| 900 |
// Option ID
|
| 901 |
$option_id = 'ot_media_post_ID';
|
| 902 |
-
|
| 903 |
// Get the media post ID
|
| 904 |
$post_ID = get_option( $option_id, false );
|
| 905 |
-
|
| 906 |
// Add $post_ID to the DB
|
| 907 |
if ( $post_ID === false || empty( $post_ID ) ) {
|
| 908 |
global $wpdb;
|
| 909 |
-
|
| 910 |
// Get the media post ID
|
| 911 |
$post_ID = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE `post_title` = 'Media' AND `post_type` = 'option-tree' AND `post_status` = 'private'" );
|
| 912 |
-
|
| 913 |
// Add to the DB
|
| 914 |
if ( $post_ID !== null )
|
| 915 |
update_option( $option_id, $post_ID );
|
| 916 |
|
| 917 |
}
|
| 918 |
-
|
| 919 |
return $post_ID;
|
| 920 |
-
|
| 921 |
}
|
| 922 |
|
| 923 |
}
|
|
@@ -933,9 +933,9 @@ if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
|
|
| 933 |
* @since 2.0
|
| 934 |
*/
|
| 935 |
if ( ! function_exists( 'ot_create_media_post' ) ) {
|
| 936 |
-
|
| 937 |
function ot_create_media_post() {
|
| 938 |
-
|
| 939 |
$regsiter_post_type = 'register_' . 'post_type';
|
| 940 |
$regsiter_post_type( 'option-tree', array(
|
| 941 |
'labels' => array( 'name' => __( 'Nifty options', 'option-tree' ) ),
|
|
@@ -949,13 +949,13 @@ if ( ! function_exists( 'ot_create_media_post' ) ) {
|
|
| 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';
|
|
@@ -964,12 +964,12 @@ if ( ! function_exists( 'ot_create_media_post' ) ) {
|
|
| 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 |
}
|
|
@@ -986,33 +986,33 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 986 |
|
| 987 |
function ot_default_settings() {
|
| 988 |
global $wpdb;
|
| 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;
|
|
@@ -1021,7 +1021,7 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 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' ) ) ) {
|
|
@@ -1032,7 +1032,7 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 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' ) ) ) {
|
|
@@ -1043,7 +1043,7 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 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' ) ) ) {
|
|
@@ -1052,12 +1052,12 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 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 ) {
|
|
@@ -1066,12 +1066,12 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 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(
|
|
@@ -1094,40 +1094,40 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 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 |
}
|
|
@@ -1143,41 +1143,41 @@ if ( ! function_exists( 'ot_default_settings' ) ) {
|
|
| 1143 |
if ( ! function_exists( 'ot_save_css' ) ) {
|
| 1144 |
|
| 1145 |
function ot_save_css( $options ) {
|
| 1146 |
-
|
| 1147 |
/* grab a copy of the settings */
|
| 1148 |
$settings = get_option( ot_settings_id() );
|
| 1149 |
-
|
| 1150 |
/* has settings */
|
| 1151 |
if ( isset( $settings['settings'] ) ) {
|
| 1152 |
-
|
| 1153 |
/* loop through sections and insert CSS when needed */
|
| 1154 |
foreach( $settings['settings'] as $k => $setting ) {
|
| 1155 |
-
|
| 1156 |
/* is the CSS option type */
|
| 1157 |
if ( isset( $setting['type'] ) && 'css' == $setting['type'] ) {
|
| 1158 |
|
| 1159 |
/* insert CSS into dynamic.css */
|
| 1160 |
if ( isset( $options[$setting['id']] ) && '' !== $options[$setting['id']] ) {
|
| 1161 |
-
|
| 1162 |
ot_insert_css_with_markers( $setting['id'], $options[$setting['id']] );
|
| 1163 |
-
|
| 1164 |
/* remove old CSS from dynamic.css */
|
| 1165 |
} else {
|
| 1166 |
-
|
| 1167 |
ot_remove_old_css( $setting['id'] );
|
| 1168 |
-
|
| 1169 |
}
|
| 1170 |
-
|
| 1171 |
}
|
| 1172 |
-
|
| 1173 |
}
|
| 1174 |
-
|
| 1175 |
}
|
| 1176 |
-
|
| 1177 |
}
|
| 1178 |
|
| 1179 |
}
|
| 1180 |
-
|
| 1181 |
/**
|
| 1182 |
* Helper function to load filters for XML mime type.
|
| 1183 |
*
|
|
@@ -1189,16 +1189,16 @@ if ( ! function_exists( 'ot_save_css' ) ) {
|
|
| 1189 |
if ( ! function_exists( 'ot_add_xml_to_upload_filetypes' ) ) {
|
| 1190 |
|
| 1191 |
function ot_add_xml_to_upload_filetypes() {
|
| 1192 |
-
|
| 1193 |
add_filter( 'upload_mimes', 'ot_upload_mimes' );
|
| 1194 |
add_filter( 'wp_mime_type_icon', 'ot_xml_mime_type_icon', 10, 2 );
|
| 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
|
|
@@ -1209,11 +1209,11 @@ if ( ! function_exists( 'ot_add_xml_to_upload_filetypes' ) ) {
|
|
| 1209 |
if ( ! function_exists( 'ot_upload_mimes' ) ) {
|
| 1210 |
|
| 1211 |
function ot_upload_mimes( $mimes ) {
|
| 1212 |
-
|
| 1213 |
$mimes['xml'] = 'application/xml';
|
| 1214 |
-
|
| 1215 |
return $mimes;
|
| 1216 |
-
|
| 1217 |
}
|
| 1218 |
|
| 1219 |
}
|
|
@@ -1231,12 +1231,12 @@ if ( ! function_exists( 'ot_upload_mimes' ) ) {
|
|
| 1231 |
if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) {
|
| 1232 |
|
| 1233 |
function ot_xml_mime_type_icon( $icon, $mime ) {
|
| 1234 |
-
|
| 1235 |
if ( $mime == 'application/xml' || $mime == 'text/xml' )
|
| 1236 |
return wp_mime_type_icon( 'document' );
|
| 1237 |
-
|
| 1238 |
return $icon;
|
| 1239 |
-
|
| 1240 |
}
|
| 1241 |
|
| 1242 |
}
|
|
@@ -1252,188 +1252,188 @@ if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) {
|
|
| 1252 |
if ( ! function_exists( 'ot_import' ) ) {
|
| 1253 |
|
| 1254 |
function ot_import() {
|
| 1255 |
-
|
| 1256 |
/* check and verify import xml nonce */
|
| 1257 |
if ( isset( $_POST['import_xml_nonce'] ) && wp_verify_nonce( $_POST['import_xml_nonce'], 'import_xml_form' ) ) {
|
| 1258 |
|
| 1259 |
/* import input value */
|
| 1260 |
$file = isset( $_POST['import_xml'] ) ? esc_url( $_POST['import_xml'] ) : '';
|
| 1261 |
-
|
| 1262 |
/* validate xml file */
|
| 1263 |
if ( preg_match( "/(.xml)$/i", $file ) && class_exists( 'SimpleXMLElement' ) ) {
|
| 1264 |
-
|
| 1265 |
$settings = ot_import_xml( $file );
|
| 1266 |
-
|
| 1267 |
}
|
| 1268 |
-
|
| 1269 |
/* default message */
|
| 1270 |
$message = 'failed';
|
| 1271 |
-
|
| 1272 |
/* cleanup, save, & show success message */
|
| 1273 |
if ( isset( $settings ) && ! empty( $settings ) ) {
|
| 1274 |
-
|
| 1275 |
/* delete file */
|
| 1276 |
if ( $file ) {
|
| 1277 |
global $wpdb;
|
| 1278 |
$attachmentid = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$file'" );
|
| 1279 |
wp_delete_attachment( $attachmentid, true );
|
| 1280 |
}
|
| 1281 |
-
|
| 1282 |
/* update settings */
|
| 1283 |
update_option( ot_settings_id(), $settings );
|
| 1284 |
-
|
| 1285 |
/* set message */
|
| 1286 |
$message = 'success';
|
| 1287 |
-
|
| 1288 |
}
|
| 1289 |
-
|
| 1290 |
/* redirect */
|
| 1291 |
-
|
| 1292 |
exit;
|
| 1293 |
-
|
| 1294 |
}
|
| 1295 |
-
|
| 1296 |
/* check and verify import settings nonce */
|
| 1297 |
if ( isset( $_POST['import_settings_nonce'] ) && wp_verify_nonce( $_POST['import_settings_nonce'], 'import_settings_form' ) ) {
|
| 1298 |
|
| 1299 |
/* textarea value */
|
| 1300 |
$textarea = isset( $_POST['import_settings'] ) ? unserialize( ot_decode( $_POST['import_settings'] ) ) : '';
|
| 1301 |
-
|
| 1302 |
/* default message */
|
| 1303 |
$message = 'failed';
|
| 1304 |
-
|
| 1305 |
/* is array: save & show success message */
|
| 1306 |
if ( is_array( $textarea ) ) {
|
| 1307 |
update_option( ot_settings_id(), $textarea );
|
| 1308 |
$message = 'success';
|
| 1309 |
}
|
| 1310 |
-
|
| 1311 |
/* redirect */
|
| 1312 |
-
|
| 1313 |
exit;
|
| 1314 |
-
|
| 1315 |
}
|
| 1316 |
-
|
| 1317 |
/* check and verify import theme options data nonce */
|
| 1318 |
if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) {
|
| 1319 |
-
|
| 1320 |
/* default message */
|
| 1321 |
$message = 'failed';
|
| 1322 |
-
|
| 1323 |
/* textarea value */
|
| 1324 |
$options = isset( $_POST['import_data'] ) ? unserialize( ot_decode( $_POST['import_data'] ) ) : '';
|
| 1325 |
-
|
| 1326 |
/* get settings array */
|
| 1327 |
$settings = get_option( ot_settings_id() );
|
| 1328 |
-
|
| 1329 |
/* has options */
|
| 1330 |
if ( is_array( $options ) ) {
|
| 1331 |
-
|
| 1332 |
/* validate options */
|
| 1333 |
if ( is_array( $settings ) ) {
|
| 1334 |
-
|
| 1335 |
foreach( $settings['settings'] as $setting ) {
|
| 1336 |
-
|
| 1337 |
if ( isset( $options[$setting['id']] ) ) {
|
| 1338 |
-
|
| 1339 |
$content = ot_stripslashes( $options[$setting['id']] );
|
| 1340 |
-
|
| 1341 |
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
| 1342 |
-
|
| 1343 |
}
|
| 1344 |
-
|
| 1345 |
}
|
| 1346 |
-
|
| 1347 |
}
|
| 1348 |
-
|
| 1349 |
/* execute the action hook and pass the theme options to it */
|
| 1350 |
do_action( 'ot_before_theme_options_save', $options );
|
| 1351 |
-
|
| 1352 |
/* update the option tree array */
|
| 1353 |
update_option( ot_options_id(), $options );
|
| 1354 |
-
|
| 1355 |
$message = 'success';
|
| 1356 |
-
|
| 1357 |
}
|
| 1358 |
-
|
| 1359 |
/* redirect accordingly */
|
| 1360 |
-
|
| 1361 |
exit;
|
| 1362 |
-
|
| 1363 |
}
|
| 1364 |
-
|
| 1365 |
/* check and verify import layouts nonce */
|
| 1366 |
if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) {
|
| 1367 |
-
|
| 1368 |
/* default message */
|
| 1369 |
$message = 'failed';
|
| 1370 |
-
|
| 1371 |
/* textarea value */
|
| 1372 |
$layouts = isset( $_POST['import_layouts'] ) ? unserialize( ot_decode( $_POST['import_layouts'] ) ) : '';
|
| 1373 |
-
|
| 1374 |
/* get settings array */
|
| 1375 |
$settings = get_option( ot_settings_id() );
|
| 1376 |
-
|
| 1377 |
/* has layouts */
|
| 1378 |
if ( is_array( $layouts ) ) {
|
| 1379 |
-
|
| 1380 |
/* validate options */
|
| 1381 |
if ( is_array( $settings ) ) {
|
| 1382 |
-
|
| 1383 |
foreach( $layouts as $key => $value ) {
|
| 1384 |
-
|
| 1385 |
if ( $key == 'active_layout' )
|
| 1386 |
continue;
|
| 1387 |
-
|
| 1388 |
$options = unserialize( ot_decode( $value ) );
|
| 1389 |
-
|
| 1390 |
foreach( $settings['settings'] as $setting ) {
|
| 1391 |
|
| 1392 |
if ( isset( $options[$setting['id']] ) ) {
|
| 1393 |
-
|
| 1394 |
$content = ot_stripslashes( $options[$setting['id']] );
|
| 1395 |
-
|
| 1396 |
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
| 1397 |
-
|
| 1398 |
}
|
| 1399 |
-
|
| 1400 |
}
|
| 1401 |
|
| 1402 |
$layouts[$key] = ot_encode( serialize( $options ) );
|
| 1403 |
-
|
| 1404 |
}
|
| 1405 |
-
|
| 1406 |
}
|
| 1407 |
-
|
| 1408 |
/* update the option tree array */
|
| 1409 |
if ( isset( $layouts['active_layout'] ) ) {
|
| 1410 |
-
|
| 1411 |
$new_options = unserialize( ot_decode( $layouts[$layouts['active_layout']] ) );
|
| 1412 |
-
|
| 1413 |
/* execute the action hook and pass the theme options to it */
|
| 1414 |
do_action( 'ot_before_theme_options_save', $new_options );
|
| 1415 |
-
|
| 1416 |
update_option( ot_options_id(), $new_options );
|
| 1417 |
-
|
| 1418 |
}
|
| 1419 |
-
|
| 1420 |
/* update the option tree layouts array */
|
| 1421 |
update_option( ot_layouts_id(), $layouts );
|
| 1422 |
-
|
| 1423 |
$message = 'success';
|
| 1424 |
-
|
| 1425 |
}
|
| 1426 |
-
|
| 1427 |
/* redirect accordingly */
|
| 1428 |
-
|
| 1429 |
exit;
|
| 1430 |
-
|
| 1431 |
}
|
| 1432 |
-
|
| 1433 |
return false;
|
| 1434 |
|
| 1435 |
}
|
| 1436 |
-
|
| 1437 |
}
|
| 1438 |
|
| 1439 |
/**
|
|
@@ -1447,16 +1447,16 @@ if ( ! function_exists( 'ot_import' ) ) {
|
|
| 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 |
/**
|
|
@@ -1471,41 +1471,41 @@ if ( ! function_exists( 'ot_export' ) ) {
|
|
| 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;
|
|
@@ -1514,7 +1514,7 @@ if ( ! function_exists( 'ot_import_xml' ) ) {
|
|
| 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' ) ) ) {
|
|
@@ -1525,7 +1525,7 @@ if ( ! function_exists( 'ot_import_xml' ) ) {
|
|
| 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' ) ) ) {
|
|
@@ -1536,7 +1536,7 @@ if ( ! function_exists( 'ot_import_xml' ) ) {
|
|
| 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' ) ) ) {
|
|
@@ -1545,12 +1545,12 @@ if ( ! function_exists( 'ot_import_xml' ) ) {
|
|
| 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 ) {
|
|
@@ -1559,11 +1559,11 @@ if ( ! function_exists( 'ot_import_xml' ) ) {
|
|
| 1559 |
}
|
| 1560 |
}
|
| 1561 |
}
|
| 1562 |
-
|
| 1563 |
return $settings;
|
| 1564 |
-
|
| 1565 |
}
|
| 1566 |
-
|
| 1567 |
return false;
|
| 1568 |
}
|
| 1569 |
|
|
@@ -1580,14 +1580,14 @@ if ( ! function_exists( 'ot_import_xml' ) ) {
|
|
| 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'] ) ) {
|
|
@@ -1596,14 +1596,14 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 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 = '';
|
|
@@ -1623,20 +1623,20 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 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 ) {
|
|
@@ -1650,14 +1650,14 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 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 ) {
|
|
@@ -1674,7 +1674,7 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 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 ) {
|
|
@@ -1693,7 +1693,7 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 1693 |
'choices' => array( $choices
|
| 1694 |
)";
|
| 1695 |
}
|
| 1696 |
-
|
| 1697 |
$std = "'$_std'";
|
| 1698 |
if ( is_array( $_std ) ) {
|
| 1699 |
$std_array = array();
|
|
@@ -1704,7 +1704,7 @@ if ( ! function_exists( 'ot_export_php_settings_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 ) {
|
|
@@ -1720,7 +1720,7 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 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 ) {
|
|
@@ -1739,7 +1739,7 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 1739 |
'choices' => array( $setting_choices
|
| 1740 |
)";
|
| 1741 |
}
|
| 1742 |
-
|
| 1743 |
$setting_std = "'$_setting_std'";
|
| 1744 |
if ( is_array( $_setting_std ) ) {
|
| 1745 |
$setting_std_array = array();
|
|
@@ -1750,7 +1750,7 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 1750 |
' . implode( ",\n", $setting_std_array ) . '
|
| 1751 |
)';
|
| 1752 |
}
|
| 1753 |
-
|
| 1754 |
$setting_settings.= "
|
| 1755 |
array(
|
| 1756 |
'id' => '$_setting_id',
|
|
@@ -1772,7 +1772,7 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 1772 |
'settings' => array( $setting_settings
|
| 1773 |
)";
|
| 1774 |
}
|
| 1775 |
-
|
| 1776 |
$settings.= "
|
| 1777 |
array(
|
| 1778 |
'id' => '$_id',
|
|
@@ -1792,14 +1792,14 @@ if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
|
| 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.
|
|
@@ -1810,35 +1810,35 @@ add_action( 'init', 'custom_theme_options' );
|
|
| 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;
|
|
@@ -1864,191 +1864,191 @@ if ( ! function_exists( 'ot_save_settings' ) ) {
|
|
| 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 |
|
|
@@ -2073,23 +2073,23 @@ if ( ! function_exists( 'ot_save_settings' ) ) {
|
|
| 2073 |
Swift_Performance_Cache::clear_all_cache();
|
| 2074 |
}
|
| 2075 |
}
|
| 2076 |
-
|
| 2077 |
/* redirect */
|
| 2078 |
-
|
| 2079 |
exit;
|
| 2080 |
-
|
| 2081 |
}
|
| 2082 |
-
|
| 2083 |
return false;
|
| 2084 |
|
| 2085 |
}
|
| 2086 |
-
|
| 2087 |
}
|
| 2088 |
|
| 2089 |
/**
|
| 2090 |
* Validate the settings array before save.
|
| 2091 |
*
|
| 2092 |
-
* This function will loop over the settings array as many
|
| 2093 |
* times as it takes to validate every sub setting.
|
| 2094 |
*
|
| 2095 |
* @param array $settings The array of settings.
|
|
@@ -2101,103 +2101,103 @@ if ( ! function_exists( 'ot_save_settings' ) ) {
|
|
| 2101 |
if ( ! function_exists( 'ot_validate_settings_array' ) ) {
|
| 2102 |
|
| 2103 |
function ot_validate_settings_array( $settings = array() ) {
|
| 2104 |
-
|
| 2105 |
/* validate settings */
|
| 2106 |
if ( count( $settings ) > 0 ) {
|
| 2107 |
-
|
| 2108 |
/* fix numeric keys since drag & drop will change them */
|
| 2109 |
$settings = array_values( $settings );
|
| 2110 |
-
|
| 2111 |
/* loop through settings */
|
| 2112 |
foreach( $settings as $k => $setting ) {
|
| 2113 |
-
|
| 2114 |
-
|
| 2115 |
/* remove from array if missing values */
|
| 2116 |
if ( ( ! isset( $setting['label'] ) && ! isset( $setting['id'] ) ) || ( '' == $setting['label'] && '' == $setting['id'] ) ) {
|
| 2117 |
-
|
| 2118 |
unset( $settings[$k] );
|
| 2119 |
-
|
| 2120 |
} else {
|
| 2121 |
-
|
| 2122 |
/* validate label */
|
| 2123 |
if ( '' != $setting['label'] ) {
|
| 2124 |
-
|
| 2125 |
$settings[$k]['label'] = wp_kses_post( $setting['label'] );
|
| 2126 |
-
|
| 2127 |
}
|
| 2128 |
-
|
| 2129 |
/* missing label set to unfiltered ID */
|
| 2130 |
if ( ! isset( $setting['label'] ) || '' == $setting['label'] ) {
|
| 2131 |
-
|
| 2132 |
$settings[$k]['label'] = $setting['id'];
|
| 2133 |
-
|
| 2134 |
-
/* missing ID set to label */
|
| 2135 |
} else if ( ! isset( $setting['id'] ) || '' == $setting['id'] ) {
|
| 2136 |
-
|
| 2137 |
$setting['id'] = wp_kses_post( $setting['label'] );
|
| 2138 |
-
|
| 2139 |
}
|
| 2140 |
-
|
| 2141 |
/* sanitize ID once everything has been checked first */
|
| 2142 |
$settings[$k]['id'] = ot_sanitize_option_id( wp_kses_post( $setting['id'] ) );
|
| 2143 |
-
|
| 2144 |
}
|
| 2145 |
-
|
| 2146 |
/* validate description */
|
| 2147 |
if ( '' != $setting['desc'] ) {
|
| 2148 |
-
|
| 2149 |
$settings[$k]['desc'] = wp_kses_post( $setting['desc'] );
|
| 2150 |
-
|
| 2151 |
}
|
| 2152 |
-
|
| 2153 |
/* validate choices */
|
| 2154 |
if ( isset( $setting['choices'] ) ) {
|
| 2155 |
-
|
| 2156 |
/* loop through choices */
|
| 2157 |
foreach( $setting['choices'] as $ck => $choice ) {
|
| 2158 |
-
|
| 2159 |
/* remove from array if missing values */
|
| 2160 |
if ( ( ! isset( $choice['label'] ) && ! isset( $choice['value'] ) ) || ( '' == $choice['label'] && '' == $choice['value'] ) ) {
|
| 2161 |
-
|
| 2162 |
unset( $setting['choices'][$ck] );
|
| 2163 |
-
|
| 2164 |
} else {
|
| 2165 |
-
|
| 2166 |
/* missing label set to unfiltered ID */
|
| 2167 |
if ( ! isset( $choice['label'] ) || '' == $choice['label'] ) {
|
| 2168 |
-
|
| 2169 |
$setting['choices'][$ck]['label'] = wp_kses_post( $choice['value'] );
|
| 2170 |
-
|
| 2171 |
-
/* missing value set to label */
|
| 2172 |
} else if ( ! isset( $choice['value'] ) || '' == $choice['value'] ) {
|
| 2173 |
-
|
| 2174 |
$setting['choices'][$ck]['value'] = ot_sanitize_option_id( wp_kses_post( $choice['label'] ) );
|
| 2175 |
-
|
| 2176 |
}
|
| 2177 |
-
|
| 2178 |
}
|
| 2179 |
-
|
| 2180 |
}
|
| 2181 |
-
|
| 2182 |
/* update keys and push new array values */
|
| 2183 |
$settings[$k]['choices'] = array_values( $setting['choices'] );
|
| 2184 |
-
|
| 2185 |
}
|
| 2186 |
-
|
| 2187 |
/* validate sub settings */
|
| 2188 |
if ( isset( $setting['settings'] ) ) {
|
| 2189 |
|
| 2190 |
$settings[$k]['settings'] = ot_validate_settings_array( $setting['settings'] );
|
| 2191 |
-
|
| 2192 |
}
|
| 2193 |
|
| 2194 |
}
|
| 2195 |
-
|
| 2196 |
}
|
| 2197 |
-
|
| 2198 |
/* return array but strip those damn slashes out first!!! */
|
| 2199 |
return ot_stripslashes( $settings );
|
| 2200 |
-
|
| 2201 |
}
|
| 2202 |
|
| 2203 |
}
|
|
@@ -2216,39 +2216,39 @@ if ( ! function_exists( 'ot_modify_layouts' ) ) {
|
|
| 2216 |
|
| 2217 |
/* check and verify modify layouts nonce */
|
| 2218 |
if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) {
|
| 2219 |
-
|
| 2220 |
/* previous layouts value */
|
| 2221 |
$option_tree_layouts = get_option( ot_layouts_id() );
|
| 2222 |
-
|
| 2223 |
/* new layouts value */
|
| 2224 |
$layouts = isset( $_POST[ot_layouts_id()] ) ? $_POST[ot_layouts_id()] : '';
|
| 2225 |
-
|
| 2226 |
/* rebuild layout array */
|
| 2227 |
$rebuild = array();
|
| 2228 |
-
|
| 2229 |
/* validate layouts */
|
| 2230 |
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
| 2231 |
-
|
| 2232 |
/* setup active layout */
|
| 2233 |
if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
|
| 2234 |
$rebuild['active_layout'] = $layouts['active_layout'];
|
| 2235 |
}
|
| 2236 |
-
|
| 2237 |
/* add new and overwrite active layout */
|
| 2238 |
if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
|
| 2239 |
$rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] );
|
| 2240 |
$rebuild[$rebuild['active_layout']] = ot_encode( serialize( get_option( ot_options_id() ) ) );
|
| 2241 |
}
|
| 2242 |
-
|
| 2243 |
$first_layout = '';
|
| 2244 |
-
|
| 2245 |
/* loop through layouts */
|
| 2246 |
foreach( $layouts as $key => $layout ) {
|
| 2247 |
-
|
| 2248 |
/* skip over active layout key */
|
| 2249 |
if ( $key == 'active_layout' )
|
| 2250 |
continue;
|
| 2251 |
-
|
| 2252 |
/* check if the key exists then set value */
|
| 2253 |
if ( isset( $option_tree_layouts[$key] ) && ! empty( $option_tree_layouts[$key] ) ) {
|
| 2254 |
$rebuild[$key] = $option_tree_layouts[$key];
|
|
@@ -2256,63 +2256,63 @@ if ( ! function_exists( 'ot_modify_layouts' ) ) {
|
|
| 2256 |
$first_layout = $key;
|
| 2257 |
}
|
| 2258 |
}
|
| 2259 |
-
|
| 2260 |
}
|
| 2261 |
-
|
| 2262 |
if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[$rebuild['active_layout']] ) && ! empty( $first_layout ) ) {
|
| 2263 |
$rebuild['active_layout'] = $first_layout;
|
| 2264 |
}
|
| 2265 |
-
|
| 2266 |
}
|
| 2267 |
-
|
| 2268 |
/* default message */
|
| 2269 |
$message = 'failed';
|
| 2270 |
-
|
| 2271 |
/* is array: save & show success message */
|
| 2272 |
if ( count( $rebuild ) > 1 ) {
|
| 2273 |
|
| 2274 |
/* rebuild the theme options */
|
| 2275 |
$rebuild_option_tree = unserialize( ot_decode( $rebuild[$rebuild['active_layout']] ) );
|
| 2276 |
if ( is_array( $rebuild_option_tree ) ) {
|
| 2277 |
-
|
| 2278 |
/* execute the action hook and pass the theme options to it */
|
| 2279 |
do_action( 'ot_before_theme_options_save', $rebuild_option_tree );
|
| 2280 |
-
|
| 2281 |
update_option( ot_options_id(), $rebuild_option_tree );
|
| 2282 |
-
|
| 2283 |
}
|
| 2284 |
-
|
| 2285 |
/* rebuild the layouts */
|
| 2286 |
update_option( ot_layouts_id(), $rebuild );
|
| 2287 |
-
|
| 2288 |
/* change message */
|
| 2289 |
$message = 'success';
|
| 2290 |
-
|
| 2291 |
} else if ( count( $rebuild ) <= 1 ) {
|
| 2292 |
|
| 2293 |
/* delete layouts option */
|
| 2294 |
delete_option( ot_layouts_id() );
|
| 2295 |
-
|
| 2296 |
/* change message */
|
| 2297 |
$message = 'deleted';
|
| 2298 |
-
|
| 2299 |
}
|
| 2300 |
-
|
| 2301 |
/* redirect */
|
| 2302 |
if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == apply_filters( 'niftycs_options_menu_slug', 'niftycs-options' ) ) {
|
| 2303 |
$query_args = esc_url_raw( add_query_arg( array( 'settings-updated' => 'layout' ), remove_query_arg( array( 'action', 'message' ), $_POST['_wp_http_referer'] ) ) );
|
| 2304 |
} else {
|
| 2305 |
$query_args = esc_url_raw( add_query_arg( array( 'action' => 'save-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) );
|
| 2306 |
}
|
| 2307 |
-
|
| 2308 |
exit;
|
| 2309 |
-
|
| 2310 |
}
|
| 2311 |
-
|
| 2312 |
return false;
|
| 2313 |
|
| 2314 |
}
|
| 2315 |
-
|
| 2316 |
}
|
| 2317 |
|
| 2318 |
/**
|
|
@@ -2327,105 +2327,105 @@ if ( ! function_exists( 'ot_modify_layouts' ) ) {
|
|
| 2327 |
if ( ! function_exists( 'ot_alert_message' ) ) {
|
| 2328 |
|
| 2329 |
function ot_alert_message( $page = array() ) {
|
| 2330 |
-
|
| 2331 |
if ( empty( $page ) )
|
| 2332 |
return false;
|
| 2333 |
-
|
| 2334 |
$before = apply_filters( 'ot_before_page_messages', '', $page );
|
| 2335 |
-
|
| 2336 |
if ( $before ) {
|
| 2337 |
return $before;
|
| 2338 |
}
|
| 2339 |
-
|
| 2340 |
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
|
| 2341 |
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
|
| 2342 |
$updated = isset( $_REQUEST['settings-updated'] ) ? $_REQUEST['settings-updated'] : '';
|
| 2343 |
-
|
| 2344 |
if ( $action == 'save-settings' ) {
|
| 2345 |
-
|
| 2346 |
if ( $message == 'success' ) {
|
| 2347 |
-
|
| 2348 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings updated.', 'option-tree' ) . '</p></div>';
|
| 2349 |
-
|
| 2350 |
} else if ( $message == 'failed' ) {
|
| 2351 |
-
|
| 2352 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be saved.', 'option-tree' ) . '</p></div>';
|
| 2353 |
-
|
| 2354 |
}
|
| 2355 |
-
|
| 2356 |
} else if ( $action == 'import-xml' || $action == 'import-settings' ) {
|
| 2357 |
-
|
| 2358 |
if ( $message == 'success' ) {
|
| 2359 |
-
|
| 2360 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings Imported.', 'option-tree' ) . '</p></div>';
|
| 2361 |
-
|
| 2362 |
} else if ( $message == 'failed' ) {
|
| 2363 |
-
|
| 2364 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be imported.', 'option-tree' ) . '</p></div>';
|
| 2365 |
-
|
| 2366 |
}
|
| 2367 |
} else if ( $action == 'import-data' ) {
|
| 2368 |
-
|
| 2369 |
if ( $message == 'success' ) {
|
| 2370 |
-
|
| 2371 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Data Imported.', 'option-tree' ) . '</p></div>';
|
| 2372 |
-
|
| 2373 |
} else if ( $message == 'failed' ) {
|
| 2374 |
-
|
| 2375 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Data could not be imported.', 'option-tree' ) . '</p></div>';
|
| 2376 |
-
|
| 2377 |
}
|
| 2378 |
-
|
| 2379 |
} else if ( $action == 'import-layouts' ) {
|
| 2380 |
-
|
| 2381 |
if ( $message == 'success' ) {
|
| 2382 |
-
|
| 2383 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Imported.', 'option-tree' ) . '</p></div>';
|
| 2384 |
-
|
| 2385 |
} else if ( $message == 'failed' ) {
|
| 2386 |
-
|
| 2387 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be imported.', 'option-tree' ) . '</p></div>';
|
| 2388 |
-
|
| 2389 |
}
|
| 2390 |
-
|
| 2391 |
} else if ( $action == 'save-layouts' ) {
|
| 2392 |
-
|
| 2393 |
if ( $message == 'success' ) {
|
| 2394 |
-
|
| 2395 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Updated.', 'option-tree' ) . '</p></div>';
|
| 2396 |
-
|
| 2397 |
} else if ( $message == 'failed' ) {
|
| 2398 |
-
|
| 2399 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be updated.', 'option-tree' ) . '</p></div>';
|
| 2400 |
-
|
| 2401 |
} else if ( $message == 'deleted' ) {
|
| 2402 |
-
|
| 2403 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts have been deleted.', 'option-tree' ) . '</p></div>';
|
| 2404 |
-
|
| 2405 |
}
|
| 2406 |
-
|
| 2407 |
-
} else if ( $updated == 'layout' ) {
|
| 2408 |
-
|
| 2409 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layout activated.', 'option-tree' ) . '</p></div>';
|
| 2410 |
-
|
| 2411 |
} else if ( $action == 'reset' ) {
|
| 2412 |
-
|
| 2413 |
return '<div id="message" class="updated fade below-h2"><p>' . $page['reset_message'] . '</p></div>';
|
| 2414 |
-
|
| 2415 |
}
|
| 2416 |
-
|
| 2417 |
do_action( 'ot_custom_page_messages', $page );
|
| 2418 |
-
|
| 2419 |
-
if ( $updated == 'true' ) {
|
| 2420 |
-
|
| 2421 |
return '<div id="message" class="updated fade below-h2"><p>' . $page['updated_message'] . '</p></div>';
|
| 2422 |
-
|
| 2423 |
-
}
|
| 2424 |
-
|
| 2425 |
return false;
|
| 2426 |
-
|
| 2427 |
}
|
| 2428 |
-
|
| 2429 |
}
|
| 2430 |
|
| 2431 |
/**
|
|
@@ -2443,8 +2443,8 @@ if ( ! function_exists( 'ot_alert_message' ) ) {
|
|
| 2443 |
if ( ! function_exists( 'ot_option_types_array' ) ) {
|
| 2444 |
|
| 2445 |
function ot_option_types_array() {
|
| 2446 |
-
|
| 2447 |
-
return apply_filters( 'ot_option_types_array', array(
|
| 2448 |
'background' => __('Background', 'option-tree'),
|
| 2449 |
'border' => __('Border', 'option-tree'),
|
| 2450 |
'box-shadow' => __('Box Shadow', 'option-tree'),
|
|
@@ -2491,7 +2491,7 @@ if ( ! function_exists( 'ot_option_types_array' ) ) {
|
|
| 2491 |
'typography' => __('Typography', 'option-tree'),
|
| 2492 |
'upload' => __('Upload', 'option-tree')
|
| 2493 |
) );
|
| 2494 |
-
|
| 2495 |
}
|
| 2496 |
}
|
| 2497 |
|
|
@@ -2507,10 +2507,10 @@ if ( ! function_exists( 'ot_option_types_array' ) ) {
|
|
| 2507 |
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
| 2508 |
|
| 2509 |
function ot_map_old_option_types( $type = '' ) {
|
| 2510 |
-
|
| 2511 |
-
if ( ! $type )
|
| 2512 |
return 'text';
|
| 2513 |
-
|
| 2514 |
$types = array(
|
| 2515 |
'background' => 'background',
|
| 2516 |
'category' => 'category-select',
|
|
@@ -2519,7 +2519,7 @@ if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
|
| 2519 |
'colorpicker' => 'colorpicker',
|
| 2520 |
'css' => 'css',
|
| 2521 |
'custom_post' => 'custom-post-type-select',
|
| 2522 |
-
'custom_posts' => 'custom-post-type-checkbox',
|
| 2523 |
'input' => 'text',
|
| 2524 |
'image' => 'upload',
|
| 2525 |
'measurement' => 'measurement',
|
|
@@ -2537,12 +2537,12 @@ if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
|
| 2537 |
'typography' => 'typography',
|
| 2538 |
'upload' => 'upload'
|
| 2539 |
);
|
| 2540 |
-
|
| 2541 |
if ( isset( $types[$type] ) )
|
| 2542 |
return $types[$type];
|
| 2543 |
-
|
| 2544 |
return false;
|
| 2545 |
-
|
| 2546 |
}
|
| 2547 |
}
|
| 2548 |
|
|
@@ -2573,7 +2573,7 @@ function ot_google_font_stack( $families, $field_id ) {
|
|
| 2573 |
}
|
| 2574 |
}
|
| 2575 |
}
|
| 2576 |
-
|
| 2577 |
return $families;
|
| 2578 |
}
|
| 2579 |
add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
|
|
@@ -2597,7 +2597,7 @@ add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
|
|
| 2597 |
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
| 2598 |
|
| 2599 |
function ot_recognized_font_families( $field_id = '' ) {
|
| 2600 |
-
|
| 2601 |
$families = array(
|
| 2602 |
'arial' => 'Arial',
|
| 2603 |
'georgia' => 'Georgia',
|
|
@@ -2608,9 +2608,9 @@ if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
|
| 2608 |
'trebuchet' => 'Trebuchet',
|
| 2609 |
'verdana' => 'Verdana'
|
| 2610 |
);
|
| 2611 |
-
|
| 2612 |
return apply_filters( 'ot_recognized_font_families', $families, $field_id );
|
| 2613 |
-
|
| 2614 |
}
|
| 2615 |
|
| 2616 |
}
|
|
@@ -2631,19 +2631,19 @@ if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
|
| 2631 |
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
|
| 2632 |
|
| 2633 |
function ot_recognized_font_sizes( $field_id ) {
|
| 2634 |
-
|
| 2635 |
-
$range = ot_range(
|
| 2636 |
-
apply_filters( 'ot_font_size_low_range', 0, $field_id ),
|
| 2637 |
-
apply_filters( 'ot_font_size_high_range', 150, $field_id ),
|
| 2638 |
apply_filters( 'ot_font_size_range_interval', 1, $field_id )
|
| 2639 |
);
|
| 2640 |
-
|
| 2641 |
$unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
|
| 2642 |
-
|
| 2643 |
foreach( $range as $k => $v ) {
|
| 2644 |
$range[$k] = $v . $unit;
|
| 2645 |
}
|
| 2646 |
-
|
| 2647 |
return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
|
| 2648 |
}
|
| 2649 |
|
|
@@ -2666,14 +2666,14 @@ if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
|
|
| 2666 |
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
|
| 2667 |
|
| 2668 |
function ot_recognized_font_styles( $field_id = '' ) {
|
| 2669 |
-
|
| 2670 |
return apply_filters( 'ot_recognized_font_styles', array(
|
| 2671 |
'normal' => 'Normal',
|
| 2672 |
'italic' => 'Italic',
|
| 2673 |
'oblique' => 'Oblique',
|
| 2674 |
'inherit' => 'Inherit'
|
| 2675 |
), $field_id );
|
| 2676 |
-
|
| 2677 |
}
|
| 2678 |
|
| 2679 |
}
|
|
@@ -2695,15 +2695,15 @@ if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
|
|
| 2695 |
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
|
| 2696 |
|
| 2697 |
function ot_recognized_font_variants( $field_id = '' ) {
|
| 2698 |
-
|
| 2699 |
return apply_filters( 'ot_recognized_font_variants', array(
|
| 2700 |
'normal' => 'Normal',
|
| 2701 |
'small-caps' => 'Small Caps',
|
| 2702 |
'inherit' => 'Inherit'
|
| 2703 |
), $field_id );
|
| 2704 |
-
|
| 2705 |
}
|
| 2706 |
-
|
| 2707 |
}
|
| 2708 |
|
| 2709 |
/**
|
|
@@ -2723,7 +2723,7 @@ if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
|
|
| 2723 |
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
| 2724 |
|
| 2725 |
function ot_recognized_font_weights( $field_id = '' ) {
|
| 2726 |
-
|
| 2727 |
return apply_filters( 'ot_recognized_font_weights', array(
|
| 2728 |
'normal' => 'Normal',
|
| 2729 |
'bold' => 'Bold',
|
|
@@ -2740,9 +2740,9 @@ if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
|
| 2740 |
'900' => '900',
|
| 2741 |
'inherit' => 'Inherit'
|
| 2742 |
), $field_id );
|
| 2743 |
-
|
| 2744 |
}
|
| 2745 |
-
|
| 2746 |
}
|
| 2747 |
|
| 2748 |
/**
|
|
@@ -2761,19 +2761,19 @@ if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
|
| 2761 |
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
|
| 2762 |
|
| 2763 |
function ot_recognized_letter_spacing( $field_id ) {
|
| 2764 |
-
|
| 2765 |
-
$range = ot_range(
|
| 2766 |
-
apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ),
|
| 2767 |
-
apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ),
|
| 2768 |
apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
|
| 2769 |
);
|
| 2770 |
-
|
| 2771 |
$unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
|
| 2772 |
-
|
| 2773 |
foreach( $range as $k => $v ) {
|
| 2774 |
$range[$k] = $v . $unit;
|
| 2775 |
}
|
| 2776 |
-
|
| 2777 |
return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
|
| 2778 |
}
|
| 2779 |
|
|
@@ -2795,19 +2795,19 @@ if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
|
|
| 2795 |
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
|
| 2796 |
|
| 2797 |
function ot_recognized_line_heights( $field_id ) {
|
| 2798 |
-
|
| 2799 |
-
$range = ot_range(
|
| 2800 |
-
apply_filters( 'ot_line_height_low_range', 0, $field_id ),
|
| 2801 |
-
apply_filters( 'ot_line_height_high_range', 150, $field_id ),
|
| 2802 |
apply_filters( 'ot_line_height_range_interval', 1, $field_id )
|
| 2803 |
);
|
| 2804 |
-
|
| 2805 |
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
|
| 2806 |
-
|
| 2807 |
foreach( $range as $k => $v ) {
|
| 2808 |
$range[$k] = $v . $unit;
|
| 2809 |
}
|
| 2810 |
-
|
| 2811 |
return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
|
| 2812 |
}
|
| 2813 |
|
|
@@ -2828,9 +2828,9 @@ if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
|
|
| 2828 |
* @since 2.0.10
|
| 2829 |
*/
|
| 2830 |
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
| 2831 |
-
|
| 2832 |
function ot_recognized_text_decorations( $field_id = '' ) {
|
| 2833 |
-
|
| 2834 |
return apply_filters( 'ot_recognized_text_decorations', array(
|
| 2835 |
'blink' => 'Blink',
|
| 2836 |
'inherit' => 'Inherit',
|
|
@@ -2839,7 +2839,7 @@ if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
|
| 2839 |
'overline' => 'Overline',
|
| 2840 |
'underline' => 'Underline'
|
| 2841 |
), $field_id );
|
| 2842 |
-
|
| 2843 |
}
|
| 2844 |
|
| 2845 |
}
|
|
@@ -2859,9 +2859,9 @@ if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
|
| 2859 |
* @since 2.0.10
|
| 2860 |
*/
|
| 2861 |
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
| 2862 |
-
|
| 2863 |
function ot_recognized_text_transformations( $field_id = '' ) {
|
| 2864 |
-
|
| 2865 |
return apply_filters( 'ot_recognized_text_transformations', array(
|
| 2866 |
'capitalize' => 'Capitalize',
|
| 2867 |
'inherit' => 'Inherit',
|
|
@@ -2869,7 +2869,7 @@ if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
|
| 2869 |
'none' => 'None',
|
| 2870 |
'uppercase' => 'Uppercase'
|
| 2871 |
), $field_id );
|
| 2872 |
-
|
| 2873 |
}
|
| 2874 |
|
| 2875 |
}
|
|
@@ -2889,9 +2889,9 @@ if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
|
| 2889 |
* @updated 2.0
|
| 2890 |
*/
|
| 2891 |
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
| 2892 |
-
|
| 2893 |
function ot_recognized_background_repeat( $field_id = '' ) {
|
| 2894 |
-
|
| 2895 |
return apply_filters( 'ot_recognized_background_repeat', array(
|
| 2896 |
'no-repeat' => 'No Repeat',
|
| 2897 |
'repeat' => 'Repeat All',
|
|
@@ -2899,9 +2899,9 @@ if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
|
| 2899 |
'repeat-y' => 'Repeat Vertically',
|
| 2900 |
'inherit' => 'Inherit'
|
| 2901 |
), $field_id );
|
| 2902 |
-
|
| 2903 |
}
|
| 2904 |
-
|
| 2905 |
}
|
| 2906 |
|
| 2907 |
/**
|
|
@@ -2921,13 +2921,13 @@ if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
|
| 2921 |
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
|
| 2922 |
|
| 2923 |
function ot_recognized_background_attachment( $field_id = '' ) {
|
| 2924 |
-
|
| 2925 |
return apply_filters( 'ot_recognized_background_attachment', array(
|
| 2926 |
"fixed" => "Fixed",
|
| 2927 |
"scroll" => "Scroll",
|
| 2928 |
"inherit" => "Inherit"
|
| 2929 |
), $field_id );
|
| 2930 |
-
|
| 2931 |
}
|
| 2932 |
|
| 2933 |
}
|
|
@@ -2949,7 +2949,7 @@ if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
|
|
| 2949 |
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
|
| 2950 |
|
| 2951 |
function ot_recognized_background_position( $field_id = '' ) {
|
| 2952 |
-
|
| 2953 |
return apply_filters( 'ot_recognized_background_position', array(
|
| 2954 |
"left top" => "Left Top",
|
| 2955 |
"left center" => "Left Center",
|
|
@@ -2961,7 +2961,7 @@ if ( ! function_exists( 'ot_recognized_background_position' ) ) {
|
|
| 2961 |
"right center" => "Right Center",
|
| 2962 |
"right bottom" => "Right Bottom"
|
| 2963 |
), $field_id );
|
| 2964 |
-
|
| 2965 |
}
|
| 2966 |
|
| 2967 |
}
|
|
@@ -3094,24 +3094,24 @@ if ( ! function_exists( 'ot_recognized_google_font_families' ) ) {
|
|
| 3094 |
|
| 3095 |
$families = array();
|
| 3096 |
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
| 3097 |
-
|
| 3098 |
// Forces an array rebuild when we sitch themes
|
| 3099 |
if ( empty( $ot_google_fonts ) ) {
|
| 3100 |
$ot_google_fonts = ot_fetch_google_fonts( true, true );
|
| 3101 |
}
|
| 3102 |
-
|
| 3103 |
foreach( (array) $ot_google_fonts as $key => $item ) {
|
| 3104 |
-
|
| 3105 |
if ( isset( $item['family'] ) ) {
|
| 3106 |
-
|
| 3107 |
$families[ $key ] = $item['family'];
|
| 3108 |
-
|
| 3109 |
}
|
| 3110 |
-
|
| 3111 |
}
|
| 3112 |
-
|
| 3113 |
return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
|
| 3114 |
-
|
| 3115 |
}
|
| 3116 |
|
| 3117 |
}
|
|
@@ -3134,13 +3134,13 @@ if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) {
|
|
| 3134 |
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
| 3135 |
|
| 3136 |
if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
|
| 3137 |
-
|
| 3138 |
$variants = $ot_google_fonts[ $family ]['variants'];
|
| 3139 |
-
|
| 3140 |
}
|
| 3141 |
-
|
| 3142 |
return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family );
|
| 3143 |
-
|
| 3144 |
}
|
| 3145 |
|
| 3146 |
}
|
|
@@ -3161,15 +3161,15 @@ if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
|
|
| 3161 |
|
| 3162 |
$subsets = array();
|
| 3163 |
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
| 3164 |
-
|
| 3165 |
if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
|
| 3166 |
-
|
| 3167 |
$subsets = $ot_google_fonts[ $family ]['subsets'];
|
| 3168 |
-
|
| 3169 |
}
|
| 3170 |
-
|
| 3171 |
return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family );
|
| 3172 |
-
|
| 3173 |
}
|
| 3174 |
|
| 3175 |
}
|
|
@@ -3189,16 +3189,16 @@ if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
|
|
| 3189 |
* @updated 2.0
|
| 3190 |
*/
|
| 3191 |
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
|
| 3192 |
-
|
| 3193 |
function ot_measurement_unit_types( $field_id = '' ) {
|
| 3194 |
-
|
| 3195 |
return apply_filters( 'ot_measurement_unit_types', array(
|
| 3196 |
'px' => 'px',
|
| 3197 |
'%' => '%',
|
| 3198 |
'em' => 'em',
|
| 3199 |
'pt' => 'pt'
|
| 3200 |
), $field_id );
|
| 3201 |
-
|
| 3202 |
}
|
| 3203 |
|
| 3204 |
}
|
|
@@ -3218,9 +3218,9 @@ if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
|
|
| 3218 |
* @since 2.0
|
| 3219 |
*/
|
| 3220 |
if ( ! function_exists( 'ot_radio_images' ) ) {
|
| 3221 |
-
|
| 3222 |
function ot_radio_images( $field_id = '' ) {
|
| 3223 |
-
|
| 3224 |
return apply_filters( 'ot_radio_images', array(
|
| 3225 |
array(
|
| 3226 |
'value' => 'left-sidebar',
|
|
@@ -3253,7 +3253,7 @@ if ( ! function_exists( 'ot_radio_images' ) ) {
|
|
| 3253 |
'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png'
|
| 3254 |
)
|
| 3255 |
), $field_id );
|
| 3256 |
-
|
| 3257 |
}
|
| 3258 |
|
| 3259 |
}
|
|
@@ -3275,7 +3275,7 @@ if ( ! function_exists( 'ot_radio_images' ) ) {
|
|
| 3275 |
if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
| 3276 |
|
| 3277 |
function ot_list_item_settings( $id ) {
|
| 3278 |
-
|
| 3279 |
$settings = apply_filters( 'ot_list_item_settings', array(
|
| 3280 |
array(
|
| 3281 |
'id' => 'image',
|
|
@@ -3311,9 +3311,9 @@ if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
|
| 3311 |
'choices' => array()
|
| 3312 |
)
|
| 3313 |
), $id );
|
| 3314 |
-
|
| 3315 |
return $settings;
|
| 3316 |
-
|
| 3317 |
}
|
| 3318 |
|
| 3319 |
}
|
|
@@ -3335,7 +3335,7 @@ if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
|
| 3335 |
if ( ! function_exists( 'ot_slider_settings' ) ) {
|
| 3336 |
|
| 3337 |
function ot_slider_settings( $id ) {
|
| 3338 |
-
|
| 3339 |
$settings = apply_filters( 'image_slider_fields', array(
|
| 3340 |
array(
|
| 3341 |
'name' => 'image',
|
|
@@ -3356,41 +3356,41 @@ if ( ! function_exists( 'ot_slider_settings' ) ) {
|
|
| 3356 |
'class' => ''
|
| 3357 |
)
|
| 3358 |
), $id );
|
| 3359 |
-
|
| 3360 |
/* fix the array keys, values, and just get it 2.0 ready */
|
| 3361 |
foreach( $settings as $_k => $setting ) {
|
| 3362 |
-
|
| 3363 |
foreach( $setting as $s_key => $s_value ) {
|
| 3364 |
-
|
| 3365 |
if ( 'name' == $s_key ) {
|
| 3366 |
-
|
| 3367 |
$settings[$_k]['id'] = $s_value;
|
| 3368 |
unset($settings[$_k]['name']);
|
| 3369 |
-
|
| 3370 |
} else if ( 'type' == $s_key ) {
|
| 3371 |
-
|
| 3372 |
if ( 'input' == $s_value ) {
|
| 3373 |
-
|
| 3374 |
$settings[$_k]['type'] = 'text';
|
| 3375 |
-
|
| 3376 |
} else if ( 'textarea' == $s_value ) {
|
| 3377 |
-
|
| 3378 |
$settings[$_k]['type'] = 'textarea-simple';
|
| 3379 |
-
|
| 3380 |
} else if ( 'image' == $s_value ) {
|
| 3381 |
-
|
| 3382 |
$settings[$_k]['type'] = 'upload';
|
| 3383 |
-
|
| 3384 |
}
|
| 3385 |
-
|
| 3386 |
}
|
| 3387 |
-
|
| 3388 |
-
}
|
| 3389 |
-
|
| 3390 |
}
|
| 3391 |
-
|
| 3392 |
return $settings;
|
| 3393 |
-
|
| 3394 |
}
|
| 3395 |
|
| 3396 |
}
|
|
@@ -3412,7 +3412,7 @@ if ( ! function_exists( 'ot_slider_settings' ) ) {
|
|
| 3412 |
if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
| 3413 |
|
| 3414 |
function ot_social_links_settings( $id ) {
|
| 3415 |
-
|
| 3416 |
$settings = apply_filters( 'ot_social_links_settings', array(
|
| 3417 |
array(
|
| 3418 |
'id' => 'name',
|
|
@@ -3435,9 +3435,9 @@ if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
|
| 3435 |
'type' => 'text',
|
| 3436 |
)
|
| 3437 |
), $id );
|
| 3438 |
-
|
| 3439 |
return $settings;
|
| 3440 |
-
|
| 3441 |
}
|
| 3442 |
|
| 3443 |
}
|
|
@@ -3446,7 +3446,7 @@ if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
|
| 3446 |
* Inserts CSS with field_id markers.
|
| 3447 |
*
|
| 3448 |
* Inserts CSS into a dynamic.css file, placing it between
|
| 3449 |
-
* BEGIN and END field_id markers. Replaces existing marked info,
|
| 3450 |
* but still retains surrounding data.
|
| 3451 |
*
|
| 3452 |
* @param string $field_id The CSS option field ID.
|
|
@@ -3540,7 +3540,7 @@ if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
|
|
| 3540 |
// Measurement
|
| 3541 |
if ( $option_type == 'measurement' ) {
|
| 3542 |
$unit = ! empty( $value[1] ) ? $value[1] : 'px';
|
| 3543 |
-
|
| 3544 |
// Set $value with measurement properties
|
| 3545 |
if ( isset( $value[0] ) && strlen( $value[0] ) > 0 )
|
| 3546 |
$value = $value[0].$unit;
|
|
@@ -3862,39 +3862,39 @@ if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
|
|
| 3862 |
if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
| 3863 |
|
| 3864 |
function ot_remove_old_css( $field_id = '' ) {
|
| 3865 |
-
|
| 3866 |
/* missing $field_id string */
|
| 3867 |
if ( '' == $field_id )
|
| 3868 |
return false;
|
| 3869 |
-
|
| 3870 |
/* path to the dynamic.css file */
|
| 3871 |
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
| 3872 |
-
|
| 3873 |
/* allow filter on path */
|
| 3874 |
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
| 3875 |
-
|
| 3876 |
/* remove CSS from file */
|
| 3877 |
if ( is_writeable( $filepath ) ) {
|
| 3878 |
-
|
| 3879 |
/* get each line in the file */
|
| 3880 |
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
| 3881 |
-
|
| 3882 |
/* can't write to the file return false */
|
| 3883 |
if ( ! $f = ot_file_open( $filepath, 'w' ) )
|
| 3884 |
return false;
|
| 3885 |
-
|
| 3886 |
$searching = true;
|
| 3887 |
-
|
| 3888 |
/* has array of lines */
|
| 3889 |
if ( ! empty( $markerdata ) ) {
|
| 3890 |
-
|
| 3891 |
/* foreach line of code */
|
| 3892 |
foreach ( $markerdata as $n => $markerline ) {
|
| 3893 |
-
|
| 3894 |
/* found begining of marker, set $searching to false */
|
| 3895 |
if ( $markerline == "/* BEGIN {$field_id} */" )
|
| 3896 |
$searching = false;
|
| 3897 |
-
|
| 3898 |
/* $searching is true, keep rewrite each line of CSS */
|
| 3899 |
if ( $searching == true ) {
|
| 3900 |
if ( $n + 1 < count( $markerdata ) )
|
|
@@ -3902,27 +3902,27 @@ if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
|
| 3902 |
else
|
| 3903 |
ot_file_write( $f, "{$markerline}" );
|
| 3904 |
}
|
| 3905 |
-
|
| 3906 |
/* found end marker delete old CSS */
|
| 3907 |
if ( $markerline == "/* END {$field_id} */" ) {
|
| 3908 |
ot_file_write( $f, "" );
|
| 3909 |
$searching = true;
|
| 3910 |
}
|
| 3911 |
-
|
| 3912 |
}
|
| 3913 |
-
|
| 3914 |
}
|
| 3915 |
-
|
| 3916 |
/* close file */
|
| 3917 |
ot_file_close( $f );
|
| 3918 |
return true;
|
| 3919 |
-
|
| 3920 |
}
|
| 3921 |
-
|
| 3922 |
return false;
|
| 3923 |
-
|
| 3924 |
}
|
| 3925 |
-
|
| 3926 |
}
|
| 3927 |
|
| 3928 |
/**
|
|
@@ -3940,17 +3940,17 @@ if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
|
| 3940 |
if ( ! function_exists( 'ot_normalize_css' ) ) {
|
| 3941 |
|
| 3942 |
function ot_normalize_css( $css ) {
|
| 3943 |
-
|
| 3944 |
/* Normalize & Convert */
|
| 3945 |
$css = str_replace( "\r\n", "\n", $css );
|
| 3946 |
$css = str_replace( "\r", "\n", $css );
|
| 3947 |
-
|
| 3948 |
/* Don't allow out-of-control blank lines */
|
| 3949 |
$css = preg_replace( "/\n{2,}/", "\n\n", $css );
|
| 3950 |
-
|
| 3951 |
return $css;
|
| 3952 |
}
|
| 3953 |
-
|
| 3954 |
}
|
| 3955 |
|
| 3956 |
/**
|
|
@@ -3966,20 +3966,20 @@ if ( ! function_exists( 'ot_normalize_css' ) ) {
|
|
| 3966 |
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
|
| 3967 |
|
| 3968 |
function ot_loop_through_option_types( $type = '', $child = false ) {
|
| 3969 |
-
|
| 3970 |
$content = '';
|
| 3971 |
$types = ot_option_types_array();
|
| 3972 |
-
|
| 3973 |
if ( $child )
|
| 3974 |
unset($types['list-item']);
|
| 3975 |
-
|
| 3976 |
foreach( $types as $key => $value )
|
| 3977 |
$content.= '<option value="' . $key . '" ' . selected( $type, $key, false ) . '>' . $value . '</option>';
|
| 3978 |
-
|
| 3979 |
return $content;
|
| 3980 |
-
|
| 3981 |
}
|
| 3982 |
-
|
| 3983 |
}
|
| 3984 |
|
| 3985 |
/**
|
|
@@ -3996,15 +3996,15 @@ if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
|
|
| 3996 |
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
|
| 3997 |
|
| 3998 |
function ot_loop_through_choices( $name, $choices = array() ) {
|
| 3999 |
-
|
| 4000 |
$content = '';
|
| 4001 |
-
|
| 4002 |
foreach( (array) $choices as $key => $choice )
|
| 4003 |
$content.= '<li class="ui-state-default list-choice">' . ot_choices_view( $name, $key, $choice ) . '</li>';
|
| 4004 |
-
|
| 4005 |
return $content;
|
| 4006 |
}
|
| 4007 |
-
|
| 4008 |
}
|
| 4009 |
|
| 4010 |
/**
|
|
@@ -4021,15 +4021,15 @@ if ( ! function_exists( 'ot_loop_through_choices' ) ) {
|
|
| 4021 |
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
|
| 4022 |
|
| 4023 |
function ot_loop_through_sub_settings( $name, $settings = array() ) {
|
| 4024 |
-
|
| 4025 |
$content = '';
|
| 4026 |
-
|
| 4027 |
foreach( $settings as $key => $setting )
|
| 4028 |
$content.= '<li class="ui-state-default list-sub-setting">' . ot_settings_view( $name, $key, $setting ) . '</li>';
|
| 4029 |
-
|
| 4030 |
return $content;
|
| 4031 |
}
|
| 4032 |
-
|
| 4033 |
}
|
| 4034 |
|
| 4035 |
/**
|
|
@@ -4049,7 +4049,7 @@ if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
|
|
| 4049 |
if ( ! function_exists( 'ot_sections_view' ) ) {
|
| 4050 |
|
| 4051 |
function ot_sections_view( $name, $key, $section = array() ) {
|
| 4052 |
-
|
| 4053 |
return '
|
| 4054 |
<div class="option-tree-setting is-section">
|
| 4055 |
<div class="open">' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( $key + 1 ) ) . '</div>
|
|
@@ -4080,7 +4080,7 @@ if ( ! function_exists( 'ot_sections_view' ) ) {
|
|
| 4080 |
</div>
|
| 4081 |
</div>
|
| 4082 |
</div>';
|
| 4083 |
-
|
| 4084 |
}
|
| 4085 |
|
| 4086 |
}
|
|
@@ -4102,23 +4102,23 @@ if ( ! function_exists( 'ot_sections_view' ) ) {
|
|
| 4102 |
if ( ! function_exists( 'ot_settings_view' ) ) {
|
| 4103 |
|
| 4104 |
function ot_settings_view( $name, $key, $setting = array() ) {
|
| 4105 |
-
|
| 4106 |
$child = ( strpos( $name, '][settings]') !== false ) ? true : false;
|
| 4107 |
$type = isset( $setting['type'] ) ? $setting['type'] : '';
|
| 4108 |
$std = isset( $setting['std'] ) ? $setting['std'] : '';
|
| 4109 |
$operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
|
| 4110 |
-
|
| 4111 |
// Serialize the standard value just incase
|
| 4112 |
if ( is_array( $std ) ) {
|
| 4113 |
$std = maybe_serialize( $std );
|
| 4114 |
}
|
| 4115 |
-
|
| 4116 |
if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ) ) ) {
|
| 4117 |
$std_form_element = '<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]">' . esc_html( $std ) . '</textarea>';
|
| 4118 |
} else {
|
| 4119 |
$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" />';
|
| 4120 |
}
|
| 4121 |
-
|
| 4122 |
return '
|
| 4123 |
<div class="option-tree-setting">
|
| 4124 |
<div class="open">' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( $key + 1 ) ) . '</div>
|
|
@@ -4152,8 +4152,8 @@ if ( ! function_exists( 'ot_settings_view' ) ) {
|
|
| 4152 |
<div class="description">' . __( '<strong>Type</strong>: Choose one of the available option types from the dropdown.', 'option-tree' ) . '</div>
|
| 4153 |
<div class="format-setting-inner">
|
| 4154 |
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][type]" value="' . esc_attr( $type ) . '" class="option-tree-ui-select">
|
| 4155 |
-
' . ot_loop_through_option_types( $type, $child ) . '
|
| 4156 |
-
|
| 4157 |
</select>
|
| 4158 |
</div>
|
| 4159 |
</div>
|
|
@@ -4258,7 +4258,7 @@ if ( ! function_exists( 'ot_settings_view' ) ) {
|
|
| 4258 |
</div>
|
| 4259 |
</div>
|
| 4260 |
' . ( ! $child ? '<input type="hidden" class="hidden-section" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][section]" value="' . ( isset( $setting['section'] ) ? esc_attr( $setting['section'] ) : '' ) . '" />' : '' );
|
| 4261 |
-
|
| 4262 |
}
|
| 4263 |
|
| 4264 |
}
|
|
@@ -4281,7 +4281,7 @@ if ( ! function_exists( 'ot_settings_view' ) ) {
|
|
| 4281 |
if ( ! function_exists( 'ot_choices_view' ) ) {
|
| 4282 |
|
| 4283 |
function ot_choices_view( $name, $key, $choice = array() ) {
|
| 4284 |
-
|
| 4285 |
return '
|
| 4286 |
<div class="option-tree-setting">
|
| 4287 |
<div class="open">' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( $key + 1 ) ) . '</div>
|
|
@@ -4325,7 +4325,7 @@ if ( ! function_exists( 'ot_choices_view' ) ) {
|
|
| 4325 |
</div>
|
| 4326 |
</div>
|
| 4327 |
</div>';
|
| 4328 |
-
|
| 4329 |
}
|
| 4330 |
|
| 4331 |
}
|
|
@@ -4347,7 +4347,7 @@ if ( ! function_exists( 'ot_choices_view' ) ) {
|
|
| 4347 |
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
|
| 4348 |
|
| 4349 |
function ot_contextual_help_view( $name, $key, $content = array() ) {
|
| 4350 |
-
|
| 4351 |
return '
|
| 4352 |
<div class="option-tree-setting">
|
| 4353 |
<div class="open">' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( $key + 1 ) ) . '</div>
|
|
@@ -4386,7 +4386,7 @@ if ( ! function_exists( 'ot_contextual_help_view' ) ) {
|
|
| 4386 |
</div>
|
| 4387 |
</div>
|
| 4388 |
</div>';
|
| 4389 |
-
|
| 4390 |
}
|
| 4391 |
|
| 4392 |
}
|
|
@@ -4420,7 +4420,7 @@ if ( ! function_exists( 'ot_layout_view' ) ) {
|
|
| 4420 |
</div>
|
| 4421 |
<input type="hidden" name="' . ot_layouts_id() . '[' . esc_attr( $key ) . ']" value="' . $data . '" />
|
| 4422 |
</div>';
|
| 4423 |
-
|
| 4424 |
}
|
| 4425 |
|
| 4426 |
}
|
|
@@ -4443,7 +4443,7 @@ if ( ! function_exists( 'ot_layout_view' ) ) {
|
|
| 4443 |
if ( ! function_exists( 'ot_list_item_view' ) ) {
|
| 4444 |
|
| 4445 |
function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
| 4446 |
-
|
| 4447 |
/* required title setting */
|
| 4448 |
$required_setting = array(
|
| 4449 |
array(
|
|
@@ -4458,24 +4458,24 @@ if ( ! function_exists( 'ot_list_item_view' ) ) {
|
|
| 4458 |
'choices' => array()
|
| 4459 |
)
|
| 4460 |
);
|
| 4461 |
-
|
| 4462 |
/* load the old filterable slider settings */
|
| 4463 |
if ( 'slider' == $type ) {
|
| 4464 |
-
|
| 4465 |
$settings = ot_slider_settings( $name );
|
| 4466 |
-
|
| 4467 |
}
|
| 4468 |
-
|
| 4469 |
/* if no settings array load the filterable list item settings */
|
| 4470 |
if ( empty( $settings ) ) {
|
| 4471 |
-
|
| 4472 |
$settings = ot_list_item_settings( $name );
|
| 4473 |
-
|
| 4474 |
}
|
| 4475 |
-
|
| 4476 |
/* merge the two settings array */
|
| 4477 |
$settings = array_merge( $required_setting, $settings );
|
| 4478 |
-
|
| 4479 |
echo '
|
| 4480 |
<div class="option-tree-setting">
|
| 4481 |
<div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
|
|
@@ -4488,31 +4488,31 @@ if ( ! function_exists( 'ot_list_item_view' ) ) {
|
|
| 4488 |
</a>
|
| 4489 |
</div>
|
| 4490 |
<div class="option-tree-setting-body">';
|
| 4491 |
-
|
| 4492 |
foreach( $settings as $field ) {
|
| 4493 |
-
|
| 4494 |
// Set field value
|
| 4495 |
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
| 4496 |
-
|
| 4497 |
/* set default to standard value */
|
| 4498 |
-
if ( isset( $field['std'] ) ) {
|
| 4499 |
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
| 4500 |
}
|
| 4501 |
-
|
| 4502 |
// filter the title label and description
|
| 4503 |
if ( $field['id'] == 'title' ) {
|
| 4504 |
-
|
| 4505 |
// filter the label
|
| 4506 |
$field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name );
|
| 4507 |
-
|
| 4508 |
// filter the description
|
| 4509 |
$field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name );
|
| 4510 |
-
|
| 4511 |
}
|
| 4512 |
-
|
| 4513 |
/* make life easier */
|
| 4514 |
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
| 4515 |
-
|
| 4516 |
/* build the arguments array */
|
| 4517 |
$_args = array(
|
| 4518 |
'type' => $field['type'],
|
|
@@ -4533,12 +4533,12 @@ if ( ! function_exists( 'ot_list_item_view' ) ) {
|
|
| 4533 |
'post_id' => $post_id,
|
| 4534 |
'get_option' => $get_option
|
| 4535 |
);
|
| 4536 |
-
|
| 4537 |
$conditions = '';
|
| 4538 |
-
|
| 4539 |
/* setup the conditions */
|
| 4540 |
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
| 4541 |
-
|
| 4542 |
/* doing magic on the conditions so they work in a list item */
|
| 4543 |
$conditionals = explode( ',', $field['condition'] );
|
| 4544 |
foreach( $conditionals as $condition ) {
|
|
@@ -4571,36 +4571,36 @@ if ( ! function_exists( 'ot_list_item_view' ) ) {
|
|
| 4571 |
$class = 'format-settings';
|
| 4572 |
|
| 4573 |
}
|
| 4574 |
-
|
| 4575 |
/* option label */
|
| 4576 |
echo '<div id="setting_' . $_args['field_id'] . '" class="' . $class . '"' . $conditions . '>';
|
| 4577 |
-
|
| 4578 |
/* don't show title with textblocks */
|
| 4579 |
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
| 4580 |
echo '<div class="format-setting-label">';
|
| 4581 |
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
| 4582 |
echo '</div>';
|
| 4583 |
}
|
| 4584 |
-
|
| 4585 |
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
| 4586 |
if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' )
|
| 4587 |
$_args['type'] = 'textarea-simple';
|
| 4588 |
-
|
| 4589 |
/* option body, list-item is not allowed inside another list-item */
|
| 4590 |
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' ) {
|
| 4591 |
echo ot_display_by_type( $_args );
|
| 4592 |
}
|
| 4593 |
-
|
| 4594 |
echo '</div>';
|
| 4595 |
-
|
| 4596 |
}
|
| 4597 |
-
|
| 4598 |
echo '</div>';
|
| 4599 |
-
|
| 4600 |
echo '</div>';
|
| 4601 |
-
|
| 4602 |
}
|
| 4603 |
-
|
| 4604 |
}
|
| 4605 |
|
| 4606 |
/**
|
|
@@ -4621,14 +4621,14 @@ if ( ! function_exists( 'ot_list_item_view' ) ) {
|
|
| 4621 |
if ( ! function_exists( 'ot_social_links_view' ) ) {
|
| 4622 |
|
| 4623 |
function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
| 4624 |
-
|
| 4625 |
/* if no settings array load the filterable social links settings */
|
| 4626 |
if ( empty( $settings ) ) {
|
| 4627 |
-
|
| 4628 |
$settings = ot_social_links_settings( $name );
|
| 4629 |
-
|
| 4630 |
}
|
| 4631 |
-
|
| 4632 |
echo '
|
| 4633 |
<div class="option-tree-setting">
|
| 4634 |
<div class="open">' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '</div>
|
|
@@ -4641,20 +4641,20 @@ if ( ! function_exists( 'ot_social_links_view' ) ) {
|
|
| 4641 |
</a>
|
| 4642 |
</div>
|
| 4643 |
<div class="option-tree-setting-body">';
|
| 4644 |
-
|
| 4645 |
foreach( $settings as $field ) {
|
| 4646 |
-
|
| 4647 |
// Set field value
|
| 4648 |
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
| 4649 |
-
|
| 4650 |
/* set default to standard value */
|
| 4651 |
-
if ( isset( $field['std'] ) ) {
|
| 4652 |
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
| 4653 |
}
|
| 4654 |
-
|
| 4655 |
/* make life easier */
|
| 4656 |
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
| 4657 |
-
|
| 4658 |
/* build the arguments array */
|
| 4659 |
$_args = array(
|
| 4660 |
'type' => $field['type'],
|
|
@@ -4675,12 +4675,12 @@ if ( ! function_exists( 'ot_social_links_view' ) ) {
|
|
| 4675 |
'post_id' => $post_id,
|
| 4676 |
'get_option' => $get_option
|
| 4677 |
);
|
| 4678 |
-
|
| 4679 |
$conditions = '';
|
| 4680 |
-
|
| 4681 |
/* setup the conditions */
|
| 4682 |
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
| 4683 |
-
|
| 4684 |
/* doing magic on the conditions so they work in a list item */
|
| 4685 |
$conditionals = explode( ',', $field['condition'] );
|
| 4686 |
foreach( $conditionals as $condition ) {
|
|
@@ -4694,36 +4694,36 @@ if ( ! function_exists( 'ot_social_links_view' ) ) {
|
|
| 4694 |
$conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
|
| 4695 |
|
| 4696 |
}
|
| 4697 |
-
|
| 4698 |
/* option label */
|
| 4699 |
echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings"' . $conditions . '>';
|
| 4700 |
-
|
| 4701 |
/* don't show title with textblocks */
|
| 4702 |
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
| 4703 |
echo '<div class="format-setting-label">';
|
| 4704 |
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
| 4705 |
echo '</div>';
|
| 4706 |
}
|
| 4707 |
-
|
| 4708 |
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
| 4709 |
if ( $_args['type'] == 'textarea' )
|
| 4710 |
$_args['type'] = 'textarea-simple';
|
| 4711 |
-
|
| 4712 |
/* option body, list-item is not allowed inside another list-item */
|
| 4713 |
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' && $_args['type'] !== 'social-links' ) {
|
| 4714 |
echo ot_display_by_type( $_args );
|
| 4715 |
}
|
| 4716 |
-
|
| 4717 |
echo '</div>';
|
| 4718 |
-
|
| 4719 |
}
|
| 4720 |
-
|
| 4721 |
echo '</div>';
|
| 4722 |
-
|
| 4723 |
echo '</div>';
|
| 4724 |
-
|
| 4725 |
}
|
| 4726 |
-
|
| 4727 |
}
|
| 4728 |
|
| 4729 |
/**
|
|
@@ -4737,63 +4737,63 @@ if ( ! function_exists( 'ot_social_links_view' ) ) {
|
|
| 4737 |
if ( ! function_exists( 'niftycs_options_layouts_form' ) ) {
|
| 4738 |
|
| 4739 |
function niftycs_options_layouts_form( $active = false ) {
|
| 4740 |
-
|
| 4741 |
echo '<form method="post" id="option-tree-options-layouts-form">';
|
| 4742 |
-
|
| 4743 |
/* form nonce */
|
| 4744 |
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
| 4745 |
-
|
| 4746 |
/* get the saved layouts */
|
| 4747 |
$layouts = get_option( ot_layouts_id() );
|
| 4748 |
-
|
| 4749 |
/* set active layout */
|
| 4750 |
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
| 4751 |
|
| 4752 |
if ( is_array( $layouts ) && count( $layouts ) > 1 ) {
|
| 4753 |
-
|
| 4754 |
$active_layout = esc_attr( $layouts['active_layout'] );
|
| 4755 |
-
|
| 4756 |
echo '<input type="hidden" id="the_current_layout" value="' . $active_layout . '" />';
|
| 4757 |
-
|
| 4758 |
echo '<div class="option-tree-active-layout">';
|
| 4759 |
-
|
| 4760 |
echo '<select name="' . ot_layouts_id() . '[active_layout]" class="option-tree-ui-select">';
|
| 4761 |
-
|
| 4762 |
-
foreach( $layouts as $key => $data ) {
|
| 4763 |
-
|
| 4764 |
if ( $key == 'active_layout' )
|
| 4765 |
continue;
|
| 4766 |
-
|
| 4767 |
echo '<option' . selected( $key, $active_layout, false ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $key ) . '</option>';
|
| 4768 |
}
|
| 4769 |
-
|
| 4770 |
echo '</select>';
|
| 4771 |
-
|
| 4772 |
echo '</div>';
|
| 4773 |
-
|
| 4774 |
foreach( $layouts as $key => $data ) {
|
| 4775 |
-
|
| 4776 |
if ( $key == 'active_layout' )
|
| 4777 |
continue;
|
| 4778 |
-
|
| 4779 |
echo '<input type="hidden" name="' . ot_layouts_id() . '[' . $key . ']" value="' . ( isset( $data ) ? $data : '' ) . '" />';
|
| 4780 |
-
|
| 4781 |
}
|
| 4782 |
-
|
| 4783 |
}
|
| 4784 |
-
|
| 4785 |
/* new layout wrapper */
|
| 4786 |
echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
|
| 4787 |
-
|
| 4788 |
/* add new layout */
|
| 4789 |
echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
| 4790 |
-
|
| 4791 |
echo '<button type="submit" class="option-tree-ui-button button button-primary save-layout" title="' . __( 'New Layout', 'option-tree' ) . '">' . __( 'New Layout', 'option-tree' ) . '</button>';
|
| 4792 |
-
|
| 4793 |
echo '</div>';
|
| 4794 |
-
|
| 4795 |
echo '</form>';
|
| 4796 |
-
|
| 4797 |
}
|
| 4798 |
|
| 4799 |
}
|
|
@@ -4810,9 +4810,9 @@ if ( ! function_exists( 'niftycs_options_layouts_form' ) ) {
|
|
| 4810 |
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
|
| 4811 |
|
| 4812 |
function ot_sanitize_option_id( $input ) {
|
| 4813 |
-
|
| 4814 |
return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
|
| 4815 |
-
|
| 4816 |
}
|
| 4817 |
|
| 4818 |
}
|
|
@@ -4829,9 +4829,9 @@ if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
|
|
| 4829 |
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
|
| 4830 |
|
| 4831 |
function ot_sanitize_layout_id( $input ) {
|
| 4832 |
-
|
| 4833 |
return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
|
| 4834 |
-
|
| 4835 |
}
|
| 4836 |
|
| 4837 |
}
|
|
@@ -4852,15 +4852,15 @@ if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
|
|
| 4852 |
|
| 4853 |
foreach( $input as $k => $choice ) {
|
| 4854 |
$choices[$k] = $choice['value'] . '|' . $choice['label'];
|
| 4855 |
-
|
| 4856 |
if ( isset( $choice['src'] ) )
|
| 4857 |
$choices[$k].= '|' . $choice['src'];
|
| 4858 |
-
|
| 4859 |
}
|
| 4860 |
-
|
| 4861 |
return implode( ',', $choices );
|
| 4862 |
}
|
| 4863 |
-
|
| 4864 |
return false;
|
| 4865 |
}
|
| 4866 |
}
|
|
@@ -4876,39 +4876,39 @@ if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
|
|
| 4876 |
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
|
| 4877 |
|
| 4878 |
function ot_convert_string_to_array( $input ) {
|
| 4879 |
-
|
| 4880 |
if ( '' !== $input ) {
|
| 4881 |
-
|
| 4882 |
/* empty choices array */
|
| 4883 |
$choices = array();
|
| 4884 |
-
|
| 4885 |
/* exlode the string into an array */
|
| 4886 |
foreach( explode( ',', $input ) as $k => $choice ) {
|
| 4887 |
-
|
| 4888 |
/* if ":" is splitting the string go deeper */
|
| 4889 |
if ( preg_match( '/\|/', $choice ) ) {
|
| 4890 |
$split = explode( '|', $choice );
|
| 4891 |
$choices[$k]['value'] = trim( $split[0] );
|
| 4892 |
$choices[$k]['label'] = trim( $split[1] );
|
| 4893 |
-
|
| 4894 |
/* if radio image there are three values */
|
| 4895 |
if ( isset( $split[2] ) )
|
| 4896 |
$choices[$k]['src'] = trim( $split[2] );
|
| 4897 |
-
|
| 4898 |
} else {
|
| 4899 |
$choices[$k]['value'] = trim( $choice );
|
| 4900 |
$choices[$k]['label'] = trim( $choice );
|
| 4901 |
}
|
| 4902 |
-
|
| 4903 |
}
|
| 4904 |
-
|
| 4905 |
/* return a formated choices array */
|
| 4906 |
return $choices;
|
| 4907 |
-
|
| 4908 |
}
|
| 4909 |
-
|
| 4910 |
return false;
|
| 4911 |
-
|
| 4912 |
}
|
| 4913 |
}
|
| 4914 |
|
|
@@ -4925,14 +4925,14 @@ if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
|
|
| 4925 |
if ( ! function_exists( 'ot_strpos_array' ) ) {
|
| 4926 |
|
| 4927 |
function ot_strpos_array( $haystack, $needles = array() ) {
|
| 4928 |
-
|
| 4929 |
foreach( $needles as $needle ) {
|
| 4930 |
$pos = strpos( $haystack, $needle );
|
| 4931 |
if ( $pos !== false ) {
|
| 4932 |
return true;
|
| 4933 |
}
|
| 4934 |
}
|
| 4935 |
-
|
| 4936 |
return false;
|
| 4937 |
}
|
| 4938 |
|
|
@@ -4949,18 +4949,18 @@ if ( ! function_exists( 'ot_strpos_array' ) ) {
|
|
| 4949 |
* @since 2.0
|
| 4950 |
*/
|
| 4951 |
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
|
| 4952 |
-
|
| 4953 |
function ot_array_keys_exists( $array, $keys ) {
|
| 4954 |
-
|
| 4955 |
foreach($keys as $k) {
|
| 4956 |
if ( isset($array[$k]) ) {
|
| 4957 |
return true;
|
| 4958 |
}
|
| 4959 |
}
|
| 4960 |
-
|
| 4961 |
return false;
|
| 4962 |
}
|
| 4963 |
-
|
| 4964 |
}
|
| 4965 |
|
| 4966 |
/**
|
|
@@ -4975,31 +4975,31 @@ if ( ! function_exists( 'ot_array_keys_exists' ) ) {
|
|
| 4975 |
if ( ! function_exists( 'ot_stripslashes' ) ) {
|
| 4976 |
|
| 4977 |
function ot_stripslashes( $input ) {
|
| 4978 |
-
|
| 4979 |
if ( is_array( $input ) ) {
|
| 4980 |
-
|
| 4981 |
foreach( $input as &$val ) {
|
| 4982 |
-
|
| 4983 |
if ( is_array( $val ) ) {
|
| 4984 |
-
|
| 4985 |
$val = ot_stripslashes( $val );
|
| 4986 |
-
|
| 4987 |
} else {
|
| 4988 |
-
|
| 4989 |
$val = stripslashes( trim( $val ) );
|
| 4990 |
-
|
| 4991 |
}
|
| 4992 |
-
|
| 4993 |
}
|
| 4994 |
-
|
| 4995 |
} else {
|
| 4996 |
-
|
| 4997 |
$input = stripslashes( trim( $input ) );
|
| 4998 |
-
|
| 4999 |
}
|
| 5000 |
-
|
| 5001 |
return $input;
|
| 5002 |
-
|
| 5003 |
}
|
| 5004 |
|
| 5005 |
}
|
|
@@ -5016,23 +5016,23 @@ if ( ! function_exists( 'ot_stripslashes' ) ) {
|
|
| 5016 |
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
| 5017 |
|
| 5018 |
function ot_reverse_wpautop( $string = '' ) {
|
| 5019 |
-
|
| 5020 |
/* return if string is empty */
|
| 5021 |
if ( trim( $string ) === '' )
|
| 5022 |
return '';
|
| 5023 |
-
|
| 5024 |
/* remove all new lines & <p> tags */
|
| 5025 |
$string = str_replace( array( "\n", "<p>" ), "", $string );
|
| 5026 |
-
|
| 5027 |
/* replace <br /> with \r */
|
| 5028 |
$string = str_replace( array( "<br />", "<br>", "<br/>" ), "\r", $string );
|
| 5029 |
-
|
| 5030 |
/* replace </p> with \r\n */
|
| 5031 |
$string = str_replace( "</p>", "\r\n", $string );
|
| 5032 |
-
|
| 5033 |
/* return clean string */
|
| 5034 |
return trim( $string );
|
| 5035 |
-
|
| 5036 |
}
|
| 5037 |
|
| 5038 |
}
|
|
@@ -5040,14 +5040,14 @@ if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
|
| 5040 |
/**
|
| 5041 |
* Returns an array of elements from start to limit, inclusive.
|
| 5042 |
*
|
| 5043 |
-
* Occasionally zero will be some impossibly large number to
|
| 5044 |
* the "E" power when creating a range from negative to positive.
|
| 5045 |
* This function attempts to fix that by setting that number back to "0".
|
| 5046 |
*
|
| 5047 |
* @param string $start First value of the sequence.
|
| 5048 |
* @param string $limit The sequence is ended upon reaching the limit value.
|
| 5049 |
-
* @param string $step If a step value is given, it will be used as the increment
|
| 5050 |
-
* between elements in the sequence. step should be given as a
|
| 5051 |
* positive number. If not specified, step will default to 1.
|
| 5052 |
* @return array
|
| 5053 |
*
|
|
@@ -5055,18 +5055,18 @@ if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
|
| 5055 |
* @since 2.0.12
|
| 5056 |
*/
|
| 5057 |
function ot_range( $start, $limit, $step = 1 ) {
|
| 5058 |
-
|
| 5059 |
if ( $step < 0 )
|
| 5060 |
$step = 1;
|
| 5061 |
-
|
| 5062 |
$range = range( $start, $limit, $step );
|
| 5063 |
-
|
| 5064 |
foreach( $range as $k => $v ) {
|
| 5065 |
if ( strpos( $v, 'E' ) ) {
|
| 5066 |
$range[$k] = 0;
|
| 5067 |
}
|
| 5068 |
}
|
| 5069 |
-
|
| 5070 |
return $range;
|
| 5071 |
}
|
| 5072 |
|
|
@@ -5082,7 +5082,7 @@ function ot_encode( $value ) {
|
|
| 5082 |
|
| 5083 |
$func = 'base64' . '_encode';
|
| 5084 |
return $func( $value );
|
| 5085 |
-
|
| 5086 |
}
|
| 5087 |
|
| 5088 |
/**
|
|
@@ -5097,7 +5097,7 @@ function ot_decode( $value ) {
|
|
| 5097 |
|
| 5098 |
$func = 'base64' . '_decode';
|
| 5099 |
return $func( $value );
|
| 5100 |
-
|
| 5101 |
}
|
| 5102 |
|
| 5103 |
/**
|
|
@@ -5110,7 +5110,7 @@ function ot_file_open( $handle, $mode ) {
|
|
| 5110 |
|
| 5111 |
$func = 'f' . 'open';
|
| 5112 |
return @$func( $handle, $mode );
|
| 5113 |
-
|
| 5114 |
}
|
| 5115 |
|
| 5116 |
/**
|
|
@@ -5123,7 +5123,7 @@ function ot_file_close( $handle ) {
|
|
| 5123 |
|
| 5124 |
$func = 'f' . 'close';
|
| 5125 |
return $func( $handle );
|
| 5126 |
-
|
| 5127 |
}
|
| 5128 |
|
| 5129 |
/**
|
|
@@ -5136,7 +5136,7 @@ function ot_file_write( $handle, $string ) {
|
|
| 5136 |
|
| 5137 |
$func = 'f' . 'write';
|
| 5138 |
return $func( $handle, $string );
|
| 5139 |
-
|
| 5140 |
}
|
| 5141 |
|
| 5142 |
/**
|
|
@@ -5150,29 +5150,29 @@ function ot_file_write( $handle, $string ) {
|
|
| 5150 |
* @since 2.0.15
|
| 5151 |
*/
|
| 5152 |
function ot_filter_std_value( $value = '', $std = '' ) {
|
| 5153 |
-
|
| 5154 |
$std = maybe_unserialize( $std );
|
| 5155 |
-
|
| 5156 |
if ( is_array( $value ) && is_array( $std ) ) {
|
| 5157 |
-
|
| 5158 |
foreach( $value as $k => $v ) {
|
| 5159 |
-
|
| 5160 |
if ( '' == $value[$k] && isset( $std[$k] ) ) {
|
| 5161 |
-
|
| 5162 |
$value[$k] = $std[$k];
|
| 5163 |
-
|
| 5164 |
}
|
| 5165 |
-
|
| 5166 |
}
|
| 5167 |
-
|
| 5168 |
} else if ( '' == $value && ! empty( $std ) ) {
|
| 5169 |
-
|
| 5170 |
$value = $std;
|
| 5171 |
-
|
| 5172 |
}
|
| 5173 |
|
| 5174 |
return $value;
|
| 5175 |
-
|
| 5176 |
}
|
| 5177 |
|
| 5178 |
/**
|
|
@@ -5254,8 +5254,8 @@ function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
|
|
| 5254 |
|
| 5255 |
/* Initiate API request */
|
| 5256 |
$ot_google_fonts_query_args = array(
|
| 5257 |
-
'key' => $ot_google_fonts_api_key,
|
| 5258 |
-
'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')',
|
| 5259 |
'sort' => $ot_google_fonts_sort
|
| 5260 |
);
|
| 5261 |
|
|
@@ -5274,7 +5274,7 @@ function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
|
|
| 5274 |
if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) {
|
| 5275 |
|
| 5276 |
$ot_google_fonts = $ot_google_fonts_data['items'];
|
| 5277 |
-
|
| 5278 |
// Normalize the array key
|
| 5279 |
$ot_google_fonts_tmp = array();
|
| 5280 |
foreach( $ot_google_fonts as $key => $value ) {
|
|
@@ -5283,7 +5283,7 @@ function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
|
|
| 5283 |
$id = preg_replace( '/[^a-z0-9_\-]/', '', $id );
|
| 5284 |
$ot_google_fonts_tmp[$id] = $value;
|
| 5285 |
}
|
| 5286 |
-
|
| 5287 |
$ot_google_fonts = $ot_google_fonts_tmp;
|
| 5288 |
set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
|
| 5289 |
set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS );
|
|
@@ -5356,11 +5356,11 @@ function ot_normalize_google_fonts( $google_fonts ) {
|
|
| 5356 |
function ot_wpml_register_string( $id, $value ) {
|
| 5357 |
|
| 5358 |
if ( function_exists( 'icl_register_string' ) ) {
|
| 5359 |
-
|
| 5360 |
icl_register_string( 'Theme Options', $id, $value );
|
| 5361 |
-
|
| 5362 |
}
|
| 5363 |
-
|
| 5364 |
}
|
| 5365 |
|
| 5366 |
/**
|
|
@@ -5372,11 +5372,11 @@ function ot_wpml_register_string( $id, $value ) {
|
|
| 5372 |
function ot_wpml_unregister_string( $id ) {
|
| 5373 |
|
| 5374 |
if ( function_exists( 'icl_unregister_string' ) ) {
|
| 5375 |
-
|
| 5376 |
icl_unregister_string( 'Theme Options', $id );
|
| 5377 |
-
|
| 5378 |
}
|
| 5379 |
-
|
| 5380 |
}
|
| 5381 |
|
| 5382 |
/**
|
|
@@ -5390,27 +5390,27 @@ function ot_wpml_unregister_string( $id ) {
|
|
| 5390 |
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
|
| 5391 |
|
| 5392 |
function ot_maybe_migrate_settings() {
|
| 5393 |
-
|
| 5394 |
// Filter the ID to migrate from
|
| 5395 |
$settings_id = apply_filters( 'ot_migrate_settings_id', '' );
|
| 5396 |
-
|
| 5397 |
-
// Attempt to migrate Settings
|
| 5398 |
if ( ! empty( $settings_id ) && get_option( ot_settings_id() ) === false && ot_settings_id() !== $settings_id ) {
|
| 5399 |
-
|
| 5400 |
// Old settings
|
| 5401 |
$settings = get_option( $settings_id );
|
| 5402 |
-
|
| 5403 |
// Check for array keys
|
| 5404 |
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
| 5405 |
-
|
| 5406 |
update_option( ot_settings_id(), $settings );
|
| 5407 |
-
|
| 5408 |
}
|
| 5409 |
-
|
| 5410 |
}
|
| 5411 |
|
| 5412 |
}
|
| 5413 |
-
|
| 5414 |
}
|
| 5415 |
|
| 5416 |
/**
|
|
@@ -5424,23 +5424,23 @@ if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
|
|
| 5424 |
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
|
| 5425 |
|
| 5426 |
function ot_maybe_migrate_options() {
|
| 5427 |
-
|
| 5428 |
// Filter the ID to migrate from
|
| 5429 |
$options_id = apply_filters( 'ot_migrate_options_id', '' );
|
| 5430 |
-
|
| 5431 |
// Attempt to migrate Theme Options
|
| 5432 |
if ( ! empty( $options_id ) && get_option( ot_options_id() ) === false && ot_options_id() !== $options_id ) {
|
| 5433 |
-
|
| 5434 |
// Old options
|
| 5435 |
$options = get_option( $options_id );
|
| 5436 |
-
|
| 5437 |
// Migrate to new ID
|
| 5438 |
update_option( ot_options_id(), $options );
|
| 5439 |
-
|
| 5440 |
}
|
| 5441 |
|
| 5442 |
}
|
| 5443 |
-
|
| 5444 |
}
|
| 5445 |
|
| 5446 |
/**
|
|
@@ -5454,19 +5454,19 @@ if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
|
|
| 5454 |
if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
|
| 5455 |
|
| 5456 |
function ot_maybe_migrate_layouts() {
|
| 5457 |
-
|
| 5458 |
// Filter the ID to migrate from
|
| 5459 |
$layouts_id = apply_filters( 'ot_migrate_layouts_id', '' );
|
| 5460 |
-
|
| 5461 |
// Attempt to migrate Layouts
|
| 5462 |
if ( ! empty( $layouts_id ) && get_option( ot_layouts_id() ) === false && ot_layouts_id() !== $layouts_id ) {
|
| 5463 |
-
|
| 5464 |
// Old options
|
| 5465 |
$layouts = get_option( $layouts_id );
|
| 5466 |
-
|
| 5467 |
// Migrate to new ID
|
| 5468 |
update_option( ot_layouts_id(), $layouts );
|
| 5469 |
-
|
| 5470 |
}
|
| 5471 |
|
| 5472 |
}
|
|
@@ -5476,8 +5476,8 @@ if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
|
|
| 5476 |
/**
|
| 5477 |
* Returns an array with the post format gallery meta box.
|
| 5478 |
*
|
| 5479 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
| 5480 |
-
* post_types and is what tells the metabox where to
|
| 5481 |
* display. Default 'post'.
|
| 5482 |
* @return array
|
| 5483 |
*
|
|
@@ -5488,10 +5488,10 @@ function ot_meta_box_post_format_gallery( $pages = 'post' ) {
|
|
| 5488 |
|
| 5489 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'gallery', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5490 |
return false;
|
| 5491 |
-
|
| 5492 |
if ( is_string( $pages ) )
|
| 5493 |
$pages = explode( ',', $pages );
|
| 5494 |
-
|
| 5495 |
return apply_filters( 'ot_meta_box_post_format_gallery', array(
|
| 5496 |
'id' => 'ot-post-format-gallery',
|
| 5497 |
'title' => __( 'Gallery', 'option-tree' ),
|
|
@@ -5516,8 +5516,8 @@ function ot_meta_box_post_format_gallery( $pages = 'post' ) {
|
|
| 5516 |
/**
|
| 5517 |
* Returns an array with the post format link metabox.
|
| 5518 |
*
|
| 5519 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
| 5520 |
-
* post_types and is what tells the metabox where to
|
| 5521 |
* display. Default 'post'.
|
| 5522 |
* @return array
|
| 5523 |
*
|
|
@@ -5525,13 +5525,13 @@ function ot_meta_box_post_format_gallery( $pages = 'post' ) {
|
|
| 5525 |
* @since 2.4.0
|
| 5526 |
*/
|
| 5527 |
function ot_meta_box_post_format_link( $pages = 'post' ) {
|
| 5528 |
-
|
| 5529 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5530 |
return false;
|
| 5531 |
-
|
| 5532 |
if ( is_string( $pages ) )
|
| 5533 |
$pages = explode( ',', $pages );
|
| 5534 |
-
|
| 5535 |
return apply_filters( 'ot_meta_box_post_format_link', array(
|
| 5536 |
'id' => 'ot-post-format-link',
|
| 5537 |
'title' => __( 'Link', 'option-tree' ),
|
|
@@ -5562,8 +5562,8 @@ function ot_meta_box_post_format_link( $pages = 'post' ) {
|
|
| 5562 |
/**
|
| 5563 |
* Returns an array with the post format quote metabox.
|
| 5564 |
*
|
| 5565 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
| 5566 |
-
* post_types and is what tells the metabox where to
|
| 5567 |
* display. Default 'post'.
|
| 5568 |
* @return array
|
| 5569 |
*
|
|
@@ -5571,10 +5571,10 @@ function ot_meta_box_post_format_link( $pages = 'post' ) {
|
|
| 5571 |
* @since 2.4.0
|
| 5572 |
*/
|
| 5573 |
function ot_meta_box_post_format_quote( $pages = 'post' ) {
|
| 5574 |
-
|
| 5575 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5576 |
return false;
|
| 5577 |
-
|
| 5578 |
if ( is_string( $pages ) )
|
| 5579 |
$pages = explode( ',', $pages );
|
| 5580 |
|
|
@@ -5622,8 +5622,8 @@ function ot_meta_box_post_format_quote( $pages = 'post' ) {
|
|
| 5622 |
/**
|
| 5623 |
* Returns an array with the post format video metabox.
|
| 5624 |
*
|
| 5625 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
| 5626 |
-
* post_types and is what tells the metabox where to
|
| 5627 |
* display. Default 'post'.
|
| 5628 |
* @return array
|
| 5629 |
*
|
|
@@ -5631,13 +5631,13 @@ function ot_meta_box_post_format_quote( $pages = 'post' ) {
|
|
| 5631 |
* @since 2.4.0
|
| 5632 |
*/
|
| 5633 |
function ot_meta_box_post_format_video( $pages = 'post' ) {
|
| 5634 |
-
|
| 5635 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5636 |
return false;
|
| 5637 |
-
|
| 5638 |
if ( is_string( $pages ) )
|
| 5639 |
$pages = explode( ',', $pages );
|
| 5640 |
-
|
| 5641 |
return apply_filters( 'ot_meta_box_post_format_video', array(
|
| 5642 |
'id' => 'ot-post-format-video',
|
| 5643 |
'title' => __( 'Video', 'option-tree' ),
|
|
@@ -5661,8 +5661,8 @@ function ot_meta_box_post_format_video( $pages = 'post' ) {
|
|
| 5661 |
/**
|
| 5662 |
* Returns an array with the post format audio metabox.
|
| 5663 |
*
|
| 5664 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
| 5665 |
-
* post_types and is what tells the metabox where to
|
| 5666 |
* display. Default 'post'.
|
| 5667 |
* @return array
|
| 5668 |
*
|
|
@@ -5670,13 +5670,13 @@ function ot_meta_box_post_format_video( $pages = 'post' ) {
|
|
| 5670 |
* @since 2.4.0
|
| 5671 |
*/
|
| 5672 |
function ot_meta_box_post_format_audio( $pages = 'post' ) {
|
| 5673 |
-
|
| 5674 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5675 |
return false;
|
| 5676 |
-
|
| 5677 |
if ( is_string( $pages ) )
|
| 5678 |
$pages = explode( ',', $pages );
|
| 5679 |
-
|
| 5680 |
return apply_filters( 'ot_meta_box_post_format_audio', array(
|
| 5681 |
'id' => 'ot-post-format-audio',
|
| 5682 |
'title' => __( 'Audio', 'option-tree' ),
|
|
@@ -5710,33 +5710,33 @@ function ot_meta_box_post_format_audio( $pages = 'post' ) {
|
|
| 5710 |
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
|
| 5711 |
|
| 5712 |
function ot_get_option_type_by_id( $option_id, $settings_id = '' ) {
|
| 5713 |
-
|
| 5714 |
if ( empty( $settings_id ) ) {
|
| 5715 |
-
|
| 5716 |
$settings_id = ot_settings_id();
|
| 5717 |
-
|
| 5718 |
}
|
| 5719 |
-
|
| 5720 |
$settings = get_option( $settings_id, array() );
|
| 5721 |
-
|
| 5722 |
if ( isset( $settings['settings'] ) ) {
|
| 5723 |
-
|
| 5724 |
foreach( $settings['settings'] as $value ) {
|
| 5725 |
-
|
| 5726 |
if ( $option_id == $value['id'] && isset( $value['type'] ) ) {
|
| 5727 |
-
|
| 5728 |
return $value['type'];
|
| 5729 |
-
|
| 5730 |
}
|
| 5731 |
-
|
| 5732 |
}
|
| 5733 |
-
|
| 5734 |
}
|
| 5735 |
-
|
| 5736 |
return false;
|
| 5737 |
-
|
| 5738 |
}
|
| 5739 |
-
|
| 5740 |
}
|
| 5741 |
|
| 5742 |
/**
|
|
@@ -5751,7 +5751,7 @@ function _ot_settings_potential_shared_terms() {
|
|
| 5751 |
|
| 5752 |
$options = array();
|
| 5753 |
$settings = get_option( ot_settings_id(), array() );
|
| 5754 |
-
$option_types = array(
|
| 5755 |
'category-checkbox',
|
| 5756 |
'category-select',
|
| 5757 |
'tag-checkbox',
|
|
@@ -5782,7 +5782,7 @@ function _ot_settings_potential_shared_terms() {
|
|
| 5782 |
}
|
| 5783 |
|
| 5784 |
if ( ! empty( $sub_options ) ) {
|
| 5785 |
-
$options[] = array(
|
| 5786 |
'id' => $item['id'],
|
| 5787 |
'taxonomy' => $value['taxonomy'],
|
| 5788 |
'parent' => $value['id'],
|
|
@@ -5798,7 +5798,7 @@ function _ot_settings_potential_shared_terms() {
|
|
| 5798 |
if ( in_array( $value['type'], $option_types ) ) {
|
| 5799 |
$saved = ot_get_option( $value['id'] );
|
| 5800 |
if ( ! empty( $saved ) ) {
|
| 5801 |
-
$options[] = array(
|
| 5802 |
'id' => $value['id'],
|
| 5803 |
'taxonomy' => $value['taxonomy'],
|
| 5804 |
'value' => $saved
|
|
@@ -5829,7 +5829,7 @@ function _ot_meta_box_potential_shared_terms() {
|
|
| 5829 |
|
| 5830 |
$options = array();
|
| 5831 |
$settings = $ot_meta_boxes;
|
| 5832 |
-
$option_types = array(
|
| 5833 |
'category-checkbox',
|
| 5834 |
'category-select',
|
| 5835 |
'tag-checkbox',
|
|
@@ -5859,9 +5859,9 @@ function _ot_meta_box_potential_shared_terms() {
|
|
| 5859 |
}
|
| 5860 |
|
| 5861 |
}
|
| 5862 |
-
|
| 5863 |
if ( ! empty( $children[$value['id']] ) ) {
|
| 5864 |
-
$options[] = array(
|
| 5865 |
'id' => $value['id'],
|
| 5866 |
'children' => $children[$value['id']],
|
| 5867 |
'taxonomy' => $value['taxonomy'],
|
|
@@ -5872,7 +5872,7 @@ function _ot_meta_box_potential_shared_terms() {
|
|
| 5872 |
|
| 5873 |
if ( in_array( $value['type'], $option_types ) ) {
|
| 5874 |
|
| 5875 |
-
$options[] = array(
|
| 5876 |
'id' => $value['id'],
|
| 5877 |
'taxonomy' => $value['taxonomy'],
|
| 5878 |
);
|
|
@@ -5997,7 +5997,7 @@ function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxon
|
|
| 5997 |
|
| 5998 |
// Process the Meta Boxes
|
| 5999 |
$meta_settings = _ot_meta_box_potential_shared_terms();
|
| 6000 |
-
$option_types = array(
|
| 6001 |
'category-checkbox',
|
| 6002 |
'category-select',
|
| 6003 |
'tag-checkbox',
|
|
@@ -6008,13 +6008,13 @@ function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxon
|
|
| 6008 |
|
| 6009 |
if ( ! empty( $meta_settings ) ) {
|
| 6010 |
$old_meta = array();
|
| 6011 |
-
|
| 6012 |
foreach( $meta_settings as $option ) {
|
| 6013 |
|
| 6014 |
if ( ! is_array( $option['taxonomy'] ) ) {
|
| 6015 |
$option['taxonomy'] = explode( ',', $option['taxonomy'] );
|
| 6016 |
}
|
| 6017 |
-
|
| 6018 |
if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) {
|
| 6019 |
continue;
|
| 6020 |
}
|
|
@@ -6074,9 +6074,9 @@ function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxon
|
|
| 6074 |
|
| 6075 |
// Update
|
| 6076 |
if ( $old_meta !== $new_meta ) {
|
| 6077 |
-
|
| 6078 |
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
| 6079 |
-
|
| 6080 |
}
|
| 6081 |
|
| 6082 |
}
|
|
@@ -6131,9 +6131,9 @@ function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxon
|
|
| 6131 |
|
| 6132 |
// Update
|
| 6133 |
if ( $old_meta !== $new_meta ) {
|
| 6134 |
-
|
| 6135 |
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
| 6136 |
-
|
| 6137 |
}
|
| 6138 |
|
| 6139 |
}
|
|
@@ -6152,4 +6152,4 @@ function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxon
|
|
| 6152 |
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
|
| 6153 |
|
| 6154 |
/* End of file ot-functions-admin.php */
|
| 6155 |
-
/* Location: ./includes/ot-functions-admin.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
|
| 24 |
if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
| 25 |
|
| 26 |
function ot_register_theme_options_page() {
|
| 27 |
+
|
| 28 |
/* get the settings array */
|
| 29 |
$get_settings = get_option( ot_settings_id() );
|
| 30 |
+
|
| 31 |
/* sections array */
|
| 32 |
$sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
|
| 33 |
+
|
| 34 |
/* settings array */
|
| 35 |
$settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
|
| 36 |
+
|
| 37 |
/* contexual_help array */
|
| 38 |
$contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
|
| 39 |
+
|
| 40 |
/* build the Theme Options */
|
| 41 |
if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) {
|
| 42 |
+
|
| 43 |
ot_register_settings( array(
|
| 44 |
array(
|
| 45 |
'id' => ot_options_id(),
|
| 46 |
+
'pages' => array(
|
| 47 |
array(
|
| 48 |
'id' => 'niftycs_options',
|
| 49 |
'parent_slug' => apply_filters( 'niftycs_options_parent_slug', null ),
|
| 62 |
)
|
| 63 |
)
|
| 64 |
)
|
| 65 |
+
)
|
| 66 |
);
|
| 67 |
+
|
| 68 |
// Filters the options.php to add the minimum user capabilities.
|
| 69 |
add_filter( 'option_page_capability_' . ot_options_id(), create_function( '$caps', "return '$caps';" ), 999 );
|
| 70 |
+
|
| 71 |
}
|
| 72 |
+
|
| 73 |
}
|
| 74 |
|
| 75 |
}
|
| 88 |
|
| 89 |
function ot_register_settings_page() {
|
| 90 |
global $ot_has_custom_theme_options;
|
| 91 |
+
|
| 92 |
// Display UI Builder admin notice
|
| 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 |
function ot_has_custom_theme_options() {
|
| 96 |
+
|
| 97 |
echo '<div class="error"><p>' . __( '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>';
|
| 98 |
+
|
| 99 |
}
|
| 100 |
+
|
| 101 |
add_action( 'admin_notices', 'ot_has_custom_theme_options' );
|
| 102 |
+
|
| 103 |
}
|
| 104 |
+
|
| 105 |
// Create the filterable pages array
|
| 106 |
+
$ot_register_pages_array = array(
|
| 107 |
+
array(
|
| 108 |
'id' => 'ot',
|
| 109 |
'page_title' => __( 'OptionTree', 'option-tree' ),
|
| 110 |
'menu_title' => __( 'OptionTree', 'option-tree' ),
|
| 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 |
$ot_register_pages_array = apply_filters( 'ot_register_pages_array', $ot_register_pages_array );
|
| 381 |
+
|
| 382 |
// Register the pages.
|
| 383 |
ot_register_settings( array(
|
| 384 |
array(
|
| 387 |
)
|
| 388 |
)
|
| 389 |
);
|
| 390 |
+
|
| 391 |
}
|
| 392 |
|
| 393 |
}
|
| 403 |
if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
|
| 404 |
|
| 405 |
function ot_after_theme_options_save() {
|
| 406 |
+
|
| 407 |
$page = isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '';
|
| 408 |
$updated = isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ? true : false;
|
| 409 |
+
|
| 410 |
/* only execute after the theme options are saved */
|
| 411 |
if ( apply_filters( 'niftycs_options_menu_slug', 'niftycs-options' ) == $page && $updated ) {
|
| 412 |
+
|
| 413 |
/* grab a copy of the theme options */
|
| 414 |
$options = get_option( ot_options_id() );
|
| 415 |
+
|
| 416 |
/* execute the action hook and pass the theme options to it */
|
| 417 |
do_action( 'ot_after_theme_options_save', $options );
|
| 418 |
+
|
| 419 |
}
|
| 420 |
+
|
| 421 |
}
|
| 422 |
|
| 423 |
}
|
| 442 |
if ( ! function_exists( 'ot_validate_setting' ) ) {
|
| 443 |
|
| 444 |
function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
|
| 445 |
+
|
| 446 |
/* exit early if missing data */
|
| 447 |
if ( ! $input || ! $type || ! $field_id )
|
| 448 |
return $input;
|
| 449 |
+
|
| 450 |
$input = apply_filters( 'ot_validate_setting', $input, $type, $field_id );
|
| 451 |
+
|
| 452 |
/* WPML Register and Unregister strings */
|
| 453 |
if ( ! empty( $wmpl_id ) ) {
|
| 454 |
+
|
| 455 |
/* Allow filtering on the WPML option types */
|
| 456 |
$single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) );
|
| 457 |
+
|
| 458 |
if ( in_array( $type, $single_string_types ) ) {
|
| 459 |
+
|
| 460 |
if ( ! empty( $input ) ) {
|
| 461 |
+
|
| 462 |
ot_wpml_register_string( $wmpl_id, $input );
|
| 463 |
+
|
| 464 |
} else {
|
| 465 |
+
|
| 466 |
ot_wpml_unregister_string( $wmpl_id );
|
| 467 |
+
|
| 468 |
}
|
| 469 |
+
|
| 470 |
}
|
| 471 |
+
|
| 472 |
}
|
| 473 |
+
|
| 474 |
if ( 'background' == $type ) {
|
| 475 |
|
| 476 |
$input['background-color'] = ot_validate_setting( $input['background-color'], 'colorpicker', $field_id );
|
| 477 |
+
|
| 478 |
$input['background-image'] = ot_validate_setting( $input['background-image'], 'upload', $field_id );
|
| 479 |
+
|
| 480 |
// Loop over array and check for values
|
| 481 |
foreach( (array) $input as $key => $value ) {
|
| 482 |
if ( ! empty( $value ) ) {
|
| 483 |
$has_value = true;
|
| 484 |
}
|
| 485 |
}
|
| 486 |
+
|
| 487 |
// No value; set to empty
|
| 488 |
if ( ! isset( $has_value ) ) {
|
| 489 |
$input = '';
|
| 490 |
}
|
| 491 |
+
|
| 492 |
} else if ( 'border' == $type ) {
|
| 493 |
+
|
| 494 |
// Loop over array and set errors or unset key from array.
|
| 495 |
foreach( $input as $key => $value ) {
|
| 496 |
+
|
| 497 |
// Validate width
|
| 498 |
if ( $key == 'width' && ! empty( $value ) && ! is_numeric( $value ) ) {
|
| 499 |
+
|
| 500 |
$input[$key] = '0';
|
| 501 |
+
|
| 502 |
add_settings_error( 'option-tree', 'invalid_border_width', sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '<code>width</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
| 503 |
+
|
| 504 |
}
|
| 505 |
+
|
| 506 |
// Validate color
|
| 507 |
if ( $key == 'color' && ! empty( $value ) ) {
|
| 508 |
|
| 509 |
$input[$key] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
| 510 |
+
|
| 511 |
}
|
| 512 |
+
|
| 513 |
// Unset keys with empty values.
|
| 514 |
if ( empty( $value ) && strlen( $value ) == 0 ) {
|
| 515 |
unset( $input[$key] );
|
| 516 |
}
|
| 517 |
+
|
| 518 |
}
|
| 519 |
+
|
| 520 |
if ( empty( $input ) ) {
|
| 521 |
$input = '';
|
| 522 |
}
|
| 523 |
+
|
| 524 |
} else if ( 'box-shadow' == $type ) {
|
| 525 |
+
|
| 526 |
// Validate inset
|
| 527 |
$input['inset'] = isset( $input['inset'] ) ? 'inset' : '';
|
| 528 |
+
|
| 529 |
// Validate offset-x
|
| 530 |
$input['offset-x'] = ot_validate_setting( $input['offset-x'], 'text', $field_id );
|
| 531 |
+
|
| 532 |
// Validate offset-y
|
| 533 |
$input['offset-y'] = ot_validate_setting( $input['offset-y'], 'text', $field_id );
|
| 534 |
+
|
| 535 |
// Validate blur-radius
|
| 536 |
$input['blur-radius'] = ot_validate_setting( $input['blur-radius'], 'text', $field_id );
|
| 537 |
+
|
| 538 |
// Validate spread-radius
|
| 539 |
$input['spread-radius'] = ot_validate_setting( $input['spread-radius'], 'text', $field_id );
|
| 540 |
+
|
| 541 |
// Validate color
|
| 542 |
$input['color'] = ot_validate_setting( $input['color'], 'colorpicker', $field_id );
|
| 543 |
+
|
| 544 |
// Unset keys with empty values.
|
| 545 |
foreach( $input as $key => $value ) {
|
| 546 |
if ( empty( $value ) && strlen( $value ) == 0 ) {
|
| 547 |
unset( $input[$key] );
|
| 548 |
}
|
| 549 |
}
|
| 550 |
+
|
| 551 |
// Set empty array to empty string.
|
| 552 |
if ( empty( $input ) ) {
|
| 553 |
$input = '';
|
| 554 |
}
|
| 555 |
+
|
| 556 |
} else if ( 'colorpicker' == $type ) {
|
| 557 |
|
| 558 |
/* return empty & set error */
|
| 559 |
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 ) ) {
|
| 560 |
+
|
| 561 |
$input = '';
|
| 562 |
+
|
| 563 |
add_settings_error( 'option-tree', 'invalid_hex', sprintf( __( 'The %s Colorpicker only allows valid hexadecimal or rgba values.', 'option-tree' ), '<code>' . $field_id . '</code>' ), 'error' );
|
| 564 |
+
|
| 565 |
}
|
| 566 |
+
|
| 567 |
} else if ( 'colorpicker-opacity' == $type ) {
|
| 568 |
|
| 569 |
// Not allowed
|
| 575 |
$input = ot_validate_setting( $input, 'colorpicker', $field_id );
|
| 576 |
|
| 577 |
} else if ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ) ) ) {
|
| 578 |
+
|
| 579 |
if ( ! current_user_can( 'unfiltered_html' ) && OT_ALLOW_UNFILTERED_HTML == false ) {
|
| 580 |
+
|
| 581 |
$input = wp_kses_post( $input );
|
| 582 |
+
|
| 583 |
}
|
| 584 |
+
|
| 585 |
} else if ( 'dimension' == $type ) {
|
| 586 |
+
|
| 587 |
// Loop over array and set error keys or unset key from array.
|
| 588 |
foreach( $input as $key => $value ) {
|
| 589 |
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
|
| 596 |
|
| 597 |
/* return 0 & set error */
|
| 598 |
if ( isset( $errors ) ) {
|
| 599 |
+
|
| 600 |
foreach( $errors as $error ) {
|
| 601 |
+
|
| 602 |
$input[$error] = '0';
|
| 603 |
+
|
| 604 |
add_settings_error( 'option-tree', 'invalid_dimension_' . $error, sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '<code>' . $error . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
| 605 |
+
|
| 606 |
}
|
| 607 |
+
|
| 608 |
}
|
| 609 |
+
|
| 610 |
if ( empty( $input ) ) {
|
| 611 |
$input = '';
|
| 612 |
}
|
| 613 |
+
|
| 614 |
} else if ( 'google-fonts' == $type ) {
|
| 615 |
+
|
| 616 |
unset($input['%key%']);
|
| 617 |
+
|
| 618 |
// Loop over array and check for values
|
| 619 |
if ( is_array( $input ) && ! empty( $input ) ) {
|
| 620 |
$input = array_values( $input );
|
| 624 |
if ( empty( $input ) ) {
|
| 625 |
$input = '';
|
| 626 |
}
|
| 627 |
+
|
| 628 |
} else if ( 'link-color' == $type ) {
|
| 629 |
+
|
| 630 |
// Loop over array and check for values
|
| 631 |
if ( is_array( $input ) && ! empty( $input ) ) {
|
| 632 |
foreach( $input as $key => $value ) {
|
| 636 |
}
|
| 637 |
}
|
| 638 |
}
|
| 639 |
+
|
| 640 |
// No value; set to empty
|
| 641 |
if ( ! isset( $has_value ) ) {
|
| 642 |
$input = '';
|
| 643 |
}
|
| 644 |
+
|
| 645 |
} else if ( 'measurement' == $type ) {
|
| 646 |
+
|
| 647 |
$input[0] = sanitize_text_field( $input[0] );
|
| 648 |
+
|
| 649 |
// No value; set to empty
|
| 650 |
if ( empty( $input[0] ) && strlen( $input[0] ) == 0 && empty( $input[1] ) ) {
|
| 651 |
$input = '';
|
| 652 |
}
|
| 653 |
+
|
| 654 |
} else if ( 'spacing' == $type ) {
|
| 655 |
+
|
| 656 |
// Loop over array and set error keys or unset key from array.
|
| 657 |
foreach( $input as $key => $value ) {
|
| 658 |
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
|
| 665 |
|
| 666 |
/* return 0 & set error */
|
| 667 |
if ( isset( $errors ) ) {
|
| 668 |
+
|
| 669 |
foreach( $errors as $error ) {
|
| 670 |
+
|
| 671 |
$input[$error] = '0';
|
| 672 |
+
|
| 673 |
add_settings_error( 'option-tree', 'invalid_spacing_' . $error, sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '<code>' . $error . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
| 674 |
+
|
| 675 |
}
|
| 676 |
+
|
| 677 |
}
|
| 678 |
+
|
| 679 |
if ( empty( $input ) ) {
|
| 680 |
$input = '';
|
| 681 |
}
|
| 682 |
+
|
| 683 |
} else if ( 'typography' == $type && isset( $input['font-color'] ) ) {
|
| 684 |
+
|
| 685 |
$input['font-color'] = ot_validate_setting( $input['font-color'], 'colorpicker', $field_id );
|
| 686 |
+
|
| 687 |
// Loop over array and check for values
|
| 688 |
foreach( $input as $key => $value ) {
|
| 689 |
if ( ! empty( $value ) ) {
|
| 690 |
$has_value = true;
|
| 691 |
}
|
| 692 |
}
|
| 693 |
+
|
| 694 |
// No value; set to empty
|
| 695 |
if ( ! isset( $has_value ) ) {
|
| 696 |
$input = '';
|
| 697 |
}
|
| 698 |
+
|
| 699 |
} else if ( 'upload' == $type ) {
|
| 700 |
|
| 701 |
if( filter_var( $input, FILTER_VALIDATE_INT ) === FALSE ) {
|
| 702 |
$input = esc_url_raw( $input );
|
| 703 |
}
|
| 704 |
+
|
| 705 |
} else if ( 'gallery' == $type ) {
|
| 706 |
|
| 707 |
$input = trim( $input );
|
| 708 |
+
|
| 709 |
} else if ( 'social-links' == $type ) {
|
| 710 |
+
|
| 711 |
// Loop over array and check for values, plus sanitize the text field
|
| 712 |
foreach( (array) $input as $key => $value ) {
|
| 713 |
if ( ! empty( $value ) && is_array( $value ) ) {
|
| 719 |
}
|
| 720 |
}
|
| 721 |
}
|
| 722 |
+
|
| 723 |
// No value; set to empty
|
| 724 |
if ( ! isset( $has_value ) ) {
|
| 725 |
$input = '';
|
| 726 |
}
|
| 727 |
+
|
| 728 |
}
|
| 729 |
+
|
| 730 |
$input = apply_filters( 'ot_after_validate_setting', $input, $type, $field_id );
|
| 731 |
+
|
| 732 |
return $input;
|
| 733 |
+
|
| 734 |
}
|
| 735 |
|
| 736 |
}
|
| 747 |
|
| 748 |
function ot_admin_styles() {
|
| 749 |
global $wp_styles, $post;
|
| 750 |
+
|
| 751 |
/* execute styles before actions */
|
| 752 |
do_action( 'ot_admin_styles_before' );
|
| 753 |
+
|
| 754 |
/* load WP colorpicker */
|
| 755 |
wp_enqueue_style( 'wp-color-picker' );
|
| 756 |
+
|
| 757 |
wp_enqueue_style('wp-jquery-ui-dialog');
|
| 758 |
+
|
| 759 |
/* load admin styles */
|
| 760 |
wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION );
|
| 761 |
+
|
| 762 |
/* load the RTL stylesheet */
|
| 763 |
$wp_styles->add_data( 'ot-admin-css','rtl', true );
|
| 764 |
+
|
| 765 |
/* Remove styles added by the Easy Digital Downloads plugin */
|
| 766 |
if ( isset( $post->post_type ) && $post->post_type == 'post' )
|
| 767 |
wp_dequeue_style( 'jquery-ui-css' );
|
| 773 |
*
|
| 774 |
* @param array $screen_ids An array of screen IDs.
|
| 775 |
*/
|
| 776 |
+
$screen_ids = apply_filters( 'ot_dequeue_jquery_ui_css_screen_ids', array(
|
| 777 |
+
'toplevel_page_ot-settings',
|
| 778 |
+
'optiontree_page_ot-documentation',
|
| 779 |
+
'appearance_page_niftycs-options'
|
| 780 |
) );
|
| 781 |
+
|
| 782 |
/* Remove styles added by the WP Review plugin and any custom pages added through filtering */
|
| 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 |
/* execute styles after actions */
|
| 789 |
do_action( 'ot_admin_styles_after' );
|
| 790 |
|
| 791 |
}
|
| 792 |
+
|
| 793 |
}
|
| 794 |
|
| 795 |
/**
|
| 807 |
if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
| 808 |
|
| 809 |
function ot_admin_scripts() {
|
| 810 |
+
|
| 811 |
/* execute scripts before actions */
|
| 812 |
do_action( 'ot_admin_scripts_before' );
|
| 813 |
+
|
| 814 |
if ( function_exists( 'wp_enqueue_media' ) ) {
|
| 815 |
/* WP 3.5 Media Uploader */
|
| 816 |
wp_enqueue_media();
|
| 829 |
wp_enqueue_script( 'wp-color-picker' );
|
| 830 |
|
| 831 |
/* load Ace Editor for CSS Editing */
|
| 832 |
+
wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js', null, '1.1.3' );
|
| 833 |
|
| 834 |
/* load jQuery UI timepicker addon */
|
| 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' );
|
| 841 |
|
| 842 |
|
| 843 |
/* load all the required scripts */
|
| 844 |
+
|
| 845 |
wp_enqueue_script('jquery-ui-dialog');
|
| 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 |
/* create localized JS array */
|
| 853 |
+
$localized_array = array(
|
| 854 |
'ajax' => admin_url( 'admin-ajax.php' ),
|
| 855 |
'nonce' => wp_create_nonce( 'option_tree' ),
|
| 856 |
'upload_text' => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ),
|
| 860 |
'remove_agree' => __( 'Are you sure you want to remove this?', 'option-tree' ),
|
| 861 |
'activate_layout_agree' => __( 'Are you sure you want to activate this layout?', 'option-tree' ),
|
| 862 |
'setting_limit' => __( 'Sorry, you can\'t have settings three levels deep.', 'option-tree' ),
|
| 863 |
+
'delete' => __( 'Delete Gallery', 'option-tree' ),
|
| 864 |
+
'edit' => __( 'Edit Gallery', 'option-tree' ),
|
| 865 |
+
'create' => __( 'Create Gallery', 'option-tree' ),
|
| 866 |
'confirm' => __( 'Are you sure you want to delete this Gallery?', 'option-tree' ),
|
| 867 |
'date_current' => __( 'Today', 'option-tree' ),
|
| 868 |
'date_time_current' => __( 'Now', 'option-tree' ),
|
| 872 |
'weforms_dialog_upsell_title' => '<img alt="' . __('weForms', 'option-tree') . '" title="' . __('weForms', 'option-tree') . '" src="' . OT_URL . '/assets/images/weforms-logo-white.png' . '">',
|
| 873 |
'weforms_install_url' => add_query_arg(array('action' => 'install_weforms'), admin_url('admin.php')),
|
| 874 |
);
|
| 875 |
+
|
| 876 |
/* localized script attached to 'option_tree' */
|
| 877 |
wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array );
|
| 878 |
+
|
| 879 |
/* execute scripts after actions */
|
| 880 |
do_action( 'ot_admin_scripts_after' );
|
| 881 |
|
| 882 |
}
|
| 883 |
+
|
| 884 |
}
|
| 885 |
|
| 886 |
/**
|
| 896 |
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
|
| 897 |
|
| 898 |
function ot_get_media_post_ID() {
|
| 899 |
+
|
| 900 |
// Option ID
|
| 901 |
$option_id = 'ot_media_post_ID';
|
| 902 |
+
|
| 903 |
// Get the media post ID
|
| 904 |
$post_ID = get_option( $option_id, false );
|
| 905 |
+
|
| 906 |
// Add $post_ID to the DB
|
| 907 |
if ( $post_ID === false || empty( $post_ID ) ) {
|
| 908 |
global $wpdb;
|
| 909 |
+
|
| 910 |
// Get the media post ID
|
| 911 |
$post_ID = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE `post_title` = 'Media' AND `post_type` = 'option-tree' AND `post_status` = 'private'" );
|
| 912 |
+
|
| 913 |
// Add to the DB
|
| 914 |
if ( $post_ID !== null )
|
| 915 |
update_option( $option_id, $post_ID );
|
| 916 |
|
| 917 |
}
|
| 918 |
+
|
| 919 |
return $post_ID;
|
| 920 |
+
|
| 921 |
}
|
| 922 |
|
| 923 |
}
|
| 933 |
* @since 2.0
|
| 934 |
*/
|
| 935 |
if ( ! function_exists( 'ot_create_media_post' ) ) {
|
| 936 |
+
|
| 937 |
function ot_create_media_post() {
|
| 938 |
+
|
| 939 |
$regsiter_post_type = 'register_' . 'post_type';
|
| 940 |
$regsiter_post_type( 'option-tree', array(
|
| 941 |
'labels' => array( 'name' => __( 'Nifty options', 'option-tree' ) ),
|
| 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';
|
| 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 |
}
|
| 986 |
|
| 987 |
function ot_default_settings() {
|
| 988 |
global $wpdb;
|
| 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;
|
| 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' ) ) ) {
|
| 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' ) ) ) {
|
| 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' ) ) ) {
|
| 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 ) {
|
| 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(
|
| 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 |
}
|
| 1143 |
if ( ! function_exists( 'ot_save_css' ) ) {
|
| 1144 |
|
| 1145 |
function ot_save_css( $options ) {
|
| 1146 |
+
|
| 1147 |
/* grab a copy of the settings */
|
| 1148 |
$settings = get_option( ot_settings_id() );
|
| 1149 |
+
|
| 1150 |
/* has settings */
|
| 1151 |
if ( isset( $settings['settings'] ) ) {
|
| 1152 |
+
|
| 1153 |
/* loop through sections and insert CSS when needed */
|
| 1154 |
foreach( $settings['settings'] as $k => $setting ) {
|
| 1155 |
+
|
| 1156 |
/* is the CSS option type */
|
| 1157 |
if ( isset( $setting['type'] ) && 'css' == $setting['type'] ) {
|
| 1158 |
|
| 1159 |
/* insert CSS into dynamic.css */
|
| 1160 |
if ( isset( $options[$setting['id']] ) && '' !== $options[$setting['id']] ) {
|
| 1161 |
+
|
| 1162 |
ot_insert_css_with_markers( $setting['id'], $options[$setting['id']] );
|
| 1163 |
+
|
| 1164 |
/* remove old CSS from dynamic.css */
|
| 1165 |
} else {
|
| 1166 |
+
|
| 1167 |
ot_remove_old_css( $setting['id'] );
|
| 1168 |
+
|
| 1169 |
}
|
| 1170 |
+
|
| 1171 |
}
|
| 1172 |
+
|
| 1173 |
}
|
| 1174 |
+
|
| 1175 |
}
|
| 1176 |
+
|
| 1177 |
}
|
| 1178 |
|
| 1179 |
}
|
| 1180 |
+
|
| 1181 |
/**
|
| 1182 |
* Helper function to load filters for XML mime type.
|
| 1183 |
*
|
| 1189 |
if ( ! function_exists( 'ot_add_xml_to_upload_filetypes' ) ) {
|
| 1190 |
|
| 1191 |
function ot_add_xml_to_upload_filetypes() {
|
| 1192 |
+
|
| 1193 |
add_filter( 'upload_mimes', 'ot_upload_mimes' );
|
| 1194 |
add_filter( 'wp_mime_type_icon', 'ot_xml_mime_type_icon', 10, 2 );
|
| 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
|
| 1209 |
if ( ! function_exists( 'ot_upload_mimes' ) ) {
|
| 1210 |
|
| 1211 |
function ot_upload_mimes( $mimes ) {
|
| 1212 |
+
|
| 1213 |
$mimes['xml'] = 'application/xml';
|
| 1214 |
+
|
| 1215 |
return $mimes;
|
| 1216 |
+
|
| 1217 |
}
|
| 1218 |
|
| 1219 |
}
|
| 1231 |
if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) {
|
| 1232 |
|
| 1233 |
function ot_xml_mime_type_icon( $icon, $mime ) {
|
| 1234 |
+
|
| 1235 |
if ( $mime == 'application/xml' || $mime == 'text/xml' )
|
| 1236 |
return wp_mime_type_icon( 'document' );
|
| 1237 |
+
|
| 1238 |
return $icon;
|
| 1239 |
+
|
| 1240 |
}
|
| 1241 |
|
| 1242 |
}
|
| 1252 |
if ( ! function_exists( 'ot_import' ) ) {
|
| 1253 |
|
| 1254 |
function ot_import() {
|
| 1255 |
+
|
| 1256 |
/* check and verify import xml nonce */
|
| 1257 |
if ( isset( $_POST['import_xml_nonce'] ) && wp_verify_nonce( $_POST['import_xml_nonce'], 'import_xml_form' ) ) {
|
| 1258 |
|
| 1259 |
/* import input value */
|
| 1260 |
$file = isset( $_POST['import_xml'] ) ? esc_url( $_POST['import_xml'] ) : '';
|
| 1261 |
+
|
| 1262 |
/* validate xml file */
|
| 1263 |
if ( preg_match( "/(.xml)$/i", $file ) && class_exists( 'SimpleXMLElement' ) ) {
|
| 1264 |
+
|
| 1265 |
$settings = ot_import_xml( $file );
|
| 1266 |
+
|
| 1267 |
}
|
| 1268 |
+
|
| 1269 |
/* default message */
|
| 1270 |
$message = 'failed';
|
| 1271 |
+
|
| 1272 |
/* cleanup, save, & show success message */
|
| 1273 |
if ( isset( $settings ) && ! empty( $settings ) ) {
|
| 1274 |
+
|
| 1275 |
/* delete file */
|
| 1276 |
if ( $file ) {
|
| 1277 |
global $wpdb;
|
| 1278 |
$attachmentid = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$file'" );
|
| 1279 |
wp_delete_attachment( $attachmentid, true );
|
| 1280 |
}
|
| 1281 |
+
|
| 1282 |
/* update settings */
|
| 1283 |
update_option( ot_settings_id(), $settings );
|
| 1284 |
+
|
| 1285 |
/* set message */
|
| 1286 |
$message = 'success';
|
| 1287 |
+
|
| 1288 |
}
|
| 1289 |
+
|
| 1290 |
/* redirect */
|
| 1291 |
+
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-xml', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
| 1292 |
exit;
|
| 1293 |
+
|
| 1294 |
}
|
| 1295 |
+
|
| 1296 |
/* check and verify import settings nonce */
|
| 1297 |
if ( isset( $_POST['import_settings_nonce'] ) && wp_verify_nonce( $_POST['import_settings_nonce'], 'import_settings_form' ) ) {
|
| 1298 |
|
| 1299 |
/* textarea value */
|
| 1300 |
$textarea = isset( $_POST['import_settings'] ) ? unserialize( ot_decode( $_POST['import_settings'] ) ) : '';
|
| 1301 |
+
|
| 1302 |
/* default message */
|
| 1303 |
$message = 'failed';
|
| 1304 |
+
|
| 1305 |
/* is array: save & show success message */
|
| 1306 |
if ( is_array( $textarea ) ) {
|
| 1307 |
update_option( ot_settings_id(), $textarea );
|
| 1308 |
$message = 'success';
|
| 1309 |
}
|
| 1310 |
+
|
| 1311 |
/* redirect */
|
| 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 |
/* check and verify import theme options data nonce */
|
| 1318 |
if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) {
|
| 1319 |
+
|
| 1320 |
/* default message */
|
| 1321 |
$message = 'failed';
|
| 1322 |
+
|
| 1323 |
/* textarea value */
|
| 1324 |
$options = isset( $_POST['import_data'] ) ? unserialize( ot_decode( $_POST['import_data'] ) ) : '';
|
| 1325 |
+
|
| 1326 |
/* get settings array */
|
| 1327 |
$settings = get_option( ot_settings_id() );
|
| 1328 |
+
|
| 1329 |
/* has options */
|
| 1330 |
if ( is_array( $options ) ) {
|
| 1331 |
+
|
| 1332 |
/* validate options */
|
| 1333 |
if ( is_array( $settings ) ) {
|
| 1334 |
+
|
| 1335 |
foreach( $settings['settings'] as $setting ) {
|
| 1336 |
+
|
| 1337 |
if ( isset( $options[$setting['id']] ) ) {
|
| 1338 |
+
|
| 1339 |
$content = ot_stripslashes( $options[$setting['id']] );
|
| 1340 |
+
|
| 1341 |
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
| 1342 |
+
|
| 1343 |
}
|
| 1344 |
+
|
| 1345 |
}
|
| 1346 |
+
|
| 1347 |
}
|
| 1348 |
+
|
| 1349 |
/* execute the action hook and pass the theme options to it */
|
| 1350 |
do_action( 'ot_before_theme_options_save', $options );
|
| 1351 |
+
|
| 1352 |
/* update the option tree array */
|
| 1353 |
update_option( ot_options_id(), $options );
|
| 1354 |
+
|
| 1355 |
$message = 'success';
|
| 1356 |
+
|
| 1357 |
}
|
| 1358 |
+
|
| 1359 |
/* redirect accordingly */
|
| 1360 |
+
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-data', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
| 1361 |
exit;
|
| 1362 |
+
|
| 1363 |
}
|
| 1364 |
+
|
| 1365 |
/* check and verify import layouts nonce */
|
| 1366 |
if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) {
|
| 1367 |
+
|
| 1368 |
/* default message */
|
| 1369 |
$message = 'failed';
|
| 1370 |
+
|
| 1371 |
/* textarea value */
|
| 1372 |
$layouts = isset( $_POST['import_layouts'] ) ? unserialize( ot_decode( $_POST['import_layouts'] ) ) : '';
|
| 1373 |
+
|
| 1374 |
/* get settings array */
|
| 1375 |
$settings = get_option( ot_settings_id() );
|
| 1376 |
+
|
| 1377 |
/* has layouts */
|
| 1378 |
if ( is_array( $layouts ) ) {
|
| 1379 |
+
|
| 1380 |
/* validate options */
|
| 1381 |
if ( is_array( $settings ) ) {
|
| 1382 |
+
|
| 1383 |
foreach( $layouts as $key => $value ) {
|
| 1384 |
+
|
| 1385 |
if ( $key == 'active_layout' )
|
| 1386 |
continue;
|
| 1387 |
+
|
| 1388 |
$options = unserialize( ot_decode( $value ) );
|
| 1389 |
+
|
| 1390 |
foreach( $settings['settings'] as $setting ) {
|
| 1391 |
|
| 1392 |
if ( isset( $options[$setting['id']] ) ) {
|
| 1393 |
+
|
| 1394 |
$content = ot_stripslashes( $options[$setting['id']] );
|
| 1395 |
+
|
| 1396 |
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
| 1397 |
+
|
| 1398 |
}
|
| 1399 |
+
|
| 1400 |
}
|
| 1401 |
|
| 1402 |
$layouts[$key] = ot_encode( serialize( $options ) );
|
| 1403 |
+
|
| 1404 |
}
|
| 1405 |
+
|
| 1406 |
}
|
| 1407 |
+
|
| 1408 |
/* update the option tree array */
|
| 1409 |
if ( isset( $layouts['active_layout'] ) ) {
|
| 1410 |
+
|
| 1411 |
$new_options = unserialize( ot_decode( $layouts[$layouts['active_layout']] ) );
|
| 1412 |
+
|
| 1413 |
/* execute the action hook and pass the theme options to it */
|
| 1414 |
do_action( 'ot_before_theme_options_save', $new_options );
|
| 1415 |
+
|
| 1416 |
update_option( ot_options_id(), $new_options );
|
| 1417 |
+
|
| 1418 |
}
|
| 1419 |
+
|
| 1420 |
/* update the option tree layouts array */
|
| 1421 |
update_option( ot_layouts_id(), $layouts );
|
| 1422 |
+
|
| 1423 |
$message = 'success';
|
| 1424 |
+
|
| 1425 |
}
|
| 1426 |
+
|
| 1427 |
/* redirect accordingly */
|
| 1428 |
+
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
| 1429 |
exit;
|
| 1430 |
+
|
| 1431 |
}
|
| 1432 |
+
|
| 1433 |
return false;
|
| 1434 |
|
| 1435 |
}
|
| 1436 |
+
|
| 1437 |
}
|
| 1438 |
|
| 1439 |
/**
|
| 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 |
/**
|
| 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;
|
| 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' ) ) ) {
|
| 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' ) ) ) {
|
| 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' ) ) ) {
|
| 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 ) {
|
| 1559 |
}
|
| 1560 |
}
|
| 1561 |
}
|
| 1562 |
+
|
| 1563 |
return $settings;
|
| 1564 |
+
|
| 1565 |
}
|
| 1566 |
+
|
| 1567 |
return false;
|
| 1568 |
}
|
| 1569 |
|
| 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'] ) ) {
|
| 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 = '';
|
| 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 ) {
|
| 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 ) {
|
| 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 ) {
|
| 1693 |
'choices' => array( $choices
|
| 1694 |
)";
|
| 1695 |
}
|
| 1696 |
+
|
| 1697 |
$std = "'$_std'";
|
| 1698 |
if ( is_array( $_std ) ) {
|
| 1699 |
$std_array = 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 ) {
|
| 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 ) {
|
| 1739 |
'choices' => array( $setting_choices
|
| 1740 |
)";
|
| 1741 |
}
|
| 1742 |
+
|
| 1743 |
$setting_std = "'$_setting_std'";
|
| 1744 |
if ( is_array( $_setting_std ) ) {
|
| 1745 |
$setting_std_array = array();
|
| 1750 |
' . implode( ",\n", $setting_std_array ) . '
|
| 1751 |
)';
|
| 1752 |
}
|
| 1753 |
+
|
| 1754 |
$setting_settings.= "
|
| 1755 |
array(
|
| 1756 |
'id' => '$_setting_id',
|
| 1772 |
'settings' => array( $setting_settings
|
| 1773 |
)";
|
| 1774 |
}
|
| 1775 |
+
|
| 1776 |
$settings.= "
|
| 1777 |
array(
|
| 1778 |
'id' => '$_id',
|
| 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.
|
| 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;
|
| 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 |
|
| 2073 |
Swift_Performance_Cache::clear_all_cache();
|
| 2074 |
}
|
| 2075 |
}
|
| 2076 |
+
|
| 2077 |
/* redirect */
|
| 2078 |
+
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'action' => 'save-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
| 2079 |
exit;
|
| 2080 |
+
|
| 2081 |
}
|
| 2082 |
+
|
| 2083 |
return false;
|
| 2084 |
|
| 2085 |
}
|
| 2086 |
+
|
| 2087 |
}
|
| 2088 |
|
| 2089 |
/**
|
| 2090 |
* Validate the settings array before save.
|
| 2091 |
*
|
| 2092 |
+
* This function will loop over the settings array as many
|
| 2093 |
* times as it takes to validate every sub setting.
|
| 2094 |
*
|
| 2095 |
* @param array $settings The array of settings.
|
| 2101 |
if ( ! function_exists( 'ot_validate_settings_array' ) ) {
|
| 2102 |
|
| 2103 |
function ot_validate_settings_array( $settings = array() ) {
|
| 2104 |
+
|
| 2105 |
/* validate settings */
|
| 2106 |
if ( count( $settings ) > 0 ) {
|
| 2107 |
+
|
| 2108 |
/* fix numeric keys since drag & drop will change them */
|
| 2109 |
$settings = array_values( $settings );
|
| 2110 |
+
|
| 2111 |
/* loop through settings */
|
| 2112 |
foreach( $settings as $k => $setting ) {
|
| 2113 |
+
|
| 2114 |
+
|
| 2115 |
/* remove from array if missing values */
|
| 2116 |
if ( ( ! isset( $setting['label'] ) && ! isset( $setting['id'] ) ) || ( '' == $setting['label'] && '' == $setting['id'] ) ) {
|
| 2117 |
+
|
| 2118 |
unset( $settings[$k] );
|
| 2119 |
+
|
| 2120 |
} else {
|
| 2121 |
+
|
| 2122 |
/* validate label */
|
| 2123 |
if ( '' != $setting['label'] ) {
|
| 2124 |
+
|
| 2125 |
$settings[$k]['label'] = wp_kses_post( $setting['label'] );
|
| 2126 |
+
|
| 2127 |
}
|
| 2128 |
+
|
| 2129 |
/* missing label set to unfiltered ID */
|
| 2130 |
if ( ! isset( $setting['label'] ) || '' == $setting['label'] ) {
|
| 2131 |
+
|
| 2132 |
$settings[$k]['label'] = $setting['id'];
|
| 2133 |
+
|
| 2134 |
+
/* missing ID set to label */
|
| 2135 |
} else if ( ! isset( $setting['id'] ) || '' == $setting['id'] ) {
|
| 2136 |
+
|
| 2137 |
$setting['id'] = wp_kses_post( $setting['label'] );
|
| 2138 |
+
|
| 2139 |
}
|
| 2140 |
+
|
| 2141 |
/* sanitize ID once everything has been checked first */
|
| 2142 |
$settings[$k]['id'] = ot_sanitize_option_id( wp_kses_post( $setting['id'] ) );
|
| 2143 |
+
|
| 2144 |
}
|
| 2145 |
+
|
| 2146 |
/* validate description */
|
| 2147 |
if ( '' != $setting['desc'] ) {
|
| 2148 |
+
|
| 2149 |
$settings[$k]['desc'] = wp_kses_post( $setting['desc'] );
|
| 2150 |
+
|
| 2151 |
}
|
| 2152 |
+
|
| 2153 |
/* validate choices */
|
| 2154 |
if ( isset( $setting['choices'] ) ) {
|
| 2155 |
+
|
| 2156 |
/* loop through choices */
|
| 2157 |
foreach( $setting['choices'] as $ck => $choice ) {
|
| 2158 |
+
|
| 2159 |
/* remove from array if missing values */
|
| 2160 |
if ( ( ! isset( $choice['label'] ) && ! isset( $choice['value'] ) ) || ( '' == $choice['label'] && '' == $choice['value'] ) ) {
|
| 2161 |
+
|
| 2162 |
unset( $setting['choices'][$ck] );
|
| 2163 |
+
|
| 2164 |
} else {
|
| 2165 |
+
|
| 2166 |
/* missing label set to unfiltered ID */
|
| 2167 |
if ( ! isset( $choice['label'] ) || '' == $choice['label'] ) {
|
| 2168 |
+
|
| 2169 |
$setting['choices'][$ck]['label'] = wp_kses_post( $choice['value'] );
|
| 2170 |
+
|
| 2171 |
+
/* missing value set to label */
|
| 2172 |
} else if ( ! isset( $choice['value'] ) || '' == $choice['value'] ) {
|
| 2173 |
+
|
| 2174 |
$setting['choices'][$ck]['value'] = ot_sanitize_option_id( wp_kses_post( $choice['label'] ) );
|
| 2175 |
+
|
| 2176 |
}
|
| 2177 |
+
|
| 2178 |
}
|
| 2179 |
+
|
| 2180 |
}
|
| 2181 |
+
|
| 2182 |
/* update keys and push new array values */
|
| 2183 |
$settings[$k]['choices'] = array_values( $setting['choices'] );
|
| 2184 |
+
|
| 2185 |
}
|
| 2186 |
+
|
| 2187 |
/* validate sub settings */
|
| 2188 |
if ( isset( $setting['settings'] ) ) {
|
| 2189 |
|
| 2190 |
$settings[$k]['settings'] = ot_validate_settings_array( $setting['settings'] );
|
| 2191 |
+
|
| 2192 |
}
|
| 2193 |
|
| 2194 |
}
|
| 2195 |
+
|
| 2196 |
}
|
| 2197 |
+
|
| 2198 |
/* return array but strip those damn slashes out first!!! */
|
| 2199 |
return ot_stripslashes( $settings );
|
| 2200 |
+
|
| 2201 |
}
|
| 2202 |
|
| 2203 |
}
|
| 2216 |
|
| 2217 |
/* check and verify modify layouts nonce */
|
| 2218 |
if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) {
|
| 2219 |
+
|
| 2220 |
/* previous layouts value */
|
| 2221 |
$option_tree_layouts = get_option( ot_layouts_id() );
|
| 2222 |
+
|
| 2223 |
/* new layouts value */
|
| 2224 |
$layouts = isset( $_POST[ot_layouts_id()] ) ? $_POST[ot_layouts_id()] : '';
|
| 2225 |
+
|
| 2226 |
/* rebuild layout array */
|
| 2227 |
$rebuild = array();
|
| 2228 |
+
|
| 2229 |
/* validate layouts */
|
| 2230 |
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
| 2231 |
+
|
| 2232 |
/* setup active layout */
|
| 2233 |
if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
|
| 2234 |
$rebuild['active_layout'] = $layouts['active_layout'];
|
| 2235 |
}
|
| 2236 |
+
|
| 2237 |
/* add new and overwrite active layout */
|
| 2238 |
if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
|
| 2239 |
$rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] );
|
| 2240 |
$rebuild[$rebuild['active_layout']] = ot_encode( serialize( get_option( ot_options_id() ) ) );
|
| 2241 |
}
|
| 2242 |
+
|
| 2243 |
$first_layout = '';
|
| 2244 |
+
|
| 2245 |
/* loop through layouts */
|
| 2246 |
foreach( $layouts as $key => $layout ) {
|
| 2247 |
+
|
| 2248 |
/* skip over active layout key */
|
| 2249 |
if ( $key == 'active_layout' )
|
| 2250 |
continue;
|
| 2251 |
+
|
| 2252 |
/* check if the key exists then set value */
|
| 2253 |
if ( isset( $option_tree_layouts[$key] ) && ! empty( $option_tree_layouts[$key] ) ) {
|
| 2254 |
$rebuild[$key] = $option_tree_layouts[$key];
|
| 2256 |
$first_layout = $key;
|
| 2257 |
}
|
| 2258 |
}
|
| 2259 |
+
|
| 2260 |
}
|
| 2261 |
+
|
| 2262 |
if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[$rebuild['active_layout']] ) && ! empty( $first_layout ) ) {
|
| 2263 |
$rebuild['active_layout'] = $first_layout;
|
| 2264 |
}
|
| 2265 |
+
|
| 2266 |
}
|
| 2267 |
+
|
| 2268 |
/* default message */
|
| 2269 |
$message = 'failed';
|
| 2270 |
+
|
| 2271 |
/* is array: save & show success message */
|
| 2272 |
if ( count( $rebuild ) > 1 ) {
|
| 2273 |
|
| 2274 |
/* rebuild the theme options */
|
| 2275 |
$rebuild_option_tree = unserialize( ot_decode( $rebuild[$rebuild['active_layout']] ) );
|
| 2276 |
if ( is_array( $rebuild_option_tree ) ) {
|
| 2277 |
+
|
| 2278 |
/* execute the action hook and pass the theme options to it */
|
| 2279 |
do_action( 'ot_before_theme_options_save', $rebuild_option_tree );
|
| 2280 |
+
|
| 2281 |
update_option( ot_options_id(), $rebuild_option_tree );
|
| 2282 |
+
|
| 2283 |
}
|
| 2284 |
+
|
| 2285 |
/* rebuild the layouts */
|
| 2286 |
update_option( ot_layouts_id(), $rebuild );
|
| 2287 |
+
|
| 2288 |
/* change message */
|
| 2289 |
$message = 'success';
|
| 2290 |
+
|
| 2291 |
} else if ( count( $rebuild ) <= 1 ) {
|
| 2292 |
|
| 2293 |
/* delete layouts option */
|
| 2294 |
delete_option( ot_layouts_id() );
|
| 2295 |
+
|
| 2296 |
/* change message */
|
| 2297 |
$message = 'deleted';
|
| 2298 |
+
|
| 2299 |
}
|
| 2300 |
+
|
| 2301 |
/* redirect */
|
| 2302 |
if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == apply_filters( 'niftycs_options_menu_slug', 'niftycs-options' ) ) {
|
| 2303 |
$query_args = esc_url_raw( add_query_arg( array( 'settings-updated' => 'layout' ), remove_query_arg( array( 'action', 'message' ), $_POST['_wp_http_referer'] ) ) );
|
| 2304 |
} else {
|
| 2305 |
$query_args = esc_url_raw( add_query_arg( array( 'action' => 'save-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) );
|
| 2306 |
}
|
| 2307 |
+
wp_safe_redirect( $query_args );
|
| 2308 |
exit;
|
| 2309 |
+
|
| 2310 |
}
|
| 2311 |
+
|
| 2312 |
return false;
|
| 2313 |
|
| 2314 |
}
|
| 2315 |
+
|
| 2316 |
}
|
| 2317 |
|
| 2318 |
/**
|
| 2327 |
if ( ! function_exists( 'ot_alert_message' ) ) {
|
| 2328 |
|
| 2329 |
function ot_alert_message( $page = array() ) {
|
| 2330 |
+
|
| 2331 |
if ( empty( $page ) )
|
| 2332 |
return false;
|
| 2333 |
+
|
| 2334 |
$before = apply_filters( 'ot_before_page_messages', '', $page );
|
| 2335 |
+
|
| 2336 |
if ( $before ) {
|
| 2337 |
return $before;
|
| 2338 |
}
|
| 2339 |
+
|
| 2340 |
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
|
| 2341 |
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
|
| 2342 |
$updated = isset( $_REQUEST['settings-updated'] ) ? $_REQUEST['settings-updated'] : '';
|
| 2343 |
+
|
| 2344 |
if ( $action == 'save-settings' ) {
|
| 2345 |
+
|
| 2346 |
if ( $message == 'success' ) {
|
| 2347 |
+
|
| 2348 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings updated.', 'option-tree' ) . '</p></div>';
|
| 2349 |
+
|
| 2350 |
} else if ( $message == 'failed' ) {
|
| 2351 |
+
|
| 2352 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be saved.', 'option-tree' ) . '</p></div>';
|
| 2353 |
+
|
| 2354 |
}
|
| 2355 |
+
|
| 2356 |
} else if ( $action == 'import-xml' || $action == 'import-settings' ) {
|
| 2357 |
+
|
| 2358 |
if ( $message == 'success' ) {
|
| 2359 |
+
|
| 2360 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings Imported.', 'option-tree' ) . '</p></div>';
|
| 2361 |
+
|
| 2362 |
} else if ( $message == 'failed' ) {
|
| 2363 |
+
|
| 2364 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be imported.', 'option-tree' ) . '</p></div>';
|
| 2365 |
+
|
| 2366 |
}
|
| 2367 |
} else if ( $action == 'import-data' ) {
|
| 2368 |
+
|
| 2369 |
if ( $message == 'success' ) {
|
| 2370 |
+
|
| 2371 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Data Imported.', 'option-tree' ) . '</p></div>';
|
| 2372 |
+
|
| 2373 |
} else if ( $message == 'failed' ) {
|
| 2374 |
+
|
| 2375 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Data could not be imported.', 'option-tree' ) . '</p></div>';
|
| 2376 |
+
|
| 2377 |
}
|
| 2378 |
+
|
| 2379 |
} else if ( $action == 'import-layouts' ) {
|
| 2380 |
+
|
| 2381 |
if ( $message == 'success' ) {
|
| 2382 |
+
|
| 2383 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Imported.', 'option-tree' ) . '</p></div>';
|
| 2384 |
+
|
| 2385 |
} else if ( $message == 'failed' ) {
|
| 2386 |
+
|
| 2387 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be imported.', 'option-tree' ) . '</p></div>';
|
| 2388 |
+
|
| 2389 |
}
|
| 2390 |
+
|
| 2391 |
} else if ( $action == 'save-layouts' ) {
|
| 2392 |
+
|
| 2393 |
if ( $message == 'success' ) {
|
| 2394 |
+
|
| 2395 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Updated.', 'option-tree' ) . '</p></div>';
|
| 2396 |
+
|
| 2397 |
} else if ( $message == 'failed' ) {
|
| 2398 |
+
|
| 2399 |
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be updated.', 'option-tree' ) . '</p></div>';
|
| 2400 |
+
|
| 2401 |
} else if ( $message == 'deleted' ) {
|
| 2402 |
+
|
| 2403 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts have been deleted.', 'option-tree' ) . '</p></div>';
|
| 2404 |
+
|
| 2405 |
}
|
| 2406 |
+
|
| 2407 |
+
} else if ( $updated == 'layout' ) {
|
| 2408 |
+
|
| 2409 |
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layout activated.', 'option-tree' ) . '</p></div>';
|
| 2410 |
+
|
| 2411 |
} else if ( $action == 'reset' ) {
|
| 2412 |
+
|
| 2413 |
return '<div id="message" class="updated fade below-h2"><p>' . $page['reset_message'] . '</p></div>';
|
| 2414 |
+
|
| 2415 |
}
|
| 2416 |
+
|
| 2417 |
do_action( 'ot_custom_page_messages', $page );
|
| 2418 |
+
|
| 2419 |
+
if ( $updated == 'true' ) {
|
| 2420 |
+
|
| 2421 |
return '<div id="message" class="updated fade below-h2"><p>' . $page['updated_message'] . '</p></div>';
|
| 2422 |
+
|
| 2423 |
+
}
|
| 2424 |
+
|
| 2425 |
return false;
|
| 2426 |
+
|
| 2427 |
}
|
| 2428 |
+
|
| 2429 |
}
|
| 2430 |
|
| 2431 |
/**
|
| 2443 |
if ( ! function_exists( 'ot_option_types_array' ) ) {
|
| 2444 |
|
| 2445 |
function ot_option_types_array() {
|
| 2446 |
+
|
| 2447 |
+
return apply_filters( 'ot_option_types_array', array(
|
| 2448 |
'background' => __('Background', 'option-tree'),
|
| 2449 |
'border' => __('Border', 'option-tree'),
|
| 2450 |
'box-shadow' => __('Box Shadow', 'option-tree'),
|
| 2491 |
'typography' => __('Typography', 'option-tree'),
|
| 2492 |
'upload' => __('Upload', 'option-tree')
|
| 2493 |
) );
|
| 2494 |
+
|
| 2495 |
}
|
| 2496 |
}
|
| 2497 |
|
| 2507 |
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
| 2508 |
|
| 2509 |
function ot_map_old_option_types( $type = '' ) {
|
| 2510 |
+
|
| 2511 |
+
if ( ! $type )
|
| 2512 |
return 'text';
|
| 2513 |
+
|
| 2514 |
$types = array(
|
| 2515 |
'background' => 'background',
|
| 2516 |
'category' => 'category-select',
|
| 2519 |
'colorpicker' => 'colorpicker',
|
| 2520 |
'css' => 'css',
|
| 2521 |
'custom_post' => 'custom-post-type-select',
|
| 2522 |
+
'custom_posts' => 'custom-post-type-checkbox',
|
| 2523 |
'input' => 'text',
|
| 2524 |
'image' => 'upload',
|
| 2525 |
'measurement' => 'measurement',
|
| 2537 |
'typography' => 'typography',
|
| 2538 |
'upload' => 'upload'
|
| 2539 |
);
|
| 2540 |
+
|
| 2541 |
if ( isset( $types[$type] ) )
|
| 2542 |
return $types[$type];
|
| 2543 |
+
|
| 2544 |
return false;
|
| 2545 |
+
|
| 2546 |
}
|
| 2547 |
}
|
| 2548 |
|
| 2573 |
}
|
| 2574 |
}
|
| 2575 |
}
|
| 2576 |
+
|
| 2577 |
return $families;
|
| 2578 |
}
|
| 2579 |
add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
|
| 2597 |
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
| 2598 |
|
| 2599 |
function ot_recognized_font_families( $field_id = '' ) {
|
| 2600 |
+
|
| 2601 |
$families = array(
|
| 2602 |
'arial' => 'Arial',
|
| 2603 |
'georgia' => 'Georgia',
|
| 2608 |
'trebuchet' => 'Trebuchet',
|
| 2609 |
'verdana' => 'Verdana'
|
| 2610 |
);
|
| 2611 |
+
|
| 2612 |
return apply_filters( 'ot_recognized_font_families', $families, $field_id );
|
| 2613 |
+
|
| 2614 |
}
|
| 2615 |
|
| 2616 |
}
|
| 2631 |
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
|
| 2632 |
|
| 2633 |
function ot_recognized_font_sizes( $field_id ) {
|
| 2634 |
+
|
| 2635 |
+
$range = ot_range(
|
| 2636 |
+
apply_filters( 'ot_font_size_low_range', 0, $field_id ),
|
| 2637 |
+
apply_filters( 'ot_font_size_high_range', 150, $field_id ),
|
| 2638 |
apply_filters( 'ot_font_size_range_interval', 1, $field_id )
|
| 2639 |
);
|
| 2640 |
+
|
| 2641 |
$unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
|
| 2642 |
+
|
| 2643 |
foreach( $range as $k => $v ) {
|
| 2644 |
$range[$k] = $v . $unit;
|
| 2645 |
}
|
| 2646 |
+
|
| 2647 |
return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
|
| 2648 |
}
|
| 2649 |
|
| 2666 |
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
|
| 2667 |
|
| 2668 |
function ot_recognized_font_styles( $field_id = '' ) {
|
| 2669 |
+
|
| 2670 |
return apply_filters( 'ot_recognized_font_styles', array(
|
| 2671 |
'normal' => 'Normal',
|
| 2672 |
'italic' => 'Italic',
|
| 2673 |
'oblique' => 'Oblique',
|
| 2674 |
'inherit' => 'Inherit'
|
| 2675 |
), $field_id );
|
| 2676 |
+
|
| 2677 |
}
|
| 2678 |
|
| 2679 |
}
|
| 2695 |
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
|
| 2696 |
|
| 2697 |
function ot_recognized_font_variants( $field_id = '' ) {
|
| 2698 |
+
|
| 2699 |
return apply_filters( 'ot_recognized_font_variants', array(
|
| 2700 |
'normal' => 'Normal',
|
| 2701 |
'small-caps' => 'Small Caps',
|
| 2702 |
'inherit' => 'Inherit'
|
| 2703 |
), $field_id );
|
| 2704 |
+
|
| 2705 |
}
|
| 2706 |
+
|
| 2707 |
}
|
| 2708 |
|
| 2709 |
/**
|
| 2723 |
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
| 2724 |
|
| 2725 |
function ot_recognized_font_weights( $field_id = '' ) {
|
| 2726 |
+
|
| 2727 |
return apply_filters( 'ot_recognized_font_weights', array(
|
| 2728 |
'normal' => 'Normal',
|
| 2729 |
'bold' => 'Bold',
|
| 2740 |
'900' => '900',
|
| 2741 |
'inherit' => 'Inherit'
|
| 2742 |
), $field_id );
|
| 2743 |
+
|
| 2744 |
}
|
| 2745 |
+
|
| 2746 |
}
|
| 2747 |
|
| 2748 |
/**
|
| 2761 |
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
|
| 2762 |
|
| 2763 |
function ot_recognized_letter_spacing( $field_id ) {
|
| 2764 |
+
|
| 2765 |
+
$range = ot_range(
|
| 2766 |
+
apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ),
|
| 2767 |
+
apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ),
|
| 2768 |
apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
|
| 2769 |
);
|
| 2770 |
+
|
| 2771 |
$unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
|
| 2772 |
+
|
| 2773 |
foreach( $range as $k => $v ) {
|
| 2774 |
$range[$k] = $v . $unit;
|
| 2775 |
}
|
| 2776 |
+
|
| 2777 |
return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
|
| 2778 |
}
|
| 2779 |
|
| 2795 |
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
|
| 2796 |
|
| 2797 |
function ot_recognized_line_heights( $field_id ) {
|
| 2798 |
+
|
| 2799 |
+
$range = ot_range(
|
| 2800 |
+
apply_filters( 'ot_line_height_low_range', 0, $field_id ),
|
| 2801 |
+
apply_filters( 'ot_line_height_high_range', 150, $field_id ),
|
| 2802 |
apply_filters( 'ot_line_height_range_interval', 1, $field_id )
|
| 2803 |
);
|
| 2804 |
+
|
| 2805 |
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
|
| 2806 |
+
|
| 2807 |
foreach( $range as $k => $v ) {
|
| 2808 |
$range[$k] = $v . $unit;
|
| 2809 |
}
|
| 2810 |
+
|
| 2811 |
return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
|
| 2812 |
}
|
| 2813 |
|
| 2828 |
* @since 2.0.10
|
| 2829 |
*/
|
| 2830 |
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
| 2831 |
+
|
| 2832 |
function ot_recognized_text_decorations( $field_id = '' ) {
|
| 2833 |
+
|
| 2834 |
return apply_filters( 'ot_recognized_text_decorations', array(
|
| 2835 |
'blink' => 'Blink',
|
| 2836 |
'inherit' => 'Inherit',
|
| 2839 |
'overline' => 'Overline',
|
| 2840 |
'underline' => 'Underline'
|
| 2841 |
), $field_id );
|
| 2842 |
+
|
| 2843 |
}
|
| 2844 |
|
| 2845 |
}
|
| 2859 |
* @since 2.0.10
|
| 2860 |
*/
|
| 2861 |
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
| 2862 |
+
|
| 2863 |
function ot_recognized_text_transformations( $field_id = '' ) {
|
| 2864 |
+
|
| 2865 |
return apply_filters( 'ot_recognized_text_transformations', array(
|
| 2866 |
'capitalize' => 'Capitalize',
|
| 2867 |
'inherit' => 'Inherit',
|
| 2869 |
'none' => 'None',
|
| 2870 |
'uppercase' => 'Uppercase'
|
| 2871 |
), $field_id );
|
| 2872 |
+
|
| 2873 |
}
|
| 2874 |
|
| 2875 |
}
|
| 2889 |
* @updated 2.0
|
| 2890 |
*/
|
| 2891 |
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
| 2892 |
+
|
| 2893 |
function ot_recognized_background_repeat( $field_id = '' ) {
|
| 2894 |
+
|
| 2895 |
return apply_filters( 'ot_recognized_background_repeat', array(
|
| 2896 |
'no-repeat' => 'No Repeat',
|
| 2897 |
'repeat' => 'Repeat All',
|
| 2899 |
'repeat-y' => 'Repeat Vertically',
|
| 2900 |
'inherit' => 'Inherit'
|
| 2901 |
), $field_id );
|
| 2902 |
+
|
| 2903 |
}
|
| 2904 |
+
|
| 2905 |
}
|
| 2906 |
|
| 2907 |
/**
|
| 2921 |
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
|
| 2922 |
|
| 2923 |
function ot_recognized_background_attachment( $field_id = '' ) {
|
| 2924 |
+
|
| 2925 |
return apply_filters( 'ot_recognized_background_attachment', array(
|
| 2926 |
"fixed" => "Fixed",
|
| 2927 |
"scroll" => "Scroll",
|
| 2928 |
"inherit" => "Inherit"
|
| 2929 |
), $field_id );
|
| 2930 |
+
|
| 2931 |
}
|
| 2932 |
|
| 2933 |
}
|
| 2949 |
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
|
| 2950 |
|
| 2951 |
function ot_recognized_background_position( $field_id = '' ) {
|
| 2952 |
+
|
| 2953 |
return apply_filters( 'ot_recognized_background_position', array(
|
| 2954 |
"left top" => "Left Top",
|
| 2955 |
"left center" => "Left Center",
|
| 2961 |
"right center" => "Right Center",
|
| 2962 |
"right bottom" => "Right Bottom"
|
| 2963 |
), $field_id );
|
| 2964 |
+
|
| 2965 |
}
|
| 2966 |
|
| 2967 |
}
|
| 3094 |
|
| 3095 |
$families = array();
|
| 3096 |
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
| 3097 |
+
|
| 3098 |
// Forces an array rebuild when we sitch themes
|
| 3099 |
if ( empty( $ot_google_fonts ) ) {
|
| 3100 |
$ot_google_fonts = ot_fetch_google_fonts( true, true );
|
| 3101 |
}
|
| 3102 |
+
|
| 3103 |
foreach( (array) $ot_google_fonts as $key => $item ) {
|
| 3104 |
+
|
| 3105 |
if ( isset( $item['family'] ) ) {
|
| 3106 |
+
|
| 3107 |
$families[ $key ] = $item['family'];
|
| 3108 |
+
|
| 3109 |
}
|
| 3110 |
+
|
| 3111 |
}
|
| 3112 |
+
|
| 3113 |
return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
|
| 3114 |
+
|
| 3115 |
}
|
| 3116 |
|
| 3117 |
}
|
| 3134 |
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
| 3135 |
|
| 3136 |
if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
|
| 3137 |
+
|
| 3138 |
$variants = $ot_google_fonts[ $family ]['variants'];
|
| 3139 |
+
|
| 3140 |
}
|
| 3141 |
+
|
| 3142 |
return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family );
|
| 3143 |
+
|
| 3144 |
}
|
| 3145 |
|
| 3146 |
}
|
| 3161 |
|
| 3162 |
$subsets = array();
|
| 3163 |
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
| 3164 |
+
|
| 3165 |
if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
|
| 3166 |
+
|
| 3167 |
$subsets = $ot_google_fonts[ $family ]['subsets'];
|
| 3168 |
+
|
| 3169 |
}
|
| 3170 |
+
|
| 3171 |
return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family );
|
| 3172 |
+
|
| 3173 |
}
|
| 3174 |
|
| 3175 |
}
|
| 3189 |
* @updated 2.0
|
| 3190 |
*/
|
| 3191 |
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
|
| 3192 |
+
|
| 3193 |
function ot_measurement_unit_types( $field_id = '' ) {
|
| 3194 |
+
|
| 3195 |
return apply_filters( 'ot_measurement_unit_types', array(
|
| 3196 |
'px' => 'px',
|
| 3197 |
'%' => '%',
|
| 3198 |
'em' => 'em',
|
| 3199 |
'pt' => 'pt'
|
| 3200 |
), $field_id );
|
| 3201 |
+
|
| 3202 |
}
|
| 3203 |
|
| 3204 |
}
|
| 3218 |
* @since 2.0
|
| 3219 |
*/
|
| 3220 |
if ( ! function_exists( 'ot_radio_images' ) ) {
|
| 3221 |
+
|
| 3222 |
function ot_radio_images( $field_id = '' ) {
|
| 3223 |
+
|
| 3224 |
return apply_filters( 'ot_radio_images', array(
|
| 3225 |
array(
|
| 3226 |
'value' => 'left-sidebar',
|
| 3253 |
'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png'
|
| 3254 |
)
|
| 3255 |
), $field_id );
|
| 3256 |
+
|
| 3257 |
}
|
| 3258 |
|
| 3259 |
}
|
| 3275 |
if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
| 3276 |
|
| 3277 |
function ot_list_item_settings( $id ) {
|
| 3278 |
+
|
| 3279 |
$settings = apply_filters( 'ot_list_item_settings', array(
|
| 3280 |
array(
|
| 3281 |
'id' => 'image',
|
| 3311 |
'choices' => array()
|
| 3312 |
)
|
| 3313 |
), $id );
|
| 3314 |
+
|
| 3315 |
return $settings;
|
| 3316 |
+
|
| 3317 |
}
|
| 3318 |
|
| 3319 |
}
|
| 3335 |
if ( ! function_exists( 'ot_slider_settings' ) ) {
|
| 3336 |
|
| 3337 |
function ot_slider_settings( $id ) {
|
| 3338 |
+
|
| 3339 |
$settings = apply_filters( 'image_slider_fields', array(
|
| 3340 |
array(
|
| 3341 |
'name' => 'image',
|
| 3356 |
'class' => ''
|
| 3357 |
)
|
| 3358 |
), $id );
|
| 3359 |
+
|
| 3360 |
/* fix the array keys, values, and just get it 2.0 ready */
|
| 3361 |
foreach( $settings as $_k => $setting ) {
|
| 3362 |
+
|
| 3363 |
foreach( $setting as $s_key => $s_value ) {
|
| 3364 |
+
|
| 3365 |
if ( 'name' == $s_key ) {
|
| 3366 |
+
|
| 3367 |
$settings[$_k]['id'] = $s_value;
|
| 3368 |
unset($settings[$_k]['name']);
|
| 3369 |
+
|
| 3370 |
} else if ( 'type' == $s_key ) {
|
| 3371 |
+
|
| 3372 |
if ( 'input' == $s_value ) {
|
| 3373 |
+
|
| 3374 |
$settings[$_k]['type'] = 'text';
|
| 3375 |
+
|
| 3376 |
} else if ( 'textarea' == $s_value ) {
|
| 3377 |
+
|
| 3378 |
$settings[$_k]['type'] = 'textarea-simple';
|
| 3379 |
+
|
| 3380 |
} else if ( 'image' == $s_value ) {
|
| 3381 |
+
|
| 3382 |
$settings[$_k]['type'] = 'upload';
|
| 3383 |
+
|
| 3384 |
}
|
| 3385 |
+
|
| 3386 |
}
|
| 3387 |
+
|
| 3388 |
+
}
|
| 3389 |
+
|
| 3390 |
}
|
| 3391 |
+
|
| 3392 |
return $settings;
|
| 3393 |
+
|
| 3394 |
}
|
| 3395 |
|
| 3396 |
}
|
| 3412 |
if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
| 3413 |
|
| 3414 |
function ot_social_links_settings( $id ) {
|
| 3415 |
+
|
| 3416 |
$settings = apply_filters( 'ot_social_links_settings', array(
|
| 3417 |
array(
|
| 3418 |
'id' => 'name',
|
| 3435 |
'type' => 'text',
|
| 3436 |
)
|
| 3437 |
), $id );
|
| 3438 |
+
|
| 3439 |
return $settings;
|
| 3440 |
+
|
| 3441 |
}
|
| 3442 |
|
| 3443 |
}
|
| 3446 |
* Inserts CSS with field_id markers.
|
| 3447 |
*
|
| 3448 |
* Inserts CSS into a dynamic.css file, placing it between
|
| 3449 |
+
* BEGIN and END field_id markers. Replaces existing marked info,
|
| 3450 |
* but still retains surrounding data.
|
| 3451 |
*
|
| 3452 |
* @param string $field_id The CSS option field ID.
|
| 3540 |
// Measurement
|
| 3541 |
if ( $option_type == 'measurement' ) {
|
| 3542 |
$unit = ! empty( $value[1] ) ? $value[1] : 'px';
|
| 3543 |
+
|
| 3544 |
// Set $value with measurement properties
|
| 3545 |
if ( isset( $value[0] ) && strlen( $value[0] ) > 0 )
|
| 3546 |
$value = $value[0].$unit;
|
| 3862 |
if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
| 3863 |
|
| 3864 |
function ot_remove_old_css( $field_id = '' ) {
|
| 3865 |
+
|
| 3866 |
/* missing $field_id string */
|
| 3867 |
if ( '' == $field_id )
|
| 3868 |
return false;
|
| 3869 |
+
|
| 3870 |
/* path to the dynamic.css file */
|
| 3871 |
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
| 3872 |
+
|
| 3873 |
/* allow filter on path */
|
| 3874 |
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
| 3875 |
+
|
| 3876 |
/* remove CSS from file */
|
| 3877 |
if ( is_writeable( $filepath ) ) {
|
| 3878 |
+
|
| 3879 |
/* get each line in the file */
|
| 3880 |
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
| 3881 |
+
|
| 3882 |
/* can't write to the file return false */
|
| 3883 |
if ( ! $f = ot_file_open( $filepath, 'w' ) )
|
| 3884 |
return false;
|
| 3885 |
+
|
| 3886 |
$searching = true;
|
| 3887 |
+
|
| 3888 |
/* has array of lines */
|
| 3889 |
if ( ! empty( $markerdata ) ) {
|
| 3890 |
+
|
| 3891 |
/* foreach line of code */
|
| 3892 |
foreach ( $markerdata as $n => $markerline ) {
|
| 3893 |
+
|
| 3894 |
/* found begining of marker, set $searching to false */
|
| 3895 |
if ( $markerline == "/* BEGIN {$field_id} */" )
|
| 3896 |
$searching = false;
|
| 3897 |
+
|
| 3898 |
/* $searching is true, keep rewrite each line of CSS */
|
| 3899 |
if ( $searching == true ) {
|
| 3900 |
if ( $n + 1 < count( $markerdata ) )
|
| 3902 |
else
|
| 3903 |
ot_file_write( $f, "{$markerline}" );
|
| 3904 |
}
|
| 3905 |
+
|
| 3906 |
/* found end marker delete old CSS */
|
| 3907 |
if ( $markerline == "/* END {$field_id} */" ) {
|
| 3908 |
ot_file_write( $f, "" );
|
| 3909 |
$searching = true;
|
| 3910 |
}
|
| 3911 |
+
|
| 3912 |
}
|
| 3913 |
+
|
| 3914 |
}
|
| 3915 |
+
|
| 3916 |
/* close file */
|
| 3917 |
ot_file_close( $f );
|
| 3918 |
return true;
|
| 3919 |
+
|
| 3920 |
}
|
| 3921 |
+
|
| 3922 |
return false;
|
| 3923 |
+
|
| 3924 |
}
|
| 3925 |
+
|
| 3926 |
}
|
| 3927 |
|
| 3928 |
/**
|
| 3940 |
if ( ! function_exists( 'ot_normalize_css' ) ) {
|
| 3941 |
|
| 3942 |
function ot_normalize_css( $css ) {
|
| 3943 |
+
|
| 3944 |
/* Normalize & Convert */
|
| 3945 |
$css = str_replace( "\r\n", "\n", $css );
|
| 3946 |
$css = str_replace( "\r", "\n", $css );
|
| 3947 |
+
|
| 3948 |
/* Don't allow out-of-control blank lines */
|
| 3949 |
$css = preg_replace( "/\n{2,}/", "\n\n", $css );
|
| 3950 |
+
|
| 3951 |
return $css;
|
| 3952 |
}
|
| 3953 |
+
|
| 3954 |
}
|
| 3955 |
|
| 3956 |
/**
|
| 3966 |
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
|
| 3967 |
|
| 3968 |
function ot_loop_through_option_types( $type = '', $child = false ) {
|
| 3969 |
+
|
| 3970 |
$content = '';
|
| 3971 |
$types = ot_option_types_array();
|
| 3972 |
+
|
| 3973 |
if ( $child )
|
| 3974 |
unset($types['list-item']);
|
| 3975 |
+
|
| 3976 |
foreach( $types as $key => $value )
|
| 3977 |
$content.= '<option value="' . $key . '" ' . selected( $type, $key, false ) . '>' . $value . '</option>';
|
| 3978 |
+
|
| 3979 |
return $content;
|
| 3980 |
+
|
| 3981 |
}
|
| 3982 |
+
|
| 3983 |
}
|
| 3984 |
|
| 3985 |
/**
|
| 3996 |
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
|
| 3997 |
|
| 3998 |
function ot_loop_through_choices( $name, $choices = array() ) {
|
| 3999 |
+
|
| 4000 |
$content = '';
|
| 4001 |
+
|
| 4002 |
foreach( (array) $choices as $key => $choice )
|
| 4003 |
$content.= '<li class="ui-state-default list-choice">' . ot_choices_view( $name, $key, $choice ) . '</li>';
|
| 4004 |
+
|
| 4005 |
return $content;
|
| 4006 |
}
|
| 4007 |
+
|
| 4008 |
}
|
| 4009 |
|
| 4010 |
/**
|
| 4021 |
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
|
| 4022 |
|
| 4023 |
function ot_loop_through_sub_settings( $name, $settings = array() ) {
|
| 4024 |
+
|
| 4025 |
$content = '';
|
| 4026 |
+
|
| 4027 |
foreach( $settings as $key => $setting )
|
| 4028 |
$content.= '<li class="ui-state-default list-sub-setting">' . ot_settings_view( $name, $key, $setting ) . '</li>';
|
| 4029 |
+
|
| 4030 |
return $content;
|
| 4031 |
}
|
| 4032 |
+
|
| 4033 |
}
|
| 4034 |
|
| 4035 |
/**
|
| 4049 |
if ( ! function_exists( 'ot_sections_view' ) ) {
|
| 4050 |
|
| 4051 |
function ot_sections_view( $name, $key, $section = array() ) {
|
| 4052 |
+
|
| 4053 |
return '
|
| 4054 |
<div class="option-tree-setting is-section">
|
| 4055 |
<div class="open">' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( $key + 1 ) ) . '</div>
|
| 4080 |
</div>
|
| 4081 |
</div>
|
| 4082 |
</div>';
|
| 4083 |
+
|
| 4084 |
}
|
| 4085 |
|
| 4086 |
}
|
| 4102 |
if ( ! function_exists( 'ot_settings_view' ) ) {
|
| 4103 |
|
| 4104 |
function ot_settings_view( $name, $key, $setting = array() ) {
|
| 4105 |
+
|
| 4106 |
$child = ( strpos( $name, '][settings]') !== false ) ? true : false;
|
| 4107 |
$type = isset( $setting['type'] ) ? $setting['type'] : '';
|
| 4108 |
$std = isset( $setting['std'] ) ? $setting['std'] : '';
|
| 4109 |
$operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
|
| 4110 |
+
|
| 4111 |
// Serialize the standard value just incase
|
| 4112 |
if ( is_array( $std ) ) {
|
| 4113 |
$std = maybe_serialize( $std );
|
| 4114 |
}
|
| 4115 |
+
|
| 4116 |
if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ) ) ) {
|
| 4117 |
$std_form_element = '<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]">' . esc_html( $std ) . '</textarea>';
|
| 4118 |
} else {
|
| 4119 |
$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" />';
|
| 4120 |
}
|
| 4121 |
+
|
| 4122 |
return '
|
| 4123 |
<div class="option-tree-setting">
|
| 4124 |
<div class="open">' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( $key + 1 ) ) . '</div>
|
| 4152 |
<div class="description">' . __( '<strong>Type</strong>: Choose one of the available option types from the dropdown.', 'option-tree' ) . '</div>
|
| 4153 |
<div class="format-setting-inner">
|
| 4154 |
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][type]" value="' . esc_attr( $type ) . '" class="option-tree-ui-select">
|
| 4155 |
+
' . ot_loop_through_option_types( $type, $child ) . '
|
| 4156 |
+
|
| 4157 |
</select>
|
| 4158 |
</div>
|
| 4159 |
</div>
|
| 4258 |
</div>
|
| 4259 |
</div>
|
| 4260 |
' . ( ! $child ? '<input type="hidden" class="hidden-section" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][section]" value="' . ( isset( $setting['section'] ) ? esc_attr( $setting['section'] ) : '' ) . '" />' : '' );
|
| 4261 |
+
|
| 4262 |
}
|
| 4263 |
|
| 4264 |
}
|
| 4281 |
if ( ! function_exists( 'ot_choices_view' ) ) {
|
| 4282 |
|
| 4283 |
function ot_choices_view( $name, $key, $choice = array() ) {
|
| 4284 |
+
|
| 4285 |
return '
|
| 4286 |
<div class="option-tree-setting">
|
| 4287 |
<div class="open">' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( $key + 1 ) ) . '</div>
|
| 4325 |
</div>
|
| 4326 |
</div>
|
| 4327 |
</div>';
|
| 4328 |
+
|
| 4329 |
}
|
| 4330 |
|
| 4331 |
}
|
| 4347 |
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
|
| 4348 |
|
| 4349 |
function ot_contextual_help_view( $name, $key, $content = array() ) {
|
| 4350 |
+
|
| 4351 |
return '
|
| 4352 |
<div class="option-tree-setting">
|
| 4353 |
<div class="open">' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( $key + 1 ) ) . '</div>
|
| 4386 |
</div>
|
| 4387 |
</div>
|
| 4388 |
</div>';
|
| 4389 |
+
|
| 4390 |
}
|
| 4391 |
|
| 4392 |
}
|
| 4420 |
</div>
|
| 4421 |
<input type="hidden" name="' . ot_layouts_id() . '[' . esc_attr( $key ) . ']" value="' . $data . '" />
|
| 4422 |
</div>';
|
| 4423 |
+
|
| 4424 |
}
|
| 4425 |
|
| 4426 |
}
|
| 4443 |
if ( ! function_exists( 'ot_list_item_view' ) ) {
|
| 4444 |
|
| 4445 |
function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
| 4446 |
+
|
| 4447 |
/* required title setting */
|
| 4448 |
$required_setting = array(
|
| 4449 |
array(
|
| 4458 |
'choices' => array()
|
| 4459 |
)
|
| 4460 |
);
|
| 4461 |
+
|
| 4462 |
/* load the old filterable slider settings */
|
| 4463 |
if ( 'slider' == $type ) {
|
| 4464 |
+
|
| 4465 |
$settings = ot_slider_settings( $name );
|
| 4466 |
+
|
| 4467 |
}
|
| 4468 |
+
|
| 4469 |
/* if no settings array load the filterable list item settings */
|
| 4470 |
if ( empty( $settings ) ) {
|
| 4471 |
+
|
| 4472 |
$settings = ot_list_item_settings( $name );
|
| 4473 |
+
|
| 4474 |
}
|
| 4475 |
+
|
| 4476 |
/* merge the two settings array */
|
| 4477 |
$settings = array_merge( $required_setting, $settings );
|
| 4478 |
+
|
| 4479 |
echo '
|
| 4480 |
<div class="option-tree-setting">
|
| 4481 |
<div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
|
| 4488 |
</a>
|
| 4489 |
</div>
|
| 4490 |
<div class="option-tree-setting-body">';
|
| 4491 |
+
|
| 4492 |
foreach( $settings as $field ) {
|
| 4493 |
+
|
| 4494 |
// Set field value
|
| 4495 |
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
| 4496 |
+
|
| 4497 |
/* set default to standard value */
|
| 4498 |
+
if ( isset( $field['std'] ) ) {
|
| 4499 |
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
| 4500 |
}
|
| 4501 |
+
|
| 4502 |
// filter the title label and description
|
| 4503 |
if ( $field['id'] == 'title' ) {
|
| 4504 |
+
|
| 4505 |
// filter the label
|
| 4506 |
$field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name );
|
| 4507 |
+
|
| 4508 |
// filter the description
|
| 4509 |
$field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name );
|
| 4510 |
+
|
| 4511 |
}
|
| 4512 |
+
|
| 4513 |
/* make life easier */
|
| 4514 |
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
| 4515 |
+
|
| 4516 |
/* build the arguments array */
|
| 4517 |
$_args = array(
|
| 4518 |
'type' => $field['type'],
|
| 4533 |
'post_id' => $post_id,
|
| 4534 |
'get_option' => $get_option
|
| 4535 |
);
|
| 4536 |
+
|
| 4537 |
$conditions = '';
|
| 4538 |
+
|
| 4539 |
/* setup the conditions */
|
| 4540 |
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
| 4541 |
+
|
| 4542 |
/* doing magic on the conditions so they work in a list item */
|
| 4543 |
$conditionals = explode( ',', $field['condition'] );
|
| 4544 |
foreach( $conditionals as $condition ) {
|
| 4571 |
$class = 'format-settings';
|
| 4572 |
|
| 4573 |
}
|
| 4574 |
+
|
| 4575 |
/* option label */
|
| 4576 |
echo '<div id="setting_' . $_args['field_id'] . '" class="' . $class . '"' . $conditions . '>';
|
| 4577 |
+
|
| 4578 |
/* don't show title with textblocks */
|
| 4579 |
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
| 4580 |
echo '<div class="format-setting-label">';
|
| 4581 |
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
| 4582 |
echo '</div>';
|
| 4583 |
}
|
| 4584 |
+
|
| 4585 |
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
| 4586 |
if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' )
|
| 4587 |
$_args['type'] = 'textarea-simple';
|
| 4588 |
+
|
| 4589 |
/* option body, list-item is not allowed inside another list-item */
|
| 4590 |
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' ) {
|
| 4591 |
echo ot_display_by_type( $_args );
|
| 4592 |
}
|
| 4593 |
+
|
| 4594 |
echo '</div>';
|
| 4595 |
+
|
| 4596 |
}
|
| 4597 |
+
|
| 4598 |
echo '</div>';
|
| 4599 |
+
|
| 4600 |
echo '</div>';
|
| 4601 |
+
|
| 4602 |
}
|
| 4603 |
+
|
| 4604 |
}
|
| 4605 |
|
| 4606 |
/**
|
| 4621 |
if ( ! function_exists( 'ot_social_links_view' ) ) {
|
| 4622 |
|
| 4623 |
function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
| 4624 |
+
|
| 4625 |
/* if no settings array load the filterable social links settings */
|
| 4626 |
if ( empty( $settings ) ) {
|
| 4627 |
+
|
| 4628 |
$settings = ot_social_links_settings( $name );
|
| 4629 |
+
|
| 4630 |
}
|
| 4631 |
+
|
| 4632 |
echo '
|
| 4633 |
<div class="option-tree-setting">
|
| 4634 |
<div class="open">' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '</div>
|
| 4641 |
</a>
|
| 4642 |
</div>
|
| 4643 |
<div class="option-tree-setting-body">';
|
| 4644 |
+
|
| 4645 |
foreach( $settings as $field ) {
|
| 4646 |
+
|
| 4647 |
// Set field value
|
| 4648 |
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
| 4649 |
+
|
| 4650 |
/* set default to standard value */
|
| 4651 |
+
if ( isset( $field['std'] ) ) {
|
| 4652 |
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
| 4653 |
}
|
| 4654 |
+
|
| 4655 |
/* make life easier */
|
| 4656 |
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
| 4657 |
+
|
| 4658 |
/* build the arguments array */
|
| 4659 |
$_args = array(
|
| 4660 |
'type' => $field['type'],
|
| 4675 |
'post_id' => $post_id,
|
| 4676 |
'get_option' => $get_option
|
| 4677 |
);
|
| 4678 |
+
|
| 4679 |
$conditions = '';
|
| 4680 |
+
|
| 4681 |
/* setup the conditions */
|
| 4682 |
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
| 4683 |
+
|
| 4684 |
/* doing magic on the conditions so they work in a list item */
|
| 4685 |
$conditionals = explode( ',', $field['condition'] );
|
| 4686 |
foreach( $conditionals as $condition ) {
|
| 4694 |
$conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
|
| 4695 |
|
| 4696 |
}
|
| 4697 |
+
|
| 4698 |
/* option label */
|
| 4699 |
echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings"' . $conditions . '>';
|
| 4700 |
+
|
| 4701 |
/* don't show title with textblocks */
|
| 4702 |
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
| 4703 |
echo '<div class="format-setting-label">';
|
| 4704 |
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
| 4705 |
echo '</div>';
|
| 4706 |
}
|
| 4707 |
+
|
| 4708 |
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
| 4709 |
if ( $_args['type'] == 'textarea' )
|
| 4710 |
$_args['type'] = 'textarea-simple';
|
| 4711 |
+
|
| 4712 |
/* option body, list-item is not allowed inside another list-item */
|
| 4713 |
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' && $_args['type'] !== 'social-links' ) {
|
| 4714 |
echo ot_display_by_type( $_args );
|
| 4715 |
}
|
| 4716 |
+
|
| 4717 |
echo '</div>';
|
| 4718 |
+
|
| 4719 |
}
|
| 4720 |
+
|
| 4721 |
echo '</div>';
|
| 4722 |
+
|
| 4723 |
echo '</div>';
|
| 4724 |
+
|
| 4725 |
}
|
| 4726 |
+
|
| 4727 |
}
|
| 4728 |
|
| 4729 |
/**
|
| 4737 |
if ( ! function_exists( 'niftycs_options_layouts_form' ) ) {
|
| 4738 |
|
| 4739 |
function niftycs_options_layouts_form( $active = false ) {
|
| 4740 |
+
|
| 4741 |
echo '<form method="post" id="option-tree-options-layouts-form">';
|
| 4742 |
+
|
| 4743 |
/* form nonce */
|
| 4744 |
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
| 4745 |
+
|
| 4746 |
/* get the saved layouts */
|
| 4747 |
$layouts = get_option( ot_layouts_id() );
|
| 4748 |
+
|
| 4749 |
/* set active layout */
|
| 4750 |
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
| 4751 |
|
| 4752 |
if ( is_array( $layouts ) && count( $layouts ) > 1 ) {
|
| 4753 |
+
|
| 4754 |
$active_layout = esc_attr( $layouts['active_layout'] );
|
| 4755 |
+
|
| 4756 |
echo '<input type="hidden" id="the_current_layout" value="' . $active_layout . '" />';
|
| 4757 |
+
|
| 4758 |
echo '<div class="option-tree-active-layout">';
|
| 4759 |
+
|
| 4760 |
echo '<select name="' . ot_layouts_id() . '[active_layout]" class="option-tree-ui-select">';
|
| 4761 |
+
|
| 4762 |
+
foreach( $layouts as $key => $data ) {
|
| 4763 |
+
|
| 4764 |
if ( $key == 'active_layout' )
|
| 4765 |
continue;
|
| 4766 |
+
|
| 4767 |
echo '<option' . selected( $key, $active_layout, false ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $key ) . '</option>';
|
| 4768 |
}
|
| 4769 |
+
|
| 4770 |
echo '</select>';
|
| 4771 |
+
|
| 4772 |
echo '</div>';
|
| 4773 |
+
|
| 4774 |
foreach( $layouts as $key => $data ) {
|
| 4775 |
+
|
| 4776 |
if ( $key == 'active_layout' )
|
| 4777 |
continue;
|
| 4778 |
+
|
| 4779 |
echo '<input type="hidden" name="' . ot_layouts_id() . '[' . $key . ']" value="' . ( isset( $data ) ? $data : '' ) . '" />';
|
| 4780 |
+
|
| 4781 |
}
|
| 4782 |
+
|
| 4783 |
}
|
| 4784 |
+
|
| 4785 |
/* new layout wrapper */
|
| 4786 |
echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
|
| 4787 |
+
|
| 4788 |
/* add new layout */
|
| 4789 |
echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
| 4790 |
+
|
| 4791 |
echo '<button type="submit" class="option-tree-ui-button button button-primary save-layout" title="' . __( 'New Layout', 'option-tree' ) . '">' . __( 'New Layout', 'option-tree' ) . '</button>';
|
| 4792 |
+
|
| 4793 |
echo '</div>';
|
| 4794 |
+
|
| 4795 |
echo '</form>';
|
| 4796 |
+
|
| 4797 |
}
|
| 4798 |
|
| 4799 |
}
|
| 4810 |
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
|
| 4811 |
|
| 4812 |
function ot_sanitize_option_id( $input ) {
|
| 4813 |
+
|
| 4814 |
return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
|
| 4815 |
+
|
| 4816 |
}
|
| 4817 |
|
| 4818 |
}
|
| 4829 |
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
|
| 4830 |
|
| 4831 |
function ot_sanitize_layout_id( $input ) {
|
| 4832 |
+
|
| 4833 |
return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
|
| 4834 |
+
|
| 4835 |
}
|
| 4836 |
|
| 4837 |
}
|
| 4852 |
|
| 4853 |
foreach( $input as $k => $choice ) {
|
| 4854 |
$choices[$k] = $choice['value'] . '|' . $choice['label'];
|
| 4855 |
+
|
| 4856 |
if ( isset( $choice['src'] ) )
|
| 4857 |
$choices[$k].= '|' . $choice['src'];
|
| 4858 |
+
|
| 4859 |
}
|
| 4860 |
+
|
| 4861 |
return implode( ',', $choices );
|
| 4862 |
}
|
| 4863 |
+
|
| 4864 |
return false;
|
| 4865 |
}
|
| 4866 |
}
|
| 4876 |
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
|
| 4877 |
|
| 4878 |
function ot_convert_string_to_array( $input ) {
|
| 4879 |
+
|
| 4880 |
if ( '' !== $input ) {
|
| 4881 |
+
|
| 4882 |
/* empty choices array */
|
| 4883 |
$choices = array();
|
| 4884 |
+
|
| 4885 |
/* exlode the string into an array */
|
| 4886 |
foreach( explode( ',', $input ) as $k => $choice ) {
|
| 4887 |
+
|
| 4888 |
/* if ":" is splitting the string go deeper */
|
| 4889 |
if ( preg_match( '/\|/', $choice ) ) {
|
| 4890 |
$split = explode( '|', $choice );
|
| 4891 |
$choices[$k]['value'] = trim( $split[0] );
|
| 4892 |
$choices[$k]['label'] = trim( $split[1] );
|
| 4893 |
+
|
| 4894 |
/* if radio image there are three values */
|
| 4895 |
if ( isset( $split[2] ) )
|
| 4896 |
$choices[$k]['src'] = trim( $split[2] );
|
| 4897 |
+
|
| 4898 |
} else {
|
| 4899 |
$choices[$k]['value'] = trim( $choice );
|
| 4900 |
$choices[$k]['label'] = trim( $choice );
|
| 4901 |
}
|
| 4902 |
+
|
| 4903 |
}
|
| 4904 |
+
|
| 4905 |
/* return a formated choices array */
|
| 4906 |
return $choices;
|
| 4907 |
+
|
| 4908 |
}
|
| 4909 |
+
|
| 4910 |
return false;
|
| 4911 |
+
|
| 4912 |
}
|
| 4913 |
}
|
| 4914 |
|
| 4925 |
if ( ! function_exists( 'ot_strpos_array' ) ) {
|
| 4926 |
|
| 4927 |
function ot_strpos_array( $haystack, $needles = array() ) {
|
| 4928 |
+
|
| 4929 |
foreach( $needles as $needle ) {
|
| 4930 |
$pos = strpos( $haystack, $needle );
|
| 4931 |
if ( $pos !== false ) {
|
| 4932 |
return true;
|
| 4933 |
}
|
| 4934 |
}
|
| 4935 |
+
|
| 4936 |
return false;
|
| 4937 |
}
|
| 4938 |
|
| 4949 |
* @since 2.0
|
| 4950 |
*/
|
| 4951 |
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
|
| 4952 |
+
|
| 4953 |
function ot_array_keys_exists( $array, $keys ) {
|
| 4954 |
+
|
| 4955 |
foreach($keys as $k) {
|
| 4956 |
if ( isset($array[$k]) ) {
|
| 4957 |
return true;
|
| 4958 |
}
|
| 4959 |
}
|
| 4960 |
+
|
| 4961 |
return false;
|
| 4962 |
}
|
| 4963 |
+
|
| 4964 |
}
|
| 4965 |
|
| 4966 |
/**
|
| 4975 |
if ( ! function_exists( 'ot_stripslashes' ) ) {
|
| 4976 |
|
| 4977 |
function ot_stripslashes( $input ) {
|
| 4978 |
+
|
| 4979 |
if ( is_array( $input ) ) {
|
| 4980 |
+
|
| 4981 |
foreach( $input as &$val ) {
|
| 4982 |
+
|
| 4983 |
if ( is_array( $val ) ) {
|
| 4984 |
+
|
| 4985 |
$val = ot_stripslashes( $val );
|
| 4986 |
+
|
| 4987 |
} else {
|
| 4988 |
+
|
| 4989 |
$val = stripslashes( trim( $val ) );
|
| 4990 |
+
|
| 4991 |
}
|
| 4992 |
+
|
| 4993 |
}
|
| 4994 |
+
|
| 4995 |
} else {
|
| 4996 |
+
|
| 4997 |
$input = stripslashes( trim( $input ) );
|
| 4998 |
+
|
| 4999 |
}
|
| 5000 |
+
|
| 5001 |
return $input;
|
| 5002 |
+
|
| 5003 |
}
|
| 5004 |
|
| 5005 |
}
|
| 5016 |
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
| 5017 |
|
| 5018 |
function ot_reverse_wpautop( $string = '' ) {
|
| 5019 |
+
|
| 5020 |
/* return if string is empty */
|
| 5021 |
if ( trim( $string ) === '' )
|
| 5022 |
return '';
|
| 5023 |
+
|
| 5024 |
/* remove all new lines & <p> tags */
|
| 5025 |
$string = str_replace( array( "\n", "<p>" ), "", $string );
|
| 5026 |
+
|
| 5027 |
/* replace <br /> with \r */
|
| 5028 |
$string = str_replace( array( "<br />", "<br>", "<br/>" ), "\r", $string );
|
| 5029 |
+
|
| 5030 |
/* replace </p> with \r\n */
|
| 5031 |
$string = str_replace( "</p>", "\r\n", $string );
|
| 5032 |
+
|
| 5033 |
/* return clean string */
|
| 5034 |
return trim( $string );
|
| 5035 |
+
|
| 5036 |
}
|
| 5037 |
|
| 5038 |
}
|
| 5040 |
/**
|
| 5041 |
* Returns an array of elements from start to limit, inclusive.
|
| 5042 |
*
|
| 5043 |
+
* Occasionally zero will be some impossibly large number to
|
| 5044 |
* the "E" power when creating a range from negative to positive.
|
| 5045 |
* This function attempts to fix that by setting that number back to "0".
|
| 5046 |
*
|
| 5047 |
* @param string $start First value of the sequence.
|
| 5048 |
* @param string $limit The sequence is ended upon reaching the limit value.
|
| 5049 |
+
* @param string $step If a step value is given, it will be used as the increment
|
| 5050 |
+
* between elements in the sequence. step should be given as a
|
| 5051 |
* positive number. If not specified, step will default to 1.
|
| 5052 |
* @return array
|
| 5053 |
*
|
| 5055 |
* @since 2.0.12
|
| 5056 |
*/
|
| 5057 |
function ot_range( $start, $limit, $step = 1 ) {
|
| 5058 |
+
|
| 5059 |
if ( $step < 0 )
|
| 5060 |
$step = 1;
|
| 5061 |
+
|
| 5062 |
$range = range( $start, $limit, $step );
|
| 5063 |
+
|
| 5064 |
foreach( $range as $k => $v ) {
|
| 5065 |
if ( strpos( $v, 'E' ) ) {
|
| 5066 |
$range[$k] = 0;
|
| 5067 |
}
|
| 5068 |
}
|
| 5069 |
+
|
| 5070 |
return $range;
|
| 5071 |
}
|
| 5072 |
|
| 5082 |
|
| 5083 |
$func = 'base64' . '_encode';
|
| 5084 |
return $func( $value );
|
| 5085 |
+
|
| 5086 |
}
|
| 5087 |
|
| 5088 |
/**
|
| 5097 |
|
| 5098 |
$func = 'base64' . '_decode';
|
| 5099 |
return $func( $value );
|
| 5100 |
+
|
| 5101 |
}
|
| 5102 |
|
| 5103 |
/**
|
| 5110 |
|
| 5111 |
$func = 'f' . 'open';
|
| 5112 |
return @$func( $handle, $mode );
|
| 5113 |
+
|
| 5114 |
}
|
| 5115 |
|
| 5116 |
/**
|
| 5123 |
|
| 5124 |
$func = 'f' . 'close';
|
| 5125 |
return $func( $handle );
|
| 5126 |
+
|
| 5127 |
}
|
| 5128 |
|
| 5129 |
/**
|
| 5136 |
|
| 5137 |
$func = 'f' . 'write';
|
| 5138 |
return $func( $handle, $string );
|
| 5139 |
+
|
| 5140 |
}
|
| 5141 |
|
| 5142 |
/**
|
| 5150 |
* @since 2.0.15
|
| 5151 |
*/
|
| 5152 |
function ot_filter_std_value( $value = '', $std = '' ) {
|
| 5153 |
+
|
| 5154 |
$std = maybe_unserialize( $std );
|
| 5155 |
+
|
| 5156 |
if ( is_array( $value ) && is_array( $std ) ) {
|
| 5157 |
+
|
| 5158 |
foreach( $value as $k => $v ) {
|
| 5159 |
+
|
| 5160 |
if ( '' == $value[$k] && isset( $std[$k] ) ) {
|
| 5161 |
+
|
| 5162 |
$value[$k] = $std[$k];
|
| 5163 |
+
|
| 5164 |
}
|
| 5165 |
+
|
| 5166 |
}
|
| 5167 |
+
|
| 5168 |
} else if ( '' == $value && ! empty( $std ) ) {
|
| 5169 |
+
|
| 5170 |
$value = $std;
|
| 5171 |
+
|
| 5172 |
}
|
| 5173 |
|
| 5174 |
return $value;
|
| 5175 |
+
|
| 5176 |
}
|
| 5177 |
|
| 5178 |
/**
|
| 5254 |
|
| 5255 |
/* Initiate API request */
|
| 5256 |
$ot_google_fonts_query_args = array(
|
| 5257 |
+
'key' => $ot_google_fonts_api_key,
|
| 5258 |
+
'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')',
|
| 5259 |
'sort' => $ot_google_fonts_sort
|
| 5260 |
);
|
| 5261 |
|
| 5274 |
if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) {
|
| 5275 |
|
| 5276 |
$ot_google_fonts = $ot_google_fonts_data['items'];
|
| 5277 |
+
|
| 5278 |
// Normalize the array key
|
| 5279 |
$ot_google_fonts_tmp = array();
|
| 5280 |
foreach( $ot_google_fonts as $key => $value ) {
|
| 5283 |
$id = preg_replace( '/[^a-z0-9_\-]/', '', $id );
|
| 5284 |
$ot_google_fonts_tmp[$id] = $value;
|
| 5285 |
}
|
| 5286 |
+
|
| 5287 |
$ot_google_fonts = $ot_google_fonts_tmp;
|
| 5288 |
set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
|
| 5289 |
set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS );
|
| 5356 |
function ot_wpml_register_string( $id, $value ) {
|
| 5357 |
|
| 5358 |
if ( function_exists( 'icl_register_string' ) ) {
|
| 5359 |
+
|
| 5360 |
icl_register_string( 'Theme Options', $id, $value );
|
| 5361 |
+
|
| 5362 |
}
|
| 5363 |
+
|
| 5364 |
}
|
| 5365 |
|
| 5366 |
/**
|
| 5372 |
function ot_wpml_unregister_string( $id ) {
|
| 5373 |
|
| 5374 |
if ( function_exists( 'icl_unregister_string' ) ) {
|
| 5375 |
+
|
| 5376 |
icl_unregister_string( 'Theme Options', $id );
|
| 5377 |
+
|
| 5378 |
}
|
| 5379 |
+
|
| 5380 |
}
|
| 5381 |
|
| 5382 |
/**
|
| 5390 |
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
|
| 5391 |
|
| 5392 |
function ot_maybe_migrate_settings() {
|
| 5393 |
+
|
| 5394 |
// Filter the ID to migrate from
|
| 5395 |
$settings_id = apply_filters( 'ot_migrate_settings_id', '' );
|
| 5396 |
+
|
| 5397 |
+
// Attempt to migrate Settings
|
| 5398 |
if ( ! empty( $settings_id ) && get_option( ot_settings_id() ) === false && ot_settings_id() !== $settings_id ) {
|
| 5399 |
+
|
| 5400 |
// Old settings
|
| 5401 |
$settings = get_option( $settings_id );
|
| 5402 |
+
|
| 5403 |
// Check for array keys
|
| 5404 |
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
| 5405 |
+
|
| 5406 |
update_option( ot_settings_id(), $settings );
|
| 5407 |
+
|
| 5408 |
}
|
| 5409 |
+
|
| 5410 |
}
|
| 5411 |
|
| 5412 |
}
|
| 5413 |
+
|
| 5414 |
}
|
| 5415 |
|
| 5416 |
/**
|
| 5424 |
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
|
| 5425 |
|
| 5426 |
function ot_maybe_migrate_options() {
|
| 5427 |
+
|
| 5428 |
// Filter the ID to migrate from
|
| 5429 |
$options_id = apply_filters( 'ot_migrate_options_id', '' );
|
| 5430 |
+
|
| 5431 |
// Attempt to migrate Theme Options
|
| 5432 |
if ( ! empty( $options_id ) && get_option( ot_options_id() ) === false && ot_options_id() !== $options_id ) {
|
| 5433 |
+
|
| 5434 |
// Old options
|
| 5435 |
$options = get_option( $options_id );
|
| 5436 |
+
|
| 5437 |
// Migrate to new ID
|
| 5438 |
update_option( ot_options_id(), $options );
|
| 5439 |
+
|
| 5440 |
}
|
| 5441 |
|
| 5442 |
}
|
| 5443 |
+
|
| 5444 |
}
|
| 5445 |
|
| 5446 |
/**
|
| 5454 |
if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
|
| 5455 |
|
| 5456 |
function ot_maybe_migrate_layouts() {
|
| 5457 |
+
|
| 5458 |
// Filter the ID to migrate from
|
| 5459 |
$layouts_id = apply_filters( 'ot_migrate_layouts_id', '' );
|
| 5460 |
+
|
| 5461 |
// Attempt to migrate Layouts
|
| 5462 |
if ( ! empty( $layouts_id ) && get_option( ot_layouts_id() ) === false && ot_layouts_id() !== $layouts_id ) {
|
| 5463 |
+
|
| 5464 |
// Old options
|
| 5465 |
$layouts = get_option( $layouts_id );
|
| 5466 |
+
|
| 5467 |
// Migrate to new ID
|
| 5468 |
update_option( ot_layouts_id(), $layouts );
|
| 5469 |
+
|
| 5470 |
}
|
| 5471 |
|
| 5472 |
}
|
| 5476 |
/**
|
| 5477 |
* Returns an array with the post format gallery meta box.
|
| 5478 |
*
|
| 5479 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
| 5480 |
+
* post_types and is what tells the metabox where to
|
| 5481 |
* display. Default 'post'.
|
| 5482 |
* @return array
|
| 5483 |
*
|
| 5488 |
|
| 5489 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'gallery', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5490 |
return false;
|
| 5491 |
+
|
| 5492 |
if ( is_string( $pages ) )
|
| 5493 |
$pages = explode( ',', $pages );
|
| 5494 |
+
|
| 5495 |
return apply_filters( 'ot_meta_box_post_format_gallery', array(
|
| 5496 |
'id' => 'ot-post-format-gallery',
|
| 5497 |
'title' => __( 'Gallery', 'option-tree' ),
|
| 5516 |
/**
|
| 5517 |
* Returns an array with the post format link metabox.
|
| 5518 |
*
|
| 5519 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
| 5520 |
+
* post_types and is what tells the metabox where to
|
| 5521 |
* display. Default 'post'.
|
| 5522 |
* @return array
|
| 5523 |
*
|
| 5525 |
* @since 2.4.0
|
| 5526 |
*/
|
| 5527 |
function ot_meta_box_post_format_link( $pages = 'post' ) {
|
| 5528 |
+
|
| 5529 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5530 |
return false;
|
| 5531 |
+
|
| 5532 |
if ( is_string( $pages ) )
|
| 5533 |
$pages = explode( ',', $pages );
|
| 5534 |
+
|
| 5535 |
return apply_filters( 'ot_meta_box_post_format_link', array(
|
| 5536 |
'id' => 'ot-post-format-link',
|
| 5537 |
'title' => __( 'Link', 'option-tree' ),
|
| 5562 |
/**
|
| 5563 |
* Returns an array with the post format quote metabox.
|
| 5564 |
*
|
| 5565 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
| 5566 |
+
* post_types and is what tells the metabox where to
|
| 5567 |
* display. Default 'post'.
|
| 5568 |
* @return array
|
| 5569 |
*
|
| 5571 |
* @since 2.4.0
|
| 5572 |
*/
|
| 5573 |
function ot_meta_box_post_format_quote( $pages = 'post' ) {
|
| 5574 |
+
|
| 5575 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5576 |
return false;
|
| 5577 |
+
|
| 5578 |
if ( is_string( $pages ) )
|
| 5579 |
$pages = explode( ',', $pages );
|
| 5580 |
|
| 5622 |
/**
|
| 5623 |
* Returns an array with the post format video metabox.
|
| 5624 |
*
|
| 5625 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
| 5626 |
+
* post_types and is what tells the metabox where to
|
| 5627 |
* display. Default 'post'.
|
| 5628 |
* @return array
|
| 5629 |
*
|
| 5631 |
* @since 2.4.0
|
| 5632 |
*/
|
| 5633 |
function ot_meta_box_post_format_video( $pages = 'post' ) {
|
| 5634 |
+
|
| 5635 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5636 |
return false;
|
| 5637 |
+
|
| 5638 |
if ( is_string( $pages ) )
|
| 5639 |
$pages = explode( ',', $pages );
|
| 5640 |
+
|
| 5641 |
return apply_filters( 'ot_meta_box_post_format_video', array(
|
| 5642 |
'id' => 'ot-post-format-video',
|
| 5643 |
'title' => __( 'Video', 'option-tree' ),
|
| 5661 |
/**
|
| 5662 |
* Returns an array with the post format audio metabox.
|
| 5663 |
*
|
| 5664 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
| 5665 |
+
* post_types and is what tells the metabox where to
|
| 5666 |
* display. Default 'post'.
|
| 5667 |
* @return array
|
| 5668 |
*
|
| 5670 |
* @since 2.4.0
|
| 5671 |
*/
|
| 5672 |
function ot_meta_box_post_format_audio( $pages = 'post' ) {
|
| 5673 |
+
|
| 5674 |
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ) ) )
|
| 5675 |
return false;
|
| 5676 |
+
|
| 5677 |
if ( is_string( $pages ) )
|
| 5678 |
$pages = explode( ',', $pages );
|
| 5679 |
+
|
| 5680 |
return apply_filters( 'ot_meta_box_post_format_audio', array(
|
| 5681 |
'id' => 'ot-post-format-audio',
|
| 5682 |
'title' => __( 'Audio', 'option-tree' ),
|
| 5710 |
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
|
| 5711 |
|
| 5712 |
function ot_get_option_type_by_id( $option_id, $settings_id = '' ) {
|
| 5713 |
+
|
| 5714 |
if ( empty( $settings_id ) ) {
|
| 5715 |
+
|
| 5716 |
$settings_id = ot_settings_id();
|
| 5717 |
+
|
| 5718 |
}
|
| 5719 |
+
|
| 5720 |
$settings = get_option( $settings_id, array() );
|
| 5721 |
+
|
| 5722 |
if ( isset( $settings['settings'] ) ) {
|
| 5723 |
+
|
| 5724 |
foreach( $settings['settings'] as $value ) {
|
| 5725 |
+
|
| 5726 |
if ( $option_id == $value['id'] && isset( $value['type'] ) ) {
|
| 5727 |
+
|
| 5728 |
return $value['type'];
|
| 5729 |
+
|
| 5730 |
}
|
| 5731 |
+
|
| 5732 |
}
|
| 5733 |
+
|
| 5734 |
}
|
| 5735 |
+
|
| 5736 |
return false;
|
| 5737 |
+
|
| 5738 |
}
|
| 5739 |
+
|
| 5740 |
}
|
| 5741 |
|
| 5742 |
/**
|
| 5751 |
|
| 5752 |
$options = array();
|
| 5753 |
$settings = get_option( ot_settings_id(), array() );
|
| 5754 |
+
$option_types = array(
|
| 5755 |
'category-checkbox',
|
| 5756 |
'category-select',
|
| 5757 |
'tag-checkbox',
|
| 5782 |
}
|
| 5783 |
|
| 5784 |
if ( ! empty( $sub_options ) ) {
|
| 5785 |
+
$options[] = array(
|
| 5786 |
'id' => $item['id'],
|
| 5787 |
'taxonomy' => $value['taxonomy'],
|
| 5788 |
'parent' => $value['id'],
|
| 5798 |
if ( in_array( $value['type'], $option_types ) ) {
|
| 5799 |
$saved = ot_get_option( $value['id'] );
|
| 5800 |
if ( ! empty( $saved ) ) {
|
| 5801 |
+
$options[] = array(
|
| 5802 |
'id' => $value['id'],
|
| 5803 |
'taxonomy' => $value['taxonomy'],
|
| 5804 |
'value' => $saved
|
| 5829 |
|
| 5830 |
$options = array();
|
| 5831 |
$settings = $ot_meta_boxes;
|
| 5832 |
+
$option_types = array(
|
| 5833 |
'category-checkbox',
|
| 5834 |
'category-select',
|
| 5835 |
'tag-checkbox',
|
| 5859 |
}
|
| 5860 |
|
| 5861 |
}
|
| 5862 |
+
|
| 5863 |
if ( ! empty( $children[$value['id']] ) ) {
|
| 5864 |
+
$options[] = array(
|
| 5865 |
'id' => $value['id'],
|
| 5866 |
'children' => $children[$value['id']],
|
| 5867 |
'taxonomy' => $value['taxonomy'],
|
| 5872 |
|
| 5873 |
if ( in_array( $value['type'], $option_types ) ) {
|
| 5874 |
|
| 5875 |
+
$options[] = array(
|
| 5876 |
'id' => $value['id'],
|
| 5877 |
'taxonomy' => $value['taxonomy'],
|
| 5878 |
);
|
| 5997 |
|
| 5998 |
// Process the Meta Boxes
|
| 5999 |
$meta_settings = _ot_meta_box_potential_shared_terms();
|
| 6000 |
+
$option_types = array(
|
| 6001 |
'category-checkbox',
|
| 6002 |
'category-select',
|
| 6003 |
'tag-checkbox',
|
| 6008 |
|
| 6009 |
if ( ! empty( $meta_settings ) ) {
|
| 6010 |
$old_meta = array();
|
| 6011 |
+
|
| 6012 |
foreach( $meta_settings as $option ) {
|
| 6013 |
|
| 6014 |
if ( ! is_array( $option['taxonomy'] ) ) {
|
| 6015 |
$option['taxonomy'] = explode( ',', $option['taxonomy'] );
|
| 6016 |
}
|
| 6017 |
+
|
| 6018 |
if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) {
|
| 6019 |
continue;
|
| 6020 |
}
|
| 6074 |
|
| 6075 |
// Update
|
| 6076 |
if ( $old_meta !== $new_meta ) {
|
| 6077 |
+
|
| 6078 |
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
| 6079 |
+
|
| 6080 |
}
|
| 6081 |
|
| 6082 |
}
|
| 6131 |
|
| 6132 |
// Update
|
| 6133 |
if ( $old_meta !== $new_meta ) {
|
| 6134 |
+
|
| 6135 |
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
| 6136 |
+
|
| 6137 |
}
|
| 6138 |
|
| 6139 |
}
|
| 6152 |
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
|
| 6153 |
|
| 6154 |
/* End of file ot-functions-admin.php */
|
| 6155 |
+
/* Location: ./includes/ot-functions-admin.php */
|
admin/includes/ot-settings-api.php
CHANGED
|
@@ -304,11 +304,16 @@ if ( ! class_exists( 'OT_Settings' ) ) {
|
|
| 304 |
echo '<button class="option-tree-ui-button button button-primary right">' . $page['button_text'] . '</button>';
|
| 305 |
echo '<a target="_blank" href="'. get_site_url().'/?get_preview=true"><div class="option-tree-ui-button button right">Live Preview</div></a>';
|
| 306 |
$options = get_option('nifty_options');
|
| 307 |
-
if (empty($options['hide_notice']['rate'])) {
|
| 308 |
$dismiss_url = add_query_arg(array('action' => 'nifty_dismiss_notice', 'notice' => 'rate', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
|
| 309 |
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>';
|
| 310 |
}
|
| 311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
/*
|
| 313 |
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.';
|
| 314 |
if (ot_is_weforms_active()) {
|
| 304 |
echo '<button class="option-tree-ui-button button button-primary right">' . $page['button_text'] . '</button>';
|
| 305 |
echo '<a target="_blank" href="'. get_site_url().'/?get_preview=true"><div class="option-tree-ui-button button right">Live Preview</div></a>';
|
| 306 |
$options = get_option('nifty_options');
|
| 307 |
+
if (false && empty($options['hide_notice']['rate'])) {
|
| 308 |
$dismiss_url = add_query_arg(array('action' => 'nifty_dismiss_notice', 'notice' => 'rate', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
|
| 309 |
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>';
|
| 310 |
}
|
| 311 |
|
| 312 |
+
if (empty($options['hide_notice']['weforms']) && !ot_is_weforms_active()) {
|
| 313 |
+
$dismiss_url = add_query_arg(array('action' => 'nifty_dismiss_notice', 'notice' => 'weforms', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
|
| 314 |
+
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>';
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
/*
|
| 318 |
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.';
|
| 319 |
if (ot_is_weforms_active()) {
|
admin/main-options.php
CHANGED
|
@@ -31,7 +31,7 @@ function nifty_cs_custom_theme_options() {
|
|
| 31 |
|
| 32 |
function admin_action_dismiss_notice() {
|
| 33 |
if (empty($_GET['notice'])) {
|
| 34 |
-
|
| 35 |
exit;
|
| 36 |
}
|
| 37 |
|
|
@@ -39,15 +39,19 @@ function admin_action_dismiss_notice() {
|
|
| 39 |
|
| 40 |
if ($_GET['notice'] == 'rate') {
|
| 41 |
$options['hide_notice']['rate'] = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
-
|
| 45 |
update_option('nifty_options', $options);
|
| 46 |
|
| 47 |
if (!empty($_GET['redirect'])) {
|
| 48 |
-
|
| 49 |
} else {
|
| 50 |
-
|
| 51 |
}
|
| 52 |
|
| 53 |
exit;
|
|
@@ -939,13 +943,15 @@ function ot_type_custom_themes() {
|
|
| 939 |
$weforms_setting = array(
|
| 940 |
'id' => 'weforms_sign_up_form_enable',
|
| 941 |
'label' => 'Any Kind of Form - Contact, Subscribe, Event, Optin,...',
|
| 942 |
-
'desc' => 'Collecting subscribers and giving users the ability to contact you is one of the most important
|
| 943 |
'std' => 'off',
|
| 944 |
'type' => 'on-off',
|
| 945 |
'section' => 'general_settings',
|
| 946 |
);
|
| 947 |
}
|
| 948 |
|
|
|
|
|
|
|
| 949 |
$custom_settings = array(
|
| 950 |
'contextual_help' => array(
|
| 951 |
'sidebar' => ''
|
| 31 |
|
| 32 |
function admin_action_dismiss_notice() {
|
| 33 |
if (empty($_GET['notice'])) {
|
| 34 |
+
wp_safe_redirect(admin_url());
|
| 35 |
exit;
|
| 36 |
}
|
| 37 |
|
| 39 |
|
| 40 |
if ($_GET['notice'] == 'rate') {
|
| 41 |
$options['hide_notice']['rate'] = true;
|
| 42 |
+
} elseif ($_GET['notice'] == 'weforms') {
|
| 43 |
+
$options['hide_notice']['weforms'] = true;
|
| 44 |
+
} else {
|
| 45 |
+
wp_safe_redirect(admin_url());
|
| 46 |
+
exit;
|
| 47 |
}
|
| 48 |
|
|
|
|
| 49 |
update_option('nifty_options', $options);
|
| 50 |
|
| 51 |
if (!empty($_GET['redirect'])) {
|
| 52 |
+
wp_safe_redirect($_GET['redirect']);
|
| 53 |
} else {
|
| 54 |
+
wp_safe_redirect(admin_url());
|
| 55 |
}
|
| 56 |
|
| 57 |
exit;
|
| 943 |
$weforms_setting = array(
|
| 944 |
'id' => 'weforms_sign_up_form_enable',
|
| 945 |
'label' => 'Any Kind of Form - Contact, Subscribe, Event, Optin,...',
|
| 946 |
+
'desc' => 'Collecting subscribers and giving users the ability to contact you is one of the most important features that every website needs. You can simply <a href="#" class="open-weforms-upsell">install the free weForms plugin</a> to add any kind of form to your coming soon page. weForms integrates seamlessly with Nifty, offering a wide range of styling options and useful integrations. More importantly, it enables you to get subscribers without any additional costs.',
|
| 947 |
'std' => 'off',
|
| 948 |
'type' => 'on-off',
|
| 949 |
'section' => 'general_settings',
|
| 950 |
);
|
| 951 |
}
|
| 952 |
|
| 953 |
+
|
| 954 |
+
|
| 955 |
$custom_settings = array(
|
| 956 |
'contextual_help' => array(
|
| 957 |
'sidebar' => ''
|
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
|
|
@@ -215,11 +215,13 @@ if ( isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL
|
|
| 215 |
*/
|
| 216 |
function nifty_add_plugin_featured($plugin_slug, $res) {
|
| 217 |
// check if plugin is alredy on the list
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
|
|
|
|
|
|
| 223 |
|
| 224 |
if ($plugin_info = get_transient('wf-plugin-info-' . $plugin_slug)) {
|
| 225 |
//$res->plugins[] = $plugin_info;
|
| 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.42
|
| 7 |
Author: WebFactory Ltd
|
| 8 |
Author URI: https://webfactoryltd.com/
|
| 9 |
License: GPLv3
|
| 215 |
*/
|
| 216 |
function nifty_add_plugin_featured($plugin_slug, $res) {
|
| 217 |
// check if plugin is alredy on the list
|
| 218 |
+
if (!empty($res->plugins)) {
|
| 219 |
+
foreach ($res->plugins as $plugin) {
|
| 220 |
+
if ($plugin->slug == $plugin_slug) {
|
| 221 |
+
return $res;
|
| 222 |
+
}
|
| 223 |
+
} // foreach
|
| 224 |
+
}
|
| 225 |
|
| 226 |
if ($plugin_info = get_transient('wf-plugin-info-' . $plugin_slug)) {
|
| 227 |
//$res->plugins[] = $plugin_info;
|
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, coming soon mode, under construction, maintenance mode page, landing page, offline page, subscribe form, maintenance
|
| 4 |
Tested up to: 5.0
|
| 5 |
License: GPLv3
|
| 6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 7 |
-
Stable tag: 1.
|
| 8 |
|
| 9 |
Nifty Coming Soon, Under Construction & Maintenance page builder creates awesome Coming Soon pages with all premium alike features for free.
|
| 10 |
|
|
@@ -87,6 +87,11 @@ As from the update of 1.0.9, the plugin offers the way to Live Preview you're Co
|
|
| 87 |
|
| 88 |
== Changelog ==
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
= 1.40 =
|
| 91 |
* 2018/11/20
|
| 92 |
* new: weForms integration - create any kind of form you need on the coming soon page
|
| 1 |
=== Coming Soon, Under Construction & Maintenance Page ===
|
| 2 |
+
Contributors: WebFactory
|
| 3 |
Tags: coming soon, coming soon page, launch page, maintenance mode, coming soon mode, under construction, maintenance mode page, landing page, offline page, subscribe form, maintenance
|
| 4 |
Tested up to: 5.0
|
| 5 |
License: GPLv3
|
| 6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 7 |
+
Stable tag: 1.42
|
| 8 |
|
| 9 |
Nifty Coming Soon, Under Construction & Maintenance page builder creates awesome Coming Soon pages with all premium alike features for free.
|
| 10 |
|
| 87 |
|
| 88 |
== Changelog ==
|
| 89 |
|
| 90 |
+
= 1.42 =
|
| 91 |
+
* 2018/11/27
|
| 92 |
+
* minor vulnerability removed
|
| 93 |
+
* few bugs fixed
|
| 94 |
+
|
| 95 |
= 1.40 =
|
| 96 |
* 2018/11/20
|
| 97 |
* new: weForms integration - create any kind of form you need on the coming soon page
|
