/inc/options-framework.php

  1. <?php 
  2. /** 
  3. Version: 1.9 
  4. */ 
  5. // If this file is called directly, abort. 
  6. if ( ! defined( 'WPINC' ) ) { 
  7. die; 
  8.  
  9. // Don't load if optionsframework_init is already defined 
  10. if (is_admin() && ! function_exists( 'optionsframework_init' ) ) : 
  11.  
  12. function optionsframework_init() { 
  13.  
  14. // If user can't edit theme options, exit 
  15. if ( ! current_user_can( 'edit_theme_options' ) ) { 
  16. return; 
  17.  
  18. // Include the required files 
  19. require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework.php'; 
  20. require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework-admin.php'; 
  21. require plugin_dir_path( __FILE__ ) . 'includes/class-options-interface.php'; 
  22. require plugin_dir_path( __FILE__ ) . 'includes/class-options-media-uploader.php'; 
  23. require plugin_dir_path( __FILE__ ) . 'includes/class-options-sanitize.php'; 
  24.  
  25. // Instantiate the options page. 
  26. $options_framework_admin = new Options_Framework_Admin; 
  27. $options_framework_admin->init(); 
  28.  
  29. // Instantiate the media uploader class 
  30. $options_framework_media_uploader = new Options_Framework_Media_Uploader; 
  31. $options_framework_media_uploader->init(); 
  32.  
  33.  
  34. add_action( 'init', 'optionsframework_init', 20 ); 
  35.  
  36. endif; 
  37.  
  38. /** 
  39. * Helper function to return the theme option value. 
  40. * If no value has been saved, it returns $default. 
  41. * Needed because options are saved as serialized strings. 
  42. * 
  43. * Not in a class to support backwards compatibility in themes. 
  44. */ 
  45. if ( ! function_exists( 'of_get_option' ) ) : 
  46. function of_get_option( $name, $default = false ) { 
  47.  
  48. $option_name = ''; 
  49.  
  50. // Gets option name as defined in the theme 
  51. if ( function_exists( 'optionsframework_option_name' ) ) { 
  52. $option_name = optionsframework_option_name(); 
  53.  
  54. // Fallback option name 
  55. if ( '' == $option_name ) { 
  56. $option_name = get_option( 'stylesheet' ); 
  57. $option_name = preg_replace( "/\W/", "_", strtolower( $option_name ) ); 
  58.  
  59. // Get option settings from database 
  60. $options = get_option( $option_name ); 
  61.  
  62. // Return specific option 
  63. if ( isset( $options[$name] ) ) { 
  64. return $options[$name]; 
  65.  
  66. return $default; 
  67. endif; 
.