Version Description
Download this release
Release Info
Developer | mbis |
Plugin | Permalink Manager Lite |
Version | 2.0.5.4a |
Comparing to | |
See all releases |
Code changes from version 2.0.5.3.1 to 2.0.5.4a
README.txt
CHANGED
@@ -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,12 @@ A. Currently there is no 100% guarantee that Permalink Manager will work correct
|
|
98 |
|
99 |
== Changelog ==
|
100 |
|
101 |
-
= 2.0.5.
|
102 |
* New filter - "permalink_manager_empty_tag_replacement"
|
103 |
* Fix for term placeholder tags in taxonomies permastructures
|
104 |
* Page pagination improvement (404 error page for non-existing pages)
|
105 |
* New settings field for pagination redirect
|
|
|
106 |
|
107 |
= 2.0.5.3 =
|
108 |
* Hotfix for redirects - redirect chain no longer occurs (WPML)
|
7 |
Requires at least: 4.0
|
8 |
Requires PHP: 5.4
|
9 |
Tested up to: 4.9
|
10 |
+
Stable tag: 2.0.5.4
|
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.4 =
|
102 |
* New filter - "permalink_manager_empty_tag_replacement"
|
103 |
* Fix for term placeholder tags in taxonomies permastructures
|
104 |
* Page pagination improvement (404 error page for non-existing pages)
|
105 |
* New settings field for pagination redirect
|
106 |
+
* Trailing slashes are no longer added to custom permalinks ended with extension, eg. .html, or .php
|
107 |
|
108 |
= 2.0.5.3 =
|
109 |
* Hotfix for redirects - redirect chain no longer occurs (WPML)
|
includes/core/permalink-manager-core-functions.php
CHANGED
@@ -36,7 +36,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
36 |
add_filter( 'permalink_manager_filter_final_post_permalink', array($this, 'control_trailing_slashes'), 9);
|
37 |
add_filter( 'permalink_manager_filter_post_sample_permalink', array($this, 'control_trailing_slashes'), 9);
|
38 |
|
39 |
-
//
|
40 |
add_filter( 'permalink_manager_filter_default_post_uri', array($this, 'replace_empty_placeholder_tags'), 10, 5 );
|
41 |
add_filter( 'permalink_manager_filter_default_term_uri', array($this, 'replace_empty_placeholder_tags'), 10, 5 );
|
42 |
}
|
@@ -93,10 +93,10 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
93 |
// Trim slashes
|
94 |
$uri = trim($uri, "/");
|
95 |
|
96 |
-
// Decode both
|
97 |
-
$uri = urldecode($uri);
|
98 |
foreach ($permalink_manager_uris as $key => $value) {
|
99 |
-
$permalink_manager_uris[$key] = urldecode($value);
|
100 |
}
|
101 |
|
102 |
// Ignore URLs with no URI grabbed
|
@@ -300,6 +300,12 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
300 |
$debug_info['new_query_vars'] = $query;
|
301 |
$debug_info['detected_id'] = (!empty($pm_query['id'])) ? $pm_query['id'] : "-";
|
302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
$debug_txt = json_encode($debug_info);
|
304 |
$debug_txt = "<textarea style=\"width:100%;height:300px\">{$debug_txt}</textarea>";
|
305 |
wp_die($debug_txt);
|
@@ -309,7 +315,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
309 |
}
|
310 |
|
311 |
/**
|
312 |
-
* Trailing slash
|
313 |
*/
|
314 |
function control_trailing_slashes($permalink) {
|
315 |
global $permalink_manager_options;
|
@@ -321,7 +327,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
321 |
|
322 |
// Do not append the trailing slash if permalink contains hashtag or get parameters
|
323 |
$url_parsed = parse_url($permalink);
|
324 |
-
if(!empty($url_parsed['query']) || !empty($url_parsed['fragment'])) { return untrailingslashit($permalink); }
|
325 |
|
326 |
if(in_array($trailing_slash_setting, array(1, 10))) {
|
327 |
$permalink = trailingslashit($permalink);
|
@@ -342,7 +348,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
342 |
$post = get_queried_object();
|
343 |
|
344 |
// 2. Check if post object is defined
|
345 |
-
if(empty($post->
|
346 |
|
347 |
// 3. Check if pagination is detected
|
348 |
$current_page = (!empty($wp_query->query_vars['page'])) ? $wp_query->query_vars['page'] : 1;
|
@@ -450,7 +456,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
450 |
* 2. Check trailing slashes (ignore links with query parameters)
|
451 |
*/
|
452 |
if($trailing_slashes_mode && empty($_SERVER['QUERY_STRING']) && !empty($_SERVER['REQUEST_URI'])) {
|
453 |
-
$home_dir = parse_url($home_url
|
454 |
$old_uri = $_SERVER['REQUEST_URI'];
|
455 |
|
456 |
// Fix for WP installed in directories (remove the directory name from the URI)
|
@@ -461,6 +467,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
461 |
|
462 |
// Check if $old_uri ends with slash or not
|
463 |
$ends_with_slash = (substr($old_uri, -1) == "/") ? true : false;
|
|
|
464 |
|
465 |
// Ignore empty URIs
|
466 |
if($old_uri != "/") {
|
@@ -552,12 +559,15 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
|
|
552 |
}
|
553 |
|
554 |
/**
|
555 |
-
* Replace empty placeholder tags
|
556 |
*/
|
557 |
public static function replace_empty_placeholder_tags($default_uri, $native_slug = "", $element = "", $slug = "", $native_uri = "") {
|
558 |
// Do not affect native URIs
|
559 |
if($native_uri == true) { return $default_uri; }
|
560 |
|
|
|
|
|
|
|
561 |
$empty_tag_replacement = apply_filters('permalink_manager_empty_tag_replacement', null, $element);
|
562 |
$default_uri = ($empty_tag_replacement || is_null($empty_tag_replacement)) ? str_replace("//", "/", preg_replace("/%(.+?)%/", $empty_tag_replacement, $default_uri)) : $default_uri;
|
563 |
|
36 |
add_filter( 'permalink_manager_filter_final_post_permalink', array($this, 'control_trailing_slashes'), 9);
|
37 |
add_filter( 'permalink_manager_filter_post_sample_permalink', array($this, 'control_trailing_slashes'), 9);
|
38 |
|
39 |
+
// Replace empty placeholder tags & remove BOM
|
40 |
add_filter( 'permalink_manager_filter_default_post_uri', array($this, 'replace_empty_placeholder_tags'), 10, 5 );
|
41 |
add_filter( 'permalink_manager_filter_default_term_uri', array($this, 'replace_empty_placeholder_tags'), 10, 5 );
|
42 |
}
|
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 |
+
$permalink_manager_uris[$key] = strtolower(urldecode($value));
|
100 |
}
|
101 |
|
102 |
// Ignore URLs with no URI grabbed
|
300 |
$debug_info['new_query_vars'] = $query;
|
301 |
$debug_info['detected_id'] = (!empty($pm_query['id'])) ? $pm_query['id'] : "-";
|
302 |
|
303 |
+
if(isset($post_type)) {
|
304 |
+
$debug_info['post_type'] = $post_type;
|
305 |
+
} else if(isset($term_taxonomy)) {
|
306 |
+
$debug_info['taxonomy'] = $term_taxonomy;
|
307 |
+
}
|
308 |
+
|
309 |
$debug_txt = json_encode($debug_info);
|
310 |
$debug_txt = "<textarea style=\"width:100%;height:300px\">{$debug_txt}</textarea>";
|
311 |
wp_die($debug_txt);
|
315 |
}
|
316 |
|
317 |
/**
|
318 |
+
* Trailing slash & remove BOM
|
319 |
*/
|
320 |
function control_trailing_slashes($permalink) {
|
321 |
global $permalink_manager_options;
|
327 |
|
328 |
// Do not append the trailing slash if permalink contains hashtag or get parameters
|
329 |
$url_parsed = parse_url($permalink);
|
330 |
+
if(!empty($url_parsed['query']) || !empty($url_parsed['fragment']) || preg_match("/.*\.([a-zA-Z]{3,4})\/?$/", $permalink)) { return untrailingslashit($permalink); }
|
331 |
|
332 |
if(in_array($trailing_slash_setting, array(1, 10))) {
|
333 |
$permalink = trailingslashit($permalink);
|
348 |
$post = get_queried_object();
|
349 |
|
350 |
// 2. Check if post object is defined
|
351 |
+
if(empty($post->post_content)) { return; }
|
352 |
|
353 |
// 3. Check if pagination is detected
|
354 |
$current_page = (!empty($wp_query->query_vars['page'])) ? $wp_query->query_vars['page'] : 1;
|
456 |
* 2. Check trailing slashes (ignore links with query parameters)
|
457 |
*/
|
458 |
if($trailing_slashes_mode && empty($_SERVER['QUERY_STRING']) && !empty($_SERVER['REQUEST_URI'])) {
|
459 |
+
$home_dir = parse_url($home_url, PHP_URL_PATH);
|
460 |
$old_uri = $_SERVER['REQUEST_URI'];
|
461 |
|
462 |
// Fix for WP installed in directories (remove the directory name from the URI)
|
467 |
|
468 |
// Check if $old_uri ends with slash or not
|
469 |
$ends_with_slash = (substr($old_uri, -1) == "/") ? true : false;
|
470 |
+
$trailing_slashes_mode = (preg_match("/.*\.([a-zA-Z]{3,4})\/?$/", $old_uri) && $trailing_slashes_mode == 10) ? 20 : $trailing_slashes_mode;
|
471 |
|
472 |
// Ignore empty URIs
|
473 |
if($old_uri != "/") {
|
559 |
}
|
560 |
|
561 |
/**
|
562 |
+
* Replace empty placeholder tags & remove BOM
|
563 |
*/
|
564 |
public static function replace_empty_placeholder_tags($default_uri, $native_slug = "", $element = "", $slug = "", $native_uri = "") {
|
565 |
// Do not affect native URIs
|
566 |
if($native_uri == true) { return $default_uri; }
|
567 |
|
568 |
+
// Remove the BOM
|
569 |
+
$default_uri = str_replace(array("\xEF\xBB\xBF", "%ef%bb%bf"), '', $default_uri);
|
570 |
+
|
571 |
$empty_tag_replacement = apply_filters('permalink_manager_empty_tag_replacement', null, $element);
|
572 |
$default_uri = ($empty_tag_replacement || is_null($empty_tag_replacement)) ? str_replace("//", "/", preg_replace("/%(.+?)%/", $empty_tag_replacement, $default_uri)) : $default_uri;
|
573 |
|
includes/core/permalink-manager-helper-functions.php
CHANGED
@@ -47,9 +47,21 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
47 |
* Allow to disable post types and taxonomies
|
48 |
*/
|
49 |
static function get_disabled_post_types() {
|
50 |
-
global $permalink_manager_options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
$initial_disabled_post_types = array('revision', 'algolia_task', 'wc_voucher', 'wc_product_tab');
|
53 |
$disabled_post_types = (!empty($permalink_manager_options['general']['partial_disable']['post_types'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['post_types'], $initial_disabled_post_types) : $initial_disabled_post_types;
|
54 |
|
55 |
return apply_filters('permalink-manager-disabled-post-types', $disabled_post_types);
|
@@ -58,7 +70,9 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
58 |
static function get_disabled_taxonomies() {
|
59 |
global $permalink_manager_options;
|
60 |
|
61 |
-
$
|
|
|
|
|
62 |
|
63 |
return apply_filters('permalink-manager-disabled-taxonomies', $disabled_taxonomies);
|
64 |
}
|
@@ -68,10 +82,10 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
68 |
|
69 |
if($content_type == 'post_type') {
|
70 |
$disabled_post_types = self::get_disabled_post_types();
|
71 |
-
$out = (is_array($disabled_post_types) && in_array($content_name, $disabled_post_types)) ? true : false;
|
72 |
} else {
|
73 |
$disabled_taxonomies = self::get_disabled_taxonomies();
|
74 |
-
$out = (is_array($disabled_taxonomies) && in_array($content_name, $disabled_taxonomies)) ? true : false;
|
75 |
}
|
76 |
|
77 |
return $out;
|
@@ -81,21 +95,23 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
|
|
81 |
* Get post_types array
|
82 |
*/
|
83 |
static function get_post_types_array($format = null, $cpt = null, $all = false) {
|
84 |
-
$
|
|
|
|
|
85 |
$disabled_post_types = self::get_disabled_post_types();
|
86 |
|
|
|
|
|
|
|
|
|
|
|
87 |
$post_types_array = array();
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
}
|
92 |
-
} else {
|
93 |
-
foreach ( $post_types as $post_type ) {
|
94 |
-
$post_types_array[$post_type->name] = $post_type->labels->name;
|
95 |
-
}
|
96 |
}
|
97 |
|
98 |
-
//
|
99 |
if(!$all && is_array($disabled_post_types)) {
|
100 |
foreach($disabled_post_types as $post_type) {
|
101 |
if(!empty($post_types_array[$post_type])) { unset($post_types_array[$post_type]); }
|
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 = array();
|
53 |
+
|
54 |
+
// Disable post types without permalink settings
|
55 |
+
if(!empty($wp_rewrite)){
|
56 |
+
foreach($wp_post_types as $post_type) {
|
57 |
+
$has_permalinks_settings = $wp_rewrite->get_extra_permastruct($post_type->name);
|
58 |
+
|
59 |
+
if(empty($has_permalinks_settings) && !in_array($post_type->name, array('post', 'page', 'attachment'))) {
|
60 |
+
$initial_disabled_post_types[] = $post_type->name;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
|
|
|
65 |
$disabled_post_types = (!empty($permalink_manager_options['general']['partial_disable']['post_types'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['post_types'], $initial_disabled_post_types) : $initial_disabled_post_types;
|
66 |
|
67 |
return apply_filters('permalink-manager-disabled-post-types', $disabled_post_types);
|
70 |
static function get_disabled_taxonomies() {
|
71 |
global $permalink_manager_options;
|
72 |
|
73 |
+
$initial_disabled_taxonomies = array();
|
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 |
|
77 |
return apply_filters('permalink-manager-disabled-taxonomies', $disabled_taxonomies);
|
78 |
}
|
82 |
|
83 |
if($content_type == 'post_type') {
|
84 |
$disabled_post_types = self::get_disabled_post_types();
|
85 |
+
$out = ((is_array($disabled_post_types) && in_array($content_name, $disabled_post_types)) || empty(get_post_type_object($content_name))) ? true : false;
|
86 |
} else {
|
87 |
$disabled_taxonomies = self::get_disabled_taxonomies();
|
88 |
+
$out = ((is_array($disabled_taxonomies) && in_array($content_name, $disabled_taxonomies)) || empty(taxonomy_exists($content_name))) ? true : false;
|
89 |
}
|
90 |
|
91 |
return $out;
|
95 |
* Get post_types array
|
96 |
*/
|
97 |
static function get_post_types_array($format = null, $cpt = null, $all = false) {
|
98 |
+
global $wp_post_types;
|
99 |
+
|
100 |
+
$post_types = get_post_types(array('public' => true, 'rewrite' => true), 'objects');
|
101 |
$disabled_post_types = self::get_disabled_post_types();
|
102 |
|
103 |
+
// Include native post types
|
104 |
+
foreach(array('post', 'page', 'attachment') as $post_type_name) {
|
105 |
+
$post_types[$post_type_name] = $wp_post_types[$post_type_name];
|
106 |
+
}
|
107 |
+
|
108 |
$post_types_array = array();
|
109 |
+
foreach($post_types as $post_type) {
|
110 |
+
$value = ($format == 'full') ? array('label' => $post_type->labels->name, 'name' => $post_type->name) : $post_type->labels->name;
|
111 |
+
$post_types_array[$post_type->name] = $value;
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
+
// Exclude disabled post types
|
115 |
if(!$all && is_array($disabled_post_types)) {
|
116 |
foreach($disabled_post_types as $post_type) {
|
117 |
if(!empty($post_types_array[$post_type])) { unset($post_types_array[$post_type]); }
|
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.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__) );
|
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.4a
|
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.4a' );
|
25 |
define( 'PERMALINK_MANAGER_FILE', __FILE__ );
|
26 |
define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
|
27 |
define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__) );
|