wp/wp-content/plugins/option-tree/ot-loader.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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Plugin Name: OptionTree
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     4
 * Plugin URI:  https://github.com/valendesigns/option-tree/
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     6
 * Version:     2.6.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * Author:      Derek Herman
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * Author URI:  http://valendesigns.com
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * License:     GPLv3
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
 * Text Domain: option-tree
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    14
 * Forces Plugin Mode when OptionTree is already loaded and displays an admin notice.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    15
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    16
if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && OT_PLUGIN_MODE == true ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    18
  add_filter( 'ot_theme_mode', '__return_false', 999 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
  function ot_conflict_notice() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
    echo '<div class="error"><p>' . __( 'OptionTree is installed as a plugin and also embedded in your current theme. Please deactivate the plugin to load the theme dependent version of OptionTree, and remove this warning.', 'option-tree' ) . '</p></div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
  add_action( 'admin_notices', 'ot_conflict_notice' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
 * This is the OptionTree loader class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
 * @package   OptionTree
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
 * @author    Derek Herman <derek@valendesigns.com>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
 * @copyright Copyright (c) 2013, Derek Herman
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
if ( ! class_exists( 'OT_Loader' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
  class OT_Loader {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
     * PHP5 constructor method.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
     * This method loads other methods of the class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
     * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
     * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
    public function __construct() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
      /* load languages */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
      $this->load_languages();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
      /* load OptionTree */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
      add_action( 'after_setup_theme', array( $this, 'load_option_tree' ), 1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
     * Load the languages before everything else.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
     * @access    private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
     * @since     2.1.3
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
    private function load_languages() {
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
       * A quick check to see if we're in plugin mode.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
       * @since     2.1.3
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
       */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    76
      define( 'OT_PLUGIN_MODE', strpos( dirname( __FILE__ ), 'plugins' . DIRECTORY_SEPARATOR . basename( dirname( __FILE__ ) ) ) !== false ? true : false );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
       * Path to the languages directory. 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
       * This path will be relative in plugin mode and absolute in theme mode.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
       * @since     2.0.10
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    84
       * @updated   2.4.1
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
       */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    86
      if ( OT_PLUGIN_MODE ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    87
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    88
        define( 'OT_LANG_DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . trailingslashit( 'languages' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    89
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    90
      } else {
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
        if ( apply_filters( 'ot_child_theme_mode', false ) == true ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    93
        
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    94
          $path = @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    95
          $path = ltrim( end( $path ), '/' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    96
          define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    97
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    98
        } else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    99
          
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   100
          $path = @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   101
          $path = ltrim( end( $path ), '/' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   102
          define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' );
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
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   105
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
      }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
      /* load the text domain  */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
      if ( OT_PLUGIN_MODE ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
        add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
      } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
        add_action( 'after_setup_theme', array( $this, 'load_textdomain' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
     * Load the text domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
     * @access    private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
     * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
    public function load_textdomain() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
      if ( OT_PLUGIN_MODE ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
        load_plugin_textdomain( 'option-tree', false, OT_LANG_DIR );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
      } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
      
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
        load_theme_textdomain( 'option-tree', OT_LANG_DIR );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
    /** 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
     * Load OptionTree on the 'after_setup_theme' action. Then filters will 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
     * be availble to the theme, and not only when in Theme Mode.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
     * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
     * @since     2.1.2
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
    public function load_option_tree() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
      /* setup the constants */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
      $this->constants();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
      /* include the required admin files */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
      $this->admin_includes();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
      /* include the required files */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
      $this->includes();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
      /* hook into WordPress */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
      $this->hooks();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
     * Constants
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
     * Defines the constants for use within OptionTree. Constants 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
     * are prefixed with 'OT_' to avoid any naming collisions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
     * @access    private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
     * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
    private function constants() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
       * Current Version number.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
       */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   184
      define( 'OT_VERSION', '2.6.0' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
       * For developers: Theme mode.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
       * Run a filter and set to true to enable OptionTree theme mode.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
       * You must have this files parent directory inside of 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
       * your themes root directory. As well, you must include 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
       * a reference to this file in your themes functions.php.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
       * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
      define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
       * For developers: Child Theme mode. TODO document
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
       * Run a filter and set to true to enable OptionTree child theme mode.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
       * You must have this files parent directory inside of 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
       * your themes root directory. As well, you must include 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
       * a reference to this file in your themes functions.php.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
       * @since     2.0.15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
      define( 'OT_CHILD_THEME_MODE', apply_filters( 'ot_child_theme_mode', false ) );
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
       * For developers: Show Pages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
       * Run a filter and set to false if you don't want to load the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
       * settings & documentation pages in the admin area of WordPress.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
       * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
      define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
       * For developers: Show Theme Options UI Builder
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
       * Run a filter and set to false if you want to hide the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
       * Theme Options UI page in the admin area of WordPress.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
       * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
      define( 'OT_SHOW_OPTIONS_UI', apply_filters( 'ot_show_options_ui', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
      /**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   231
       * For developers: Show Settings Import
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
       * Run a filter and set to false if you want to hide the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
       * Settings Import options on the Import page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
       * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
      define( 'OT_SHOW_SETTINGS_IMPORT', apply_filters( 'ot_show_settings_import', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
      /**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   241
       * For developers: Show Settings Export
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
       * Run a filter and set to false if you want to hide the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
       * Settings Import options on the Import page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
       * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
      define( 'OT_SHOW_SETTINGS_EXPORT', apply_filters( 'ot_show_settings_export', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
       * For developers: Show New Layout.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
       * Run a filter and set to false if you don't want to show the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
       * "New Layout" section at the top of the theme options page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
       * @since     2.0.10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
      define( 'OT_SHOW_NEW_LAYOUT', apply_filters( 'ot_show_new_layout', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
       * For developers: Show Documentation
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
       * Run a filter and set to false if you want to hide the Documentation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
       * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
      define( 'OT_SHOW_DOCS', apply_filters( 'ot_show_docs', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
       * For developers: Custom Theme Option page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
       * Run a filter and set to false if you want to hide the OptionTree 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
       * Theme Option page and build your own.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
       * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
      define( 'OT_USE_THEME_OPTIONS', apply_filters( 'ot_use_theme_options', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
       * For developers: Meta Boxes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
       * Run a filter and set to false to keep OptionTree from
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
       * loading the meta box resources.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
       * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
      define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
      /**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   290
       * For developers: Allow Unfiltered HTML in all the textareas.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   291
       *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   292
       * Run a filter and set to true if you want all the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   293
       * users to be able to post anything in the textareas.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   294
       * WARNING: This opens a security hole for low level users
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   295
       * to be able to post malicious scripts, you've been warned.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   296
       *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   297
       * @since     2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   298
       */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   299
      define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   301
      /**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
       * For developers: Post Formats.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
       *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   304
       * Run a filter and set to true if you want OptionTree 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   305
       * to load meta boxes for post formats.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
       *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
       * @since     2.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   308
       */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   309
      define( 'OT_POST_FORMATS', apply_filters( 'ot_post_formats', false ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   310
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
      /**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
       * Check if in theme mode.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
       * If OT_THEME_MODE and OT_CHILD_THEME_MODE is false, set the 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
       * directory path & URL like any other plugin. Otherwise, use 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
       * the parent or child themes root directory. 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
       * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
      if ( false == OT_THEME_MODE && false == OT_CHILD_THEME_MODE ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
        define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
        define( 'OT_URL', plugin_dir_url( __FILE__ ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
      } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
        if ( true == OT_CHILD_THEME_MODE ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   325
          $path = ltrim( end( @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   326
          define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   327
          define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
        } else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   329
          $path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   330
          define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   331
          define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
      /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
       * Template directory URI for the current theme.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
       *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
       * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
       */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
      if ( true == OT_CHILD_THEME_MODE ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
        define( 'OT_THEME_URL', get_stylesheet_directory_uri() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
      } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
        define( 'OT_THEME_URL', get_template_directory_uri() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
    }
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
     * Include admin files
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
     * These functions are included on admin pages only.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
     * @access    private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
     * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
    private function admin_includes() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
      /* exit early if we're not on an admin page */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
      if ( ! is_admin() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
      /* global include files */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
      $files = array( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
        'ot-functions-admin',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
        'ot-functions-option-types',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
        'ot-functions-compat',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
        'ot-settings-api'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
      );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
      /* include the meta box api */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
      if ( OT_META_BOXES == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
        $files[] = 'ot-meta-box-api';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
      
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   377
      /* include the post formats api */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   378
      if ( OT_META_BOXES == true && OT_POST_FORMATS == true ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   379
        $files[] = 'ot-post-formats-api';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   380
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   381
      
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
      /* include the settings & docs pages */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
      if ( OT_SHOW_PAGES == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
        $files[] = 'ot-functions-settings-page';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
        $files[] = 'ot-functions-docs-page';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
      
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   388
      /* include the cleanup api */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   389
      $files[] = 'ot-cleanup-api';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   390
      
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
      /* require the files */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
      foreach ( $files as $file ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
        $this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" );
0
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
      /* Registers the Theme Option page */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
      add_action( 'init', 'ot_register_theme_options_page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
      /* Registers the Settings page */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
      if ( OT_SHOW_PAGES == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
        add_action( 'init', 'ot_register_settings_page' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   402
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   403
        /* global CSS */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   404
        add_action( 'admin_head', array( $this, 'global_admin_css' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
     * Include front-end files
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
     * These functions are included on every page load 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
     * incase other plugins need to access them.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
     * @access    private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
     * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
    private function includes() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
      $files = array( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
        'ot-functions',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
        'ot-functions-deprecated'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
      );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
      /* require the files */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
      foreach ( $files as $file ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   429
        $this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
     * Execute the WordPress Hooks
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
     * @return    void
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
    private function hooks() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   443
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   444
      // Attempt to migrate the settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   445
      if ( function_exists( 'ot_maybe_migrate_settings' ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   446
        add_action( 'init', 'ot_maybe_migrate_settings', 1 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   447
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   448
      // Attempt to migrate the Options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   449
      if ( function_exists( 'ot_maybe_migrate_options' ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   450
        add_action( 'init', 'ot_maybe_migrate_options', 1 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   451
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   452
      // Attempt to migrate the Layouts
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   453
      if ( function_exists( 'ot_maybe_migrate_layouts' ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   454
        add_action( 'init', 'ot_maybe_migrate_layouts', 1 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
      /* load the Meta Box assets */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
      if ( OT_META_BOXES == true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
        /* add scripts for metaboxes to post-new.php & post.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
        add_action( 'admin_print_scripts-post-new.php', 'ot_admin_scripts', 11 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
        add_action( 'admin_print_scripts-post.php', 'ot_admin_scripts', 11 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
              
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
        /* add styles for metaboxes to post-new.php & post.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
        add_action( 'admin_print_styles-post-new.php', 'ot_admin_styles', 11 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
        add_action( 'admin_print_styles-post.php', 'ot_admin_styles', 11 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
      
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
      /* Adds the Theme Option page to the admin bar */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
      add_action( 'admin_bar_menu', 'ot_register_theme_options_admin_bar_menu', 999 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
      /* prepares the after save do_action */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
      add_action( 'admin_init', 'ot_after_theme_options_save', 1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
      /* default settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
      add_action( 'admin_init', 'ot_default_settings', 2 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
      /* add xml to upload filetypes array */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
      add_action( 'admin_init', 'ot_add_xml_to_upload_filetypes', 3 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
      /* import */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
      add_action( 'admin_init', 'ot_import', 4 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
      /* export */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
      add_action( 'admin_init', 'ot_export', 5 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
      /* save settings */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
      add_action( 'admin_init', 'ot_save_settings', 6 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
      /* save layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
      add_action( 'admin_init', 'ot_modify_layouts', 7 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
      /* create media post */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
      add_action( 'admin_init', 'ot_create_media_post', 8 );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   495
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   496
      /* Google Fonts front-end CSS */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   497
      add_action( 'wp_enqueue_scripts', 'ot_load_google_fonts_css', 1 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   498
 
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
      /* dynamic front-end CSS */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
      add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
      /* insert theme CSS dynamically */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
      add_action( 'ot_after_theme_options_save', 'ot_save_css' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
      /* AJAX call to create a new section */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
      add_action( 'wp_ajax_add_section', array( $this, 'add_section' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
      /* AJAX call to create a new setting */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
      add_action( 'wp_ajax_add_setting', array( $this, 'add_setting' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
      /* AJAX call to create a new contextual help */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
      add_action( 'wp_ajax_add_the_contextual_help', array( $this, 'add_the_contextual_help' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
      /* AJAX call to create a new choice */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
      add_action( 'wp_ajax_add_choice', array( $this, 'add_choice' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
      /* AJAX call to create a new list item setting */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
      add_action( 'wp_ajax_add_list_item_setting', array( $this, 'add_list_item_setting' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
      /* AJAX call to create a new layout */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
      add_action( 'wp_ajax_add_layout', array( $this, 'add_layout' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
      /* AJAX call to create a new list item */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
      add_action( 'wp_ajax_add_list_item', array( $this, 'add_list_item' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
      
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   526
      /* AJAX call to create a new social link */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   527
      add_action( 'wp_ajax_add_social_links', array( $this, 'add_social_links' ) );
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
      /* AJAX call to retrieve Google Font data */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   530
      add_action( 'wp_ajax_ot_google_font', array( $this, 'retrieve_google_font' ) );
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
      // Adds the temporary hacktastic shortcode
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   533
      add_filter( 'media_view_settings', array( $this, 'shortcode' ), 10, 2 );
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
      // AJAX update
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   536
      add_action( 'wp_ajax_gallery_update', array( $this, 'ajax_gallery_update' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   537
      
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
      /* Modify the media uploader button */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
      add_filter( 'gettext', array( $this, 'change_image_button' ), 10, 3 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
     * Load a file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
     * @return    void
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
     * @access    private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
     * @since     2.0.15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
    private function load_file( $file ){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
      include_once( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
     * Adds the global CSS to fix the menu icon.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
    public function global_admin_css() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   561
      global $wp_version;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   562
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   563
      $wp_38plus = version_compare( $wp_version, '3.8', '>=' ) ? true : false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   564
      $fontsize = $wp_38plus ? '20px' : '16px';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   565
      $wp_38minus = '';
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
      if ( ! $wp_38plus ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   568
        $wp_38minus = '
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   569
        #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   570
          background: none;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   571
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   572
        #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   573
          padding-left: 6px;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   574
        }';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   575
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   576
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
      echo '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
      <style>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   579
        @font-face {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   580
          font-family: "option-tree-font";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   581
          src:url("' . OT_URL . 'assets/fonts/option-tree-font.eot");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   582
          src:url("' . OT_URL . 'assets/fonts/option-tree-font.eot?#iefix") format("embedded-opentype"),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   583
            url("' . OT_URL . 'assets/fonts/option-tree-font.woff") format("woff"),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
            url("' . OT_URL . 'assets/fonts/option-tree-font.ttf") format("truetype"),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   585
            url("' . OT_URL . 'assets/fonts/option-tree-font.svg#option-tree-font") format("svg");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   586
          font-weight: normal;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   587
          font-style: normal;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
        }
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   589
        #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   590
          font: normal ' . $fontsize . '/1 "option-tree-font" !important;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
          speak: none;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   592
          padding: 6px 0;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   593
          height: 34px;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
          width: 20px;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   595
          display: inline-block;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
          -webkit-font-smoothing: antialiased;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
          -moz-osx-font-smoothing: grayscale;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
          -webkit-transition: all .1s ease-in-out;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
          -moz-transition:    all .1s ease-in-out;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
          transition:         all .1s ease-in-out;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
        }
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   602
        #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
          content: "\e785";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   604
        }'  . $wp_38minus . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
      </style>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
      ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
     * AJAX utility function for adding a new section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
    public function add_section() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
      echo ot_sections_view( ot_settings_id() . '[sections]', $_REQUEST['count'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
      die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
     * AJAX utility function for adding a new setting.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
    public function add_setting() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
      echo ot_settings_view( $_REQUEST['name'], $_REQUEST['count'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
      die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
     * AJAX utility function for adding a new list item setting.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
    public function add_list_item_setting() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
      echo ot_settings_view( $_REQUEST['name'] . '[settings]', $_REQUEST['count'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
      die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   633
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
     * AJAX utility function for adding new contextual help content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
    public function add_the_contextual_help() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
      echo ot_contextual_help_view( $_REQUEST['name'], $_REQUEST['count'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
      die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
     * AJAX utility function for adding a new choice.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
    public function add_choice() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
      echo ot_choices_view( $_REQUEST['name'], $_REQUEST['count'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
      die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
     * AJAX utility function for adding a new layout.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
    public function add_layout() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
      echo ot_layout_view( $_REQUEST['count'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
      die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
    /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
     * AJAX utility function for adding a new list item.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
    public function add_list_item() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   661
      check_ajax_referer( 'option_tree', 'nonce' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
      ot_list_item_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
      die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
    
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
    /**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   667
     * AJAX utility function for adding a new social link.
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
    public function add_social_links() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   670
      check_ajax_referer( 'option_tree', 'nonce' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   671
      ot_social_links_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   672
      die();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   673
    }
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
     * Fake the gallery shortcode
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
     * The JS takes over and creates the actual shortcode with 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   679
     * the real attachment IDs on the fly. Here we just need to 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   680
     * pass in the post ID to get the ball rolling.
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
     * @param     array     The current settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   683
     * @param     object    The post object
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   684
     * @return    array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   685
     *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   686
     * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   687
     * @since     2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   688
     */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   689
    public function shortcode( $settings, $post ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   690
      global $pagenow;
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
      if ( in_array( $pagenow, array( 'upload.php', 'customize.php' ) ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   693
        return $settings;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   694
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   695
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   696
      // Set the OptionTree post ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   697
      if ( ! is_object( $post ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   698
        $post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_GET['post_ID'] ) ? $_GET['post_ID'] : 0 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   699
        if ( $post_id == 0 && function_exists( 'ot_get_media_post_ID' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   700
          $post_id = ot_get_media_post_ID();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   701
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   702
        $settings['post']['id'] = $post_id;
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
      // No ID return settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   706
      if ( $settings['post']['id'] == 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   707
        return $settings;
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
      // Set the fake shortcode
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   710
      $settings['ot_gallery'] = array( 'shortcode' => "[gallery id='{$settings['post']['id']}']" );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   711
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   712
      // Return settings
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   713
      return $settings;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   714
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   715
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   716
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   717
    /**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   718
     * Returns the AJAX images
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
     * @return    string
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
     * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   723
     * @since     2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   724
     */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   725
    public function ajax_gallery_update() {
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
      if ( ! empty( $_POST['ids'] ) )  {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   728
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   729
        $return = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   730
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
        foreach( $_POST['ids'] as $id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
          $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   734
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   735
          $return .= '<li><img  src="' . $thumbnail[0] . '" width="75" height="75" /></li>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   736
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   738
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   739
        echo $return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   740
        exit();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   741
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   742
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   743
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   744
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   745
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   746
    /**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   747
     * Returns a JSON encoded Google fonts array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   748
     *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   749
     * @return    array
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
     * @access    public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   752
     * @since     2.5.0
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
    public function retrieve_google_font() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   755
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   756
      if ( isset( $_POST['field_id'], $_POST['family'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   757
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   758
        ot_fetch_google_fonts();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   759
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   760
        echo json_encode( array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   761
          'variants' => ot_recognized_google_font_variants( $_POST['field_id'], $_POST['family'] ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   762
          'subsets'  => ot_recognized_google_font_subsets( $_POST['field_id'], $_POST['family'] )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   763
        ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   764
        exit();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   765
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
    }
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
    /**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
     * Filters the media uploader button.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
     * @return    string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
     *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
     * @access    public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
     * @since     2.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
     */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
    public function change_image_button( $translation, $text, $domain ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
      global $pagenow;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   781
      if ( $pagenow == apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) && 'default' == $domain && 'Insert into post' == $text ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
        // Once is enough.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
        remove_filter( 'gettext', array( $this, 'ot_change_image_button' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   785
        return apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
        
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
      
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
      return $translation;
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
    
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   793
    
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
  
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
  /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
   * Instantiate the OptionTree loader class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
   *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
   * @since     2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
   */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
  $ot_loader = new OT_Loader();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
/* End of file ot-loader.php */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   806
/* Location: ./ot-loader.php */