11<?php
22namespace JustCoded \WP \Framework \Admin ;
33
4+ use JustCoded \WP \Framework \Objects \Singleton ;
5+
46/**
57 * Theme Settings base class
68 * Contain few methods to work with Titan framework
79 */
810abstract class Theme_Settings {
11+ use Singleton;
12+
913 /**
1014 * Unique framework instance to be used
1115 *
1216 * @var \TitanFramework
1317 */
14- protected static $ tf ;
18+ protected static $ titan_instance ;
1519
1620 /**
1721 * Theme Settings constructor
1822 * init framework hook
1923 */
20- public function __construct () {
24+ protected function __construct () {
2125 add_action ( 'tf_create_options ' , array ( $ this , 'init ' ) );
2226 }
2327
28+ /**
29+ * Check and create titan framework instance if needed
30+ *
31+ * @return \TitanFramework
32+ */
33+ public static function titan_instance () {
34+ if ( ! static ::$ titan_instance ) {
35+ static ::$ titan_instance = \TitanFramework::getInstance ( 'just_theme_options ' );
36+ }
37+ return static ::$ titan_instance ;
38+ }
39+
2440 /**
2541 * Check and init framework instance if needed
42+ *
43+ * @deprecated from 2.1.2, use titan_instance() method.
2644 */
2745 public static function check_instance () {
28- if ( ! self ::$ tf ) {
29- self ::$ tf = \TitanFramework::getInstance ( 'just_theme_options ' );
30- }
46+ return static ::titan_instance ();
3147 }
3248
3349 /**
@@ -38,9 +54,7 @@ public static function check_instance() {
3854 * @return mixed
3955 */
4056 public static function get ( $ option_name ) {
41- self ::check_instance ();
42-
43- return self ::$ tf ->getOption ( $ option_name );
57+ return static ::titan_instance ()->getOption ( $ option_name );
4458 }
4559
4660 /**
@@ -50,6 +64,7 @@ public static function get( $option_name ) {
5064 * @param \TitanFrameworkAdminPage $panel Titan framework panel object.
5165 * @param array $tabs Tabs init callbacks to be executed.
5266 *
67+ * @deprecated from 1.1.2
5368 * @throws \Exception Missing method to execute.
5469 */
5570 public function add_panel_tabs ( $ panel , $ tabs ) {
0 commit comments