Permalink Manager Lite - Version 2.0.5.4

Version Description

  • New filter - "permalink_manager_empty_tag_replacement"
  • Fix for term placeholder tags in taxonomies permastructures
  • Page pagination improvement (404 error page for non-existing pages)
  • New settings field for pagination redirect
  • Trailing slashes are no longer added to custom permalinks ended with extension, eg. .html, or .php
  • The attachment URI duplicates are removed if redirect for them is enabled in Yoast's SEO Premium plugin
Download this release

Release Info

Developer mbis
Plugin Icon 128x128 Permalink Manager Lite
Version 2.0.5.4
Comparing to
See all releases

Code changes from version 2.0.5.4a to 2.0.5.4

README.txt CHANGED
@@ -1,4 +1,4 @@
1
- === Permalink Manager Lite ===
2
  Contributors: mbis
3
  Donate link: https://www.paypal.me/Bismit
4
  License: GPLv3
@@ -104,6 +104,7 @@ A. Currently there is no 100% guarantee that Permalink Manager will work correct
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)
1
+ === Permalink Manager ===
2
  Contributors: mbis
3
  Donate link: https://www.paypal.me/Bismit
4
  License: GPLv3
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
+ * The attachment URI duplicates are removed if redirect for them is enabled in Yoast's SEO Premium plugin
108
 
109
  = 2.0.5.3 =
110
  * Hotfix for redirects - redirect chain no longer occurs (WPML)
includes/core/permalink-manager-actions.php CHANGED
@@ -27,7 +27,6 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
27
  'flush_sitemaps' => array('function' => 'save_permastructures'),
28
  'import' => array('function' => 'import_custom_permalinks_uris'),
29
  );
30
- // Clear URIs & reset settings & permastructs also should be added here.
31
 
32
  // 2. Find the action
33
  foreach($actions_map as $action => $map) {
@@ -229,6 +228,16 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
229
 
230
  // Remove custom URIs for removed, auto-draft posts or disabled post types
231
  $remove = (!empty($post_type)) ? Permalink_Manager_Helper_Functions::is_disabled($post_type, 'post_type') : true;
 
 
 
 
 
 
 
 
 
 
232
  } else if(strpos($element_id, 'tax-') !== false) {
233
  $term_id = preg_replace("/[^0-9]/", "", $element_id);
234
  $taxonomy = $wpdb->get_var($wpdb->prepare("SELECT t.taxonomy FROM $wpdb->term_taxonomy AS t WHERE t.term_id = %s LIMIT 1", $term_id));
27
  'flush_sitemaps' => array('function' => 'save_permastructures'),
28
  'import' => array('function' => 'import_custom_permalinks_uris'),
29
  );
 
30
 
31
  // 2. Find the action
32
  foreach($actions_map as $action => $map) {
228
 
229
  // Remove custom URIs for removed, auto-draft posts or disabled post types
230
  $remove = (!empty($post_type)) ? Permalink_Manager_Helper_Functions::is_disabled($post_type, 'post_type') : true;
231
+
232
+ // Remove custom URIs for attachments redirected with Yoast's SEO Premium
233
+ $yoast_permalink_options = (class_exists('WPSEO_Premium')) ? get_option('wpseo_permalinks') : array();
234
+
235
+ if(!empty($yoast_permalink_options['redirectattachment']) && $post_type == 'attachment') {
236
+ $attachment_parent = $wpdb->get_var("SELECT post_parent FROM {$wpdb->prefix}posts WHERE ID = {$element_id} AND post_type = 'attachment'");
237
+ if(!empty($attachment_parent)) {
238
+ $remove = true;
239
+ }
240
+ }
241
  } else if(strpos($element_id, 'tax-') !== false) {
242
  $term_id = preg_replace("/[^0-9]/", "", $element_id);
243
  $taxonomy = $wpdb->get_var($wpdb->prepare("SELECT t.taxonomy FROM $wpdb->term_taxonomy AS t WHERE t.term_id = %s LIMIT 1", $term_id));
includes/core/permalink-manager-helper-functions.php CHANGED
@@ -54,9 +54,9 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
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
  }
