-
Notifications
You must be signed in to change notification settings - Fork 286
/
options-framework.php
86 lines (69 loc) · 2.39 KB
/
options-framework.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Options Framework
*
* @package Options Framework
* @author Devin Price <[email protected]>
* @license GPL-2.0+
* @link http://wptheming.com
* @copyright 2010-2016 WP Theming
*
* @wordpress-plugin
* Plugin Name: Options Framework
* Plugin URI: http://wptheming.com
* Description: A framework for building theme options.
* Version: 1.8.6
* Author: Devin Price
* Author URI: http://wptheming.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: options-framework
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
function optionsframework_init() {
// If user can't edit theme options, exit
if ( !current_user_can( 'edit_theme_options' ) )
return;
// Load translation files
load_plugin_textdomain( 'options-framework', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
// Loads the required Options Framework classes.
require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework-admin.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-interface.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-media-uploader.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-sanitization.php';
// Instantiate the main plugin class.
$options_framework = new Options_Framework;
$options_framework->init();
// Instantiate the options page.
$options_framework_admin = new Options_Framework_Admin;
$options_framework_admin->init();
// Instantiate the media uploader class
$options_framework_media_uploader = new Options_Framework_Media_Uploader;
$options_framework_media_uploader->init();
}
add_action( 'init', 'optionsframework_init', 20 );
/**
* Helper function to return the theme option value.
* If no value has been saved, it returns $default.
* Needed because options are saved as serialized strings.
*
* Not in a class to support backwards compatibility in themes.
*/
if ( ! function_exists( 'of_get_option' ) ) :
function of_get_option( $name, $default = false ) {
$config = get_option( 'optionsframework' );
if ( ! isset( $config['id'] ) ) {
return $default;
}
$options = get_option( $config['id'] );
if ( isset( $options[$name] ) ) {
return $options[$name];
}
return $default;
}
endif;