Version Description
Download this release
Release Info
Developer | mbis |
Plugin | Permalink Manager Lite |
Version | 2.2.9.1 |
Comparing to | |
See all releases |
Code changes from version 2.2.8.9 to 2.2.9.1
- README.txt +12 -3
- includes/core/permalink-manager-actions.php +1 -1
- includes/core/permalink-manager-admin-functions.php +3 -3
- includes/core/permalink-manager-core-functions.php +5 -1
- includes/core/permalink-manager-gutenberg.php +0 -4
- includes/core/permalink-manager-helper-functions.php +58 -31
- includes/core/permalink-manager-third-parties.php +62 -3
- includes/core/permalink-manager-uri-functions-post.php +22 -15
- includes/views/permalink-manager-permastructs.php +1 -0
- permalink-manager.php +4 -4
README.txt
CHANGED
@@ -6,10 +6,10 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
6 |
Tags: permalinks, custom permalinks, url editor, permalinks, woocommerce permalinks
|
7 |
Requires at least: 4.4.0
|
8 |
Requires PHP: 5.4
|
9 |
-
Tested up to: 5.5.
|
10 |
-
Stable tag: 2.2.
|
11 |
|
12 |
-
Permalink Manager allows to easily change full URL addresses of posts, pages, custom post types, terms and WooCommerce links. You can also set different permalink formats per language or bulk change the URLs.
|
13 |
|
14 |
== Description ==
|
15 |
|
@@ -103,6 +103,15 @@ It is because Permalink Manager overwrites one of the core Wordpress functionali
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
= 2.2.8.8/2.2.8.9 =
|
107 |
* Hotfix for 'redirect_canonical' function (causing a redirect loop)
|
108 |
* The custom canonical permalink set with Yoast SEO is now no longer overwriten
|
6 |
Tags: permalinks, custom permalinks, url editor, permalinks, woocommerce permalinks
|
7 |
Requires at least: 4.4.0
|
8 |
Requires PHP: 5.4
|
9 |
+
Tested up to: 5.5.1
|
10 |
+
Stable tag: 2.2.9.0
|
11 |
|
12 |
+
Permalink Manager Pro allows to easily change full URL addresses of posts, pages, custom post types, terms and WooCommerce links. You can also set different permalink formats per language or bulk change the URLs.
|
13 |
|
14 |
== Description ==
|
15 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 2.2.9.0/2.2.9.1 =
|
107 |
+
* Basic support for BasePress added
|
108 |
+
* Added support for custom product attributes in products' permalinks (WooCommerce)
|
109 |
+
* "Trailing slash redirect" is now disabled on front pages (to prevent redirect loop on Polylang/WPML language front pages)
|
110 |
+
* The taxonomy term used in custom permalinks is selected differently
|
111 |
+
* Performance improvements (duplicate-check function)
|
112 |
+
* Further improvements for the function used to sanitize the custom permalinks
|
113 |
+
* Codebase improvements
|
114 |
+
|
115 |
= 2.2.8.8/2.2.8.9 =
|
116 |
* Hotfix for 'redirect_canonical' function (causing a redirect loop)
|
117 |
* The custom canonical permalink set with Yoast SEO is now no longer overwriten
|
includes/core/permalink-manager-actions.php
CHANGED
@@ -639,7 +639,7 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
|
|
639 |
} else if(!empty($_REQUEST['custom_uri']) && !empty($_REQUEST['element_id'])) {
|
640 |
$is_duplicated = Permalink_Manager_Helper_Functions::is_uri_duplicated($uri, $element_id);
|
641 |
|
642 |
-
echo ($is_duplicated) ? $duplicate_alert : 0
|
643 |
}
|
644 |
|
645 |
die();
|
639 |
} else if(!empty($_REQUEST['custom_uri']) && !empty($_REQUEST['element_id'])) {
|
640 |
$is_duplicated = Permalink_Manager_Helper_Functions::is_uri_duplicated($uri, $element_id);
|
641 |
|
642 |
+
echo ($is_duplicated) ? $duplicate_alert : 0;
|
643 |
}
|
644 |
|
645 |
die();
|
includes/core/permalink-manager-admin-functions.php
CHANGED
@@ -17,7 +17,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
|
|
17 |
add_action( 'admin_notices', array($this, 'display_global_notices'));
|
18 |
add_action( 'wp_ajax_dismissed_notice_handler', array($this, 'hide_global_notice') );
|
19 |
|
20 |
-
add_filter( 'default_hidden_columns', array($this, 'quick_edit_hide_column'),
|
21 |
}
|
22 |
|
23 |
/**
|
@@ -38,7 +38,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
|
|
38 |
*/
|
39 |
public function fix_customize_url($wp_admin_bar) {
|
40 |
$object = get_queried_object();
|
41 |
-
|
42 |
$customize = $wp_admin_bar->get_node('customize');
|
43 |
|
44 |
if(empty($customize->href)) { return; }
|
@@ -1013,7 +1013,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
|
|
1013 |
if(class_exists('Permalink_Manager_Pro_Functions')) {
|
1014 |
$exp_date = Permalink_Manager_Pro_Functions::get_expiration_date(true);
|
1015 |
|
1016 |
-
$is_pro = ($exp_date >
|
1017 |
} else {
|
1018 |
$is_pro = false;
|
1019 |
}
|
17 |
add_action( 'admin_notices', array($this, 'display_global_notices'));
|
18 |
add_action( 'wp_ajax_dismissed_notice_handler', array($this, 'hide_global_notice') );
|
19 |
|
20 |
+
add_filter( 'default_hidden_columns', array($this, 'quick_edit_hide_column'), 99, 2 );
|
21 |
}
|
22 |
|
23 |
/**
|
38 |
*/
|
39 |
public function fix_customize_url($wp_admin_bar) {
|
40 |
$object = get_queried_object();
|
41 |
+
|
42 |
$customize = $wp_admin_bar->get_node('customize');
|
43 |
|
44 |
if(empty($customize->href)) { return; }
|
1013 |
if(class_exists('Permalink_Manager_Pro_Functions')) {
|
1014 |
$exp_date = Permalink_Manager_Pro_Functions::get_expiration_date(true);
|
1015 |
|
1016 |
+
$is_pro = ($exp_date > 1) ? false : true;
|
1017 |
} else {
|
1018 |
$is_pro = false;
|
1019 |
}
|
includes/core/permalink-manager-core-functions.php
CHANGED
@@ -387,6 +387,10 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
387 |
foreach($get_endpoints as $endpoint) {
|
388 |
// Numeric endpoints
|
389 |
$endpoint_value = (in_array($endpoint, array('page', 'paged', 'attachment_id'))) ? filter_var($_GET[$endpoint], FILTER_SANITIZE_NUMBER_INT) : $_GET[$endpoint];
|
|
|
|
|
|
|
|
|
390 |
$query[$endpoint] = sanitize_text_field($endpoint_value);
|
391 |
}
|
392 |
}
|
@@ -759,7 +763,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
759 |
|
760 |
// Check if any endpoint is called (fix for feed and similar endpoints)
|
761 |
foreach($endpoints_array as $endpoint) {
|
762 |
-
if(!empty($wp->query_vars[$endpoint]) && $endpoint
|
763 |
$wp->query_vars['do_not_redirect'] = 1;
|
764 |
break;
|
765 |
}
|
387 |
foreach($get_endpoints as $endpoint) {
|
388 |
// Numeric endpoints
|
389 |
$endpoint_value = (in_array($endpoint, array('page', 'paged', 'attachment_id'))) ? filter_var($_GET[$endpoint], FILTER_SANITIZE_NUMBER_INT) : $_GET[$endpoint];
|
390 |
+
|
391 |
+
// Ignore page endpoint if its value is 1
|
392 |
+
if(in_array($endpoint, array('page', 'paged')) && $endpoint_value == 1) { continue; }
|
393 |
+
|
394 |
$query[$endpoint] = sanitize_text_field($endpoint_value);
|
395 |
}
|
396 |
}
|
763 |
|
764 |
// Check if any endpoint is called (fix for feed and similar endpoints)
|
765 |
foreach($endpoints_array as $endpoint) {
|
766 |
+
if(!empty($wp->query_vars[$endpoint]) && !in_array($endpoint, array('attachment', 'page', 'paged'))) {
|
767 |
$wp->query_vars['do_not_redirect'] = 1;
|
768 |
break;
|
769 |
}
|
includes/core/permalink-manager-gutenberg.php
CHANGED
@@ -26,10 +26,6 @@ class Permalink_Manager_Gutenberg extends Permalink_Manager_Class {
|
|
26 |
add_meta_box('permalink-manager', __('Permalink Manager', 'permalink-manager'), array($this, 'meta_box'), '', 'side', 'high' );
|
27 |
}
|
28 |
|
29 |
-
public function pm_gutenberg_scripts() {
|
30 |
-
wp_enqueue_script('permalink-manager-gutenberg', PERMALINK_MANAGER_URL . '/out/permalink-manager-gutenberg.js', array('wp-blocks', 'wp-element', 'wp-components', 'wp-i18n'), PERMALINK_MANAGER_VERSION, true);
|
31 |
-
}
|
32 |
-
|
33 |
public function meta_box($post) {
|
34 |
global $permalink_manager_uris;
|
35 |
|
26 |
add_meta_box('permalink-manager', __('Permalink Manager', 'permalink-manager'), array($this, 'meta_box'), '', 'side', 'high' );
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
29 |
public function meta_box($post) {
|
30 |
global $permalink_manager_uris;
|
31 |
|
includes/core/permalink-manager-helper-functions.php
CHANGED
@@ -122,7 +122,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
122 |
$mode = (is_taxonomy_hierarchical($taxonomy)) ? 2 : 4;
|
123 |
}
|
124 |
|
125 |
-
// A.
|
126 |
if($mode == 1) {
|
127 |
$term_slug = $permalink_manager_uris["tax-{$term->term_id}"];
|
128 |
}
|
@@ -142,18 +142,32 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
142 |
$last_term_slug = ($native_uri) ? $term->slug : self::force_custom_slugs($term->slug, $term);
|
143 |
$term_slug = "{$term_slug}/{$last_term_slug}";
|
144 |
}
|
145 |
-
// C. Force flat taxonomy base - get
|
146 |
-
else if($mode ==
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
151 |
}
|
152 |
}
|
|
|
|
|
153 |
}
|
154 |
-
// D.
|
155 |
-
else
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
|
159 |
return (!empty($term_slug)) ? $term_slug : "";
|
@@ -450,18 +464,14 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
450 |
$sanitize_slugs = (!empty($permalink_manager_options['general']['disable_slug_sanitization'])) ? false : true;
|
451 |
}
|
452 |
|
453 |
-
// Trim slashes & whitespaces
|
454 |
-
$clean = trim($str, " /");
|
455 |
-
|
456 |
// Remove accents & entities
|
457 |
-
$clean = (empty($permalink_manager_options['general']['keep_accents'])) ? remove_accents($
|
458 |
$clean = str_replace(array('<', '>', '&'), '', $clean);
|
459 |
|
460 |
$percent_sign = ($keep_percent_sign) ? "\%" : "";
|
461 |
-
//$sanitize_regex = apply_filters("permalink_manager_sanitize_regex", "/[^\p{Thai}\p{Greek}\p{Hebrew}\p{Arabic}\p{Cyrillic}a-zA-Z0-9{$percent_sign}\/_\.|+, -]/u", $percent_sign);
|
462 |
$sanitize_regex = apply_filters("permalink_manager_sanitize_regex", "/[^\p{Xan}a-zA-Z0-9{$percent_sign}\/_\.|+, -]/ui", $percent_sign);
|
463 |
$clean = preg_replace($sanitize_regex, '', $clean);
|
464 |
-
$clean = ($force_lowercase) ? strtolower(
|
465 |
|
466 |
// Remove amperand
|
467 |
$clean = str_replace(array('%26', '&'), '', $clean);
|
@@ -476,8 +486,12 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
476 |
$clean = preg_replace("/[\s]+/", "-", $clean);
|
477 |
}
|
478 |
|
479 |
-
// Remove
|
480 |
-
$clean =
|
|
|
|
|
|
|
|
|
481 |
|
482 |
return $clean;
|
483 |
}
|
@@ -598,7 +612,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
598 |
$duplicated_ids = array_keys($all_uris, $duplicated_uri);
|
599 |
|
600 |
// Ignore duplicates in different langauges
|
601 |
-
if(self::is_uri_duplicated($duplicated_uri, $duplicated_ids[0])) {
|
602 |
$duplicates_groups[$duplicated_uri] = $duplicated_ids;
|
603 |
}
|
604 |
}
|
@@ -610,35 +624,49 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
610 |
/**
|
611 |
* Check if a single URI is duplicated
|
612 |
*/
|
613 |
-
public static function is_uri_duplicated($uri, $element_id) {
|
614 |
global $permalink_manager_uris;
|
615 |
|
616 |
-
if(empty($uri) || empty($element_id)) { return false; }
|
617 |
|
618 |
$uri = trim(trim(sanitize_text_field($uri)), "/");
|
619 |
$element_id = sanitize_text_field($element_id);
|
620 |
|
621 |
-
// Keep the URIs in a separate array just here
|
622 |
-
|
623 |
-
|
|
|
|
|
|
|
624 |
|
625 |
-
if(
|
626 |
-
|
627 |
$this_uri_lang = Permalink_Manager_Language_Plugins::get_language_code($element_id);
|
628 |
|
629 |
if($this_uri_lang) {
|
630 |
foreach($all_duplicates as $key => $duplicated_id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
631 |
$duplicated_uri_lang = Permalink_Manager_Language_Plugins::get_language_code($duplicated_id);
|
632 |
|
633 |
-
|
|
|
634 |
unset($all_duplicates[$key]);
|
635 |
}
|
636 |
}
|
|
|
637 |
|
638 |
-
|
639 |
-
|
640 |
-
|
|
|
641 |
}
|
|
|
|
|
642 |
} else {
|
643 |
return false;
|
644 |
}
|
@@ -681,5 +709,4 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
681 |
}
|
682 |
}
|
683 |
|
684 |
-
|
685 |
}
|
122 |
$mode = (is_taxonomy_hierarchical($taxonomy)) ? 2 : 4;
|
123 |
}
|
124 |
|
125 |
+
// A. Inherit the custom permalink from the term
|
126 |
if($mode == 1) {
|
127 |
$term_slug = $permalink_manager_uris["tax-{$term->term_id}"];
|
128 |
}
|
142 |
$last_term_slug = ($native_uri) ? $term->slug : self::force_custom_slugs($term->slug, $term);
|
143 |
$term_slug = "{$term_slug}/{$last_term_slug}";
|
144 |
}
|
145 |
+
// C. Force flat taxonomy base - get highest level term (if %taxonomy_top% tag is used)
|
146 |
+
else if($mode == 3) {
|
147 |
+
if(!empty($term->parent)) {
|
148 |
+
$ancestors = get_ancestors($term->term_id, $taxonomy, 'taxonomy');
|
149 |
+
|
150 |
+
if(is_array($ancestors)) {
|
151 |
+
$top_ancestor = end($ancestors);
|
152 |
+
$top_ancestor_term = get_term($top_ancestor, $taxonomy);
|
153 |
+
$single_term = (!empty($top_ancestor_term->slug)) ? $top_ancestor_term : $term;
|
154 |
}
|
155 |
}
|
156 |
+
|
157 |
+
$term_slug = (!empty($single_term->slug)) ? self::force_custom_slugs($single_term->slug, $single_term) : $term->slug;
|
158 |
}
|
159 |
+
// D. Force flat taxonomy base - get primary or lowest level term (if term is non-hierarchical or %taxonomy_flat% tag is used)
|
160 |
+
else {
|
161 |
+
if(!empty($term->slug)) {
|
162 |
+
$term_slug = ($native_uri) ? $term->slug : Permalink_Manager_Helper_Functions::force_custom_slugs($term->slug, $term);
|
163 |
+
} else {
|
164 |
+
foreach($terms as $single_term) {
|
165 |
+
if($single_term->parent == 0) {
|
166 |
+
$term_slug = self::force_custom_slugs($single_term->slug, $single_term);
|
167 |
+
break;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
}
|
172 |
|
173 |
return (!empty($term_slug)) ? $term_slug : "";
|
464 |
$sanitize_slugs = (!empty($permalink_manager_options['general']['disable_slug_sanitization'])) ? false : true;
|
465 |
}
|
466 |
|
|
|
|
|
|
|
467 |
// Remove accents & entities
|
468 |
+
$clean = (empty($permalink_manager_options['general']['keep_accents'])) ? remove_accents($str) : $str;
|
469 |
$clean = str_replace(array('<', '>', '&'), '', $clean);
|
470 |
|
471 |
$percent_sign = ($keep_percent_sign) ? "\%" : "";
|
|
|
472 |
$sanitize_regex = apply_filters("permalink_manager_sanitize_regex", "/[^\p{Xan}a-zA-Z0-9{$percent_sign}\/_\.|+, -]/ui", $percent_sign);
|
473 |
$clean = preg_replace($sanitize_regex, '', $clean);
|
474 |
+
$clean = ($force_lowercase) ? strtolower($clean) : $clean;
|
475 |
|
476 |
// Remove amperand
|
477 |
$clean = str_replace(array('%26', '&'), '', $clean);
|
486 |
$clean = preg_replace("/[\s]+/", "-", $clean);
|
487 |
}
|
488 |
|
489 |
+
// Remove widow & duplicated slashes
|
490 |
+
$clean = preg_replace('/([-]*[\/]+[-]*)/', '/', $clean);
|
491 |
+
$clean = preg_replace('/([\/]+)/', '/', $clean);
|
492 |
+
|
493 |
+
// Trim slashes, dashes and whitespaces
|
494 |
+
$clean = trim($clean, " /-");
|
495 |
|
496 |
return $clean;
|
497 |
}
|
612 |
$duplicated_ids = array_keys($all_uris, $duplicated_uri);
|
613 |
|
614 |
// Ignore duplicates in different langauges
|
615 |
+
if(self::is_uri_duplicated($duplicated_uri, $duplicated_ids[0], $duplicated_ids)) {
|
616 |
$duplicates_groups[$duplicated_uri] = $duplicated_ids;
|
617 |
}
|
618 |
}
|
624 |
/**
|
625 |
* Check if a single URI is duplicated
|
626 |
*/
|
627 |
+
public static function is_uri_duplicated($uri, $element_id, $duplicated_ids = array()) {
|
628 |
global $permalink_manager_uris;
|
629 |
|
630 |
+
if(empty($uri) || empty($element_id) || empty($permalink_manager_uris)) { return false; }
|
631 |
|
632 |
$uri = trim(trim(sanitize_text_field($uri)), "/");
|
633 |
$element_id = sanitize_text_field($element_id);
|
634 |
|
635 |
+
// Keep the URIs in a separate array just here
|
636 |
+
if(!empty($duplicated_ids)) {
|
637 |
+
$all_duplicates = $duplicated_ids;
|
638 |
+
} else if(in_array($uri, $permalink_manager_uris)) {
|
639 |
+
$all_duplicates = array_keys($permalink_manager_uris, $uri);
|
640 |
+
}
|
641 |
|
642 |
+
if(!empty($all_duplicates)) {
|
643 |
+
// Get the language code of current element
|
644 |
$this_uri_lang = Permalink_Manager_Language_Plugins::get_language_code($element_id);
|
645 |
|
646 |
if($this_uri_lang) {
|
647 |
foreach($all_duplicates as $key => $duplicated_id) {
|
648 |
+
// Ignore custom redirects
|
649 |
+
if(strpos($key, 'redirect-') !== false) {
|
650 |
+
unset($all_duplicates[$key]);
|
651 |
+
continue;
|
652 |
+
}
|
653 |
+
|
654 |
$duplicated_uri_lang = Permalink_Manager_Language_Plugins::get_language_code($duplicated_id);
|
655 |
|
656 |
+
// Ignore the other elements in other languages to prevent the false alert
|
657 |
+
if($duplicated_uri_lang !== $this_uri_lang) {
|
658 |
unset($all_duplicates[$key]);
|
659 |
}
|
660 |
}
|
661 |
+
}
|
662 |
|
663 |
+
// Ignore the URI for requested element to prevent the false alert
|
664 |
+
if(in_array($element_id, $all_duplicates)) {
|
665 |
+
$this_element_key = array_search($element_id, $all_duplicates);
|
666 |
+
unset($all_duplicates[$this_element_key]);
|
667 |
}
|
668 |
+
|
669 |
+
return (count($all_duplicates) > 0) ? true : false;
|
670 |
} else {
|
671 |
return false;
|
672 |
}
|
709 |
}
|
710 |
}
|
711 |
|
|
|
712 |
}
|
includes/core/permalink-manager-third-parties.php
CHANGED
@@ -39,6 +39,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
39 |
}
|
40 |
|
41 |
add_action('woocommerce_product_import_inserted_product_object', array($this, 'woocommerce_generate_permalinks_after_import'), 9, 2);
|
|
|
42 |
|
43 |
if(wp_doing_ajax() && class_exists('SitePress')) {
|
44 |
add_filter('permalink_manager_filter_final_post_permalink', array($this, 'woocommerce_translate_ajax_fragments_urls'), 9999, 3);
|
@@ -120,6 +121,11 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
120 |
if(class_exists('GeoDirectory')) {
|
121 |
add_filter('permalink_manager_filter_default_post_uri', array($this, 'geodir_custom_fields'), 5, 5 );
|
122 |
}
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
/**
|
@@ -355,6 +361,29 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
355 |
}
|
356 |
}
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
function woocommerce_translate_ajax_fragments_urls($permalink, $post, $old_permalink) {
|
359 |
// Use it only if the permalinks are different
|
360 |
if($permalink == $old_permalink || $post->post_type !== 'page') {
|
@@ -876,7 +905,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
876 |
function ml_set_listing_uri($post_id) {
|
877 |
global $permalink_manager_uris;
|
878 |
|
879 |
-
if(!empty($permalink_manager_uris)) {
|
880 |
$default_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($post_id);
|
881 |
|
882 |
if($default_uri) {
|
@@ -896,7 +925,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
896 |
|
897 |
// Check if any MyListing taxonomy was detected
|
898 |
foreach($taxonomies as $taxonomy) {
|
899 |
-
if(!empty($query[$taxonomy])) {
|
900 |
return array(
|
901 |
"page_id" => $explore_page_id,
|
902 |
"explore_tab" => $taxonomy,
|
@@ -1020,7 +1049,37 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
1020 |
}
|
1021 |
|
1022 |
/**
|
1023 |
-
* 16.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1024 |
*/
|
1025 |
public function wpsl_regenerate_after_import($meta_id, $post_id, $meta_key, $meta_value) {
|
1026 |
global $permalink_manager_uris;
|
39 |
}
|
40 |
|
41 |
add_action('woocommerce_product_import_inserted_product_object', array($this, 'woocommerce_generate_permalinks_after_import'), 9, 2);
|
42 |
+
add_filter('permalink_manager_filter_default_post_uri', array($this, 'woocommerce_product_attributes'), 5, 5);
|
43 |
|
44 |
if(wp_doing_ajax() && class_exists('SitePress')) {
|
45 |
add_filter('permalink_manager_filter_final_post_permalink', array($this, 'woocommerce_translate_ajax_fragments_urls'), 9999, 3);
|
121 |
if(class_exists('GeoDirectory')) {
|
122 |
add_filter('permalink_manager_filter_default_post_uri', array($this, 'geodir_custom_fields'), 5, 5 );
|
123 |
}
|
124 |
+
|
125 |
+
// 16. BasePress
|
126 |
+
if(class_exists('Basepress')) {
|
127 |
+
add_filter('permalink_manager_filter_query', array($this, 'kb_adjust_query'), 5, 5);
|
128 |
+
}
|
129 |
}
|
130 |
|
131 |
/**
|
361 |
}
|
362 |
}
|
363 |
|
364 |
+
function woocommerce_product_attributes($default_uri, $slug, $post, $post_name, $native_uri) {
|
365 |
+
// Do not affect native URIs
|
366 |
+
if($native_uri == true) { return $default_uri; }
|
367 |
+
|
368 |
+
// Use only for products
|
369 |
+
if(empty($post->post_type) || $post->post_type !== 'product') { return $default_uri; }
|
370 |
+
|
371 |
+
preg_match_all("/%pa_(.[^\%]+)%/", $default_uri, $custom_fields);
|
372 |
+
|
373 |
+
if(!empty($custom_fields[1])) {
|
374 |
+
$product = wc_get_product($post->ID);
|
375 |
+
|
376 |
+
foreach($custom_fields[1] as $i => $custom_field) {
|
377 |
+
$attribute_name = sanitize_title($custom_field);
|
378 |
+
$attribute_value = $product->get_attribute($attribute_name);
|
379 |
+
|
380 |
+
$default_uri = str_replace($custom_fields[0][$i], Permalink_Manager_Helper_Functions::sanitize_title($attribute_value), $default_uri);
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
return $default_uri;
|
385 |
+
}
|
386 |
+
|
387 |
function woocommerce_translate_ajax_fragments_urls($permalink, $post, $old_permalink) {
|
388 |
// Use it only if the permalinks are different
|
389 |
if($permalink == $old_permalink || $post->post_type !== 'page') {
|
905 |
function ml_set_listing_uri($post_id) {
|
906 |
global $permalink_manager_uris;
|
907 |
|
908 |
+
if(!empty($permalink_manager_uris) && empty($permalink_manager_uris[$post_id])) {
|
909 |
$default_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($post_id);
|
910 |
|
911 |
if($default_uri) {
|
925 |
|
926 |
// Check if any MyListing taxonomy was detected
|
927 |
foreach($taxonomies as $taxonomy) {
|
928 |
+
if(!empty($query[$taxonomy]) && empty($_GET[$taxonomy])) {
|
929 |
return array(
|
930 |
"page_id" => $explore_page_id,
|
931 |
"explore_tab" => $taxonomy,
|
1049 |
}
|
1050 |
|
1051 |
/**
|
1052 |
+
* 16. BasePress
|
1053 |
+
*/
|
1054 |
+
function kb_adjust_query($query, $old_query, $uri_parts, $pm_query, $content_type) {
|
1055 |
+
$knowledgebase_options = get_option('basepress_settings');
|
1056 |
+
$knowledgebase_page = (!empty($knowledgebase_options['entry_page'])) ? $knowledgebase_options['entry_page'] : '';
|
1057 |
+
|
1058 |
+
// A. Knowledgebase category
|
1059 |
+
if(isset($query['knowledgebase_cat']) && !empty($pm_query['id']) && strpos($pm_query['id'], 'tax-') !== false) {
|
1060 |
+
$query['post_type'] = 'knowledgebase';
|
1061 |
+
unset($query['taxonomy']);
|
1062 |
+
unset($query['term']);
|
1063 |
+
|
1064 |
+
$term_id = intval(preg_replace("/[^0-9]/", "", $pm_query['id']));
|
1065 |
+
$term = get_term($term_id);
|
1066 |
+
|
1067 |
+
if(empty($term->parent)) {
|
1068 |
+
$query['is_knowledgebase_product'] = 1;
|
1069 |
+
}
|
1070 |
+
}
|
1071 |
+
// B. Knowledgebase main page
|
1072 |
+
else if(!empty($knowledgebase_page) && !empty($pm_query['id']) && $pm_query['id'] == $knowledgebase_page) {
|
1073 |
+
$query = array(
|
1074 |
+
'page_id' => $knowledgebase_page
|
1075 |
+
);
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
return $query;
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
/**
|
1082 |
+
* 17. Store Locator - CSV Manager
|
1083 |
*/
|
1084 |
public function wpsl_regenerate_after_import($meta_id, $post_id, $meta_key, $meta_value) {
|
1085 |
global $permalink_manager_uris;
|
includes/core/permalink-manager-uri-functions-post.php
CHANGED
@@ -280,16 +280,27 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
280 |
// 0. Check if taxonomy tag is present
|
281 |
if(strpos($default_uri, "%{$taxonomy}") === false) { continue; }
|
282 |
|
283 |
-
// 1. Reset $replacement
|
284 |
$replacement = $replacement_term = "";
|
285 |
$terms = wp_get_object_terms($post->ID, $taxonomy);
|
286 |
|
287 |
-
// 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
$replacement_term = $primary_term = Permalink_Manager_Helper_Functions::get_primary_term($post->ID, $taxonomy, false);
|
289 |
|
290 |
-
//
|
291 |
if(empty($replacement_term)) {
|
292 |
-
$replacement_term = (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) ? Permalink_Manager_Helper_Functions::get_lowest_element($terms[0], $terms) :
|
293 |
$replacement_term = apply_filters('permalink_manager_filter_post_terms', $replacement_term, $post, $terms, $taxonomy, $native_uri);
|
294 |
}
|
295 |
|
@@ -298,21 +309,16 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
298 |
$mode = 1;
|
299 |
}
|
300 |
// 4B. Hierarhcical term base
|
301 |
-
else if(!empty($replacement_term->term_id) && strpos($default_uri, "%{$taxonomy}_flat%") === false && is_taxonomy_hierarchical($taxonomy)) {
|
302 |
$mode = 2;
|
303 |
}
|
304 |
-
// 4C. Force flat/non-hierarchical term base - get
|
305 |
-
else if(
|
306 |
$mode = 3;
|
307 |
}
|
308 |
-
// 4D.
|
309 |
-
else if(empty($primary_term->slug)) {
|
310 |
-
$mode = 4;
|
311 |
-
}
|
312 |
-
// 4E. Flat/non-hierarchical term base - get and force primary term (if set)
|
313 |
else {
|
314 |
-
$mode =
|
315 |
-
$replacement_term = $primary_term;
|
316 |
}
|
317 |
|
318 |
// Get the replacement slug (custom + native)
|
@@ -327,7 +333,8 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
327 |
$replacement = apply_filters('permalink_manager_filter_term_slug', $replacement, $replacement_term, $post, $terms, $taxonomy, $native_uri);
|
328 |
|
329 |
// 4. Do the replacement
|
330 |
-
$default_uri = (!empty($replacement)) ? str_replace(array("%{$taxonomy}%", "%{$taxonomy}_flat%", "%{$taxonomy}_custom_uri%", "%{$taxonomy}
|
|
|
331 |
}
|
332 |
}
|
333 |
|
280 |
// 0. Check if taxonomy tag is present
|
281 |
if(strpos($default_uri, "%{$taxonomy}") === false) { continue; }
|
282 |
|
283 |
+
// 1. Reset $replacement variable
|
284 |
$replacement = $replacement_term = "";
|
285 |
$terms = wp_get_object_terms($post->ID, $taxonomy);
|
286 |
|
287 |
+
// 2. Sort the terms
|
288 |
+
if(!empty($terms)) {
|
289 |
+
$terms = wp_list_sort(
|
290 |
+
$terms,
|
291 |
+
array(
|
292 |
+
'parent' => 'DESC',
|
293 |
+
'term_id' => 'ASC',
|
294 |
+
)
|
295 |
+
);
|
296 |
+
}
|
297 |
+
|
298 |
+
// 3A. Try to use Yoast SEO Primary Term
|
299 |
$replacement_term = $primary_term = Permalink_Manager_Helper_Functions::get_primary_term($post->ID, $taxonomy, false);
|
300 |
|
301 |
+
// 3B. Get the first assigned term to this taxonomy
|
302 |
if(empty($replacement_term)) {
|
303 |
+
$replacement_term = (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) ? Permalink_Manager_Helper_Functions::get_lowest_element($terms[0], $terms) : '';
|
304 |
$replacement_term = apply_filters('permalink_manager_filter_post_terms', $replacement_term, $post, $terms, $taxonomy, $native_uri);
|
305 |
}
|
306 |
|
309 |
$mode = 1;
|
310 |
}
|
311 |
// 4B. Hierarhcical term base
|
312 |
+
else if(!empty($replacement_term->term_id) && strpos($default_uri, "%{$taxonomy}_flat%") === false && strpos($default_uri, "%{$taxonomy}_top%") === false && is_taxonomy_hierarchical($taxonomy)) {
|
313 |
$mode = 2;
|
314 |
}
|
315 |
+
// 4C. Force flat/non-hierarchical term base - get highest level term (if %taxonomy_top% tag is used)
|
316 |
+
else if(strpos($default_uri, "%{$taxonomy}_top%") !== false) {
|
317 |
$mode = 3;
|
318 |
}
|
319 |
+
// 4D. Force flat/non-hierarchical term base - get lowest level term (if %taxonomy_flat% tag is used)
|
|
|
|
|
|
|
|
|
320 |
else {
|
321 |
+
$mode = 4;
|
|
|
322 |
}
|
323 |
|
324 |
// Get the replacement slug (custom + native)
|
333 |
$replacement = apply_filters('permalink_manager_filter_term_slug', $replacement, $replacement_term, $post, $terms, $taxonomy, $native_uri);
|
334 |
|
335 |
// 4. Do the replacement
|
336 |
+
$default_uri = (!empty($replacement)) ? str_replace(array("%{$taxonomy}%", "%{$taxonomy}_flat%", "%{$taxonomy}_custom_uri%", "%{$taxonomy}_top%"), $replacement, $default_uri) : $default_uri;
|
337 |
+
$default_uri = (!empty($native_replacement)) ? str_replace("%{$taxonomy}_native_slug%", $native_replacement, $default_uri) : $default_uri;
|
338 |
}
|
339 |
}
|
340 |
|
includes/views/permalink-manager-permastructs.php
CHANGED
@@ -52,6 +52,7 @@ class Permalink_Manager_Permastructs extends Permalink_Manager_Class {
|
|
52 |
|
53 |
// 3. Append fields for all post types
|
54 |
foreach($all_post_types as $post_type) {
|
|
|
55 |
|
56 |
$fields["post_types"]["fields"][$post_type['name']] = array(
|
57 |
'label' => $post_type['label'],
|
52 |
|
53 |
// 3. Append fields for all post types
|
54 |
foreach($all_post_types as $post_type) {
|
55 |
+
if($post_type['name'] == 'shop_coupon') { continue; }
|
56 |
|
57 |
$fields["post_types"]["fields"][$post_type['name']] = array(
|
58 |
'label' => $post_type['label'],
|
permalink-manager.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Permalink Manager Lite
|
5 |
* Plugin URI: https://permalinkmanager.pro?utm_source=plugin
|
6 |
* Description: Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
|
7 |
-
* Version: 2.2.
|
8 |
* Author: Maciej Bis
|
9 |
* Author URI: http://maciejbis.net/
|
10 |
* License: GPL-2.0+
|
@@ -12,7 +12,7 @@
|
|
12 |
* Text Domain: permalink-manager
|
13 |
* Domain Path: /languages
|
14 |
* WC requires at least: 3.0.0
|
15 |
-
* WC tested up to: 4.
|
16 |
*/
|
17 |
|
18 |
// If this file is called directly or plugin is already defined, abort.
|
@@ -25,7 +25,7 @@ if(!class_exists('Permalink_Manager_Class')) {
|
|
25 |
// Define the directories used to load plugin files.
|
26 |
define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'Permalink Manager' );
|
27 |
define( 'PERMALINK_MANAGER_PLUGIN_SLUG', 'permalink-manager' );
|
28 |
-
define( 'PERMALINK_MANAGER_VERSION', '2.2.
|
29 |
define( 'PERMALINK_MANAGER_FILE', __FILE__ );
|
30 |
define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
|
31 |
define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__));
|
@@ -348,6 +348,6 @@ if(!class_exists('Permalink_Manager_Class')) {
|
|
348 |
|
349 |
$permalink_manager = new Permalink_Manager_Class();
|
350 |
}
|
351 |
-
run_permalink_manager();
|
352 |
|
|
|
353 |
}
|
4 |
* Plugin Name: Permalink Manager Lite
|
5 |
* Plugin URI: https://permalinkmanager.pro?utm_source=plugin
|
6 |
* Description: Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
|
7 |
+
* Version: 2.2.9.1
|
8 |
* Author: Maciej Bis
|
9 |
* Author URI: http://maciejbis.net/
|
10 |
* License: GPL-2.0+
|
12 |
* Text Domain: permalink-manager
|
13 |
* Domain Path: /languages
|
14 |
* WC requires at least: 3.0.0
|
15 |
+
* WC tested up to: 4.5.2
|
16 |
*/
|
17 |
|
18 |
// If this file is called directly or plugin is already defined, abort.
|
25 |
// Define the directories used to load plugin files.
|
26 |
define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'Permalink Manager' );
|
27 |
define( 'PERMALINK_MANAGER_PLUGIN_SLUG', 'permalink-manager' );
|
28 |
+
define( 'PERMALINK_MANAGER_VERSION', '2.2.9.1' );
|
29 |
define( 'PERMALINK_MANAGER_FILE', __FILE__ );
|
30 |
define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
|
31 |
define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__));
|
348 |
|
349 |
$permalink_manager = new Permalink_Manager_Class();
|
350 |
}
|
|
|
351 |
|
352 |
+
run_permalink_manager();
|
353 |
}
|