Repository navigation
Expand file tree
/
Copy pathtag-groups.php
More file actions
385 lines (346 loc) · 14.9 KB
/
Copy pathtag-groups.php
File metadata and controls
385 lines (346 loc) · 14.9 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<?php
/**
* Plugin Name: PublishPress Tag Groups Free
* Plugin URI: https://wordpress.org/plugins/tag-groups/
* Description: PublishPress Tag Groups allows you to organize your WordPress taxonomy terms and show them in clouds, tabs, accordions, tables, lists and much more.
* Author: PublishPress
* Author URI: https://publishpress.com
* Version: 3.0.0
* License: GPL-3.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: tag-groups
* Domain Path: /languages
* Requires at least: 5.5
* Requires PHP: 7.2.5
*
* @package PublishPress\TagGroups
* @author PublishPress
* @copyright Copyright (c) 2024, PublishPress
* @license GPL-3.0-or-later
*/
// keep the following line for automatic processing
// define( "CM_TGP_KERNL_UUID", '' );
defined('ABSPATH') || exit;
if (! defined('TAG_GROUPS_VERSION')) {
define('TAG_GROUPS_VERSION', '3.0.0');
}
$includeFileRelativePath = '/publishpress/instance-protection/include.php';
if (file_exists(__DIR__ . '/lib/vendor' . $includeFileRelativePath)) {
require_once __DIR__ . '/lib/vendor' . $includeFileRelativePath;
} elseif (file_exists(__DIR__ . '/vendor' . $includeFileRelativePath)) {
require_once __DIR__ . '/vendor' . $includeFileRelativePath;
}
if (class_exists('PublishPressInstanceProtection\Config')) {
$pluginCheckerConfig = new PublishPressInstanceProtection\Config();
$pluginCheckerConfig->pluginSlug = 'tag-groups';
$pluginCheckerConfig->pluginName = 'PublishPress Tag Groups';
$pluginCheckerConfig->pluginFolder = 'tag-groups';
$pluginChecker = new PublishPressInstanceProtection\InstanceChecker($pluginCheckerConfig);
}
$bundledTranslationsPath = '/publishpress/bundled-translations/core/include.php';
if (file_exists(__DIR__ . '/lib/vendor' . $bundledTranslationsPath)) {
require_once __DIR__ . '/lib/vendor' . $bundledTranslationsPath;
} elseif (file_exists(__DIR__ . '/vendor' . $bundledTranslationsPath)) {
require_once __DIR__ . '/vendor' . $bundledTranslationsPath;
}
add_action('plugins_loaded', function () {
if (class_exists('PublishPress\BundledTranslations\BundledTranslations')) {
$bundledTranslations = new PublishPress\BundledTranslations\BundledTranslations('tag-groups', __DIR__ . '/languages', __FILE__);
$bundledTranslations->init();
}
}, 5);
$wordpressVersionNoticesPath = '/publishpress/wordpress-version-notices/src/include.php';
if (file_exists(__DIR__ . '/lib/vendor' . $wordpressVersionNoticesPath)) {
require_once __DIR__ . '/lib/vendor' . $wordpressVersionNoticesPath;
} elseif (file_exists(__DIR__ . '/vendor' . $wordpressVersionNoticesPath)) {
require_once __DIR__ . '/vendor' . $wordpressVersionNoticesPath;
}
if (!function_exists('tag_groups_free_plugin_basenames')) {
/**
* Return the supported free-plugin entry paths.
*
* The WordPress.org folder remains the canonical installation path. The
* branded folder is accepted for compatibility with pre-release packages.
*
* @return string[]
*/
function tag_groups_free_plugin_basenames()
{
return [
'publishpress-tag-groups/tag-groups.php',
'tag-groups/tag-groups.php',
];
}
}
if (! function_exists('publishpress_tag_groups_get_active_pro_plugin')) {
/**
* Return the active Pro entry path, including legacy and pre-release paths.
*
* @return string
*/
function publishpress_tag_groups_get_active_pro_plugin()
{
$proPlugins = [
'tag-groups-pro/tag-groups-pro.php',
'tag-groups-pro/tag-groups.php',
'publishpress-tag-groups-pro/tag-groups-pro.php',
'publishpress-tag-groups-pro/publishpress-tag-groups-pro.php',
];
if (! function_exists('is_plugin_active')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
foreach ($proPlugins as $proPlugin) {
if (is_plugin_active($proPlugin)) {
return $proPlugin;
}
}
return '';
}
}
if (! function_exists('publishpress_tag_groups_deactivate_free_when_pro_is_active')) {
/**
* Prevent a standalone Free copy from remaining active alongside Pro.
*
* This also handles legacy Pro versions that predate the Pro-side
* deactivation routine.
*
* @param string $freePlugin Standalone Free plugin basename.
* @return void
*/
function publishpress_tag_groups_deactivate_free_when_pro_is_active($freePlugin = '')
{
if (! current_user_can('activate_plugins')) {
return;
}
if (! in_array($freePlugin, tag_groups_free_plugin_basenames(), true)) {
return;
}
$proPlugin = publishpress_tag_groups_get_active_pro_plugin();
if (empty($proPlugin)) {
return;
}
if (is_multisite() && is_plugin_active_for_network($freePlugin)) {
if (is_plugin_active_for_network($proPlugin) && current_user_can('manage_network_plugins')) {
deactivate_plugins($freePlugin, true, true);
update_site_option('publishpress_tag_groups_network_free_deactivated_for_pro', 1);
} else {
update_site_option('publishpress_tag_groups_network_free_plugin_detected', 1);
}
return;
}
if (is_plugin_active($freePlugin)) {
deactivate_plugins($freePlugin, true, false);
update_option('publishpress_tag_groups_free_deactivated_for_pro', 1);
}
}
}
if (! function_exists('publishpress_tag_groups_free_pro_activation_notice')) {
/**
* Explain an automatic Free deactivation on the current admin request.
*
* @return void
*/
function publishpress_tag_groups_free_pro_activation_notice()
{
if (! current_user_can('activate_plugins')) {
return;
}
if (get_option('publishpress_tag_groups_free_deactivated_for_pro')) {
delete_option('publishpress_tag_groups_free_deactivated_for_pro');
echo '<div class="notice notice-info is-dismissible"><p>'
. esc_html__('PublishPress Tag Groups Free was deactivated because PublishPress Tag Groups Pro is active.', 'tag-groups')
. '</p></div>';
}
}
}
if (! function_exists('publishpress_tag_groups_free_pro_network_notice')) {
/**
* Report network-level Free and Pro activation handling.
*
* @return void
*/
function publishpress_tag_groups_free_pro_network_notice()
{
if (! is_network_admin() || ! current_user_can('manage_network_plugins')) {
return;
}
if (get_site_option('publishpress_tag_groups_network_free_deactivated_for_pro')) {
delete_site_option('publishpress_tag_groups_network_free_deactivated_for_pro');
echo '<div class="notice notice-info is-dismissible"><p>'
. esc_html__('PublishPress Tag Groups Free was deactivated network-wide because PublishPress Tag Groups Pro is active network-wide.', 'tag-groups')
. '</p></div>';
}
if (get_site_option('publishpress_tag_groups_network_free_plugin_detected')) {
delete_site_option('publishpress_tag_groups_network_free_plugin_detected');
echo '<div class="notice notice-warning"><p>'
. esc_html__('PublishPress Tag Groups Free remains active network-wide. Deactivate it network-wide or activate PublishPress Tag Groups Pro network-wide.', 'tag-groups')
. '</p></div>';
}
}
}
$publishpressTagGroupsFreePlugin = plugin_basename(__FILE__);
if (in_array($publishpressTagGroupsFreePlugin, tag_groups_free_plugin_basenames(), true)) {
add_action(
'admin_init',
static function () use ($publishpressTagGroupsFreePlugin) {
publishpress_tag_groups_deactivate_free_when_pro_is_active($publishpressTagGroupsFreePlugin);
},
1
);
add_action('admin_notices', 'publishpress_tag_groups_free_pro_activation_notice');
add_action('network_admin_notices', 'publishpress_tag_groups_free_pro_network_notice');
}
if (!defined('TAG_GROUPS_PLUGIN_IS_FREE')) {
if (in_array(plugin_basename(__FILE__), tag_groups_free_plugin_basenames(), true)) {
define('TAG_GROUPS_PLUGIN_IS_FREE', true);
} else {
// Don't define the constant! If the premium plugin runs earlier, the free plugin still needs to define it.
}
}
if (!defined('TAG_GROUPS_PLUGIN_IS_KERNL')) {
if (defined('CM_TGP_KERNL_UUID') && CM_TGP_KERNL_UUID != '' || defined('CM_TGP_BETA_PLUGIN_UUID') && CM_TGP_BETA_PLUGIN_UUID != '') {
define('TAG_GROUPS_PLUGIN_IS_KERNL', true);
} else {
define('TAG_GROUPS_PLUGIN_IS_KERNL', false);
}
}
if (!defined('TAG_GROUPS_PLUGIN_BASENAME')) {
define('TAG_GROUPS_FILE', __FILE__);
/**
* The plugin's relative path (starting below the plugin directory), including the name of this file.
*/
define("TAG_GROUPS_PLUGIN_BASENAME", plugin_basename(__FILE__));
/**
* The required minimum version of WordPress.
*/
define("TAG_GROUPS_MINIMUM_VERSION_WP", "4.9");
/**
* Comma-separated list of default themes that come bundled with this plugin.
*/
define("TAG_GROUPS_BUILT_IN_THEMES", "delta,base,ui-gray,ui-lightness,ui-darkness,blitzer,aristo");
/**
* The theme that is selected by default. Must be among TAG_GROUPS_BUILT_IN_THEMES.
*/
define("TAG_GROUPS_STANDARD_THEME", "delta");
/**
* The default number of groups on one page on the edit group screen.
*/
define("TAG_GROUPS_ITEMS_PER_PAGE", 20);
/**
* This plugin's last piece of the path, i.e. basically the plugin's name
*/
define("TAG_GROUPS_PLUGIN_RELATIVE_PATH", basename(dirname(__FILE__)));
/**
* This plugin's absolute path on this server - starting from root.
*/
define("TAG_GROUPS_PLUGIN_ABSOLUTE_PATH", dirname(__FILE__));
if (!defined('TAG_GROUPS_LIB_VENDOR_PATH')) {
define('TAG_GROUPS_LIB_VENDOR_PATH', __DIR__ . '/lib/vendor');
}
}
if (defined('TAG_GROUPS_LOADED_BY_PRO') && TAG_GROUPS_LOADED_BY_PRO && defined('TAG_GROUPS_PRO_ABSPATH')) {
if (!defined('TAG_GROUPS_PREMIUM_PLUGIN_ABSOLUTE_PATH')) {
define('TAG_GROUPS_PREMIUM_PLUGIN_ABSOLUTE_PATH', TAG_GROUPS_PRO_ABSPATH . '/premium');
}
if (!defined('TAG_GROUPS_PREMIUM_PLUGIN_RELATIVE_PATH')) {
define('TAG_GROUPS_PREMIUM_PLUGIN_RELATIVE_PATH', 'premium');
}
if (!defined('TAG_GROUPS_PREMIUM_CACHE_LIFETIME')) {
define('TAG_GROUPS_PREMIUM_CACHE_LIFETIME', 600);
}
if (!defined('TAG_GROUPS_PREMIUM_MB_RELOAD_TAGS')) {
define('TAG_GROUPS_PREMIUM_MB_RELOAD_TAGS', 300000);
}
if (!defined('TAG_GROUPS_PREMIUM_PLUGIN_URL') && defined('TAG_GROUPS_PRO_URL')) {
define('TAG_GROUPS_PREMIUM_PLUGIN_URL', TAG_GROUPS_PRO_URL . '/premium');
}
}
$libAutoloadPath = TAG_GROUPS_LIB_VENDOR_PATH . '/autoload.php';
if (file_exists($libAutoloadPath)) {
require_once $libAutoloadPath;
}
$autoloadPath = TAG_GROUPS_PLUGIN_ABSOLUTE_PATH . '/vendor/autoload.php';
if (file_exists($autoloadPath)) {
require_once $autoloadPath;
}
/**
* Make scope of $tag_groups_loader global for wp-cli
*/
global $tag_groups_loader ;
require_once dirname(__FILE__) . '/include/class.loader.php';
$tag_groups_loader = new TagGroups_Loader(TAG_GROUPS_PLUGIN_ABSOLUTE_PATH);
$tag_groups_loader->require_classes();
if (!function_exists('tag_groups_init')) {
/**
* Do all initial stuff: register hooks, check dependencies
*
*
* @param void
* @return void
*/
function tag_groups_init()
{
global $tag_groups_loader ;
if (!in_array(plugin_basename(__FILE__), tag_groups_free_plugin_basenames(), true)) {
/**
* TGP-Codester or TGP-Freemius
*/
if (defined('TAG_GROUPS_PLUGIN_IS_FREE') && TAG_GROUPS_PLUGIN_IS_FREE) {
/**
* The free version is also active.
*/
/**
* Make sure we don't delete data by removing the base plugin by returning data removal to opt-in:
* Set the option to OFF and keep, because removing the plugin might only happen later.
*/
update_option('tag_group_reset_when_uninstall', 0);
require_once ABSPATH . 'wp-admin/includes/plugin.php';
deactivate_plugins(tag_groups_free_plugin_basenames(), true);
// add the hook directly
add_action('admin_notices', function () {
echo '<div class="notice notice-info is-dismissible"><p>' . esc_html__('The free PublishPress Tag Groups plugin cannot be active together with PublishPress Tag Groups Pro.', 'tag-groups') . ' <a href="https://publishpress.com/tag-groups/" target="_blank" style="text-decoration: none;" title="' . esc_attr__('more information', 'tag-groups') . '"><span class="dashicons dashicons-editor-help"></span></a></p></div><div clear="all" /></div>' ;
});
/**
* Remove the misleading "Plugin activated" messaage
*/
unset($_GET['activate']);
}
}
// URL must be defined after WP has finished loading its settings
if (!defined('TAG_GROUPS_PLUGIN_URL')) {
define("TAG_GROUPS_PLUGIN_URL", plugins_url('', __FILE__));
// start all initializations, registration of hooks, housekeeping, menus, ...
$tag_groups_loader->set_version();
$tag_groups_loader->check_preconditions();
$tag_groups_loader->provide_globals();
$tag_groups_loader->add_hooks();
$tag_groups_loader->register_shortcodes_and_blocks();
$tag_groups_loader->register_REST_API();
$tag_groups_loader->register_CRON();
if (is_admin()) {
// Only load free-only admin features if not running inside Pro
if (!defined('TAG_GROUPS_SKIP_VERSION_NOTICES') || !TAG_GROUPS_SKIP_VERSION_NOTICES) {
require_once(TAG_GROUPS_PLUGIN_ABSOLUTE_PATH . '/includes-core/TagGroupsCoreAdmin.php');
// Keep the former namespace available for third-party integrations during the rebrand.
if (!class_exists('TaxoPress\\TagGroups\\TagGroupsCoreAdmin', false)) {
class_alias(
\PublishPress\TagGroups\TagGroupsCoreAdmin::class,
'TaxoPress\\TagGroups\\TagGroupsCoreAdmin'
);
}
new \PublishPress\TagGroups\TagGroupsCoreAdmin();
require_once(TAG_GROUPS_PLUGIN_ABSOLUTE_PATH . '/includes-core/TagGroupsReviews.php');
}
}
}
}
add_action('plugins_loaded', 'tag_groups_init');
register_activation_hook(__FILE__, array( 'TagGroups_Activation_Deactivation', 'on_activation' ));
}
/**
* aliases for common functions, for backwards compatibility
*/
require_once 'aliases.php';
/**
* guess what - the end
*/