wp/wp-content/plugins/option-tree/includes/ot-functions-admin.php
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 17:39:30 +0200
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 11 bf1778c34b9a
permissions -rwxr-xr-x
resynchronize code repo with production
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' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   846
      'nonce'                 => wp_create_nonce( 'option_tree' ),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   847
      'upload_text'           => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
      'remove_media_text'     => __( 'Remove Media', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
      '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
   850
      '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
   851
      'remove_agree'          => __( 'Are you sure you want to remove this?', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
      '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
   853
      '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
   854
      'delete'                => __( 'Delete Gallery', 'option-tree' ), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   855
      'edit'                  => __( 'Edit Gallery', 'option-tree' ), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   856
      'create'                => __( 'Create Gallery', 'option-tree' ), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   857
      '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
   858
      'date_current'          => __( 'Today', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   859
      'date_time_current'     => __( 'Now', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   860
      'date_close'            => __( 'Close', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   861
      'replace'               => __( 'Featured Image', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   862
      'with'                  => __( 'Image', 'option-tree' )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
    /* localized script attached to 'option_tree' */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
    wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   867
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   868
    /* execute scripts after actions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   869
    do_action( 'ot_admin_scripts_after' );
0
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   876
 * Returns the ID of a custom post type by post_title.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
 * @uses        get_results()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
 * @return      int
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
 * @access      public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
 * @since       2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   884
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   886
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   887
  function ot_get_media_post_ID() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   888
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   889
    // Option ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   890
    $option_id = 'ot_media_post_ID';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   891
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   892
    // Get the media post ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   893
    $post_ID = get_option( $option_id, false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   894
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   895
    // Add $post_ID to the DB
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
    if ( $post_ID === false || empty( $post_ID ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   897
      global $wpdb;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   898
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   899
      // Get the media post ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   900
      $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
   901
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   902
      // Add to the DB
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   903
      if ( $post_ID !== null )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   904
        update_option( $option_id, $post_ID );
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
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   908
    return $post_ID;
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
 * Register custom post type & create the media post used to attach images.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
 * @uses        get_results()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   918
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
 * @return      void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
 * @access      public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
 * @since       2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
if ( ! function_exists( 'ot_create_media_post' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
  function ot_create_media_post() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   928
    $regsiter_post_type = 'register_' . 'post_type';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   929
    $regsiter_post_type( 'option-tree', array(
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   930
      'labels'              => array( 'name' => __( 'Option Tree', 'option-tree' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
      'public'              => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
      'show_ui'             => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
      'capability_type'     => 'post',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
      'exclude_from_search' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
      'hierarchical'        => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
      'rewrite'             => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
      'supports'            => array( 'title', 'editor' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
      'can_export'          => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
      'show_in_nav_menus'   => false
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
    ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
    /* look for custom page */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
    $post_id = ot_get_media_post_ID();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
    /* no post exists */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
    if ( $post_id == 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
      /* create post object */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
      $_p = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
      $_p['post_title']     = 'Media';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   951
      $_p['post_name']      = 'media';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
      $_p['post_status']    = 'private';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
      $_p['post_type']      = 'option-tree';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
      $_p['comment_status'] = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
      $_p['ping_status']    = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
      /* insert the post into the database */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
      wp_insert_post( $_p );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
 * Setup default settings array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   969
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
if ( ! function_exists( 'ot_default_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   976
  function ot_default_settings() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   977
    global $wpdb;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   978
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   979
    if ( ! get_option( ot_settings_id() ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
      $section_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
      $settings_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
      $settings = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   984
      $table_name = $wpdb->prefix . 'option_tree';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   985
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   986
      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
   987
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
        foreach ( $old_settings as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   990
          /* heading is a section now */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
          if ( $setting->item_type == 'heading' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   992
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
            /* add section to the sections array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   994
            $settings['sections'][$section_count]['id'] = $setting->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
            $settings['sections'][$section_count]['title'] = $setting->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
            /* save the last section id to use in creating settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
            $section = $setting->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
            /* increment the section count */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
            $section_count++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1003
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
            /* add setting to the settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1006
            $settings['settings'][$settings_count]['id'] = $setting->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
            $settings['settings'][$settings_count]['label'] = $setting->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1008
            $settings['settings'][$settings_count]['desc'] = $setting->item_desc;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
            $settings['settings'][$settings_count]['section'] = $section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
            $settings['settings'][$settings_count]['type'] = ot_map_old_option_types( $setting->item_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1011
            $settings['settings'][$settings_count]['std'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
            $settings['settings'][$settings_count]['class'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
            /* textarea rows */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1015
            $rows = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1016
            if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
              if ( (int) $setting->item_options > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
                $rows = (int) $setting->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
              } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
                $rows = 15;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1022
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
            $settings['settings'][$settings_count]['rows'] = $rows;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
            
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
            $post_type = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
            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
  1028
              if ( '' != $setting->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
                $post_type = $setting->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
              } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
                $post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
            $settings['settings'][$settings_count]['post_type'] = $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
            /* choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
            $choices = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
            if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
              if ( '' != $setting->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
                $choices = ot_convert_string_to_array( $setting->item_options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
            $settings['settings'][$settings_count]['choices'] = $choices;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
            $settings_count++;
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
        /* make sure each setting has a section just incase */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
        if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
          foreach( $settings['settings'] as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
            if ( '' == $setting['section'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
              $settings['settings'][$k]['section'] = $settings['sections'][0]['id'];
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
      /* if array if not properly formed create fallback settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
      if ( ! isset( $settings['sections'] ) || ! isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
        $settings = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
          'sections' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
            array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
              'id'        => 'general',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
              'title'     => __( 'General', 'option-tree' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
            )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
          ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
          'settings' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
            array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
              'id'        => 'sample_text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
              'label'     => __( 'Sample Text Field Label', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
              'desc'      => __( 'Description for the sample text field.', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
              'section'   => 'general',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
              'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
              'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
              'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
              'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
              'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
              'choices'   => array()
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1089
      /* update the settings array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1090
      update_option( ot_settings_id(), $settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
      /* get option tree array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1093
      $options = get_option( ot_options_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
      /* validate options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
      if ( is_array( $options ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
        foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
          if ( isset( $options[$setting['id']] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
            $content = ot_stripslashes( $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
            $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
        /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
        do_action( 'ot_before_theme_options_save', $options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
        /* update the option tree array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1114
        update_option( ot_options_id(), $options );
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
 * Helper function to update the CSS option type after save.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1131
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1132
if ( ! function_exists( 'ot_save_css' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
  function ot_save_css( $options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1136
    /* grab a copy of the settings */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1137
    $settings = get_option( ot_settings_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
    /* has settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
    if ( isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1141
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1142
      /* loop through sections and insert CSS when needed */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1143
      foreach( $settings['settings'] as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
        /* is the CSS option type */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
        if ( isset( $setting['type'] ) && 'css' == $setting['type'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1148
          /* insert CSS into dynamic.css */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
          if ( isset( $options[$setting['id']] ) && '' !== $options[$setting['id']] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
            ot_insert_css_with_markers( $setting['id'], $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
          /* remove old CSS from dynamic.css */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1154
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
            ot_remove_old_css( $setting['id'] );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
 * Helper function to load filters for XML mime type.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1172
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
if ( ! function_exists( 'ot_add_xml_to_upload_filetypes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1179
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
  function ot_add_xml_to_upload_filetypes() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1181
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
    add_filter( 'upload_mimes', 'ot_upload_mimes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
    add_filter( 'wp_mime_type_icon', 'ot_xml_mime_type_icon', 10, 2 );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
 * Filter 'upload_mimes' and add xml. 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1191
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
 * @param     array     $mimes An array of valid upload mime types
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1193
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1194
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1195
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
if ( ! function_exists( 'ot_upload_mimes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1199
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
  function ot_upload_mimes( $mimes ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1201
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
    $mimes['xml'] = 'application/xml';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1203
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
    return $mimes;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1211
 * Filters 'wp_mime_type_icon' and have xml display as a document.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1213
 * @param     string    $icon The mime icon
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
 * @param     string    $mime The mime type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1219
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1220
if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1221
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1222
  function ot_xml_mime_type_icon( $icon, $mime ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1223
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1224
    if ( $mime == 'application/xml' || $mime == 'text/xml' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1225
      return wp_mime_type_icon( 'document' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1226
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1227
    return $icon;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1234
 * Import before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1235
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1238
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1241
if ( ! function_exists( 'ot_import' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1242
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1243
  function ot_import() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1244
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1245
    /* check and verify import xml nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1246
    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
  1247
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1248
      /* import input value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1249
      $file = isset( $_POST['import_xml'] ) ? esc_url( $_POST['import_xml'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1250
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
      /* validate xml file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
      if ( preg_match( "/(.xml)$/i", $file ) && class_exists( 'SimpleXMLElement' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1254
        $settings = ot_import_xml( $file );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
      /* cleanup, save, & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
      if ( isset( $settings ) && ! empty( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
        /* delete file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1265
        if ( $file ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1266
          global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1267
          $attachmentid = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$file'" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
          wp_delete_attachment( $attachmentid, true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1269
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1270
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1271
        /* update settings */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1272
        update_option( ot_settings_id(), $settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1274
        /* set message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1275
        $message = 'success';
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1279
      /* redirect */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1280
      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
  1281
      exit;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1285
    /* check and verify import settings nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1286
    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
  1287
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1288
      /* textarea value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1289
      $textarea = isset( $_POST['import_settings'] ) ? unserialize( ot_decode( $_POST['import_settings'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1290
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1291
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1292
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1293
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1294
      /* is array: save & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1295
      if ( is_array( $textarea ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1296
        update_option( ot_settings_id(), $textarea );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1297
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1298
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1299
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1300
      /* redirect */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1301
      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
  1302
      exit;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
    /* check and verify import theme options data nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1307
    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
  1308
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1309
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1310
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1311
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1312
      /* textarea value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1313
      $options = isset( $_POST['import_data'] ) ? unserialize( ot_decode( $_POST['import_data'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1314
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1315
      /* get settings array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1316
      $settings = get_option( ot_settings_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1317
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1318
      /* has options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1319
      if ( is_array( $options ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1320
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1321
        /* validate options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1322
        if ( is_array( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1323
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1324
          foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
            if ( isset( $options[$setting['id']] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1327
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1328
              $content = ot_stripslashes( $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1330
              $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
        /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
        do_action( 'ot_before_theme_options_save', $options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1341
        /* update the option tree array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1342
        update_option( ot_options_id(), $options );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1344
        $message = 'success';
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1348
      /* redirect accordingly */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1349
      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
  1350
      exit;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
    /* check and verify import layouts nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1355
    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
  1356
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1357
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1358
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1359
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
      /* textarea value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
      $layouts = isset( $_POST['import_layouts'] ) ? unserialize( ot_decode( $_POST['import_layouts'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1363
      /* get settings array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1364
      $settings = get_option( ot_settings_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
      /* has layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
      if ( is_array( $layouts ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1368
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1369
        /* validate options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
        if ( is_array( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1371
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
          foreach( $layouts as $key => $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
            if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1375
              continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1376
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1377
            $options = unserialize( ot_decode( $value ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1378
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1379
            foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1380
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1381
              if ( isset( $options[$setting['id']] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1382
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1383
                $content = ot_stripslashes( $options[$setting['id']] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1384
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1385
                $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1391
            $layouts[$key] = ot_encode( serialize( $options ) );
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1397
        /* update the option tree array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1398
        if ( isset( $layouts['active_layout'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1399
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1400
          $new_options = unserialize( ot_decode( $layouts[$layouts['active_layout']] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1401
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1402
          /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1403
          do_action( 'ot_before_theme_options_save', $new_options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1404
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1405
          update_option( ot_options_id(), $new_options );
0
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1409
        /* update the option tree layouts array */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1410
        update_option( ot_layouts_id(), $layouts );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
        $message = 'success';
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1416
      /* redirect accordingly */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1417
      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
  1418
      exit;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1429
 * Export before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1430
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1431
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1432
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1433
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
 * @since     2.0.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
if ( ! function_exists( 'ot_export' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1437
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1438
  function ot_export() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1439
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1440
    /* check and verify export settings file nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1441
    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
  1442
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1443
      ot_export_php_settings_array();
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
 * Reusable XMl import helper function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1453
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1454
 * @param     string    $file The path to the file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
 * @return    mixed     False or an array of settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
 * @since     2.0.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1460
if ( ! function_exists( 'ot_import_xml' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
  function ot_import_xml( $file ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
    $get_data = wp_remote_get( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1465
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1466
    if ( is_wp_error( $get_data ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
      return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1468
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1469
    $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1470
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1471
    if ( $rawdata ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1472
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
      $section_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1474
      $settings_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1476
      $section = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
      $settings = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
      $xml = new SimpleXMLElement( $rawdata );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1480
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1481
      foreach ( $xml->row as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1482
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1483
        /* heading is a section now */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1484
        if ( $value->item_type == 'heading' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1485
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1486
          /* add section to the sections array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1487
          $settings['sections'][$section_count]['id'] = (string) $value->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1488
          $settings['sections'][$section_count]['title'] = (string) $value->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1489
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1490
          /* save the last section id to use in creating settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1491
          $section = (string) $value->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1493
          /* increment the section count */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1494
          $section_count++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1495
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1496
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1497
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1498
          /* add setting to the settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1499
          $settings['settings'][$settings_count]['id'] = (string) $value->item_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1500
          $settings['settings'][$settings_count]['label'] = (string) $value->item_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1501
          $settings['settings'][$settings_count]['desc'] = (string) $value->item_desc;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1502
          $settings['settings'][$settings_count]['section'] = $section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1503
          $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
  1504
          $settings['settings'][$settings_count]['std'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1505
          $settings['settings'][$settings_count]['class'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1506
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1507
          /* textarea rows */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1508
          $rows = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1509
          if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1510
            if ( (int) $value->item_options > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1511
              $rows = (int) $value->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1512
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
              $rows = 15;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1514
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1515
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1516
          $settings['settings'][$settings_count]['rows'] = $rows;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1517
          
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
          $post_type = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1520
          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
  1521
            if ( '' != (string) $value->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1522
              $post_type = (string) $value->item_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1523
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1524
              $post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1525
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1526
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1527
          $settings['settings'][$settings_count]['post_type'] = $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1529
          /* choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1530
          $choices = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1531
          if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1532
            if ( '' != (string) $value->item_options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1533
              $choices = ot_convert_string_to_array( (string) $value->item_options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1534
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1535
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1536
          $settings['settings'][$settings_count]['choices'] = $choices;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1537
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1538
          $settings_count++;
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1543
      /* make sure each setting has a section just incase */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
      if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
        foreach( $settings['settings'] as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1546
          if ( '' == $setting['section'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
            $settings['settings'][$k]['section'] = $settings['sections'][0]['id'];
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1552
      return $settings;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1556
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1562
 * Export the Theme Mode theme-options.php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1563
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1564
 * @return    attachment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1565
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1566
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1567
 * @since     2.0.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1568
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1569
if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1570
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
  function ot_export_php_settings_array() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1573
    $content              = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1574
    $build_settings       = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1575
    $contextual_help      = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1576
    $sections             = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1577
    $settings             = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1578
    $option_tree_settings = get_option( ot_settings_id(), array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1579
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1580
    // Domain string helper
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1581
    function ot_I18n_string( $string ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1582
      if ( ! empty( $string ) && isset( $_POST['domain'] ) && ! empty( $_POST['domain'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1583
        $domain = str_replace( ' ', '-', trim( $_POST['domain'] ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1584
        return "__( '$string', '$domain' )";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1585
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1586
      return "'$string'";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1587
    }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1588
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1589
    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
  1590
    header( "Pragma: no-cache ");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1591
    header( "Content-Description: File Transfer" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1592
    header( 'Content-Disposition: attachment; filename="theme-options.php"');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1593
    header( "Content-Type: application/octet-stream");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
    header( "Content-Transfer-Encoding: binary" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1595
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1596
    /* build contextual help content */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1597
    if ( isset( $option_tree_settings['contextual_help']['content'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1598
      $help = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1599
      foreach( $option_tree_settings['contextual_help']['content'] as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1600
        $_id = isset( $value['id'] ) ? $value['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1601
        $_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1602
        $_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
  1603
        $help.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1604
        array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1605
          'id'        => '$_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1606
          'title'     => $_title,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1607
          'content'   => $_content
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1608
        ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1609
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1610
      $help = substr_replace( $help, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1611
      $contextual_help = "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1612
      'content'       => array( $help
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1616
    /* build contextual help sidebar */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1617
    if ( isset( $option_tree_settings['contextual_help']['sidebar'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1618
      $contextual_help.= "
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1619
      '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
  1620
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1621
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
    /* check that $contexual_help has a value and add to $build_settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1623
    if ( '' != $contextual_help ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
      $build_settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1625
    'contextual_help' => array( $contextual_help
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1629
    /* build sections */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1630
    if ( isset( $option_tree_settings['sections'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1631
      foreach( $option_tree_settings['sections'] as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1632
        $_id = isset( $value['id'] ) ? $value['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1633
        $_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1634
        $sections.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1635
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
        'id'          => '$_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1637
        'title'       => $_title
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1638
      ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1639
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1640
      $sections = substr_replace( $sections, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1641
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1642
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1643
    /* check that $sections has a value and add to $build_settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1644
    if ( '' != $sections ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1645
      $build_settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
    'sections'        => array( $sections
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1650
    /* build settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1651
    if ( isset( $option_tree_settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1652
      foreach( $option_tree_settings['settings'] as $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1653
        $_id = isset( $value['id'] ) ? $value['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1654
        $_label = ot_I18n_string( isset( $value['label'] ) ? str_replace( "'", "\'", $value['label'] ) : '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1655
        $_desc = ot_I18n_string( isset( $value['desc'] ) ? str_replace( "'", "\'", $value['desc'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1656
        $_std = isset( $value['std'] ) ? str_replace( "'", "\'", $value['std'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
        $_type = isset( $value['type'] ) ? $value['type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1658
        $_section = isset( $value['section'] ) ? $value['section'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
        $_rows = isset( $value['rows'] ) ? $value['rows'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1660
        $_post_type = isset( $value['post_type'] ) ? $value['post_type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
        $_taxonomy = isset( $value['taxonomy'] ) ? $value['taxonomy'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1662
        $_min_max_step = isset( $value['min_max_step'] ) ? $value['min_max_step'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
        $_class = isset( $value['class'] ) ? $value['class'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1664
        $_condition = isset( $value['condition'] ) ? $value['condition'] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1665
        $_operator = isset( $value['operator'] ) ? $value['operator'] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1666
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
        $choices = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1668
        if ( isset( $value['choices'] ) && ! empty( $value['choices'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1669
          foreach( $value['choices'] as $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1670
            $_choice_value = isset( $choice['value'] ) ? str_replace( "'", "\'", $choice['value'] ) : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1671
            $_choice_label = ot_I18n_string( isset( $choice['label'] ) ? str_replace( "'", "\'", $choice['label'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1672
            $_choice_src = isset( $choice['src'] ) ? str_replace( "'", "\'", $choice['src'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1673
            $choices.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1674
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1675
            'value'       => '$_choice_value',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1676
            'label'       => $_choice_label,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1677
            'src'         => '$_choice_src'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1678
          ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1679
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
          $choices = substr_replace( $choices, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
          $choices = ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1682
        'choices'     => array( $choices
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1683
        )";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1684
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1685
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1686
        $std = "'$_std'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
        if ( is_array( $_std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1688
          $std_array = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1689
          foreach( $_std as $_sk => $_sv ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1690
            $std_array[] = "'$_sk' => '$_sv'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1691
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1692
          $std = 'array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1693
' . implode( ",\n", $std_array ) . '
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
        $setting_settings = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1698
        if ( isset( $value['settings'] ) && ! empty( $value['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1699
          foreach( $value['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1700
            $_setting_id = isset( $setting['id'] ) ? $setting['id'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1701
            $_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
  1702
            $_setting_desc = ot_I18n_string( isset( $setting['desc'] ) ? str_replace( "'", "\'", $setting['desc'] ) : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1703
            $_setting_std = isset( $setting['std'] ) ? $setting['std'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1704
            $_setting_type = isset( $setting['type'] ) ? $setting['type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1705
            $_setting_rows = isset( $setting['rows'] ) ? $setting['rows'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1706
            $_setting_post_type = isset( $setting['post_type'] ) ? $setting['post_type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1707
            $_setting_taxonomy = isset( $setting['taxonomy'] ) ? $setting['taxonomy'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1708
            $_setting_min_max_step = isset( $setting['min_max_step'] ) ? $setting['min_max_step'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1709
            $_setting_class = isset( $setting['class'] ) ? $setting['class'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1710
            $_setting_condition = isset( $setting['condition'] ) ? $setting['condition'] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1711
            $_setting_operator = isset( $setting['operator'] ) ? $setting['operator'] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1712
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1713
            $setting_choices = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
            if ( isset( $setting['choices'] ) && ! empty( $setting['choices'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
              foreach( $setting['choices'] as $setting_choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1716
                $_setting_choice_value = isset( $setting_choice['value'] ) ? $setting_choice['value'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1717
                $_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
  1718
                $_setting_choice_src = isset( $setting_choice['src'] ) ? str_replace( "'", "\'", $setting_choice['src'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1719
                $setting_choices.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
              array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
                'value'       => '$_setting_choice_value',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1722
                'label'       => $_setting_choice_label,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
                'src'         => '$_setting_choice_src'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
              ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1726
              $setting_choices = substr_replace( $setting_choices, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
              $setting_choices = ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1728
            'choices'     => array( $setting_choices
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1729
            )";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1730
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1731
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1732
            $setting_std = "'$_setting_std'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1733
            if ( is_array( $_setting_std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1734
              $setting_std_array = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
              foreach( $_setting_std as $_ssk => $_ssv ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1736
                $setting_std_array[] = "'$_ssk' => '$_ssv'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1737
              }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1738
              $setting_std = 'array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1739
' . implode( ",\n", $setting_std_array ) . '
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
            $setting_settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1744
          array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1745
            'id'          => '$_setting_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1746
            'label'       => $_setting_label,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1747
            'desc'        => $_setting_desc,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1748
            'std'         => $setting_std,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1749
            'type'        => '$_setting_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1750
            'rows'        => '$_setting_rows',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1751
            'post_type'   => '$_setting_post_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1752
            'taxonomy'    => '$_setting_taxonomy',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1753
            'min_max_step'=> '$_setting_min_max_step',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1754
            'class'       => '$_setting_class',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1755
            'condition'   => '$_setting_condition',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1756
            'operator'    => '$_setting_operator'$setting_choices
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1757
          ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1758
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1759
          $setting_settings = substr_replace( $setting_settings, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1760
          $setting_settings = ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1761
        'settings'    => array( $setting_settings
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
        $settings.= "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
        'id'          => '$_id',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1768
        'label'       => $_label,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1769
        'desc'        => $_desc,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1770
        'std'         => $std,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1771
        'type'        => '$_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1772
        'section'     => '$_section',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
        'rows'        => '$_rows',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1774
        'post_type'   => '$_post_type',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
        'taxonomy'    => '$_taxonomy',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
        'min_max_step'=> '$_min_max_step',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1777
        'class'       => '$_class',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1778
        'condition'   => '$_condition',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1779
        'operator'    => '$_operator'$choices$setting_settings
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
      ),";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
      $settings = substr_replace( $settings, '' , -1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1783
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1785
    /* check that $sections has a value and add to $build_settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
    if ( '' != $settings ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1787
      $build_settings.= ",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1788
    'settings'        => array( $settings
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1792
    $content.= "<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1793
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1794
 * Initialize the custom theme options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1795
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1796
add_action( 'init', 'custom_theme_options' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
 * Build the custom settings & update OptionTree.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1801
function custom_theme_options() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1802
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1803
  /* 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
  1804
  if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1805
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1806
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1807
  /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
   * Get a copy of the saved settings array. 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1809
   */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1810
  \$saved_settings = get_option( ot_settings_id(), array() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1811
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
  /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
   * Custom settings array that will eventually be 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1814
   * passes to the OptionTree Settings API Class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
   */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
  \$custom_settings = array( $build_settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1817
  );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1818
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1819
  /* allow settings to be filtered before saving */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1820
  \$custom_settings = apply_filters( ot_settings_id() . '_args', \$custom_settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1821
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
  /* settings are not the same update the DB */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1823
  if ( \$saved_settings !== \$custom_settings ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1824
    update_option( ot_settings_id(), \$custom_settings ); 
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1825
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1826
  
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1827
  /* Lets OptionTree know the UI Builder is being overridden */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1828
  global \$ot_has_custom_theme_options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1829
  \$ot_has_custom_theme_options = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1830
  
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
}";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1832
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1833
    echo $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1834
    die();
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1840
 * Save settings array before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1841
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1842
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1843
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1844
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1845
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1846
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1847
if ( ! function_exists( 'ot_save_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1848
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1849
  function ot_save_settings() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1851
    /* check and verify import settings nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1852
    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
  1853
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1854
      /* settings value */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1855
      $settings = isset( $_POST[ot_settings_id()] ) ? $_POST[ot_settings_id()] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1856
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1857
      /* validate sections */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1858
      if ( isset( $settings['sections'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1860
        /* fix numeric keys since drag & drop will change them */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1861
        $settings['sections'] = array_values( $settings['sections'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1862
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1863
        /* loop through sections */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1864
        foreach( $settings['sections'] as $k => $section ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1866
          /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1867
          if ( ( ! isset( $section['title'] ) && ! isset( $section['id'] ) ) || ( '' == $section['title'] && '' == $section['id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1868
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1869
            unset( $settings['sections'][$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1870
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1871
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1872
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1873
            /* validate label */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1874
            if ( '' != $section['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1875
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1876
             $settings['sections'][$k]['title'] = wp_kses_post( $section['title'] );
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
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1880
            /* missing title set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1881
            if ( ! isset( $section['title'] ) || '' == $section['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1882
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1883
              $settings['sections'][$k]['title'] = wp_kses_post( $section['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1884
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1885
            /* missing ID set to title */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1886
            } else if ( ! isset( $section['id'] ) || '' == $section['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1887
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1888
              $section['id'] = wp_kses_post( $section['title'] );
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
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1892
            /* sanitize ID once everything has been checked first */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1893
            $settings['sections'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $section['id'] ) );
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1899
        $settings['sections'] = ot_stripslashes( $settings['sections'] );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
      /* validate settings by looping over array as many times as it takes */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
      if ( isset( $settings['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
        $settings['settings'] = ot_validate_settings_array( $settings['settings'] );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1910
      /* validate contextual_help */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1911
      if ( isset( $settings['contextual_help']['content'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1912
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1913
        /* fix numeric keys since drag & drop will change them */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1914
        $settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1915
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1916
        /* loop through content */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1917
        foreach( $settings['contextual_help']['content'] as $k => $content ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1918
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1919
          /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1920
          if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' == $content['title'] && '' == $content['id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1921
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1922
            unset( $settings['contextual_help']['content'][$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1924
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1925
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1926
            /* validate label */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1927
            if ( '' != $content['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1928
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1929
             $settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['title'] );
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
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1933
            /* missing title set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
            if ( ! isset( $content['title'] ) || '' == $content['title'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1935
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1936
              $settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1937
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1938
            /* missing ID set to title */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
            } else if ( ! isset( $content['id'] ) || '' == $content['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1940
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
              $content['id'] = wp_kses_post( $content['title'] );
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
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
            /* sanitize ID once everything has been checked first */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1946
            $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
  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
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1950
          /* validate textarea description */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1951
          if ( isset( $content['content'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1952
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1953
            $settings['contextual_help']['content'][$k]['content'] = wp_kses_post( $content['content'] );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1961
      /* validate contextual_help sidebar */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
      if ( isset( $settings['contextual_help']['sidebar'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1963
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1964
        $settings['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1968
      $settings['contextual_help'] = ot_stripslashes( $settings['contextual_help'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1969
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1970
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1971
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1972
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1973
      /* is array: save & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1974
      if ( is_array( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1975
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1976
        /* WPML unregister ID's that have been removed */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1977
        if ( function_exists( 'icl_unregister_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1978
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1979
          $current = get_option( ot_settings_id() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1980
          $options = get_option( ot_options_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1981
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1982
          if ( isset( $current['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1983
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1984
            /* Empty ID array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1985
            $new_ids = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1986
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1987
            /* Build the WPML IDs array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1988
            foreach( $settings['settings'] as $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1989
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1990
              if ( $setting['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1991
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
                $new_ids[] = $setting['id'];
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
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1998
            /* Remove missing IDs from WPML */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1999
            foreach( $current['settings'] as $current_setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2000
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2001
              if ( ! in_array( $current_setting['id'], $new_ids ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2002
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2003
                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
  2004
                  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2005
                  foreach( $options[$current_setting['id']] as $key => $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2006
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2007
                    foreach( $value as $ckey => $cvalue ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2008
                      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2009
                      ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
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
                  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2013
                  }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2014
                
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2015
                } 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
  2016
                  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2017
                  foreach( $options[$current_setting['id']] as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2018
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2019
                    foreach( $value as $ckey => $cvalue ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2020
                      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2021
                      ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
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
                  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2025
                  }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2026
                  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2027
                } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2028
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2029
                  ot_wpml_unregister_string( $current_setting['id'] );
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
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2040
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2041
        update_option( ot_settings_id(), $settings );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2042
        $message = 'success';
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2046
      /* redirect */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2047
      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
  2048
      exit;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2052
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2059
 * Validate the settings array before save.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2060
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2061
 * This function will loop over the settings array as many 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2062
 * times as it takes to validate every sub setting.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2063
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2064
 * @param     array     $settings The array of settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2065
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2066
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2067
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2068
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2069
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2070
if ( ! function_exists( 'ot_validate_settings_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2071
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2072
  function ot_validate_settings_array( $settings = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2073
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2074
    /* validate settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2075
    if ( count( $settings ) > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2076
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2077
      /* fix numeric keys since drag & drop will change them */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2078
      $settings = array_values( $settings );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2079
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2080
      /* loop through settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2081
      foreach( $settings as $k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2082
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2083
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2084
        /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2085
        if ( ( ! isset( $setting['label'] ) && ! isset( $setting['id'] ) ) || ( '' == $setting['label'] && '' == $setting['id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2086
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2087
          unset( $settings[$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2088
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2089
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2090
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2091
          /* validate label */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2092
          if ( '' != $setting['label'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2093
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2094
            $settings[$k]['label'] = wp_kses_post( $setting['label'] );
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
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2098
          /* missing label set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2099
          if ( ! isset( $setting['label'] ) || '' == $setting['label'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2100
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2101
            $settings[$k]['label'] = $setting['id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2102
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2103
          /* missing ID set to label */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2104
          } else if ( ! isset( $setting['id'] ) || '' == $setting['id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2105
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2106
            $setting['id'] = wp_kses_post( $setting['label'] );
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
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2110
          /* sanitize ID once everything has been checked first */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2111
          $settings[$k]['id'] = ot_sanitize_option_id( wp_kses_post( $setting['id'] ) );
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2115
        /* validate description */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2116
        if ( '' != $setting['desc']  ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2117
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2118
          $settings[$k]['desc'] = wp_kses_post( $setting['desc'] );
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2122
        /* validate choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2123
        if ( isset( $setting['choices'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2124
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2125
          /* loop through choices */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2126
          foreach( $setting['choices'] as $ck => $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2128
            /* remove from array if missing values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2129
            if ( ( ! isset( $choice['label'] ) && ! isset( $choice['value'] ) ) || ( '' == $choice['label'] && '' == $choice['value'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2130
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2131
              unset( $setting['choices'][$ck] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2132
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2133
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2134
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2135
              /* missing label set to unfiltered ID */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2136
              if ( ! isset( $choice['label'] ) || '' == $choice['label'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2137
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2138
                $setting['choices'][$ck]['label'] = wp_kses_post( $choice['value'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2139
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2140
              /* missing value set to label */ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2141
              } else if ( ! isset( $choice['value'] ) || '' == $choice['value'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2142
                
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2143
                $setting['choices'][$ck]['value'] = ot_sanitize_option_id( wp_kses_post( $choice['label'] ) );
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
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2151
          /* update keys and push new array values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2152
          $settings[$k]['choices'] = array_values( $setting['choices'] );
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2156
        /* validate sub settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2157
        if ( isset( $setting['settings'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2158
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2159
          $settings[$k]['settings'] = ot_validate_settings_array( $setting['settings'] );
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2167
    /* return array but strip those damn slashes out first!!! */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2168
    return ot_stripslashes( $settings );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2175
 * Save layouts array before the screen is displayed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2176
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2177
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2178
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2179
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2180
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2181
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2182
if ( ! function_exists( 'ot_modify_layouts' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2183
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2184
  function ot_modify_layouts() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2185
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2186
    /* check and verify modify layouts nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2187
    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
  2188
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2189
      /* previous layouts value */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2190
      $option_tree_layouts = get_option( ot_layouts_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2191
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2192
      /* new layouts value */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2193
      $layouts = isset( $_POST[ot_layouts_id()] ) ? $_POST[ot_layouts_id()] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2194
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2195
      /* rebuild layout array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2196
      $rebuild = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2197
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2198
      /* validate layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2199
      if ( is_array( $layouts ) && ! empty( $layouts ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2200
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2201
        /* setup active layout */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2202
        if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2203
          $rebuild['active_layout'] = $layouts['active_layout'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2204
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2205
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2206
        /* add new and overwrite active layout */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2207
        if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2208
          $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
  2209
          $rebuild[$rebuild['active_layout']] = ot_encode( serialize( get_option( ot_options_id() ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2210
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2211
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2212
        $first_layout = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2213
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2214
        /* loop through layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2215
        foreach( $layouts as $key => $layout ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2216
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2217
          /* skip over active layout key */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2218
          if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2219
            continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2220
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2221
          /* check if the key exists then set value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2222
          if ( isset( $option_tree_layouts[$key] ) && ! empty( $option_tree_layouts[$key] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2223
            $rebuild[$key] = $option_tree_layouts[$key];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2224
            if ( '' == $first_layout ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2225
              $first_layout = $key;
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2231
        if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[$rebuild['active_layout']] ) && ! empty( $first_layout ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2232
          $rebuild['active_layout'] = $first_layout;
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2237
      /* default message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2238
      $message = 'failed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2239
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2240
      /* is array: save & show success message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2241
      if ( count( $rebuild ) > 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2242
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2243
        /* rebuild the theme options */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2244
        $rebuild_option_tree = unserialize( ot_decode( $rebuild[$rebuild['active_layout']] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2245
        if ( is_array( $rebuild_option_tree ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2246
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2247
          /* execute the action hook and pass the theme options to it */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2248
          do_action( 'ot_before_theme_options_save', $rebuild_option_tree );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2249
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2250
          update_option( ot_options_id(), $rebuild_option_tree );
0
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
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2254
        /* rebuild the layouts */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2255
        update_option( ot_layouts_id(), $rebuild );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2256
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2257
        /* change message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2258
        $message = 'success';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2259
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2260
      } else if ( count( $rebuild ) <= 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2261
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2262
        /* delete layouts option */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2263
        delete_option( ot_layouts_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2264
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2265
        /* change message */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2266
        $message = 'deleted';
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2270
      /* redirect */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2271
      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
  2272
        $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
  2273
      } else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2274
        $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
  2275
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2276
      wp_redirect( $query_args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2277
      exit;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2281
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2288
 * Helper function to display alert messages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2289
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2290
 * @param     array     Page array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2291
 * @return    mixed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2292
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2293
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2294
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2295
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2296
if ( ! function_exists( 'ot_alert_message' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2297
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2298
  function ot_alert_message( $page = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2299
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2300
    if ( empty( $page ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2301
      return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2302
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2303
    $before = apply_filters( 'ot_before_page_messages', '', $page );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2304
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2305
    if ( $before ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2306
      return $before;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2307
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2308
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2309
    $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2310
    $message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2311
    $updated = isset( $_REQUEST['settings-updated'] ) ? $_REQUEST['settings-updated'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2312
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2313
    if ( $action == 'save-settings' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2314
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2315
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2316
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2317
        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
  2318
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2319
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2320
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2321
        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
  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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2325
    } else if ( $action == 'import-xml' || $action == 'import-settings' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2326
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2327
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2328
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2329
        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
  2330
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2331
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2332
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2333
        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
  2334
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2335
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2336
    } else if ( $action == 'import-data' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2337
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2338
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2339
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2340
        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
  2341
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2342
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2343
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2344
        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
  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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2348
    } else if ( $action == 'import-layouts' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2349
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2350
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2351
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2352
        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
  2353
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2354
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2355
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2356
        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
  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
           
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2360
    } else if ( $action == 'save-layouts' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2361
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2362
      if ( $message == 'success' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2363
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2364
        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
  2365
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2366
      } else if ( $message == 'failed' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2367
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2368
        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
  2369
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2370
      } else if ( $message == 'deleted' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2371
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2372
        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
  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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2376
    } else if ( $updated == 'layout' ) {  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2377
       
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2378
      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
  2379
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
    } else if ( $action == 'reset' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2382
      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
  2383
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2384
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2385
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2386
    do_action( 'ot_custom_page_messages', $page );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2387
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2388
    if ( $updated == 'true' ) {  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2389
       
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2390
      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
  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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2394
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2401
 * Setup the default option types.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2402
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2403
 * The returned option types are filterable so you can add your own.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2404
 * 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
  2405
 * that displays the option to the user and validate the saved data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2406
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2407
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2408
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2409
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2410
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2411
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2412
if ( ! function_exists( 'ot_option_types_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2413
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2414
  function ot_option_types_array() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2415
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2416
    return apply_filters( 'ot_option_types_array', array( 
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2417
      'background'                => __('Background', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2418
      'border'                    => __('Border', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2419
      'box-shadow'                => __('Box Shadow', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2420
      'category-checkbox'         => __('Category Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2421
      'category-select'           => __('Category Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2422
      'checkbox'                  => __('Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2423
      'colorpicker'               => __('Colorpicker', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2424
      'colorpicker-opacity'       => __('Colorpicker Opacity', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2425
      'css'                       => __('CSS', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2426
      'custom-post-type-checkbox' => __('Custom Post Type Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2427
      'custom-post-type-select'   => __('Custom Post Type Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2428
      'date-picker'               => __('Date Picker', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2429
      'date-time-picker'          => __('Date Time Picker', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2430
      'dimension'                 => __('Dimension', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2431
      'gallery'                   => __('Gallery', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2432
      'google-fonts'              => __('Google Fonts', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2433
      'javascript'                => __('JavaScript', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2434
      'link-color'                => __('Link Color', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2435
      'list-item'                 => __('List Item', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2436
      'measurement'               => __('Measurement', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2437
      'numeric-slider'            => __('Numeric Slider', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2438
      'on-off'                    => __('On/Off', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2439
      'page-checkbox'             => __('Page Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2440
      'page-select'               => __('Page Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2441
      'post-checkbox'             => __('Post Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2442
      'post-select'               => __('Post Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2443
      'radio'                     => __('Radio', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2444
      'radio-image'               => __('Radio Image', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2445
      'select'                    => __('Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2446
      'sidebar-select'            => __('Sidebar Select',  'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2447
      'slider'                    => __('Slider', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2448
      'social-links'              => __('Social Links', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2449
      'spacing'                   => __('Spacing', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2450
      'tab'                       => __('Tab', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2451
      'tag-checkbox'              => __('Tag Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2452
      'tag-select'                => __('Tag Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2453
      'taxonomy-checkbox'         => __('Taxonomy Checkbox', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2454
      'taxonomy-select'           => __('Taxonomy Select', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2455
      'text'                      => __('Text', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2456
      'textarea'                  => __('Textarea', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2457
      'textarea-simple'           => __('Textarea Simple', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2458
      'textblock'                 => __('Textblock', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2459
      'textblock-titled'          => __('Textblock Titled', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2460
      'typography'                => __('Typography', 'option-tree'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2461
      'upload'                    => __('Upload', 'option-tree')
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2468
 * Map old option types for rebuilding XML and Table data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2469
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2470
 * @param     string      $type The old option type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2471
 * @return    string      The new option type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2472
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2473
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2474
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2475
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2476
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2477
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2478
  function ot_map_old_option_types( $type = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2479
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2480
    if ( ! $type ) 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2481
      return 'text';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2482
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2483
    $types = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2484
      'background'        => 'background',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2485
      'category'          => 'category-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2486
      'categories'        => 'category-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2487
      'checkbox'          => 'checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2488
      'colorpicker'       => 'colorpicker',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2489
      'css'               => 'css',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2490
      'custom_post'       => 'custom-post-type-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2491
      'custom_posts'      => 'custom-post-type-checkbox',                     
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2492
      'input'             => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2493
      'image'             => 'upload',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2494
      'measurement'       => 'measurement',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2495
      'page'              => 'page-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2496
      'pages'             => 'page-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2497
      'post'              => 'post-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2498
      'posts'             => 'post-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2499
      'radio'             => 'radio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2500
      'select'            => 'select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2501
      'slider'            => 'slider',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2502
      'tag'               => 'tag-select',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2503
      'tags'              => 'tag-checkbox',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2504
      'textarea'          => 'textarea',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2505
      'textblock'         => 'textblock',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2506
      'typography'        => 'typography',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2507
      'upload'            => 'upload'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2508
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2509
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2510
    if ( isset( $types[$type] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2511
      return $types[$type];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2512
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2513
    return false;
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2518
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2519
 * Filters the typography font-family to add Google fonts dynamically.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2520
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2521
 * @param     array     $families An array of all recognized font families.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2522
 * @param     string    $field_id ID of the feild being filtered.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2523
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2524
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2525
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2526
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2527
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2528
function ot_google_font_stack( $families, $field_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2529
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2530
  $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2531
  $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
  2532
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2533
  if ( ! empty( $ot_set_google_fonts ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2534
    foreach( $ot_set_google_fonts as $id => $sets ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2535
      foreach( $sets as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2536
        $family = isset( $value['family'] ) ? $value['family'] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2537
        if ( $family && isset( $ot_google_fonts[$family] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2538
          $spaces = explode(' ', $ot_google_fonts[$family]['family'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2539
          $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
  2540
          $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
  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
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2546
  return $families;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2547
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2548
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
  2549
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2550
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2551
 * Recognized font families
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2552
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2553
 * Returns an array of all recognized font families.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2554
 * Keys are intended to be stored in the database
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2555
 * while values are ready for display in html.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2556
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2557
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2558
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2559
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2560
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2561
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2562
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2563
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2564
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2565
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2566
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2567
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2568
  function ot_recognized_font_families( $field_id = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2569
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2570
    $families = array(
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2571
      'arial'     => 'Arial',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2572
      'georgia'   => 'Georgia',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2573
      'helvetica' => 'Helvetica',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2574
      'palatino'  => 'Palatino',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2575
      'tahoma'    => 'Tahoma',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2576
      'times'     => '"Times New Roman", sans-serif',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2577
      'trebuchet' => 'Trebuchet',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2578
      'verdana'   => 'Verdana'
5
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
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2581
    return apply_filters( 'ot_recognized_font_families', $families, $field_id );
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2588
 * Recognized font sizes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2589
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2590
 * Returns an array of all recognized font sizes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2591
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2592
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2593
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2594
 * @param     string  $field_id ID that's passed to the filters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2595
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2596
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2597
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2598
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2599
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2600
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2601
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2602
  function ot_recognized_font_sizes( $field_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2603
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2604
    $range = ot_range( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2605
      apply_filters( 'ot_font_size_low_range', 0, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2606
      apply_filters( 'ot_font_size_high_range', 150, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2607
      apply_filters( 'ot_font_size_range_interval', 1, $field_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2608
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2609
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2610
    $unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2611
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2612
    foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2613
      $range[$k] = $v . $unit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2614
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2615
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2616
    return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2622
 * Recognized font styles
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2623
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2624
 * Returns an array of all recognized font styles.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2625
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2626
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2627
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2628
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2629
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2630
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2631
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2632
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2633
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2634
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2635
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2636
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2637
  function ot_recognized_font_styles( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2638
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2639
    return apply_filters( 'ot_recognized_font_styles', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2640
      'normal'  => 'Normal',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2641
      'italic'  => 'Italic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2642
      'oblique' => 'Oblique',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2643
      'inherit' => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2644
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2651
 * Recognized font variants
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2652
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2653
 * Returns an array of all recognized font variants.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2654
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2655
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2656
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2657
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2658
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2659
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2660
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2661
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2662
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2663
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2664
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2665
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2666
  function ot_recognized_font_variants( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2667
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2668
    return apply_filters( 'ot_recognized_font_variants', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2669
      'normal'      => 'Normal',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2670
      'small-caps'  => 'Small Caps',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2671
      'inherit'     => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2672
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2679
 * Recognized font weights
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2680
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2681
 * Returns an array of all recognized font weights.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2682
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2683
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2684
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2685
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2686
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2687
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2688
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2689
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2690
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2691
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2692
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2693
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2694
  function ot_recognized_font_weights( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2695
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2696
    return apply_filters( 'ot_recognized_font_weights', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2697
      'normal'    => 'Normal',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2698
      'bold'      => 'Bold',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2699
      'bolder'    => 'Bolder',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2700
      'lighter'   => 'Lighter',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2701
      '100'       => '100',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2702
      '200'       => '200',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2703
      '300'       => '300',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2704
      '400'       => '400',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2705
      '500'       => '500',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2706
      '600'       => '600',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2707
      '700'       => '700',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2708
      '800'       => '800',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2709
      '900'       => '900',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2710
      'inherit'   => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2711
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2718
 * Recognized letter spacing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2719
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2720
 * Returns an array of all recognized line heights.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2721
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2722
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2723
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2724
 * @param     string  $field_id ID that's passed to the filters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2725
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2726
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2727
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2728
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2729
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2730
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2731
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2732
  function ot_recognized_letter_spacing( $field_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2733
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2734
    $range = ot_range( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2735
      apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2736
      apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2737
      apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2738
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2739
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2740
    $unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2741
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2742
    foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2743
      $range[$k] = $v . $unit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2744
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2745
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2746
    return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2752
 * Recognized line heights
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2753
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2754
 * Returns an array of all recognized line heights.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2755
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2756
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2757
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2758
 * @param     string  $field_id ID that's passed to the filters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2759
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2760
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2761
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2762
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2763
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2764
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2765
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2766
  function ot_recognized_line_heights( $field_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2767
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2768
    $range = ot_range( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2769
      apply_filters( 'ot_line_height_low_range', 0, $field_id ), 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2770
      apply_filters( 'ot_line_height_high_range', 150, $field_id ), 
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2771
      apply_filters( 'ot_line_height_range_interval', 1, $field_id )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2772
    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2773
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2774
    $unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2775
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2776
    foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2777
      $range[$k] = $v . $unit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2778
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2779
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2780
    return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2786
 * Recognized text decorations
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2787
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2788
 * Returns an array of all recognized text decorations.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2789
 * Keys are intended to be stored in the database
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2790
 * while values are ready for display in html.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2791
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2792
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2793
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2794
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2795
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2796
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2797
 * @since     2.0.10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2798
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2799
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2800
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2801
  function ot_recognized_text_decorations( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2802
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2803
    return apply_filters( 'ot_recognized_text_decorations', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2804
      'blink'         => 'Blink',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2805
      'inherit'       => 'Inherit',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2806
      'line-through'  => 'Line Through',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2807
      'none'          => 'None',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2808
      'overline'      => 'Overline',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2809
      'underline'     => 'Underline'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2810
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2817
 * Recognized text transformations
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2818
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2819
 * Returns an array of all recognized text transformations.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2820
 * Keys are intended to be stored in the database
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2821
 * while values are ready for display in html.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2822
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2823
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2824
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2825
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2826
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2827
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2828
 * @since     2.0.10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2829
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2830
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2831
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2832
  function ot_recognized_text_transformations( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2833
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2834
    return apply_filters( 'ot_recognized_text_transformations', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2835
      'capitalize'  => 'Capitalize',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2836
      'inherit'     => 'Inherit',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2837
      'lowercase'   => 'Lowercase',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2838
      'none'        => 'None',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2839
      'uppercase'   => 'Uppercase'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2840
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2847
 * Recognized background repeat
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2848
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2849
 * Returns an array of all recognized background repeat values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2850
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2851
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2852
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2853
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2854
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2855
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2856
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2857
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2858
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2859
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2860
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2861
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2862
  function ot_recognized_background_repeat( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2863
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2864
    return apply_filters( 'ot_recognized_background_repeat', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2865
      'no-repeat' => 'No Repeat',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2866
      'repeat'    => 'Repeat All',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2867
      'repeat-x'  => 'Repeat Horizontally',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2868
      'repeat-y'  => 'Repeat Vertically',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2869
      'inherit'   => 'Inherit'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2870
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2877
 * Recognized background attachment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2878
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2879
 * Returns an array of all recognized background attachment values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2880
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2881
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2882
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2883
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2884
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2885
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2886
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2887
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2888
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2889
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2890
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2891
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2892
  function ot_recognized_background_attachment( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2893
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2894
    return apply_filters( 'ot_recognized_background_attachment', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2895
      "fixed"   => "Fixed",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2896
      "scroll"  => "Scroll",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2897
      "inherit" => "Inherit"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2898
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2905
 * Recognized background position
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2906
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2907
 * Returns an array of all recognized background position values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2908
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2909
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2910
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2911
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2912
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2913
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2914
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2915
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2916
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2917
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2918
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2919
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2920
  function ot_recognized_background_position( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2921
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2922
    return apply_filters( 'ot_recognized_background_position', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2923
      "left top"      => "Left Top",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2924
      "left center"   => "Left Center",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2925
      "left bottom"   => "Left Bottom",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2926
      "center top"    => "Center Top",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2927
      "center center" => "Center Center",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2928
      "center bottom" => "Center Bottom",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2929
      "right top"     => "Right Top",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2930
      "right center"  => "Right Center",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2931
      "right bottom"  => "Right Bottom"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2932
    ), $field_id );
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2938
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2939
 * Border Styles
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2940
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2941
 * Returns an array of all available style types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2942
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2943
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2944
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2945
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2946
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2947
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2948
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2949
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2950
if ( ! function_exists( 'ot_recognized_border_style_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2951
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2952
  function ot_recognized_border_style_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2953
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2954
    return apply_filters( 'ot_recognized_border_style_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2955
      'hidden' => 'Hidden',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2956
      'dashed' => 'Dashed',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2957
      'solid'  => 'Solid',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2958
      'double' => 'Double',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2959
      'groove' => 'Groove',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2960
      'ridge'  => 'Ridge',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2961
      'inset'  => 'Inset',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2962
      'outset' => 'Outset',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2963
    ), $field_id );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2970
 * Border Units
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2971
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2972
 * Returns an array of all available unit types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2973
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2974
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2975
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2976
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2977
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2978
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2979
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2980
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2981
if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2982
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2983
  function ot_recognized_border_unit_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2984
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2985
    return apply_filters( 'ot_recognized_border_unit_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2986
      'px' => 'px',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2987
      '%'  => '%',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2988
      'em' => 'em',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2989
      'pt' => 'pt'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2990
    ), $field_id );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2997
 * Dimension Units
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2998
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2999
 * Returns an array of all available unit types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3000
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3001
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3002
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3003
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3004
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3005
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3006
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3007
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3008
if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3009
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3010
  function ot_recognized_dimension_unit_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3011
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3012
    return apply_filters( 'ot_recognized_dimension_unit_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3013
      'px' => 'px',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3014
      '%'  => '%',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3015
      'em' => 'em',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3016
      'pt' => 'pt'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3017
    ), $field_id );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3024
 * Spacing Units
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3025
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3026
 * Returns an array of all available unit types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3027
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3028
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3029
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3030
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3031
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3032
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3033
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3034
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3035
if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3036
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3037
  function ot_recognized_spacing_unit_types( $field_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3038
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3039
    return apply_filters( 'ot_recognized_spacing_unit_types', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3040
      'px' => 'px',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3041
      '%'  => '%',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3042
      'em' => 'em',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3043
      'pt' => 'pt'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3044
    ), $field_id );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3051
 * Recognized Google font families
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3052
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3053
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3054
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3055
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3056
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3057
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3058
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3059
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3060
if ( ! function_exists( 'ot_recognized_google_font_families' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3061
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3062
  function ot_recognized_google_font_families( $field_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3063
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3064
    $families = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3065
    $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3066
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3067
    // Forces an array rebuild when we sitch themes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3068
    if ( empty( $ot_google_fonts ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3069
      $ot_google_fonts = ot_fetch_google_fonts( true, true );
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
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3072
    foreach( (array) $ot_google_fonts as $key => $item ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3073
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3074
      if ( isset( $item['family'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3075
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3076
        $families[ $key ] = $item['family'];
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
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3082
    return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3089
 * Recognized Google font variants
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3090
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3091
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3092
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3093
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3094
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3095
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3096
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3097
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3098
if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3099
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3100
  function ot_recognized_google_font_variants( $field_id, $family ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3101
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3102
    $variants = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3103
    $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3104
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3105
    if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3106
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3107
      $variants = $ot_google_fonts[ $family ]['variants'];
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
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3111
    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
  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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3118
 * Recognized Google font subsets
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3119
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3120
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3121
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3122
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3123
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3124
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3125
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3126
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3127
if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3128
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3129
  function ot_recognized_google_font_subsets( $field_id, $family ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3130
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3131
    $subsets = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3132
    $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3133
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3134
    if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3135
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3136
      $subsets = $ot_google_fonts[ $family ]['subsets'];
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
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3140
    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
  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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3146
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3147
 * Measurement Units
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3148
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3149
 * Returns an array of all available unit types.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3150
 * Renamed in version 2.0 to avoid name collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3151
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3152
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3153
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3154
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3155
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3156
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3157
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3158
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3159
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3160
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3161
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3162
  function ot_measurement_unit_types( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3163
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3164
    return apply_filters( 'ot_measurement_unit_types', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3165
      'px' => 'px',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3166
      '%'  => '%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3167
      'em' => 'em',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3168
      'pt' => 'pt'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3169
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3176
 * Radio Images default array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3177
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3178
 * Returns an array of all available radio images.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3179
 * You can filter this function to change the images
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3180
 * on a per option basis.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3181
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3182
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3183
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3184
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3185
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3186
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3187
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3188
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3189
if ( ! function_exists( 'ot_radio_images' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3190
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3191
  function ot_radio_images( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3192
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3193
    return apply_filters( 'ot_radio_images', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3194
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3195
        'value'   => 'left-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3196
        'label'   => __( 'Left Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3197
        'src'     => OT_URL . 'assets/images/layout/left-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3198
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3199
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3200
        'value'   => 'right-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3201
        'label'   => __( 'Right Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3202
        'src'     => OT_URL . 'assets/images/layout/right-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3203
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3204
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3205
        'value'   => 'full-width',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3206
        'label'   => __( 'Full Width (no sidebar)', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3207
        'src'     => OT_URL . 'assets/images/layout/full-width.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3208
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3209
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3210
        'value'   => 'dual-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3211
        'label'   => __( 'Dual Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3212
        'src'     => OT_URL . 'assets/images/layout/dual-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3213
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3214
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3215
        'value'   => 'left-dual-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3216
        'label'   => __( 'Left Dual Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3217
        'src'     => OT_URL . 'assets/images/layout/left-dual-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3218
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3219
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3220
        'value'   => 'right-dual-sidebar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3221
        'label'   => __( 'Right Dual Sidebar', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3222
        'src'     => OT_URL . 'assets/images/layout/right-dual-sidebar.png'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3223
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3224
    ), $field_id );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3231
 * Default List Item Settings array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3232
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3233
 * Returns an array of the default list item settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3234
 * You can filter this function to change the settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3235
 * on a per option basis.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3236
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3237
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3238
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3239
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3240
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3241
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3242
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3243
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3244
if ( ! function_exists( 'ot_list_item_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3245
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3246
  function ot_list_item_settings( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3247
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3248
    $settings = apply_filters( 'ot_list_item_settings', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3249
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3250
        'id'        => 'image',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3251
        'label'     => __( 'Image', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3252
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3253
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3254
        'type'      => 'upload',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3255
        'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3256
        'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3257
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3258
        'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3259
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3260
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3261
        'id'        => 'link',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3262
        'label'     => __( 'Link', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3263
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3264
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3265
        'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3266
        'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3267
        'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3268
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3269
        'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3270
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3271
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3272
        'id'        => 'description',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3273
        'label'     => __( 'Description', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3274
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3275
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3276
        'type'      => 'textarea-simple',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3277
        'rows'      => 10,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3278
        'class'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3279
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3280
        'choices'   => array()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3281
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3282
    ), $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3283
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3284
    return $settings;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3291
 * Default Slider Settings array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3292
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3293
 * Returns an array of the default slider settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3294
 * You can filter this function to change the settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3295
 * on a per option basis.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3296
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3297
 * @uses      apply_filters()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3298
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3299
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3300
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3301
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3302
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3303
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3304
if ( ! function_exists( 'ot_slider_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3305
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3306
  function ot_slider_settings( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3307
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3308
    $settings = apply_filters( 'image_slider_fields', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3309
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3310
        'name'      => 'image',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3311
        'type'      => 'image',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3312
        'label'     => __( 'Image', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3313
        'class'     => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3314
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3315
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3316
        'name'      => 'link',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3317
        'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3318
        'label'     => __( 'Link', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3319
        'class'     => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3320
      ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3321
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3322
        'name'      => 'description',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3323
        'type'      => 'textarea',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3324
        'label'     => __( 'Description', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3325
        'class'     => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3326
      )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3327
    ), $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3328
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3329
    /* fix the array keys, values, and just get it 2.0 ready */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3330
    foreach( $settings as $_k => $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3331
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3332
      foreach( $setting as $s_key => $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3333
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3334
        if ( 'name' == $s_key ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3335
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3336
          $settings[$_k]['id'] = $s_value;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3337
          unset($settings[$_k]['name']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3338
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3339
        } else if ( 'type' == $s_key ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3340
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3341
          if ( 'input' == $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3342
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3343
            $settings[$_k]['type'] = 'text';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3344
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3345
          } else if ( 'textarea' == $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3346
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3347
            $settings[$_k]['type'] = 'textarea-simple';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3348
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3349
          } else if ( 'image' == $s_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3350
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3351
            $settings[$_k]['type'] = 'upload';
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3361
    return $settings;
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3367
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3368
 * Default Social Links Settings array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3369
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3370
 * Returns an array of the default social links settings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3371
 * You can filter this function to change the settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3372
 * on a per option basis.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3373
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3374
 * @uses      apply_filters()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3375
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3376
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3377
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3378
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3379
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3380
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3381
if ( ! function_exists( 'ot_social_links_settings' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3382
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3383
  function ot_social_links_settings( $id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3384
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3385
    $settings = apply_filters( 'ot_social_links_settings', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3386
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3387
        'id'        => 'name',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3388
        'label'     => __( 'Name', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3389
        'desc'      => __( 'Enter the name of the social website.', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3390
        'std'       => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3391
        'type'      => 'text',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3392
        'class'     => 'option-tree-setting-title'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3393
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3394
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3395
        'id'        => 'title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3396
        'label'     => 'Title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3397
        '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
  3398
        'type'      => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3399
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3400
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3401
        'id'        => 'href',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3402
        'label'     => 'Link',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3403
        '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
  3404
        'type'      => 'text',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3405
      )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3406
    ), $id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3407
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3408
    return $settings;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3414
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3415
 * Inserts CSS with field_id markers.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3416
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3417
 * Inserts CSS into a dynamic.css file, placing it between
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3418
 * BEGIN and END field_id markers. Replaces existing marked info, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3419
 * but still retains surrounding data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3420
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3421
 * @param     string  $field_id The CSS option field ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3422
 * @param     array   $options The current option_tree array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3423
 * @return    bool    True on write success, false on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3424
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3425
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3426
 * @since     1.1.8
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3427
 * @updated   2.5.3
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3428
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3429
if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3430
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3431
  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
  3432
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3433
    /* missing $field_id or $insertion exit early */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3434
    if ( '' == $field_id || '' == $insertion )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3435
      return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3436
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3437
    /* path to the dynamic.css file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3438
    $filepath = get_stylesheet_directory() . '/dynamic.css';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3439
    if ( is_multisite() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3440
      $multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3441
      if ( file_exists( $multisite_filepath ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3442
        $filepath = $multisite_filepath;
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
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3445
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3446
    /* allow filter on path */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3447
    $filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3448
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3449
    /* grab a copy of the paths array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3450
    $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
  3451
    if ( is_multisite() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3452
      $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
  3453
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3454
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3455
    /* set the path for this field */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3456
    $ot_css_file_paths[$field_id] = $filepath;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3457
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3458
    /* update the paths */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3459
    if ( is_multisite() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3460
      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
  3461
    } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3462
      update_option( 'ot_css_file_paths', $ot_css_file_paths );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3463
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3464
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3465
    /* insert CSS into file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3466
    if ( file_exists( $filepath ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3467
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3468
      $insertion   = ot_normalize_css( $insertion );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3469
      $regex       = "/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3470
      $marker      = $field_id;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3471
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3472
      /* Match custom CSS */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3473
      preg_match_all( $regex, $insertion, $matches );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3474
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3475
      /* Loop through CSS */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3476
      foreach( $matches[0] as $option ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3477
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3478
        $value        = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3479
        $option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3480
        $option_id    = isset( $option_array[0] ) ? $option_array[0] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3481
        $option_key   = isset( $option_array[1] ) ? $option_array[1] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3482
        $option_type  = ot_get_option_type_by_id( $option_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3483
        $fallback     = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3484
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3485
        // Get the meta array value
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3486
        if ( $meta ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3487
          global $post;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3488
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3489
          $value = get_post_meta( $post->ID, $option_id, true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3490
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3491
        // Get the options array value
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3492
        } else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3493
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3494
          $options = get_option( ot_options_id() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3495
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3496
          if ( isset( $options[$option_id] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3497
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3498
            $value = $options[$option_id];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3499
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3500
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3501
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3502
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3503
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3504
        // This in an array of values
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3505
        if ( is_array( $value ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3506
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3507
          if ( empty( $option_key ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3508
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3509
            // Measurement
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3510
            if ( $option_type == 'measurement' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3511
              $unit = ! empty( $value[1] ) ? $value[1] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3512
			  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3513
              // Set $value with measurement properties
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3514
              if ( isset( $value[0] ) && strlen( $value[0] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3515
                $value = $value[0].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3516
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3517
            // Border
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3518
            } else if ( $option_type == 'border' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3519
              $border = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3520
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3521
              $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3522
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3523
              if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3524
                $border[] = $value['width'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3525
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3526
              if ( ! empty( $value['style'] ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3527
                $border[] = $value['style'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3528
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3529
              if ( ! empty( $value['color'] ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3530
                $border[] = $value['color'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3531
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3532
              /* set $value with border properties or empty string */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3533
              $value = ! empty( $border ) ? implode( ' ', $border ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3534
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3535
            // Box Shadow
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3536
            } else if ( $option_type == 'box-shadow' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3537
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3538
              /* set $value with box-shadow properties or empty string */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3539
              $value = ! empty( $value ) ? implode( ' ', $value ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3540
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3541
            // Dimension
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3542
            } else if ( $option_type == 'dimension' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3543
              $dimension = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3544
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3545
              $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3546
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3547
              if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3548
                $dimension[] = $value['width'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3549
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3550
              if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3551
                $dimension[] = $value['height'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3552
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3553
              // Set $value with dimension properties or empty string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3554
              $value = ! empty( $dimension ) ? implode( ' ', $dimension ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3555
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3556
            // Spacing
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3557
            } else if ( $option_type == 'spacing' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3558
              $spacing = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3559
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3560
              $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3561
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3562
              if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3563
                $spacing[] = $value['top'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3564
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3565
              if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3566
                $spacing[] = $value['right'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3567
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3568
              if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3569
                $spacing[] = $value['bottom'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3570
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3571
              if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3572
                $spacing[] = $value['left'].$unit;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3573
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3574
              // Set $value with spacing properties or empty string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3575
              $value = ! empty( $spacing ) ? implode( ' ', $spacing ) : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3576
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3577
            // Typography
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3578
            } else if ( $option_type == 'typography' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3579
              $font = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3580
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3581
              if ( ! empty( $value['font-color'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3582
                $font[] = "color: " . $value['font-color'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3583
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3584
              if ( ! empty( $value['font-family'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3585
                foreach ( ot_recognized_font_families( $marker ) as $key => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3586
                  if ( $key == $value['font-family'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3587
                    $font[] = "font-family: " . $v . ";";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3588
                  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3589
                }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3590
              }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3591
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3592
              if ( ! empty( $value['font-size'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3593
                $font[] = "font-size: " . $value['font-size'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3594
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3595
              if ( ! empty( $value['font-style'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3596
                $font[] = "font-style: " . $value['font-style'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3597
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3598
              if ( ! empty( $value['font-variant'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3599
                $font[] = "font-variant: " . $value['font-variant'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3600
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3601
              if ( ! empty( $value['font-weight'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3602
                $font[] = "font-weight: " . $value['font-weight'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3603
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3604
              if ( ! empty( $value['letter-spacing'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3605
                $font[] = "letter-spacing: " . $value['letter-spacing'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3606
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3607
              if ( ! empty( $value['line-height'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3608
                $font[] = "line-height: " . $value['line-height'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3609
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3610
              if ( ! empty( $value['text-decoration'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3611
                $font[] = "text-decoration: " . $value['text-decoration'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3612
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3613
              if ( ! empty( $value['text-transform'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3614
                $font[] = "text-transform: " . $value['text-transform'] . ";";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3615
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3616
              // Set $value with font properties or empty string
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3617
              $value = ! empty( $font ) ? implode( "\n", $font ) : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3618
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3619
            // Background
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3620
            } else if ( $option_type == 'background' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3621
              $bg = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3622
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3623
              if ( ! empty( $value['background-color'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3624
                $bg[] = $value['background-color'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3625
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3626
              if ( ! empty( $value['background-image'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3627
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3628
                // 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
  3629
                if ( wp_attachment_is_image( $value['background-image'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3630
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3631
                  $attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3632
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3633
                  // Check for attachment data
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3634
                  if ( $attachment_data ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3635
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3636
                    $value['background-image'] = $attachment_data[0];
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
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3641
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3642
                $bg[] = 'url("' . $value['background-image'] . '")';
5
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
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3645
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3646
              if ( ! empty( $value['background-repeat'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3647
                $bg[] = $value['background-repeat'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3648
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3649
              if ( ! empty( $value['background-attachment'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3650
                $bg[] = $value['background-attachment'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3651
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3652
              if ( ! empty( $value['background-position'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3653
                $bg[] = $value['background-position'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3654
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3655
              if ( ! empty( $value['background-size'] ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3656
                $size = $value['background-size'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3657
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3658
              // Set $value with background properties or empty string
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3659
              $value = ! empty( $bg ) ? 'background: ' . implode( " ", $bg ) . ';' : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3660
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3661
              if ( isset( $size ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3662
                if ( ! empty( $bg ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3663
                  $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
  3664
                }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3665
                $value.= "background-size: $size;";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3666
              }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3667
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3668
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3669
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3670
          } else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3671
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3672
            $value = $value[$option_key];
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3678
        // 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
  3679
        if ( $option_type == 'upload' && wp_attachment_is_image( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3680
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3681
          $attachment_data = wp_get_attachment_image_src( $value, 'original' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3682
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3683
          // Check for attachment data
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3684
          if ( $attachment_data ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3685
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3686
            $value = $attachment_data[0];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3687
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3688
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3689
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3690
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3691
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3692
        // Attempt to fallback when `$value` is empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3693
        if ( empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3694
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3695
          // We're trying to access a single array key
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3696
          if ( ! empty( $option_key ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3697
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3698
            // Link Color `inherit`
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3699
            if ( $option_type == 'link-color' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3700
              $fallback = 'inherit';
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3703
          } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3704
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3705
            // Border
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3706
            if ( $option_type == 'border' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3707
              $fallback = 'inherit';
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3710
            // Box Shadow
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3711
            if ( $option_type == 'box-shadow' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3712
              $fallback = 'none';
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3715
            // Colorpicker
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3716
            if ( $option_type == 'colorpicker' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3717
              $fallback = 'inherit';
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3720
            // Colorpicker Opacity
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3721
            if ( $option_type == 'colorpicker-opacity' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3722
              $fallback = 'inherit';
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
          /**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3728
           * Filter the `dynamic.css` fallback value.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3729
           *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3730
           * @since 2.5.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3731
           *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3732
           * @param string $fallback The default CSS fallback value.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3733
           * @param string $option_id The option ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3734
           * @param string $option_type The option type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3735
           * @param string $option_key The option array key.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3736
           */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3737
          $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
  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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3741
        // Let's fallback!
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3742
        if ( ! empty( $fallback ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3743
          $value = $fallback;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3744
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3745
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3746
        // Filter the CSS
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3747
        $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
  3748
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3749
        // Insert CSS, even if the value is empty
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3750
        $insertion = stripslashes( str_replace( $option, $value, $insertion ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3751
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3752
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3753
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3754
      // Can't write to the file so we error out
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3755
      if ( ! is_writable( $filepath ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3756
        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
  3757
        return false;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3760
      // Create array from the lines of code
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3761
      $markerdata = explode( "\n", implode( '', file( $filepath ) ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3762
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3763
      // Can't write to the file return false
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3764
      if ( ! $f = ot_file_open( $filepath, 'w' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3765
        return false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3766
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3767
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3768
      $searching = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3769
      $foundit = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3770
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3771
      // Has array of lines
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3772
      if ( ! empty( $markerdata ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3773
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3774
        // Foreach line of code
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3775
        foreach( $markerdata as $n => $markerline ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3776
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3777
          // Found begining of marker, set $searching to false
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3778
          if ( $markerline == "/* BEGIN {$marker} */" )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3779
            $searching = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3780
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3781
          // Keep searching each line of CSS
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3782
          if ( $searching == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3783
            if ( $n + 1 < count( $markerdata ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3784
              ot_file_write( $f, "{$markerline}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3785
            else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3786
              ot_file_write( $f, "{$markerline}" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3787
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3788
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3789
          // Found end marker write code
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3790
          if ( $markerline == "/* END {$marker} */" ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3791
            ot_file_write( $f, "/* BEGIN {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3792
            ot_file_write( $f, "{$insertion}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3793
            ot_file_write( $f, "/* END {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3794
            $searching = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3795
            $foundit = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3796
          }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3797
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3798
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3799
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3800
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3801
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3802
      // Nothing inserted, write code. DO IT, DO IT!
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3803
      if ( ! $foundit ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3804
        ot_file_write( $f, "/* BEGIN {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3805
        ot_file_write( $f, "{$insertion}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3806
        ot_file_write( $f, "/* END {$marker} */\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3807
      }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3808
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3809
      // Close file
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3810
      ot_file_close( $f );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3811
      return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3812
    }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3813
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3814
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3821
 * Remove old CSS.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3822
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3823
 * Removes CSS when the textarea is empty, but still retains surrounding styles.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3824
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3825
 * @param     string  $field_id The CSS option field ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3826
 * @return    bool    True on write success, false on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3827
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3828
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3829
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3830
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3831
if ( ! function_exists( 'ot_remove_old_css' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3832
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3833
  function ot_remove_old_css( $field_id = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3834
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3835
    /* missing $field_id string */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3836
    if ( '' == $field_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3837
      return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3838
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3839
    /* path to the dynamic.css file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3840
    $filepath = get_stylesheet_directory() . '/dynamic.css';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3841
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3842
    /* allow filter on path */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3843
    $filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3844
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3845
    /* remove CSS from file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3846
    if ( is_writeable( $filepath ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3847
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3848
      /* get each line in the file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3849
      $markerdata = explode( "\n", implode( '', file( $filepath ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3850
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3851
      /* can't write to the file return false */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3852
      if ( ! $f = ot_file_open( $filepath, 'w' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3853
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3854
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3855
      $searching = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3856
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3857
      /* has array of lines */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3858
      if ( ! empty( $markerdata ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3859
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3860
        /* foreach line of code */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3861
        foreach ( $markerdata as $n => $markerline ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3862
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3863
          /* found begining of marker, set $searching to false  */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3864
          if ( $markerline == "/* BEGIN {$field_id} */" )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3865
            $searching = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3866
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3867
          /* $searching is true, keep rewrite each line of CSS  */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3868
          if ( $searching == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3869
            if ( $n + 1 < count( $markerdata ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3870
              ot_file_write( $f, "{$markerline}\n" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3871
            else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3872
              ot_file_write( $f, "{$markerline}" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3873
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3874
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3875
          /* found end marker delete old CSS */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3876
          if ( $markerline == "/* END {$field_id} */" ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3877
            ot_file_write( $f, "" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3878
            $searching = true;
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3885
      /* close file */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3886
      ot_file_close( $f );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3887
      return true;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3891
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3898
 * Normalize CSS
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3899
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3900
 * Normalize & Convert all line-endings to UNIX format.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3901
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3902
 * @param     string    $css
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3903
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3904
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3905
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3906
 * @since     1.1.8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3907
 * @updated   2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3908
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3909
if ( ! function_exists( 'ot_normalize_css' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3910
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3911
  function ot_normalize_css( $css ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3912
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3913
    /* Normalize & Convert */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3914
    $css = str_replace( "\r\n", "\n", $css );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3915
    $css = str_replace( "\r", "\n", $css );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3916
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3917
    /* Don't allow out-of-control blank lines */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3918
    $css = preg_replace( "/\n{2,}/", "\n\n", $css );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3919
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3920
    return $css;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3926
 * Helper function to loop over the option types.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3927
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3928
 * @param    array    $type The current option type.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3929
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3930
 * @return   string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3931
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3932
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3933
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3934
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3935
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3936
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3937
  function ot_loop_through_option_types( $type = '', $child = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3938
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3939
    $content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3940
    $types = ot_option_types_array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3941
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3942
    if ( $child )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3943
      unset($types['list-item']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3944
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3945
    foreach( $types as $key => $value )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3946
      $content.= '<option value="' . $key . '" ' . selected( $type, $key, false ) . '>'  . $value . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3947
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3948
    return $content;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3955
 * Helper function to loop over choices.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3956
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3957
 * @param    string     $name The form element name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3958
 * @param    array      $choices The array of choices.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3959
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3960
 * @return   string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3961
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3962
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3963
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3964
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3965
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3966
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3967
  function ot_loop_through_choices( $name, $choices = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3968
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3969
    $content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3970
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3971
    foreach( (array) $choices as $key => $choice )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3972
      $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
  3973
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3974
    return $content;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3980
 * Helper function to loop over sub settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3981
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3982
 * @param    string     $name The form element name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3983
 * @param    array      $settings The array of settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3984
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3985
 * @return   string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3986
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3987
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3988
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3989
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3990
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3991
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3992
  function ot_loop_through_sub_settings( $name, $settings = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3993
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3994
    $content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3995
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3996
    foreach( $settings as $key => $setting )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3997
      $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
  3998
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3999
    return $content;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4005
 * Helper function to display sections.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4006
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4007
 * This function is used in AJAX to add a new section
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4008
 * and when section have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4009
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4010
 * @param    int      $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4011
 * @param    array    An array of values for the current section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4012
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4013
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4014
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4015
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4016
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4017
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4018
if ( ! function_exists( 'ot_sections_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4019
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4020
  function ot_sections_view( $name, $key, $section = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4021
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4022
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4023
    <div class="option-tree-setting is-section">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4024
      <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
  4025
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4026
        <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
  4027
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4028
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4029
        <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
  4030
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4031
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4032
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4033
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4034
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4035
          <div class="format-setting type-text">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4036
            <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
  4037
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4038
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4042
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4043
          <div class="format-setting type-text">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4044
            <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
  4045
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4046
              <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
  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
    </div>';
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4058
 * Helper function to display settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4059
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4060
 * This function is used in AJAX to add a new setting
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4061
 * and when settings have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4062
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4063
 * @param    int      $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4064
 * @param    array    An array of values for the current section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4065
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4066
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4067
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4068
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4069
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4070
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4071
if ( ! function_exists( 'ot_settings_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4072
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4073
  function ot_settings_view( $name, $key, $setting = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4074
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4075
    $child = ( strpos( $name, '][settings]') !== false ) ? true : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4076
    $type = isset( $setting['type'] ) ? $setting['type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4077
    $std = isset( $setting['std'] ) ? $setting['std'] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4078
    $operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4079
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4080
    // Serialize the standard value just incase
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4081
    if ( is_array( $std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4082
      $std = maybe_serialize( $std );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4083
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4084
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4085
    if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4086
      $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
  4087
    } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4088
      $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
  4089
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4090
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4091
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4092
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4093
      <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
  4094
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4095
        <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
  4096
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4097
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4098
        <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
  4099
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4100
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4101
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4102
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4103
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4104
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4105
            <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
  4106
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4107
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4111
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4112
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4113
            <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
  4114
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4115
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4119
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4120
          <div class="format-setting type-select wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4121
            <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
  4122
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4123
              <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
  4124
              ' . ot_loop_through_option_types( $type, $child ) . '                     
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4125
               
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4126
              </select>
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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4130
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4131
          <div class="format-setting type-textarea wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4132
            <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
  4133
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4134
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4138
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4139
          <div class="format-setting type-textblock wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4140
            <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
  4141
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4142
              <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
  4143
                ' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4144
              </ul>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4145
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4149
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4150
          <div class="format-setting type-textblock wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4151
            <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
  4152
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4153
              <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
  4154
                ' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4155
              </ul>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4156
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4160
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4161
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4162
            <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
  4163
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4164
              ' . $std_form_element . '
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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4168
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4169
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4170
            <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
  4171
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4172
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4176
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4177
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4178
            <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
  4179
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4180
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4184
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4185
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4186
            <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
  4187
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4188
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4192
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4193
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4194
            <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
  4195
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4196
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4200
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4201
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4202
            <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
  4203
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4204
              <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
  4205
            </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4206
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4207
        </div>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4208
        <div class="format-settings">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4209
          <div class="format-setting type-text wide-desc">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4210
            <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
  4211
            <div class="format-setting-inner">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4212
              <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
  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>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4216
        <div class="format-settings">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4217
          <div class="format-setting type-select wide-desc">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4218
            <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
  4219
            <div class="format-setting-inner">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4220
              <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
  4221
                <option value="and" ' . selected( $operator, 'and', false ) . '>' . __( 'and', 'option-tree' ) . '</option>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4222
                <option value="or" ' . selected( $operator, 'or', false ) . '>' . __( 'or', 'option-tree' ) . '</option>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4223
              </select>
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>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4226
        </div>
0
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
    </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4229
    ' . ( ! $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
  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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4236
 * Helper function to display setting choices.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4237
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4238
 * This function is used in AJAX to add a new choice
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4239
 * and when choices have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4240
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4241
 * @param    string   $name The form element name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4242
 * @param    array    $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4243
 * @param    array    An array of values for the current choice.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4244
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4245
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4246
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4247
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4248
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4249
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4250
if ( ! function_exists( 'ot_choices_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4251
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4252
  function ot_choices_view( $name, $key, $choice = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4253
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4254
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4255
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4256
      <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
  4257
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4258
        <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
  4259
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4260
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4261
        <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
  4262
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4263
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4264
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4265
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4266
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4267
          <div class="format-setting-label">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4268
            <h5>' . __( 'Label', 'option-tree' ) . '</h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4269
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4270
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4271
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4272
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4276
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4277
          <div class="format-setting-label">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4278
            <h5>' . __( 'Value', 'option-tree' ) . '</h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4279
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4280
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4281
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4282
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4286
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4287
          <div class="format-setting-label">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4288
            <h5>' . __( 'Image Source (Radio Image only)', 'option-tree' ) . '</h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4289
          </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4290
          <div class="format-setting type-text wide-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4291
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4292
              <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
  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
    </div>';
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4303
 * Helper function to display sections.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4304
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4305
 * This function is used in AJAX to add a new section
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4306
 * and when section have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4307
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4308
 * @param    int      $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4309
 * @param    array    An array of values for the current section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4310
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4311
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4312
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4313
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4314
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4315
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4316
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4317
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4318
  function ot_contextual_help_view( $name, $key, $content = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4319
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4320
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4321
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4322
      <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
  4323
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4324
        <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
  4325
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4326
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4327
        <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
  4328
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4329
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4330
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4331
      <div class="option-tree-setting-body">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4332
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4333
          <div class="format-setting type-text no-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4334
            <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
  4335
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4336
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4340
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4341
          <div class="format-setting type-text no-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4342
            <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
  4343
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4344
              <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
  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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4348
        <div class="format-settings">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4349
          <div class="format-setting type-textarea no-desc">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4350
            <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
  4351
            <div class="format-setting-inner">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4352
              <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
  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
    </div>';
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4364
 * Helper function to display sections.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4365
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4366
 * @param     string      $key
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4367
 * @param     string      $data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4368
 * @param     string      $active_layout
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4369
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4370
 * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4371
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4372
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4373
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4374
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4375
if ( ! function_exists( 'ot_layout_view' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4376
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4377
  function ot_layout_view( $key, $data = '', $active_layout = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4378
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4379
    return '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4380
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4381
      <div class="open">' . ( isset( $key ) ? esc_attr( $key ) : __( 'Layout', 'option-tree' ) ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4382
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4383
        <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
  4384
          <span class="icon ot-icon-square-o"></span>' . __( 'Activate', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4385
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4386
        <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
  4387
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4388
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4389
      </div>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4390
      <input type="hidden" name="' . ot_layouts_id() . '[' . esc_attr( $key ) . ']" value="' . $data . '" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4391
    </div>';
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4398
 * Helper function to display list items.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4399
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4400
 * This function is used in AJAX to add a new list items
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4401
 * and when they have already been added and saved.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4402
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4403
 * @param     string    $name The form field name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4404
 * @param     int       $key The array key for the current element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4405
 * @param     array     An array of values for the current list item.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4406
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4407
 * @return   void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4408
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4409
 * @access   public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4410
 * @since    2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4411
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4412
if ( ! function_exists( 'ot_list_item_view' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4413
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4414
  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
  4415
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4416
    /* required title setting */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4417
    $required_setting = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4418
      array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4419
        'id'        => 'title',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4420
        'label'     => __( 'Title', 'option-tree' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4421
        'desc'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4422
        'std'       => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4423
        'type'      => 'text',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4424
        'rows'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4425
        'class'     => 'option-tree-setting-title',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4426
        'post_type' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4427
        'choices'   => array()
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4431
    /* load the old filterable slider settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4432
    if ( 'slider' == $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4433
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4434
      $settings = ot_slider_settings( $name );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4438
    /* if no settings array load the filterable list item settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4439
    if ( empty( $settings ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4440
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4441
      $settings = ot_list_item_settings( $name );
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4445
    /* merge the two settings array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4446
    $settings = array_merge( $required_setting, $settings );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4447
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4448
    echo '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4449
    <div class="option-tree-setting">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4450
      <div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4451
      <div class="button-section">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4452
        <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
  4453
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4454
        </a>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4455
        <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
  4456
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4457
        </a>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4458
      </div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4459
      <div class="option-tree-setting-body">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4460
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4461
      foreach( $settings as $field ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4462
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4463
        // Set field value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4464
        $field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4465
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4466
        /* set default to standard value */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4467
        if ( isset( $field['std'] ) ) {  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4468
          $field_value = ot_filter_std_value( $field_value, $field['std'] );
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
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4471
        // filter the title label and description
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4472
        if ( $field['id'] == 'title' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4473
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4474
          // filter the label
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4475
          $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
  4476
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4477
          // filter the description
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4478
          $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
  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
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4482
        /* make life easier */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4483
        $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4484
             
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4485
        /* build the arguments array */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4486
        $_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4487
          'type'              => $field['type'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4488
          'field_id'          => $name . '_' . $field['id'] . '_' . $key,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4489
          'field_name'        => $_field_name . '[' . $key . '][' . $field['id'] . ']',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4490
          'field_value'       => $field_value,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4491
          'field_desc'        => isset( $field['desc'] ) ? $field['desc'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4492
          'field_std'         => isset( $field['std'] ) ? $field['std'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4493
          'field_rows'        => isset( $field['rows'] ) ? $field['rows'] : 10,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4494
          '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
  4495
          'field_taxonomy'    => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4496
          '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
  4497
          'field_class'       => isset( $field['class'] ) ? $field['class'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4498
          'field_condition'   => isset( $field['condition'] ) ? $field['condition'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4499
          'field_operator'    => isset( $field['operator'] ) ? $field['operator'] : 'and',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4500
          'field_choices'     => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4501
          'field_settings'    => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4502
          'post_id'           => $post_id,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4503
          'get_option'        => $get_option
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
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4506
        $conditions = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4507
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4508
        /* setup the conditions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4509
        if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4510
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4511
          /* 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
  4512
          $conditionals = explode( ',', $field['condition'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4513
          foreach( $conditionals as $condition ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4514
            $parts = explode( ':', $condition );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4515
            if ( isset( $parts[0] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4516
              $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
  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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4520
          $conditions = ' data-condition="' . $field['condition'] . '"';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4521
          $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
  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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4525
        // Build the setting CSS class
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4526
        if ( ! empty( $_args['field_class'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4527
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4528
          $classes = explode( ' ', $_args['field_class'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4529
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4530
          foreach( $classes as $_key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4531
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4532
            $classes[$_key] = $value . '-wrap';
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4536
          $class = 'format-settings ' . implode( ' ', $classes );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4537
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4538
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4539
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4540
          $class = 'format-settings';
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
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4544
        /* option label */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4545
        echo '<div id="setting_' . $_args['field_id'] . '" class="' . $class . '"' . $conditions . '>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4546
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4547
          /* don't show title with textblocks */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4548
          if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4549
            echo '<div class="format-setting-label">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4550
              echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4551
            echo '</div>';
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
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4554
          /* 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
  4555
          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
  4556
            $_args['type'] = 'textarea-simple';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4557
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4558
          /* option body, list-item is not allowed inside another list-item */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4559
          if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4560
            echo ot_display_by_type( $_args );
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
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4563
        echo '</div>';
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
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4567
      echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4568
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4569
    echo '</div>';
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4576
 * Helper function to display social links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4577
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4578
 * 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
  4579
 * and when they have already been added and saved.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4580
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4581
 * @param     string    $name The form field name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4582
 * @param     int       $key The array key for the current element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4583
 * @param     array     An array of values for the current list item.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4584
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4585
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4586
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4587
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4588
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4589
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4590
if ( ! function_exists( 'ot_social_links_view' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4591
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4592
  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
  4593
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4594
    /* if no settings array load the filterable social links settings */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4595
    if ( empty( $settings ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4596
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4597
      $settings = ot_social_links_settings( $name );
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
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4601
    echo '
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4602
    <div class="option-tree-setting">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4603
      <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
  4604
      <div class="button-section">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4605
        <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
  4606
          <span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4607
        </a>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4608
        <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
  4609
          <span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4610
        </a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4611
      </div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4612
      <div class="option-tree-setting-body">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4613
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4614
      foreach( $settings as $field ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4615
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4616
        // Set field value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4617
        $field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4618
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4619
        /* set default to standard value */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4620
        if ( isset( $field['std'] ) ) {  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4621
          $field_value = ot_filter_std_value( $field_value, $field['std'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4622
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4623
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4624
        /* make life easier */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4625
        $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4626
             
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4627
        /* build the arguments array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4628
        $_args = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4629
          'type'              => $field['type'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4630
          'field_id'          => $name . '_' . $field['id'] . '_' . $key,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4631
          'field_name'        => $_field_name . '[' . $key . '][' . $field['id'] . ']',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4632
          'field_value'       => $field_value,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4633
          'field_desc'        => isset( $field['desc'] ) ? $field['desc'] : '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4634
          'field_std'         => isset( $field['std'] ) ? $field['std'] : '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4635
          'field_rows'        => isset( $field['rows'] ) ? $field['rows'] : 10,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4636
          '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
  4637
          'field_taxonomy'    => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4638
          '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
  4639
          'field_class'       => isset( $field['class'] ) ? $field['class'] : '',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4640
          'field_condition'   => isset( $field['condition'] ) ? $field['condition'] : '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4641
          'field_operator'    => isset( $field['operator'] ) ? $field['operator'] : 'and',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4642
          'field_choices'     => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4643
          'field_settings'    => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4644
          'post_id'           => $post_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4645
          'get_option'        => $get_option
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4646
        );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4647
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4648
        $conditions = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4649
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4650
        /* setup the conditions */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4651
        if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4652
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4653
          /* 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
  4654
          $conditionals = explode( ',', $field['condition'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4655
          foreach( $conditionals as $condition ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4656
            $parts = explode( ':', $condition );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4657
            if ( isset( $parts[0] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4658
              $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
  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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4662
          $conditions = ' data-condition="' . $field['condition'] . '"';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4663
          $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
  4664
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4665
        }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4666
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4667
        /* option label */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4668
        echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings"' . $conditions . '>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4669
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4670
          /* don't show title with textblocks */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4671
          if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4672
            echo '<div class="format-setting-label">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4673
              echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4674
            echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4675
          }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4676
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4677
          /* 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
  4678
          if ( $_args['type'] == 'textarea' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4679
            $_args['type'] = 'textarea-simple';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4680
          
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4681
          /* option body, list-item is not allowed inside another list-item */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4682
          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
  4683
            echo ot_display_by_type( $_args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4684
          }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4685
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4686
        echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4687
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4688
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4689
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4690
      echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4691
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4692
    echo '</div>';
0
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4699
 * Helper function to display Theme Options layouts form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4700
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4701
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4702
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4703
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4704
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4705
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4706
if ( ! function_exists( 'ot_theme_options_layouts_form' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4707
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4708
  function ot_theme_options_layouts_form( $active = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4709
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4710
    echo '<form method="post" id="option-tree-options-layouts-form">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4711
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4712
      /* form nonce */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4713
      wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4714
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4715
      /* get the saved layouts */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4716
      $layouts = get_option( ot_layouts_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4717
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4718
      /* set active layout */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4719
      $active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4720
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4721
      if ( is_array( $layouts ) && count( $layouts ) > 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4722
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4723
        $active_layout = esc_attr( $layouts['active_layout'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4724
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4725
        echo '<input type="hidden" id="the_current_layout" value="' . $active_layout . '" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4726
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4727
        echo '<div class="option-tree-active-layout">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4728
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4729
          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
  4730
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4731
            foreach( $layouts as $key => $data ) { 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4732
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4733
              if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4734
                continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4735
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4736
              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
  4737
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4738
           
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4739
          echo '</select>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4740
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4741
        echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4742
         
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4743
        foreach( $layouts as $key => $data ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4744
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4745
          if ( $key == 'active_layout' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4746
              continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4747
              
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4748
          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
  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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4754
      /* new layout wrapper */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4755
      echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4756
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4757
        /* add new layout */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4758
        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
  4759
        
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4760
        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
  4761
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4762
      echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4763
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4764
    echo '</form>';
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4771
 * Helper function to validate option ID's
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4772
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4773
 * @param     string      $input The string to sanitize.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4774
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4775
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4776
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4777
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4778
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4779
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4780
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4781
  function ot_sanitize_option_id( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4782
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4783
    return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4790
 * Helper function to validate layout ID's
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4791
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4792
 * @param     string      $input The string to sanitize.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4793
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4794
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4795
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4796
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4797
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4798
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4799
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4800
  function ot_sanitize_layout_id( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4801
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4802
    return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4809
 * Convert choices array to string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4810
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4811
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4812
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4813
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4814
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4815
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4816
if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4817
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4818
  function ot_convert_array_to_string( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4819
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4820
    if ( is_array( $input ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4821
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4822
      foreach( $input as $k => $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4823
        $choices[$k] = $choice['value'] . '|' . $choice['label'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4824
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4825
        if ( isset( $choice['src'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4826
          $choices[$k].= '|' . $choice['src'];
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4830
      return implode( ',', $choices );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4831
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4832
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4833
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4838
 * Convert choices string to array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4839
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4840
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4841
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4842
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4843
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4844
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4845
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4846
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4847
  function ot_convert_string_to_array( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4848
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4849
    if ( '' !== $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4850
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4851
      /* empty choices array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4852
      $choices = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4853
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4854
      /* exlode the string into an array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4855
      foreach( explode( ',', $input ) as $k => $choice ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4856
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4857
        /* if ":" is splitting the string go deeper */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4858
        if ( preg_match( '/\|/', $choice ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4859
          $split = explode( '|', $choice );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4860
          $choices[$k]['value'] = trim( $split[0] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4861
          $choices[$k]['label'] = trim( $split[1] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4862
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4863
          /* if radio image there are three values */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4864
          if ( isset( $split[2] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4865
            $choices[$k]['src'] = trim( $split[2] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4866
            
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4867
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4868
          $choices[$k]['value'] = trim( $choice );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4869
          $choices[$k]['label'] = trim( $choice );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4874
      /* return a formated choices array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4875
      return $choices;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4879
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4885
 * Helper function - strpos() with arrays.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4886
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4887
 * @param     string    $haystack
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4888
 * @param     array     $needles
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4889
 * @return    bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4890
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4891
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4892
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4893
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4894
if ( ! function_exists( 'ot_strpos_array' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4895
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4896
  function ot_strpos_array( $haystack, $needles = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4897
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4898
    foreach( $needles as $needle ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4899
      $pos = strpos( $haystack, $needle );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4900
      if ( $pos !== false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4901
        return true;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4905
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4911
 * Helper function - strpos() with arrays.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4912
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4913
 * @param     string    $haystack
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4914
 * @param     array     $needles
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4915
 * @return    bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4916
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4917
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4918
 * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4919
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4920
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4921
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4922
  function ot_array_keys_exists( $array, $keys ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4923
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4924
    foreach($keys as $k) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4925
      if ( isset($array[$k]) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4926
        return true;
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4930
    return false;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4936
 * Custom stripslashes from single value or array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4937
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4938
 * @param       mixed   $input
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4939
 * @return      mixed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4940
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4941
 * @access      public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4942
 * @since       2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4943
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4944
if ( ! function_exists( 'ot_stripslashes' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4945
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4946
  function ot_stripslashes( $input ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4947
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4948
    if ( is_array( $input ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4949
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4950
      foreach( $input as &$val ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4951
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4952
        if ( is_array( $val ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4953
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4954
          $val = ot_stripslashes( $val );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4955
          
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4956
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4957
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4958
          $val = stripslashes( trim( $val ) );
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
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4964
    } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4965
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4966
      $input = stripslashes( trim( $input ) );
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
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4970
    return $input;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4977
 * Reverse wpautop.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4978
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4979
 * @param     string    $string The string to be filtered
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4980
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4981
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4982
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4983
 * @since     2.0.9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4984
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4985
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4986
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4987
  function ot_reverse_wpautop( $string = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4988
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4989
    /* return if string is empty */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4990
    if ( trim( $string ) === '' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4991
      return '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4992
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4993
    /* remove all new lines & <p> tags */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4994
    $string = str_replace( array( "\n", "<p>" ), "", $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4995
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4996
    /* replace <br /> with \r */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4997
    $string = str_replace( array( "<br />", "<br>", "<br/>" ), "\r", $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4998
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4999
    /* replace </p> with \r\n */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5000
    $string = str_replace( "</p>", "\r\n", $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5001
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5002
    /* return clean string */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5003
    return trim( $string );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5010
 * Returns an array of elements from start to limit, inclusive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5011
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5012
 * Occasionally zero will be some impossibly large number to 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5013
 * the "E" power when creating a range from negative to positive.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5014
 * This function attempts to fix that by setting that number back to "0".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5015
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5016
 * @param     string    $start First value of the sequence.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5017
 * @param     string    $limit The sequence is ended upon reaching the limit value.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5018
 * @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
  5019
 *                      between elements in the sequence. step should be given as a 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5020
 *                      positive number. If not specified, step will default to 1.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5021
 * @return    array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5022
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5023
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5024
 * @since     2.0.12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5025
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5026
function ot_range( $start, $limit, $step = 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5027
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5028
  if ( $step < 0 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5029
    $step = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5030
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5031
  $range = range( $start, $limit, $step );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5032
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5033
  foreach( $range as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5034
    if ( strpos( $v, 'E' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5035
      $range[$k] = 0;
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
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5039
  return $range;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5043
 * Helper function to return encoded strings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5044
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5045
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5046
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5047
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5048
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5049
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5050
function ot_encode( $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5051
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5052
  $func = 'base64' . '_encode';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5053
  return $func( $value );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5058
 * Helper function to return decoded strings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5059
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5060
 * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5061
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5062
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5063
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5064
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5065
function ot_decode( $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5066
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5067
  $func = 'base64' . '_decode';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5068
  return $func( $value );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5073
 * Helper function to open a file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5074
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5075
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5076
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5077
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5078
function ot_file_open( $handle, $mode ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5079
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5080
  $func = 'f' . 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5081
  return @$func( $handle, $mode );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5086
 * Helper function to close a file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5087
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5088
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5089
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5090
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5091
function ot_file_close( $handle ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5092
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5093
  $func = 'f' . 'close';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5094
  return $func( $handle );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5099
 * Helper function to write to an open file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5100
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5101
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5102
 * @since     2.0.13
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5103
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5104
function ot_file_write( $handle, $string ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5106
  $func = 'f' . 'write';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5107
  return $func( $handle, $string );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5112
 * Helper function to filter standard option values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5113
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5114
 * @param     mixed     $value Saved string or array value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5115
 * @param     mixed     $std Standard string or array value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5116
 * @return    mixed     String or array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5117
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5118
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5119
 * @since     2.0.15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5120
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5121
function ot_filter_std_value( $value = '', $std = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5122
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5123
  $std = maybe_unserialize( $std );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5124
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5125
  if ( is_array( $value ) && is_array( $std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5126
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5127
    foreach( $value as $k => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5128
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5129
      if ( '' == $value[$k] && isset( $std[$k] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5130
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5131
        $value[$k] = $std[$k];
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
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5137
  } else if ( '' == $value && ! empty( $std ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5138
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5139
    $value = $std;
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5143
  return $value;
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5147
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5148
 * Helper function to set the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5149
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5150
 * @param     string    $id The option ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5151
 * @param     bool      $value The option value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5152
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5153
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5154
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5155
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5156
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5157
function ot_set_google_fonts( $id = '', $value = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5158
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5159
  $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
  5160
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5161
  if ( is_array( $value ) && ! empty( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5162
    $ot_set_google_fonts[$id] = $value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5163
  } else if ( isset( $ot_set_google_fonts[$id] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5164
    unset( $ot_set_google_fonts[$id] );
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5167
  set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5172
 * Helper function to remove unused options from the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5173
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5174
 * @param     array     $options The array of saved options.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5175
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5176
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5177
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5178
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5179
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5180
function ot_update_google_fonts_after_save( $options ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5181
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5182
  $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
  5183
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5184
  foreach( $ot_set_google_fonts as $key => $set ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5185
    if ( ! isset( $options[$key] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5186
      unset( $ot_set_google_fonts[$key] );
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
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5189
  set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
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
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5192
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
  5193
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5194
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5195
 * Helper function to fetch the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5196
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5197
 * @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
  5198
 * @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
  5199
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5200
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5201
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5202
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5203
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5204
function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5205
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5206
  /* Google Fonts cache key */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5207
  $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
  5208
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5209
  /* get the fonts from cache */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5210
  $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
  5211
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5212
  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
  5213
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5214
    $ot_google_fonts = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5215
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5216
    /* API url and key */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5217
    $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
  5218
    $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
  5219
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5220
    /* API arguments */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5221
    $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
  5222
    $ot_google_fonts_sort   = apply_filters( 'ot_google_fonts_sort', 'alpha' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5223
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5224
    /* Initiate API request */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5225
    $ot_google_fonts_query_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5226
      'key'    => $ot_google_fonts_api_key, 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5227
      'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')', 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5228
      'sort'   => $ot_google_fonts_sort
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5231
    /* Build and make the request */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5232
    $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
  5233
    $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
  5234
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5235
    /* continue if we got a valid response */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5236
    if ( 200 == wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5237
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5238
      if ( $response_body = wp_remote_retrieve_body( $ot_google_fonts_response ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5239
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5240
        /* JSON decode the response body and cache the result */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5241
        $ot_google_fonts_data = json_decode( trim( $response_body ), true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5242
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5243
        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
  5244
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5245
          $ot_google_fonts = $ot_google_fonts_data['items'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5246
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5247
          // Normalize the array key
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5248
          $ot_google_fonts_tmp = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5249
          foreach( $ot_google_fonts as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5250
            $id = remove_accents( $value['family'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5251
            $id = strtolower( $id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5252
            $id = preg_replace( '/[^a-z0-9_\-]/', '', $id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5253
            $ot_google_fonts_tmp[$id] = $value;
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
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5256
          $ot_google_fonts = $ot_google_fonts_tmp;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5257
          set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5258
          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
  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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5268
  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
  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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5273
 * Helper function to normalize the Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5274
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5275
 * @param     array     $google_fonts An array of fonts to nrmalize.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5276
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5277
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5278
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5279
 * @since     2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5280
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5281
function ot_normalize_google_fonts( $google_fonts ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5282
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5283
  $ot_normalized_google_fonts = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5284
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5285
  if ( is_array( $google_fonts ) && ! empty( $google_fonts ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5286
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5287
    foreach( $google_fonts as $google_font ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5288
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5289
      if( isset( $google_font['family'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5290
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5291
        $id = str_replace( ' ', '+', $google_font['family'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5292
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5293
        $ot_normalized_google_fonts[ $id ] = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5294
          'family' => $google_font['family']
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5297
        if( isset( $google_font['variants'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5298
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5299
          $ot_normalized_google_fonts[ $id ]['variants'] = $google_font['variants'];
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5303
        if( isset( $google_font['subsets'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5304
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5305
          $ot_normalized_google_fonts[ $id ]['subsets'] = $google_font['subsets'];
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5315
  return $ot_normalized_google_fonts;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5319
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5320
 * Helper function to register a WPML string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5321
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5322
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5323
 * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5324
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5325
function ot_wpml_register_string( $id, $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5326
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5327
  if ( function_exists( 'icl_register_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5328
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5329
    icl_register_string( 'Theme Options', $id, $value );
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5336
 * Helper function to unregister a WPML string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5337
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5338
 * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5339
 * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5340
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5341
function ot_wpml_unregister_string( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5342
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5343
  if ( function_exists( 'icl_unregister_string' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5344
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5345
    icl_unregister_string( 'Theme Options', $id );
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
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5350
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5351
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5352
 * Maybe migrate Settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5353
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5354
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5355
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5356
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5357
 * @since     2.3.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5358
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5359
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5360
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5361
  function ot_maybe_migrate_settings() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5362
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5363
    // Filter the ID to migrate from
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5364
    $settings_id = apply_filters( 'ot_migrate_settings_id', '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5365
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5366
    // Attempt to migrate Settings 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5367
    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
  5368
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5369
      // Old settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5370
      $settings = get_option( $settings_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5371
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5372
      // Check for array keys
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5373
      if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5374
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5375
        update_option( ot_settings_id(), $settings );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5386
 * Maybe migrate Option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5387
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5388
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5389
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5390
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5391
 * @since     2.3.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5392
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5393
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5394
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5395
  function ot_maybe_migrate_options() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5396
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5397
    // Filter the ID to migrate from
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5398
    $options_id = apply_filters( 'ot_migrate_options_id', '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5399
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5400
    // Attempt to migrate Theme Options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5401
    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
  5402
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5403
      // Old options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5404
      $options = get_option( $options_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5405
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5406
      // Migrate to new ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5407
      update_option( ot_options_id(), $options );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5416
 * Maybe migrate Layouts
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5417
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5418
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5419
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5420
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5421
 * @since     2.3.3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5422
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5423
if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5424
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5425
  function ot_maybe_migrate_layouts() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5426
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5427
    // Filter the ID to migrate from
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5428
    $layouts_id = apply_filters( 'ot_migrate_layouts_id', '' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5429
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5430
    // Attempt to migrate Layouts
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5431
    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
  5432
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5433
      // Old options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5434
      $layouts = get_option( $layouts_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5435
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5436
      // Migrate to new ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5437
      update_option( ot_layouts_id(), $layouts );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5446
 * Returns an array with the post format gallery meta box.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5447
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5448
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5449
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5450
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5451
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5452
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5453
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5454
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5455
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5456
function ot_meta_box_post_format_gallery( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5457
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5458
  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
  5459
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5460
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5461
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5462
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5463
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5464
  return apply_filters( 'ot_meta_box_post_format_gallery', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5465
    'id'        => 'ot-post-format-gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5466
    'title'     => __( 'Gallery', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5467
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5468
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5469
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5470
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5471
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5472
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5473
        'id'          => '_format_gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5474
        'label'       => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5475
        'desc'        => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5476
        'std'         => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5477
        'type'        => 'gallery',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5478
        'class'       => 'ot-gallery-shortcode'
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
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5481
  ), $pages );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5486
 * Returns an array with the post format link metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5487
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5488
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5489
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5490
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5491
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5492
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5493
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5494
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5495
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5496
function ot_meta_box_post_format_link( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5497
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5498
  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
  5499
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5500
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5501
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5502
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5503
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5504
  return apply_filters( 'ot_meta_box_post_format_link', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5505
    'id'        => 'ot-post-format-link',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5506
    'title'     => __( 'Link', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5507
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5508
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5509
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5510
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5511
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5512
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5513
        'id'      => '_format_link_url',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5514
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5515
        'desc'    => __( 'Link URL', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5516
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5517
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5518
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5519
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5520
        'id'      => '_format_link_title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5521
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5522
        'desc'    => __( 'Link Title', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5523
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5524
        'type'    => 'text'
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
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5527
  ), $pages );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5532
 * Returns an array with the post format quote metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5533
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5534
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5535
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5536
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5537
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5538
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5539
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5540
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5541
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5542
function ot_meta_box_post_format_quote( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5543
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5544
  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
  5545
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5546
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5547
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5548
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5549
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5550
  return apply_filters( 'ot_meta_box_post_format_quote', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5551
    'id'        => 'ot-post-format-quote',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5552
    'title'     => __( 'Quote', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5553
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5554
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5555
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5556
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5557
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5558
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5559
        'id'      => '_format_quote_source_name',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5560
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5561
        'desc'    => __( 'Source Name (ex. author, singer, actor)', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5562
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5563
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5564
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5565
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5566
        'id'      => '_format_quote_source_url',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5567
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5568
        'desc'    => __( 'Source URL', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5569
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5570
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5571
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5572
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5573
        'id'      => '_format_quote_source_title',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5574
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5575
        'desc'    => __( 'Source Title (ex. book, song, movie)', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5576
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5577
        'type'    => 'text'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5578
      ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5579
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5580
        'id'      => '_format_quote_source_date',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5581
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5582
        'desc'    => __( 'Source Date', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5583
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5584
        'type'    => 'text'
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
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5587
  ), $pages );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5592
 * Returns an array with the post format video metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5593
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5594
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5595
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5596
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5597
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5598
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5599
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5600
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5601
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5602
function ot_meta_box_post_format_video( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5603
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5604
  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
  5605
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5606
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5607
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5608
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5609
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5610
  return apply_filters( 'ot_meta_box_post_format_video', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5611
    'id'        => 'ot-post-format-video',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5612
    'title'     => __( 'Video', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5613
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5614
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5615
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5616
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5617
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5618
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5619
        'id'      => '_format_video_embed',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5620
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5621
        '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
  5622
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5623
        'type'    => 'textarea'
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
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5626
  ), $pages );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5631
 * Returns an array with the post format audio metabox.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5632
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5633
 * @param     mixed     $pages Excepts a comma separated string or array of 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5634
 *                      post_types and is what tells the metabox where to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5635
 *                      display. Default 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5636
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5637
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5638
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5639
 * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5640
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5641
function ot_meta_box_post_format_audio( $pages = 'post' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5642
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5643
  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
  5644
    return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5645
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5646
  if ( is_string( $pages ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5647
    $pages = explode( ',', $pages );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5648
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5649
  return apply_filters( 'ot_meta_box_post_format_audio', array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5650
    'id'        => 'ot-post-format-audio',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5651
    'title'     => __( 'Audio', 'option-tree' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5652
    'desc'      => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5653
    'pages'     => $pages,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5654
    'context'   => 'side',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5655
    'priority'  => 'low',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5656
    'fields'    => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5657
      array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5658
        'id'      => '_format_audio_embed',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5659
        'label'   => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5660
        '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
  5661
        'std'     => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5662
        'type'    => 'textarea'
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
  	)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5665
  ), $pages );
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5670
 * Returns the option type by ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5671
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5672
 * @param     string    $option_id The option ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5673
 * @return    string    $settings_id The settings array ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5674
 * @return    string    The option type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5675
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5676
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5677
 * @since     2.4.2
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5678
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5679
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5680
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5681
  function ot_get_option_type_by_id( $option_id, $settings_id = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5682
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5683
    if ( empty( $settings_id ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5684
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5685
      $settings_id = ot_settings_id();
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
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5689
    $settings = get_option( $settings_id, array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5690
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5691
    if ( isset( $settings['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5692
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5693
      foreach( $settings['settings'] as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5694
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5695
        if ( $option_id == $value['id'] && isset( $value['type'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5696
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5697
          return $value['type'];
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
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5705
    return false;
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5712
 * Build an array of potential Theme Options that could share terms
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5713
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5714
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5715
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5716
 * @access    private
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5717
 * @since     2.5.4
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5718
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5719
function _ot_settings_potential_shared_terms() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5720
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5721
  $options      = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5722
  $settings     = get_option( ot_settings_id(), array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5723
  $option_types = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5724
    'category-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5725
    'category-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5726
    'tag-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5727
    'tag-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5728
    'taxonomy-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5729
    'taxonomy-select'
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5732
  if ( isset( $settings['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5733
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5734
    foreach( $settings['settings'] as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5735
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5736
      if ( isset( $value['type'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5737
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5738
        if ( $value['type'] == 'list-item' && isset( $value['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5739
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5740
          $saved = ot_get_option( $value['id'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5741
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5742
          foreach( $value['settings'] as $item ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5743
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5744
            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
  5745
              $sub_options = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5746
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5747
              foreach( $saved as $sub_key => $sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5748
                if ( isset( $sub_value[$item['id']] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5749
                  $sub_options[$sub_key] = $sub_value[$item['id']];
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5753
              if ( ! empty( $sub_options ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5754
                $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5755
                  'id'       => $item['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5756
                  'taxonomy' => $value['taxonomy'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5757
                  'parent'   => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5758
                  'value'    => $sub_options
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5767
        if ( in_array( $value['type'], $option_types ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5768
          $saved = ot_get_option( $value['id'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5769
          if ( ! empty( $saved ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5770
            $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5771
              'id'       => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5772
              'taxonomy' => $value['taxonomy'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5773
              'value'    => $saved
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5784
  return $options;
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5789
 * 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
  5790
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5791
 * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5792
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5793
 * @access    private
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5794
 * @since     2.5.4
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5795
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5796
function _ot_meta_box_potential_shared_terms() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5797
  global $ot_meta_boxes;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5798
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5799
  $options      = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5800
  $settings     = $ot_meta_boxes;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5801
  $option_types = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5802
    'category-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5803
    'category-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5804
    'tag-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5805
    'tag-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5806
    'taxonomy-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5807
    'taxonomy-select'
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5810
  foreach( $settings as $setting ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5811
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5812
    if ( isset( $setting['fields'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5813
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5814
      foreach( $setting['fields'] as $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5815
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5816
        if ( isset( $value['type'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5817
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5818
          if ( $value['type'] == 'list-item' && isset( $value['settings'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5819
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5820
            $children = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5821
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5822
            foreach( $value['settings'] as $item ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5823
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5824
              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
  5825
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5826
                $children[$value['id']][] = $item['id'];
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
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5832
            if ( ! empty( $children[$value['id']] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5833
              $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5834
                'id'       => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5835
                'children' => $children[$value['id']],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5836
                'taxonomy' => $value['taxonomy'],
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5842
          if ( in_array( $value['type'], $option_types ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5843
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5844
            $options[] = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5845
              'id'       => $value['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5846
              'taxonomy' => $value['taxonomy'],
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5859
  return $options;
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
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5864
 * Update terms when a term gets split.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5865
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5866
 * @param     int     $term_id ID of the formerly shared term.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5867
 * @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
  5868
 * @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
  5869
 * @param     string  $taxonomy Taxonomy for the split term.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5870
 * @return    void
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5871
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5872
 * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5873
 * @since     2.5.4
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5874
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5875
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
  5876
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5877
  // Process the Theme Options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5878
  $settings    = _ot_settings_potential_shared_terms();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5879
  $old_options = get_option( ot_options_id(), array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5880
  $new_options = $old_options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5881
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5882
  // Process the saved settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5883
  if ( ! empty( $settings ) && ! empty( $old_options ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5884
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5885
    // Loop over the Theme Options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5886
    foreach( $settings as $option ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5887
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5888
      if ( ! is_array( $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5889
        $option['taxonomy'] = explode( ',', $option['taxonomy'] );
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5892
      if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5893
        continue;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5896
      // The option ID was found
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5897
      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
  5898
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5899
        // This is a list item, we have to go deeper
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5900
        if ( isset( $option['parent'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5901
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5902
          // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5903
          foreach( $option['value'] as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5904
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5905
            // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5906
            if ( is_array( $value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5907
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5908
              // Loop over the sub array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5909
              foreach( $value as $sub_key => $sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5910
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5911
                if ( $sub_value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5912
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5913
                  unset( $new_options[$option['parent']][$key][$option['id']][$sub_key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5914
                  $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
  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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5920
            } else if ( $value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5921
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5922
              unset( $new_options[$option['parent']][$key][$option['id']] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5923
              $new_options[$option['parent']][$key][$option['id']] = $new_term_id;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5929
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5930
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5931
          // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5932
          if ( is_array( $option['value'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5933
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5934
            // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5935
            foreach( $option['value'] as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5936
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5937
              // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5938
              if ( $value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5939
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5940
                unset( $new_options[$option['id']][$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5941
                $new_options[$option['id']][$new_term_id] = $new_term_id;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5947
          // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5948
          } else if ( $option['value'] == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5949
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5950
            $new_options[$option['id']] = $new_term_id;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5962
  // Options need to be updated
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5963
  if ( $old_options !== $new_options ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5964
    update_option( ot_options_id(), $new_options );
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5967
  // Process the Meta Boxes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5968
  $meta_settings = _ot_meta_box_potential_shared_terms();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5969
  $option_types  = array( 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5970
    'category-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5971
    'category-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5972
    'tag-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5973
    'tag-select',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5974
    'taxonomy-checkbox',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5975
    'taxonomy-select'
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5978
  if ( ! empty( $meta_settings ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5979
    $old_meta = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5980
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5981
    foreach( $meta_settings as $option ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5982
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5983
      if ( ! is_array( $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5984
        $option['taxonomy'] = explode( ',', $option['taxonomy'] );
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
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5987
      if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5988
        continue;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5991
      if ( isset( $option['children'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5992
        $post_ids = get_posts( array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5993
          'fields'     => 'ids',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5994
          'meta_key'   => $option['id'],
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5997
        if ( $post_ids ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5998
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5999
          foreach( $post_ids as $post_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6000
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6001
            // Get the meta
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6002
            $old_meta = get_post_meta( $post_id, $option['id'], true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6003
            $new_meta = $old_meta;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6004
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6005
            // Has a saved value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6006
            if ( ! empty( $old_meta ) && is_array( $old_meta ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6007
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6008
              // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6009
              foreach( $old_meta as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6010
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6011
                foreach( $value as $sub_key => $sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6012
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6013
                  if ( in_array( $sub_key, $option['children'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6014
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6015
                    // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6016
                    if ( is_array( $sub_value ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6017
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6018
                      // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6019
                      foreach( $sub_value as $sub_sub_key => $sub_sub_value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6020
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6021
                        // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6022
                        if ( $sub_sub_value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6023
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6024
                          unset( $new_meta[$key][$sub_key][$sub_sub_key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6025
                          $new_meta[$key][$sub_key][$new_term_id] = $new_term_id;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6031
                    // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6032
                    } else if ( $sub_value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6033
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6034
                      $new_meta[$key][$sub_key] = $new_term_id;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6044
              // Update
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6045
              if ( $old_meta !== $new_meta ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6046
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6047
                update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6057
      } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6058
        $post_ids = get_posts( array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6059
          'fields'     => 'ids',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6060
          'meta_query' => array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6061
            'key'     => $option['id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6062
            'value'   => $term_id,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6063
            'compare' => 'IN'
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6067
        if ( $post_ids ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6068
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6069
          foreach( $post_ids as $post_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6070
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6071
            // Get the meta
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6072
            $old_meta = get_post_meta( $post_id, $option['id'], true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6073
            $new_meta = $old_meta;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6074
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6075
            // Has a saved value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6076
            if ( ! empty( $old_meta ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6077
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6078
              // The value is an array of IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6079
              if ( is_array( $old_meta ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6080
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6081
                // Loop over the array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6082
                foreach( $old_meta as $key => $value ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6083
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6084
                  // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6085
                  if ( $value == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6086
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6087
                    unset( $new_meta[$key] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6088
                    $new_meta[$new_term_id] = $new_term_id;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6094
              // It's a single value, just replace it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6095
              } else if ( $old_meta == $term_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6096
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6097
                $new_meta = $new_term_id;
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6101
              // Update
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6102
              if ( $old_meta !== $new_meta ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6103
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6104
                update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
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
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6121
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6122
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6123
/* End of file ot-functions-admin.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6124
/* Location: ./includes/ot-functions-admin.php */