-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththemezee-breadcrumbs.php
More file actions
254 lines (203 loc) · 6.75 KB
/
themezee-breadcrumbs.php
File metadata and controls
254 lines (203 loc) · 6.75 KB
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
<?php
/*
Plugin Name: ThemeZee Breadcrumbs
Plugin URI: https://themezee.com/plugins/breadcrumbs/
Description: This plugin allows you to add a nice and elegant breadcrumb navigation. Breadcrumbs make it easy for the user to navigate up and down the hierarchy of your website and are good for SEO.
Author: ThemeZee
Author URI: https://themezee.com/
Version: 1.1.2
Text Domain: themezee-breadcrumbs
Domain Path: /languages/
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
ThemeZee Breadcrumbs
Copyright(C) 2019, ThemeZee.com - support@themezee.com
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main ThemeZee_Breadcrumbs Class
*
* @package ThemeZee Breadcrumbs
*/
class ThemeZee_Breadcrumbs {
/**
* Call all Functions to setup the Plugin
*
* @uses ThemeZee_Breadcrumbs::constants() Setup the constants needed
* @uses ThemeZee_Breadcrumbs::includes() Include the required files
* @uses ThemeZee_Breadcrumbs::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( 'TZBC_NAME', 'ThemeZee Breadcrumbs' );
// Define Version Number.
define( 'TZBC_VERSION', '1.1.2' );
// Define Plugin Name.
define( 'TZBC_PRODUCT_ID', 49729 );
// Define Update API URL.
define( 'TZBC_STORE_API_URL', 'https://themezee.com' );
// Define Plugin Name.
define( 'TZBC_LICENSE', 'd2830f6767515a780ebd6530ed48d4c2' );
// Plugin Folder Path.
define( 'TZBC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
// Plugin Folder URL.
define( 'TZBC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Plugin Root File.
define( 'TZBC_PLUGIN_FILE', __FILE__ );
}
/**
* Load Translation File
*
* @return void
*/
static function translation() {
load_plugin_textdomain( 'themezee-breadcrumbs', false, dirname( plugin_basename( TZBC_PLUGIN_FILE ) ) . '/languages/' );
}
/**
* Include required files
*
* @return void
*/
static function includes() {
// Include Admin Classes.
require_once TZBC_PLUGIN_DIR . '/includes/admin/class-themezee-plugins-page.php';
require_once TZBC_PLUGIN_DIR . '/includes/admin/class-tzbc-plugin-updater.php';
// Include Settings Classes.
require_once TZBC_PLUGIN_DIR . '/includes/settings/class-tzbc-settings.php';
require_once TZBC_PLUGIN_DIR . '/includes/settings/class-tzbc-settings-page.php';
// Include Breadcrumb Files.
require_once TZBC_PLUGIN_DIR . '/includes/class-tzbc-breadcrumb-trail.php';
require_once TZBC_PLUGIN_DIR . '/includes/breadcrumbs-setup.php';
}
/**
* Setup Action Hooks
*
* @see https://codex.wordpress.org/Function_Reference/add_action WordPress Codex
* @return void
*/
static function setup_actions() {
// Enqueue Frontend Widget Styles.
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_styles' ) );
// Add Settings link to Plugin actions.
add_filter( 'plugin_action_links_' . plugin_basename( TZBC_PLUGIN_FILE ), array( __CLASS__, 'plugin_action_links' ) );
// Add Breadcrumbs Plugin Box to Plugin Overview Page.
add_action( 'themezee_plugins_overview_page', array( __CLASS__, 'plugin_overview_page' ) );
// Add License Key admin notice.
add_action( 'admin_notices', array( __CLASS__, 'license_key_admin_notice' ) );
// 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 theme handles styling.
if ( current_theme_supports( 'themezee-breadcrumbs' ) ) :
return;
endif;
// Enqueue Plugin Stylesheet.
wp_enqueue_style( 'themezee-breadcrumbs', TZBC_PLUGIN_URL . 'assets/css/themezee-breadcrumbs.css', array(), TZBC_VERSION );
}
/**
* Add Settings link to the plugin actions
*
* @return array $actions Plugin action links
*/
static function plugin_action_links( $actions ) {
$settings_link = array( 'settings' => sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=themezee-plugins&tab=breadcrumbs' ), __( 'Settings', 'themezee-breadcrumbs' ) ) );
return array_merge( $settings_link, $actions );
}
/**
* Add widget bundle box to plugin overview admin page
*
* @return void
*/
static function plugin_overview_page() {
$plugin_data = get_plugin_data( __FILE__ );
?>
<dl>
<dt>
<h4><?php echo esc_html( $plugin_data['Name'] ); ?></h4>
<span><?php printf( esc_html__( 'Version %s', 'themezee-breadcrumbs' ), esc_html( $plugin_data['Version'] ) ); ?></span>
</dt>
<dd>
<p><?php echo wp_kses_post( $plugin_data['Description'] ); ?><br/></p>
<a href="<?php echo admin_url( 'options-general.php?page=themezee-plugins&tab=breadcrumbs' ); ?>" class="button button-primary"><?php esc_html_e( 'Plugin Settings', 'themezee-breadcrumbs' ); ?></a>
<a href="<?php echo esc_url( 'https://themezee.com/docs/breadcrumbs-documentation/?utm_source=plugin-overview&utm_medium=button&utm_campaign=breadcrumbs&utm_content=documentation' ); ?>" class="button button-secondary" target="_blank"><?php esc_html_e( 'View Documentation', 'themezee-breadcrumbs' ); ?></a>
</dd>
</dl>
<?php
}
/**
* Add license key admin notice
*
* @return void
*/
static function license_key_admin_notice() {
global $pagenow;
// Display only on Plugins and Updates page.
if ( ! ( 'plugins.php' == $pagenow or 'update-core.php' == $pagenow ) ) {
return;
}
// Get Settings.
$options = TZBC_Settings::instance();
if ( 'valid' !== $options->get( 'license_status' ) ) :
?>
<div class="updated">
<p>
<?php
printf( __( 'Please activate your license for the %1$s plugin in order to receive updates and support. <a href="%2$s">Activate License</a>', 'themezee-breadcrumbs' ),
TZBC_NAME,
admin_url( 'options-general.php?page=themezee-plugins&tab=breadcrumbs' )
);
?>
</p>
</div>
<?php
endif;
}
/**
* Plugin Updater
*
* @return void
*/
static function plugin_updater() {
if ( ! is_admin() ) :
return;
endif;
$options = TZBC_Settings::instance();
if ( 'valid' === $options->get( 'license_status' ) ) :
// Setup the updater.
$tzbc_updater = new TZBC_Plugin_Updater( TZBC_STORE_API_URL, __FILE__, array(
'version' => TZBC_VERSION,
'license' => TZBC_LICENSE,
'item_name' => TZBC_NAME,
'item_id' => TZBC_PRODUCT_ID,
'author' => 'ThemeZee',
) );
endif;
}
}
// Run Plugin.
ThemeZee_Breadcrumbs::setup();