wp/wp-content/plugins/option-tree/includes/ot-functions-admin.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Functions used only while viewing the admin UI.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * Limit loading these function only when needed 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * and not in the front end.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @package   OptionTree
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * @author    Derek Herman <derek@valendesigns.com>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * @copyright Copyright (c) 2013, Derek Herman
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 * Registers the Theme Option page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
 * @uses      ot_register_settings()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
  function ot_register_theme_options_page() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
    /* get the settings array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
    $get_settings = get_option( ot_settings_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
    /* sections array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
    $sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
    /* settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
    $settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
    /* contexual_help array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
    $contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
    /* build the Theme Options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
    if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
      ot_register_settings( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
          array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
            'id'                  => ot_options_id(),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
            'pages'               => array( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
              array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
                'id'              => 'ot_theme_options',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
                'parent_slug'     => apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
                'page_title'      => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
                'menu_title'      => apply_filters( 'ot_theme_options_menu_title', __( 'Theme Options', 'option-tree' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
                'capability'      => $caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
                'menu_slug'       => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
                'icon_url'        => apply_filters( 'ot_theme_options_icon_url', null ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
                'position'        => apply_filters( 'ot_theme_options_position', null ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
                'updated_message' => apply_filters( 'ot_theme_options_updated_message', __( 'Theme Options updated.', 'option-tree' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
                'reset_message'   => apply_filters( 'ot_theme_options_reset_message', __( 'Theme Options reset.', 'option-tree' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
                'button_text'     => apply_filters( 'ot_theme_options_button_text', __( 'Save Changes', 'option-tree' ) ),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
                'contextual_help' => apply_filters( 'ot_theme_options_contextual_help', $contextual_help ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
                'sections'        => apply_filters( 'ot_theme_options_sections', $sections ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
                'settings'        => apply_filters( 'ot_theme_options_settings', $settings )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
              )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
            )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
          )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
        ) 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
      );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
      // Filters the options.php to add the minimum user capabilities.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
      add_filter( 'option_page_capability_' . ot_options_id(), create_function( '$caps', "return '$caps';" ), 999 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
 * Registers the Settings page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
 * @uses      ot_register_settings()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
 * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
if ( ! function_exists( 'ot_register_settings_page' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
  function ot_register_settings_page() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    90
    global $ot_has_custom_theme_options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    91
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    92
    // Display UI Builder admin notice
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    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' ) ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    95
      function ot_has_custom_theme_options() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    96
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    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>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    98
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   100
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   101
      add_action( 'admin_notices', 'ot_has_custom_theme_options' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
  
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   103
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   104
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
    // Create the filterable pages array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
    $ot_register_pages_array =  array( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
      array( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
        'id'              => 'ot',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
        'page_title'      => __( 'OptionTree', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
        'menu_title'      => __( 'OptionTree', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
        'capability'      => 'edit_theme_options',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
        'menu_slug'       => 'ot-settings',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
        'icon_url'        => null,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
        'position'        => 61,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
        'hidden_page'     => true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
        'id'              => 'settings',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
        'parent_slug'     => 'ot-settings',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
        'page_title'      => __( 'Settings', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
        'menu_title'      => __( 'Settings', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
        'capability'      => 'edit_theme_options',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
        'menu_slug'       => 'ot-settings',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
        'icon_url'        => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
        'position'        => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
        'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
        'reset_message'   => __( 'Theme Options reset.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
        'button_text'     => __( 'Save Settings', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
        'show_buttons'    => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
        'sections'        => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
            'id'          => 'create_setting',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
            'title'       => __( 'Theme Options UI', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
            'id'          => 'import',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
            'title'       => __( 'Import', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
            'id'          => 'export',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
            'title'       => __( 'Export', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
            'id'          => 'layouts',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
            'title'       => __( 'Layouts', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
          )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
        ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
        'settings'        => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
            'id'          => 'theme_options_ui_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
            'label'       => __( 'Theme Options UI Builder', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
            'type'        => 'theme_options_ui',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
            'section'     => 'create_setting'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
            'id'          => 'import_xml_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
            'label'       => __( 'Settings XML', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
            'type'        => 'import-xml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
            'section'     => 'import'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
            'id'          => 'import_settings_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
            'label'       => __( 'Settings', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
            'type'        => 'import-settings',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
            'section'     => 'import'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
            'id'          => 'import_data_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
            'label'       => __( 'Theme Options', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
            'type'        => 'import-data',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
            'section'     => 'import'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
            'id'          => 'import_layouts_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
            'label'       => __( 'Layouts', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
            'type'        => 'import-layouts',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
            'section'     => 'import'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
            'id'          => 'export_settings_file_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
            'label'       => __( 'Settings PHP File', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
            'type'        => 'export-settings-file',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
            'section'     => 'export'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
            'id'          => 'export_settings_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
            'label'       => __( 'Settings', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
            'type'        => 'export-settings',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
            'section'     => 'export'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
            'id'          => 'export_data_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
            'label'       => __( 'Theme Options', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
            'type'        => 'export-data',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
            'section'     => 'export'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
            'id'          => 'export_layout_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
            'label'       => __( 'Layouts', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
            'type'        => 'export-layouts',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
            'section'     => 'export'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
            'id'          => 'modify_layouts_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
            'label'       => __( 'Layout Management', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
            'type'        => 'modify-layouts',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
            'section'     => 'layouts'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
          )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
        )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
        'id'              => 'documentation',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
        'parent_slug'     => 'ot-settings',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
        'page_title'      => __( 'Documentation', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
        'menu_title'      => __( 'Documentation', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
        'capability'      => 'edit_theme_options',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
        'menu_slug'       => 'ot-documentation',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
        'icon_url'        => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
        'position'        => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
        'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
        'reset_message'   => __( 'Theme Options reset.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
        'button_text'     => __( 'Save Settings', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
        'show_buttons'    => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
        'sections'        => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
            'id'          => 'creating_options',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
            'title'       => __( 'Creating Options', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
            'id'          => 'option_types',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
            'title'       => __( 'Option Types', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
            'id'          => 'functions',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
            'title'       => __( 'Function References', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
            'id'          => 'theme_mode',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
            'title'       => __( 'Theme Mode', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
            'id'          => 'meta_boxes',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
            'title'       => __( 'Meta Boxes', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
            'id'          => 'examples',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
            'title'       => __( 'Code Examples', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
            'id'          => 'layouts_overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
            'title'       => __( 'Layouts Overview', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
          )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
        ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
        'settings'        => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
            'id'          => 'creating_options_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
            'label'       => __( 'Overview of available Theme Option fields.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
            'type'        => 'creating-options',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
            'section'     => 'creating_options'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
            'id'          => 'option_types_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
            'label'       => __( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
            'type'        => 'option-types',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
            'section'     => 'option_types'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
            'id'          => 'functions_ot_get_option',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
            'label'       => __( 'Function Reference:ot_get_option()', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
            'type'        => 'ot-get-option',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
            'section'     => 'functions'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
            'id'          => 'functions_get_option_tree',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
            'label'       => __( 'Function Reference:get_option_tree()', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
            'type'        => 'get-option-tree',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
            'section'     => 'functions'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
            'id'          => 'theme_mode_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
            'label'       => __( 'Theme Mode', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
            'type'        => 'theme-mode',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
            'section'     => 'theme_mode'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
            'id'          => 'meta_boxes_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
            'label'       => __( 'Meta Boxes', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
            'type'        => 'meta-boxes',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
            'section'     => 'meta_boxes'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
            'id'          => 'example_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
            'label'       => __( 'Code examples for front-end development.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
            'type'        => 'examples',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
            'section'     => 'examples'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
            'id'          => 'layouts_overview_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
            'label'       => __( 'What\'s a layout anyhow?', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
            'type'        => 'layouts-overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
            'section'     => 'layouts_overview'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
          )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
        )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
    // Loop over the settings and remove as needed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
    foreach( $ot_register_pages_array as $key => $page ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
      // Remove various options from the Settings UI.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
      if ( $page['id'] == 'settings' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
        // Remove the Theme Options UI
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
        if ( OT_SHOW_OPTIONS_UI == false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
          foreach( $page['sections'] as $section_key => $section ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
            if ( $section['id'] == 'create_setting' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
              unset($ot_register_pages_array[$key]['sections'][$section_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
          foreach( $page['settings'] as $setting_key => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
            if ( $setting['section'] == 'create_setting' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
              unset($ot_register_pages_array[$key]['settings'][$setting_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
        // Remove parts of the Imports UI
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
        if ( OT_SHOW_SETTINGS_IMPORT == false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
          foreach( $page['settings'] as $setting_key => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
            if ( $setting['section'] == 'import' && in_array( $setting['id'], array('import_xml_text', 'import_settings_text' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
              unset($ot_register_pages_array[$key]['settings'][$setting_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
        // Remove parts of the Export UI
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
        if ( OT_SHOW_SETTINGS_EXPORT == false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
          foreach( $page['settings'] as $setting_key => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
            if ( $setting['section'] == 'export' && in_array( $setting['id'], array('export_settings_file_text', 'export_settings_text' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
              unset($ot_register_pages_array[$key]['settings'][$setting_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
        // Remove the Layouts UI
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
        if ( OT_SHOW_NEW_LAYOUT == false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
          foreach( $page['sections'] as $section_key => $section ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
            if ( $section['id'] == 'layouts' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
              unset($ot_register_pages_array[$key]['sections'][$section_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
          foreach( $page['settings'] as $setting_key => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
            if ( $setting['section'] == 'layouts' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
              unset($ot_register_pages_array[$key]['settings'][$setting_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
      // Remove the Documentation UI.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
      if ( OT_SHOW_DOCS == false && $page['id'] == 'documentation' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
        unset( $ot_register_pages_array[$key] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
    $ot_register_pages_array = apply_filters( 'ot_register_pages_array', $ot_register_pages_array );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
    // Register the pages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
    ot_register_settings( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
        array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   385
          'id'              => ot_settings_id(),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
          'pages'           => $ot_register_pages_array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
        )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
 * Runs directly after the Theme Options are save.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
  function ot_after_theme_options_save() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
    $page = isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
    $updated = isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ? true : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
    /* only execute after the theme options are saved */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
    if ( apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) == $page && $updated ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
      /* grab a copy of the theme options */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   414
      $options = get_option( ot_options_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
      /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
      do_action( 'ot_after_theme_options_save', $options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
 * Validate the options by type before saving.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
 * This function will run on only some of the option types
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
 * as all of them don't need to be validated, just the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
 * ones users are going to input data into; because they
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
 * can't be trusted.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
 * @param     mixed     Setting value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
 * @param     string    Setting type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
 * @param     string    Setting field ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
 * @param     string    WPML field ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
 * @return    mixed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
if ( ! function_exists( 'ot_validate_setting' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
  function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
    /* exit early if missing data */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
    if ( ! $input || ! $type || ! $field_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
      return $input;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
    $input = apply_filters( 'ot_validate_setting', $input, $type, $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
    /* WPML Register and Unregister strings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
    if ( ! empty( $wmpl_id ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
      /* Allow filtering on the WPML option types */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
      $single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
      if ( in_array( $type, $single_string_types ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
        if ( ! empty( $input ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
          ot_wpml_register_string( $wmpl_id, $input );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
          ot_wpml_unregister_string( $wmpl_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
    if ( 'background' == $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
      $input['background-color'] = ot_validate_setting( $input['background-color'], 'colorpicker', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
      $input['background-image'] = ot_validate_setting( $input['background-image'], 'upload', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
      
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   480
      // Loop over array and check for values
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   481
      foreach( (array) $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   482
        if ( ! empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   483
          $has_value = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   484
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   485
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   486
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   487
      // No value; set to empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   488
      if ( ! isset( $has_value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   489
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   490
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   491
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   492
    } else if ( 'border' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   493
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   494
      // Loop over array and set errors or unset key from array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   495
      foreach( $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   496
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   497
        // Validate width
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   498
        if ( $key == 'width' && ! empty( $value ) && ! is_numeric( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   499
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   500
          $input[$key] = '0';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   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' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   503
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   504
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   505
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   506
        // Validate color
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   507
        if ( $key == 'color' && ! empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   508
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   509
          $input[$key] = ot_validate_setting( $value, 'colorpicker', $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   510
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   511
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   512
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   513
        // Unset keys with empty values.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   514
        if ( empty( $value ) && strlen( $value ) == 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   515
          unset( $input[$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   516
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   517
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   518
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   519
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   520
      if ( empty( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   521
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   522
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   523
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   524
    } else if ( 'box-shadow' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   525
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   526
      // Validate inset
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   527
      $input['inset'] = isset( $input['inset'] ) ? 'inset' : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   528
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   529
      // Validate offset-x
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   530
      $input['offset-x'] = ot_validate_setting( $input['offset-x'], 'text', $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   531
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   532
      // Validate offset-y
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   533
      $input['offset-y'] = ot_validate_setting( $input['offset-y'], 'text', $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   534
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   535
      // Validate blur-radius
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   536
      $input['blur-radius'] = ot_validate_setting( $input['blur-radius'], 'text', $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   537
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   538
      // Validate spread-radius
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   539
      $input['spread-radius'] = ot_validate_setting( $input['spread-radius'], 'text', $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   540
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   541
      // Validate color
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
      $input['color'] = ot_validate_setting( $input['color'], 'colorpicker', $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   544
      // Unset keys with empty values.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
      foreach( $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   546
        if ( empty( $value ) && strlen( $value ) == 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   547
          unset( $input[$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   548
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   549
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   550
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   551
      // Set empty array to empty string.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   552
      if ( empty( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   553
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   554
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   555
      
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
    } else if ( 'colorpicker' == $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
      /* return empty & set error */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   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 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
        $input = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   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' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   566
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   567
    } else if ( 'colorpicker-opacity' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   568
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   569
      // Not allowed
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   570
      if ( is_array( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   571
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   572
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   573
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   574
      // Validate color
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   575
      $input = ot_validate_setting( $input, 'colorpicker', $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   576
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   577
    } else if ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
      if ( ! current_user_can( 'unfiltered_html' ) && OT_ALLOW_UNFILTERED_HTML == false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
        $input = wp_kses_post( $input );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   585
    } else if ( 'dimension' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   586
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   587
      // Loop over array and set error keys or unset key from array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
      foreach( $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
        if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   590
          $errors[] = $key;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   592
        if ( empty( $value ) && strlen( $value ) == 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   593
          unset( $input[$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   595
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
      /* return 0 & set error */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
      if ( isset( $errors ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
        foreach( $errors as $error ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
          $input[$error] = '0';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   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' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   605
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   606
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   607
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   608
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   609
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   610
      if ( empty( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   611
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   612
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   614
    } else if ( 'google-fonts' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   615
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   616
      unset($input['%key%']);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   617
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   618
      // Loop over array and check for values
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   619
      if ( is_array( $input ) && ! empty( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   620
        $input = array_values( $input );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   621
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   622
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   623
      // No value; set to empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   624
      if ( empty( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   625
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   626
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   627
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   628
    } else if ( 'link-color' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   629
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   630
      // Loop over array and check for values
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   631
      if ( is_array( $input ) && ! empty( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   632
        foreach( $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
          if ( ! empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   634
            $input[$key] = ot_validate_setting( $input[$key], 'colorpicker', $field_id . '-' . $key );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   635
            $has_value = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   636
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   637
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   639
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
      // No value; set to empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   641
      if ( ! isset( $has_value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   642
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   643
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   644
               
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
    } else if ( 'measurement' == $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
      $input[0] = sanitize_text_field( $input[0] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
      
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   649
      // No value; set to empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   650
      if ( empty( $input[0] ) && strlen( $input[0] ) == 0 && empty( $input[1] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   651
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   652
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   653
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   654
    } else if ( 'spacing' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   655
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   656
      // Loop over array and set error keys or unset key from array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   657
      foreach( $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   658
        if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   659
          $errors[] = $key;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   660
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   661
        if ( empty( $value ) && strlen( $value ) == 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   662
          unset( $input[$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   663
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   664
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   665
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   666
      /* return 0 & set error */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   667
      if ( isset( $errors ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   668
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   669
        foreach( $errors as $error ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   670
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   671
          $input[$error] = '0';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   672
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   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' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   674
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   675
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   676
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   677
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   678
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   679
      if ( empty( $input ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   680
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   681
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   682
      
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
    } else if ( 'typography' == $type && isset( $input['font-color'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
      $input['font-color'] = ot_validate_setting( $input['font-color'], 'colorpicker', $field_id );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   686
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   687
      // Loop over array and check for values
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   688
      foreach( $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   689
        if ( ! empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   690
          $has_value = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   691
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   692
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   693
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   694
      // No value; set to empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   695
      if ( ! isset( $has_value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   696
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   697
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   698
      
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
    } else if ( 'upload' == $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   701
      if( filter_var( $input, FILTER_VALIDATE_INT ) === FALSE ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   702
        $input = esc_url_raw( $input );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   703
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   704
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   705
    } else if ( 'gallery' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   706
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   707
      $input = trim( $input );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   708
           
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   709
    } else if ( 'social-links' == $type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   710
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   711
      // Loop over array and check for values, plus sanitize the text field
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   712
      foreach( (array) $input as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   713
        if ( ! empty( $value ) && is_array( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   714
          foreach( (array) $value as $item_key => $item_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   715
            if ( ! empty( $item_value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   716
              $has_value = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   717
              $input[$key][$item_key] = sanitize_text_field( $item_value );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   718
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   719
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   720
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   721
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   722
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   723
      // No value; set to empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   724
      if ( ! isset( $has_value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   725
        $input = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   726
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   727
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
    $input = apply_filters( 'ot_after_validate_setting', $input, $type, $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
    return $input;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
 * Setup the default admin styles
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
if ( ! function_exists( 'ot_admin_styles' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
  function ot_admin_styles() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   749
    global $wp_styles, $post;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   750
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   751
    /* execute styles before actions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   752
    do_action( 'ot_admin_styles_before' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   753
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   754
    /* load WP colorpicker */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   755
    wp_enqueue_style( 'wp-color-picker' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   756
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   757
    /* load admin styles */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
    wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   760
    /* load the RTL stylesheet */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   761
    $wp_styles->add_data( 'ot-admin-css','rtl', true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   762
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   763
    /* Remove styles added by the Easy Digital Downloads plugin */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   764
    if ( isset( $post->post_type ) && $post->post_type == 'post' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   765
      wp_dequeue_style( 'jquery-ui-css' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   766
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   767
    /**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   768
     * Filter the screen IDs used to dequeue `jquery-ui-css`.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   769
     *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   770
     * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   771
     *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   772
     * @param array $screen_ids An array of screen IDs.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   773
     */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   774
    $screen_ids = apply_filters( 'ot_dequeue_jquery_ui_css_screen_ids', array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   775
      'toplevel_page_ot-settings', 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   776
      'optiontree_page_ot-documentation', 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   777
      'appearance_page_ot-theme-options' 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   778
    ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   779
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   780
    /* Remove styles added by the WP Review plugin and any custom pages added through filtering */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   781
    if ( in_array( get_current_screen()->id, $screen_ids ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   782
      wp_dequeue_style( 'plugin_name-admin-ui-css' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   783
      wp_dequeue_style( 'jquery-ui-css' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   784
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   785
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   786
    /* execute styles after actions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   787
    do_action( 'ot_admin_styles_after' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   788
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
 * Setup the default admin scripts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
 * @uses      add_thickbox()          Include Thickbox for file uploads
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
 * @uses      wp_enqueue_script()     Add OptionTree scripts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
 * @uses      wp_localize_script()    Used to include arbitrary Javascript data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
if ( ! function_exists( 'ot_admin_scripts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
  function ot_admin_scripts() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   808
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   809
    /* execute scripts before actions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   810
    do_action( 'ot_admin_scripts_before' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   811
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
    if ( function_exists( 'wp_enqueue_media' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
      /* WP 3.5 Media Uploader */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
      wp_enqueue_media();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
    } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
      /* Legacy Thickbox */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
      add_thickbox();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
    }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   819
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
    /* load jQuery-ui slider */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
    wp_enqueue_script( 'jquery-ui-slider' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   822
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   823
    /* load jQuery-ui datepicker */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   824
    wp_enqueue_script( 'jquery-ui-datepicker' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   825
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   826
    /* load WP colorpicker */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   827
    wp_enqueue_script( 'wp-color-picker' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   828
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   829
    /* load Ace Editor for CSS Editing */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   830
    wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js', null, '1.1.3' );   
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   831
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   832
    /* load jQuery UI timepicker addon */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   833
    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' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   834
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   835
    /* load the post formats */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   836
    if ( OT_META_BOXES == true && OT_POST_FORMATS == true ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   837
      wp_enqueue_script( 'ot-postformats', OT_URL . 'assets/js/ot-postformats.js', array( 'jquery' ), '1.0.1' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   838
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   839
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
    /* load all the required scripts */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   841
    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 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   842
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
    /* create localized JS array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
    $localized_array = array( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
      'ajax'                  => admin_url( 'admin-ajax.php' ),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   846
      'upload_text'           => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
      'remove_media_text'     => __( 'Remove Media', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
      'reset_agree'           => __( 'Are you sure you want to reset back to the defaults?', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
      'remove_no'             => __( 'You can\'t remove this! But you can edit the values.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
      'remove_agree'          => __( 'Are you sure you want to remove this?', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
      'activate_layout_agree' => __( 'Are you sure you want to activate this layout?', 'option-tree' ),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   852
      'setting_limit'         => __( 'Sorry, you can\'t have settings three levels deep.', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   853
      'delete'                => __( 'Delete Gallery', 'option-tree' ), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   854
      'edit'                  => __( 'Edit Gallery', 'option-tree' ), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   855
      'create'                => __( 'Create Gallery', 'option-tree' ), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   856
      'confirm'               => __( 'Are you sure you want to delete this Gallery?', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   857
      'date_current'          => __( 'Today', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   858
      'date_time_current'     => __( 'Now', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   859
      'date_close'            => __( 'Close', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   860
      'replace'               => __( 'Featured Image', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   861
      'with'                  => __( 'Image', 'option-tree' )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
    /* localized script attached to 'option_tree' */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
    wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   866
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   867
    /* execute scripts after actions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   868
    do_action( 'ot_admin_scripts_after' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   875
 * Returns the ID of a custom post type by post_title.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   876
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
 * @uses        get_results()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
 * @return      int
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
 * @access      public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
 * @since       2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   884
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   886
  function ot_get_media_post_ID() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   887
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   888
    // Option ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   889
    $option_id = 'ot_media_post_ID';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   890
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   891
    // Get the media post ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   892
    $post_ID = get_option( $option_id, false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   893
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   894
    // Add $post_ID to the DB
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   895
    if ( $post_ID === false || empty( $post_ID ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
      global $wpdb;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   897
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   898
      // Get the media post ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   899
      $post_ID = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE `post_title` = 'Media' AND `post_type` = 'option-tree' AND `post_status` = 'private'" );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   900
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   901
      // Add to the DB
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   902
      if ( $post_ID !== null )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   903
        update_option( $option_id, $post_ID );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   904
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   905
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   906
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   907
    return $post_ID;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   910
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   913
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   914
 * Register custom post type & create the media post used to attach images.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
 * @uses        get_results()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   918
 * @return      void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
 * @access      public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
 * @since       2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
if ( ! function_exists( 'ot_create_media_post' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
  function ot_create_media_post() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   927
    $regsiter_post_type = 'register_' . 'post_type';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   928
    $regsiter_post_type( 'option-tree', array(
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
      'labels'              => array( 'name' => __( 'Option Tree', 'option-tree' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   930
      'public'              => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
      'show_ui'             => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
      'capability_type'     => 'post',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
      'exclude_from_search' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
      'hierarchical'        => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
      'rewrite'             => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
      'supports'            => array( 'title', 'editor' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
      'can_export'          => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
      'show_in_nav_menus'   => false
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
    ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
    /* look for custom page */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
    $post_id = ot_get_media_post_ID();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
    /* no post exists */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
    if ( $post_id == 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
      /* create post object */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
      $_p = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
      $_p['post_title']     = 'Media';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   950
      $_p['post_name']      = 'media';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
      $_p['post_status']    = 'private';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
      $_p['post_type']      = 'option-tree';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
      $_p['comment_status'] = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
      $_p['ping_status']    = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
      /* insert the post into the database */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
      wp_insert_post( $_p );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   964
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
 * Setup default settings array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   969
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
if ( ! function_exists( 'ot_default_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
  function ot_default_settings() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   976
    global $wpdb;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   977
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   978
    if ( ! get_option( ot_settings_id() ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
      $section_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
      $settings_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
      $settings = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   983
      $table_name = $wpdb->prefix . 'option_tree';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   984
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   985
      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" ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
        foreach ( $old_settings as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
          /* heading is a section now */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   990
          if ( $setting->item_type == 'heading' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   992
            /* add section to the sections array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
            $settings['sections'][$section_count]['id'] = $setting->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   994
            $settings['sections'][$section_count]['title'] = $setting->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
            /* save the last section id to use in creating settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
            $section = $setting->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
            /* increment the section count */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
            $section_count++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1003
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
            /* add setting to the settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
            $settings['settings'][$settings_count]['id'] = $setting->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1006
            $settings['settings'][$settings_count]['label'] = $setting->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
            $settings['settings'][$settings_count]['desc'] = $setting->item_desc;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1008
            $settings['settings'][$settings_count]['section'] = $section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
            $settings['settings'][$settings_count]['type'] = ot_map_old_option_types( $setting->item_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
            $settings['settings'][$settings_count]['std'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1011
            $settings['settings'][$settings_count]['class'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
            /* textarea rows */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
            $rows = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1015
            if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
              if ( (int) $setting->item_options > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
                $rows = (int) $setting->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
              } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
                $rows = 15;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1022
            $settings['settings'][$settings_count]['rows'] = $rows;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
            /* post type */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1025
            $post_type = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
            if ( in_array( $settings['settings'][$settings_count]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
              if ( '' != $setting->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
                $post_type = $setting->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
              } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
                $post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
            $settings['settings'][$settings_count]['post_type'] = $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
            /* choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
            $choices = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
            if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
              if ( '' != $setting->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
                $choices = ot_convert_string_to_array( $setting->item_options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
            $settings['settings'][$settings_count]['choices'] = $choices;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
            $settings_count++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
        /* make sure each setting has a section just incase */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
        if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
          foreach( $settings['settings'] as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
            if ( '' == $setting['section'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
              $settings['settings'][$k]['section'] = $settings['sections'][0]['id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1058
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1059
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
      /* if array if not properly formed create fallback settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
      if ( ! isset( $settings['sections'] ) || ! isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
        $settings = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
          'sections' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
            array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
              'id'        => 'general',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
              'title'     => __( 'General', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
            )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
          'settings' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
            array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
              'id'        => 'sample_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
              'label'     => __( 'Sample Text Field Label', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
              'desc'      => __( 'Description for the sample text field.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
              'section'   => 'general',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
              'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
              'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
              'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
              'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
              'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
              'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
            )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
          )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
        );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1087
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
      /* update the settings array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1089
      update_option( ot_settings_id(), $settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
      /* get option tree array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1092
      $options = get_option( ot_options_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
      /* validate options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
      if ( is_array( $options ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
        foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
          if ( isset( $options[$setting['id']] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
            $content = ot_stripslashes( $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
            $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
        /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
        do_action( 'ot_before_theme_options_save', $options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
        /* update the option tree array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1113
        update_option( ot_options_id(), $options );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
 * Helper function to update the CSS option type after save.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1131
if ( ! function_exists( 'ot_save_css' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1132
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
  function ot_save_css( $options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
    /* grab a copy of the settings */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1136
    $settings = get_option( ot_settings_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1137
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
    /* has settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
    if ( isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1141
      /* loop through sections and insert CSS when needed */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1142
      foreach( $settings['settings'] as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1143
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
        /* is the CSS option type */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
        if ( isset( $setting['type'] ) && 'css' == $setting['type'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
          /* insert CSS into dynamic.css */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1148
          if ( isset( $options[$setting['id']] ) && '' !== $options[$setting['id']] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
            ot_insert_css_with_markers( $setting['id'], $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
          /* remove old CSS from dynamic.css */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1154
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
            ot_remove_old_css( $setting['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1158
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1159
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1160
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1161
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1162
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1163
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1165
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1168
 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1169
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
 * Helper function to load filters for XML mime type.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1172
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
if ( ! function_exists( 'ot_add_xml_to_upload_filetypes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1179
  function ot_add_xml_to_upload_filetypes() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1181
    add_filter( 'upload_mimes', 'ot_upload_mimes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
    add_filter( 'wp_mime_type_icon', 'ot_xml_mime_type_icon', 10, 2 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1186
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1187
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1188
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
 * Filter 'upload_mimes' and add xml. 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1191
 * @param     array     $mimes An array of valid upload mime types
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1193
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1194
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1195
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
if ( ! function_exists( 'ot_upload_mimes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1199
  function ot_upload_mimes( $mimes ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1201
    $mimes['xml'] = 'application/xml';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1203
    return $mimes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1205
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1206
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1208
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1209
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1210
 * Filters 'wp_mime_type_icon' and have xml display as a document.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1211
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
 * @param     string    $icon The mime icon
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1213
 * @param     string    $mime The mime type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1219
if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1220
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1221
  function ot_xml_mime_type_icon( $icon, $mime ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1222
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1223
    if ( $mime == 'application/xml' || $mime == 'text/xml' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1224
      return wp_mime_type_icon( 'document' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1225
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1226
    return $icon;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1227
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1228
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1229
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1230
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1231
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1232
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1233
 * Import before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1234
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1235
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1238
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
if ( ! function_exists( 'ot_import' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1241
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1242
  function ot_import() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1243
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1244
    /* check and verify import xml nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1245
    if ( isset( $_POST['import_xml_nonce'] ) && wp_verify_nonce( $_POST['import_xml_nonce'], 'import_xml_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1246
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1247
      /* import input value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1248
      $file = isset( $_POST['import_xml'] ) ? esc_url( $_POST['import_xml'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1249
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1250
      /* validate xml file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
      if ( preg_match( "/(.xml)$/i", $file ) && class_exists( 'SimpleXMLElement' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
        $settings = ot_import_xml( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1254
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1255
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1256
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
      /* cleanup, save, & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
      if ( isset( $settings ) && ! empty( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
        /* delete file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
        if ( $file ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1265
          global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1266
          $attachmentid = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$file'" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1267
          wp_delete_attachment( $attachmentid, true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1269
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1270
        /* update settings */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1271
        update_option( ot_settings_id(), $settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1272
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
        /* set message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1274
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1275
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1276
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1277
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1278
      /* redirect */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1279
      wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-xml', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1280
      exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1281
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1282
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1283
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1284
    /* check and verify import settings nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1285
    if ( isset( $_POST['import_settings_nonce'] ) && wp_verify_nonce( $_POST['import_settings_nonce'], 'import_settings_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1286
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1287
      /* textarea value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1288
      $textarea = isset( $_POST['import_settings'] ) ? unserialize( ot_decode( $_POST['import_settings'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1289
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1290
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1291
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1292
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1293
      /* is array: save & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1294
      if ( is_array( $textarea ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1295
        update_option( ot_settings_id(), $textarea );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1296
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1297
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1298
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1299
      /* redirect */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1300
      wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1301
      exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1304
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1305
    /* check and verify import theme options data nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
    if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1307
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1308
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1309
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1310
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1311
      /* textarea value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1312
      $options = isset( $_POST['import_data'] ) ? unserialize( ot_decode( $_POST['import_data'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1313
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1314
      /* get settings array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1315
      $settings = get_option( ot_settings_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1316
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1317
      /* has options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1318
      if ( is_array( $options ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1319
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1320
        /* validate options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1321
        if ( is_array( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1322
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1323
          foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1324
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
            if ( isset( $options[$setting['id']] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1327
              $content = ot_stripslashes( $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1328
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
              $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1330
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1331
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1332
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1333
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1334
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1335
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
        /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
        do_action( 'ot_before_theme_options_save', $options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
        /* update the option tree array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1341
        update_option( ot_options_id(), $options );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1342
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1344
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1345
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1346
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1347
      /* redirect accordingly */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1348
      wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-data', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1349
      exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1350
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1351
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1352
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1353
    /* check and verify import layouts nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
    if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1355
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1356
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1357
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1358
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1359
      /* textarea value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
      $layouts = isset( $_POST['import_layouts'] ) ? unserialize( ot_decode( $_POST['import_layouts'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
      /* get settings array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1363
      $settings = get_option( ot_settings_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
      /* has layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
      if ( is_array( $layouts ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1368
        /* validate options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1369
        if ( is_array( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1371
          foreach( $layouts as $key => $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
            if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
              continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1375
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1376
            $options = unserialize( ot_decode( $value ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1377
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1378
            foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1379
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1380
              if ( isset( $options[$setting['id']] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1381
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1382
                $content = ot_stripslashes( $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1383
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1384
                $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1385
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1386
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1387
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1388
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1389
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1390
            $layouts[$key] = ot_encode( serialize( $options ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1391
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1392
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1393
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1394
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1395
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1396
        /* update the option tree array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1397
        if ( isset( $layouts['active_layout'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1398
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1399
          $new_options = unserialize( ot_decode( $layouts[$layouts['active_layout']] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1400
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1401
          /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1402
          do_action( 'ot_before_theme_options_save', $new_options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1403
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1404
          update_option( ot_options_id(), $new_options );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1405
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1406
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1407
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1408
        /* update the option tree layouts array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1409
        update_option( ot_layouts_id(), $layouts );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1410
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1413
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1414
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1415
      /* redirect accordingly */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1416
      wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1417
      exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1418
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1419
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1420
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1421
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1423
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1424
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1425
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1426
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1427
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1428
 * Export before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1429
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1430
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1431
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1432
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1433
 * @since     2.0.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
if ( ! function_exists( 'ot_export' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1437
  function ot_export() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1438
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1439
    /* check and verify export settings file nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1440
    if ( isset( $_POST['export_settings_file_nonce'] ) && wp_verify_nonce( $_POST['export_settings_file_nonce'], 'export_settings_file_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1441
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1442
      ot_export_php_settings_array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1443
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1444
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1445
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1446
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1448
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1449
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1450
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
 * Reusable XMl import helper function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1453
 * @param     string    $file The path to the file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1454
 * @return    mixed     False or an array of settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
 * @since     2.0.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
if ( ! function_exists( 'ot_import_xml' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1460
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
  function ot_import_xml( $file ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
    $get_data = wp_remote_get( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1465
    if ( is_wp_error( $get_data ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1466
      return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1468
    $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1469
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1470
    if ( $rawdata ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1471
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1472
      $section_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
      $settings_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1474
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
      $section = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1476
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
      $settings = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
      $xml = new SimpleXMLElement( $rawdata );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1480
      foreach ( $xml->row as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1481
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1482
        /* heading is a section now */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1483
        if ( $value->item_type == 'heading' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1484
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1485
          /* add section to the sections array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1486
          $settings['sections'][$section_count]['id'] = (string) $value->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1487
          $settings['sections'][$section_count]['title'] = (string) $value->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1488
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1489
          /* save the last section id to use in creating settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1490
          $section = (string) $value->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1491
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
          /* increment the section count */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1493
          $section_count++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1494
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1495
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1496
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1497
          /* add setting to the settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1498
          $settings['settings'][$settings_count]['id'] = (string) $value->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1499
          $settings['settings'][$settings_count]['label'] = (string) $value->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1500
          $settings['settings'][$settings_count]['desc'] = (string) $value->item_desc;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1501
          $settings['settings'][$settings_count]['section'] = $section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1502
          $settings['settings'][$settings_count]['type'] = ot_map_old_option_types( (string) $value->item_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1503
          $settings['settings'][$settings_count]['std'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1504
          $settings['settings'][$settings_count]['class'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1505
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1506
          /* textarea rows */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1507
          $rows = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1508
          if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1509
            if ( (int) $value->item_options > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1510
              $rows = (int) $value->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1511
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1512
              $rows = 15;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1514
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1515
          $settings['settings'][$settings_count]['rows'] = $rows;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1516
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1517
          /* post type */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1518
          $post_type = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1519
          if ( in_array( $settings['settings'][$settings_count]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1520
            if ( '' != (string) $value->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1521
              $post_type = (string) $value->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1522
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1523
              $post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1524
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1525
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1526
          $settings['settings'][$settings_count]['post_type'] = $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1527
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
          /* choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1529
          $choices = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1530
          if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1531
            if ( '' != (string) $value->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1532
              $choices = ot_convert_string_to_array( (string) $value->item_options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1533
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1534
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1535
          $settings['settings'][$settings_count]['choices'] = $choices;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1536
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1537
          $settings_count++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1538
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1539
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1540
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1541
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1542
      /* make sure each setting has a section just incase */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1543
      if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
        foreach( $settings['settings'] as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
          if ( '' == $setting['section'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1546
            $settings['settings'][$k]['section'] = $settings['sections'][0]['id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1548
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1549
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1550
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1551
      return $settings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1552
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1553
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1554
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1555
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1556
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1557
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1558
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1559
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1560
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1561
 * Export the Theme Mode theme-options.php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1562
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1563
 * @return    attachment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1564
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1565
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1566
 * @since     2.0.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1567
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1568
if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1569
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1570
  function ot_export_php_settings_array() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
    $content              = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1573
    $build_settings       = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1574
    $contextual_help      = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1575
    $sections             = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1576
    $settings             = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1577
    $option_tree_settings = get_option( ot_settings_id(), array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1578
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1579
    // Domain string helper
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1580
    function ot_I18n_string( $string ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1581
      if ( ! empty( $string ) && isset( $_POST['domain'] ) && ! empty( $_POST['domain'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1582
        $domain = str_replace( ' ', '-', trim( $_POST['domain'] ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1583
        return "__( '$string', '$domain' )";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1584
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1585
      return "'$string'";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1586
    }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1587
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1588
    header( "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1589
    header( "Pragma: no-cache ");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1590
    header( "Content-Description: File Transfer" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1591
    header( 'Content-Disposition: attachment; filename="theme-options.php"');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1592
    header( "Content-Type: application/octet-stream");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1593
    header( "Content-Transfer-Encoding: binary" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1595
    /* build contextual help content */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1596
    if ( isset( $option_tree_settings['contextual_help']['content'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1597
      $help = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1598
      foreach( $option_tree_settings['contextual_help']['content'] as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1599
        $_id = isset( $value['id'] ) ? $value['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1600
        $_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1601
        $_content = ot_I18n_string( isset( $value['content'] ) ? html_entity_decode(  str_replace( "'", "\'", $value['content'] ) ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1602
        $help.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1603
        array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1604
          'id'        => '$_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1605
          'title'     => $_title,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1606
          'content'   => $_content
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1607
        ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1608
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1609
      $help = substr_replace( $help, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1610
      $contextual_help = "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1611
      'content'       => array( $help
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1612
      ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1613
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1614
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1615
    /* build contextual help sidebar */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1616
    if ( isset( $option_tree_settings['contextual_help']['sidebar'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1617
      $contextual_help.= "
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1618
      'sidebar'       => " . ot_I18n_string( html_entity_decode(  str_replace( "'", "\'", $option_tree_settings['contextual_help']['sidebar'] ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1619
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1621
    /* check that $contexual_help has a value and add to $build_settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
    if ( '' != $contextual_help ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1623
      $build_settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
    'contextual_help' => array( $contextual_help
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1625
    ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1626
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1627
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1628
    /* build sections */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1629
    if ( isset( $option_tree_settings['sections'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1630
      foreach( $option_tree_settings['sections'] as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1631
        $_id = isset( $value['id'] ) ? $value['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1632
        $_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1633
        $sections.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1634
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1635
        'id'          => '$_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1636
        'title'       => $_title
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1637
      ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1638
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1639
      $sections = substr_replace( $sections, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1640
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1641
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1642
    /* check that $sections has a value and add to $build_settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1643
    if ( '' != $sections ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1644
      $build_settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1645
    'sections'        => array( $sections
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
    )";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1647
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1648
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1649
    /* build settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1650
    if ( isset( $option_tree_settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1651
      foreach( $option_tree_settings['settings'] as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1652
        $_id = isset( $value['id'] ) ? $value['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1653
        $_label = ot_I18n_string( isset( $value['label'] ) ? str_replace( "'", "\'", $value['label'] ) : '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1654
        $_desc = ot_I18n_string( isset( $value['desc'] ) ? str_replace( "'", "\'", $value['desc'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
        $_std = isset( $value['std'] ) ? str_replace( "'", "\'", $value['std'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1656
        $_type = isset( $value['type'] ) ? $value['type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
        $_section = isset( $value['section'] ) ? $value['section'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1658
        $_rows = isset( $value['rows'] ) ? $value['rows'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
        $_post_type = isset( $value['post_type'] ) ? $value['post_type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1660
        $_taxonomy = isset( $value['taxonomy'] ) ? $value['taxonomy'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
        $_min_max_step = isset( $value['min_max_step'] ) ? $value['min_max_step'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1662
        $_class = isset( $value['class'] ) ? $value['class'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1663
        $_condition = isset( $value['condition'] ) ? $value['condition'] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1664
        $_operator = isset( $value['operator'] ) ? $value['operator'] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1665
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1666
        $choices = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
        if ( isset( $value['choices'] ) && ! empty( $value['choices'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1668
          foreach( $value['choices'] as $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1669
            $_choice_value = isset( $choice['value'] ) ? str_replace( "'", "\'", $choice['value'] ) : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1670
            $_choice_label = ot_I18n_string( isset( $choice['label'] ) ? str_replace( "'", "\'", $choice['label'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1671
            $_choice_src = isset( $choice['src'] ) ? str_replace( "'", "\'", $choice['src'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1672
            $choices.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1673
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1674
            'value'       => '$_choice_value',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1675
            'label'       => $_choice_label,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1676
            'src'         => '$_choice_src'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1677
          ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1678
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1679
          $choices = substr_replace( $choices, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
          $choices = ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
        'choices'     => array( $choices
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1682
        )";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1684
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1685
        $std = "'$_std'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1686
        if ( is_array( $_std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
          $std_array = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1688
          foreach( $_std as $_sk => $_sv ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1689
            $std_array[] = "'$_sk' => '$_sv'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1690
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1691
          $std = 'array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1692
' . implode( ",\n", $std_array ) . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1693
          )';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1694
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1695
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1696
        $setting_settings = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
        if ( isset( $value['settings'] ) && ! empty( $value['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1698
          foreach( $value['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1699
            $_setting_id = isset( $setting['id'] ) ? $setting['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1700
            $_setting_label = ot_I18n_string( isset( $setting['label'] ) ? str_replace( "'", "\'", $setting['label'] ) : '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1701
            $_setting_desc = ot_I18n_string( isset( $setting['desc'] ) ? str_replace( "'", "\'", $setting['desc'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1702
            $_setting_std = isset( $setting['std'] ) ? $setting['std'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1703
            $_setting_type = isset( $setting['type'] ) ? $setting['type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1704
            $_setting_rows = isset( $setting['rows'] ) ? $setting['rows'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1705
            $_setting_post_type = isset( $setting['post_type'] ) ? $setting['post_type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1706
            $_setting_taxonomy = isset( $setting['taxonomy'] ) ? $setting['taxonomy'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1707
            $_setting_min_max_step = isset( $setting['min_max_step'] ) ? $setting['min_max_step'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1708
            $_setting_class = isset( $setting['class'] ) ? $setting['class'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1709
            $_setting_condition = isset( $setting['condition'] ) ? $setting['condition'] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1710
            $_setting_operator = isset( $setting['operator'] ) ? $setting['operator'] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1711
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1712
            $setting_choices = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1713
            if ( isset( $setting['choices'] ) && ! empty( $setting['choices'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
              foreach( $setting['choices'] as $setting_choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
                $_setting_choice_value = isset( $setting_choice['value'] ) ? $setting_choice['value'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1716
                $_setting_choice_label = ot_I18n_string( isset( $setting_choice['label'] ) ? str_replace( "'", "\'", $setting_choice['label'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1717
                $_setting_choice_src = isset( $setting_choice['src'] ) ? str_replace( "'", "\'", $setting_choice['src'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1718
                $setting_choices.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1719
              array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
                'value'       => '$_setting_choice_value',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1721
                'label'       => $_setting_choice_label,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
                'src'         => '$_setting_choice_src'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
              ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
              $setting_choices = substr_replace( $setting_choices, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1726
              $setting_choices = ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
            'choices'     => array( $setting_choices
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1728
            )";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1729
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1730
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1731
            $setting_std = "'$_setting_std'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1732
            if ( is_array( $_setting_std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1733
              $setting_std_array = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1734
              foreach( $_setting_std as $_ssk => $_ssv ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
                $setting_std_array[] = "'$_ssk' => '$_ssv'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1736
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1737
              $setting_std = 'array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1738
' . implode( ",\n", $setting_std_array ) . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1739
              )';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1740
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1741
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1742
            $setting_settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1744
            'id'          => '$_setting_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1745
            'label'       => $_setting_label,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1746
            'desc'        => $_setting_desc,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1747
            'std'         => $setting_std,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1748
            'type'        => '$_setting_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1749
            'rows'        => '$_setting_rows',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1750
            'post_type'   => '$_setting_post_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1751
            'taxonomy'    => '$_setting_taxonomy',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1752
            'min_max_step'=> '$_setting_min_max_step',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1753
            'class'       => '$_setting_class',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1754
            'condition'   => '$_setting_condition',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1755
            'operator'    => '$_setting_operator'$setting_choices
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1756
          ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1757
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1758
          $setting_settings = substr_replace( $setting_settings, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1759
          $setting_settings = ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1760
        'settings'    => array( $setting_settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1761
        )";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1762
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1763
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
        $settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
        'id'          => '$_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1767
        'label'       => $_label,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1768
        'desc'        => $_desc,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1769
        'std'         => $std,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1770
        'type'        => '$_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1771
        'section'     => '$_section',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1772
        'rows'        => '$_rows',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
        'post_type'   => '$_post_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1774
        'taxonomy'    => '$_taxonomy',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
        'min_max_step'=> '$_min_max_step',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1776
        'class'       => '$_class',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1777
        'condition'   => '$_condition',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1778
        'operator'    => '$_operator'$choices$setting_settings
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1779
      ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
      $settings = substr_replace( $settings, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1783
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
    /* check that $sections has a value and add to $build_settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1785
    if ( '' != $settings ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
      $build_settings.= ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1787
    'settings'        => array( $settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1788
    )";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1789
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1790
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1791
    $content.= "<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1792
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1793
 * Initialize the custom theme options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1794
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1795
add_action( 'init', 'custom_theme_options' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1796
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
 * Build the custom settings & update OptionTree.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
function custom_theme_options() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1801
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1802
  /* OptionTree is not loaded yet, or this is not an admin request */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1803
  if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1804
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1805
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1806
  /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1807
   * Get a copy of the saved settings array. 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
   */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1809
  \$saved_settings = get_option( ot_settings_id(), array() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1811
  /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
   * Custom settings array that will eventually be 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
   * passes to the OptionTree Settings API Class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1814
   */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
  \$custom_settings = array( $build_settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
  );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1817
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1818
  /* allow settings to be filtered before saving */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1819
  \$custom_settings = apply_filters( ot_settings_id() . '_args', \$custom_settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1820
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1821
  /* settings are not the same update the DB */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
  if ( \$saved_settings !== \$custom_settings ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1823
    update_option( ot_settings_id(), \$custom_settings ); 
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1824
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1825
  
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1826
  /* Lets OptionTree know the UI Builder is being overridden */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1827
  global \$ot_has_custom_theme_options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1828
  \$ot_has_custom_theme_options = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1829
  
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1830
}";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1832
    echo $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1833
    die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1834
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1835
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1836
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1837
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1838
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1839
 * Save settings array before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1840
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1841
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1842
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1843
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1844
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1845
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1846
if ( ! function_exists( 'ot_save_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1847
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1848
  function ot_save_settings() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1849
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
    /* check and verify import settings nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1851
    if ( isset( $_POST['option_tree_settings_nonce'] ) && wp_verify_nonce( $_POST['option_tree_settings_nonce'], 'option_tree_settings_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1852
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1853
      /* settings value */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1854
      $settings = isset( $_POST[ot_settings_id()] ) ? $_POST[ot_settings_id()] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1855
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1856
      /* validate sections */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1857
      if ( isset( $settings['sections'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1858
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
        /* fix numeric keys since drag & drop will change them */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1860
        $settings['sections'] = array_values( $settings['sections'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1861
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1862
        /* loop through sections */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1863
        foreach( $settings['sections'] as $k => $section ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1864
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
          /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1866
          if ( ( ! isset( $section['title'] ) && ! isset( $section['id'] ) ) || ( '' == $section['title'] && '' == $section['id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1867
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1868
            unset( $settings['sections'][$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1869
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1870
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1871
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1872
            /* validate label */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1873
            if ( '' != $section['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1874
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1875
             $settings['sections'][$k]['title'] = wp_kses_post( $section['title'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1876
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1877
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1878
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1879
            /* missing title set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1880
            if ( ! isset( $section['title'] ) || '' == $section['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1881
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1882
              $settings['sections'][$k]['title'] = wp_kses_post( $section['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1883
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1884
            /* missing ID set to title */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1885
            } else if ( ! isset( $section['id'] ) || '' == $section['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1886
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1887
              $section['id'] = wp_kses_post( $section['title'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1888
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1889
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1890
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1891
            /* sanitize ID once everything has been checked first */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1892
            $settings['sections'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $section['id'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1893
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1894
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1895
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1896
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1897
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1898
        $settings['sections'] = ot_stripslashes( $settings['sections'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1899
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1900
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1901
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1902
      /* validate settings by looping over array as many times as it takes */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
      if ( isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
        $settings['settings'] = ot_validate_settings_array( $settings['settings'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1907
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1908
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1909
      /* validate contextual_help */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1910
      if ( isset( $settings['contextual_help']['content'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1911
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1912
        /* fix numeric keys since drag & drop will change them */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1913
        $settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1914
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1915
        /* loop through content */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1916
        foreach( $settings['contextual_help']['content'] as $k => $content ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1917
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1918
          /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1919
          if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' == $content['title'] && '' == $content['id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1920
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1921
            unset( $settings['contextual_help']['content'][$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1922
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1924
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1925
            /* validate label */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1926
            if ( '' != $content['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1927
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1928
             $settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['title'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1929
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1930
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1931
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1932
            /* missing title set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1933
            if ( ! isset( $content['title'] ) || '' == $content['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1935
              $settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1936
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1937
            /* missing ID set to title */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1938
            } else if ( ! isset( $content['id'] ) || '' == $content['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1940
              $content['id'] = wp_kses_post( $content['title'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1942
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1943
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1944
            /* sanitize ID once everything has been checked first */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
            $settings['contextual_help']['content'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $content['id'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1946
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1947
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1948
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1949
          /* validate textarea description */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1950
          if ( isset( $content['content'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1951
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1952
            $settings['contextual_help']['content'][$k]['content'] = wp_kses_post( $content['content'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1953
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1954
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1955
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1956
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1957
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1958
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1959
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1960
      /* validate contextual_help sidebar */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1961
      if ( isset( $settings['contextual_help']['sidebar'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1963
        $settings['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1964
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1965
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1966
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1967
      $settings['contextual_help'] = ot_stripslashes( $settings['contextual_help'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1968
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1969
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1970
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1971
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1972
      /* is array: save & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1973
      if ( is_array( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1974
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1975
        /* WPML unregister ID's that have been removed */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1976
        if ( function_exists( 'icl_unregister_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1977
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1978
          $current = get_option( ot_settings_id() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1979
          $options = get_option( ot_options_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1980
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1981
          if ( isset( $current['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1982
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1983
            /* Empty ID array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1984
            $new_ids = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1985
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1986
            /* Build the WPML IDs array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1987
            foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1988
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1989
              if ( $setting['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1990
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1991
                $new_ids[] = $setting['id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1993
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1994
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1995
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1996
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1997
            /* Remove missing IDs from WPML */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1998
            foreach( $current['settings'] as $current_setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1999
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2000
              if ( ! in_array( $current_setting['id'], $new_ids ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2001
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2002
                if ( ! empty( $options[$current_setting['id']] ) && in_array( $current_setting['type'], array( 'list-item', 'slider' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2003
                  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2004
                  foreach( $options[$current_setting['id']] as $key => $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2005
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2006
                    foreach( $value as $ckey => $cvalue ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2007
                      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2008
                      ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2009
                      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2010
                    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2011
                  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2012
                  }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2013
                
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2014
                } else if ( ! empty( $options[$current_setting['id']] ) && $current_setting['type'] == 'social-icons' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2015
                  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2016
                  foreach( $options[$current_setting['id']] as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2017
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2018
                    foreach( $value as $ckey => $cvalue ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2019
                      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2020
                      ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2021
                      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2022
                    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2023
                  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2024
                  }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2025
                  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2026
                } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2027
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2028
                  ot_wpml_unregister_string( $current_setting['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2029
                  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2030
                }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2031
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2032
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2033
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2034
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2035
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2036
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2037
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2038
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2039
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2040
        update_option( ot_settings_id(), $settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2041
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2042
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2043
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2044
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2045
      /* redirect */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2046
      wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'save-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2047
      exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2048
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2049
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2050
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2051
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2052
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2053
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2054
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2055
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2056
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2057
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2058
 * Validate the settings array before save.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2059
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2060
 * This function will loop over the settings array as many 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2061
 * times as it takes to validate every sub setting.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2062
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2063
 * @param     array     $settings The array of settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2064
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2065
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2066
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2067
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2068
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2069
if ( ! function_exists( 'ot_validate_settings_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2070
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2071
  function ot_validate_settings_array( $settings = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2072
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2073
    /* validate settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2074
    if ( count( $settings ) > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2075
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2076
      /* fix numeric keys since drag & drop will change them */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2077
      $settings = array_values( $settings );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2078
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2079
      /* loop through settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2080
      foreach( $settings as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2081
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2082
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2083
        /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2084
        if ( ( ! isset( $setting['label'] ) && ! isset( $setting['id'] ) ) || ( '' == $setting['label'] && '' == $setting['id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2085
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2086
          unset( $settings[$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2087
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2088
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2089
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2090
          /* validate label */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2091
          if ( '' != $setting['label'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2092
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2093
            $settings[$k]['label'] = wp_kses_post( $setting['label'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2094
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2095
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2096
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2097
          /* missing label set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2098
          if ( ! isset( $setting['label'] ) || '' == $setting['label'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2099
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2100
            $settings[$k]['label'] = $setting['id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2101
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2102
          /* missing ID set to label */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2103
          } else if ( ! isset( $setting['id'] ) || '' == $setting['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2104
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2105
            $setting['id'] = wp_kses_post( $setting['label'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2106
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2107
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2108
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2109
          /* sanitize ID once everything has been checked first */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2110
          $settings[$k]['id'] = ot_sanitize_option_id( wp_kses_post( $setting['id'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2111
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2112
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2113
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2114
        /* validate description */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2115
        if ( '' != $setting['desc']  ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2116
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2117
          $settings[$k]['desc'] = wp_kses_post( $setting['desc'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2118
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2119
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2120
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2121
        /* validate choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2122
        if ( isset( $setting['choices'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2123
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2124
          /* loop through choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2125
          foreach( $setting['choices'] as $ck => $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2126
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
            /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2128
            if ( ( ! isset( $choice['label'] ) && ! isset( $choice['value'] ) ) || ( '' == $choice['label'] && '' == $choice['value'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2129
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2130
              unset( $setting['choices'][$ck] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2131
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2132
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2133
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2134
              /* missing label set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2135
              if ( ! isset( $choice['label'] ) || '' == $choice['label'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2136
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2137
                $setting['choices'][$ck]['label'] = wp_kses_post( $choice['value'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2138
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2139
              /* missing value set to label */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2140
              } else if ( ! isset( $choice['value'] ) || '' == $choice['value'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2141
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2142
                $setting['choices'][$ck]['value'] = ot_sanitize_option_id( wp_kses_post( $choice['label'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2143
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2144
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2145
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2146
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2147
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2148
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2149
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2150
          /* update keys and push new array values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2151
          $settings[$k]['choices'] = array_values( $setting['choices'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2152
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2153
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2154
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2155
        /* validate sub settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2156
        if ( isset( $setting['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2157
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2158
          $settings[$k]['settings'] = ot_validate_settings_array( $setting['settings'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2159
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2160
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2161
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2162
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2163
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2164
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2165
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2166
    /* return array but strip those damn slashes out first!!! */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2167
    return ot_stripslashes( $settings );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2168
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2169
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2171
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2172
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2173
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2174
 * Save layouts array before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2175
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2176
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2177
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2178
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2179
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2180
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2181
if ( ! function_exists( 'ot_modify_layouts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2183
  function ot_modify_layouts() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2184
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2185
    /* check and verify modify layouts nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2186
    if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2187
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2188
      /* previous layouts value */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2189
      $option_tree_layouts = get_option( ot_layouts_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2190
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2191
      /* new layouts value */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2192
      $layouts = isset( $_POST[ot_layouts_id()] ) ? $_POST[ot_layouts_id()] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2193
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2194
      /* rebuild layout array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2195
      $rebuild = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2196
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2197
      /* validate layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2198
      if ( is_array( $layouts ) && ! empty( $layouts ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2199
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2200
        /* setup active layout */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2201
        if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2202
          $rebuild['active_layout'] = $layouts['active_layout'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2203
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2204
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2205
        /* add new and overwrite active layout */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2206
        if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2207
          $rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2208
          $rebuild[$rebuild['active_layout']] = ot_encode( serialize( get_option( ot_options_id() ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2209
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2210
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2211
        $first_layout = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2212
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2213
        /* loop through layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2214
        foreach( $layouts as $key => $layout ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2215
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2216
          /* skip over active layout key */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2217
          if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2218
            continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2219
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2220
          /* check if the key exists then set value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2221
          if ( isset( $option_tree_layouts[$key] ) && ! empty( $option_tree_layouts[$key] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2222
            $rebuild[$key] = $option_tree_layouts[$key];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2223
            if ( '' == $first_layout ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2224
              $first_layout = $key;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2225
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2226
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2227
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2228
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2229
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2230
        if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[$rebuild['active_layout']] ) && ! empty( $first_layout ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2231
          $rebuild['active_layout'] = $first_layout;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2232
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2233
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2234
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2235
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2236
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2237
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2238
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2239
      /* is array: save & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2240
      if ( count( $rebuild ) > 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2241
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2242
        /* rebuild the theme options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2243
        $rebuild_option_tree = unserialize( ot_decode( $rebuild[$rebuild['active_layout']] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2244
        if ( is_array( $rebuild_option_tree ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2245
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2246
          /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2247
          do_action( 'ot_before_theme_options_save', $rebuild_option_tree );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2248
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2249
          update_option( ot_options_id(), $rebuild_option_tree );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2250
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2251
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2252
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2253
        /* rebuild the layouts */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2254
        update_option( ot_layouts_id(), $rebuild );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2255
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2256
        /* change message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2257
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2258
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2259
      } else if ( count( $rebuild ) <= 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2260
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2261
        /* delete layouts option */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2262
        delete_option( ot_layouts_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2263
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2264
        /* change message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2265
        $message = 'deleted';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2266
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2267
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2268
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2269
      /* redirect */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2270
      if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2271
        $query_args = esc_url_raw( add_query_arg( array( 'settings-updated' => 'layout' ), remove_query_arg( array( 'action', 'message' ), $_POST['_wp_http_referer'] ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2272
      } else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2273
        $query_args = esc_url_raw( add_query_arg( array( 'action' => 'save-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2274
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2275
      wp_redirect( $query_args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2276
      exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2277
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2278
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2279
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2280
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2281
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2282
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2283
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2284
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2285
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2286
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2287
 * Helper function to display alert messages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2288
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2289
 * @param     array     Page array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2290
 * @return    mixed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2291
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2292
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2293
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2294
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2295
if ( ! function_exists( 'ot_alert_message' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2296
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2297
  function ot_alert_message( $page = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2298
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2299
    if ( empty( $page ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2300
      return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2301
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2302
    $before = apply_filters( 'ot_before_page_messages', '', $page );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2303
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2304
    if ( $before ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2305
      return $before;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2306
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2307
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2308
    $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2309
    $message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2310
    $updated = isset( $_REQUEST['settings-updated'] ) ? $_REQUEST['settings-updated'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2311
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2312
    if ( $action == 'save-settings' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2313
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2314
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2315
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2316
        return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings updated.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2317
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2318
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2319
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2320
        return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be saved.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2321
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2322
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2323
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2324
    } else if ( $action == 'import-xml' || $action == 'import-settings' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2325
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2326
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2327
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2328
        return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings Imported.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2329
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2330
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2331
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2332
        return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be imported.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2333
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2334
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2335
    } else if ( $action == 'import-data' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2336
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2337
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2338
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2339
        return '<div id="message" class="updated fade below-h2"><p>' . __( 'Data Imported.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2340
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2341
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2342
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2343
        return '<div id="message" class="error fade below-h2"><p>' . __( 'Data could not be imported.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2344
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2345
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2346
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2347
    } else if ( $action == 'import-layouts' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2348
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2349
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2350
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2351
        return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Imported.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2352
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2353
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2354
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2355
        return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be imported.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2356
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2357
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2358
           
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2359
    } else if ( $action == 'save-layouts' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2360
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2361
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2362
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2363
        return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Updated.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2364
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2365
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2366
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2367
        return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be updated.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2368
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2369
      } else if ( $message == 'deleted' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2370
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2371
        return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts have been deleted.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2372
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2373
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2374
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2375
    } else if ( $updated == 'layout' ) {  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2376
       
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2377
      return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layout activated.', 'option-tree' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2378
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2379
    } else if ( $action == 'reset' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
      return '<div id="message" class="updated fade below-h2"><p>' . $page['reset_message'] . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2382
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2383
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2384
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2385
    do_action( 'ot_custom_page_messages', $page );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2386
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2387
    if ( $updated == 'true' ) {  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2388
       
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2389
      return '<div id="message" class="updated fade below-h2"><p>' . $page['updated_message'] . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2390
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2391
    } 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2392
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2393
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2394
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2395
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2396
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2397
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2398
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2399
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2400
 * Setup the default option types.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2401
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2402
 * The returned option types are filterable so you can add your own.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2403
 * This is not a task for a beginner as you'll need to add the function
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2404
 * that displays the option to the user and validate the saved data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2405
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2406
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2407
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2408
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2409
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2410
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2411
if ( ! function_exists( 'ot_option_types_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2412
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2413
  function ot_option_types_array() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2414
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2415
    return apply_filters( 'ot_option_types_array', array( 
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2416
      'background'                => __('Background', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2417
      'border'                    => __('Border', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2418
      'box-shadow'                => __('Box Shadow', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2419
      'category-checkbox'         => __('Category Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2420
      'category-select'           => __('Category Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2421
      'checkbox'                  => __('Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2422
      'colorpicker'               => __('Colorpicker', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2423
      'colorpicker-opacity'       => __('Colorpicker Opacity', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2424
      'css'                       => __('CSS', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2425
      'custom-post-type-checkbox' => __('Custom Post Type Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2426
      'custom-post-type-select'   => __('Custom Post Type Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2427
      'date-picker'               => __('Date Picker', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2428
      'date-time-picker'          => __('Date Time Picker', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2429
      'dimension'                 => __('Dimension', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2430
      'gallery'                   => __('Gallery', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2431
      'google-fonts'              => __('Google Fonts', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2432
      'javascript'                => __('JavaScript', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2433
      'link-color'                => __('Link Color', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2434
      'list-item'                 => __('List Item', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2435
      'measurement'               => __('Measurement', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2436
      'numeric-slider'            => __('Numeric Slider', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2437
      'on-off'                    => __('On/Off', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2438
      'page-checkbox'             => __('Page Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2439
      'page-select'               => __('Page Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2440
      'post-checkbox'             => __('Post Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2441
      'post-select'               => __('Post Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2442
      'radio'                     => __('Radio', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2443
      'radio-image'               => __('Radio Image', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2444
      'select'                    => __('Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2445
      'sidebar-select'            => __('Sidebar Select',  'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2446
      'slider'                    => __('Slider', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2447
      'social-links'              => __('Social Links', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2448
      'spacing'                   => __('Spacing', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2449
      'tab'                       => __('Tab', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2450
      'tag-checkbox'              => __('Tag Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2451
      'tag-select'                => __('Tag Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2452
      'taxonomy-checkbox'         => __('Taxonomy Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2453
      'taxonomy-select'           => __('Taxonomy Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2454
      'text'                      => __('Text', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2455
      'textarea'                  => __('Textarea', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2456
      'textarea-simple'           => __('Textarea Simple', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2457
      'textblock'                 => __('Textblock', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2458
      'textblock-titled'          => __('Textblock Titled', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2459
      'typography'                => __('Typography', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2460
      'upload'                    => __('Upload', 'option-tree')
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2461
    ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2462
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2463
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2464
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2465
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2466
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2467
 * Map old option types for rebuilding XML and Table data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2468
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2469
 * @param     string      $type The old option type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2470
 * @return    string      The new option type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2471
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2472
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2473
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2474
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2475
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2476
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2477
  function ot_map_old_option_types( $type = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2478
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2479
    if ( ! $type ) 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2480
      return 'text';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2481
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2482
    $types = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2483
      'background'        => 'background',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2484
      'category'          => 'category-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2485
      'categories'        => 'category-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2486
      'checkbox'          => 'checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2487
      'colorpicker'       => 'colorpicker',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2488
      'css'               => 'css',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2489
      'custom_post'       => 'custom-post-type-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2490
      'custom_posts'      => 'custom-post-type-checkbox',                     
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2491
      'input'             => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2492
      'image'             => 'upload',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2493
      'measurement'       => 'measurement',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2494
      'page'              => 'page-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2495
      'pages'             => 'page-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2496
      'post'              => 'post-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2497
      'posts'             => 'post-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2498
      'radio'             => 'radio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2499
      'select'            => 'select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2500
      'slider'            => 'slider',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2501
      'tag'               => 'tag-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2502
      'tags'              => 'tag-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2503
      'textarea'          => 'textarea',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2504
      'textblock'         => 'textblock',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2505
      'typography'        => 'typography',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2506
      'upload'            => 'upload'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2507
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2508
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2509
    if ( isset( $types[$type] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2510
      return $types[$type];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2511
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2512
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2513
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2514
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2515
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2516
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2517
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2518
 * Filters the typography font-family to add Google fonts dynamically.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2519
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2520
 * @param     array     $families An array of all recognized font families.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2521
 * @param     string    $field_id ID of the feild being filtered.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2522
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2523
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2524
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2525
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2526
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2527
function ot_google_font_stack( $families, $field_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2528
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2529
  $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2530
  $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2531
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2532
  if ( ! empty( $ot_set_google_fonts ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2533
    foreach( $ot_set_google_fonts as $id => $sets ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2534
      foreach( $sets as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2535
        $family = isset( $value['family'] ) ? $value['family'] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2536
        if ( $family && isset( $ot_google_fonts[$family] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2537
          $spaces = explode(' ', $ot_google_fonts[$family]['family'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2538
          $font_stack = count( $spaces ) > 1 ? '"' . $ot_google_fonts[$family]['family'] . '"': $ot_google_fonts[$family]['family'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2539
          $families[$family] = apply_filters( 'ot_google_font_stack', $font_stack, $family, $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2540
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2541
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2542
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2543
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2544
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2545
  return $families;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2546
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2547
add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2548
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2549
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2550
 * Recognized font families
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2551
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2552
 * Returns an array of all recognized font families.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2553
 * Keys are intended to be stored in the database
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2554
 * while values are ready for display in html.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2555
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2556
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2557
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2558
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2559
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2560
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2561
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2562
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2563
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2564
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2565
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2566
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2567
  function ot_recognized_font_families( $field_id = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2568
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2569
    $families = array(
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2570
      'arial'     => 'Arial',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2571
      'georgia'   => 'Georgia',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2572
      'helvetica' => 'Helvetica',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2573
      'palatino'  => 'Palatino',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2574
      'tahoma'    => 'Tahoma',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2575
      'times'     => '"Times New Roman", sans-serif',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2576
      'trebuchet' => 'Trebuchet',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2577
      'verdana'   => 'Verdana'
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2578
    );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2579
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2580
    return apply_filters( 'ot_recognized_font_families', $families, $field_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2581
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2582
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2583
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2584
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2585
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2586
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2587
 * Recognized font sizes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2588
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2589
 * Returns an array of all recognized font sizes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2590
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2591
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2592
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2593
 * @param     string  $field_id ID that's passed to the filters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2594
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2595
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2596
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2597
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2598
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2599
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2600
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2601
  function ot_recognized_font_sizes( $field_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2602
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2603
    $range = ot_range( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2604
      apply_filters( 'ot_font_size_low_range', 0, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2605
      apply_filters( 'ot_font_size_high_range', 150, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2606
      apply_filters( 'ot_font_size_range_interval', 1, $field_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2607
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2608
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2609
    $unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2610
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2611
    foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2612
      $range[$k] = $v . $unit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2613
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2614
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2615
    return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2616
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2617
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2618
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2619
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2620
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2621
 * Recognized font styles
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2622
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2623
 * Returns an array of all recognized font styles.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2624
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2625
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2626
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2627
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2628
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2629
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2630
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2631
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2632
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2633
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2634
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2635
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2636
  function ot_recognized_font_styles( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2637
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2638
    return apply_filters( 'ot_recognized_font_styles', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2639
      'normal'  => 'Normal',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2640
      'italic'  => 'Italic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2641
      'oblique' => 'Oblique',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2642
      'inherit' => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2643
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2644
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2645
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2646
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2647
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2648
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2649
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2650
 * Recognized font variants
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2651
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2652
 * Returns an array of all recognized font variants.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2653
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2654
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2655
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2656
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2657
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2658
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2659
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2660
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2661
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2662
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2663
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2664
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2665
  function ot_recognized_font_variants( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2666
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2667
    return apply_filters( 'ot_recognized_font_variants', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2668
      'normal'      => 'Normal',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2669
      'small-caps'  => 'Small Caps',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2670
      'inherit'     => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2671
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2672
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2673
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2674
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2675
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2676
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2677
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2678
 * Recognized font weights
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2679
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2680
 * Returns an array of all recognized font weights.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2681
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2682
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2683
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2684
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2685
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2686
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2687
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2688
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2689
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2690
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2691
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2692
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2693
  function ot_recognized_font_weights( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2694
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2695
    return apply_filters( 'ot_recognized_font_weights', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2696
      'normal'    => 'Normal',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2697
      'bold'      => 'Bold',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2698
      'bolder'    => 'Bolder',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2699
      'lighter'   => 'Lighter',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2700
      '100'       => '100',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2701
      '200'       => '200',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2702
      '300'       => '300',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2703
      '400'       => '400',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2704
      '500'       => '500',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2705
      '600'       => '600',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2706
      '700'       => '700',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2707
      '800'       => '800',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2708
      '900'       => '900',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2709
      'inherit'   => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2710
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2711
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2712
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2713
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2714
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2715
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2716
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2717
 * Recognized letter spacing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2718
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2719
 * Returns an array of all recognized line heights.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2720
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2721
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2722
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2723
 * @param     string  $field_id ID that's passed to the filters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2724
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2725
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2726
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2727
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2728
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2729
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2730
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2731
  function ot_recognized_letter_spacing( $field_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2732
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2733
    $range = ot_range( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2734
      apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2735
      apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2736
      apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2737
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2738
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2739
    $unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2740
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2741
    foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2742
      $range[$k] = $v . $unit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2743
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2744
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2745
    return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2746
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2747
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2748
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2749
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2750
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2751
 * Recognized line heights
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2752
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2753
 * Returns an array of all recognized line heights.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2754
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2755
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2756
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2757
 * @param     string  $field_id ID that's passed to the filters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2758
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2759
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2760
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2761
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2762
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2763
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2764
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2765
  function ot_recognized_line_heights( $field_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2766
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2767
    $range = ot_range( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2768
      apply_filters( 'ot_line_height_low_range', 0, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2769
      apply_filters( 'ot_line_height_high_range', 150, $field_id ), 
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2770
      apply_filters( 'ot_line_height_range_interval', 1, $field_id )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2771
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2772
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2773
    $unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2774
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2775
    foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2776
      $range[$k] = $v . $unit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2777
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2778
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2779
    return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2780
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2781
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2782
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2783
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2784
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2785
 * Recognized text decorations
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2786
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2787
 * Returns an array of all recognized text decorations.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2788
 * Keys are intended to be stored in the database
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2789
 * while values are ready for display in html.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2790
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2791
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2792
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2793
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2794
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2795
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2796
 * @since     2.0.10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2797
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2798
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2799
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2800
  function ot_recognized_text_decorations( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2801
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2802
    return apply_filters( 'ot_recognized_text_decorations', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2803
      'blink'         => 'Blink',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2804
      'inherit'       => 'Inherit',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2805
      'line-through'  => 'Line Through',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2806
      'none'          => 'None',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2807
      'overline'      => 'Overline',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2808
      'underline'     => 'Underline'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2809
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2810
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2811
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2812
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2813
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2814
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2815
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2816
 * Recognized text transformations
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2817
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2818
 * Returns an array of all recognized text transformations.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2819
 * Keys are intended to be stored in the database
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2820
 * while values are ready for display in html.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2821
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2822
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2823
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2824
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2825
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2826
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2827
 * @since     2.0.10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2828
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2829
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2830
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2831
  function ot_recognized_text_transformations( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2832
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2833
    return apply_filters( 'ot_recognized_text_transformations', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2834
      'capitalize'  => 'Capitalize',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2835
      'inherit'     => 'Inherit',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2836
      'lowercase'   => 'Lowercase',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2837
      'none'        => 'None',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2838
      'uppercase'   => 'Uppercase'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2839
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2840
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2841
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2842
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2843
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2844
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2845
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2846
 * Recognized background repeat
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2847
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2848
 * Returns an array of all recognized background repeat values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2849
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2850
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2851
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2852
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2853
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2854
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2855
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2856
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2857
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2858
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2859
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2860
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2861
  function ot_recognized_background_repeat( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2862
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2863
    return apply_filters( 'ot_recognized_background_repeat', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2864
      'no-repeat' => 'No Repeat',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2865
      'repeat'    => 'Repeat All',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2866
      'repeat-x'  => 'Repeat Horizontally',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2867
      'repeat-y'  => 'Repeat Vertically',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2868
      'inherit'   => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2869
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2870
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2871
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2872
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2873
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2874
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2875
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2876
 * Recognized background attachment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2877
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2878
 * Returns an array of all recognized background attachment values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2879
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2880
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2881
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2882
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2883
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2884
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2885
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2886
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2887
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2888
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2889
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2890
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2891
  function ot_recognized_background_attachment( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2892
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2893
    return apply_filters( 'ot_recognized_background_attachment', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2894
      "fixed"   => "Fixed",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2895
      "scroll"  => "Scroll",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2896
      "inherit" => "Inherit"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2897
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2898
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2899
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2900
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2901
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2902
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2903
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2904
 * Recognized background position
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2905
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2906
 * Returns an array of all recognized background position values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2907
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2908
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2909
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2910
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2911
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2912
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2913
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2914
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2915
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2916
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2917
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2918
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2919
  function ot_recognized_background_position( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2920
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2921
    return apply_filters( 'ot_recognized_background_position', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2922
      "left top"      => "Left Top",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2923
      "left center"   => "Left Center",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2924
      "left bottom"   => "Left Bottom",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2925
      "center top"    => "Center Top",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2926
      "center center" => "Center Center",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2927
      "center bottom" => "Center Bottom",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2928
      "right top"     => "Right Top",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2929
      "right center"  => "Right Center",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2930
      "right bottom"  => "Right Bottom"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2931
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2932
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2933
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2934
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2935
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2936
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2937
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2938
 * Border Styles
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2939
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2940
 * Returns an array of all available style types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2941
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2942
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2943
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2944
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2945
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2946
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2947
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2948
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2949
if ( ! function_exists( 'ot_recognized_border_style_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2950
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2951
  function ot_recognized_border_style_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2952
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2953
    return apply_filters( 'ot_recognized_border_style_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2954
      'hidden' => 'Hidden',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2955
      'dashed' => 'Dashed',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2956
      'solid'  => 'Solid',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2957
      'double' => 'Double',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2958
      'groove' => 'Groove',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2959
      'ridge'  => 'Ridge',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2960
      'inset'  => 'Inset',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2961
      'outset' => 'Outset',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2962
    ), $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2963
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2964
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2965
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2966
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2967
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2968
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2969
 * Border Units
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2970
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2971
 * Returns an array of all available unit types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2972
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2973
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2974
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2975
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2976
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2977
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2978
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2979
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2980
if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2981
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2982
  function ot_recognized_border_unit_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2983
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2984
    return apply_filters( 'ot_recognized_border_unit_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2985
      'px' => 'px',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2986
      '%'  => '%',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2987
      'em' => 'em',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2988
      'pt' => 'pt'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2989
    ), $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2990
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2991
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2992
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2993
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2994
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2995
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2996
 * Dimension Units
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2997
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2998
 * Returns an array of all available unit types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2999
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3000
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3001
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3002
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3003
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3004
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3005
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3006
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3007
if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3008
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3009
  function ot_recognized_dimension_unit_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3010
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3011
    return apply_filters( 'ot_recognized_dimension_unit_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3012
      'px' => 'px',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3013
      '%'  => '%',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3014
      'em' => 'em',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3015
      'pt' => 'pt'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3016
    ), $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3017
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3018
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3019
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3020
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3021
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3022
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3023
 * Spacing Units
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3024
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3025
 * Returns an array of all available unit types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3026
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3027
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3028
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3029
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3030
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3031
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3032
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3033
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3034
if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3035
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3036
  function ot_recognized_spacing_unit_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3037
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3038
    return apply_filters( 'ot_recognized_spacing_unit_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3039
      'px' => 'px',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3040
      '%'  => '%',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3041
      'em' => 'em',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3042
      'pt' => 'pt'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3043
    ), $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3044
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3045
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3046
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3047
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3048
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3049
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3050
 * Recognized Google font families
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3051
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3052
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3053
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3054
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3055
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3056
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3057
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3058
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3059
if ( ! function_exists( 'ot_recognized_google_font_families' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3060
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3061
  function ot_recognized_google_font_families( $field_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3062
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3063
    $families = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3064
    $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3065
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3066
    // Forces an array rebuild when we sitch themes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3067
    if ( empty( $ot_google_fonts ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3068
      $ot_google_fonts = ot_fetch_google_fonts( true, true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3069
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3070
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3071
    foreach( (array) $ot_google_fonts as $key => $item ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3072
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3073
      if ( isset( $item['family'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3074
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3075
        $families[ $key ] = $item['family'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3076
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3077
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3078
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3079
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3080
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3081
    return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3082
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3083
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3084
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3085
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3086
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3087
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3088
 * Recognized Google font variants
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3089
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3090
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3091
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3092
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3093
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3094
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3095
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3096
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3097
if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3098
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3099
  function ot_recognized_google_font_variants( $field_id, $family ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3100
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3101
    $variants = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3102
    $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3103
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3104
    if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3105
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3106
      $variants = $ot_google_fonts[ $family ]['variants'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3107
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3108
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3109
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3110
    return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3111
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3112
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3113
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3114
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3115
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3116
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3117
 * Recognized Google font subsets
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3118
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3119
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3120
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3121
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3122
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3123
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3124
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3125
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3126
if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3127
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3128
  function ot_recognized_google_font_subsets( $field_id, $family ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3129
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3130
    $subsets = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3131
    $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3132
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3133
    if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3134
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3135
      $subsets = $ot_google_fonts[ $family ]['subsets'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3136
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3137
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3138
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3139
    return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3140
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3141
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3142
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3143
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3144
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3145
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3146
 * Measurement Units
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3147
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3148
 * Returns an array of all available unit types.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3149
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3150
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3151
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3152
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3153
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3154
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3155
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3156
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3157
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3158
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3159
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3160
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3161
  function ot_measurement_unit_types( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3162
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3163
    return apply_filters( 'ot_measurement_unit_types', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3164
      'px' => 'px',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3165
      '%'  => '%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3166
      'em' => 'em',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3167
      'pt' => 'pt'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3168
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3169
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3170
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3171
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3172
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3173
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3174
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3175
 * Radio Images default array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3176
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3177
 * Returns an array of all available radio images.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3178
 * You can filter this function to change the images
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3179
 * on a per option basis.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3180
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3181
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3182
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3183
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3184
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3185
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3186
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3187
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3188
if ( ! function_exists( 'ot_radio_images' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3189
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3190
  function ot_radio_images( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3191
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3192
    return apply_filters( 'ot_radio_images', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3193
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3194
        'value'   => 'left-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3195
        'label'   => __( 'Left Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3196
        'src'     => OT_URL . 'assets/images/layout/left-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3197
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3198
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3199
        'value'   => 'right-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3200
        'label'   => __( 'Right Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3201
        'src'     => OT_URL . 'assets/images/layout/right-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3202
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3203
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3204
        'value'   => 'full-width',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3205
        'label'   => __( 'Full Width (no sidebar)', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3206
        'src'     => OT_URL . 'assets/images/layout/full-width.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3207
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3208
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3209
        'value'   => 'dual-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3210
        'label'   => __( 'Dual Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3211
        'src'     => OT_URL . 'assets/images/layout/dual-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3212
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3213
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3214
        'value'   => 'left-dual-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3215
        'label'   => __( 'Left Dual Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3216
        'src'     => OT_URL . 'assets/images/layout/left-dual-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3217
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3218
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3219
        'value'   => 'right-dual-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3220
        'label'   => __( 'Right Dual Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3221
        'src'     => OT_URL . 'assets/images/layout/right-dual-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3222
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3223
    ), $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3224
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3225
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3226
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3227
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3228
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3229
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3230
 * Default List Item Settings array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3231
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3232
 * Returns an array of the default list item settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3233
 * You can filter this function to change the settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3234
 * on a per option basis.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3235
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3236
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3237
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3238
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3239
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3240
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3241
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3242
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3243
if ( ! function_exists( 'ot_list_item_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3244
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3245
  function ot_list_item_settings( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3246
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3247
    $settings = apply_filters( 'ot_list_item_settings', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3248
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3249
        'id'        => 'image',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3250
        'label'     => __( 'Image', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3251
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3252
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3253
        'type'      => 'upload',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3254
        'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3255
        'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3256
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3257
        'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3258
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3259
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3260
        'id'        => 'link',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3261
        'label'     => __( 'Link', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3262
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3263
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3264
        'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3265
        'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3266
        'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3267
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3268
        'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3269
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3270
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3271
        'id'        => 'description',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3272
        'label'     => __( 'Description', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3273
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3274
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3275
        'type'      => 'textarea-simple',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3276
        'rows'      => 10,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3277
        'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3278
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3279
        'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3280
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3281
    ), $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3282
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3283
    return $settings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3284
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3285
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3286
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3287
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3288
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3289
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3290
 * Default Slider Settings array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3291
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3292
 * Returns an array of the default slider settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3293
 * You can filter this function to change the settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3294
 * on a per option basis.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3295
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3296
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3297
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3298
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3299
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3300
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3301
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3302
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3303
if ( ! function_exists( 'ot_slider_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3304
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3305
  function ot_slider_settings( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3306
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3307
    $settings = apply_filters( 'image_slider_fields', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3308
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3309
        'name'      => 'image',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3310
        'type'      => 'image',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3311
        'label'     => __( 'Image', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3312
        'class'     => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3313
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3314
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3315
        'name'      => 'link',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3316
        'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3317
        'label'     => __( 'Link', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3318
        'class'     => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3319
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3320
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3321
        'name'      => 'description',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3322
        'type'      => 'textarea',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3323
        'label'     => __( 'Description', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3324
        'class'     => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3325
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3326
    ), $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3327
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3328
    /* fix the array keys, values, and just get it 2.0 ready */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3329
    foreach( $settings as $_k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3330
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3331
      foreach( $setting as $s_key => $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3332
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3333
        if ( 'name' == $s_key ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3334
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3335
          $settings[$_k]['id'] = $s_value;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3336
          unset($settings[$_k]['name']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3337
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3338
        } else if ( 'type' == $s_key ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3339
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3340
          if ( 'input' == $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3341
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3342
            $settings[$_k]['type'] = 'text';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3343
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3344
          } else if ( 'textarea' == $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3345
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3346
            $settings[$_k]['type'] = 'textarea-simple';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3347
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3348
          } else if ( 'image' == $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3349
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3350
            $settings[$_k]['type'] = 'upload';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3351
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3352
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3353
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3354
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3355
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3356
      } 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3357
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3358
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3359
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3360
    return $settings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3361
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3362
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3363
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3364
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3365
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3366
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3367
 * Default Social Links Settings array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3368
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3369
 * Returns an array of the default social links settings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3370
 * You can filter this function to change the settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3371
 * on a per option basis.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3372
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3373
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3374
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3375
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3376
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3377
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3378
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3379
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3380
if ( ! function_exists( 'ot_social_links_settings' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3381
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3382
  function ot_social_links_settings( $id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3383
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3384
    $settings = apply_filters( 'ot_social_links_settings', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3385
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3386
        'id'        => 'name',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3387
        'label'     => __( 'Name', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3388
        'desc'      => __( 'Enter the name of the social website.', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3389
        'std'       => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3390
        'type'      => 'text',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3391
        'class'     => 'option-tree-setting-title'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3392
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3393
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3394
        'id'        => 'title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3395
        'label'     => 'Title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3396
        'desc'      => __( 'Enter the text shown in the title attribute of the link.', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3397
        'type'      => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3398
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3399
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3400
        'id'        => 'href',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3401
        'label'     => 'Link',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3402
        'desc'      => sprintf( __( 'Enter a link to the profile or page on the social website. Remember to add the %s part to the front of the link.', 'option-tree' ), '<code>http://</code>' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3403
        'type'      => 'text',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3404
      )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3405
    ), $id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3406
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3407
    return $settings;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3408
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3409
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3410
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3411
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3412
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3413
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3414
 * Inserts CSS with field_id markers.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3415
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3416
 * Inserts CSS into a dynamic.css file, placing it between
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3417
 * BEGIN and END field_id markers. Replaces existing marked info, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3418
 * but still retains surrounding data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3419
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3420
 * @param     string  $field_id The CSS option field ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3421
 * @param     array   $options The current option_tree array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3422
 * @return    bool    True on write success, false on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3423
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3424
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3425
 * @since     1.1.8
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3426
 * @updated   2.5.3
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3427
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3428
if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3429
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3430
  function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = false ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3431
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3432
    /* missing $field_id or $insertion exit early */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3433
    if ( '' == $field_id || '' == $insertion )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3434
      return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3435
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3436
    /* path to the dynamic.css file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3437
    $filepath = get_stylesheet_directory() . '/dynamic.css';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3438
    if ( is_multisite() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3439
      $multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3440
      if ( file_exists( $multisite_filepath ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3441
        $filepath = $multisite_filepath;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3442
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3443
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3444
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3445
    /* allow filter on path */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3446
    $filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3447
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3448
    /* grab a copy of the paths array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3449
    $ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3450
    if ( is_multisite() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3451
      $ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3452
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3453
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3454
    /* set the path for this field */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3455
    $ot_css_file_paths[$field_id] = $filepath;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3456
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3457
    /* update the paths */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3458
    if ( is_multisite() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3459
      update_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3460
    } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3461
      update_option( 'ot_css_file_paths', $ot_css_file_paths );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3462
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3463
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3464
    /* insert CSS into file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3465
    if ( file_exists( $filepath ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3466
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3467
      $insertion   = ot_normalize_css( $insertion );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3468
      $regex       = "/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3469
      $marker      = $field_id;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3470
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3471
      /* Match custom CSS */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3472
      preg_match_all( $regex, $insertion, $matches );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3473
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3474
      /* Loop through CSS */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3475
      foreach( $matches[0] as $option ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3476
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3477
        $value        = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3478
        $option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3479
        $option_id    = isset( $option_array[0] ) ? $option_array[0] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3480
        $option_key   = isset( $option_array[1] ) ? $option_array[1] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3481
        $option_type  = ot_get_option_type_by_id( $option_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3482
        $fallback     = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3483
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3484
        // Get the meta array value
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3485
        if ( $meta ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3486
          global $post;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3487
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3488
          $value = get_post_meta( $post->ID, $option_id, true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3489
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3490
        // Get the options array value
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3491
        } else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3492
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3493
          $options = get_option( ot_options_id() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3494
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3495
          if ( isset( $options[$option_id] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3496
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3497
            $value = $options[$option_id];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3498
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3499
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3500
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3501
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3502
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3503
        // This in an array of values
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3504
        if ( is_array( $value ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3505
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3506
          if ( empty( $option_key ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3507
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3508
            // Measurement
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3509
            if ( $option_type == 'measurement' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3510
              $unit = ! empty( $value[1] ) ? $value[1] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3511
			  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3512
              // Set $value with measurement properties
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3513
              if ( isset( $value[0] ) && strlen( $value[0] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3514
                $value = $value[0].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3515
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3516
            // Border
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3517
            } else if ( $option_type == 'border' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3518
              $border = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3519
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3520
              $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3521
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3522
              if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3523
                $border[] = $value['width'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3524
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3525
              if ( ! empty( $value['style'] ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3526
                $border[] = $value['style'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3527
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3528
              if ( ! empty( $value['color'] ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3529
                $border[] = $value['color'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3530
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3531
              /* set $value with border properties or empty string */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3532
              $value = ! empty( $border ) ? implode( ' ', $border ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3533
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3534
            // Box Shadow
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3535
            } else if ( $option_type == 'box-shadow' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3536
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3537
              /* set $value with box-shadow properties or empty string */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3538
              $value = ! empty( $value ) ? implode( ' ', $value ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3539
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3540
            // Dimension
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3541
            } else if ( $option_type == 'dimension' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3542
              $dimension = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3543
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3544
              $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3545
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3546
              if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3547
                $dimension[] = $value['width'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3548
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3549
              if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3550
                $dimension[] = $value['height'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3551
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3552
              // Set $value with dimension properties or empty string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3553
              $value = ! empty( $dimension ) ? implode( ' ', $dimension ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3554
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3555
            // Spacing
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3556
            } else if ( $option_type == 'spacing' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3557
              $spacing = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3558
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3559
              $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3560
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3561
              if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3562
                $spacing[] = $value['top'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3563
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3564
              if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3565
                $spacing[] = $value['right'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3566
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3567
              if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3568
                $spacing[] = $value['bottom'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3569
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3570
              if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3571
                $spacing[] = $value['left'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3572
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3573
              // Set $value with spacing properties or empty string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3574
              $value = ! empty( $spacing ) ? implode( ' ', $spacing ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3575
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3576
            // Typography
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3577
            } else if ( $option_type == 'typography' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3578
              $font = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3579
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3580
              if ( ! empty( $value['font-color'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3581
                $font[] = "color: " . $value['font-color'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3582
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3583
              if ( ! empty( $value['font-family'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3584
                foreach ( ot_recognized_font_families( $marker ) as $key => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3585
                  if ( $key == $value['font-family'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3586
                    $font[] = "font-family: " . $v . ";";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3587
                  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3588
                }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3589
              }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3590
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3591
              if ( ! empty( $value['font-size'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3592
                $font[] = "font-size: " . $value['font-size'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3593
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3594
              if ( ! empty( $value['font-style'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3595
                $font[] = "font-style: " . $value['font-style'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3596
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3597
              if ( ! empty( $value['font-variant'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3598
                $font[] = "font-variant: " . $value['font-variant'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3599
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3600
              if ( ! empty( $value['font-weight'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3601
                $font[] = "font-weight: " . $value['font-weight'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3602
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3603
              if ( ! empty( $value['letter-spacing'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3604
                $font[] = "letter-spacing: " . $value['letter-spacing'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3605
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3606
              if ( ! empty( $value['line-height'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3607
                $font[] = "line-height: " . $value['line-height'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3608
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3609
              if ( ! empty( $value['text-decoration'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3610
                $font[] = "text-decoration: " . $value['text-decoration'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3611
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3612
              if ( ! empty( $value['text-transform'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3613
                $font[] = "text-transform: " . $value['text-transform'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3614
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3615
              // Set $value with font properties or empty string
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3616
              $value = ! empty( $font ) ? implode( "\n", $font ) : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3617
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3618
            // Background
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3619
            } else if ( $option_type == 'background' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3620
              $bg = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3621
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3622
              if ( ! empty( $value['background-color'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3623
                $bg[] = $value['background-color'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3624
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3625
              if ( ! empty( $value['background-image'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3626
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3627
                // If an attachment ID is stored here fetch its URL and replace the value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3628
                if ( wp_attachment_is_image( $value['background-image'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3629
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3630
                  $attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3631
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3632
                  // Check for attachment data
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3633
                  if ( $attachment_data ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3634
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3635
                    $value['background-image'] = $attachment_data[0];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3636
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3637
                  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3638
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3639
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3640
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3641
                $bg[] = 'url("' . $value['background-image'] . '")';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3642
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3643
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3644
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3645
              if ( ! empty( $value['background-repeat'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3646
                $bg[] = $value['background-repeat'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3647
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3648
              if ( ! empty( $value['background-attachment'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3649
                $bg[] = $value['background-attachment'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3650
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3651
              if ( ! empty( $value['background-position'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3652
                $bg[] = $value['background-position'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3653
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3654
              if ( ! empty( $value['background-size'] ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3655
                $size = $value['background-size'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3656
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3657
              // Set $value with background properties or empty string
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3658
              $value = ! empty( $bg ) ? 'background: ' . implode( " ", $bg ) . ';' : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3659
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3660
              if ( isset( $size ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3661
                if ( ! empty( $bg ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3662
                  $value.= apply_filters( 'ot_insert_css_with_markers_bg_size_white_space', "\n\x20\x20", $option_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3663
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3664
                $value.= "background-size: $size;";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3665
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3666
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3667
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3668
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3669
          } else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3670
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3671
            $value = $value[$option_key];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3672
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3673
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3674
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3675
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3676
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3677
        // If an attachment ID is stored here fetch its URL and replace the value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3678
        if ( $option_type == 'upload' && wp_attachment_is_image( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3679
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3680
          $attachment_data = wp_get_attachment_image_src( $value, 'original' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3681
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3682
          // Check for attachment data
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3683
          if ( $attachment_data ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3684
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3685
            $value = $attachment_data[0];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3686
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3687
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3688
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3689
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3690
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3691
        // Attempt to fallback when `$value` is empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3692
        if ( empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3693
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3694
          // We're trying to access a single array key
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3695
          if ( ! empty( $option_key ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3696
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3697
            // Link Color `inherit`
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3698
            if ( $option_type == 'link-color' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3699
              $fallback = 'inherit';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3700
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3701
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3702
          } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3703
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3704
            // Border
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3705
            if ( $option_type == 'border' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3706
              $fallback = 'inherit';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3707
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3708
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3709
            // Box Shadow
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3710
            if ( $option_type == 'box-shadow' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3711
              $fallback = 'none';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3712
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3713
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3714
            // Colorpicker
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3715
            if ( $option_type == 'colorpicker' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3716
              $fallback = 'inherit';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3717
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3718
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3719
            // Colorpicker Opacity
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3720
            if ( $option_type == 'colorpicker-opacity' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3721
              $fallback = 'inherit';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3722
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3723
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3724
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3725
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3726
          /**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3727
           * Filter the `dynamic.css` fallback value.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3728
           *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3729
           * @since 2.5.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3730
           *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3731
           * @param string $fallback The default CSS fallback value.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3732
           * @param string $option_id The option ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3733
           * @param string $option_type The option type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3734
           * @param string $option_key The option array key.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3735
           */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3736
          $fallback = apply_filters( 'ot_insert_css_with_markers_fallback', $fallback, $option_id, $option_type, $option_key );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3737
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3738
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3739
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3740
        // Let's fallback!
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3741
        if ( ! empty( $fallback ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3742
          $value = $fallback;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3743
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3744
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3745
        // Filter the CSS
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3746
        $value = apply_filters( 'ot_insert_css_with_markers_value', $value, $option_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3747
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3748
        // Insert CSS, even if the value is empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3749
        $insertion = stripslashes( str_replace( $option, $value, $insertion ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3750
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3751
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3752
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3753
      // Can't write to the file so we error out
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3754
      if ( ! is_writable( $filepath ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3755
        add_settings_error( 'option-tree', 'dynamic_css', sprintf( __( 'Unable to write to file %s.', 'option-tree' ), '<code>' . $filepath . '</code>' ), 'error' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3756
        return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3757
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3758
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3759
      // Create array from the lines of code
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3760
      $markerdata = explode( "\n", implode( '', file( $filepath ) ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3761
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3762
      // Can't write to the file return false
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3763
      if ( ! $f = ot_file_open( $filepath, 'w' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3764
        return false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3765
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3766
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3767
      $searching = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3768
      $foundit = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3769
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3770
      // Has array of lines
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3771
      if ( ! empty( $markerdata ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3772
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3773
        // Foreach line of code
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3774
        foreach( $markerdata as $n => $markerline ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3775
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3776
          // Found begining of marker, set $searching to false
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3777
          if ( $markerline == "/* BEGIN {$marker} */" )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3778
            $searching = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3779
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3780
          // Keep searching each line of CSS
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3781
          if ( $searching == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3782
            if ( $n + 1 < count( $markerdata ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3783
              ot_file_write( $f, "{$markerline}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3784
            else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3785
              ot_file_write( $f, "{$markerline}" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3786
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3787
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3788
          // Found end marker write code
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3789
          if ( $markerline == "/* END {$marker} */" ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3790
            ot_file_write( $f, "/* BEGIN {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3791
            ot_file_write( $f, "{$insertion}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3792
            ot_file_write( $f, "/* END {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3793
            $searching = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3794
            $foundit = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3795
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3796
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3797
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3798
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3799
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3800
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3801
      // Nothing inserted, write code. DO IT, DO IT!
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3802
      if ( ! $foundit ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3803
        ot_file_write( $f, "/* BEGIN {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3804
        ot_file_write( $f, "{$insertion}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3805
        ot_file_write( $f, "/* END {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3806
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3807
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3808
      // Close file
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3809
      ot_file_close( $f );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3810
      return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3811
    }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3812
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3813
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3814
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3815
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3816
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3817
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3818
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3819
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3820
 * Remove old CSS.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3821
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3822
 * Removes CSS when the textarea is empty, but still retains surrounding styles.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3823
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3824
 * @param     string  $field_id The CSS option field ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3825
 * @return    bool    True on write success, false on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3826
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3827
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3828
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3829
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3830
if ( ! function_exists( 'ot_remove_old_css' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3831
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3832
  function ot_remove_old_css( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3833
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3834
    /* missing $field_id string */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3835
    if ( '' == $field_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3836
      return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3837
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3838
    /* path to the dynamic.css file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3839
    $filepath = get_stylesheet_directory() . '/dynamic.css';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3840
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3841
    /* allow filter on path */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3842
    $filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3843
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3844
    /* remove CSS from file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3845
    if ( is_writeable( $filepath ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3846
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3847
      /* get each line in the file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3848
      $markerdata = explode( "\n", implode( '', file( $filepath ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3849
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3850
      /* can't write to the file return false */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3851
      if ( ! $f = ot_file_open( $filepath, 'w' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3852
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3853
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3854
      $searching = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3855
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3856
      /* has array of lines */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3857
      if ( ! empty( $markerdata ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3858
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3859
        /* foreach line of code */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3860
        foreach ( $markerdata as $n => $markerline ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3861
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3862
          /* found begining of marker, set $searching to false  */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3863
          if ( $markerline == "/* BEGIN {$field_id} */" )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3864
            $searching = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3865
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3866
          /* $searching is true, keep rewrite each line of CSS  */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3867
          if ( $searching == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3868
            if ( $n + 1 < count( $markerdata ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3869
              ot_file_write( $f, "{$markerline}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3870
            else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3871
              ot_file_write( $f, "{$markerline}" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3872
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3873
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3874
          /* found end marker delete old CSS */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3875
          if ( $markerline == "/* END {$field_id} */" ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3876
            ot_file_write( $f, "" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3877
            $searching = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3878
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3879
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3880
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3881
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3882
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3883
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3884
      /* close file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3885
      ot_file_close( $f );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3886
      return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3887
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3888
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3889
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3890
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3891
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3892
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3893
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3894
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3895
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3896
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3897
 * Normalize CSS
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3898
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3899
 * Normalize & Convert all line-endings to UNIX format.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3900
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3901
 * @param     string    $css
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3902
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3903
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3904
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3905
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3906
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3907
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3908
if ( ! function_exists( 'ot_normalize_css' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3909
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3910
  function ot_normalize_css( $css ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3911
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3912
    /* Normalize & Convert */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3913
    $css = str_replace( "\r\n", "\n", $css );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3914
    $css = str_replace( "\r", "\n", $css );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3915
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3916
    /* Don't allow out-of-control blank lines */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3917
    $css = preg_replace( "/\n{2,}/", "\n\n", $css );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3918
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3919
    return $css;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3920
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3921
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3922
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3923
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3924
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3925
 * Helper function to loop over the option types.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3926
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3927
 * @param    array    $type The current option type.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3928
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3929
 * @return   string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3930
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3931
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3932
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3933
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3934
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3935
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3936
  function ot_loop_through_option_types( $type = '', $child = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3937
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3938
    $content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3939
    $types = ot_option_types_array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3940
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3941
    if ( $child )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3942
      unset($types['list-item']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3943
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3944
    foreach( $types as $key => $value )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3945
      $content.= '<option value="' . $key . '" ' . selected( $type, $key, false ) . '>'  . $value . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3946
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3947
    return $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3948
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3949
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3950
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3951
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3952
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3953
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3954
 * Helper function to loop over choices.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3955
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3956
 * @param    string     $name The form element name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3957
 * @param    array      $choices The array of choices.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3958
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3959
 * @return   string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3960
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3961
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3962
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3963
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3964
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3965
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3966
  function ot_loop_through_choices( $name, $choices = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3967
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3968
    $content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3969
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3970
    foreach( (array) $choices as $key => $choice )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3971
      $content.= '<li class="ui-state-default list-choice">' . ot_choices_view( $name, $key, $choice ) . '</li>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3972
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3973
    return $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3974
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3975
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3976
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3977
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3978
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3979
 * Helper function to loop over sub settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3980
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3981
 * @param    string     $name The form element name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3982
 * @param    array      $settings The array of settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3983
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3984
 * @return   string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3985
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3986
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3987
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3988
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3989
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3990
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3991
  function ot_loop_through_sub_settings( $name, $settings = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3992
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3993
    $content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3994
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3995
    foreach( $settings as $key => $setting )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3996
      $content.= '<li class="ui-state-default list-sub-setting">' . ot_settings_view( $name, $key, $setting ) . '</li>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3997
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3998
    return $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3999
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4000
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4001
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4002
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4003
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4004
 * Helper function to display sections.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4005
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4006
 * This function is used in AJAX to add a new section
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4007
 * and when section have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4008
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4009
 * @param    int      $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4010
 * @param    array    An array of values for the current section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4011
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4012
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4013
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4014
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4015
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4016
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4017
if ( ! function_exists( 'ot_sections_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4018
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4019
  function ot_sections_view( $name, $key, $section = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4020
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4021
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4022
    <div class="option-tree-setting is-section">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4023
      <div class="open">' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( $key + 1 ) ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4024
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4025
        <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'edit', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4026
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4027
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4028
        <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4029
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4030
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4031
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4032
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4033
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4034
          <div class="format-setting type-text">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4035
            <div class="description">' . __( '<strong>Section Title</strong>: Displayed as a menu item on the Theme Options page.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4036
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4037
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title section-title" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4038
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4039
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4040
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4041
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4042
          <div class="format-setting type-text">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4043
            <div class="description">' . __( '<strong>Section ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4044
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4045
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $section['id'] ) ? esc_attr( $section['id'] ) : '' ) . '" class="widefat option-tree-ui-input section-id" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4046
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4047
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4048
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4049
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4050
    </div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4051
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4052
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4053
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4054
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4055
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4056
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4057
 * Helper function to display settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4058
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4059
 * This function is used in AJAX to add a new setting
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4060
 * and when settings have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4061
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4062
 * @param    int      $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4063
 * @param    array    An array of values for the current section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4064
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4065
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4066
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4067
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4068
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4069
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4070
if ( ! function_exists( 'ot_settings_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4071
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4072
  function ot_settings_view( $name, $key, $setting = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4073
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4074
    $child = ( strpos( $name, '][settings]') !== false ) ? true : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4075
    $type = isset( $setting['type'] ) ? $setting['type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4076
    $std = isset( $setting['std'] ) ? $setting['std'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4077
    $operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4078
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4079
    // Serialize the standard value just incase
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4080
    if ( is_array( $std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4081
      $std = maybe_serialize( $std );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4082
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4083
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4084
    if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4085
      $std_form_element = '<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]">' . esc_html( $std ) . '</textarea>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4086
    } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4087
      $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" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4088
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4089
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4090
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4091
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4092
      <div class="open">' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( $key + 1 ) ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4093
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4094
        <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4095
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4096
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4097
        <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4098
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4099
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4100
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4101
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4102
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4103
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4104
            <div class="description">' . __( '<strong>Label</strong>: Displayed as the label of a form element on the Theme Options page.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4105
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4106
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][label]" value="' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4107
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4108
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4109
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4110
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4111
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4112
            <div class="description">' . __( '<strong>ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4113
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4114
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $setting['id'] ) ? esc_attr( $setting['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4115
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4116
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4117
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4118
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4119
          <div class="format-setting type-select wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4120
            <div class="description">' . __( '<strong>Type</strong>: Choose one of the available option types from the dropdown.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4121
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4122
              <select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][type]" value="' . esc_attr( $type ) . '" class="option-tree-ui-select">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4123
              ' . ot_loop_through_option_types( $type, $child ) . '                     
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4124
               
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4125
              </select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4126
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4127
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4128
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4129
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4130
          <div class="format-setting type-textarea wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4131
            <div class="description">' . __( '<strong>Description</strong>: Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4132
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4133
              <textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][desc]">' . ( isset( $setting['desc'] ) ? esc_html( $setting['desc'] ) : '' ) . '</textarea>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4134
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4135
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4136
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4137
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4138
          <div class="format-setting type-textblock wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4139
            <div class="description">' . __( '<strong>Choices</strong>: This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4140
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4141
              <ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4142
                ' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4143
              </ul>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4144
              <a href="javascript:void(0);" class="option-tree-choice-add option-tree-ui-button button hug-left">' . __( 'Add Choice', 'option-tree' ) . '</a>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4145
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4146
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4147
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4148
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4149
          <div class="format-setting type-textblock wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4150
            <div class="description">' . __( '<strong>Settings</strong>: This will only affect the List Item option type.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4151
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4152
              <ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4153
                ' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4154
              </ul>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4155
              <a href="javascript:void(0);" class="option-tree-list-item-setting-add option-tree-ui-button button hug-left">' . __( 'Add Setting', 'option-tree' ) . '</a>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4156
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4157
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4158
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4159
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4160
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4161
            <div class="description">' . __( '<strong>Standard</strong>: Setting the standard value for your option only works for some option types. Read the <code>OptionTree->Documentation</code> for more information on which ones.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4162
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4163
              ' . $std_form_element . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4164
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4165
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4166
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4167
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4168
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4169
            <div class="description">' . __( '<strong>Rows</strong>: Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4170
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4171
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][rows]" value="' . ( isset( $setting['rows'] ) ? esc_attr( $setting['rows'] ) : '' ) . '" class="widefat option-tree-ui-input" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4172
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4173
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4174
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4175
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4176
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4177
            <div class="description">' . __( '<strong>Post Type</strong>: Add a comma separated list of post type like \'post,page\'. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4178
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4179
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][post_type]" value="' . ( isset( $setting['post_type'] ) ? esc_attr( $setting['post_type'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4180
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4181
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4182
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4183
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4184
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4185
            <div class="description">' . __( '<strong>Taxonomy</strong>: Add a comma separated list of any registered taxonomy like \'category,post_tag\'. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4186
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4187
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][taxonomy]" value="' . ( isset( $setting['taxonomy'] ) ? esc_attr( $setting['taxonomy'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4188
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4189
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4190
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4191
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4192
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4193
            <div class="description">' . __( '<strong>Min, Max, & Step</strong>: Add a comma separated list of options in the following format <code>0,100,1</code> (slide from <code>0-100</code> in intervals of <code>1</code>). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4194
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4195
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][min_max_step]" value="' . ( isset( $setting['min_max_step'] ) ? esc_attr( $setting['min_max_step'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4196
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4197
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4198
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4199
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4200
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4201
            <div class="description">' . __( '<strong>CSS Class</strong>: Add and optional class to this option type.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4202
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4203
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][class]" value="' . ( isset( $setting['class'] ) ? esc_attr( $setting['class'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4204
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4205
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4206
        </div>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4207
        <div class="format-settings">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4208
          <div class="format-setting type-text wide-desc">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4209
            <div class="description">' . sprintf( __( '<strong>Condition</strong>: Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, <code>value</code> is a placeholder for your condition, which can be in the form of %s.', 'option-tree' ), '<code>field_id:is(value)</code>, <code>field_id:not(value)</code>, <code>field_id:contains(value)</code>, <code>field_id:less_than(value)</code>, <code>field_id:less_than_or_equal_to(value)</code>, <code>field_id:greater_than(value)</code>, or <code>field_id:greater_than_or_equal_to(value)</code>' ) . '</div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4210
            <div class="format-setting-inner">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4211
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][condition]" value="' . ( isset( $setting['condition'] ) ? esc_attr( $setting['condition'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4212
            </div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4213
          </div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4214
        </div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4215
        <div class="format-settings">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4216
          <div class="format-setting type-select wide-desc">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4217
            <div class="description">' . __( '<strong>Operator</strong>: Choose the logical operator to compute the result of the conditions.', 'option-tree' ) . '</div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4218
            <div class="format-setting-inner">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4219
              <select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][operator]" value="' . $operator . '" class="option-tree-ui-select">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4220
                <option value="and" ' . selected( $operator, 'and', false ) . '>' . __( 'and', 'option-tree' ) . '</option>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4221
                <option value="or" ' . selected( $operator, 'or', false ) . '>' . __( 'or', 'option-tree' ) . '</option>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4222
              </select>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4223
            </div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4224
          </div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4225
        </div>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4226
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4227
    </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4228
    ' . ( ! $child ? '<input type="hidden" class="hidden-section" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][section]" value="' . ( isset( $setting['section'] ) ? esc_attr( $setting['section'] ) : '' ) . '" />' : '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4229
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4230
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4231
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4232
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4233
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4234
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4235
 * Helper function to display setting choices.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4236
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4237
 * This function is used in AJAX to add a new choice
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4238
 * and when choices have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4239
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4240
 * @param    string   $name The form element name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4241
 * @param    array    $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4242
 * @param    array    An array of values for the current choice.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4243
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4244
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4245
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4246
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4247
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4248
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4249
if ( ! function_exists( 'ot_choices_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4250
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4251
  function ot_choices_view( $name, $key, $choice = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4252
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4253
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4254
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4255
      <div class="open">' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( $key + 1 ) ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4256
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4257
        <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4258
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4259
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4260
        <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4261
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4262
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4263
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4264
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4265
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4266
          <div class="format-setting-label">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4267
            <h5>' . __( 'Label', 'option-tree' ) . '</h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4268
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4269
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4270
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4271
              <input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][label]" value="' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4272
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4273
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4274
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4275
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4276
          <div class="format-setting-label">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4277
            <h5>' . __( 'Value', 'option-tree' ) . '</h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4278
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4279
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4280
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4281
              <input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][value]" value="' . ( isset( $choice['value'] ) ? esc_attr( $choice['value'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4282
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4283
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4284
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4285
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4286
          <div class="format-setting-label">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4287
            <h5>' . __( 'Image Source (Radio Image only)', 'option-tree' ) . '</h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4288
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4289
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4290
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4291
              <input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][src]" value="' . ( isset( $choice['src'] ) ? esc_attr( $choice['src'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4292
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4293
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4294
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4295
    </div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4296
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4297
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4298
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4299
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4300
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4301
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4302
 * Helper function to display sections.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4303
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4304
 * This function is used in AJAX to add a new section
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4305
 * and when section have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4306
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4307
 * @param    int      $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4308
 * @param    array    An array of values for the current section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4309
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4310
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4311
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4312
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4313
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4314
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4315
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4316
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4317
  function ot_contextual_help_view( $name, $key, $content = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4318
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4319
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4320
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4321
      <div class="open">' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( $key + 1 ) ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4322
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4323
        <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4324
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4325
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4326
        <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4327
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4328
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4329
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4330
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4331
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4332
          <div class="format-setting type-text no-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4333
            <div class="description">' . __( '<strong>Title</strong>: Displayed as a contextual help menu item on the Theme Options page.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4334
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4335
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4336
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4337
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4338
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4339
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4340
          <div class="format-setting type-text no-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4341
            <div class="description">' . __( '<strong>ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4342
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4343
              <input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $content['id'] ) ? esc_attr( $content['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4344
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4345
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4346
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4347
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4348
          <div class="format-setting type-textarea no-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4349
            <div class="description">' . __( '<strong>Content</strong>: Enter the HTML content about this contextual help item displayed on the Theme Option page for end users to read.', 'option-tree' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4350
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4351
              <textarea class="textarea" rows="15" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][content]">' . ( isset( $content['content'] ) ? esc_html( $content['content'] ) : '' ) . '</textarea>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4352
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4353
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4354
        </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4355
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4356
    </div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4357
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4358
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4359
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4360
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4361
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4362
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4363
 * Helper function to display sections.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4364
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4365
 * @param     string      $key
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4366
 * @param     string      $data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4367
 * @param     string      $active_layout
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4368
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4369
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4370
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4371
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4372
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4373
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4374
if ( ! function_exists( 'ot_layout_view' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4375
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4376
  function ot_layout_view( $key, $data = '', $active_layout = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4377
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4378
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4379
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4380
      <div class="open">' . ( isset( $key ) ? esc_attr( $key ) : __( 'Layout', 'option-tree' ) ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4381
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4382
        <a href="javascript:void(0);" class="option-tree-layout-activate option-tree-ui-button button left-item' . ( $active_layout == $key ? ' active' : '' ) . '" title="' . __( 'Activate', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4383
          <span class="icon ot-icon-square-o"></span>' . __( 'Activate', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4384
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4385
        <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="'. __( 'Delete', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4386
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4387
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4388
      </div>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4389
      <input type="hidden" name="' . ot_layouts_id() . '[' . esc_attr( $key ) . ']" value="' . $data . '" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4390
    </div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4391
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4392
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4393
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4394
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4395
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4396
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4397
 * Helper function to display list items.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4398
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4399
 * This function is used in AJAX to add a new list items
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4400
 * and when they have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4401
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4402
 * @param     string    $name The form field name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4403
 * @param     int       $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4404
 * @param     array     An array of values for the current list item.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4405
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4406
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4407
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4408
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4409
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4410
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4411
if ( ! function_exists( 'ot_list_item_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4412
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4413
  function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4414
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4415
    /* required title setting */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4416
    $required_setting = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4417
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4418
        'id'        => 'title',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4419
        'label'     => __( 'Title', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4420
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4421
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4422
        'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4423
        'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4424
        'class'     => 'option-tree-setting-title',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4425
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4426
        'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4427
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4428
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4429
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4430
    /* load the old filterable slider settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4431
    if ( 'slider' == $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4432
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4433
      $settings = ot_slider_settings( $name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4434
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4435
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4436
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4437
    /* if no settings array load the filterable list item settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4438
    if ( empty( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4439
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4440
      $settings = ot_list_item_settings( $name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4441
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4442
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4443
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4444
    /* merge the two settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4445
    $settings = array_merge( $required_setting, $settings );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4446
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4447
    echo '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4448
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4449
      <div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4450
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4451
        <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4452
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4453
        </a>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4454
        <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4455
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4456
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4457
      </div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4458
      <div class="option-tree-setting-body">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4459
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4460
      foreach( $settings as $field ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4461
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4462
        // Set field value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4463
        $field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4464
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4465
        /* set default to standard value */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4466
        if ( isset( $field['std'] ) ) {  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4467
          $field_value = ot_filter_std_value( $field_value, $field['std'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4468
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4469
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4470
        // filter the title label and description
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4471
        if ( $field['id'] == 'title' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4472
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4473
          // filter the label
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4474
          $field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4475
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4476
          // filter the description
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4477
          $field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4478
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4479
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4480
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4481
        /* make life easier */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4482
        $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4483
             
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4484
        /* build the arguments array */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4485
        $_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4486
          'type'              => $field['type'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4487
          'field_id'          => $name . '_' . $field['id'] . '_' . $key,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4488
          'field_name'        => $_field_name . '[' . $key . '][' . $field['id'] . ']',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4489
          'field_value'       => $field_value,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4490
          'field_desc'        => isset( $field['desc'] ) ? $field['desc'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4491
          'field_std'         => isset( $field['std'] ) ? $field['std'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4492
          'field_rows'        => isset( $field['rows'] ) ? $field['rows'] : 10,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4493
          'field_post_type'   => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4494
          'field_taxonomy'    => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4495
          'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4496
          'field_class'       => isset( $field['class'] ) ? $field['class'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4497
          'field_condition'   => isset( $field['condition'] ) ? $field['condition'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4498
          'field_operator'    => isset( $field['operator'] ) ? $field['operator'] : 'and',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4499
          'field_choices'     => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4500
          'field_settings'    => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4501
          'post_id'           => $post_id,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4502
          'get_option'        => $get_option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4503
        );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4504
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4505
        $conditions = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4506
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4507
        /* setup the conditions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4508
        if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4509
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4510
          /* doing magic on the conditions so they work in a list item */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4511
          $conditionals = explode( ',', $field['condition'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4512
          foreach( $conditionals as $condition ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4513
            $parts = explode( ':', $condition );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4514
            if ( isset( $parts[0] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4515
              $field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4516
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4517
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4518
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4519
          $conditions = ' data-condition="' . $field['condition'] . '"';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4520
          $conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4521
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4522
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4523
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4524
        // Build the setting CSS class
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4525
        if ( ! empty( $_args['field_class'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4526
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4527
          $classes = explode( ' ', $_args['field_class'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4528
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4529
          foreach( $classes as $_key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4530
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4531
            $classes[$_key] = $value . '-wrap';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4532
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4533
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4534
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4535
          $class = 'format-settings ' . implode( ' ', $classes );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4536
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4537
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4538
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4539
          $class = 'format-settings';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4540
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4541
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4542
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4543
        /* option label */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4544
        echo '<div id="setting_' . $_args['field_id'] . '" class="' . $class . '"' . $conditions . '>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4545
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4546
          /* don't show title with textblocks */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4547
          if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4548
            echo '<div class="format-setting-label">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4549
              echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4550
            echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4551
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4552
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4553
          /* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4554
          if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4555
            $_args['type'] = 'textarea-simple';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4556
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4557
          /* option body, list-item is not allowed inside another list-item */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4558
          if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4559
            echo ot_display_by_type( $_args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4560
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4561
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4562
        echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4563
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4564
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4565
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4566
      echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4567
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4568
    echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4569
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4570
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4571
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4572
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4573
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4574
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4575
 * Helper function to display social links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4576
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4577
 * This function is used in AJAX to add a new list items
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4578
 * and when they have already been added and saved.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4579
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4580
 * @param     string    $name The form field name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4581
 * @param     int       $key The array key for the current element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4582
 * @param     array     An array of values for the current list item.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4583
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4584
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4585
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4586
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4587
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4588
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4589
if ( ! function_exists( 'ot_social_links_view' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4590
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4591
  function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4592
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4593
    /* if no settings array load the filterable social links settings */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4594
    if ( empty( $settings ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4595
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4596
      $settings = ot_social_links_settings( $name );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4597
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4598
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4599
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4600
    echo '
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4601
    <div class="option-tree-setting">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4602
      <div class="open">' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '</div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4603
      <div class="button-section">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4604
        <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4605
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4606
        </a>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4607
        <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4608
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4609
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4610
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4611
      <div class="option-tree-setting-body">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4612
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4613
      foreach( $settings as $field ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4614
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4615
        // Set field value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4616
        $field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4617
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4618
        /* set default to standard value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4619
        if ( isset( $field['std'] ) ) {  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4620
          $field_value = ot_filter_std_value( $field_value, $field['std'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4621
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4622
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4623
        /* make life easier */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4624
        $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4625
             
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4626
        /* build the arguments array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4627
        $_args = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4628
          'type'              => $field['type'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4629
          'field_id'          => $name . '_' . $field['id'] . '_' . $key,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4630
          'field_name'        => $_field_name . '[' . $key . '][' . $field['id'] . ']',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4631
          'field_value'       => $field_value,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4632
          'field_desc'        => isset( $field['desc'] ) ? $field['desc'] : '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4633
          'field_std'         => isset( $field['std'] ) ? $field['std'] : '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4634
          'field_rows'        => isset( $field['rows'] ) ? $field['rows'] : 10,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4635
          'field_post_type'   => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4636
          'field_taxonomy'    => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4637
          'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4638
          'field_class'       => isset( $field['class'] ) ? $field['class'] : '',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4639
          'field_condition'   => isset( $field['condition'] ) ? $field['condition'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4640
          'field_operator'    => isset( $field['operator'] ) ? $field['operator'] : 'and',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4641
          'field_choices'     => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4642
          'field_settings'    => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4643
          'post_id'           => $post_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4644
          'get_option'        => $get_option
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4645
        );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4646
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4647
        $conditions = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4648
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4649
        /* setup the conditions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4650
        if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4651
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4652
          /* doing magic on the conditions so they work in a list item */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4653
          $conditionals = explode( ',', $field['condition'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4654
          foreach( $conditionals as $condition ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4655
            $parts = explode( ':', $condition );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4656
            if ( isset( $parts[0] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4657
              $field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4658
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4659
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4660
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4661
          $conditions = ' data-condition="' . $field['condition'] . '"';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4662
          $conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4663
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4664
        }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4665
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4666
        /* option label */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4667
        echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings"' . $conditions . '>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4668
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4669
          /* don't show title with textblocks */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4670
          if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4671
            echo '<div class="format-setting-label">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4672
              echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4673
            echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4674
          }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4675
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4676
          /* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4677
          if ( $_args['type'] == 'textarea' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4678
            $_args['type'] = 'textarea-simple';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4679
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4680
          /* option body, list-item is not allowed inside another list-item */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4681
          if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' && $_args['type'] !== 'social-links' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4682
            echo ot_display_by_type( $_args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4683
          }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4684
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4685
        echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4686
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4687
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4688
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4689
      echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4690
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4691
    echo '</div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4692
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4693
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4694
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4695
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4696
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4697
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4698
 * Helper function to display Theme Options layouts form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4699
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4700
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4701
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4702
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4703
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4704
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4705
if ( ! function_exists( 'ot_theme_options_layouts_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4706
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4707
  function ot_theme_options_layouts_form( $active = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4708
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4709
    echo '<form method="post" id="option-tree-options-layouts-form">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4710
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4711
      /* form nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4712
      wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4713
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4714
      /* get the saved layouts */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4715
      $layouts = get_option( ot_layouts_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4716
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4717
      /* set active layout */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4718
      $active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4719
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4720
      if ( is_array( $layouts ) && count( $layouts ) > 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4721
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4722
        $active_layout = esc_attr( $layouts['active_layout'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4723
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4724
        echo '<input type="hidden" id="the_current_layout" value="' . $active_layout . '" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4725
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4726
        echo '<div class="option-tree-active-layout">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4727
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4728
          echo '<select name="' . ot_layouts_id() . '[active_layout]" class="option-tree-ui-select">';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4729
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4730
            foreach( $layouts as $key => $data ) { 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4731
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4732
              if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4733
                continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4734
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4735
              echo '<option' . selected( $key, $active_layout, false ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $key ) . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4736
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4737
           
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4738
          echo '</select>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4739
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4740
        echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4741
         
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4742
        foreach( $layouts as $key => $data ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4743
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4744
          if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4745
              continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4746
              
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4747
          echo '<input type="hidden" name="' . ot_layouts_id() . '[' . $key . ']" value="' . ( isset( $data ) ? $data : '' ) . '" />';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4748
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4749
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4750
       
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4751
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4752
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4753
      /* new layout wrapper */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4754
      echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4755
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4756
        /* add new layout */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4757
        echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4758
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4759
        echo '<button type="submit" class="option-tree-ui-button button button-primary save-layout" title="' . __( 'New Layout', 'option-tree' ) . '">' . __( 'New Layout', 'option-tree' ) . '</button>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4760
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4761
      echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4762
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4763
    echo '</form>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4764
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4765
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4766
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4767
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4768
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4769
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4770
 * Helper function to validate option ID's
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4771
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4772
 * @param     string      $input The string to sanitize.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4773
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4774
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4775
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4776
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4777
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4778
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4779
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4780
  function ot_sanitize_option_id( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4781
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4782
    return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4783
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4784
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4785
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4786
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4787
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4788
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4789
 * Helper function to validate layout ID's
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4790
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4791
 * @param     string      $input The string to sanitize.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4792
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4793
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4794
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4795
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4796
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4797
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4798
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4799
  function ot_sanitize_layout_id( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4800
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4801
    return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4802
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4803
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4804
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4805
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4806
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4807
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4808
 * Convert choices array to string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4809
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4810
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4811
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4812
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4813
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4814
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4815
if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4816
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4817
  function ot_convert_array_to_string( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4818
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4819
    if ( is_array( $input ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4820
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4821
      foreach( $input as $k => $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4822
        $choices[$k] = $choice['value'] . '|' . $choice['label'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4823
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4824
        if ( isset( $choice['src'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4825
          $choices[$k].= '|' . $choice['src'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4826
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4827
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4828
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4829
      return implode( ',', $choices );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4830
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4831
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4832
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4833
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4834
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4835
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4836
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4837
 * Convert choices string to array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4838
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4839
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4840
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4841
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4842
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4843
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4844
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4845
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4846
  function ot_convert_string_to_array( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4847
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4848
    if ( '' !== $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4849
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4850
      /* empty choices array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4851
      $choices = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4852
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4853
      /* exlode the string into an array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4854
      foreach( explode( ',', $input ) as $k => $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4855
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4856
        /* if ":" is splitting the string go deeper */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4857
        if ( preg_match( '/\|/', $choice ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4858
          $split = explode( '|', $choice );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4859
          $choices[$k]['value'] = trim( $split[0] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4860
          $choices[$k]['label'] = trim( $split[1] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4861
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4862
          /* if radio image there are three values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4863
          if ( isset( $split[2] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4864
            $choices[$k]['src'] = trim( $split[2] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4865
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4866
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4867
          $choices[$k]['value'] = trim( $choice );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4868
          $choices[$k]['label'] = trim( $choice );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4869
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4870
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4871
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4872
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4873
      /* return a formated choices array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4874
      return $choices;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4875
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4876
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4877
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4878
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4879
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4880
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4881
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4882
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4883
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4884
 * Helper function - strpos() with arrays.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4885
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4886
 * @param     string    $haystack
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4887
 * @param     array     $needles
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4888
 * @return    bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4889
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4890
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4891
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4892
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4893
if ( ! function_exists( 'ot_strpos_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4894
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4895
  function ot_strpos_array( $haystack, $needles = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4896
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4897
    foreach( $needles as $needle ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4898
      $pos = strpos( $haystack, $needle );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4899
      if ( $pos !== false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4900
        return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4901
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4902
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4903
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4904
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4905
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4906
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4907
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4908
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4909
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4910
 * Helper function - strpos() with arrays.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4911
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4912
 * @param     string    $haystack
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4913
 * @param     array     $needles
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4914
 * @return    bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4915
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4916
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4917
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4918
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4919
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4920
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4921
  function ot_array_keys_exists( $array, $keys ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4922
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4923
    foreach($keys as $k) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4924
      if ( isset($array[$k]) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4925
        return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4926
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4927
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4928
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4929
    return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4930
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4931
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4932
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4933
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4934
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4935
 * Custom stripslashes from single value or array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4936
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4937
 * @param       mixed   $input
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4938
 * @return      mixed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4939
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4940
 * @access      public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4941
 * @since       2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4942
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4943
if ( ! function_exists( 'ot_stripslashes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4944
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4945
  function ot_stripslashes( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4946
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4947
    if ( is_array( $input ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4948
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4949
      foreach( $input as &$val ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4950
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4951
        if ( is_array( $val ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4952
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4953
          $val = ot_stripslashes( $val );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4954
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4955
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4956
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4957
          $val = stripslashes( trim( $val ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4958
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4959
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4960
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4961
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4962
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4963
    } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4964
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4965
      $input = stripslashes( trim( $input ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4966
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4967
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4968
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4969
    return $input;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4970
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4971
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4972
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4973
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4974
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4975
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4976
 * Reverse wpautop.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4977
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4978
 * @param     string    $string The string to be filtered
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4979
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4980
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4981
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4982
 * @since     2.0.9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4983
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4984
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4985
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4986
  function ot_reverse_wpautop( $string = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4987
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4988
    /* return if string is empty */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4989
    if ( trim( $string ) === '' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4990
      return '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4991
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4992
    /* remove all new lines & <p> tags */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4993
    $string = str_replace( array( "\n", "<p>" ), "", $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4994
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4995
    /* replace <br /> with \r */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4996
    $string = str_replace( array( "<br />", "<br>", "<br/>" ), "\r", $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4997
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4998
    /* replace </p> with \r\n */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4999
    $string = str_replace( "</p>", "\r\n", $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5000
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5001
    /* return clean string */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5002
    return trim( $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5003
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5004
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5005
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5006
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5007
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5008
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5009
 * Returns an array of elements from start to limit, inclusive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5010
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5011
 * Occasionally zero will be some impossibly large number to 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5012
 * the "E" power when creating a range from negative to positive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5013
 * This function attempts to fix that by setting that number back to "0".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5014
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5015
 * @param     string    $start First value of the sequence.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5016
 * @param     string    $limit The sequence is ended upon reaching the limit value.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5017
 * @param     string    $step If a step value is given, it will be used as the increment 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5018
 *                      between elements in the sequence. step should be given as a 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5019
 *                      positive number. If not specified, step will default to 1.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5020
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5021
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5022
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5023
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5024
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5025
function ot_range( $start, $limit, $step = 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5026
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5027
  if ( $step < 0 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5028
    $step = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5029
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5030
  $range = range( $start, $limit, $step );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5031
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5032
  foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5033
    if ( strpos( $v, 'E' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5034
      $range[$k] = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5035
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5036
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5037
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5038
  return $range;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5039
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5040
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5041
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5042
 * Helper function to return encoded strings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5043
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5044
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5045
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5046
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5047
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5048
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5049
function ot_encode( $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5050
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5051
  $func = 'base64' . '_encode';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5052
  return $func( $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5053
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5054
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5055
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5056
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5057
 * Helper function to return decoded strings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5058
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5059
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5060
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5061
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5062
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5063
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5064
function ot_decode( $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5065
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5066
  $func = 'base64' . '_decode';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5067
  return $func( $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5068
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5069
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5070
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5071
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5072
 * Helper function to open a file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5073
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5074
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5075
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5076
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5077
function ot_file_open( $handle, $mode ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5078
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5079
  $func = 'f' . 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5080
  return @$func( $handle, $mode );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5081
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5082
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5083
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5084
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5085
 * Helper function to close a file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5086
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5087
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5088
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5089
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5090
function ot_file_close( $handle ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5091
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5092
  $func = 'f' . 'close';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5093
  return $func( $handle );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5094
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5095
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5096
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5097
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5098
 * Helper function to write to an open file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5099
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5100
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5101
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5102
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5103
function ot_file_write( $handle, $string ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5105
  $func = 'f' . 'write';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5106
  return $func( $handle, $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5107
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5108
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5109
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5110
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5111
 * Helper function to filter standard option values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5112
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5113
 * @param     mixed     $value Saved string or array value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5114
 * @param     mixed     $std Standard string or array value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5115
 * @return    mixed     String or array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5116
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5117
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5118
 * @since     2.0.15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5119
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5120
function ot_filter_std_value( $value = '', $std = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5121
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5122
  $std = maybe_unserialize( $std );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5123
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5124
  if ( is_array( $value ) && is_array( $std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5125
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5126
    foreach( $value as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5127
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5128
      if ( '' == $value[$k] && isset( $std[$k] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5129
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5130
        $value[$k] = $std[$k];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5131
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5132
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5133
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5134
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5135
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5136
  } else if ( '' == $value && ! empty( $std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5137
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5138
    $value = $std;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5139
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5140
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5141
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5142
  return $value;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5143
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5144
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5145
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5146
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5147
 * Helper function to set the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5148
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5149
 * @param     string    $id The option ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5150
 * @param     bool      $value The option value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5151
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5152
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5153
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5154
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5155
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5156
function ot_set_google_fonts( $id = '', $value = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5157
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5158
  $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5159
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5160
  if ( is_array( $value ) && ! empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5161
    $ot_set_google_fonts[$id] = $value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5162
  } else if ( isset( $ot_set_google_fonts[$id] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5163
    unset( $ot_set_google_fonts[$id] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5164
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5165
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5166
  set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5167
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5168
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5169
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5170
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5171
 * Helper function to remove unused options from the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5172
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5173
 * @param     array     $options The array of saved options.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5174
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5175
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5176
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5177
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5178
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5179
function ot_update_google_fonts_after_save( $options ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5180
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5181
  $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5182
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5183
  foreach( $ot_set_google_fonts as $key => $set ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5184
    if ( ! isset( $options[$key] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5185
      unset( $ot_set_google_fonts[$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5186
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5187
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5188
  set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5189
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5190
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5191
add_action( 'ot_after_theme_options_save', 'ot_update_google_fonts_after_save', 1 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5192
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5193
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5194
 * Helper function to fetch the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5195
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5196
 * @param     bool      $normalize Whether or not to return a normalized array. Default 'true'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5197
 * @param     bool      $force_rebuild Whether or not to force the array to be rebuilt. Default 'false'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5198
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5199
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5200
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5201
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5202
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5203
function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5204
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5205
  /* Google Fonts cache key */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5206
  $ot_google_fonts_cache_key = apply_filters( 'ot_google_fonts_cache_key', 'ot_google_fonts_cache' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5207
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5208
  /* get the fonts from cache */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5209
  $ot_google_fonts = apply_filters( 'ot_google_fonts_cache', get_transient( $ot_google_fonts_cache_key ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5210
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5211
  if ( $force_rebuild || ! is_array( $ot_google_fonts ) || empty( $ot_google_fonts ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5212
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5213
    $ot_google_fonts = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5214
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5215
    /* API url and key */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5216
    $ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5217
    $ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', 'AIzaSyB8G-4UtQr9fhDYTiNrDP40Y5GYQQKrNWI' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5218
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5219
    /* API arguments */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5220
    $ot_google_fonts_fields = apply_filters( 'ot_google_fonts_fields', array( 'family', 'variants', 'subsets' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5221
    $ot_google_fonts_sort   = apply_filters( 'ot_google_fonts_sort', 'alpha' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5222
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5223
    /* Initiate API request */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5224
    $ot_google_fonts_query_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5225
      'key'    => $ot_google_fonts_api_key, 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5226
      'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')', 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5227
      'sort'   => $ot_google_fonts_sort
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5228
    );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5229
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5230
    /* Build and make the request */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5231
    $ot_google_fonts_query = esc_url_raw( add_query_arg( $ot_google_fonts_query_args, $ot_google_fonts_api_url ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5232
    $ot_google_fonts_response = wp_safe_remote_get( $ot_google_fonts_query, array( 'sslverify' => false, 'timeout' => 15 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5233
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5234
    /* continue if we got a valid response */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5235
    if ( 200 == wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5236
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5237
      if ( $response_body = wp_remote_retrieve_body( $ot_google_fonts_response ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5238
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5239
        /* JSON decode the response body and cache the result */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5240
        $ot_google_fonts_data = json_decode( trim( $response_body ), true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5241
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5242
        if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5243
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5244
          $ot_google_fonts = $ot_google_fonts_data['items'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5245
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5246
          // Normalize the array key
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5247
          $ot_google_fonts_tmp = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5248
          foreach( $ot_google_fonts as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5249
            $id = remove_accents( $value['family'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5250
            $id = strtolower( $id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5251
            $id = preg_replace( '/[^a-z0-9_\-]/', '', $id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5252
            $ot_google_fonts_tmp[$id] = $value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5253
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5254
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5255
          $ot_google_fonts = $ot_google_fonts_tmp;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5256
          set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5257
          set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5258
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5259
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5260
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5261
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5262
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5263
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5264
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5265
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5266
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5267
  return $normalize ? ot_normalize_google_fonts( $ot_google_fonts ) : $ot_google_fonts;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5268
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5269
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5270
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5271
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5272
 * Helper function to normalize the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5273
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5274
 * @param     array     $google_fonts An array of fonts to nrmalize.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5275
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5276
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5277
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5278
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5279
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5280
function ot_normalize_google_fonts( $google_fonts ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5281
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5282
  $ot_normalized_google_fonts = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5283
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5284
  if ( is_array( $google_fonts ) && ! empty( $google_fonts ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5285
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5286
    foreach( $google_fonts as $google_font ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5287
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5288
      if( isset( $google_font['family'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5289
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5290
        $id = str_replace( ' ', '+', $google_font['family'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5291
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5292
        $ot_normalized_google_fonts[ $id ] = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5293
          'family' => $google_font['family']
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5294
        );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5295
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5296
        if( isset( $google_font['variants'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5297
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5298
          $ot_normalized_google_fonts[ $id ]['variants'] = $google_font['variants'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5299
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5300
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5301
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5302
        if( isset( $google_font['subsets'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5303
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5304
          $ot_normalized_google_fonts[ $id ]['subsets'] = $google_font['subsets'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5305
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5306
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5307
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5308
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5309
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5310
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5311
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5312
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5313
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5314
  return $ot_normalized_google_fonts;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5315
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5316
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5317
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5318
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5319
 * Helper function to register a WPML string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5320
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5321
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5322
 * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5323
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5324
function ot_wpml_register_string( $id, $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5325
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5326
  if ( function_exists( 'icl_register_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5327
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5328
    icl_register_string( 'Theme Options', $id, $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5329
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5330
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5331
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5332
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5333
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5334
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5335
 * Helper function to unregister a WPML string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5336
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5337
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5338
 * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5339
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5340
function ot_wpml_unregister_string( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5341
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5342
  if ( function_exists( 'icl_unregister_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5343
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5344
    icl_unregister_string( 'Theme Options', $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5345
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5346
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5347
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5348
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5349
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5350
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5351
 * Maybe migrate Settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5352
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5353
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5354
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5355
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5356
 * @since     2.3.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5357
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5358
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5359
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5360
  function ot_maybe_migrate_settings() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5361
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5362
    // Filter the ID to migrate from
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5363
    $settings_id = apply_filters( 'ot_migrate_settings_id', '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5364
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5365
    // Attempt to migrate Settings 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5366
    if ( ! empty( $settings_id ) && get_option( ot_settings_id() ) === false && ot_settings_id() !== $settings_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5367
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5368
      // Old settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5369
      $settings = get_option( $settings_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5370
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5371
      // Check for array keys
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5372
      if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5373
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5374
        update_option( ot_settings_id(), $settings );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5375
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5376
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5377
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5378
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5379
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5380
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5381
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5382
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5383
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5384
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5385
 * Maybe migrate Option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5386
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5387
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5388
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5389
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5390
 * @since     2.3.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5391
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5392
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5393
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5394
  function ot_maybe_migrate_options() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5395
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5396
    // Filter the ID to migrate from
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5397
    $options_id = apply_filters( 'ot_migrate_options_id', '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5398
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5399
    // Attempt to migrate Theme Options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5400
    if ( ! empty( $options_id ) && get_option( ot_options_id() ) === false && ot_options_id() !== $options_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5401
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5402
      // Old options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5403
      $options = get_option( $options_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5404
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5405
      // Migrate to new ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5406
      update_option( ot_options_id(), $options );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5407
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5408
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5409
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5410
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5411
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5412
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5413
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5414
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5415
 * Maybe migrate Layouts
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5416
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5417
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5418
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5419
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5420
 * @since     2.3.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5421
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5422
if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5423
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5424
  function ot_maybe_migrate_layouts() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5425
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5426
    // Filter the ID to migrate from
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5427
    $layouts_id = apply_filters( 'ot_migrate_layouts_id', '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5428
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5429
    // Attempt to migrate Layouts
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5430
    if ( ! empty( $layouts_id ) && get_option( ot_layouts_id() ) === false && ot_layouts_id() !== $layouts_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5431
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5432
      // Old options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5433
      $layouts = get_option( $layouts_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5434
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5435
      // Migrate to new ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5436
      update_option( ot_layouts_id(), $layouts );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5437
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5438
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5439
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5440
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5441
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5442
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5443
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5444
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5445
 * Returns an array with the post format gallery meta box.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5446
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5447
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5448
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5449
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5450
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5451
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5452
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5453
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5454
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5455
function ot_meta_box_post_format_gallery( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5456
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5457
  if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'gallery', current( get_theme_support( 'post-formats' ) ) ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5458
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5459
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5460
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5461
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5462
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5463
  return apply_filters( 'ot_meta_box_post_format_gallery', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5464
    'id'        => 'ot-post-format-gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5465
    'title'     => __( 'Gallery', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5466
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5467
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5468
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5469
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5470
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5471
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5472
        'id'          => '_format_gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5473
        'label'       => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5474
        'desc'        => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5475
        'std'         => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5476
        'type'        => 'gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5477
        'class'       => 'ot-gallery-shortcode'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5478
      )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5479
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5480
  ), $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5481
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5482
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5483
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5484
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5485
 * Returns an array with the post format link metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5486
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5487
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5488
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5489
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5490
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5491
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5492
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5493
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5494
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5495
function ot_meta_box_post_format_link( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5496
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5497
  if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ) ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5498
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5499
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5500
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5501
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5502
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5503
  return apply_filters( 'ot_meta_box_post_format_link', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5504
    'id'        => 'ot-post-format-link',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5505
    'title'     => __( 'Link', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5506
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5507
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5508
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5509
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5510
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5511
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5512
        'id'      => '_format_link_url',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5513
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5514
        'desc'    => __( 'Link URL', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5515
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5516
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5517
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5518
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5519
        'id'      => '_format_link_title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5520
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5521
        'desc'    => __( 'Link Title', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5522
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5523
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5524
      )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5525
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5526
  ), $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5527
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5528
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5529
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5530
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5531
 * Returns an array with the post format quote metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5532
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5533
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5534
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5535
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5536
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5537
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5538
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5539
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5540
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5541
function ot_meta_box_post_format_quote( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5542
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5543
  if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ) ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5544
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5545
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5546
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5547
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5548
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5549
  return apply_filters( 'ot_meta_box_post_format_quote', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5550
    'id'        => 'ot-post-format-quote',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5551
    'title'     => __( 'Quote', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5552
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5553
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5554
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5555
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5556
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5557
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5558
        'id'      => '_format_quote_source_name',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5559
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5560
        'desc'    => __( 'Source Name (ex. author, singer, actor)', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5561
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5562
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5563
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5564
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5565
        'id'      => '_format_quote_source_url',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5566
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5567
        'desc'    => __( 'Source URL', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5568
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5569
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5570
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5571
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5572
        'id'      => '_format_quote_source_title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5573
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5574
        'desc'    => __( 'Source Title (ex. book, song, movie)', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5575
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5576
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5577
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5578
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5579
        'id'      => '_format_quote_source_date',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5580
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5581
        'desc'    => __( 'Source Date', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5582
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5583
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5584
      )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5585
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5586
  ), $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5587
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5588
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5589
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5590
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5591
 * Returns an array with the post format video metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5592
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5593
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5594
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5595
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5596
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5597
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5598
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5599
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5600
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5601
function ot_meta_box_post_format_video( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5602
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5603
  if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ) ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5604
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5605
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5606
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5607
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5608
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5609
  return apply_filters( 'ot_meta_box_post_format_video', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5610
    'id'        => 'ot-post-format-video',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5611
    'title'     => __( 'Video', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5612
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5613
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5614
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5615
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5616
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5617
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5618
        'id'      => '_format_video_embed',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5619
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5620
        'desc'    => sprintf( __( 'Embed video from services like Youtube, Vimeo, or Hulu. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ), '<a href="http://codex.wordpress.org/Embeds" target="_blank">' . __( 'Wordpress Codex', 'option-tree' ) .'</a>', '<code>[video]</code>' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5621
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5622
        'type'    => 'textarea'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5623
      )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5624
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5625
  ), $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5626
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5627
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5628
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5629
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5630
 * Returns an array with the post format audio metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5631
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5632
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5633
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5634
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5635
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5636
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5637
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5638
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5639
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5640
function ot_meta_box_post_format_audio( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5641
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5642
  if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ) ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5643
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5644
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5645
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5646
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5647
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5648
  return apply_filters( 'ot_meta_box_post_format_audio', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5649
    'id'        => 'ot-post-format-audio',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5650
    'title'     => __( 'Audio', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5651
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5652
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5653
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5654
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5655
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5656
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5657
        'id'      => '_format_audio_embed',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5658
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5659
        'desc'    => sprintf( __( 'Embed audio from services like SoundCloud and Rdio. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ), '<a href="http://codex.wordpress.org/Embeds" target="_blank">' . __( 'Wordpress Codex', 'option-tree' ) .'</a>', '<code>[audio]</code>' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5660
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5661
        'type'    => 'textarea'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5662
      )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5663
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5664
  ), $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5665
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5666
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5667
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5668
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5669
 * Returns the option type by ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5670
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5671
 * @param     string    $option_id The option ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5672
 * @return    string    $settings_id The settings array ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5673
 * @return    string    The option type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5674
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5675
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5676
 * @since     2.4.2
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5677
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5678
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5679
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5680
  function ot_get_option_type_by_id( $option_id, $settings_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5681
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5682
    if ( empty( $settings_id ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5683
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5684
      $settings_id = ot_settings_id();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5685
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5686
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5687
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5688
    $settings = get_option( $settings_id, array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5689
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5690
    if ( isset( $settings['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5691
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5692
      foreach( $settings['settings'] as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5693
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5694
        if ( $option_id == $value['id'] && isset( $value['type'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5695
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5696
          return $value['type'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5697
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5698
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5699
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5700
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5701
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5702
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5703
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5704
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5705
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5706
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5707
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5708
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5709
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5710
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5711
 * Build an array of potential Theme Options that could share terms
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5712
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5713
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5714
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5715
 * @access    private
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5716
 * @since     2.5.4
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5717
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5718
function _ot_settings_potential_shared_terms() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5719
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5720
  $options      = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5721
  $settings     = get_option( ot_settings_id(), array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5722
  $option_types = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5723
    'category-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5724
    'category-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5725
    'tag-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5726
    'tag-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5727
    'taxonomy-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5728
    'taxonomy-select'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5729
  );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5730
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5731
  if ( isset( $settings['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5732
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5733
    foreach( $settings['settings'] as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5734
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5735
      if ( isset( $value['type'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5736
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5737
        if ( $value['type'] == 'list-item' && isset( $value['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5738
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5739
          $saved = ot_get_option( $value['id'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5740
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5741
          foreach( $value['settings'] as $item ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5742
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5743
            if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5744
              $sub_options = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5745
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5746
              foreach( $saved as $sub_key => $sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5747
                if ( isset( $sub_value[$item['id']] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5748
                  $sub_options[$sub_key] = $sub_value[$item['id']];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5749
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5750
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5751
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5752
              if ( ! empty( $sub_options ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5753
                $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5754
                  'id'       => $item['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5755
                  'taxonomy' => $value['taxonomy'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5756
                  'parent'   => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5757
                  'value'    => $sub_options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5758
                );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5759
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5760
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5761
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5762
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5763
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5764
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5765
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5766
        if ( in_array( $value['type'], $option_types ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5767
          $saved = ot_get_option( $value['id'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5768
          if ( ! empty( $saved ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5769
            $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5770
              'id'       => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5771
              'taxonomy' => $value['taxonomy'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5772
              'value'    => $saved
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5773
            );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5774
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5775
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5776
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5777
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5778
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5779
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5780
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5781
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5782
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5783
  return $options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5784
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5785
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5786
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5787
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5788
 * Build an array of potential Meta Box options that could share terms
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5789
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5790
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5791
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5792
 * @access    private
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5793
 * @since     2.5.4
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5794
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5795
function _ot_meta_box_potential_shared_terms() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5796
  global $ot_meta_boxes;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5797
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5798
  $options      = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5799
  $settings     = $ot_meta_boxes;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5800
  $option_types = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5801
    'category-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5802
    'category-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5803
    'tag-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5804
    'tag-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5805
    'taxonomy-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5806
    'taxonomy-select'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5807
  );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5808
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5809
  foreach( $settings as $setting ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5810
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5811
    if ( isset( $setting['fields'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5812
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5813
      foreach( $setting['fields'] as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5814
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5815
        if ( isset( $value['type'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5816
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5817
          if ( $value['type'] == 'list-item' && isset( $value['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5818
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5819
            $children = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5820
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5821
            foreach( $value['settings'] as $item ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5822
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5823
              if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5824
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5825
                $children[$value['id']][] = $item['id'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5826
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5827
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5828
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5829
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5830
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5831
            if ( ! empty( $children[$value['id']] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5832
              $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5833
                'id'       => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5834
                'children' => $children[$value['id']],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5835
                'taxonomy' => $value['taxonomy'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5836
              );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5837
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5838
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5839
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5840
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5841
          if ( in_array( $value['type'], $option_types ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5842
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5843
            $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5844
              'id'       => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5845
              'taxonomy' => $value['taxonomy'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5846
            );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5847
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5848
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5849
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5850
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5851
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5852
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5853
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5854
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5855
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5856
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5857
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5858
  return $options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5859
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5860
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5861
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5862
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5863
 * Update terms when a term gets split.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5864
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5865
 * @param     int     $term_id ID of the formerly shared term.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5866
 * @param     int     $new_term_id ID of the new term created for the $term_taxonomy_id.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5867
 * @param     int     $term_taxonomy_id ID for the term_taxonomy row affected by the split.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5868
 * @param     string  $taxonomy Taxonomy for the split term.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5869
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5870
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5871
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5872
 * @since     2.5.4
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5873
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5874
function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5875
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5876
  // Process the Theme Options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5877
  $settings    = _ot_settings_potential_shared_terms();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5878
  $old_options = get_option( ot_options_id(), array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5879
  $new_options = $old_options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5880
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5881
  // Process the saved settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5882
  if ( ! empty( $settings ) && ! empty( $old_options ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5883
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5884
    // Loop over the Theme Options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5885
    foreach( $settings as $option ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5886
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5887
      if ( ! is_array( $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5888
        $option['taxonomy'] = explode( ',', $option['taxonomy'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5889
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5890
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5891
      if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5892
        continue;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5893
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5894
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5895
      // The option ID was found
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5896
      if ( array_key_exists( $option['id'], $old_options ) || ( isset( $option['parent'] ) && array_key_exists( $option['parent'], $old_options ) ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5897
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5898
        // This is a list item, we have to go deeper
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5899
        if ( isset( $option['parent'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5900
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5901
          // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5902
          foreach( $option['value'] as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5903
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5904
            // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5905
            if ( is_array( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5906
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5907
              // Loop over the sub array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5908
              foreach( $value as $sub_key => $sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5909
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5910
                if ( $sub_value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5911
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5912
                  unset( $new_options[$option['parent']][$key][$option['id']][$sub_key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5913
                  $new_options[$option['parent']][$key][$option['id']][$new_term_id] = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5914
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5915
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5916
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5917
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5918
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5919
            } else if ( $value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5920
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5921
              unset( $new_options[$option['parent']][$key][$option['id']] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5922
              $new_options[$option['parent']][$key][$option['id']] = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5923
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5924
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5925
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5926
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5927
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5928
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5929
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5930
          // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5931
          if ( is_array( $option['value'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5932
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5933
            // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5934
            foreach( $option['value'] as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5935
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5936
              // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5937
              if ( $value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5938
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5939
                unset( $new_options[$option['id']][$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5940
                $new_options[$option['id']][$new_term_id] = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5941
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5942
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5943
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5944
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5945
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5946
          // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5947
          } else if ( $option['value'] == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5948
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5949
            $new_options[$option['id']] = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5950
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5951
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5952
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5953
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5954
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5955
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5956
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5957
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5958
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5959
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5960
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5961
  // Options need to be updated
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5962
  if ( $old_options !== $new_options ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5963
    update_option( ot_options_id(), $new_options );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5964
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5965
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5966
  // Process the Meta Boxes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5967
  $meta_settings = _ot_meta_box_potential_shared_terms();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5968
  $option_types  = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5969
    'category-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5970
    'category-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5971
    'tag-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5972
    'tag-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5973
    'taxonomy-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5974
    'taxonomy-select'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5975
  );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5976
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5977
  if ( ! empty( $meta_settings ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5978
    $old_meta = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5979
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5980
    foreach( $meta_settings as $option ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5981
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5982
      if ( ! is_array( $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5983
        $option['taxonomy'] = explode( ',', $option['taxonomy'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5984
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5985
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5986
      if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5987
        continue;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5988
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5989
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5990
      if ( isset( $option['children'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5991
        $post_ids = get_posts( array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5992
          'fields'     => 'ids',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5993
          'meta_key'   => $option['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5994
        ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5995
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5996
        if ( $post_ids ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5997
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5998
          foreach( $post_ids as $post_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5999
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6000
            // Get the meta
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6001
            $old_meta = get_post_meta( $post_id, $option['id'], true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6002
            $new_meta = $old_meta;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6003
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6004
            // Has a saved value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6005
            if ( ! empty( $old_meta ) && is_array( $old_meta ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6006
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6007
              // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6008
              foreach( $old_meta as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6009
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6010
                foreach( $value as $sub_key => $sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6011
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6012
                  if ( in_array( $sub_key, $option['children'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6013
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6014
                    // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6015
                    if ( is_array( $sub_value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6016
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6017
                      // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6018
                      foreach( $sub_value as $sub_sub_key => $sub_sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6019
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6020
                        // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6021
                        if ( $sub_sub_value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6022
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6023
                          unset( $new_meta[$key][$sub_key][$sub_sub_key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6024
                          $new_meta[$key][$sub_key][$new_term_id] = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6025
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6026
                        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6027
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6028
                      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6029
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6030
                    // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6031
                    } else if ( $sub_value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6032
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6033
                      $new_meta[$key][$sub_key] = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6034
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6035
                    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6036
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6037
                  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6038
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6039
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6040
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6041
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6042
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6043
              // Update
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6044
              if ( $old_meta !== $new_meta ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6045
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6046
                update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6047
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6048
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6049
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6050
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6051
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6052
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6053
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6054
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6055
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6056
      } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6057
        $post_ids = get_posts( array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6058
          'fields'     => 'ids',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6059
          'meta_query' => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6060
            'key'     => $option['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6061
            'value'   => $term_id,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6062
            'compare' => 'IN'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6063
          ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6064
        ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6065
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6066
        if ( $post_ids ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6067
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6068
          foreach( $post_ids as $post_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6069
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6070
            // Get the meta
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6071
            $old_meta = get_post_meta( $post_id, $option['id'], true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6072
            $new_meta = $old_meta;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6073
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6074
            // Has a saved value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6075
            if ( ! empty( $old_meta ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6076
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6077
              // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6078
              if ( is_array( $old_meta ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6079
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6080
                // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6081
                foreach( $old_meta as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6082
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6083
                  // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6084
                  if ( $value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6085
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6086
                    unset( $new_meta[$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6087
                    $new_meta[$new_term_id] = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6088
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6089
                  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6090
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6091
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6092
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6093
              // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6094
              } else if ( $old_meta == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6095
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6096
                $new_meta = $new_term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6097
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6098
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6099
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6100
              // Update
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6101
              if ( $old_meta !== $new_meta ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6102
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6103
                update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6104
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6105
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6106
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6107
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6108
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6109
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6110
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6111
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6112
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6113
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6114
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6115
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6116
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6117
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6118
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6119
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6120
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6121
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6122
/* End of file ot-functions-admin.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6123
/* Location: ./includes/ot-functions-admin.php */