-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstorefront-pro-skins.php
executable file
·126 lines (101 loc) · 3.12 KB
/
storefront-pro-skins.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/*
Plugin Name: Storefront Pro Skins
Plugin URI: http://pootlepress.com/
Description: Save instances of theme customization settings as skins and apply them on demand later.
Author: pootlepress
Version: 1.0.0
Author URI: http://pootlepress.com/
@developer shramee <[email protected]>
*/
/** Plugin admin class */
require 'inc/class-admin.php';
/** Plugin public class */
require 'inc/class-public.php';
/**
* Storefront Pro Skins main class
* @static string $token Plugin token
* @static string $file Plugin __FILE__
* @static string $url Plugin root dir url
* @static string $path Plugin root dir path
* @static string $version Plugin version
*/
class Storefront_Pro_Skins {
/** @var Storefront_Pro_Skins Instance */
private static $_instance = null;
/** @var string Token */
public static $token;
/** @var string Version */
public static $version;
/** @var string Plugin main __FILE__ */
public static $file;
/** @var string Plugin directory url */
public static $url;
/** @var string Plugin directory path */
public static $path;
public static $app_url;
/** @var Storefront_Pro_Skins_Admin Instance */
public $admin;
/** @var Storefront_Pro_Skins_Public Instance */
public $public;
/**
* Return class instance
* @return Storefront_Pro_Skins instance
*/
public static function instance( $file = __FILE__ ) {
if ( null == self::$_instance ) {
self::$_instance = new self( $file );
}
return self::$_instance;
}
/**
* Constructor function.
* @param string $file __FILE__ of the main plugin
* @access private
* @since 1.0.0
*/
private function __construct( $file ) {
self::$token = 'sfp-skins';
self::$file = $file;
self::$url = plugin_dir_url( $file );
self::$path = plugin_dir_path( $file );
self::$version = '1.0.0';
add_action( 'after_setup_theme', array( $this, 'setup' ) );
}
/**
* Initiates the plugin
* @action init
*/
public function setup() {
$theme = wp_get_theme();
if ( class_exists( 'Storefront_Pro' ) && ( $theme->name == 'Storefront' || $theme->parent_theme == 'Storefront' ) ) {
self::$app_url = 'https://storefront-pro-skins.firebaseapp.com/';
if ( isset( $_REQUEST['SFPS_DEBUG'] ) || ( defined( 'SFPS_DEBUG' ) && SFPS_DEBUG ) ) {
self::$app_url = 'http://localhost:4200/';
}
$this->_admin(); //Initiate admin
$this->_public(); //Initiate public
}
}
/**
* Initiates admin class and adds admin hooks
*/
private function _admin() {
//Instantiating admin class
$this->admin = Storefront_Pro_Skins_Admin::instance();
//Enqueue admin end JS and CSS
add_action( 'customize_controls_print_footer_scripts', array( $this->admin, 'enqueue' ) );
add_action( 'wp_ajax_sfp_clear_skins', array( $this->admin, 'ajax_sfp_clear_skins' ) );
}
/**
* Initiates public class and adds public hooks
*/
private function _public() {
//Instantiating public class
$this->public = Storefront_Pro_Skins_Public::instance();
//Enqueue front end JS and CSS
add_action( 'wp_enqueue_scripts', array( $this->public, 'enqueue' ) );
}
}
/** Intantiating main plugin class */
Storefront_Pro_Skins::instance( __FILE__ );