Version Description
(4th July 2022) =
- Fix: Redirected URL now keeps the query strings from the original URL
- Fix: Child category URLs now redirecting correctly after altering the category setting
- Fix: Breadcrumbs URL now using the home URL instead of site URL
Download this release
Release Info
Developer | premmerce |
Plugin | Premmerce Permalink Manager for WooCommerce |
Version | 2.3.6 |
Comparing to | |
See all releases |
Code changes from version 2.3.5 to 2.3.6
- premmerce-url-manager.php +3 -3
- readme.txt +8 -2
- src/Addons/AddonInterface.php +10 -10
- src/Addons/AddonManager.php +26 -24
- src/Addons/BreadcrumbsAddon.php +155 -152
- src/Addons/YoastBreadcrumbsAddon.php +43 -39
- src/Admin/Admin.php +355 -345
- src/Admin/AffiliateTab.php +36 -32
- src/Admin/BundleAndSave.php +152 -145
- src/Admin/Settings.php +207 -198
- src/Admin/Tabs/Base/TabInterface.php +26 -27
- src/Frontend/Frontend.php +12 -8
- src/PermalinkListener.php +8 -8
- src/Updater.php +71 -70
- src/UrlManagerPlugin.php +164 -161
- vendor/autoload.php +6 -1
- vendor/composer/ClassLoader.php +1 -1
- vendor/composer/InstalledVersions.php +2 -0
- vendor/composer/autoload_classmap.php +1 -1
- vendor/composer/autoload_namespaces.php +1 -1
- vendor/composer/autoload_psr4.php +1 -1
- vendor/composer/autoload_real.php +7 -26
- vendor/composer/autoload_static.php +4 -4
- vendor/composer/installed.php +6 -6
- woo-permalink-manager.php +32 -0
premmerce-url-manager.php
CHANGED
@@ -11,7 +11,7 @@ use Premmerce\UrlManager\UrlManagerPlugin;
|
|
11 |
* Plugin Name: Premmerce Permalink Manager for WooCommerce
|
12 |
* Plugin URI: https://premmerce.com/woocommerce-permalink-manager-remove-shop-product-product-category-url/
|
13 |
* Description: Premmerce Permalink Manager for WooCommerce allows you to change WooCommerce permalink and remove product and product_category slugs from the URL.
|
14 |
-
* Version: 2.3.
|
15 |
*
|
16 |
* Author: premmerce
|
17 |
* Author URI: https://premmerce.com/
|
@@ -20,9 +20,9 @@ use Premmerce\UrlManager\UrlManagerPlugin;
|
|
20 |
* Text Domain: premmerce-url-manager
|
21 |
* Domain Path: /languages
|
22 |
*
|
23 |
-
* Tested up to:
|
24 |
* WC requires at least: 3.6.0
|
25 |
-
* WC tested up to: 6.
|
26 |
*/
|
27 |
|
28 |
// If this file is called directly, abort.
|
11 |
* Plugin Name: Premmerce Permalink Manager for WooCommerce
|
12 |
* Plugin URI: https://premmerce.com/woocommerce-permalink-manager-remove-shop-product-product-category-url/
|
13 |
* Description: Premmerce Permalink Manager for WooCommerce allows you to change WooCommerce permalink and remove product and product_category slugs from the URL.
|
14 |
+
* Version: 2.3.6
|
15 |
*
|
16 |
* Author: premmerce
|
17 |
* Author URI: https://premmerce.com/
|
20 |
* Text Domain: premmerce-url-manager
|
21 |
* Domain Path: /languages
|
22 |
*
|
23 |
+
* Tested up to: 6.0
|
24 |
* WC requires at least: 3.6.0
|
25 |
+
* WC tested up to: 6.5.1
|
26 |
*/
|
27 |
|
28 |
// If this file is called directly, abort.
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
|
2 |
=== Premmerce Permalink Manager for WooCommerce ===
|
3 |
|
4 |
-
Contributors: premmerce
|
5 |
Tags: woocommerce url, remove product, remove product_category, woocommerce permalink, woocommerce, woocommerce seo
|
6 |
Requires at least: 4.8
|
7 |
Tested up to: 6.0
|
8 |
-
Stable tag: 2.3.
|
9 |
Requires PHP: 5.6
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -85,6 +85,12 @@ You can also install this plugin manually:
|
|
85 |
|
86 |
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
= 2.3.5 =
|
89 |
|
90 |
Release Date: Mar 3, 2022
|
1 |
|
2 |
=== Premmerce Permalink Manager for WooCommerce ===
|
3 |
|
4 |
+
Contributors: premmerce, freemius
|
5 |
Tags: woocommerce url, remove product, remove product_category, woocommerce permalink, woocommerce, woocommerce seo
|
6 |
Requires at least: 4.8
|
7 |
Tested up to: 6.0
|
8 |
+
Stable tag: 2.3.6
|
9 |
Requires PHP: 5.6
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
85 |
|
86 |
|
87 |
|
88 |
+
= 2.3.6 (4th July 2022) =
|
89 |
+
|
90 |
+
* Fix: Redirected URL now keeps the query strings from the original URL
|
91 |
+
* Fix: Child category URLs now redirecting correctly after altering the category setting
|
92 |
+
* Fix: Breadcrumbs URL now using the home URL instead of site URL
|
93 |
+
|
94 |
= 2.3.5 =
|
95 |
|
96 |
Release Date: Mar 3, 2022
|
src/Addons/AddonInterface.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php namespace Premmerce\UrlManager\Addons;
|
2 |
|
3 |
-
interface AddonInterface
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Innit addon
|
12 |
-
*/
|
13 |
-
public function init();
|
14 |
}
|
1 |
<?php namespace Premmerce\UrlManager\Addons;
|
2 |
|
3 |
+
interface AddonInterface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Check if addon is active
|
7 |
+
*/
|
8 |
+
public function isActive();
|
9 |
|
10 |
+
/**
|
11 |
+
* Innit addon
|
12 |
+
*/
|
13 |
+
public function init();
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
src/Addons/AddonManager.php
CHANGED
@@ -1,28 +1,30 @@
|
|
1 |
<?php namespace Premmerce\UrlManager\Addons;
|
2 |
|
3 |
-
class AddonManager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Init Addons
|
19 |
-
*/
|
20 |
-
public function initAddons() {
|
21 |
-
foreach ( $this->getAddons() as $addon ) {
|
22 |
-
$addon = new $addon();
|
23 |
-
if ( $addon->isActive() ) {
|
24 |
-
$addon->init();
|
25 |
-
}
|
26 |
-
}
|
27 |
-
}
|
28 |
}
|
1 |
<?php namespace Premmerce\UrlManager\Addons;
|
2 |
|
3 |
+
class AddonManager
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Get Addons
|
7 |
+
*
|
8 |
+
* @return string[]
|
9 |
+
*/
|
10 |
+
public function getAddons()
|
11 |
+
{
|
12 |
+
return array(
|
13 |
+
BreadcrumbsAddon::class,
|
14 |
+
YoastBreadcrumbsAddon::class
|
15 |
+
);
|
16 |
+
}
|
17 |
|
18 |
+
/**
|
19 |
+
* Init Addons
|
20 |
+
*/
|
21 |
+
public function initAddons()
|
22 |
+
{
|
23 |
+
foreach ($this->getAddons() as $addon) {
|
24 |
+
$addon = new $addon();
|
25 |
+
if ($addon->isActive()) {
|
26 |
+
$addon->init();
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
src/Addons/BreadcrumbsAddon.php
CHANGED
@@ -2,156 +2,159 @@
|
|
2 |
|
3 |
use Premmerce\UrlManager\Admin\Settings;
|
4 |
|
5 |
-
class BreadcrumbsAddon implements AddonInterface
|
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 |
}
|
2 |
|
3 |
use Premmerce\UrlManager\Admin\Settings;
|
4 |
|
5 |
+
class BreadcrumbsAddon implements AddonInterface
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Breadcrumbs
|
9 |
+
*
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
protected $breadcrumbs = array();
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Options
|
16 |
+
*
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
protected $options = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructor
|
23 |
+
*/
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
$options = get_option(Settings::OPTIONS);
|
27 |
+
$this->options = $options;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Is active
|
32 |
+
*
|
33 |
+
* @return boolean
|
34 |
+
*/
|
35 |
+
public function isActive()
|
36 |
+
{
|
37 |
+
include_once ABSPATH . 'wp-admin/includes/plugin.php' ;
|
38 |
+
if (! empty($this->options['breadcrumbs']) && is_plugin_active('woocommerce/woocommerce.php')) {
|
39 |
+
return true;
|
40 |
+
}
|
41 |
+
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Init reformat breadcrumbs
|
47 |
+
*/
|
48 |
+
public function init()
|
49 |
+
{
|
50 |
+
add_filter('woocommerce_get_breadcrumb', array( $this, 'createBreadcrumbs' ), 999);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Init reformat breadcrumbs
|
55 |
+
*
|
56 |
+
* @param array $crumbs
|
57 |
+
*
|
58 |
+
* @return array|void
|
59 |
+
*/
|
60 |
+
public function createBreadcrumbs($crumbs)
|
61 |
+
{
|
62 |
+
if (! is_product() && ! is_product_category()) {
|
63 |
+
return $crumbs;
|
64 |
+
}
|
65 |
+
|
66 |
+
$this->addCrumb(apply_filters('premmerce_permalink_home_breadcrumb_default', __('Home', 'premmerce-url-manager')), get_home_url());
|
67 |
+
|
68 |
+
if (empty($this->options['br_remove_shop'])) {
|
69 |
+
$this->addCrumb(apply_filters('premmerce_permalink_shop_breadcrumb_default', __('Shop', 'premmerce-url-manager')), get_permalink(wc_get_page_id('shop')));
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
if (is_product()) {
|
74 |
+
if (! empty($this->options['product'])) {
|
75 |
+
global $post;
|
76 |
+
|
77 |
+
$terms = wc_get_product_terms(
|
78 |
+
$post->ID,
|
79 |
+
'product_cat',
|
80 |
+
array(
|
81 |
+
'orderby' => 'parent',
|
82 |
+
'order' => 'DESC',
|
83 |
+
)
|
84 |
+
);
|
85 |
+
|
86 |
+
if ($terms) {
|
87 |
+
$mainTerm = $terms[0];
|
88 |
+
if ('category_slug' === $this->options['product']) {
|
89 |
+
$this->addCrumb($mainTerm->name, get_term_link($mainTerm));
|
90 |
+
} elseif ('hierarchical' === $this->options['product']) {
|
91 |
+
$this->addCrumbAncestors($mainTerm->term_id, 'product_cat');
|
92 |
+
$this->addCrumb($mainTerm->name, get_term_link($mainTerm));
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->addCrumb(get_the_title($post), get_permalink($post));
|
97 |
+
}
|
98 |
+
} elseif (is_product_category()) {
|
99 |
+
if (! empty($this->options['category'])) {
|
100 |
+
$currentTerm = $GLOBALS['wp_query']->get_queried_object();
|
101 |
+
|
102 |
+
if ('hierarchical' === $this->options['category']) {
|
103 |
+
$this->addCrumbAncestors($currentTerm->term_id, 'product_cat');
|
104 |
+
}
|
105 |
+
|
106 |
+
$this->addCrumb($currentTerm->name, get_term_link($currentTerm, 'product_cat'));
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
if (! empty($this->breadcrumbs)) {
|
111 |
+
return $this->getBreadcrumbs();
|
112 |
+
}
|
113 |
+
|
114 |
+
return $crumbs;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Get breadcrumbs
|
119 |
+
*
|
120 |
+
* @return array
|
121 |
+
*/
|
122 |
+
protected function getBreadcrumbs()
|
123 |
+
{
|
124 |
+
return $this->breadcrumbs;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Add crumbs for a term
|
129 |
+
*
|
130 |
+
* @param int $termId Term ID
|
131 |
+
* @param string $taxonomy Taxonomy
|
132 |
+
*/
|
133 |
+
protected function addCrumbAncestors($termId, $taxonomy)
|
134 |
+
{
|
135 |
+
$ancestors = get_ancestors($termId, $taxonomy);
|
136 |
+
$ancestors = array_reverse($ancestors);
|
137 |
+
|
138 |
+
foreach ($ancestors as $ancestor) {
|
139 |
+
$ancestor = get_term($ancestor, $taxonomy);
|
140 |
+
|
141 |
+
if (! is_wp_error($ancestor) && $ancestor) {
|
142 |
+
$this->addCrumb($ancestor->name, get_term_link($ancestor));
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Add a crumb
|
149 |
+
*
|
150 |
+
* @param string $name Name
|
151 |
+
* @param string $link Link
|
152 |
+
*/
|
153 |
+
protected function addCrumb($name, $link = '')
|
154 |
+
{
|
155 |
+
$this->breadcrumbs[] = array(
|
156 |
+
wp_strip_all_tags($name),
|
157 |
+
$link,
|
158 |
+
);
|
159 |
+
}
|
160 |
}
|
src/Addons/YoastBreadcrumbsAddon.php
CHANGED
@@ -1,46 +1,50 @@
|
|
1 |
<?php namespace Premmerce\UrlManager\Addons;
|
2 |
|
3 |
-
class YoastBreadcrumbsAddon extends BreadcrumbsAddon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
*
|
8 |
-
* @return boolean
|
9 |
-
*/
|
10 |
-
public function isActive() {
|
11 |
-
include_once ABSPATH . 'wp-admin/includes/plugin.php' ;
|
12 |
-
if ( ! empty( $this->options['breadcrumbs'] ) && is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) {
|
13 |
-
return true;
|
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 |
-
* @return array
|
39 |
-
*/
|
40 |
-
protected function reformatBreadcrumbs( $arr ) {
|
41 |
-
return [
|
42 |
-
'text' => $arr[0],
|
43 |
-
'url' => $arr[1],
|
44 |
-
];
|
45 |
-
}
|
46 |
}
|
1 |
<?php namespace Premmerce\UrlManager\Addons;
|
2 |
|
3 |
+
class YoastBreadcrumbsAddon extends BreadcrumbsAddon
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Is active
|
7 |
+
*
|
8 |
+
* @return boolean
|
9 |
+
*/
|
10 |
+
public function isActive()
|
11 |
+
{
|
12 |
+
include_once ABSPATH . 'wp-admin/includes/plugin.php' ;
|
13 |
+
if (! empty($this->options['breadcrumbs']) && is_plugin_active('wordpress-seo/wp-seo.php')) {
|
14 |
+
return true;
|
15 |
+
}
|
16 |
|
17 |
+
return false;
|
18 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
/**
|
21 |
+
* Init reformat breadcrumbs
|
22 |
+
*/
|
23 |
+
public function init()
|
24 |
+
{
|
25 |
+
add_filter('wpseo_breadcrumb_links', array( $this, 'createBreadcrumbs' ), 999);
|
26 |
+
}
|
27 |
|
28 |
+
/**
|
29 |
+
* Get breadcrumbs
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function getBreadcrumbs()
|
34 |
+
{
|
35 |
+
return array_map(array( $this, 'reformatBreadcrumbs' ), $this->breadcrumbs);
|
36 |
+
}
|
37 |
|
38 |
+
/**
|
39 |
+
* Reformat breadcrumbs
|
40 |
+
*
|
41 |
+
* @return array
|
42 |
+
*/
|
43 |
+
protected function reformatBreadcrumbs($arr)
|
44 |
+
{
|
45 |
+
return array(
|
46 |
+
'text' => $arr[0],
|
47 |
+
'url' => $arr[1],
|
48 |
+
);
|
49 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
src/Admin/Admin.php
CHANGED
@@ -1,356 +1,366 @@
|
|
1 |
<?php namespace Premmerce\UrlManager\Admin;
|
2 |
|
3 |
-
use Premmerce\UrlManager\Admin\Settings;
|
4 |
use Premmerce\UrlManager\UrlManagerPlugin;
|
5 |
-
use Premmerce\UrlManager\Admin\AffiliateTab;
|
6 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
7 |
-
use Premmerce\UrlManager\Admin\BundleAndSave;
|
8 |
-
use Premmerce\UrlManager\Admin\FieldsTypes\InputOptionTypeRadio;
|
9 |
-
use Premmerce\UrlManager\Admin\FieldsTypes\InputOptionTypeCheckbox;
|
10 |
-
use Premmerce\UrlManager\Admin\FieldsTypes\InputOptionTypeUrlSuffix;
|
11 |
|
12 |
/**
|
13 |
* Class Admin
|
14 |
*
|
15 |
* @package Premmerce\UrlManager
|
16 |
*/
|
17 |
-
class Admin
|
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 |
}
|
1 |
<?php namespace Premmerce\UrlManager\Admin;
|
2 |
|
|
|
3 |
use Premmerce\UrlManager\UrlManagerPlugin;
|
|
|
4 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
|
|
|
|
|
|
|
|
5 |
|
6 |
/**
|
7 |
* Class Admin
|
8 |
*
|
9 |
* @package Premmerce\UrlManager
|
10 |
*/
|
11 |
+
class Admin
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Settings Page
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
private $settingsPage;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Settings Array
|
22 |
+
*
|
23 |
+
* @var arrat
|
24 |
+
*/
|
25 |
+
private $settingsArray;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* All Settings Field Names
|
29 |
+
*
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
private $allFieldsName;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Settings Page
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
private $parrentPageSlug;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* FileManager
|
43 |
+
*
|
44 |
+
* @var FileManager
|
45 |
+
*/
|
46 |
+
private $fileManager;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Settings
|
50 |
+
*
|
51 |
+
* @var Settings
|
52 |
+
*/
|
53 |
+
private $settings;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Bundles and Save
|
57 |
+
*
|
58 |
+
* @var bundlesAndSave
|
59 |
+
*/
|
60 |
+
private $bundlesAndSave;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Affiliate Tab
|
64 |
+
*
|
65 |
+
* @var affiliateTab
|
66 |
+
*/
|
67 |
+
private $affiliate;
|
68 |
+
|
69 |
+
const META_IGNORE_BANNER = 'premmerce_url_manager_ignore_banner';
|
70 |
+
|
71 |
+
const WOO_TAB_NAME = 'woo_tab_premmerce_permalink';
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Admin constructor.
|
75 |
+
*
|
76 |
+
* @param FileManager $fileManager
|
77 |
+
*/
|
78 |
+
public function __construct(FileManager $fileManager)
|
79 |
+
{
|
80 |
+
$this->fileManager = $fileManager;
|
81 |
+
$this->settings = new Settings($fileManager);
|
82 |
+
$this->settingsPage = UrlManagerPlugin::DOMAIN . '-admin';
|
83 |
+
|
84 |
+
$this->parrentPageSlug = 'premmerce';
|
85 |
+
$this->bundlesAndSave = new BundleAndSave($fileManager);
|
86 |
+
$this->affiliate = new AffiliateTab($fileManager);
|
87 |
+
$this->registerActions();
|
88 |
+
}
|
89 |
+
|
90 |
+
private function registerActions()
|
91 |
+
{
|
92 |
+
$flushActions = array(
|
93 |
+
'created_product_cat',
|
94 |
+
'edited_product_cat',
|
95 |
+
'delete_product_cat',
|
96 |
+
|
97 |
+
'created_product_tag',
|
98 |
+
'edited_product_tag',
|
99 |
+
'delete_product_tag',
|
100 |
+
|
101 |
+
'update_option_' . Settings::OPTIONS,
|
102 |
+
);
|
103 |
+
|
104 |
+
foreach ($flushActions as $action) {
|
105 |
+
add_action($action, array($this, 'triggerFlush'));
|
106 |
+
}
|
107 |
+
|
108 |
+
add_action('shutdown', array($this, 'flush'));
|
109 |
+
|
110 |
+
add_action('admin_init', array($this->settings, 'register'));
|
111 |
+
|
112 |
+
add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
add_action('admin_menu', array($this, 'addMenuPage'), 80);
|
117 |
+
add_action('admin_menu', array($this, 'addFullPack'), 100);
|
118 |
+
add_action('admin_notices', array($this, 'renderAdminBanner'));
|
119 |
+
add_action('wp_ajax_premmerce_url_manager_ignore_banner', array($this, 'ignoreAdminBanner'));
|
120 |
+
add_filter('plugin_action_links_' . plugin_basename($this->fileManager->getMainFile()), array($this, 'settingPageLink'), 10, 4);
|
121 |
+
add_filter('admin_footer_text', array($this, 'removeFooterAdmin'));
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Setting Page Link
|
126 |
+
*
|
127 |
+
* @param mixed $actions
|
128 |
+
* @return void
|
129 |
+
*/
|
130 |
+
public function settingPageLink($actions)
|
131 |
+
{
|
132 |
+
$actions[] = '<a href="' . $this->getSettingLink() . '">' . __('Settings', 'premmerce-url-manager') . '</a>';
|
133 |
+
|
134 |
+
return $actions;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Get url to settings page
|
139 |
+
*
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
public function getSettingLink()
|
143 |
+
{
|
144 |
+
$param = array('page' => 'premmerce-url-manager-admin' );
|
145 |
+
return esc_url(add_query_arg($param, get_admin_url() . 'admin.php'));
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Show Banner
|
150 |
+
*/
|
151 |
+
public function renderAdminBanner()
|
152 |
+
{
|
153 |
+
if ($this->isBannerActive()) {
|
154 |
+
$this->fileManager->includeTemplate('admin/banner.php', array('fm' => $this->fileManager));
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Hide Banner
|
160 |
+
*/
|
161 |
+
public function ignoreAdminBanner()
|
162 |
+
{
|
163 |
+
$user = wp_get_current_user();
|
164 |
+
$user_id = $user->ID;
|
165 |
+
|
166 |
+
add_user_meta($user_id, self::META_IGNORE_BANNER, true, true);
|
167 |
+
|
168 |
+
die;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Add submenu to premmerce menu page
|
173 |
+
*/
|
174 |
+
public function addMenuPage()
|
175 |
+
{
|
176 |
+
global $admin_page_hooks;
|
177 |
+
|
178 |
+
|
179 |
+
$premmerceMenuExists = isset($admin_page_hooks['premmerce']);
|
180 |
+
|
181 |
+
if (! $premmerceMenuExists) {
|
182 |
+
$svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="20" height="16" style="fill:#82878c" viewBox="0 0 20 16"><g id="Rectangle_7"> <path d="M17.8,4l-0.5,1C15.8,7.3,14.4,8,14,8c0,0,0,0,0,0H8h0V4.3C8,4.1,8.1,4,8.3,4H17.8 M4,0H1C0.4,0,0,0.4,0,1c0,0.6,0.4,1,1,1 h1.7C2.9,2,3,2.1,3,2.3V12c0,0.6,0.4,1,1,1c0.6,0,1-0.4,1-1V1C5,0.4,4.6,0,4,0L4,0z M18,2H7.3C6.6,2,6,2.6,6,3.3V12 c0,0.6,0.4,1,1,1c0.6,0,1-0.4,1-1v-1.7C8,10.1,8.1,10,8.3,10H14c1.1,0,3.2-1.1,5-4l0.7-1.4C20,4,20,3.2,19.5,2.6 C19.1,2.2,18.6,2,18,2L18,2z M14,11h-4c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1h4c0.6,0,1-0.4,1-1C15,11.4,14.6,11,14,11L14,11z M14,14 c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1c0.6,0,1-0.4,1-1C15,14.4,14.6,14,14,14L14,14z M4,14c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1 c0.6,0,1-0.4,1-1C5,14.4,4.6,14,4,14L4,14z"/></g></svg>';
|
183 |
+
$svg = 'data:image/svg+xml;base64,' . base64_encode($svg);
|
184 |
+
add_menu_page(
|
185 |
+
'Premmerce',
|
186 |
+
'Premmerce',
|
187 |
+
'manage_options',
|
188 |
+
'premmerce',
|
189 |
+
'',
|
190 |
+
$svg
|
191 |
+
);
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
add_submenu_page(
|
196 |
+
$this->parrentPageSlug,
|
197 |
+
__('Permalink Manager', 'premmerce-url-manager'),
|
198 |
+
__('Permalink Manager', 'premmerce-url-manager'),
|
199 |
+
'manage_options',
|
200 |
+
$this->settingsPage,
|
201 |
+
array($this, 'options'),
|
202 |
+
10
|
203 |
+
);
|
204 |
+
|
205 |
+
if (! $premmerceMenuExists) {
|
206 |
+
global $submenu;
|
207 |
+
unset($submenu['premmerce'][0]);
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
public function addFullPack()
|
212 |
+
{
|
213 |
+
if (! function_exists('get_plugins')) {
|
214 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
215 |
+
}
|
216 |
+
|
217 |
+
$plugins = get_plugins();
|
218 |
+
|
219 |
+
$premmerceInstalled = array_key_exists('premmerce-premium/premmerce.php', $plugins)
|
220 |
+
|| array_key_exists('premmerce/premmerce.php', $plugins);
|
221 |
+
|
222 |
+
if (! $premmerceInstalled) {
|
223 |
+
add_submenu_page(
|
224 |
+
'premmerce',
|
225 |
+
__('Get premmerce full pack', 'premmerce-url-manager'),
|
226 |
+
__('Get premmerce full pack', 'premmerce-url-manager'),
|
227 |
+
'manage_options',
|
228 |
+
admin_url('plugin-install.php?tab=plugin-information&plugin=premmerce')
|
229 |
+
);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Options page
|
235 |
+
*/
|
236 |
+
public function options()
|
237 |
+
{
|
238 |
+
$this->triggerFlush();
|
239 |
+
|
240 |
+
$current = isset($_GET['tab']) ? wc_clean(wp_unslash($_GET['tab'])) : 'settings';
|
241 |
+
|
242 |
+
$tabs['settings'] = __('Settings', 'premmerce-url-manager');
|
243 |
+
$tabs['bundle_and_save'] = __('Bundle and Save', 'premmerce-url-manager');
|
244 |
+
$tabs['affiliate'] = __('Affiliate', 'premmerce-url-manager');
|
245 |
+
|
246 |
+
if (function_exists('premmerce_wpm_fs')) {
|
247 |
+
if (premmerce_wpm_fs()->is_registered()) {
|
248 |
+
$tabs['account'] = __('Account', 'premmerce-url-manager');
|
249 |
+
}
|
250 |
+
$tabs['contact'] = __('Contact Us', 'premmerce-url-manager');
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
$this->fileManager->includeTemplate('admin/main.php', array(
|
255 |
+
'settings' => $this->settings,
|
256 |
+
'bundles' => $this->bundlesAndSave,
|
257 |
+
'affiliate' => $this->affiliate,
|
258 |
+
'tabs' => $tabs,
|
259 |
+
'current' => $current,
|
260 |
+
));
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Enqueue Scripts
|
265 |
+
*
|
266 |
+
* @param string $hook
|
267 |
+
*/
|
268 |
+
public function enqueueScripts($hook)
|
269 |
+
{
|
270 |
+
//init input-mask
|
271 |
+
wp_enqueue_script(
|
272 |
+
'input-mask.js',
|
273 |
+
$this->fileManager->locateAsset('admin/js/input-mask.min.js'),
|
274 |
+
array( 'jquery' ),
|
275 |
+
UrlManagerPlugin::getPluginVersion()
|
276 |
+
);
|
277 |
+
//add styles for Settings
|
278 |
+
if (in_array($hook, array('premmerce_page_premmerce-url-manager-admin', 'woocommerce_page_wc-settings'))) {
|
279 |
+
wp_enqueue_style(
|
280 |
+
'premmerce-permalink-style',
|
281 |
+
$this->fileManager->locateAsset('admin/css/style.css'),
|
282 |
+
array(),
|
283 |
+
UrlManagerPlugin::getPluginVersion()
|
284 |
+
);
|
285 |
+
}
|
286 |
+
//add scripts for settings
|
287 |
+
wp_enqueue_script(
|
288 |
+
'premmerce-permalink-settings-script',
|
289 |
+
$this->fileManager->locateAsset('admin/js/settings.js'),
|
290 |
+
array('jquery'),
|
291 |
+
UrlManagerPlugin::getPluginVersion()
|
292 |
+
);
|
293 |
+
|
294 |
+
if ($this->isBannerActive()) {
|
295 |
+
wp_enqueue_script(
|
296 |
+
'premmerce-permalink-banner-script',
|
297 |
+
$this->fileManager->locateAsset('admin/js/banner.js'),
|
298 |
+
array('jquery'),
|
299 |
+
UrlManagerPlugin::getPluginVersion()
|
300 |
+
);
|
301 |
+
wp_enqueue_style(
|
302 |
+
'premmerce-permalink-banner-style',
|
303 |
+
$this->fileManager->locateAsset('admin/css/banner.css'),
|
304 |
+
array(),
|
305 |
+
UrlManagerPlugin::getPluginVersion()
|
306 |
+
);
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Set flush trigger
|
312 |
+
*/
|
313 |
+
public function triggerFlush()
|
314 |
+
{
|
315 |
+
update_option(Settings::OPTION_FLUSH, true);
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Flush rewrite rules
|
320 |
+
*/
|
321 |
+
public function flush()
|
322 |
+
{
|
323 |
+
if (get_option(Settings::OPTION_FLUSH)) {
|
324 |
+
flush_rewrite_rules();
|
325 |
+
delete_option(Settings::OPTION_FLUSH);
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Admin footer modification
|
331 |
+
*
|
332 |
+
* @param $text - default WordPress footer thankyou text
|
333 |
+
*/
|
334 |
+
public function removeFooterAdmin($text)
|
335 |
+
{
|
336 |
+
$screen = get_current_screen();
|
337 |
+
$premmercePages = array(
|
338 |
+
'premmerce_page_premmerce-url-manager-admin'
|
339 |
+
);
|
340 |
+
|
341 |
+
if (in_array($screen->id, $premmercePages)) {
|
342 |
+
$link = 'https://wordpress.org/support/plugin/woo-permalink-manager/reviews/?filter=5';
|
343 |
+
$target = 'target="_blank"';
|
344 |
+
$text = '<span id="footer-thankyou">';
|
345 |
+
$text .= sprintf(
|
346 |
+
/* translators: %%1$s: plugin link, %2$s target */
|
347 |
+
__('Please rate our Premmerce Permalink Manager for WooCommerce on <a href="%1$s" %2$s>WordPress.org</a><br/>Thank you from the Premmerce team!', 'premmerce-filter'),
|
348 |
+
$link,
|
349 |
+
$target
|
350 |
+
);
|
351 |
+
$text .= '</span>';
|
352 |
+
} else {
|
353 |
+
$text = '<span id="footer-thankyou">' . $text . '</span>';
|
354 |
+
}
|
355 |
+
|
356 |
+
return $text;
|
357 |
+
}
|
358 |
+
|
359 |
+
public function isBannerActive()
|
360 |
+
{
|
361 |
+
$user = wp_get_current_user();
|
362 |
+
$user_id = $user->ID;
|
363 |
+
|
364 |
+
return ! get_user_meta($user_id, self::META_IGNORE_BANNER, true);
|
365 |
+
}
|
366 |
}
|
src/Admin/AffiliateTab.php
CHANGED
@@ -3,36 +3,40 @@
|
|
3 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
4 |
use Premmerce\UrlManager\Admin\Tabs\Base\TabInterface;
|
5 |
|
6 |
-
class AffiliateTab implements TabInterface
|
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 |
}
|
3 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
4 |
use Premmerce\UrlManager\Admin\Tabs\Base\TabInterface;
|
5 |
|
6 |
+
class AffiliateTab implements TabInterface
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* FileManager
|
10 |
+
*
|
11 |
+
* @var FileManager
|
12 |
+
*/
|
13 |
+
private $fileManager;
|
14 |
+
|
15 |
+
public function __construct(FileManager $fileManager)
|
16 |
+
{
|
17 |
+
$this->fileManager = $fileManager;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function init()
|
21 |
+
{
|
22 |
+
}
|
23 |
+
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getLabel()
|
29 |
+
{
|
30 |
+
return __('Affiliate', 'premmerce-url-manager');
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getName()
|
34 |
+
{
|
35 |
+
return 'affiliate';
|
36 |
+
}
|
37 |
+
|
38 |
+
public function valid()
|
39 |
+
{
|
40 |
+
return true;
|
41 |
+
}
|
42 |
}
|
src/Admin/BundleAndSave.php
CHANGED
@@ -4,149 +4,156 @@ use Premmerce\UrlManager\UrlManagerPlugin;
|
|
4 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
5 |
use Premmerce\UrlManager\Admin\Tabs\Base\TabInterface;
|
6 |
|
7 |
-
class BundleAndSave implements TabInterface
|
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 |
}
|
4 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
5 |
use Premmerce\UrlManager\Admin\Tabs\Base\TabInterface;
|
6 |
|
7 |
+
class BundleAndSave implements TabInterface
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* FileManager
|
11 |
+
*
|
12 |
+
* @var FileManager
|
13 |
+
*/
|
14 |
+
private $fileManager;
|
15 |
+
|
16 |
+
public function __construct(FileManager $fileManager)
|
17 |
+
{
|
18 |
+
$this->fileManager = $fileManager;
|
19 |
+
$this->hooks();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function init()
|
23 |
+
{
|
24 |
+
}
|
25 |
+
|
26 |
+
public function hooks()
|
27 |
+
{
|
28 |
+
add_action('admin_enqueue_scripts', array($this, 'registerBundlesAssets'), 11);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function render()
|
32 |
+
{
|
33 |
+
$images = array(
|
34 |
+
'header_img' => $this->fileManager->locateAsset('admin/img/premmerce_bundle.jpg'),
|
35 |
+
'premmerce_logo' => $this->fileManager->locateAsset('admin/img/premmerce.png'),
|
36 |
+
'permalink_img' => $this->fileManager->locateAsset('admin/img/permalink.png'),
|
37 |
+
'filter_img' => $this->fileManager->locateAsset('admin/img/filter.png'),
|
38 |
+
'variants_img' => $this->fileManager->locateAsset('admin/img/variants.png'),
|
39 |
+
'search_img' => $this->fileManager->locateAsset('admin/img/search.png'),
|
40 |
+
'riley_pearcy' => $this->fileManager->locateAsset('admin/img/riley_pearcy.jpg'),
|
41 |
+
'lian_perry' => $this->fileManager->locateAsset('admin/img/lian_perry.jpg'),
|
42 |
+
'rommie_mercer' => $this->fileManager->locateAsset('admin/img/rommie_mercer.jpg'),
|
43 |
+
'svg' => $this->fileManager->locateAsset('admin/img/svg.svg'),
|
44 |
+
'wp_logo' => $this->fileManager->locateAsset('admin/img/wp.png'),
|
45 |
+
'wp_rocket_logo' => $this->fileManager->locateAsset('admin/img/wp-rocket.jpg'),
|
46 |
+
'learnwoo_logo' => $this->fileManager->locateAsset('admin/img/learnwoo.png'),
|
47 |
+
'wp_lift_logo' => $this->fileManager->locateAsset('admin/img/wp-lift.png'),
|
48 |
+
'mayor_logo' => $this->fileManager->locateAsset('admin/img/mayor.png'),
|
49 |
+
'managewp_logo' => $this->fileManager->locateAsset('admin/img/managewp.png'),
|
50 |
+
'thanks_img' => $this->fileManager->locateAsset('admin/img/thanks.png'),
|
51 |
+
);
|
52 |
+
|
53 |
+
//sections on Bundles tab
|
54 |
+
$this->fileManager->includeTemplate('admin/tabs/bundle-and-save/header.php', $images);
|
55 |
+
$this->fileManager->includeTemplate('admin/tabs/bundle-and-save/pricing.php', $images);
|
56 |
+
$this->fileManager->includeTemplate('admin/tabs/bundle-and-save/texts.php', $images);
|
57 |
+
$this->fileManager->includeTemplate('admin/tabs/bundle-and-save/testimonials.php', $images);
|
58 |
+
$this->fileManager->includeTemplate('admin/tabs/bundle-and-save/faq.php', $images);
|
59 |
+
$this->fileManager->includeTemplate('admin/tabs/bundle-and-save/featured-in.php', $images);
|
60 |
+
$this->fileManager->includeTemplate('admin/tabs/bundle-and-save/thanks.php', $images);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Register css and js only for Bundles tab
|
65 |
+
*
|
66 |
+
* @param $page
|
67 |
+
*/
|
68 |
+
public function registerBundlesAssets($page)
|
69 |
+
{
|
70 |
+
if ('premmerce_page_premmerce-url-manager-admin' === $page) {
|
71 |
+
//scripts and styles for bundle tab
|
72 |
+
if (isset($_GET['tab']) && $_GET['tab'] === $this->getName()) {
|
73 |
+
//css and js for bundle tab
|
74 |
+
wp_enqueue_style(
|
75 |
+
'premmerce_url_manager_admin_premmerce_style',
|
76 |
+
$this->fileManager->locateAsset('admin/css/premmerce.min.css'),
|
77 |
+
array(),
|
78 |
+
UrlManagerPlugin::getPluginVersion()
|
79 |
+
);
|
80 |
+
wp_enqueue_script(
|
81 |
+
'premmerce_url_manager_admin_bundles_freemius_jquery_for_checkout_script',
|
82 |
+
'https://code.jquery.com/jquery-1.12.4.min.js',
|
83 |
+
UrlManagerPlugin::getPluginVersion(),
|
84 |
+
true
|
85 |
+
);
|
86 |
+
wp_enqueue_script(
|
87 |
+
'premmerce_url_manager_admin_bundles_freemius_checkout_script',
|
88 |
+
'https://checkout.freemius.com/checkout.min.js',
|
89 |
+
UrlManagerPlugin::getPluginVersion(),
|
90 |
+
true
|
91 |
+
);
|
92 |
+
wp_enqueue_script(
|
93 |
+
'premmerce_url_manager_admin_bundles_script',
|
94 |
+
$this->fileManager->locateAsset('admin/js/bundles.js'),
|
95 |
+
UrlManagerPlugin::getPluginVersion(),
|
96 |
+
true
|
97 |
+
);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get Label
|
104 |
+
*
|
105 |
+
* @return void
|
106 |
+
*/
|
107 |
+
public function getLabel()
|
108 |
+
{
|
109 |
+
return __('Bundle & Save', 'premmerce-url-manager');
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Get Name
|
114 |
+
*
|
115 |
+
* @return void
|
116 |
+
*/
|
117 |
+
public function getName()
|
118 |
+
{
|
119 |
+
return 'bundle_and_save';
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Valid
|
124 |
+
*
|
125 |
+
* @return void
|
126 |
+
*/
|
127 |
+
public function valid()
|
128 |
+
{
|
129 |
+
return true;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Get ico
|
134 |
+
*
|
135 |
+
* @param mixed $svg_url
|
136 |
+
* @param mixed $name
|
137 |
+
* @param mixed $echo
|
138 |
+
* @return void
|
139 |
+
*/
|
140 |
+
public static function premmerce_use_svg_symbol($svg_url, $name, $echo = true)
|
141 |
+
{
|
142 |
+
$ico = '<use xlink:href="' . $svg_url . '#svg-icon__' . $name . '"></use>';
|
143 |
+
|
144 |
+
$ksesDefaults = wp_kses_allowed_html('post');
|
145 |
+
|
146 |
+
$icoArgs = array(
|
147 |
+
'use' => array(
|
148 |
+
'href' => true,
|
149 |
+
'xlink:href' => true,
|
150 |
+
)
|
151 |
+
);
|
152 |
+
|
153 |
+
if ($echo) {
|
154 |
+
echo wp_kses($ico, array_merge($ksesDefaults, $icoArgs));
|
155 |
+
} else {
|
156 |
+
return $ico;
|
157 |
+
}
|
158 |
+
}
|
159 |
}
|
src/Admin/Settings.php
CHANGED
@@ -2,202 +2,211 @@
|
|
2 |
|
3 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
4 |
|
5 |
-
class Settings
|
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 |
}
|
2 |
|
3 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
4 |
|
5 |
+
class Settings
|
6 |
+
{
|
7 |
+
const OPTION_DISABLED = 'premmerce_url_manager_disabled';
|
8 |
+
|
9 |
+
const OPTION_FLUSH = 'premmerce_url_manager_flush_rules';
|
10 |
+
|
11 |
+
const OPTIONS = 'premmerce_permalink_manager';
|
12 |
+
|
13 |
+
const SETTINGS_PAGE = 'premmerce_permalink_manager_page';
|
14 |
+
|
15 |
+
const PERMALINK_STRUCTURE = '/%postname%/';
|
16 |
+
|
17 |
+
const PERMALINK_WC_PRODUCT_CAT = '/product/%product_cat%/';
|
18 |
+
|
19 |
+
const PERMALINK_WC_PRODUCT = 'product';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* FileManager
|
23 |
+
*
|
24 |
+
* @var FileManager
|
25 |
+
*/
|
26 |
+
private $fileManager;
|
27 |
+
|
28 |
+
public function __construct(FileManager $fileManager)
|
29 |
+
{
|
30 |
+
$this->fileManager = $fileManager;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function register()
|
34 |
+
{
|
35 |
+
register_setting(self::OPTIONS, self::OPTIONS, array(
|
36 |
+
'sanitize_callback' => array( $this, 'updateSettings' ),
|
37 |
+
));
|
38 |
+
|
39 |
+
add_settings_section('category_link', __('Categories', 'premmerce-url-manager'), array(
|
40 |
+
$this,
|
41 |
+
'categorySection',
|
42 |
+
), self::SETTINGS_PAGE);
|
43 |
+
|
44 |
+
add_settings_section('product_link', __('Products', 'premmerce-url-manager'), array(
|
45 |
+
$this,
|
46 |
+
'productSection',
|
47 |
+
), self::SETTINGS_PAGE);
|
48 |
+
|
49 |
+
add_settings_section('sku_link', __('SKU', 'premmerce-url-manager'), array(
|
50 |
+
$this,
|
51 |
+
'skuSection',
|
52 |
+
), self::SETTINGS_PAGE);
|
53 |
+
|
54 |
+
add_settings_section('additional', __('Additional', 'premmerce-url-manager'), array(
|
55 |
+
$this,
|
56 |
+
'canonicalSection',
|
57 |
+
), self::SETTINGS_PAGE);
|
58 |
+
|
59 |
+
add_settings_section('suffix', __('URL\'s suffix', 'premmerce-url-manager'), array(
|
60 |
+
$this,
|
61 |
+
'suffixSection',
|
62 |
+
), self::SETTINGS_PAGE);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get Main Settings Text
|
67 |
+
*
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
public static function getMainSettingsText()
|
71 |
+
{
|
72 |
+
return __('WooCommerce Permalink Manager offers you the ability to create a custom URL structure for your permalinks. Custom URL structures can improve the aesthetics, usability, and forward-compatibility of your links. A number of settings are available, and here are some examples to get you started.', 'premmerce-url-manager');
|
73 |
+
}
|
74 |
+
|
75 |
+
public function show()
|
76 |
+
{
|
77 |
+
print('<form action="' . esc_url(admin_url('options.php')) . '" method="post">');
|
78 |
+
|
79 |
+
settings_errors();
|
80 |
+
|
81 |
+
settings_fields(self::OPTIONS);
|
82 |
+
|
83 |
+
do_settings_sections(self::SETTINGS_PAGE);
|
84 |
+
|
85 |
+
submit_button();
|
86 |
+
print('</form>');
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get Product Path For Sku
|
91 |
+
*
|
92 |
+
* @return void
|
93 |
+
*/
|
94 |
+
public function getProductPathForSku()
|
95 |
+
{
|
96 |
+
$product = $this->getOption('product');
|
97 |
+
|
98 |
+
switch ($product) {
|
99 |
+
case 'category_slug':
|
100 |
+
return '/category';
|
101 |
+
case 'hierarchical':
|
102 |
+
return 'parent-category/category';
|
103 |
+
default:
|
104 |
+
return '';
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
public function categorySection()
|
109 |
+
{
|
110 |
+
$this->fileManager->includeTemplate('admin/section/category.php', array(
|
111 |
+
'category' => $this->getOption('category'),
|
112 |
+
));
|
113 |
+
}
|
114 |
+
|
115 |
+
public function productSection()
|
116 |
+
{
|
117 |
+
$this->fileManager->includeTemplate('admin/section/product.php', array(
|
118 |
+
'product' => $this->getOption('product'),
|
119 |
+
));
|
120 |
+
}
|
121 |
+
|
122 |
+
public function skuSection()
|
123 |
+
{
|
124 |
+
$this->fileManager->includeTemplate('admin/section/sku.php', array(
|
125 |
+
'sku' => $this->getOption('sku'),
|
126 |
+
'productPath' => $this->getProductPathForSku(),
|
127 |
+
));
|
128 |
+
}
|
129 |
+
|
130 |
+
public function canonicalSection()
|
131 |
+
{
|
132 |
+
$this->fileManager->includeTemplate('admin/section/additional.php', array(
|
133 |
+
'tag' => $this->getOption('tag'),
|
134 |
+
'canonical' => $this->getOption('canonical'),
|
135 |
+
'redirect' => $this->getOption('redirect'),
|
136 |
+
'use_primary_category' => $this->getOption('use_primary_category'),
|
137 |
+
'breadcrumbs' => $this->getOption('breadcrumbs'),
|
138 |
+
'br_remove_shop' => $this->getOption('br_remove_shop'),
|
139 |
+
));
|
140 |
+
}
|
141 |
+
|
142 |
+
public function suffixSection()
|
143 |
+
{
|
144 |
+
$this->fileManager->includeTemplate('admin/section/suffix.php', array(
|
145 |
+
'suffix' => $this->getOption('suffix', ''),
|
146 |
+
'enable_suffix_products' => $this->getOption('enable_suffix_products', 'no'),
|
147 |
+
'enable_suffix_categories' => $this->getOption('enable_suffix_categories', 'no'),
|
148 |
+
'product' => $this->getOption('product'),
|
149 |
+
'category' => $this->getOption('category')
|
150 |
+
));
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Update Settings
|
155 |
+
*
|
156 |
+
* @param mixed $settings
|
157 |
+
* @return void
|
158 |
+
*/
|
159 |
+
public function updateSettings($settings)
|
160 |
+
{
|
161 |
+
$this->fixWPWCSettings($settings);
|
162 |
+
|
163 |
+
if (! empty($settings['suffix'])) {
|
164 |
+
esc_url_raw($settings['suffix']);
|
165 |
+
}
|
166 |
+
|
167 |
+
return $settings;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Fix WP WC Settings
|
172 |
+
*
|
173 |
+
* @param mixed $options
|
174 |
+
* @return void
|
175 |
+
*/
|
176 |
+
private function fixWPWCSettings($options)
|
177 |
+
{
|
178 |
+
if (isset($options['product']) && !empty($options['product']) || isset($options['category']) && !empty($options['category'])) {
|
179 |
+
if (! get_option('permalink_structure')) {
|
180 |
+
update_option('permalink_structure', self::PERMALINK_STRUCTURE);
|
181 |
+
};
|
182 |
+
}
|
183 |
+
|
184 |
+
if (isset($options['product']) && !empty($options['product'])) {
|
185 |
+
if ('slug' === $options['product']) {
|
186 |
+
$wc['product_base'] = self::PERMALINK_WC_PRODUCT;
|
187 |
+
}
|
188 |
+
if (in_array($options['product'], array( 'category_slug', 'hierarchical' ))) {
|
189 |
+
$wc['product_base'] = self::PERMALINK_WC_PRODUCT_CAT;
|
190 |
+
}
|
191 |
+
|
192 |
+
update_option('woocommerce_permalinks', $wc);
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Get Option
|
198 |
+
*
|
199 |
+
* @param string $key
|
200 |
+
* @param mixed|null $default
|
201 |
+
*
|
202 |
+
* @return mixed|null
|
203 |
+
*/
|
204 |
+
public function getOption($key, $default = null)
|
205 |
+
{
|
206 |
+
if (! isset($this->options)) {
|
207 |
+
$this->options = get_option(self::OPTIONS);
|
208 |
+
}
|
209 |
+
|
210 |
+
return isset($this->options[ $key ]) ? $this->options[ $key ] : $default;
|
211 |
+
}
|
212 |
}
|
src/Admin/Tabs/Base/TabInterface.php
CHANGED
@@ -1,34 +1,33 @@
|
|
1 |
<?php namespace Premmerce\UrlManager\Admin\Tabs\Base;
|
2 |
|
3 |
-
interface TabInterface
|
|
|
|
|
|
|
|
|
|
|
4 |
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Returns unique tab name
|
25 |
-
*/
|
26 |
-
public function getName();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Is tab valid to render
|
30 |
-
*
|
31 |
-
* @return bool
|
32 |
-
*/
|
33 |
-
public function valid();
|
34 |
}
|
1 |
<?php namespace Premmerce\UrlManager\Admin\Tabs\Base;
|
2 |
|
3 |
+
interface TabInterface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Register hooks
|
7 |
+
*/
|
8 |
+
public function init();
|
9 |
|
10 |
+
/**
|
11 |
+
* Render tab content
|
12 |
+
*/
|
13 |
+
public function render();
|
14 |
|
15 |
+
/**
|
16 |
+
* Returns tab label
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getLabel();
|
21 |
|
22 |
+
/**
|
23 |
+
* Returns unique tab name
|
24 |
+
*/
|
25 |
+
public function getName();
|
26 |
|
27 |
+
/**
|
28 |
+
* Is tab valid to render
|
29 |
+
*
|
30 |
+
* @return bool
|
31 |
+
*/
|
32 |
+
public function valid();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
src/Frontend/Frontend.php
CHANGED
@@ -28,14 +28,14 @@ class Frontend
|
|
28 |
$options = get_option( Settings::OPTIONS );
|
29 |
$this->options = $options;
|
30 |
if ( !empty($options['product']) || !empty($options['sku']) ) {
|
31 |
-
add_action( 'request',
|
32 |
}
|
33 |
if ( !empty($options['canonical']) ) {
|
34 |
-
add_action( 'wp_head',
|
35 |
}
|
36 |
$isGetParamUrlFormat = apply_filters( 'wpml_setting', 0, 'language_negotiation_type' ) == '3';
|
37 |
if ( class_exists( 'SitePress' ) && $isGetParamUrlFormat ) {
|
38 |
-
add_filter( 'icl_ls_languages',
|
39 |
}
|
40 |
}
|
41 |
|
@@ -84,7 +84,7 @@ class Frontend
|
|
84 |
if ( !empty($url) ) {
|
85 |
$url = explode( '/', $url );
|
86 |
$slug = array_pop( $url );
|
87 |
-
$replace =
|
88 |
|
89 |
if ( 'feed' === $slug ) {
|
90 |
$replace['feed'] = $slug;
|
@@ -104,14 +104,18 @@ class Frontend
|
|
104 |
$slug = array_pop( $url );
|
105 |
}
|
106 |
|
107 |
-
$num = intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) as count_id FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s",
|
108 |
|
109 |
if ( $num > 0 ) {
|
110 |
$replace['page'] = '';
|
111 |
$replace['post_type'] = self::WOO_PRODUCT;
|
112 |
$replace['product'] = $slug;
|
113 |
$replace['name'] = $slug;
|
114 |
-
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
|
117 |
}
|
@@ -184,7 +188,7 @@ class Frontend
|
|
184 |
protected function findSlugBySku( $sku )
|
185 |
{
|
186 |
global $wpdb ;
|
187 |
-
$skuId = $wpdb->get_row( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = %s AND meta_key = '_sku'",
|
188 |
|
189 |
if ( isset( $skuId['post_id'] ) ) {
|
190 |
$postSlug = get_post_field( 'post_name', $skuId['post_id'] );
|
@@ -205,7 +209,7 @@ class Frontend
|
|
205 |
*/
|
206 |
protected function checkIfWooCategoryExists( $request )
|
207 |
{
|
208 |
-
if ( !empty($this->options['category']) && in_array( $this->options['product'],
|
209 |
if ( array_key_exists( self::WOO_CATEGORY, $request ) ) {
|
210 |
return true;
|
211 |
}
|
28 |
$options = get_option( Settings::OPTIONS );
|
29 |
$this->options = $options;
|
30 |
if ( !empty($options['product']) || !empty($options['sku']) ) {
|
31 |
+
add_action( 'request', array( $this, 'replaceRequest' ), 11 );
|
32 |
}
|
33 |
if ( !empty($options['canonical']) ) {
|
34 |
+
add_action( 'wp_head', array( $this, 'addCanonical' ) );
|
35 |
}
|
36 |
$isGetParamUrlFormat = apply_filters( 'wpml_setting', 0, 'language_negotiation_type' ) == '3';
|
37 |
if ( class_exists( 'SitePress' ) && $isGetParamUrlFormat ) {
|
38 |
+
add_filter( 'icl_ls_languages', array( $this, 'modifyWpmlLanguageSwitcher' ), 20 );
|
39 |
}
|
40 |
}
|
41 |
|
84 |
if ( !empty($url) ) {
|
85 |
$url = explode( '/', $url );
|
86 |
$slug = array_pop( $url );
|
87 |
+
$replace = array();
|
88 |
|
89 |
if ( 'feed' === $slug ) {
|
90 |
$replace['feed'] = $slug;
|
104 |
$slug = array_pop( $url );
|
105 |
}
|
106 |
|
107 |
+
$num = intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) as count_id FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s", array( $slug, self::WOO_PRODUCT ) ) ) );
|
108 |
|
109 |
if ( $num > 0 ) {
|
110 |
$replace['page'] = '';
|
111 |
$replace['post_type'] = self::WOO_PRODUCT;
|
112 |
$replace['product'] = $slug;
|
113 |
$replace['name'] = $slug;
|
114 |
+
// Find other query vars
|
115 |
+
$old_request = $request;
|
116 |
+
unset( $old_request['pagename'] );
|
117 |
+
$extra = array_diff_key( $old_request, $replace );
|
118 |
+
return array_merge( $replace, $extra );
|
119 |
}
|
120 |
|
121 |
}
|
188 |
protected function findSlugBySku( $sku )
|
189 |
{
|
190 |
global $wpdb ;
|
191 |
+
$skuId = $wpdb->get_row( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = %s AND meta_key = '_sku'", array( $sku ) ), ARRAY_A );
|
192 |
|
193 |
if ( isset( $skuId['post_id'] ) ) {
|
194 |
$postSlug = get_post_field( 'post_name', $skuId['post_id'] );
|
209 |
*/
|
210 |
protected function checkIfWooCategoryExists( $request )
|
211 |
{
|
212 |
+
if ( !empty($this->options['category']) && in_array( $this->options['product'], array( 'category_slug', 'hierarchical' ) ) ) {
|
213 |
if ( array_key_exists( self::WOO_CATEGORY, $request ) ) {
|
214 |
return true;
|
215 |
}
|
src/PermalinkListener.php
CHANGED
@@ -24,14 +24,14 @@ class PermalinkListener
|
|
24 |
public function __construct()
|
25 |
{
|
26 |
$options = get_option( Settings::OPTIONS );
|
27 |
-
$this->options =
|
28 |
'use_primary_category' => !empty($options['use_primary_category']),
|
29 |
'product' => ( isset( $options['product'] ) ? $options['product'] : '' ),
|
30 |
'suffix' => ( !empty($options['suffix']) ? $options['suffix'] : false ),
|
31 |
'enable_suffix_categories' => ( isset( $options['enable_suffix_categories'] ) && !empty($options['enable_suffix_categories']) ? true : false ),
|
32 |
'enable_suffix_products' => ( isset( $options['enable_suffix_products'] ) && !empty($options['enable_suffix_products']) ? true : false ),
|
33 |
'sku' => ( isset( $options['sku'] ) ? $options['sku'] : '' ),
|
34 |
-
|
35 |
$this->taxonomyOptions['product_cat'] = ( isset( $options['category'] ) ? $options['category'] : '' );
|
36 |
}
|
37 |
|
@@ -42,17 +42,17 @@ class PermalinkListener
|
|
42 |
{
|
43 |
add_filter(
|
44 |
'post_type_link',
|
45 |
-
|
46 |
1,
|
47 |
2
|
48 |
);
|
49 |
add_filter(
|
50 |
'term_link',
|
51 |
-
|
52 |
0,
|
53 |
3
|
54 |
);
|
55 |
-
add_filter( 'rewrite_rules_array',
|
56 |
add_action( 'pll_init', function ( $polylang ) {
|
57 |
$this->polyLang = $polylang;
|
58 |
} );
|
@@ -123,7 +123,7 @@ class PermalinkListener
|
|
123 |
wp_cache_flush();
|
124 |
global $wp_rewrite ;
|
125 |
$feed = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
|
126 |
-
$customRules =
|
127 |
/**
|
128 |
* Remove WPML filters while getting terms, to get all languages
|
129 |
*/
|
@@ -138,10 +138,10 @@ class PermalinkListener
|
|
138 |
foreach ( $this->taxonomyOptions as $taxonomy => $option ) {
|
139 |
|
140 |
if ( !empty($option) ) {
|
141 |
-
$terms = get_categories(
|
142 |
'taxonomy' => $taxonomy,
|
143 |
'hide_empty' => false,
|
144 |
-
|
145 |
$hierarchical = $this->isHierarchical( $option );
|
146 |
$suffix = false;
|
147 |
foreach ( $terms as $term ) {
|
24 |
public function __construct()
|
25 |
{
|
26 |
$options = get_option( Settings::OPTIONS );
|
27 |
+
$this->options = array(
|
28 |
'use_primary_category' => !empty($options['use_primary_category']),
|
29 |
'product' => ( isset( $options['product'] ) ? $options['product'] : '' ),
|
30 |
'suffix' => ( !empty($options['suffix']) ? $options['suffix'] : false ),
|
31 |
'enable_suffix_categories' => ( isset( $options['enable_suffix_categories'] ) && !empty($options['enable_suffix_categories']) ? true : false ),
|
32 |
'enable_suffix_products' => ( isset( $options['enable_suffix_products'] ) && !empty($options['enable_suffix_products']) ? true : false ),
|
33 |
'sku' => ( isset( $options['sku'] ) ? $options['sku'] : '' ),
|
34 |
+
);
|
35 |
$this->taxonomyOptions['product_cat'] = ( isset( $options['category'] ) ? $options['category'] : '' );
|
36 |
}
|
37 |
|
42 |
{
|
43 |
add_filter(
|
44 |
'post_type_link',
|
45 |
+
array( $this, 'replaceProductLink' ),
|
46 |
1,
|
47 |
2
|
48 |
);
|
49 |
add_filter(
|
50 |
'term_link',
|
51 |
+
array( $this, 'replaceTermLink' ),
|
52 |
0,
|
53 |
3
|
54 |
);
|
55 |
+
add_filter( 'rewrite_rules_array', array( $this, 'addRewriteRules' ), 99 );
|
56 |
add_action( 'pll_init', function ( $polylang ) {
|
57 |
$this->polyLang = $polylang;
|
58 |
} );
|
123 |
wp_cache_flush();
|
124 |
global $wp_rewrite ;
|
125 |
$feed = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
|
126 |
+
$customRules = array();
|
127 |
/**
|
128 |
* Remove WPML filters while getting terms, to get all languages
|
129 |
*/
|
138 |
foreach ( $this->taxonomyOptions as $taxonomy => $option ) {
|
139 |
|
140 |
if ( !empty($option) ) {
|
141 |
+
$terms = get_categories( array(
|
142 |
'taxonomy' => $taxonomy,
|
143 |
'hide_empty' => false,
|
144 |
+
) );
|
145 |
$hierarchical = $this->isHierarchical( $option );
|
146 |
$suffix = false;
|
147 |
foreach ( $terms as $term ) {
|
src/Updater.php
CHANGED
@@ -2,74 +2,75 @@
|
|
2 |
|
3 |
use Premmerce\UrlManager\Admin\Settings;
|
4 |
|
5 |
-
class Updater
|
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 |
}
|
2 |
|
3 |
use Premmerce\UrlManager\Admin\Settings;
|
4 |
|
5 |
+
class Updater
|
6 |
+
{
|
7 |
+
const CURRENT_VERSION = '2.0';
|
8 |
+
|
9 |
+
const DB_OPTION = 'premmerce_permalink_manager_db_version';
|
10 |
+
|
11 |
+
public function checkForUpdates()
|
12 |
+
{
|
13 |
+
return $this->compare(self::CURRENT_VERSION);
|
14 |
+
}
|
15 |
+
|
16 |
+
private function compare($version)
|
17 |
+
{
|
18 |
+
$dbVersion = get_option(self::DB_OPTION, 1.1);
|
19 |
+
|
20 |
+
return version_compare($dbVersion, $version, '<');
|
21 |
+
}
|
22 |
+
|
23 |
+
public function update()
|
24 |
+
{
|
25 |
+
if ($this->checkForUpdates()) {
|
26 |
+
foreach ($this->getUpdates() as $version => $callback) {
|
27 |
+
if ($this->compare($version)) {
|
28 |
+
call_user_func($callback);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
update_option(Settings::OPTION_FLUSH, true);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getUpdates()
|
37 |
+
{
|
38 |
+
return array(
|
39 |
+
'2.0' => array($this, 'update2_0'),
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
public function update2_0()
|
44 |
+
{
|
45 |
+
$options = get_option('premmerce_url_manager_options', array());
|
46 |
+
$options12 = array(
|
47 |
+
'use_primary_category' => 'on',
|
48 |
+
);
|
49 |
+
|
50 |
+
$wc = get_option('woocommerce_permalinks');
|
51 |
+
|
52 |
+
$showProductCats = false;
|
53 |
+
if (! empty($wc['product_base'])) {
|
54 |
+
$showProductCats = strpos($wc['product_base'], '%product_cat%') !== false;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
if (! empty($options['remove_product_base'])) {
|
59 |
+
$options12['product'] = 'slug';
|
60 |
+
if ($showProductCats) {
|
61 |
+
$options12['product'] = 'hierarchical';
|
62 |
+
}
|
63 |
+
}
|
64 |
+
if (! empty($options['remove_category_base'])) {
|
65 |
+
$options12['category'] = 'hierarchical';
|
66 |
+
if (! empty($options['remove_category_parent_slugs'])) {
|
67 |
+
$options12['category'] = 'slug';
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
update_option('premmerce_permalink_manager', $options12);
|
72 |
+
delete_option('premmerce_url_manager_options');
|
73 |
+
delete_option(Settings::OPTION_DISABLED);
|
74 |
+
update_option(self::DB_OPTION, '2.0');
|
75 |
+
}
|
76 |
}
|
src/UrlManagerPlugin.php
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
|
3 |
use Premmerce\UrlManager\Admin\Admin;
|
4 |
use Premmerce\UrlManager\Admin\Settings;
|
5 |
-
use Premmerce\UrlManager\Admin\WooSettings;
|
6 |
use Premmerce\UrlManager\Frontend\Frontend;
|
7 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
8 |
use Premmerce\UrlManager\Addons\AddonManager;
|
@@ -13,167 +12,171 @@ use Premmerce\SDK\V2\Notifications\AdminNotifier;
|
|
13 |
*
|
14 |
* @package Premmerce\UrlManager
|
15 |
*/
|
16 |
-
class UrlManagerPlugin
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
const VERSION = '2.3.5';
|
23 |
-
|
24 |
-
/**
|
25 |
* FileManager
|
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 |
}
|
2 |
|
3 |
use Premmerce\UrlManager\Admin\Admin;
|
4 |
use Premmerce\UrlManager\Admin\Settings;
|
|
|
5 |
use Premmerce\UrlManager\Frontend\Frontend;
|
6 |
use Premmerce\SDK\V2\FileManager\FileManager;
|
7 |
use Premmerce\UrlManager\Addons\AddonManager;
|
12 |
*
|
13 |
* @package Premmerce\UrlManager
|
14 |
*/
|
15 |
+
class UrlManagerPlugin
|
16 |
+
{
|
17 |
+
const DOMAIN = 'premmerce-url-manager';
|
18 |
|
19 |
+
const VERSION = '2.3.5';
|
20 |
|
21 |
+
/**
|
|
|
|
|
|
|
|
|
22 |
* FileManager
|
23 |
+
*
|
24 |
+
* @var FileManager
|
25 |
+
*/
|
26 |
+
private $fileManager;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Notifier
|
30 |
+
*
|
31 |
+
* @var AdminNotifier
|
32 |
+
*/
|
33 |
+
private $notifier;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* PluginManager constructor.
|
37 |
+
*
|
38 |
+
* @param $mainFile
|
39 |
+
*/
|
40 |
+
public function __construct($mainFile)
|
41 |
+
{
|
42 |
+
$this->fileManager = new FileManager($mainFile);
|
43 |
+
$this->notifier = new AdminNotifier();
|
44 |
+
|
45 |
+
add_action('init', array($this, 'loadTextDomain'));
|
46 |
+
add_action('admin_init', array($this, 'checkRequirePlugins'));
|
47 |
+
|
48 |
+
premmerce_wpm_fs()->add_filter('freemius_pricing_js_path', array($this, 'cutomFreemiusPricingPage'));
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Get Plugin Version
|
53 |
+
*
|
54 |
+
* @return void
|
55 |
+
*/
|
56 |
+
public static function getPluginVersion()
|
57 |
+
{
|
58 |
+
if (defined('self::VERSION')) {
|
59 |
+
return self::VERSION;
|
60 |
+
}
|
61 |
+
return '1.0.0';
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Custom pricing page
|
66 |
+
*/
|
67 |
+
public function cutomFreemiusPricingPage($default_pricing_js_path)
|
68 |
+
{
|
69 |
+
$pluginDir = $this->fileManager->getPluginDirectory();
|
70 |
+
$pricing_js_path = $pluginDir . '/assets/admin/js/pricing-page/freemius-pricing.js';
|
71 |
+
|
72 |
+
return $pricing_js_path;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Run plugin part
|
77 |
+
*/
|
78 |
+
public function run()
|
79 |
+
{
|
80 |
+
$valid = count($this->validateRequiredPlugins()) === 0;
|
81 |
+
( new Updater() )->update();
|
82 |
+
|
83 |
+
if (is_admin()) {
|
84 |
+
new Admin($this->fileManager);
|
85 |
+
}
|
86 |
+
|
87 |
+
if ($valid) {
|
88 |
+
if (! is_admin()) {
|
89 |
+
new Frontend();
|
90 |
+
}
|
91 |
+
( new PermalinkListener() )->registerFilters();
|
92 |
+
( new AddonManager() )->initAddons();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Fired when the plugin is activated
|
98 |
+
*/
|
99 |
+
public function activate()
|
100 |
+
{
|
101 |
+
flush_rewrite_rules();
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Fired when the plugin is deactivated
|
106 |
+
*/
|
107 |
+
public function deactivate()
|
108 |
+
{
|
109 |
+
$this->deleteUsersBannerMeta();
|
110 |
+
flush_rewrite_rules();
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Fired during plugin uninstall
|
115 |
+
*/
|
116 |
+
public static function uninstall()
|
117 |
+
{
|
118 |
+
delete_option(Updater::DB_OPTION);
|
119 |
+
delete_option(Settings::OPTION_FLUSH);
|
120 |
+
delete_option(Settings::OPTION_DISABLED);
|
121 |
+
delete_option(Settings::OPTIONS);
|
122 |
+
|
123 |
+
flush_rewrite_rules();
|
124 |
+
}
|
125 |
+
|
126 |
+
private function deleteUsersBannerMeta()
|
127 |
+
{
|
128 |
+
global $wpdb;
|
129 |
+
|
130 |
+
$wpdb->delete($wpdb->usermeta, array('meta_key' => Admin::META_IGNORE_BANNER));
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Load plugin translations
|
135 |
+
*/
|
136 |
+
public function loadTextDomain()
|
137 |
+
{
|
138 |
+
$name = $this->fileManager->getPluginName();
|
139 |
+
load_plugin_textdomain('premmerce-url-manager', false, $name . '/languages/');
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Check required plugins and push notifications
|
144 |
+
*/
|
145 |
+
public function checkRequirePlugins()
|
146 |
+
{
|
147 |
+
/* translators: %%1$s: our plugin name, %2$s another plugin name */
|
148 |
+
$message = __('The %1$s plugin requires %2$s plugin to be active!', 'premmerce-url-manager');
|
149 |
+
|
150 |
+
$plugins = $this->validateRequiredPlugins();
|
151 |
+
|
152 |
+
if (count($plugins)) {
|
153 |
+
foreach ($plugins as $plugin) {
|
154 |
+
$error = sprintf($message, 'WooCommerce Permalink Manager', $plugin);
|
155 |
+
$this->notifier->push($error, AdminNotifier::ERROR, false);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Validate required plugins
|
162 |
+
*
|
163 |
+
* @return array
|
164 |
+
*/
|
165 |
+
private function validateRequiredPlugins()
|
166 |
+
{
|
167 |
+
$plugins = array();
|
168 |
+
|
169 |
+
if (! function_exists('is_plugin_active')) {
|
170 |
+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Check if WooCommerce is active
|
175 |
+
**/
|
176 |
+
if (! (is_plugin_active('woocommerce/woocommerce.php') || is_plugin_active_for_network('woocommerce/woocommerce.php'))) {
|
177 |
+
$plugins[] = '<a target="_blank" href="https://wordpress.org/plugins/woocommerce/">WooCommerce</a>';
|
178 |
+
}
|
179 |
+
|
180 |
+
return $plugins;
|
181 |
+
}
|
182 |
}
|
vendor/autoload.php
CHANGED
@@ -2,6 +2,11 @@
|
|
2 |
|
3 |
// autoload.php @generated by Composer
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
2 |
|
3 |
// autoload.php @generated by Composer
|
4 |
|
5 |
+
if (PHP_VERSION_ID < 50600) {
|
6 |
+
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
7 |
+
exit(1);
|
8 |
+
}
|
9 |
+
|
10 |
require_once __DIR__ . '/composer/autoload_real.php';
|
11 |
|
12 |
+
return ComposerAutoloaderInita6026d7805fa28dd437b7e92e52cc4a1::getLoader();
|
vendor/composer/ClassLoader.php
CHANGED
@@ -149,7 +149,7 @@ class ClassLoader
|
|
149 |
|
150 |
/**
|
151 |
* @return string[] Array of classname => path
|
152 |
-
* @psalm-
|
153 |
*/
|
154 |
public function getClassMap()
|
155 |
{
|
149 |
|
150 |
/**
|
151 |
* @return string[] Array of classname => path
|
152 |
+
* @psalm-return array<string, string>
|
153 |
*/
|
154 |
public function getClassMap()
|
155 |
{
|
vendor/composer/InstalledVersions.php
CHANGED
@@ -21,6 +21,8 @@ use Composer\Semver\VersionParser;
|
|
21 |
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
22 |
*
|
23 |
* To require its presence, you can require `composer-runtime-api ^2.0`
|
|
|
|
|
24 |
*/
|
25 |
class InstalledVersions
|
26 |
{
|
21 |
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
22 |
*
|
23 |
* To require its presence, you can require `composer-runtime-api ^2.0`
|
24 |
+
*
|
25 |
+
* @final
|
26 |
*/
|
27 |
class InstalledVersions
|
28 |
{
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_classmap.php @generated by Composer
|
4 |
|
5 |
-
$vendorDir = dirname(
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
2 |
|
3 |
// autoload_classmap.php @generated by Composer
|
4 |
|
5 |
+
$vendorDir = dirname(__DIR__);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
vendor/composer/autoload_namespaces.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_namespaces.php @generated by Composer
|
4 |
|
5 |
-
$vendorDir = dirname(
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
2 |
|
3 |
// autoload_namespaces.php @generated by Composer
|
4 |
|
5 |
+
$vendorDir = dirname(__DIR__);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_psr4.php @generated by Composer
|
4 |
|
5 |
-
$vendorDir = dirname(
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
2 |
|
3 |
// autoload_psr4.php @generated by Composer
|
4 |
|
5 |
+
$vendorDir = dirname(__DIR__);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -22,31 +22,12 @@ class ComposerAutoloaderInitd57565eb5812eae38d62a7da0f230b5f
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
-
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(
|
27 |
-
spl_autoload_unregister(array('
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
require __DIR__ . '/autoload_static.php';
|
32 |
-
|
33 |
-
call_user_func(\Composer\Autoload\ComposerStaticInitd57565eb5812eae38d62a7da0f230b5f::getInitializer($loader));
|
34 |
-
} else {
|
35 |
-
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
-
foreach ($map as $namespace => $path) {
|
37 |
-
$loader->set($namespace, $path);
|
38 |
-
}
|
39 |
-
|
40 |
-
$map = require __DIR__ . '/autoload_psr4.php';
|
41 |
-
foreach ($map as $namespace => $path) {
|
42 |
-
$loader->setPsr4($namespace, $path);
|
43 |
-
}
|
44 |
-
|
45 |
-
$classMap = require __DIR__ . '/autoload_classmap.php';
|
46 |
-
if ($classMap) {
|
47 |
-
$loader->addClassMap($classMap);
|
48 |
-
}
|
49 |
-
}
|
50 |
|
51 |
$loader->register(true);
|
52 |
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInita6026d7805fa28dd437b7e92e52cc4a1
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInita6026d7805fa28dd437b7e92e52cc4a1', 'loadClassLoader'), true, true);
|
26 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInita6026d7805fa28dd437b7e92e52cc4a1', 'loadClassLoader'));
|
28 |
+
|
29 |
+
require __DIR__ . '/autoload_static.php';
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInita6026d7805fa28dd437b7e92e52cc4a1::getInitializer($loader));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
$loader->register(true);
|
33 |
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'P' =>
|
@@ -32,9 +32,9 @@ class ComposerStaticInitd57565eb5812eae38d62a7da0f230b5f
|
|
32 |
public static function getInitializer(ClassLoader $loader)
|
33 |
{
|
34 |
return \Closure::bind(function () use ($loader) {
|
35 |
-
$loader->prefixLengthsPsr4 =
|
36 |
-
$loader->prefixDirsPsr4 =
|
37 |
-
$loader->classMap =
|
38 |
|
39 |
}, null, ClassLoader::class);
|
40 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInita6026d7805fa28dd437b7e92e52cc4a1
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'P' =>
|
32 |
public static function getInitializer(ClassLoader $loader)
|
33 |
{
|
34 |
return \Closure::bind(function () use ($loader) {
|
35 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInita6026d7805fa28dd437b7e92e52cc4a1::$prefixLengthsPsr4;
|
36 |
+
$loader->prefixDirsPsr4 = ComposerStaticInita6026d7805fa28dd437b7e92e52cc4a1::$prefixDirsPsr4;
|
37 |
+
$loader->classMap = ComposerStaticInita6026d7805fa28dd437b7e92e52cc4a1::$classMap;
|
38 |
|
39 |
}, null, ClassLoader::class);
|
40 |
}
|
vendor/composer/installed.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
<?php return array(
|
2 |
'root' => array(
|
3 |
-
'pretty_version' => 'dev-
|
4 |
-
'version' => 'dev-
|
5 |
'type' => 'wordpress-plugin',
|
6 |
'install_path' => __DIR__ . '/../../',
|
7 |
'aliases' => array(),
|
8 |
-
'reference' => '
|
9 |
'name' => 'premmerce/woo-permalink-manager',
|
10 |
'dev' => false,
|
11 |
),
|
12 |
'versions' => array(
|
13 |
'premmerce/woo-permalink-manager' => array(
|
14 |
-
'pretty_version' => 'dev-
|
15 |
-
'version' => 'dev-
|
16 |
'type' => 'wordpress-plugin',
|
17 |
'install_path' => __DIR__ . '/../../',
|
18 |
'aliases' => array(),
|
19 |
-
'reference' => '
|
20 |
'dev_requirement' => false,
|
21 |
),
|
22 |
'premmerce/wordpress-sdk' => array(
|
1 |
<?php return array(
|
2 |
'root' => array(
|
3 |
+
'pretty_version' => 'dev-develop',
|
4 |
+
'version' => 'dev-develop',
|
5 |
'type' => 'wordpress-plugin',
|
6 |
'install_path' => __DIR__ . '/../../',
|
7 |
'aliases' => array(),
|
8 |
+
'reference' => '9433134395b881ae7c40ef05b73a483a104bac6a',
|
9 |
'name' => 'premmerce/woo-permalink-manager',
|
10 |
'dev' => false,
|
11 |
),
|
12 |
'versions' => array(
|
13 |
'premmerce/woo-permalink-manager' => array(
|
14 |
+
'pretty_version' => 'dev-develop',
|
15 |
+
'version' => 'dev-develop',
|
16 |
'type' => 'wordpress-plugin',
|
17 |
'install_path' => __DIR__ . '/../../',
|
18 |
'aliases' => array(),
|
19 |
+
'reference' => '9433134395b881ae7c40ef05b73a483a104bac6a',
|
20 |
'dev_requirement' => false,
|
21 |
),
|
22 |
'premmerce/wordpress-sdk' => array(
|
woo-permalink-manager.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Premmerce Permalink Manager Slug fix
|
4 |
+
*
|
5 |
+
* This file is intended to fix a wrong plugin slug from an older version.
|
6 |
+
*
|
7 |
+
* @since 2.3.6
|
8 |
+
*/
|
9 |
+
|
10 |
+
add_action(
|
11 |
+
'plugins_loaded',
|
12 |
+
function() {
|
13 |
+
if ( ! function_exists( 'deactivate_plugins' ) ) {
|
14 |
+
include ABSPATH . 'wp-admin/includes/plugin.php';
|
15 |
+
}
|
16 |
+
|
17 |
+
// this file
|
18 |
+
$deactivate = plugin_basename( __FILE__ );
|
19 |
+
|
20 |
+
// correct file
|
21 |
+
$activate = dirname( $deactivate ) . '/premmerce-url-manager.php';
|
22 |
+
|
23 |
+
$network_wide = is_plugin_active_for_network( $deactivate );
|
24 |
+
|
25 |
+
// don't trigger (de)activation hooks
|
26 |
+
$silent = true;
|
27 |
+
|
28 |
+
deactivate_plugins( $deactivate, $silent, $network_wide );
|
29 |
+
activate_plugins( $activate, '', $network_wide, $silent );
|
30 |
+
|
31 |
+
}
|
32 |
+
);
|