-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTheme_Settings.php
More file actions
91 lines (79 loc) · 2.04 KB
/
Theme_Settings.php
File metadata and controls
91 lines (79 loc) · 2.04 KB
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
87
88
89
90
91
<?php
namespace JustCoded\WP\Framework\Admin;
use JustCoded\WP\Framework\Objects\Singleton;
/**
* Theme Settings base class
* Contain few methods to work with Titan framework
*/
abstract class Theme_Settings {
use Singleton;
/**
* Unique framework instance to be used
*
* @var \TitanFramework
*/
protected static $titan_instance;
public static $panel;
/**
* Theme Settings constructor
* init framework hook
*/
protected function __construct() {
add_action( 'tf_create_options', array( $this, 'init' ) );
}
/**
* Check and create titan framework instance if needed
*
* @return \TitanFramework
*/
public static function titan_instance() {
if ( ! static::$titan_instance ) {
static::$titan_instance = \TitanFramework::getInstance( 'just_theme_options' );
}
return static::$titan_instance;
}
/**
* Check and init framework instance if needed
*
* @deprecated from 2.1.2, use titan_instance() method.
*/
public static function check_instance() {
return static::titan_instance();
}
/**
* Get theme setting from the database
*
* @param string $option_name option name to get value from.
*
* @return mixed
*/
public static function get( $option_name ) {
return static::titan_instance()->getOption( $option_name );
}
/**
* Run tabs methods one by one
* Search for function self::register_{slug}_tab
*
* @param \TitanFrameworkAdminPage $panel Titan framework panel object.
* @param array $tabs Tabs init callbacks to be executed.
*
* @deprecated from 1.1.2
* @throws \Exception Missing method to execute.
*/
public function add_panel_tabs( $panel, $tabs ) {
foreach ( $tabs as $slug => $name ) {
$method = 'register_' . $slug . '_tab';
if ( ! method_exists( $this, $method ) ) {
throw new \Exception( 'Theme_Settings: Unable to find tab method "' . $method . '"' );
}
$this->$method( $panel );
}
}
/**
* Main function to init Theme settings
* should be written in child App class
*
* @return mixed
*/
abstract public function init();
}