Permalink Manager Lite - Version 2.2.20.3

Version Description

Download this release

Release Info

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

Code changes from version 2.2.20.1 to 2.2.20.3

README.txt CHANGED
@@ -6,8 +6,8 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
  Tags: permalinks, custom permalinks, permalink, woocommerce permalinks, url editor
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.4
9
- Tested up to: 6.1.0
10
- Stable tag: 2.2.20.1
11
 
12
  Permalink Manager lets you customize the complete URL addresses of your posts, pages, custom post types, terms, and WooCommerce links with ease without touching any core files.
13
 
@@ -93,6 +93,10 @@ It is because Permalink Manager overwrites one of the core Wordpress functionali
93
 
94
  == Changelog ==
95
 
 
 
 
 
96
  = 2.2.20.1 (October 31, 2022) =
97
  * Fix - Security fix for BAC vulnerability found in the debug function that allowed unauthorized removal of single URIs
98
 
6
  Tags: permalinks, custom permalinks, permalink, woocommerce permalinks, url editor
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.4
9
+ Tested up to: 6.1.1
10
+ Stable tag: 2.2.20.3
11
 
12
  Permalink Manager lets you customize the complete URL addresses of your posts, pages, custom post types, terms, and WooCommerce links with ease without touching any core files.
13
 
93
 
94
  == Changelog ==
95
 
96
+ = 2.2.20.2/2.2.20.3 (November 15, 2022) =
97
+ * Fix - A nonce field has been added to debug tools code for increased security
98
+ * Fix - The "Fix language mismatch" function now functions exactly the same way in Polylang as it does in WPML
99
+
100
  = 2.2.20.1 (October 31, 2022) =
101
  * Fix - Security fix for BAC vulnerability found in the debug function that allowed unauthorized removal of single URIs
102
 
includes/core/permalink-manager-actions.php CHANGED
@@ -40,7 +40,6 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
40
  'uri_editor' => array('function' => 'update_all_permalinks', 'display_uri_table' => true),
41
  'permalink_manager_options' => array('function' => 'save_settings'),
42
  'permalink_manager_permastructs' => array('function' => 'save_permastructures'),
43
- 'flush_sitemaps' => array('function' => 'flush_sitemaps'),
44
  'import' => array('function' => 'import_custom_permalinks_uris'),
45
  );
46
 
@@ -285,21 +284,29 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
285
  * Additional actions
286
  */
287
  public static function extra_actions() {
288
- if(current_user_can('manage_options')) {
289
- if(isset($_GET['flush_sitemaps'])) {
290
- self::flush_sitemaps();
291
- } else if(isset($_GET['clear-permalink-manager-uris'])) {
 
 
 
 
 
 
 
 
292
  self::clear_all_uris();
293
  } else if(isset($_GET['remove-permalink-manager-settings'])) {
294
  $option_name = sanitize_text_field($_GET['remove-permalink-manager-settings']);
295
  self::remove_plugin_data($option_name);
296
- } /*else if(!empty($_REQUEST['remove-uri'])) {
297
  $uri_key = sanitize_text_field($_REQUEST['remove-uri']);
298
  self::force_clear_single_element_uris_and_redirects($uri_key);
299
  } else if(!empty($_REQUEST['remove-redirect'])) {
300
  $redirect_key = sanitize_text_field($_REQUEST['remove-redirect']);
301
  self::force_clear_single_redirect($redirect_key);
302
- }*/
303
  } else if(!empty($_POST['screen-options-apply'])) {
304
  self::save_screen_options();
305
  }
@@ -415,13 +422,6 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
415
  $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'You are not allowed to remove Permalink Manager data!', 'permalink-manager' ), 'error updated_slugs');
416
  }
417
 
418
- // Check if the nonce field is correct
419
- $nonce = sanitize_key($_GET['_wpnonce']);
420
- if(!wp_verify_nonce($nonce, 'permalink-manager')) {
421
- $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'You are not allowed to remove Permalink Manager data!', 'permalink-manager' ), 'error updated_slugs');
422
- return;
423
- }
424
-
425
  switch($field_name) {
426
  case 'uris' :
427
  $option_name = 'permalink-manager-uris';
@@ -701,19 +701,6 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
701
  }
