-
Notifications
You must be signed in to change notification settings - Fork 2
/
poseidon-pro.php
269 lines (213 loc) · 7.52 KB
/
poseidon-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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?php
/*
Plugin Name: Poseidon Pro
Plugin URI: http://themezee.com/addons/poseidon-pro/
Description: Adds additional features like footer widgets, custom colors, fonts and logo upload to the Poseidon theme.
Author: ThemeZee
Author URI: https://themezee.com/
Version: 2.2.5
Text Domain: poseidon-pro
Domain Path: /languages/
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Poseidon Pro
Copyright(C) 2022, ThemeZee.com - [email protected]
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main Poseidon_Pro Class
*
* @package Poseidon Pro
*/
class Poseidon_Pro {
/**
* Call all Functions to setup the Plugin
*
* @uses Poseidon_Pro::constants() Setup the constants needed
* @uses Poseidon_Pro::includes() Include the required files
* @uses Poseidon_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( 'POSEIDON_PRO_NAME', 'Poseidon Pro' );
// Define Version Number.
define( 'POSEIDON_PRO_VERSION', '2.2.5' );
// Define Plugin Name.
define( 'POSEIDON_PRO_PRODUCT_ID', 53694 );
// Define Update API URL.
define( 'POSEIDON_PRO_STORE_API_URL', 'https://themezee.com' );
// Plugin Folder Path.
define( 'POSEIDON_PRO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
// Plugin Folder URL.
define( 'POSEIDON_PRO_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Plugin Root File.
define( 'POSEIDON_PRO_PLUGIN_FILE', __FILE__ );
}
/**
* Load Translation File
*
* @return void
*/
static function translation() {
load_plugin_textdomain( 'poseidon-pro', false, dirname( plugin_basename( POSEIDON_PRO_PLUGIN_FILE ) ) . '/languages/' );
}
/**
* Include required files
*
* @return void
*/
static function includes() {
// Include Admin Classes.
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/admin/class-plugin-updater.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/admin/class-settings.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/admin/class-settings-page.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/admin/class-admin-notices.php';
// Include Customizer Classes.
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/customizer/class-customizer.php';
// Include Pro Features.
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-author-bio.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-block-colors.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-custom-colors.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-custom-fonts.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-footer-line.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-footer-widgets.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-header-bar.php';
require_once POSEIDON_PRO_PLUGIN_DIR . '/includes/modules/class-header-search.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-header-spacing.php';
require_once POSEIDON_PRO_PLUGIN_DIR . '/includes/modules/class-scroll-to-top.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/modules/class-widget-areas.php';
// Include Magazine Widgets.
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/widgets/widget-magazine-posts-list.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/widgets/widget-magazine-posts-sidebar.php';
require_once POSEIDON_PRO_PLUGIN_DIR . 'includes/widgets/widget-magazine-posts-single.php';
}
/**
* Setup Action Hooks
*
* @see https://codex.wordpress.org/Function_Reference/add_action WordPress Codex
* @return void
*/
static function setup_actions() {
// Enqueue Poseidon 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 );
// Register additional Magazine Widgets.
add_action( 'widgets_init', array( __CLASS__, 'register_widgets' ) );
// Add Settings link to Plugin actions.
add_filter( 'plugin_action_links_' . plugin_basename( POSEIDON_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 Poseidon Theme is not active.
if ( ! current_theme_supports( 'poseidon-pro' ) ) {
return;
}
// Enqueue RTL or default Plugin Stylesheet.
if ( is_rtl() ) {
wp_enqueue_style( 'poseidon-pro', POSEIDON_PRO_PLUGIN_URL . 'assets/css/poseidon-pro-rtl.css', array(), POSEIDON_PRO_VERSION );
} else {
wp_enqueue_style( 'poseidon-pro', POSEIDON_PRO_PLUGIN_URL . 'assets/css/poseidon-pro.css', array(), POSEIDON_PRO_VERSION );
}
// Enqueue Custom CSS.
wp_add_inline_style( 'poseidon-pro', self::get_custom_css() );
}
/**
* Enqueue Editor Styles
*
* @return void
*/
static function enqueue_editor_styles() {
// Return early if Poseidon Theme is not active.
if ( ! current_theme_supports( 'poseidon-pro' ) ) {
return;
}
// Enqueue Custom CSS.
wp_add_inline_style( 'poseidon-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( 'poseidon_pro_custom_css_stylesheet', '' );
// Sanitize Custom CSS.
$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;
}
/**
* Register Magazine Widgets
*
* @return void
*/
static function register_widgets() {
// Return early if Poseidon Theme is not active.
if ( ! current_theme_supports( 'poseidon-pro' ) ) {
return;
}
register_widget( 'Poseidon_Pro_Magazine_Posts_List_Widget' );
register_widget( 'Poseidon_Pro_Magazine_Posts_Sidebar_Widget' );
register_widget( 'Poseidon_Pro_Magazine_Posts_Single_Widget' );
}
/**
* 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>', admin_url( 'themes.php?page=poseidon-pro' ), __( 'Settings', 'poseidon-pro' ) ) );
return array_merge( $settings_link, $actions );
}
/**
* Plugin Updater
*
* @return void
*/
static function plugin_updater() {
$options = Poseidon_Pro_Settings::instance();
if ( '' !== $options->get( 'license_key' ) ) :
$license_key = trim( $options->get( 'license_key' ) );
// Setup the updater.
$poseidon_pro_updater = new Poseidon_Pro_Plugin_Updater( POSEIDON_PRO_STORE_API_URL, __FILE__, array(
'version' => POSEIDON_PRO_VERSION,
'license' => $license_key,
'item_name' => POSEIDON_PRO_NAME,
'item_id' => POSEIDON_PRO_PRODUCT_ID,
'author' => 'ThemeZee',
) );
endif;
}
}
// Run Plugin.
Poseidon_Pro::setup();