-
Notifications
You must be signed in to change notification settings - Fork 0
/
napoli-pro.php
272 lines (215 loc) · 7.36 KB
/
napoli-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
270
271
272
<?php
/*
Plugin Name: Napoli Pro
Plugin URI: http://themezee.com/addons/napoli-pro/
Description: Adds additional features like custom colors, google fonts, widget areas and footer copyright to the Napoli theme.
Author: ThemeZee
Author URI: https://themezee.com/
Version: 2.2.3
Text Domain: napoli-pro
Domain Path: /languages/
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Napoli Pro
Copyright(C) 2022, ThemeZee.com - [email protected]
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main Napoli_Pro Class
*
* @package Napoli Pro
*/
class Napoli_Pro {
/**
* Call all Functions to setup the Plugin
*
* @uses Napoli_Pro::constants() Setup the constants needed
* @uses Napoli_Pro::includes() Include the required files
* @uses Napoli_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( 'NAPOLI_PRO_NAME', 'Napoli Pro' );
// Define Version Number.
define( 'NAPOLI_PRO_VERSION', '2.2.3' );
// Define Plugin Name.
define( 'NAPOLI_PRO_PRODUCT_ID', 96583 );
// Define Update API URL.
define( 'NAPOLI_PRO_STORE_API_URL', 'https://themezee.com' );
// Plugin Folder Path.
define( 'NAPOLI_PRO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
// Plugin Folder URL.
define( 'NAPOLI_PRO_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Plugin Root File.
define( 'NAPOLI_PRO_PLUGIN_FILE', __FILE__ );
}
/**
* Load Translation File
*
* @return void
*/
static function translation() {
load_plugin_textdomain( 'napoli-pro', false, dirname( plugin_basename( NAPOLI_PRO_PLUGIN_FILE ) ) . '/languages/' );
}
/**
* Include required files
*
* @return void
*/
static function includes() {
// Include Admin Classes.
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/admin/class-plugin-updater.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/admin/class-settings.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/admin/class-settings-page.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/admin/class-admin-notices.php';
// Include Customizer Classes.
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/customizer/class-customizer.php';
// Include Pro Features.
require_once NAPOLI_PRO_PLUGIN_DIR . 'includes/modules/class-author-bio.php';
require_once NAPOLI_PRO_PLUGIN_DIR . 'includes/modules/class-block-colors.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/modules/class-custom-colors.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/modules/class-custom-fonts.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/modules/class-header-menu.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/modules/class-header-search.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/modules/class-footer-line.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/modules/class-footer-widgets.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/modules/class-scroll-to-top.php';
require_once NAPOLI_PRO_PLUGIN_DIR . 'includes/modules/class-widget-areas.php';
// Include Magazine Widgets.
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/widgets/widget-magazine-columns.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/widgets/widget-magazine-horizontal-box.php';
require_once NAPOLI_PRO_PLUGIN_DIR . '/includes/widgets/widget-magazine-vertical-box.php';
}
/**
* Setup Action Hooks
*
* @see https://codex.wordpress.org/Function_Reference/add_action WordPress Codex
* @return void
*/
static function setup_actions() {
// Enqueue Napoli 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( NAPOLI_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 Napoli Theme is not active.
if ( ! current_theme_supports( 'napoli-pro' ) ) {
return;
}
// Enqueue RTL or default Plugin Stylesheet.
if ( is_rtl() ) {
wp_enqueue_style( 'napoli-pro', NAPOLI_PRO_PLUGIN_URL . 'assets/css/napoli-pro-rtl.css', array(), NAPOLI_PRO_VERSION );
} else {
wp_enqueue_style( 'napoli-pro', NAPOLI_PRO_PLUGIN_URL . 'assets/css/napoli-pro.css', array(), NAPOLI_PRO_VERSION );
}
// Enqueue Custom CSS.
wp_add_inline_style( 'napoli-pro', self::get_custom_css() );
}
/**
* Enqueue Editor Styles
*
* @return void
*/
static function enqueue_editor_styles() {
// Return early if Napoli Theme is not active.
if ( ! current_theme_supports( 'napoli-pro' ) ) {
return;
}
// Enqueue Custom CSS.
wp_add_inline_style( 'napoli-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( 'napoli_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 Napoli Theme is not active.
if ( ! current_theme_supports( 'napoli-pro' ) ) {
return;
}
register_widget( 'Napoli_Pro_Magazine_Columns_Widget' );
register_widget( 'Napoli_Pro_Magazine_Horizontal_Box_Widget' );
register_widget( 'Napoli_Pro_Magazine_Vertical_Box_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=napoli-pro' ), __( 'Settings', 'napoli-pro' ) ) );
return array_merge( $settings_link, $actions );
}
/**
* Plugin Updater
*
* @return void
*/
static function plugin_updater() {
if ( ! is_admin() ) :
return;
endif;
$options = Napoli_Pro_Settings::instance();
if ( '' !== $options->get( 'license_key' ) ) :
$license_key = trim( $options->get( 'license_key' ) );
// Setup the updater.
$napoli_pro_updater = new Napoli_Pro_Plugin_Updater( NAPOLI_PRO_STORE_API_URL, __FILE__, array(
'version' => NAPOLI_PRO_VERSION,
'license' => $license_key,
'item_name' => NAPOLI_PRO_NAME,
'item_id' => NAPOLI_PRO_PRODUCT_ID,
'author' => 'ThemeZee',
) );
endif;
}
}
// Run Plugin.
Napoli_Pro::setup();