702
  }
703
 
704
- /**
705
- * Clear sitemaps cache
706
- */
707
- function flush_sitemaps($types = array()) {
708
- global $permalink_manager_before_sections_html;
709
-
710
- if(class_exists('WPSEO_Sitemaps_Cache')) {
711
- $sitemaps = WPSEO_Sitemaps_Cache::clear($types);
712
-
713
- $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'Sitemaps were updated!', 'permalink-manager' ), 'updated');
714
- }
715
- }
716
-
717
  /**
718
  * Import old URIs from "Custom Permalinks" (Pro)
719
  */
40
  'uri_editor' => array('function' => 'update_all_permalinks', 'display_uri_table' => true),
41
  'permalink_manager_options' => array('function' => 'save_settings'),
42
  'permalink_manager_permastructs' => array('function' => 'save_permastructures'),
 
43
  'import' => array('function' => 'import_custom_permalinks_uris'),
44
  );
45
 
284
  * Additional actions
285
  */
286
  public static function extra_actions() {
287
+ global $permalink_manager_before_sections_html;
288
+
289
+ if(current_user_can('manage_options') && !empty($_GET['_wpnonce'])) {
290
+ // Check if the nonce field is correct
291
+ $nonce = sanitize_key($_GET['_wpnonce']);
292
+
293
+ if(!wp_verify_nonce($nonce, 'permalink-manager')) {
294
+ $permalink_manager_before_sections_html = Permalink_Manager_Admin_Functions::get_alert_message(__( 'You are not allowed to remove Permalink Manager data!', 'permalink-manager' ), 'error updated_slugs');
295
+ return;
296
+ }
297
+
298
+ if(isset($_GET['clear-permalink-manager-uris'])) {
299
  self::clear_all_uris();
300
  } else if(isset($_GET['remove-permalink-manager-settings'])) {
301
  $option_name = sanitize_text_field($_GET['remove-permalink-manager-settings']);
302
  self::remove_plugin_data($option_name);
303
+ } else if(!empty($_REQUEST['remove-uri'])) {
304
  $uri_key = sanitize_text_field($_REQUEST['remove-uri']);
305
  self::force_clear_single_element_uris_and_redirects($uri_key);
306
  } else if(!empty($_REQUEST['remove-redirect'])) {
307
  $redirect_key = sanitize_text_field($_REQUEST['remove-redirect']);
308
  self::force_clear_single_redirect($redirect_key);
309
+ }
310
  } else if(!empty($_POST['screen-options-apply'])) {
311
  self::save_screen_options();
312
  }
422
  $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'You are not allowed to remove Permalink Manager data!', 'permalink-manager' ), 'error updated_slugs');
423
  }
424
 
 
 
 
 
 
 
 
425
  switch($field_name) {
426
  case 'uris' :
427
  $option_name = 'permalink-manager-uris';
701
  }
702
  }
703
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  /**
705
  * Import old URIs from "Custom Permalinks" (Pro)
706
  */
includes/core/permalink-manager-core-functions.php CHANGED
@@ -221,13 +221,13 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
221
  */
222
  if(strpos($element_id, 'tax-') !== false) {
223
  // Remove the "tax-" prefix
224
- $term_id = intval(preg_replace("/[^0-9]/", "", $element_id));
225
 
226
  // Filter detected post ID
227
- $term_id = apply_filters('permalink_manager_detected_term_id', intval($term_id), $uri_parts, true);
228
 
229
  // Get the variables to filter wp_query and double-check if taxonomy exists
230
- $term = get_term($term_id);
231
  $term_taxonomy = (!empty($term->taxonomy)) ? $term->taxonomy : false;
232
 
233
  // Check if term is allowed
@@ -244,7 +244,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
244
  $query["taxonomy"] = $term_taxonomy;
245
  $query_parameter = $term_taxonomy;
246
  }
247
- $term_ancestors = get_ancestors($term_id, $term_taxonomy);
248
  $final_uri = $term->slug;
