-
Notifications
You must be signed in to change notification settings - Fork 0
/
occasio-pro.php
237 lines (194 loc) · 6.68 KB
/
occasio-pro.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
/*
Plugin Name: Occasio Pro
Plugin URI: http://themezee.com/addons/occasio-pro/
Description: Occasio Pro is an add-on plugin for Occasio including additional customization options for colors and typography as well as extra features like navigation menus, social icons and footer widgets.
Author: ThemeZee
Author URI: https://themezee.com/
Version: 1.1
Text Domain: occasio-pro
Domain Path: /languages/
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Occasio Pro
Copyright(C) 2022, ThemeZee.com - [email protected]
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main Occasio_Pro Class
*
* @package Occasio Pro
*/
class Occasio_Pro {
/**
* Call all Functions to setup the Plugin
*
* @uses Occasio_Pro::constants() Setup the constants needed
* @uses Occasio_Pro::includes() Include the required files
* @uses Occasio_Pro::setup_actions() Setup the hooks and actions
* @return void
*/
static function setup() {
// Setup Constants.
self::constants();
// Setup Translation.
add_action( 'plugins_loaded', array( __CLASS__, 'translation' ) );
// Include Files.
self::includes();
// Setup Action Hooks.
self::setup_actions();
}
/**
* Setup plugin constants
*
* @return void
*/
static function constants() {
// Define Plugin Name.
define( 'OCCASIO_PRO_NAME', 'Occasio Pro' );
// Define Version Number.
define( 'OCCASIO_PRO_VERSION', '1.1' );
// Define Plugin Name.
define( 'OCCASIO_PRO_PRODUCT_ID', 232393 );
// Define Update API URL.
define( 'OCCASIO_PRO_STORE_API_URL', 'https://themezee.com' );
// Plugin Folder Path.
define( 'OCCASIO_PRO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
// Plugin Folder URL.
define( 'OCCASIO_PRO_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Plugin Root File.
define( 'OCCASIO_PRO_PLUGIN_FILE', __FILE__ );
}
/**
* Load Translation File
*
* @return void
*/
static function translation() {
load_plugin_textdomain( 'occasio-pro', false, dirname( plugin_basename( OCCASIO_PRO_PLUGIN_FILE ) ) . '/languages/' );
}
/**
* Include required files
*
* @return void
*/
static function includes() {
// Include Admin Classes.
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/admin/class-admin-notices.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/admin/class-license-key.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/admin/class-plugin-updater.php';
// Include Customizer Classes.
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/customizer/class-customizer.php';
// Include Pro Features.
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-author-bio.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-block-colors.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-custom-fonts.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-footer-menu.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-footer-widgets.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-header-bar.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-header-search.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-scroll-to-top.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-social-icons.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-theme-colors.php';
require_once OCCASIO_PRO_PLUGIN_DIR . 'includes/modules/class-widget-areas.php';
}
/**
* Setup Action Hooks
*
* @see https://codex.wordpress.org/Function_Reference/add_action WordPress Codex
* @return void
*/
static function setup_actions() {
// Enqueue Occasio Pro Stylesheet.
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_styles' ), 11 );
// Add Custom CSS code to the Gutenberg editor.
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'enqueue_editor_styles' ), 11 );
// Add Settings link to Plugin actions.
add_filter( 'plugin_action_links_' . plugin_basename( OCCASIO_PRO_PLUGIN_FILE ), array( __CLASS__, 'plugin_action_links' ) );
// Add automatic plugin updater from ThemeZee Store API.
add_action( 'admin_init', array( __CLASS__, 'plugin_updater' ), 0 );
}
/**
* Enqueue Styles
*
* @return void
*/
static function enqueue_styles() {
// Return early if Occasio Theme is not active.
if ( ! current_theme_supports( 'occasio-pro' ) ) {
return;
}
// Enqueue RTL or default Plugin Stylesheet.
if ( is_rtl() ) {
wp_enqueue_style( 'occasio-pro', OCCASIO_PRO_PLUGIN_URL . 'assets/css/occasio-pro-rtl.css', array(), OCCASIO_PRO_VERSION );
} else {
wp_enqueue_style( 'occasio-pro', OCCASIO_PRO_PLUGIN_URL . 'assets/css/occasio-pro.css', array(), OCCASIO_PRO_VERSION );
}
// Enqueue Custom CSS.
wp_add_inline_style( 'occasio-pro', self::get_custom_css() );
}
/**
* Enqueue Editor Styles
*
* @return void
*/
static function enqueue_editor_styles() {
// Return early if Occasio Theme is not active.
if ( ! current_theme_supports( 'occasio-pro' ) ) {
return;
}
// Enqueue Custom CSS.
wp_add_inline_style( 'occasio-editor-styles', self::get_custom_css() );
}
/**
* Return custom CSS for color and font variables.
*
* @return void
*/
static function get_custom_css() {
// Get Custom CSS.
$custom_css = apply_filters( 'occasio_pro_custom_css_stylesheet', '' );
// Sanitize CSS Code.
$custom_css = wp_kses( $custom_css, array( '\'', '\"' ) );
$custom_css = str_replace( '>', '>', $custom_css );
$custom_css = preg_replace( '/\n/', '', $custom_css );
$custom_css = preg_replace( '/\t/', '', $custom_css );
return $custom_css;
}
/**
* Add Settings link to the plugin actions
*
* @param array $actions Plugin action links.
* @return array $actions Plugin action links
*/
static function plugin_action_links( $actions ) {
$settings_link = array(
'settings' => sprintf( '<a href="%s">%s</a>', wp_customize_url() . '?autofocus[panel]=occasio_options_panel', esc_html__( 'Theme Options', 'occasio-pro' ) ),
);
return array_merge( $settings_link, $actions );
}
/**
* Plugin Updater
*
* @return void
*/
static function plugin_updater() {
$theme_options = Occasio_Pro_Customizer::get_theme_options();
// Check if license key was entered.
if ( '' !== $theme_options['license_key'] ) :
// Setup the updater.
$occasio_pro_updater = new Occasio_Pro_Plugin_Updater( OCCASIO_PRO_STORE_API_URL, __FILE__, array(
'version' => OCCASIO_PRO_VERSION,
'license' => trim( $theme_options['license_key'] ),
'item_name' => OCCASIO_PRO_NAME,
'item_id' => OCCASIO_PRO_PRODUCT_ID,
'author' => 'ThemeZee',
) );
endif;
}
}
// Run Plugin.
Occasio_Pro::setup();