@@ -82,10 +82,12 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
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;
@@ -97,7 +99,6 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
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
@@ -106,7 +107,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
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
  }
@@ -380,4 +381,22 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
380
  return $duplicates_groups;
381
  }
382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  }
54
  // Disable post types without permalink settings
55
  if(!empty($wp_rewrite)){
56
  foreach($wp_post_types as $post_type) {
57
+ $is_publicly_queryable = (empty($post_type->publicly_queryable) || empty($post_type->public)) ? false : true;
58
 
59
+ if(!$is_publicly_queryable && !in_array($post_type->name, array('post', 'page', 'attachment'))) {
60
  $initial_disabled_post_types[] = $post_type->name;
61
  }
62
  }
82
 
83
  if($content_type == 'post_type') {
84
  $disabled_post_types = self::get_disabled_post_types();
85
+ $post_type_exists = get_post_type_object($content_name);
86
+ $out = ((is_array($disabled_post_types) && in_array($content_name, $disabled_post_types)) || empty($post_type_exists)) ? true : false;
87
  } else {
88
  $disabled_taxonomies = self::get_disabled_taxonomies();
89
+ $taxonomy_exists = taxonomy_exists($content_name);
90
+ $out = ((is_array($disabled_taxonomies) && in_array($content_name, $disabled_taxonomies)) || empty($taxonomy_exists)) ? true : false;
91
  }
92
 
93
  return $out;
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
  }
108
 
109
  $post_types_array = array();
110
+ foreach($wp_post_types as $post_type) {
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
  }
381
  return $duplicates_groups;
382
  }
383
 
384
+ /**
385
+ * Check if a single URI is duplicated
386
+ */
387
+ public static function is_uri_duplicated($uri, $element_id) {
388
+ global $permalink_manager_uris;
389
+
390
+ if(empty($uri) || empty($element_id)) { return false; }
391
+
392
+ $uri = trim(trim(sanitize_text_field($uri)), "/");
393
+ $element_id = sanitize_text_field($element_id);
394
+
395
+ // Keep the URIs in a separate array just here & unset the URI for requested element to prevent false alert
396
+ $all_uris = $permalink_manager_uris;
397
+ unset($permalink_manager_uris[$element_id]);
398
+
399
+ return (in_array($uri, $permalink_manager_uris)) ? 1 : 0;
400
+ }
401
+
402
  }
includes/core/permalink-manager-third-parties.php CHANGED
@@ -51,6 +51,9 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
51
  if(class_exists('Theme_My_Login')) {
52
  add_filter('permalink_manager_filter_final_post_permalink', array($this, 'tml_keep_query_parameters'), 9, 3);
53
  }
 
 
 
54
  }
55
 
56
  /**
@@ -344,5 +347,19 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
344
  return $permalink . $get_parameters;
345
  }
346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  }
348
  ?>
51
  if(class_exists('Theme_My_Login')) {
52
  add_filter('permalink_manager_filter_final_post_permalink', array($this, 'tml_keep_query_parameters'), 9, 3);
53
  }
54
+
55
+ // 7. Yoast SEO
56
+ add_filter('wpseo_xml_sitemap_post_url', array($this, 'yoast_fix_sitemap_urls'));
57
  }
58
 
59
  /**
347
  return $permalink . $get_parameters;
348
  }
349
 
350
+ /**
351
+ * 7. Fix Yoast's homepage URL
352
+ */
353
+ function yoast_fix_sitemap_urls($permalink) {
354
+ if(class_exists('WPSEO_Utils')) {
355
+ $home_url = WPSEO_Utils::home_url();
356
+ $home_protocol = parse_url($home_url, PHP_URL_SCHEME);
357
+
358
+ $permalink = preg_replace("/http(s)?/", $home_protocol, $permalink);
359
+ }
360
+
361
+ return $permalink;
362
+ }
363
+
364
  }
365
  ?>
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, 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
 
@@ -39,12 +39,6 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
39
  'label' => __('Auto-update permalinks', 'permalink-manager'),
40
  'input_class' => '',