249
 
250
  // Fix for hierarchical terms
221
  */
222
  if(strpos($element_id, 'tax-') !== false) {
223
  // Remove the "tax-" prefix
224
+ $element_id = intval(preg_replace("/[^0-9]/", "", $element_id));
225
 
226
  // Filter detected post ID
227
+ $element_id = apply_filters('permalink_manager_detected_term_id', intval($element_id), $uri_parts, true);
228
 
229
  // Get the variables to filter wp_query and double-check if taxonomy exists
230
+ $term = get_term($element_id);
231
  $term_taxonomy = (!empty($term->taxonomy)) ? $term->taxonomy : false;
232
 
233
  // Check if term is allowed
244
  $query["taxonomy"] = $term_taxonomy;
245
  $query_parameter = $term_taxonomy;
246
  }
247
+ $term_ancestors = get_ancestors($element_id, $term_taxonomy);
248
  $final_uri = $term->slug;
249
 
250
  // Fix for hierarchical terms
includes/core/permalink-manager-language-plugins.php CHANGED
@@ -180,7 +180,7 @@ class Permalink_Manager_Language_Plugins extends Permalink_Manager_Class {
180
  $icl_adjust_id_url_filter_off = false;
181
 
182
  // Use default language if nothing detected
183
- return ($lang_code) ? $lang_code : self::get_default_language();
184
  }
185
 
186
  public static function get_translatepress_language_code($lang) {
@@ -248,10 +248,14 @@ class Permalink_Manager_Language_Plugins extends Permalink_Manager_Class {
248
  }
249
 
250
  function fix_language_mismatch($item_id, $uri_parts, $is_term = false) {
251
- global $wp, $polylang, $language_code, $permalink_manager_options;
252
 
253
  $mode = (!empty($permalink_manager_options['general']['fix_language_mismatch'])) ? $permalink_manager_options['general']['fix_language_mismatch'] : 0;
254
 
 
 
 
 
255
  if($is_term) {
256
  $element = get_term($item_id);
257
  if(!empty($element) && !is_wp_error($element)) {
@@ -294,7 +298,7 @@ class Permalink_Manager_Language_Plugins extends Permalink_Manager_Class {
294
  $translated_item_id = pll_get_term($element_id, $detected_language_code);
295
  }
296
 
297
- $item_id = (!empty($translated_item_id)) ? $translated_item_id : $item_id;
298
  } else {
299
  $item_id = apply_filters('wpml_object_id', $element_id, $element_type);
300
  }
@@ -305,6 +309,8 @@ class Permalink_Manager_Language_Plugins extends Permalink_Manager_Class {
305
  }
306
  }
307
 
 
 
308
  return $item_id;
309
  }
310
 
180
  $icl_adjust_id_url_filter_off = false;
181
 
182
  // Use default language if nothing detected
183
+ return (!empty($lang_code)) ? $lang_code : self::get_default_language();
184
  }
185
 
186
  public static function get_translatepress_language_code($lang) {
248
  }
249
 
250
  function fix_language_mismatch($item_id, $uri_parts, $is_term = false) {
251
+ global $wp, $polylang, $language_code, $permalink_manager_options, $icl_adjust_id_url_filter_off;
252
 
253
  $mode = (!empty($permalink_manager_options['general']['fix_language_mismatch'])) ? $permalink_manager_options['general']['fix_language_mismatch'] : 0;
254
 
255
+ // Stop WPML from changing the output of the get_term() and get_post() functions
256
+ $icl_adjust_id_url_filter_off_prior = $icl_adjust_id_url_filter_off;
257
+ $icl_adjust_id_url_filter_off = true;
258
+
259
  if($is_term) {
260
  $element = get_term($item_id);
261
  if(!empty($element) && !is_wp_error($element)) {
298
  $translated_item_id = pll_get_term($element_id, $detected_language_code);
299
  }
300
 
301
+ $item_id = (isset($translated_item_id)) ? $translated_item_id : $item_id;
302
  } else {
303
  $item_id = apply_filters('wpml_object_id', $element_id, $element_type);
304
  }
309
  }
