wp/wp-content/plugins/option-tree/ot-loader.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * Plugin Name: OptionTree
     3  * Plugin Name: OptionTree
     4  * Plugin URI:  http://wp.envato.com
     4  * Plugin URI:  https://github.com/valendesigns/option-tree/
     5  * Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
     5  * Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes.
     6  * Version:     2.1.4
     6  * Version:     2.5.5
     7  * Author:      Derek Herman
     7  * Author:      Derek Herman
     8  * Author URI:  http://valendesigns.com
     8  * Author URI:  http://valendesigns.com
     9  * License:     GPLv3
     9  * License:     GPLv3
    10  */
    10  */
       
    11 
       
    12 /**
       
    13  * Forces Plugin Mode when OptionTree is already loaded and displays an admin notice.
       
    14  */
       
    15 if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && OT_PLUGIN_MODE == true ) {
       
    16   
       
    17   add_filter( 'ot_theme_mode', '__return_false', 999 );
       
    18   
       
    19   function ot_conflict_notice() {
       
    20     
       
    21     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>';
       
    22     
       
    23   }
       
    24   
       
    25   add_action( 'admin_notices', 'ot_conflict_notice' );
       
    26   
       
    27 }
    11 
    28 
    12 /**
    29 /**
    13  * This is the OptionTree loader class.
    30  * This is the OptionTree loader class.
    14  *
    31  *
    15  * @package   OptionTree
    32  * @package   OptionTree
    53       /**
    70       /**
    54        * A quick check to see if we're in plugin mode.
    71        * A quick check to see if we're in plugin mode.
    55        *
    72        *
    56        * @since     2.1.3
    73        * @since     2.1.3
    57        */
    74        */
    58       define( 'OT_PLUGIN_MODE', strpos( dirname( __FILE__ ), 'plugins/' . basename( dirname( __FILE__ ) ) ) !== false ? true : false );
    75       define( 'OT_PLUGIN_MODE', strpos( dirname( __FILE__ ), 'plugins' . DIRECTORY_SEPARATOR . basename( dirname( __FILE__ ) ) ) !== false ? true : false );
    59       
    76       
    60       /**
    77       /**
    61        * Path to the languages directory. 
    78        * Path to the languages directory. 
    62        *
    79        *
    63        * This path will be relative in plugin mode and absolute in theme mode.
    80        * This path will be relative in plugin mode and absolute in theme mode.
    64        *
    81        *
    65        * @since     2.0.10
    82        * @since     2.0.10
    66        */
    83        * @updated   2.4.1
    67       define( 'OT_LANG_DIR', dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    84        */
       
    85       if ( OT_PLUGIN_MODE ) {
       
    86         
       
    87         define( 'OT_LANG_DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . trailingslashit( 'languages' ) );
       
    88         
       
    89       } else {
       
    90       
       
    91         if ( apply_filters( 'ot_child_theme_mode', false ) == true ) {
       
    92         
       
    93           $path = ltrim( end( @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
       
    94           define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' );
       
    95           
       
    96         } else {
       
    97         
       
    98           $path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
       
    99           define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' );
       
   100           
       
   101         }
       
   102       
       
   103       }
    68 
   104 
    69       /* load the text domain  */
   105       /* load the text domain  */
    70       if ( OT_PLUGIN_MODE ) {
   106       if ( OT_PLUGIN_MODE ) {
    71       
   107       
    72         add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
   108         add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
    93       
   129       
    94         load_plugin_textdomain( 'option-tree', false, OT_LANG_DIR );
   130         load_plugin_textdomain( 'option-tree', false, OT_LANG_DIR );
    95         
   131         
    96       } else {
   132       } else {
    97       
   133       
    98         load_theme_textdomain( 'option-tree', OT_LANG_DIR . 'theme-mode' );
   134         load_theme_textdomain( 'option-tree', OT_LANG_DIR );
    99         
   135         
   100       }
   136       }
   101       
   137       
   102     }
   138     }
   103     
   139     
   140     private function constants() {
   176     private function constants() {
   141       
   177       
   142       /**
   178       /**
   143        * Current Version number.
   179        * Current Version number.
   144        */
   180        */
   145       define( 'OT_VERSION', '2.1.4' );
   181       define( 'OT_VERSION', '2.5.5' );
       
   182       
       
   183       /**
       
   184        * For developers: Theme mode.
       
   185        *
       
   186        * Run a filter and set to true to enable OptionTree theme mode.
       
   187        * You must have this files parent directory inside of 
       
   188        * your themes root directory. As well, you must include 
       
   189        * a reference to this file in your themes functions.php.
       
   190        *
       
   191        * @since     2.0
       
   192        */
       
   193       define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) );
       
   194       
       
   195       /**
       
   196        * For developers: Child Theme mode. TODO document
       
   197        *
       
   198        * Run a filter and set to true to enable OptionTree child theme mode.
       
   199        * You must have this files parent directory inside of 
       
   200        * your themes root directory. As well, you must include 
       
   201        * a reference to this file in your themes functions.php.
       
   202        *
       
   203        * @since     2.0.15
       
   204        */
       
   205       define( 'OT_CHILD_THEME_MODE', apply_filters( 'ot_child_theme_mode', false ) );
       
   206       
       
   207       /**
       
   208        * For developers: Show Pages.
       
   209        *
       
   210        * Run a filter and set to false if you don't want to load the
       
   211        * settings & documentation pages in the admin area of WordPress.
       
   212        *
       
   213        * @since     2.0
       
   214        */
       
   215       define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) );
       
   216       
       
   217       /**
       
   218        * For developers: Show Theme Options UI Builder
       
   219        *
       
   220        * Run a filter and set to false if you want to hide the
       
   221        * Theme Options UI page in the admin area of WordPress.
       
   222        *
       
   223        * @since     2.1
       
   224        */
       
   225       define( 'OT_SHOW_OPTIONS_UI', apply_filters( 'ot_show_options_ui', true ) );
       
   226       
       
   227       /**
       
   228        * For developers: Show Settings Import
       
   229        *
       
   230        * Run a filter and set to false if you want to hide the
       
   231        * Settings Import options on the Import page.
       
   232        *
       
   233        * @since     2.1
       
   234        */
       
   235       define( 'OT_SHOW_SETTINGS_IMPORT', apply_filters( 'ot_show_settings_import', true ) );
       
   236       
       
   237       /**
       
   238        * For developers: Show Settings Export
       
   239        *
       
   240        * Run a filter and set to false if you want to hide the
       
   241        * Settings Import options on the Import page.
       
   242        *
       
   243        * @since     2.1
       
   244        */
       
   245       define( 'OT_SHOW_SETTINGS_EXPORT', apply_filters( 'ot_show_settings_export', true ) );
       
   246       
       
   247       /**
       
   248        * For developers: Show New Layout.
       
   249        *
       
   250        * Run a filter and set to false if you don't want to show the
       
   251        * "New Layout" section at the top of the theme options page.
       
   252        *
       
   253        * @since     2.0.10
       
   254        */
       
   255       define( 'OT_SHOW_NEW_LAYOUT', apply_filters( 'ot_show_new_layout', true ) );
       
   256       
       
   257       /**
       
   258        * For developers: Show Documentation
       
   259        *
       
   260        * Run a filter and set to false if you want to hide the Documentation.
       
   261        *
       
   262        * @since     2.1
       
   263        */
       
   264       define( 'OT_SHOW_DOCS', apply_filters( 'ot_show_docs', true ) );
       
   265       
       
   266       /**
       
   267        * For developers: Custom Theme Option page
       
   268        *
       
   269        * Run a filter and set to false if you want to hide the OptionTree 
       
   270        * Theme Option page and build your own.
       
   271        *
       
   272        * @since     2.1
       
   273        */
       
   274       define( 'OT_USE_THEME_OPTIONS', apply_filters( 'ot_use_theme_options', true ) );
       
   275       
       
   276       /**
       
   277        * For developers: Meta Boxes.
       
   278        *
       
   279        * Run a filter and set to false to keep OptionTree from
       
   280        * loading the meta box resources.
       
   281        *
       
   282        * @since     2.0
       
   283        */
       
   284       define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) );
   146       
   285       
   147       /**
   286       /**
   148        * For developers: Allow Unfiltered HTML in all the textareas.
   287        * For developers: Allow Unfiltered HTML in all the textareas.
   149        *
   288        *
   150        * Run a filter and set to true if you want all the
   289        * Run a filter and set to true if you want all the
   153        * to be able to post malicious scripts, you've been warned.
   292        * to be able to post malicious scripts, you've been warned.
   154        *
   293        *
   155        * @since     2.0
   294        * @since     2.0
   156        */
   295        */
   157       define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) );
   296       define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) );
   158       
   297 
   159       /**
   298       /**
   160        * For developers: Theme mode.
   299        * For developers: Post Formats.
   161        *
   300        *
   162        * Run a filter and set to true to enable OptionTree theme mode.
   301        * Run a filter and set to true if you want OptionTree 
   163        * You must have this files parent directory inside of 
   302        * to load meta boxes for post formats.
   164        * your themes root directory. As well, you must include 
   303        *
   165        * a reference to this file in your themes functions.php.
   304        * @since     2.4.0
   166        *
   305        */
   167        * @since     2.0
   306       define( 'OT_POST_FORMATS', apply_filters( 'ot_post_formats', false ) );
   168        */
       
   169       define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) );
       
   170       
       
   171       /**
       
   172        * For developers: Child Theme mode. TODO document
       
   173        *
       
   174        * Run a filter and set to true to enable OptionTree child theme mode.
       
   175        * You must have this files parent directory inside of 
       
   176        * your themes root directory. As well, you must include 
       
   177        * a reference to this file in your themes functions.php.
       
   178        *
       
   179        * @since     2.0.15
       
   180        */
       
   181       define( 'OT_CHILD_THEME_MODE', apply_filters( 'ot_child_theme_mode', false ) );
       
   182       
       
   183       /**
       
   184        * For developers: Show Pages.
       
   185        *
       
   186        * Run a filter and set to false if you don't want to load the
       
   187        * settings & documentation pages in the admin area of WordPress.
       
   188        *
       
   189        * @since     2.0
       
   190        */
       
   191       define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) );
       
   192       
       
   193       /**
       
   194        * For developers: Show Theme Options UI Builder
       
   195        *
       
   196        * Run a filter and set to false if you want to hide the
       
   197        * Theme Options UI page in the admin area of WordPress.
       
   198        *
       
   199        * @since     2.1
       
   200        */
       
   201       define( 'OT_SHOW_OPTIONS_UI', apply_filters( 'ot_show_options_ui', true ) );
       
   202       
       
   203       /**
       
   204        * For developers: Hide Settings Import
       
   205        *
       
   206        * Run a filter and set to false if you want to hide the
       
   207        * Settings Import options on the Import page.
       
   208        *
       
   209        * @since     2.1
       
   210        */
       
   211       define( 'OT_SHOW_SETTINGS_IMPORT', apply_filters( 'ot_show_settings_import', true ) );
       
   212       
       
   213       /**
       
   214        * For developers: Hide Settings Export
       
   215        *
       
   216        * Run a filter and set to false if you want to hide the
       
   217        * Settings Import options on the Import page.
       
   218        *
       
   219        * @since     2.1
       
   220        */
       
   221       define( 'OT_SHOW_SETTINGS_EXPORT', apply_filters( 'ot_show_settings_export', true ) );
       
   222       
       
   223       /**
       
   224        * For developers: Show New Layout.
       
   225        *
       
   226        * Run a filter and set to false if you don't want to show the
       
   227        * "New Layout" section at the top of the theme options page.
       
   228        *
       
   229        * @since     2.0.10
       
   230        */
       
   231       define( 'OT_SHOW_NEW_LAYOUT', apply_filters( 'ot_show_new_layout', true ) );
       
   232       
       
   233       /**
       
   234        * For developers: Show Documentation
       
   235        *
       
   236        * Run a filter and set to false if you want to hide the Documentation.
       
   237        *
       
   238        * @since     2.1
       
   239        */
       
   240       define( 'OT_SHOW_DOCS', apply_filters( 'ot_show_docs', true ) );
       
   241       
       
   242       /**
       
   243        * For developers: Custom Theme Option page
       
   244        *
       
   245        * Run a filter and set to false if you want to hide the OptionTree 
       
   246        * Theme Option page and build your own.
       
   247        *
       
   248        * @since     2.1
       
   249        */
       
   250       define( 'OT_USE_THEME_OPTIONS', apply_filters( 'ot_use_theme_options', true ) );
       
   251       
       
   252       /**
       
   253        * For developers: Meta Boxes.
       
   254        *
       
   255        * Run a filter and set to false to keep OptionTree from
       
   256        * loading the meta box resources.
       
   257        *
       
   258        * @since     2.0
       
   259        */
       
   260       define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) );
       
   261       
   307       
   262       /**
   308       /**
   263        * Check if in theme mode.
   309        * Check if in theme mode.
   264        *
   310        *
   265        * If OT_THEME_MODE and OT_CHILD_THEME_MODE is false, set the 
   311        * If OT_THEME_MODE and OT_CHILD_THEME_MODE is false, set the 
   271       if ( false == OT_THEME_MODE && false == OT_CHILD_THEME_MODE ) {
   317       if ( false == OT_THEME_MODE && false == OT_CHILD_THEME_MODE ) {
   272         define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
   318         define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
   273         define( 'OT_URL', plugin_dir_url( __FILE__ ) );
   319         define( 'OT_URL', plugin_dir_url( __FILE__ ) );
   274       } else {
   320       } else {
   275         if ( true == OT_CHILD_THEME_MODE ) {
   321         if ( true == OT_CHILD_THEME_MODE ) {
   276           define( 'OT_DIR', trailingslashit( get_stylesheet_directory() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
   322           $path = ltrim( end( @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
   277           define( 'OT_URL', trailingslashit( get_stylesheet_directory_uri() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
   323           define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) );
       
   324           define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) );
   278         } else {
   325         } else {
   279           define( 'OT_DIR', trailingslashit( get_template_directory() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
   326           $path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
   280           define( 'OT_URL', trailingslashit( get_template_directory_uri() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
   327           define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) );
       
   328           define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) );
   281         }
   329         }
   282       }
   330       }
   283       
   331       
   284       /**
   332       /**
   285        * Template directory URI for the current theme.
   333        * Template directory URI for the current theme.
   321       /* include the meta box api */
   369       /* include the meta box api */
   322       if ( OT_META_BOXES == true ) {
   370       if ( OT_META_BOXES == true ) {
   323         $files[] = 'ot-meta-box-api';
   371         $files[] = 'ot-meta-box-api';
   324       }
   372       }
   325       
   373       
       
   374       /* include the post formats api */
       
   375       if ( OT_META_BOXES == true && OT_POST_FORMATS == true ) {
       
   376         $files[] = 'ot-post-formats-api';
       
   377       }
       
   378       
   326       /* include the settings & docs pages */
   379       /* include the settings & docs pages */
   327       if ( OT_SHOW_PAGES == true ) {
   380       if ( OT_SHOW_PAGES == true ) {
   328         $files[] = 'ot-functions-settings-page';
   381         $files[] = 'ot-functions-settings-page';
   329         $files[] = 'ot-functions-docs-page';
   382         $files[] = 'ot-functions-docs-page';
   330       }
   383       }
   331       
   384       
       
   385       /* include the cleanup api */
       
   386       $files[] = 'ot-cleanup-api';
       
   387       
   332       /* require the files */
   388       /* require the files */
   333       foreach ( $files as $file ) {
   389       foreach ( $files as $file ) {
   334         $this->load_file( OT_DIR . "includes/{$file}.php" );
   390         $this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" );
   335       }
   391       }
   336       
   392       
   337       /* Registers the Theme Option page */
   393       /* Registers the Theme Option page */
   338       add_action( 'init', 'ot_register_theme_options_page' );
   394       add_action( 'init', 'ot_register_theme_options_page' );
   339       
   395       
   362         'ot-functions-deprecated'
   418         'ot-functions-deprecated'
   363       );
   419       );
   364 
   420 
   365       /* require the files */
   421       /* require the files */
   366       foreach ( $files as $file ) {
   422       foreach ( $files as $file ) {
   367         $this->load_file( OT_DIR . "includes/{$file}.php" );
   423         $this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" );
   368       }
   424       }
   369       
   425       
   370     }
   426     }
   371     
   427     
   372     /**
   428     /**
   376      *
   432      *
   377      * @access    public
   433      * @access    public
   378      * @since     2.0
   434      * @since     2.0
   379      */
   435      */
   380     private function hooks() {
   436     private function hooks() {
       
   437       
       
   438       // Attempt to migrate the settings
       
   439       if ( function_exists( 'ot_maybe_migrate_settings' ) )
       
   440         add_action( 'init', 'ot_maybe_migrate_settings', 1 );
       
   441       
       
   442       // Attempt to migrate the Options
       
   443       if ( function_exists( 'ot_maybe_migrate_options' ) )
       
   444         add_action( 'init', 'ot_maybe_migrate_options', 1 );
       
   445       
       
   446       // Attempt to migrate the Layouts
       
   447       if ( function_exists( 'ot_maybe_migrate_layouts' ) )
       
   448         add_action( 'init', 'ot_maybe_migrate_layouts', 1 );
   381 
   449 
   382       /* load the Meta Box assets */
   450       /* load the Meta Box assets */
   383       if ( OT_META_BOXES == true ) {
   451       if ( OT_META_BOXES == true ) {
   384       
   452       
   385         /* add scripts for metaboxes to post-new.php & post.php */
   453         /* add scripts for metaboxes to post-new.php & post.php */
   419       /* create media post */
   487       /* create media post */
   420       add_action( 'admin_init', 'ot_create_media_post', 8 );
   488       add_action( 'admin_init', 'ot_create_media_post', 8 );
   421       
   489       
   422       /* global CSS */
   490       /* global CSS */
   423       add_action( 'admin_head', array( $this, 'global_admin_css' ) );
   491       add_action( 'admin_head', array( $this, 'global_admin_css' ) );
   424       
   492 
       
   493       /* Google Fonts front-end CSS */
       
   494       add_action( 'wp_enqueue_scripts', 'ot_load_google_fonts_css', 1 );
       
   495  
   425       /* dynamic front-end CSS */
   496       /* dynamic front-end CSS */
   426       add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 );
   497       add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 );
   427 
   498 
   428       /* insert theme CSS dynamically */
   499       /* insert theme CSS dynamically */
   429       add_action( 'ot_after_theme_options_save', 'ot_save_css' );
   500       add_action( 'ot_after_theme_options_save', 'ot_save_css' );
   447       add_action( 'wp_ajax_add_layout', array( $this, 'add_layout' ) );
   518       add_action( 'wp_ajax_add_layout', array( $this, 'add_layout' ) );
   448       
   519       
   449       /* AJAX call to create a new list item */
   520       /* AJAX call to create a new list item */
   450       add_action( 'wp_ajax_add_list_item', array( $this, 'add_list_item' ) );
   521       add_action( 'wp_ajax_add_list_item', array( $this, 'add_list_item' ) );
   451       
   522       
       
   523       /* AJAX call to create a new social link */
       
   524       add_action( 'wp_ajax_add_social_links', array( $this, 'add_social_links' ) );
       
   525 
       
   526       /* AJAX call to retrieve Google Font data */
       
   527       add_action( 'wp_ajax_ot_google_font', array( $this, 'retrieve_google_font' ) );
       
   528       
       
   529       // Adds the temporary hacktastic shortcode
       
   530       add_filter( 'media_view_settings', array( $this, 'shortcode' ), 10, 2 );
       
   531     
       
   532       // AJAX update
       
   533       add_action( 'wp_ajax_gallery_update', array( $this, 'ajax_gallery_update' ) );
       
   534       
   452       /* Modify the media uploader button */
   535       /* Modify the media uploader button */
   453       add_filter( 'gettext', array( $this, 'change_image_button' ), 10, 3 );
   536       add_filter( 'gettext', array( $this, 'change_image_button' ), 10, 3 );
   454       
   537       
   455     }
   538     }
   456     
   539     
   470     
   553     
   471     /**
   554     /**
   472      * Adds the global CSS to fix the menu icon.
   555      * Adds the global CSS to fix the menu icon.
   473      */
   556      */
   474     public function global_admin_css() {
   557     public function global_admin_css() {
       
   558       global $wp_version;
       
   559       
       
   560       $wp_38plus = version_compare( $wp_version, '3.8', '>=' ) ? true : false;
       
   561       $fontsize = $wp_38plus ? '20px' : '16px';
       
   562       $wp_38minus = '';
       
   563       
       
   564       if ( ! $wp_38plus ) {
       
   565         $wp_38minus = '
       
   566         #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image {
       
   567           background: none;
       
   568         }
       
   569         #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before {
       
   570           padding-left: 6px;
       
   571         }';
       
   572       }
       
   573 
   475       echo '
   574       echo '
   476       <style>
   575       <style>
   477         #adminmenu #toplevel_page_ot-settings .wp-menu-image img { padding: 5px 0px 1px 6px !important; }
   576         @font-face {
       
   577           font-family: "option-tree-font";
       
   578           src:url("' . OT_URL . 'assets/fonts/option-tree-font.eot");
       
   579           src:url("' . OT_URL . 'assets/fonts/option-tree-font.eot?#iefix") format("embedded-opentype"),
       
   580             url("' . OT_URL . 'assets/fonts/option-tree-font.woff") format("woff"),
       
   581             url("' . OT_URL . 'assets/fonts/option-tree-font.ttf") format("truetype"),
       
   582             url("' . OT_URL . 'assets/fonts/option-tree-font.svg#option-tree-font") format("svg");
       
   583           font-weight: normal;
       
   584           font-style: normal;
       
   585         }
       
   586         #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before,
       
   587         #option-tree-header #option-tree-logo a:before {
       
   588           font: normal ' . $fontsize . '/1 "option-tree-font" !important;
       
   589           speak: none;
       
   590           padding: 6px 0;
       
   591           height: 34px;
       
   592           width: 20px;
       
   593           display: inline-block;
       
   594           -webkit-font-smoothing: antialiased;
       
   595           -moz-osx-font-smoothing: grayscale;
       
   596           -webkit-transition: all .1s ease-in-out;
       
   597           -moz-transition:    all .1s ease-in-out;
       
   598           transition:         all .1s ease-in-out;
       
   599         }
       
   600         #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before,
       
   601         #option-tree-header #option-tree-logo a:before {
       
   602           content: "\e785";
       
   603         }
       
   604         #option-tree-header #option-tree-logo a:before {
       
   605           font-size: 20px !important;
       
   606           height: 24px;
       
   607           padding: 2px 0;
       
   608         }'  . $wp_38minus . '
   478       </style>
   609       </style>
   479       ';
   610       ';
   480     }
   611     }
   481     
   612     
   482     /**
   613     /**
   483      * AJAX utility function for adding a new section.
   614      * AJAX utility function for adding a new section.
   484      */
   615      */
   485     public function add_section() {
   616     public function add_section() {
   486       echo ot_sections_view( 'option_tree_settings[sections]', $_REQUEST['count'] );
   617       echo ot_sections_view( ot_settings_id() . '[sections]', $_REQUEST['count'] );
   487       die();
   618       die();
   488     }
   619     }
   489     
   620     
   490     /**
   621     /**
   491      * AJAX utility function for adding a new setting.
   622      * AJAX utility function for adding a new setting.
   534       ot_list_item_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
   665       ot_list_item_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
   535       die();
   666       die();
   536     }
   667     }
   537     
   668     
   538     /**
   669     /**
       
   670      * AJAX utility function for adding a new social link.
       
   671      */
       
   672     public function add_social_links() {
       
   673       ot_social_links_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] );
       
   674       die();
       
   675     }
       
   676     
       
   677     /**
       
   678      * Fake the gallery shortcode
       
   679      *
       
   680      * The JS takes over and creates the actual shortcode with 
       
   681      * the real attachment IDs on the fly. Here we just need to 
       
   682      * pass in the post ID to get the ball rolling.
       
   683      *
       
   684      * @param     array     The current settings
       
   685      * @param     object    The post object
       
   686      * @return    array
       
   687      *
       
   688      * @access    public
       
   689      * @since     2.2.0
       
   690      */
       
   691     public function shortcode( $settings, $post ) {
       
   692       global $pagenow;
       
   693 
       
   694       if ( in_array( $pagenow, array( 'upload.php', 'customize.php' ) ) ) {
       
   695         return $settings;
       
   696       }
       
   697 
       
   698       // Set the OptionTree post ID
       
   699       if ( ! is_object( $post ) ) {
       
   700         $post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_GET['post_ID'] ) ? $_GET['post_ID'] : 0 );
       
   701         if ( $post_id == 0 && function_exists( 'ot_get_media_post_ID' ) ) {
       
   702           $post_id = ot_get_media_post_ID();
       
   703         }
       
   704         $settings['post']['id'] = $post_id;
       
   705       }
       
   706       
       
   707       // No ID return settings
       
   708       if ( $settings['post']['id'] == 0 )
       
   709         return $settings;
       
   710   
       
   711       // Set the fake shortcode
       
   712       $settings['ot_gallery'] = array( 'shortcode' => "[gallery id='{$settings['post']['id']}']" );
       
   713       
       
   714       // Return settings
       
   715       return $settings;
       
   716       
       
   717     }
       
   718     
       
   719     /**
       
   720      * Returns the AJAX images
       
   721      *
       
   722      * @return    string
       
   723      *
       
   724      * @access    public
       
   725      * @since     2.2.0
       
   726      */
       
   727     public function ajax_gallery_update() {
       
   728     
       
   729       if ( ! empty( $_POST['ids'] ) )  {
       
   730         
       
   731         $return = '';
       
   732         
       
   733         foreach( $_POST['ids'] as $id ) {
       
   734         
       
   735           $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
       
   736           
       
   737           $return .= '<li><img  src="' . $thumbnail[0] . '" width="75" height="75" /></li>';
       
   738           
       
   739         }
       
   740         
       
   741         echo $return;
       
   742         exit();
       
   743       
       
   744       }
       
   745       
       
   746     }
       
   747 
       
   748     /**
       
   749      * Returns a JSON encoded Google fonts array.
       
   750      *
       
   751      * @return    array
       
   752      *
       
   753      * @access    public
       
   754      * @since     2.5.0
       
   755      */
       
   756     public function retrieve_google_font() {
       
   757 
       
   758       if ( isset( $_POST['field_id'], $_POST['family'] ) ) {
       
   759         
       
   760         ot_fetch_google_fonts();
       
   761         
       
   762         echo json_encode( array(
       
   763           'variants' => ot_recognized_google_font_variants( $_POST['field_id'], $_POST['family'] ),
       
   764           'subsets'  => ot_recognized_google_font_subsets( $_POST['field_id'], $_POST['family'] )
       
   765         ) );
       
   766         exit();
       
   767 
       
   768       }
       
   769 
       
   770     }
       
   771     
       
   772     /**
   539      * Filters the media uploader button.
   773      * Filters the media uploader button.
   540      *
   774      *
   541      * @return    string
   775      * @return    string
   542      *
   776      *
   543      * @access    public
   777      * @access    public
   544      * @since     2.1
   778      * @since     2.1
   545      */
   779      */
   546     public function change_image_button( $translation, $text, $domain ) {
   780     public function change_image_button( $translation, $text, $domain ) {
   547       global $pagenow;
   781       global $pagenow;
   548     
   782     
   549       if ( $pagenow == 'themes.php' && 'default' == $domain && 'Insert into post' == $text ) {
   783       if ( $pagenow == apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) && 'default' == $domain && 'Insert into post' == $text ) {
   550         
   784         
   551         // Once is enough.
   785         // Once is enough.
   552         remove_filter( 'gettext', array( $this, 'ot_change_image_button' ) );
   786         remove_filter( 'gettext', array( $this, 'ot_change_image_button' ) );
   553         return 'Send to OptionTree';
   787         return apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) );
   554         
   788         
   555       }
   789       }
   556       
   790       
   557       return $translation;
   791       return $translation;
   558       
   792       
   559     }
   793     }
       
   794     
   560     
   795     
   561   }
   796   }
   562   
   797   
   563   /**
   798   /**
   564    * Instantiate the OptionTree loader class.
   799    * Instantiate the OptionTree loader class.