Version Description
- The URIs for trashed posts are now correctly removed
- Better support for non-ASCII characters in URIs
- Minor fix for hierarchical post types
Download this release
Release Info
Developer | mbis |
Plugin | Permalink Manager Lite |
Version | 2.0.5.6 |
Comparing to | |
See all releases |
Code changes from version 2.0.5.5 to 2.0.5.6
- README.txt +9 -2
- includes/core/permalink-manager-core-functions.php +9 -7
- includes/core/permalink-manager-helper-functions.php +22 -8
- includes/core/permalink-manager-third-parties.php +10 -3
- includes/core/permalink-manager-uri-functions-post.php +36 -26
- includes/views/permalink-manager-settings.php +1 -1
- permalink-manager.php +3 -3
README.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
=== Permalink Manager ===
|
2 |
Contributors: mbis
|
3 |
Donate link: https://www.paypal.me/Bismit
|
4 |
License: GPLv3
|
@@ -7,7 +7,7 @@ Tags: urls, permalinks, custom permalinks, url, permalink, woocommerce permalink
|
|
7 |
Requires at least: 4.0
|
8 |
Requires PHP: 5.4
|
9 |
Tested up to: 4.9
|
10 |
-
Stable tag: 2.0.5.
|
11 |
|
12 |
Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
|
13 |
|
@@ -98,11 +98,18 @@ A. Currently there is no 100% guarantee that Permalink Manager will work correct
|
|
98 |
|
99 |
== Changelog ==
|
100 |
|
|
|
|
|
|
|
|
|
|
|
101 |
= 2.0.5.5 =
|
102 |
* Discount URLs for WooCommerce - now the shop clients can use coupons' custom URIs to easily apply the discount to the cart
|
103 |
* Extra AJAX check for duplicated URIs in "Edit URI" box
|
104 |
* Wordpress CronJobs for "Automatically remove duplicates" functionality
|
105 |
* Extra improvements in "save_post/update_term" hooks
|
|
|
|
|
106 |
|
107 |
= 2.0.5.4 =
|
108 |
* New filter - "permalink_manager_empty_tag_replacement"
|
1 |
+
=== Permalink Manager Lite ===
|
2 |
Contributors: mbis
|
3 |
Donate link: https://www.paypal.me/Bismit
|
4 |
License: GPLv3
|
7 |
Requires at least: 4.0
|
8 |
Requires PHP: 5.4
|
9 |
Tested up to: 4.9
|
10 |
+
Stable tag: 2.0.5.6
|
11 |
|
12 |
Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
|
13 |
|
98 |
|
99 |
== Changelog ==
|
100 |
|
101 |
+
= 2.0.5.6 =
|
102 |
+
* The URIs for trashed posts are now correctly removed
|
103 |
+
* Better support for non-ASCII characters in URIs
|
104 |
+
* Minor fix for hierarchical post types
|
105 |
+
|
106 |
= 2.0.5.5 =
|
107 |
* Discount URLs for WooCommerce - now the shop clients can use coupons' custom URIs to easily apply the discount to the cart
|
108 |
* Extra AJAX check for duplicated URIs in "Edit URI" box
|
109 |
* Wordpress CronJobs for "Automatically remove duplicates" functionality
|
110 |
* Extra improvements in "save_post/update_term" hooks
|
111 |
+
* Fix for terms permalinks added via "Edit post" page
|
112 |
+
* New filter - "permalink-manager-force-lowercase-uris"
|
113 |
|
114 |
= 2.0.5.4 =
|
115 |
* New filter - "permalink_manager_empty_tag_replacement"
|
includes/core/permalink-manager-core-functions.php
CHANGED
@@ -93,10 +93,11 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
93 |
// Trim slashes
|
94 |
$uri = trim($uri, "/");
|
95 |
|
96 |
-
// Decode both request URI & URIs array & make them lowercase
|
97 |
$uri = strtolower(urldecode($uri));
|
|
|
98 |
foreach ($permalink_manager_uris as $key => $value) {
|
99 |
-
$
|
100 |
}
|
101 |
|
102 |
// Ignore URLs with no URI grabbed
|
@@ -105,15 +106,15 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
105 |
/**
|
106 |
* 2. Check if found URI matches any element from custom uris array
|
107 |
*/
|
108 |
-
$element_id = array_search($uri, $
|
109 |
|
110 |
// Check again in case someone added .html suffix to particular post (with .html suffix)
|
111 |
-
$element_id = (empty($element_id)) ? array_search("{$uri}.html", $
|
112 |
|
113 |
// Check again in case someone used post/tax IDs instead of slugs
|
114 |
if($deep_detect_enabled && isset($old_query['page'])) {
|
115 |
|
116 |
-
$new_item_id = array_search("{$uri}/{$endpoint_value}", $
|
117 |
if($new_item_id) {
|
118 |
$element_id = $new_item_id;
|
119 |
$endpoint_value = $endpoint = "";
|
@@ -191,8 +192,10 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
191 |
|
192 |
// Proceed only if the term is not removed and its taxonomy is not disabled
|
193 |
if(!$disabled && $post_type) {
|
|
|
|
|
194 |
// Fix for hierarchical CPT & pages
|
195 |
-
if(!(empty($post_to_load->ancestors))) {
|
196 |
foreach ($post_to_load->ancestors as $parent) {
|
197 |
$parent = get_post( $parent );
|
198 |
if($parent && $parent->post_name) {
|
@@ -210,7 +213,6 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
210 |
$query['attachment'] = $final_uri;
|
211 |
} else {
|
212 |
// Get the query var
|
213 |
-
$post_type_object = get_post_type_object($post_type);
|
214 |
$query_var = (!empty($post_type_object->query_var)) ? $post_type_object->query_var : $post_type;
|
215 |
|
216 |
$query['name'] = $final_uri;
|
93 |
// Trim slashes
|
94 |
$uri = trim($uri, "/");
|
95 |
|
96 |
+
// Decode both request URI & URIs array & make them lowercase (and save in a separate variable)
|
97 |
$uri = strtolower(urldecode($uri));
|
98 |
+
$all_uris = array();
|
99 |
foreach ($permalink_manager_uris as $key => $value) {
|
100 |
+
$all_uris[$key] = strtolower(urldecode($value));
|
101 |
}
|
102 |
|
103 |
// Ignore URLs with no URI grabbed
|
106 |
/**
|
107 |
* 2. Check if found URI matches any element from custom uris array
|
108 |
*/
|
109 |
+
$element_id = array_search($uri, $all_uris);
|
110 |
|
111 |
// Check again in case someone added .html suffix to particular post (with .html suffix)
|
112 |
+
$element_id = (empty($element_id)) ? array_search("{$uri}.html", $all_uris) : $element_id;
|
113 |
|
114 |
// Check again in case someone used post/tax IDs instead of slugs
|
115 |
if($deep_detect_enabled && isset($old_query['page'])) {
|
116 |
|
117 |
+
$new_item_id = array_search("{$uri}/{$endpoint_value}", $all_uris);
|
118 |
if($new_item_id) {
|
119 |
$element_id = $new_item_id;
|
120 |
$endpoint_value = $endpoint = "";
|
192 |
|
193 |
// Proceed only if the term is not removed and its taxonomy is not disabled
|
194 |
if(!$disabled && $post_type) {
|
195 |
+
$post_type_object = get_post_type_object($post_type);
|
196 |
+
|
197 |
// Fix for hierarchical CPT & pages
|
198 |
+
if(!(empty($post_to_load->ancestors)) && !empty($post_type_object->hierarchical)) {
|
199 |
foreach ($post_to_load->ancestors as $parent) {
|
200 |
$parent = get_post( $parent );
|
201 |
if($parent && $parent->post_name) {
|
213 |
$query['attachment'] = $final_uri;
|
214 |
} else {
|
215 |
// Get the query var
|
|
|
216 |
$query_var = (!empty($post_type_object->query_var)) ? $post_type_object->query_var : $post_type;
|
217 |
|
218 |
$query['name'] = $final_uri;
|
includes/core/permalink-manager-helper-functions.php
CHANGED
@@ -43,13 +43,21 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
43 |
return '';
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
/**
|
47 |
* Allow to disable post types and taxonomies
|
48 |
*/
|
49 |
static function get_disabled_post_types() {
|
50 |
global $permalink_manager_options, $wp_post_types, $wp_rewrite;
|
51 |
|
52 |
-
$initial_disabled_post_types =
|
53 |
|
54 |
// Disable post types that are not publicly_queryable
|
55 |
if(!empty($wp_rewrite)){
|
@@ -70,7 +78,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
70 |
static function get_disabled_taxonomies() {
|
71 |
global $permalink_manager_options;
|
72 |
|
73 |
-
$initial_disabled_taxonomies =
|
74 |
|
75 |
$disabled_taxonomies = (!empty($permalink_manager_options['general']['partial_disable']['taxonomies'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['taxonomies'], $initial_disabled_taxonomies) : array();
|
76 |
|
@@ -99,6 +107,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
99 |
static function get_post_types_array($format = null, $cpt = null, $all = false) {
|
100 |
global $wp_post_types;
|
101 |
|
|
|
102 |
$disabled_post_types = self::get_disabled_post_types();
|
103 |
|
104 |
// Include native post types
|
@@ -107,7 +116,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
107 |
}
|
108 |
|
109 |
$post_types_array = array();
|
110 |
-
foreach($
|
111 |
$value = ($format == 'full') ? array('label' => $post_type->labels->name, 'name' => $post_type->name) : $post_type->labels->name;
|
112 |
$post_types_array[$post_type->name] = $value;
|
113 |
}
|
@@ -125,8 +134,8 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
125 |
/**
|
126 |
* Get array with all taxonomies
|
127 |
*/
|
128 |
-
static function get_taxonomies_array($format = null, $tax = null, $prefix = false, $all = false) {
|
129 |
-
$taxonomies = get_taxonomies(array('public' => true, '
|
130 |
$disabled_taxonomies = self::get_disabled_taxonomies();
|
131 |
|
132 |
$taxonomies_array = array();
|
@@ -147,6 +156,8 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
147 |
}
|
148 |
}
|
149 |
|
|
|
|
|
150 |
return (empty($tax)) ? $taxonomies_array : $taxonomies_array[$tax];
|
151 |
}
|
152 |
|
@@ -175,7 +186,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
175 |
global $wp_rewrite;
|
176 |
|
177 |
// Start with default endpoints
|
178 |
-
$endpoints = "page|feed|embed|attachment|
|
179 |
|
180 |
if(!empty($wp_rewrite->endpoints)) {
|
181 |
foreach($wp_rewrite->endpoints as $endpoint) {
|
@@ -304,10 +315,13 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
304 |
// Remove accents
|
305 |
$clean = remove_accents($clean);
|
306 |
|
|
|
|
|
|
|
307 |
// $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $clean);
|
308 |
$percent_sign = ($keep_percent_sign) ? "\%" : "";
|
309 |
$clean = preg_replace("/[^\p{L}a-zA-Z0-9{$percent_sign}\/_\.|+ -]/u", '', $clean);
|
310 |
-
$clean = strtolower(trim($clean, '-'));
|
311 |
$clean = preg_replace("/[_|+ -]+/", "-", $clean);
|
312 |
|
313 |
return $clean;
|
@@ -321,7 +335,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
321 |
|
322 |
if(!empty($permalink_manager_options['general']['force_custom_slugs'])) {
|
323 |
$old_slug = basename($slug);
|
324 |
-
$new_slug = (!empty($object->name)) ? sanitize_title($object->name) : sanitize_title($object->post_title);
|
325 |
|
326 |
$slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
|
327 |
}
|
43 |
return '';
|
44 |
}
|
45 |
|
46 |
+
static function content_types_disabled_by_default($is_taxonomy = false) {
|
47 |
+
if($is_taxonomy) {
|
48 |
+
return array();
|
49 |
+
} else {
|
50 |
+
return array('revision', 'algolia_task', 'fl_builder', 'fl-builder', 'fl-theme-layout', 'wc_product_tab', 'wc_voucher', 'wc_voucher_template');
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
/**
|
55 |
* Allow to disable post types and taxonomies
|
56 |
*/
|
57 |
static function get_disabled_post_types() {
|
58 |
global $permalink_manager_options, $wp_post_types, $wp_rewrite;
|
59 |
|
60 |
+
$initial_disabled_post_types = self::content_types_disabled_by_default();
|
61 |
|
62 |
// Disable post types that are not publicly_queryable
|
63 |
if(!empty($wp_rewrite)){
|
78 |
static function get_disabled_taxonomies() {
|
79 |
global $permalink_manager_options;
|
80 |
|
81 |
+
$initial_disabled_taxonomies = self::content_types_disabled_by_default(true);
|
82 |
|
83 |
$disabled_taxonomies = (!empty($permalink_manager_options['general']['partial_disable']['taxonomies'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['taxonomies'], $initial_disabled_taxonomies) : array();
|
84 |
|
107 |
static function get_post_types_array($format = null, $cpt = null, $all = false) {
|
108 |
global $wp_post_types;
|
109 |
|
110 |
+
$post_types = get_post_types(array('public' => true, 'publicly_queryable' => true, '_builtin' => false), 'objects', 'AND');
|
111 |
$disabled_post_types = self::get_disabled_post_types();
|
112 |
|
113 |
// Include native post types
|
116 |
}
|
117 |
|
118 |
$post_types_array = array();
|
119 |
+
foreach($post_types as $post_type) {
|
120 |
$value = ($format == 'full') ? array('label' => $post_type->labels->name, 'name' => $post_type->name) : $post_type->labels->name;
|
121 |
$post_types_array[$post_type->name] = $value;
|
122 |
}
|
134 |
/**
|
135 |
* Get array with all taxonomies
|
136 |
*/
|
137 |
+
static function get_taxonomies_array($format = null, $tax = null, $prefix = false, $all = false, $settings = false) {
|
138 |
+
$taxonomies = get_taxonomies(array('public' => true, 'publicly_queryable' => true), 'objects', 'AND');
|
139 |
$disabled_taxonomies = self::get_disabled_taxonomies();
|
140 |
|
141 |
$taxonomies_array = array();
|
156 |
}
|
157 |
}
|
158 |
|
159 |
+
ksort($taxonomies_array);
|
160 |
+
|
161 |
return (empty($tax)) ? $taxonomies_array : $taxonomies_array[$tax];
|
162 |
}
|
163 |
|
186 |
global $wp_rewrite;
|
187 |
|
188 |
// Start with default endpoints
|
189 |
+
$endpoints = "page|feed|embed|attachment|trackback|filter";
|
190 |
|
191 |
if(!empty($wp_rewrite->endpoints)) {
|
192 |
foreach($wp_rewrite->endpoints as $endpoint) {
|
315 |
// Remove accents
|
316 |
$clean = remove_accents($clean);
|
317 |
|
318 |
+
// Foree lowercase
|
319 |
+
$force_lowercase = apply_filters('permalink-manager-force-lowercase-uris', true);
|
320 |
+
|
321 |
// $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $clean);
|
322 |
$percent_sign = ($keep_percent_sign) ? "\%" : "";
|
323 |
$clean = preg_replace("/[^\p{L}a-zA-Z0-9{$percent_sign}\/_\.|+ -]/u", '', $clean);
|
324 |
+
$clean = ($force_lowercase) ? strtolower(trim($clean, '-')) : trim($clean, '-');
|
325 |
$clean = preg_replace("/[_|+ -]+/", "-", $clean);
|
326 |
|
327 |
return $clean;
|
335 |
|
336 |
if(!empty($permalink_manager_options['general']['force_custom_slugs'])) {
|
337 |
$old_slug = basename($slug);
|
338 |
+
$new_slug = (!empty($object->name)) ? sanitize_title($object->name) : self::sanitize_title($object->post_title);
|
339 |
|
340 |
$slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
|
341 |
}
|
includes/core/permalink-manager-third-parties.php
CHANGED
@@ -89,19 +89,21 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
89 |
}
|
90 |
|
91 |
function wpml_detect_post($uri_parts, $request_url, $endpoints) {
|
92 |
-
global $sitepress_settings, $polylang;
|
93 |
|
94 |
if(!empty($sitepress_settings['active_languages'])) {
|
95 |
$languages_list = implode("|", $sitepress_settings['active_languages']);
|
|
|
96 |
} elseif(function_exists('pll_languages_list')) {
|
97 |
$languages_array = pll_languages_list();
|
98 |
$languages_list = (is_array($languages_array)) ? implode("|", $languages_array) : "";
|
|
|
99 |
}
|
100 |
|
101 |
if(!empty($languages_list)) {
|
102 |
preg_match("/^(?:({$languages_list})\/)?(.+?)(?|\/({$endpoints})\/?([^\/]*)|\/()([\d+]))?\/?$/i", $request_url, $regex_parts);
|
103 |
|
104 |
-
$uri_parts['lang'] = (!empty($regex_parts[1])) ? $regex_parts[1] :
|
105 |
$uri_parts['uri'] = (!empty($regex_parts[2])) ? $regex_parts[2] : "";
|
106 |
$uri_parts['endpoint'] = (!empty($regex_parts[3])) ? $regex_parts[3] : "";
|
107 |
$uri_parts['endpoint_value'] = (!empty($regex_parts[4])) ? $regex_parts[4] : "";
|
@@ -303,8 +305,13 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
|
|
303 |
function woocommerce_detect($query) {
|
304 |
global $woocommerce, $pm_query;
|
305 |
|
|
|
|
|
|
|
|
|
|
|
306 |
// Fix shop page
|
307 |
-
if(!empty($pm_query['id']) && is_numeric($pm_query['id']) &&
|
308 |
$query['post_type'] = 'product';
|
309 |
unset($query['pagename']);
|
310 |
}
|
89 |
}
|
90 |
|
91 |
function wpml_detect_post($uri_parts, $request_url, $endpoints) {
|
92 |
+
global $sitepress, $sitepress_settings, $polylang;
|
93 |
|
94 |
if(!empty($sitepress_settings['active_languages'])) {
|
95 |
$languages_list = implode("|", $sitepress_settings['active_languages']);
|
96 |
+
$default_language = $sitepress->get_default_language();
|
97 |
} elseif(function_exists('pll_languages_list')) {
|
98 |
$languages_array = pll_languages_list();
|
99 |
$languages_list = (is_array($languages_array)) ? implode("|", $languages_array) : "";
|
100 |
+
$default_language = pll_default_language();
|
101 |
}
|
102 |
|
103 |
if(!empty($languages_list)) {
|
104 |
preg_match("/^(?:({$languages_list})\/)?(.+?)(?|\/({$endpoints})\/?([^\/]*)|\/()([\d+]))?\/?$/i", $request_url, $regex_parts);
|
105 |
|
106 |
+
$uri_parts['lang'] = (!empty($regex_parts[1])) ? $regex_parts[1] : $default_language;
|
107 |
$uri_parts['uri'] = (!empty($regex_parts[2])) ? $regex_parts[2] : "";
|
108 |
$uri_parts['endpoint'] = (!empty($regex_parts[3])) ? $regex_parts[3] : "";
|
109 |
$uri_parts['endpoint_value'] = (!empty($regex_parts[4])) ? $regex_parts[4] : "";
|
305 |
function woocommerce_detect($query) {
|
306 |
global $woocommerce, $pm_query;
|
307 |
|
308 |
+
$shop_page_id = get_option('woocommerce_shop_page_id');
|
309 |
+
|
310 |
+
// WPML - translate shop page id
|
311 |
+
$shop_page_id = apply_filters('wpml_object_id', $shop_page_id, 'page', TRUE);
|
312 |
+
|
313 |
// Fix shop page
|
314 |
+
if(!empty($pm_query['id']) && is_numeric($pm_query['id']) && $shop_page_id == $pm_query['id']) {
|
315 |
$query['post_type'] = 'product';
|
316 |
unset($query['pagename']);
|
317 |
}
|
includes/core/permalink-manager-uri-functions-post.php
CHANGED
@@ -6,40 +6,36 @@
|
|
6 |
class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
7 |
|
8 |
public function __construct() {
|
9 |
-
add_action( 'admin_init', array($this, 'admin_init'),
|
10 |
|
11 |
-
add_filter( '_get_page_link', array($this, 'custom_post_permalinks'),
|
12 |
-
add_filter( 'page_link', array($this, 'custom_post_permalinks'),
|
13 |
-
add_filter( 'post_link', array($this, 'custom_post_permalinks'),
|
14 |
-
add_filter( 'post_type_link', array($this, 'custom_post_permalinks'),
|
15 |
-
add_filter( 'attachment_link', array($this, 'custom_post_permalinks'),
|
16 |
|
17 |
-
add_filter( 'permalink-manager-uris', array($this, 'exclude_homepage'),
|
18 |
|
19 |
/**
|
20 |
* URI Editor
|
21 |
*/
|
22 |
-
add_filter( 'get_sample_permalink_html', array($this, 'edit_uri_box'),
|
23 |
-
add_action( 'save_post', array($this, 'update_post_uri'),
|
24 |
-
add_action( 'edit_attachment', array($this, 'update_post_uri'),
|
25 |
-
add_action( 'wp_insert_post', array($this, 'new_post_uri'),
|
26 |
-
add_action( 'wp_trash_post', array($this, 'remove_post_uri'),
|
27 |
|
28 |
-
add_action( 'quick_edit_custom_box', array($this, 'quick_edit_column_form'),
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
* Init
|
33 |
*/
|
34 |
function admin_init() {
|
35 |
-
$post_types =
|
36 |
|
37 |
// Add "URI Editor" to "Quick Edit" for all post_types
|
38 |
-
foreach($post_types as $post_type) {
|
39 |
-
|
40 |
-
// Check if post type is allowed
|
41 |
-
if(Permalink_Manager_Helper_Functions::is_disabled($post_type, 'post_type')) { continue; }
|
42 |
-
|
43 |
$post_type = ($post_type == 'post' || $post_type == 'page') ? "{$post_type}s" : $post_type;
|
44 |
add_filter( "manage_{$post_type}_columns" , array($this, 'quick_edit_column') );
|
45 |
add_filter( "manage_{$post_type}_custom_column" , array($this, 'quick_edit_column_content'), 10, 2 );
|
@@ -102,7 +98,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
102 |
global $wpdb;
|
103 |
|
104 |
// Update slug and make it unique
|
105 |
-
$slug = (empty($slug)) ? sanitize_title(get_the_title($id)) : $slug;
|
106 |
$new_slug = wp_unique_post_slug($slug, $id, get_post_status($id), get_post_type($id), null);
|
107 |
$wpdb->query("UPDATE $wpdb->posts SET post_name = '$new_slug' WHERE ID = '$id'");
|
108 |
|
@@ -135,7 +131,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
135 |
if(empty($post->ID) || (get_option('page_on_front') == $post->ID)) { return ''; }
|
136 |
$post_id = $post->ID;
|
137 |
$post_type = $post->post_type;
|
138 |
-
$post_name = (empty($post->post_name)) ? sanitize_title($post->post_title) : $post->post_name;
|
139 |
|
140 |
// 1. Get the permastruct
|
141 |
if($post_type == 'attachment') {
|
@@ -255,6 +251,9 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
255 |
$replacement = ($native_uri) ? $replacement_term->slug : Permalink_Manager_Helper_Functions::force_custom_slugs($replacement_term->slug, $replacement_term);
|
256 |
}
|
257 |
|
|
|
|
|
|
|
258 |
// 4. Do the replacement
|
259 |
$default_uri = (!empty($replacement)) ? str_replace(array("%{$taxonomy}%", "%{$taxonomy}_flat%", "%{$taxonomy}_custom_uri%"), $replacement, $default_uri) : $default_uri;
|
260 |
}
|
@@ -439,7 +438,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
439 |
$default_uri = self::get_default_post_uri($row['ID']);
|
440 |
$old_post_name = $row['post_name'];
|
441 |
$old_uri = isset($permalink_manager_uris[$row['ID']]) ? trim($permalink_manager_uris[$row['ID']], "/") : $native_uri;
|
442 |
-
$correct_slug = sanitize_title($row['post_title']);
|
443 |
|
444 |
// Process URI & slug
|
445 |
$new_slug = wp_unique_post_slug($correct_slug, $row['ID'], get_post_status($row['ID']), get_post_type($row['ID']), null);
|
@@ -592,14 +591,22 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
592 |
* "Quick Edit" form
|
593 |
*/
|
594 |
function quick_edit_column($columns) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
return array_merge($columns, array('permalink-manager-col' => __( 'Current URI', 'permalink-manager')));
|
596 |
}
|
597 |
|
598 |
function quick_edit_column_content($column_name, $post_id) {
|
599 |
-
global $permalink_manager_uris;
|
600 |
|
601 |
if($column_name == "permalink-manager-col") {
|
602 |
-
echo (!empty($permalink_manager_uris[$post_id])) ? urldecode($permalink_manager_uris[$post_id]) :
|
603 |
}
|
604 |
}
|
605 |
|
@@ -632,8 +639,11 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
|
632 |
// Check if post type is allowed
|
633 |
if(Permalink_Manager_Helper_Functions::is_disabled($post->post_type, 'post_type')) { return $post_id; };
|
634 |
|
635 |
-
//
|
636 |
-
if($post->post_type == 'nav_menu_item'
|
|
|
|
|
|
|
637 |
|
638 |
$native_uri = self::get_default_post_uri($post_id, true);
|
639 |
$new_uri = self::get_default_post_uri($post_id);
|
6 |
class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
|
7 |
|
8 |
public function __construct() {
|
9 |
+
add_action( 'admin_init', array($this, 'admin_init'), 99, 3);
|
10 |
|
11 |
+
add_filter( '_get_page_link', array($this, 'custom_post_permalinks'), 99, 2);
|
12 |
+
add_filter( 'page_link', array($this, 'custom_post_permalinks'), 99, 2);
|
13 |
+
add_filter( 'post_link', array($this, 'custom_post_permalinks'), 99, 2);
|
14 |
+
add_filter( 'post_type_link', array($this, 'custom_post_permalinks'), 99, 2);
|
15 |
+
add_filter( 'attachment_link', array($this, 'custom_post_permalinks'), 99, 2);
|
16 |
|
17 |
+
add_filter( 'permalink-manager-uris', array($this, 'exclude_homepage'), 99, 2);
|
18 |
|
19 |
/**
|
20 |
* URI Editor
|
21 |
*/
|
22 |
+
add_filter( 'get_sample_permalink_html', array($this, 'edit_uri_box'), 99, 5 );
|
23 |
+
add_action( 'save_post', array($this, 'update_post_uri'), 99, 1);
|
24 |
+
add_action( 'edit_attachment', array($this, 'update_post_uri'), 99, 1 );
|
25 |
+
add_action( 'wp_insert_post', array($this, 'new_post_uri'), 99, 1 );
|
26 |
+
add_action( 'wp_trash_post', array($this, 'remove_post_uri'), 100, 1 );
|
27 |
|
28 |
+
add_action( 'quick_edit_custom_box', array($this, 'quick_edit_column_form'), 99, 3);
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
* Init
|
33 |
*/
|
34 |
function admin_init() {
|
35 |
+
$post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
|
36 |
|
37 |
// Add "URI Editor" to "Quick Edit" for all post_types
|
38 |
+
foreach($post_types as $post_type => $label) {
|
|
|
|
|
|
|
|
|
39 |
$post_type = ($post_type == 'post' || $post_type == 'page') ? "{$post_type}s" : $post_type;
|
40 |
add_filter( "manage_{$post_type}_columns" , array($this, 'quick_edit_column') );
|
41 |
add_filter( "manage_{$post_type}_custom_column" , array($this, 'quick_edit_column_content'), 10, 2 );
|
98 |
global $wpdb;
|
99 |
|
100 |
// Update slug and make it unique
|
101 |
+
$slug = (empty($slug)) ? Permalink_Manager_Helper_Functions::sanitize_title(get_the_title($id)) : $slug;
|
102 |
$new_slug = wp_unique_post_slug($slug, $id, get_post_status($id), get_post_type($id), null);
|
103 |
$wpdb->query("UPDATE $wpdb->posts SET post_name = '$new_slug' WHERE ID = '$id'");
|
104 |
|
131 |
if(empty($post->ID) || (get_option('page_on_front') == $post->ID)) { return ''; }
|
132 |
$post_id = $post->ID;
|
133 |
$post_type = $post->post_type;
|
134 |
+
$post_name = (empty($post->post_name)) ? Permalink_Manager_Helper_Functions::sanitize_title($post->post_title) : $post->post_name;
|
135 |
|
136 |
// 1. Get the permastruct
|
137 |
if($post_type == 'attachment') {
|
251 |
$replacement = ($native_uri) ? $replacement_term->slug : Permalink_Manager_Helper_Functions::force_custom_slugs($replacement_term->slug, $replacement_term);
|
252 |
}
|
253 |
|
254 |
+
// Filter final category slug
|
255 |
+
$replacement = apply_filters('permalink_manager_filter_term_slug', $replacement, $replacement_term, $post, $terms, $taxonomy, $native_uri);
|
256 |
+
|
257 |
// 4. Do the replacement
|
258 |
$default_uri = (!empty($replacement)) ? str_replace(array("%{$taxonomy}%", "%{$taxonomy}_flat%", "%{$taxonomy}_custom_uri%"), $replacement, $default_uri) : $default_uri;
|
259 |
}
|
438 |
$default_uri = self::get_default_post_uri($row['ID']);
|
439 |
$old_post_name = $row['post_name'];
|
440 |
$old_uri = isset($permalink_manager_uris[$row['ID']]) ? trim($permalink_manager_uris[$row['ID']], "/") : $native_uri;
|
441 |
+
$correct_slug = Permalink_Manager_Helper_Functions::sanitize_title($row['post_title']);
|
442 |
|
443 |
// Process URI & slug
|
444 |
$new_slug = wp_unique_post_slug($correct_slug, $row['ID'], get_post_status($row['ID']), get_post_type($row['ID']), null);
|
591 |
* "Quick Edit" form
|
592 |
*/
|
593 |
function quick_edit_column($columns) {
|
594 |
+
global $current_screen;
|
595 |
+
|
596 |
+
// Get post type
|
597 |
+
$post_type = (!empty($current_screen->post_type)) ? $current_screen->post_type : false;
|
598 |
+
|
599 |
+
// Check if post type is disabled
|
600 |
+
if(Permalink_Manager_Helper_Functions::is_disabled($post_type, 'post_type')) { return $columns; }
|
601 |
+
|
602 |
return array_merge($columns, array('permalink-manager-col' => __( 'Current URI', 'permalink-manager')));
|
603 |
}
|
604 |
|
605 |
function quick_edit_column_content($column_name, $post_id) {
|
606 |
+
global $permalink_manager_uris, $wp_current_filter;
|
607 |
|
608 |
if($column_name == "permalink-manager-col") {
|
609 |
+
echo (!empty($permalink_manager_uris[$post_id])) ? urldecode($permalink_manager_uris[$post_id]) : self::get_post_uri($post_id, true);
|
610 |
}
|
611 |
}
|
612 |
|
639 |
// Check if post type is allowed
|
640 |
if(Permalink_Manager_Helper_Functions::is_disabled($post->post_type, 'post_type')) { return $post_id; };
|
641 |
|
642 |
+
// Ignore menu items
|
643 |
+
if($post->post_type == 'nav_menu_item') { return $post_id; }
|
644 |
+
|
645 |
+
// Ignore auto-drafts & removed posts
|
646 |
+
if(in_array($post->post_status, array('auto-draft', 'trash'))) { return; }
|
647 |
|
648 |
$native_uri = self::get_default_post_uri($post_id, true);
|
649 |
$new_uri = self::get_default_post_uri($post_id);
|
includes/views/permalink-manager-settings.php
CHANGED
@@ -24,7 +24,7 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
|
|
24 |
public function output() {
|
25 |
// Get all registered post types array & statuses
|
26 |
$all_post_statuses_array = get_post_statuses();
|
27 |
-
$all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array(null, null,
|
28 |
$all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array(false, false, false, true);
|
29 |
$content_types = (defined('PERMALINK_MANAGER_PRO')) ? array('post_types' => $all_post_types, 'taxonomies' => $all_taxonomies) : array('post_types' => $all_post_types);
|
30 |
|
24 |
public function output() {
|
25 |
// Get all registered post types array & statuses
|
26 |
$all_post_statuses_array = get_post_statuses();
|
27 |
+
$all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array(null, null, true);
|
28 |
$all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array(false, false, false, true);
|
29 |
$content_types = (defined('PERMALINK_MANAGER_PRO')) ? array('post_types' => $all_post_types, 'taxonomies' => $all_taxonomies) : array('post_types' => $all_post_types);
|
30 |
|
permalink-manager.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Plugin Name: Permalink Manager
|
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.0.5.
|
8 |
* Author: Maciej Bis
|
9 |
* Author URI: http://maciejbis.net/
|
10 |
* License: GPL-2.0+
|
@@ -21,7 +21,7 @@ if (!defined('WPINC')) {
|
|
21 |
// Define the directories used to load plugin files.
|
22 |
define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'Permalink Manager' );
|
23 |
define( 'PERMALINK_MANAGER_PLUGIN_SLUG', 'permalink-manager' );
|
24 |
-
define( 'PERMALINK_MANAGER_VERSION', '2.0.5.
|
25 |
define( 'PERMALINK_MANAGER_FILE', __FILE__ );
|
26 |
define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
|
27 |
define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__) );
|
1 |
<?php
|
2 |
|
3 |
/**
|
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.0.5.6
|
8 |
* Author: Maciej Bis
|
9 |
* Author URI: http://maciejbis.net/
|
10 |
* License: GPL-2.0+
|
21 |
// Define the directories used to load plugin files.
|
22 |
define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'Permalink Manager' );
|
23 |
define( 'PERMALINK_MANAGER_PLUGIN_SLUG', 'permalink-manager' );
|
24 |
+
define( 'PERMALINK_MANAGER_VERSION', '2.0.5.6' );
|
25 |
define( 'PERMALINK_MANAGER_FILE', __FILE__ );
|
26 |
define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
|
27 |
define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__) );
|