310
  }
311
 
312
+ $icl_adjust_id_url_filter_off = $icl_adjust_id_url_filter_off_prior;
313
+
314
  return $item_id;
315
  }
316
 
includes/core/permalink-manager-uri-functions-post.php CHANGED
@@ -123,7 +123,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
123
  $slug = (empty($slug)) ? get_the_title($id) : $slug;
124
  $slug = sanitize_title($slug);
125
 
126
- $new_slug = wp_unique_post_slug($slug, $id, get_post_status($id), get_post_type($id), null);
127
  $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_name = %s WHERE ID = %d", $new_slug, $id));
128
 
129
  return $new_slug;
@@ -537,7 +537,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
537
  $correct_slug = ($mode == 'slugs') ? sanitize_title($row['post_title']) : Permalink_Manager_Helper_Functions::sanitize_title($row['post_title']);
538
 
539
  // Process URI & slug
540
- $new_slug = wp_unique_post_slug($correct_slug, $row['ID'], get_post_status($row['ID']), get_post_type($row['ID']), null);
541
  $new_post_name = ($mode == 'slugs') ? $new_slug : $old_post_name; // Post name is changed only in first mode
542
 
543
  // Prepare the new URI
123
  $slug = (empty($slug)) ? get_the_title($id) : $slug;
124
  $slug = sanitize_title($slug);
125
 
126
+ $new_slug = wp_unique_post_slug($slug, $id, get_post_status($id), get_post_type($id), 0);
127
  $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_name = %s WHERE ID = %d", $new_slug, $id));
128
 
129
  return $new_slug;
537
  $correct_slug = ($mode == 'slugs') ? sanitize_title($row['post_title']) : Permalink_Manager_Helper_Functions::sanitize_title($row['post_title']);
538
 
539
  // Process URI & slug
540
+ $new_slug = wp_unique_post_slug($correct_slug, $row['ID'], get_post_status($row['ID']), get_post_type($row['ID']), 0);
541
  $new_post_name = ($mode == 'slugs') ? $new_slug : $old_post_name; // Post name is changed only in first mode
542
 
543
  // Prepare the new URI
includes/views/permalink-manager-tools.php CHANGED
@@ -51,8 +51,15 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
51
  $all_duplicates = Permalink_Manager_Helper_Functions::get_all_duplicates();
52
  $home_url = trim(get_option('home'), "/");
53
 
 
 
 
 
 
 
 
54
  $html = sprintf("<h3>%s</h3>", __("List of duplicated permalinks", "permalink-manager"));
55
- $html .= wpautop(sprintf("<a class=\"button button-primary\" href=\"%s\">%s</a>", admin_url('tools.php?page=permalink-manager&section=tools&subsection=duplicates&clear-permalink-manager-uris=1'), __('Fix custom permalinks & redirects', 'permalink-manager')));
56
 
57
  if(!empty($all_duplicates)) {
58
  foreach($all_duplicates as $uri => $duplicates) {
51
  $all_duplicates = Permalink_Manager_Helper_Functions::get_all_duplicates();
52
  $home_url = trim(get_option('home'), "/");
53
 
54
+ $button_url = add_query_arg(array(
55
+ 'section' => 'tools',
56
+ 'subsection' => 'duplicates',
57
+ 'clear-permalink-manager-uris' => 1,
58
+ '_wpnonce' => wp_create_nonce('permalink-manager')
59
+ ), Permalink_Manager_Admin_Functions::get_admin_url());
60
+
61
  $html = sprintf("<h3>%s</h3>", __("List of duplicated permalinks", "permalink-manager"));
62
+ $html .= wpautop(sprintf("<a class=\"button button-primary\" href=\"%s\">%s</a>", $button_url, __('Fix custom permalinks & redirects', 'permalink-manager')));
63
 
64
  if(!empty($all_duplicates)) {
65
  foreach($all_duplicates as $uri => $duplicates) {
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.20.1
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: 7.0.0
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.20.1' );
29
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
30
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
31
  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.2.20.3
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: 7.1.0
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.20.3' );
29
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
30
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
31
  define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__));