41
  'description' => __('If enabled, the custom permalinks will be automatically updated every time the post is saved or updated.', 'permalink-manager')
42
- ),
43
- 'case_insensitive_permalinks' => array(
44
- 'type' => 'single_checkbox',
45
- 'label' => __('Case insensitive permalinks', 'permalink-manager'),
46
- 'input_class' => '',
47
- 'description' => __('Make all the permalinks case-insensitive.', 'permalink-manager')
48
  )
49
  )
50
  ),
@@ -85,7 +79,7 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
85
  'type' => 'single_checkbox',
86
  'label' => __('Force 404 on non-existing pagination pages', 'permalink-manager'),
87
  'input_class' => '',
88
- 'description' => __('If enabled, the non-existing pagination pages (for single posts) will return 404 ("Not Found") error.', 'permalink-manager')
89
  ),
90
  )
91
  ),
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, false);
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
 
39
  'label' => __('Auto-update permalinks', 'permalink-manager'),
40
  'input_class' => '',
41
  'description' => __('If enabled, the custom permalinks will be automatically updated every time the post is saved or updated.', 'permalink-manager')
 
 
 
 
 
 
42
  )
43
  )
44
  ),
79
  'type' => 'single_checkbox',
80
  'label' => __('Force 404 on non-existing pagination pages', 'permalink-manager'),
81
  'input_class' => '',
82
+ 'description' => __('If enabled, the non-existing pagination pages (for single posts) will return 404 ("Not Found") error.<br /><strong>Please disable it, if you encounter any problems with pagination pages or use custom pagination system.</strong>', 'permalink-manager')
83
  ),
84
  )
85
  ),
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.4a
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.4a' );
25
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
26
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
27
  define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__) );
@@ -149,7 +149,6 @@ class Permalink_Manager_Class {
149
  'general' => array(
150
  'force_custom_slugs' => 0,
151
  'auto_update_uris' => 0,
152
- 'case_insensitive_permalinks' => 0,
153
  'setup_redirects' => 1,
154
  'redirect' => '301',
155
  'canonical_redirect' => 1,
@@ -179,15 +178,15 @@ class Permalink_Manager_Class {
179
  */
180
  public function default_alerts($alerts) {
181
  $default_alerts = apply_filters('permalink-manager-default-alerts', array(
182
- 'october' => array(
183
  'txt' => sprintf(
184
- __("Get access to extra features: full taxonomy and WooCommerce support, possibility to use custom fields inside the permalinks and more!<br /><strong>Buy Permalink Manager Pro <a href=\"%s\" target=\"_blank\">here</a> and save 20&#37; using \"OCTOBER\" coupon code!</strong> Valid until 31.10!", "permalink-manager"),
185
  PERMALINK_MANAGER_WEBSITE
186
  ),
187
  'type' => 'notice-info',
188
  'show' => 'pro_hide',
189
  'plugin_only' => true,
190
- 'until' => '2017-10-31'
191
  )
192
  ));
193
 
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.4
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.4' );
25
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
26
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
27
  define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__) );
149
  'general' => array(
150
  'force_custom_slugs' => 0,
151
  'auto_update_uris' => 0,
 
152
  'setup_redirects' => 1,
153
  'redirect' => '301',
154
  'canonical_redirect' => 1,
178
  */
179
  public function default_alerts($alerts) {
180
  $default_alerts = apply_filters('permalink-manager-default-alerts', array(
181
+ '01.2018' => array(
182
  'txt' => sprintf(
183
+ __("Get access to extra features: full taxonomy and WooCommerce support, possibility to use custom fields inside the permalinks and more!<br /><strong>Buy Permalink Manager Pro <a href=\"%s\" target=\"_blank\">here</a> and save 20&#37; using \"NEWYEAR\" coupon code!</strong> Valid until 31.01!", "permalink-manager"),
184
  PERMALINK_MANAGER_WEBSITE
185
  ),
186
  'type' => 'notice-info',
187
  'show' => 'pro_hide',
188
  'plugin_only' => true,
189
+ 'until' => '2018-01-31'
190
  )
191
  ));
192