Custom Permalinks - Version 2.4.0

Version Description

  • Nov 26, 2021 =

  • Bugs

    • filter for leading special characters
    • search Permalinks button doesnt work. (part2)
    • PHP 8 errors on first visit of Taxonomy Permalinks tab
    • Notice: Undefined variable: site_url in custom-permalinks/admin/class-custom-permalinks-post-types-table.php on line 306
  • Enhancements

    • Pending Post Preview Link
Download this release

Release Info

Developer sasiddiqui
Plugin Icon Custom Permalinks
Version 2.4.0
Comparing to
See all releases

Code changes from version 2.3.0 to 2.4.0

admin/class-custom-permalinks-admin.php CHANGED
@@ -31,6 +31,7 @@ class Custom_Permalinks_Admin {
31
 
32
  add_action( 'admin_init', array( $this, 'privacy_policy' ) );
33
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
 
34
 
35
  add_filter(
36
  'plugin_action_links_' . CUSTOM_PERMALINKS_BASENAME,
@@ -194,7 +195,7 @@ class Custom_Permalinks_Admin {
194
  *
195
  * @param array $links Contains the Plugin Basic Link (Activate/Deactivate/Delete).
196
  *
197
- * @return array Plugin Basic Links and added some custome link for Settings,
198
  * Contact, and About.
199
  */
200
  public function settings_link( $links ) {
@@ -242,6 +243,23 @@ class Custom_Permalinks_Admin {
242
  wp_kses_post( wpautop( $cp_privacy, false ) )
243
  );
244
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
246
 
247
  new Custom_Permalinks_Admin();
31
 
32
  add_action( 'admin_init', array( $this, 'privacy_policy' ) );
33
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
34
+ add_action( 'init', array( $this, 'allow_redirection' ) );
35
 
36
  add_filter(
37
  'plugin_action_links_' . CUSTOM_PERMALINKS_BASENAME,
195
  *
196
  * @param array $links Contains the Plugin Basic Link (Activate/Deactivate/Delete).
197
  *
198
+ * @return array Plugin Basic Links and added some customer link for Settings,
199
  * Contact, and About.
200
  */
201
  public function settings_link( $links ) {
243
  wp_kses_post( wpautop( $cp_privacy, false ) )
244
  );
245
  }
246
+
247
+ /**
248
+ * Buffer the output to allow redirection, even if the website starts to send
249
+ * output to the browser.
250
+ *
251
+ * @since 2.4.0
252
+ * @access public
253
+ *
254
+ * @return void
255
+ */
256
+ public function allow_redirection() {
257
+ if ( isset( $_REQUEST['_custom_permalinks_post_nonce'] ) ||
258
+ isset( $_REQUEST['_custom_permalinks_taxonomy_nonce'] )
259
+ ) {
260
+ ob_start();
261
+ }
262
+ }
263
  }
264
 
265
  new Custom_Permalinks_Admin();
admin/class-custom-permalinks-post-types-table.php CHANGED
@@ -148,7 +148,7 @@ final class Custom_Permalinks_Post_Types_Table extends WP_List_Table {
148
  <?php
149
  esc_html_e( 'Search results for: ', 'custom-permalinks' );
150
  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
151
- printf( '<strong>%s</strong>', $search_permalink );
152
  ?>
153
  </span>
154
  <?php endif; ?>
@@ -303,7 +303,7 @@ final class Custom_Permalinks_Post_Types_Table extends WP_List_Table {
303
  );
304
 
305
  if ( 1 === intval( $wpml_lang_format ) ) {
306
- $home_url = $site_url;
307
  }
308
  }
309
 
148
  <?php
149
  esc_html_e( 'Search results for: ', 'custom-permalinks' );
150
  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
151
+ printf( '<strong>%s</strong>', esc_html( $search_permalink ) );
152
  ?>
153
  </span>
154
  <?php endif; ?>
303
  );
304
 
305
  if ( 1 === intval( $wpml_lang_format ) ) {
306
+ $home_url = site_url();
307
  }
308
  }
309
 
admin/class-custom-permalinks-taxonomies-table.php CHANGED
@@ -148,7 +148,7 @@ final class Custom_Permalinks_Taxonomies_Table extends WP_List_Table {
148
  <?php
149
  esc_html_e( 'Search results for: ', 'custom-permalinks' );
150
  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
151
- printf( '<strong>%s</strong>', $search_permalink );
152
  ?>
153
  </span>
154
  <?php endif; ?>
@@ -313,7 +313,7 @@ final class Custom_Permalinks_Taxonomies_Table extends WP_List_Table {
313
  );
314
 
315
  if ( 1 === intval( $wpml_lang_format ) ) {
316
- $home_url = $site_url;
317
  }
318
  }
319
 
148
  <?php
149
  esc_html_e( 'Search results for: ', 'custom-permalinks' );
150
  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
151
+ printf( '<strong>%s</strong>', esc_html( $search_permalink ) );
152
  ?>
153
  </span>
154
  <?php endif; ?>
313
  );
314
 
315
  if ( 1 === intval( $wpml_lang_format ) ) {
316
+ $home_url = site_url();
317
  }
318
  }
319
 
admin/class-custom-permalinks-taxonomies.php CHANGED
@@ -39,25 +39,28 @@ final class Custom_Permalinks_Taxonomies {
39
  public static function total_permalinks() {
40
  $total_taxonomies = wp_cache_get( 'total_taxonomies_result', 'custom_permalinks' );
41
  if ( ! $total_taxonomies ) {
42
- $taxonomy_table = get_option( 'custom_permalink_table' );
43
- $search_taxonomy = array();
44
-
45
- // phpcs:disable WordPress.Security.NonceVerification.Recommended
46
- // Include search in total results.
47
- if ( isset( $_REQUEST['s'] ) && ! empty( $_REQUEST['s'] ) ) {
48
- $search_value = ltrim( sanitize_text_field( $_REQUEST['s'] ), '/' );
49
- $search_value = str_replace( '/', '\/', $search_value );
50
- foreach ( $taxonomy_table as $key => $value ) {
51
- if ( preg_match( '/' . $search_value . '/', $key ) ) {
52
- $search_taxonomy[ $key ] = $value;
 
 
 
53
  }
 
 
54
  }
 
55
 
56
- $taxonomy_table = $search_taxonomy;
57
  }
58
- // phpcs:enable WordPress.Security.NonceVerification.Recommended
59
-
60
- $total_taxonomies = count( $taxonomy_table );
61
 
62
  wp_cache_set( 'total_taxonomies_result', $total_taxonomies, 'custom_permalinks' );
63
  }
@@ -83,42 +86,44 @@ final class Custom_Permalinks_Taxonomies {
83
  $taxonomy_table = get_option( 'custom_permalink_table' );
84
  $all_taxonomies = $taxonomy_table;
85
  $search_taxonomy = array();
86
-
87
- // phpcs:disable WordPress.Security.NonceVerification.Recommended
88
- // Include search in total results.
89
- if ( isset( $_REQUEST['s'] ) && ! empty( $_REQUEST['s'] ) ) {
90
- $search_value = ltrim( sanitize_text_field( $_REQUEST['s'] ), '/' );
91
- $search_value = str_replace( '/', '\/', $search_value );
92
- foreach ( $taxonomy_table as $key => $value ) {
93
- if ( preg_match( '/' . $search_value . '/', $key ) ) {
94
- $search_taxonomy[ $key ] = $value;
 
 
 
95
  }
96
- }
97
 
98
- $all_taxonomies = $search_taxonomy;
99
- }
100
- // phpcs:enable WordPress.Security.NonceVerification.Recommended
101
-
102
- uasort( $all_taxonomies, array( 'Custom_Permalinks_Taxonomies', 'sort_array' ) );
103
- $pager_limit = -1;
104
- $skip_count = -1;
105
- $taxonomies = array();
106
- foreach ( $all_taxonomies as $permalink => $info ) {
107
- ++$skip_count;
108
- if ( $skip_count < $page_offset ) {
109
- continue;
110
  }
 
 
 
 
 
 
 
 
 
 
111
 
112
- ++$pager_limit;
113
- if ( $pager_limit >= $per_page ) {
114
- break;
115
- }
116
 
117
- $taxonomies[] = array(
118
- 'ID' => $info['id'],
119
- 'permalink' => $permalink,
120
- 'type' => $info['kind'],
121
- );
 
122
  }
123
 
124
  wp_cache_set( 'taxonomies_results', $taxonomies, 'custom_permalinks' );
39
  public static function total_permalinks() {
40
  $total_taxonomies = wp_cache_get( 'total_taxonomies_result', 'custom_permalinks' );
41
  if ( ! $total_taxonomies ) {
42
+ $search_taxonomy = array();
43
+ $taxonomy_table = get_option( 'custom_permalink_table' );
44
+ $total_taxonomies = 0;
45
+
46
+ if ( is_array( $taxonomy_table ) ) {
47
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
48
+ // Include search in total results.
49
+ if ( isset( $_REQUEST['s'] ) && ! empty( $_REQUEST['s'] ) ) {
50
+ $search_value = ltrim( sanitize_text_field( $_REQUEST['s'] ), '/' );
51
+ $search_value = str_replace( '/', '\/', $search_value );
52
+ foreach ( $taxonomy_table as $key => $value ) {
53
+ if ( preg_match( '/' . $search_value . '/', $key ) ) {
54
+ $search_taxonomy[ $key ] = $value;
55
+ }
56
  }
57
+
58
+ $taxonomy_table = $search_taxonomy;
59
  }
60
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
61
 
62
+ $total_taxonomies = count( $taxonomy_table );
63
  }
 
 
 
64
 
65
  wp_cache_set( 'total_taxonomies_result', $total_taxonomies, 'custom_permalinks' );
66
  }
86
  $taxonomy_table = get_option( 'custom_permalink_table' );
87
  $all_taxonomies = $taxonomy_table;
88
  $search_taxonomy = array();
89
+ $taxonomies = array();
90
+
91
+ if ( is_array( $all_taxonomies ) ) {
92
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
93
+ // Include search in total results.
94
+ if ( isset( $_REQUEST['s'] ) && ! empty( $_REQUEST['s'] ) ) {
95
+ $search_value = ltrim( sanitize_text_field( $_REQUEST['s'] ), '/' );
96
+ $search_value = str_replace( '/', '\/', $search_value );
97
+ foreach ( $taxonomy_table as $key => $value ) {
98
+ if ( preg_match( '/' . $search_value . '/', $key ) ) {
99
+ $search_taxonomy[ $key ] = $value;
100
+ }
101
  }
 
102
 
103
+ $all_taxonomies = $search_taxonomy;
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
106
+
107
+ uasort( $all_taxonomies, array( 'Custom_Permalinks_Taxonomies', 'sort_array' ) );
108
+ $pager_limit = -1;
109
+ $skip_count = -1;
110
+ foreach ( $all_taxonomies as $permalink => $info ) {
111
+ ++$skip_count;
112
+ if ( $skip_count < $page_offset ) {
113
+ continue;
114
+ }
115
 
116
+ ++$pager_limit;
117
+ if ( $pager_limit >= $per_page ) {
118
+ break;
119
+ }
120
 
121
+ $taxonomies[] = array(
122
+ 'ID' => $info['id'],
123
+ 'permalink' => $permalink,
124
+ 'type' => $info['kind'],
125
+ );
126
+ }
127
  }
128
 
129
  wp_cache_set( 'taxonomies_results', $taxonomies, 'custom_permalinks' );
assets/css/{about-plugins-2.3.0.min.css → about-plugins-2.4.0.min.css} RENAMED
File without changes
assets/js/{script-form-2.3.0.min.js → script-form-2.4.0.min.js} RENAMED
File without changes
changelog.txt CHANGED
@@ -2,6 +2,45 @@
2
 
3
  This file contains only old changelog. See readme.txt for newer versions.
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  = 1.7.1 - Aug 30, 2020 =
6
 
7
  * Bugs
2
 
3
  This file contains only old changelog. See readme.txt for newer versions.
4
 
5
+ = 2.2.0 - Aug 13, 2021 =
6
+
7
+ * Bugs
8
+ * Show decoded permalink in meta box
9
+ * Enhancements
10
+ * Update script to fix linting issues and use updated permalink to view the post/page
11
+
12
+ = 2.1.0 - Aug 09, 2021 =
13
+
14
+ * Bugs
15
+ * [Plugin not save persian alphabet](https://wordpress.org/support/topic/plugin-not-save-persian-alphabet/)
16
+ * Fix PHP Error on Deactivating the plugin
17
+ * Enhancements
18
+ * Exclude processing for sitemap URLs
19
+
20
+ = 2.0.1 - Aug 02, 2021 =
21
+
22
+ * Bugs
23
+ * [404 error when post/page custom permalink is part of category custom permalink](https://github.com/samiahmedsiddiqui/custom-permalinks/issues/49)
24
+
25
+ = 2.0.0 - Jul 30, 2021 =
26
+
27
+ * Bugs
28
+ * [Bug with AMP plugin](https://wordpress.org/support/topic/bug-with-amp-plugin/)
29
+ * [Oembed links not working](https://wordpress.org/support/topic/oembed-links-not-working/)
30
+ * [Uncaught (in promise) TypeError: getHomeURL is null](https://wordpress.org/support/topic/uncaught-in-promise-typeerror-gethomeurl-is-null/)
31
+ * [Plugin stop saving uppercase slugs](https://wordpress.org/support/topic/plugin-stop-saving-upppercase-slugs/)
32
+ * [template_redirect](https://wordpress.org/support/topic/make-redirect/)
33
+ * conflict with WooCommerce Paid courses
34
+ * Fix creating duplicated permalink while creating multiple `Categories` and/or `Tags`
35
+ * Enhancements
36
+ * Added Query caching to improve performance
37
+ * Changed Permalink sanitization method (Similar way as WP does)
38
+ * Added Nonce verification to make forms secure
39
+ * [Permalink Filter before saving](https://wordpress.org/support/topic/permalink-filter/)
40
+ * Show/Hide column and Pagination features added on Post Type Permalinks and Taxonomies Permalinks page
41
+ * Removed deprecated functions
42
+ * Applied WPCS Standards
43
+
44
  = 1.7.1 - Aug 30, 2020 =
45
 
46
  * Bugs
custom-permalinks.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Custom Permalinks
4
  * Plugin URI: https://www.custompermalinks.com/
5
  * Description: Set custom permalinks on a per-post basis.
6
- * Version: 2.3.0
7
  * Requires at least: 2.6
8
  * Requires PHP: 5.4
9
  * Author: Sami Ahmed Siddiqui
3
  * Plugin Name: Custom Permalinks
4
  * Plugin URI: https://www.custompermalinks.com/
5
  * Description: Set custom permalinks on a per-post basis.
6
+ * Version: 2.4.0
7
  * Requires at least: 2.6
8
  * Requires PHP: 5.4
9
  * Author: Sami Ahmed Siddiqui
includes/class-custom-permalinks-form.php CHANGED
@@ -337,7 +337,16 @@ class Custom_Permalinks_Form {
337
  $permalink = preg_replace( '|-+|', '-', $permalink );
338
  $permalink = str_replace( '-/', '/', $permalink );
339
  $permalink = str_replace( '/-', '/', $permalink );
340
- $permalink = trim( $permalink, '-' );
 
 
 
 
 
 
 
 
 
341
 
342
  return $permalink;
343
  }
@@ -461,7 +470,9 @@ class Custom_Permalinks_Form {
461
  if ( isset( $permalink ) && ! empty( $permalink ) ) {
462
  $view_post_link = $home_url . $permalink;
463
  } else {
464
- if ( 'draft' === $post->post_status ) {
 
 
465
  $view_post = 'Preview';
466
  $view_post_link = $home_url . '?';
467
  if ( 'page' === $post->post_type ) {
@@ -763,6 +774,10 @@ class Custom_Permalinks_Form {
763
  $permalink = $this->sanitize_permalink( $new_permalink, $language_code );
764
  $table = get_option( 'custom_permalink_table' );
765
 
 
 
 
 
766
  if ( $permalink && ! array_key_exists( $permalink, $table ) ) {
767
  $table[ $permalink ] = array(
768
  'id' => $term_id,
@@ -825,16 +840,16 @@ class Custom_Permalinks_Form {
825
 
826
  /*
827
  * Check if `hide_default` is `true` and the current language is not
828
- * the default. Otherwise remove the lang code from the url.
829
  */
830
  if ( 1 === $polylang_config['hide_default'] ) {
831
  $current_language = '';
832
  if ( function_exists( 'pll_current_language' ) ) {
833
- // get current language.
834
  $current_language = pll_current_language();
835
  }
836
 
837
- // get default language.
838
  $default_language = $polylang_config['default_lang'];
839
  if ( $current_language !== $default_language ) {
840
  $remove_lang = ltrim( strstr( $requested_url, '/' ), '/' );
@@ -875,7 +890,9 @@ class Custom_Permalinks_Form {
875
  );
876
 
877
  if ( ! $all_permalinks['custom_permalink'] ) {
878
- if ( 'draft' === $post->post_status ) {
 
 
879
  $view_post_link = '?';
880
  if ( 'page' === $post->post_type ) {
881
  $view_post_link .= 'page_id';
337
  $permalink = preg_replace( '|-+|', '-', $permalink );
338
  $permalink = str_replace( '-/', '/', $permalink );
339
  $permalink = str_replace( '/-', '/', $permalink );
340
+
341
+ /*
342
+ * Avoid trimming hyphens if filter returns `false`.
343
+ *
344
+ * @since 2.4.0
345
+ */
346
+ $trim_hyphen = apply_filters( 'custom_permalinks_redundant_hyphens', false );
347
+ if ( ! is_bool( $trim_hyphen ) || ! $trim_hyphen ) {
348
+ $permalink = trim( $permalink, '-' );
349
+ }
350
 
351
  return $permalink;
352
  }
470
  if ( isset( $permalink ) && ! empty( $permalink ) ) {
471
  $view_post_link = $home_url . $permalink;
472
  } else {
473
+ if ( 'draft' === $post->post_status
474
+ || 'pending' === $post->post_status
475
+ ) {
476
  $view_post = 'Preview';
477
  $view_post_link = $home_url . '?';
478
  if ( 'page' === $post->post_type ) {
774
  $permalink = $this->sanitize_permalink( $new_permalink, $language_code );
775
  $table = get_option( 'custom_permalink_table' );
776
 
777
+ if ( ! is_array( $table ) ) {
778
+ $table = array();
779
+ }
780
+
781
  if ( $permalink && ! array_key_exists( $permalink, $table ) ) {
782
  $table[ $permalink ] = array(
783
  'id' => $term_id,
840
 
841
  /*
842
  * Check if `hide_default` is `true` and the current language is not
843
+ * the default. Otherwise remove the lang code from the URL.
844
  */
845
  if ( 1 === $polylang_config['hide_default'] ) {
846
  $current_language = '';
847
  if ( function_exists( 'pll_current_language' ) ) {
848
+ // Get current language.
849
  $current_language = pll_current_language();
850
  }
851
 
852
+ // Get default language.
853
  $default_language = $polylang_config['default_lang'];
854
  if ( $current_language !== $default_language ) {
855
  $remove_lang = ltrim( strstr( $requested_url, '/' ), '/' );
890
  );
891
 
892
  if ( ! $all_permalinks['custom_permalink'] ) {
893
+ if ( 'draft' === $post->post_status
894
+ || 'pending' === $post->post_status
895
+ ) {
896
  $view_post_link = '?';
897
  if ( 'page' === $post->post_type ) {
898
  $view_post_link .= 'page_id';
includes/class-custom-permalinks-frontend.php CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  }
11
 
12
  /**
13
- * Class that passes custom link, parse the requested url and redirect.
14
  */
15
  class Custom_Permalinks_Frontend {
16
  /**
@@ -28,7 +28,7 @@ class Custom_Permalinks_Frontend {
28
  private $query_string_uri = '';
29
 
30
  /**
31
- * Preserve the url for later use in parse_request.
32
  *
33
  * @var string
34
  */
@@ -115,7 +115,7 @@ class Custom_Permalinks_Frontend {
115
  * @access public
116
  *
117
  * @param string $permalink Custom Permalink.
118
- * @param string $language_code The language to convert the url into.
119
  *
120
  * @return string permalink with language information.
121
  */
@@ -308,7 +308,7 @@ class Custom_Permalinks_Frontend {
308
 
309
  if ( $posts ) {
310
  /*
311
- * A post matches our request. Preserve this url for later use. If it's
312
  * the same as the permalink (no extra stuff).
313
  */
314
  if ( trim( $posts[0]->meta_value, '/' ) === $request_no_slash ) {
@@ -317,7 +317,9 @@ class Custom_Permalinks_Frontend {
317
  }
318
 
319
  $found_permalink = $posts[0]->meta_value;
320
- if ( 'draft' === $posts[0]->post_status ) {
 
 
321
  if ( 'page' === $posts[0]->post_type ) {
322
  $original_url = '?page_id=' . $posts[0]->ID;
323
  } else {
@@ -374,7 +376,7 @@ class Custom_Permalinks_Frontend {
374
  $term_permalink = true;
375
 
376
  /*
377
- * Preserve this url for later if it's the same as the
378
  * permalink (no extra stuff).
379
  */
380
  if ( trim( $permalink, '/' ) === $request_no_slash ) {
@@ -399,7 +401,7 @@ class Custom_Permalinks_Frontend {
399
 
400
  /*
401
  * Allow redirect function to work if permalink is not exactly matched
402
- * with the requested url. Like Trailing slash (Requested URL doesn't
403
  * contain trailing slash but permalink has trailing slash or vice versa)
404
  * and letter-case issue etc.
405
  */
@@ -643,7 +645,7 @@ class Custom_Permalinks_Frontend {
643
  if ( substr( $request, 0, $original_length ) === $original_permalink
644
  && trim( $request, '/' ) !== trim( $original_permalink, '/' )
645
  ) {
646
- // This is the original link; we can use this url to derive the new one.
647
  $url = preg_replace(
648
  '@//*@',
649
  '/',
10
  }
11
 
12
  /**
13
+ * Class that passes custom link, parse the requested URL and redirect.
14
  */
15
  class Custom_Permalinks_Frontend {
16
  /**
28
  private $query_string_uri = '';
29
 
30
  /**
31
+ * Preserve the URL for later use in parse_request.
32
  *
33
  * @var string
34
  */
115
  * @access public
116
  *
117
  * @param string $permalink Custom Permalink.
118
+ * @param string $language_code The language to convert the URL into.
119
  *
120
  * @return string permalink with language information.
121
  */
308
 
309
  if ( $posts ) {
310
  /*
311
+ * A post matches our request. Preserve this URL for later use. If it's
312
  * the same as the permalink (no extra stuff).
313
  */
314
  if ( trim( $posts[0]->meta_value, '/' ) === $request_no_slash ) {
317
  }
318
 
319
  $found_permalink = $posts[0]->meta_value;
320
+ if ( 'draft' === $posts[0]->post_status
321
+ || 'pending' === $posts[0]->post_status
322
+ ) {
323
  if ( 'page' === $posts[0]->post_type ) {
324
  $original_url = '?page_id=' . $posts[0]->ID;
325
  } else {
376
  $term_permalink = true;
377
 
378
  /*
379
+ * Preserve this URL for later if it's the same as the
380
  * permalink (no extra stuff).
381
  */
382
  if ( trim( $permalink, '/' ) === $request_no_slash ) {
401
 
402
  /*
403
  * Allow redirect function to work if permalink is not exactly matched
404
+ * with the requested URL. Like Trailing slash (Requested URL doesn't
405
  * contain trailing slash but permalink has trailing slash or vice versa)
406
  * and letter-case issue etc.
407
  */
645
  if ( substr( $request, 0, $original_length ) === $original_permalink
646
  && trim( $request, '/' ) !== trim( $original_permalink, '/' )
647
  ) {
648
+ // This is the original link; we can use this URL to derive the new one.
649
  $url = preg_replace(
650
  '@//*@',
651
  '/',
includes/class-custom-permalinks.php CHANGED
@@ -18,7 +18,7 @@ class Custom_Permalinks {
18
  *
19
  * @var string
20
  */
21
- public $version = '2.3.0';
22
 
23
  /**
24
  * Class constructor.
18
  *
19
  * @var string
20
  */
21
+ public $version = '2.4.0';
22
 
23
  /**
24
  * Class constructor.
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Custom Permalinks ===
2
  Contributors: sasiddiqui
3
  Tags: permalink, url, link, address, custom, redirect, custom post type, GDPR, GDPR Compliant
4
- Tested up to: 5.8
5
- Stable tag: 2.3.0
6
  License: GPLv3
7
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
8
 
@@ -10,7 +10,7 @@ Set custom permalinks on a per-post, per-tag or per-category basis.
10
 
11
  == Description ==
12
 
13
- > Incase of found any site breaking issue after upgrading to the latest version then please report the issue on [WordPress Forum](https://wordpress.org/support/plugin/custom-permalinks/) OR [GitHub](https://github.com/samiahmedsiddiqui/custom-permalinks) with complete information to reproduce the issue and move back to the old version. You can download any of the old version from here: https://wordpress.org/plugins/custom-permalinks/advanced/
14
 
15
  Lay out your site the way *you* want it. Set the URL of any post, page, tag or category to anything you want. Old permalinks will redirect properly to the new address. Custom Permalinks give you ultimate control over your site structure.
16
 
@@ -137,6 +137,17 @@ function yasglobal_allow_uppercaps() {
137
  add_filter( 'custom_permalinks_allow_caps', 'yasglobal_allow_uppercaps' );
138
  `
139
 
 
 
 
 
 
 
 
 
 
 
 
140
  === Manipulate Permalink Before Saving ===
141
 
142
  To make changes in permalink before saving, please use `custom_permalink_before_saving` filter. Here is an example to see how it works.
@@ -188,6 +199,16 @@ This process defines you the steps to follow either you are installing through W
188
 
189
  == Changelog ==
190
 
 
 
 
 
 
 
 
 
 
 
191
  = 2.3.0 - Sep 21, 2021 =
192
 
193
  * Bugs
@@ -198,45 +219,6 @@ This process defines you the steps to follow either you are installing through W
198
  * Enhancements
199
  * Allow period in the permalink
200
 
201
- = 2.2.0 - Aug 13, 2021 =
202
-
203
- * Bugs
204
- * Show decoded permalink in meta box
205
- * Enhancements
206
- * Update script to fix linting issues and use updated permalink to view the post/page
207
-
208
- = 2.1.0 - Aug 09, 2021 =
209
-
210
- * Bugs
211
- * [Plugin not save persian alphabet](https://wordpress.org/support/topic/plugin-not-save-persian-alphabet/)
212
- * Fix PHP Error on Deactivating the plugin
213
- * Enhancements
214
- * Exclude processing for sitemap URLs
215
-
216
- = 2.0.1 - Aug 02, 2021 =
217
-
218
- * Bugs
219
- * [404 error when post/page custom permalink is part of category custom permalink](https://github.com/samiahmedsiddiqui/custom-permalinks/issues/49)
220
-
221
- = 2.0.0 - Jul 30, 2021 =
222
-
223
- * Bugs
224
- * [Bug with AMP plugin](https://wordpress.org/support/topic/bug-with-amp-plugin/)
225
- * [Oembed links not working](https://wordpress.org/support/topic/oembed-links-not-working/)
226
- * [Uncaught (in promise) TypeError: getHomeURL is null](https://wordpress.org/support/topic/uncaught-in-promise-typeerror-gethomeurl-is-null/)
227
- * [Plugin stop saving uppercase slugs](https://wordpress.org/support/topic/plugin-stop-saving-upppercase-slugs/)
228
- * [template_redirect](https://wordpress.org/support/topic/make-redirect/)
229
- * conflict with WooCommerce Paid courses
230
- * Fix creating duplicated permalink while creating multiple `Categories` and/or `Tags`
231
- * Enhancements
232
- * Added Query caching to improve performance
233
- * Changed Permalink sanitization method (Similar way as WP does)
234
- * Added Nonce verification to make forms secure
235
- * [Permalink Filter before saving](https://wordpress.org/support/topic/permalink-filter/)
236
- * Show/Hide column and Pagination features added on Post Type Permalinks and Taxonomies Permalinks page
237
- * Removed deprecated functions
238
- * Applied WPCS Standards
239
-
240
  = Earlier versions =
241
 
242
  * For the changelog of earlier versions, please refer to the separate changelog.txt file.
1
  === Custom Permalinks ===
2
  Contributors: sasiddiqui
3
  Tags: permalink, url, link, address, custom, redirect, custom post type, GDPR, GDPR Compliant
4
+ Tested up to: 6.0
5
+ Stable tag: 2.4.0
6
  License: GPLv3
7
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
8
 
10
 
11
  == Description ==
12
 
13
+ > In case of found any site breaking issue after upgrading to the latest version then please report the issue on [WordPress Forum](https://wordpress.org/support/plugin/custom-permalinks/) OR [GitHub](https://github.com/samiahmedsiddiqui/custom-permalinks) with complete information to reproduce the issue and move back to the old version. You can download any of the old version from here: https://wordpress.org/plugins/custom-permalinks/advanced/
14
 
15
  Lay out your site the way *you* want it. Set the URL of any post, page, tag or category to anything you want. Old permalinks will redirect properly to the new address. Custom Permalinks give you ultimate control over your site structure.
16
 
137
  add_filter( 'custom_permalinks_allow_caps', 'yasglobal_allow_uppercaps' );
138
  `
139
 
140
+ === Allow Redundant Hyphens ===
141
+
142
+ To allow redundant hyphens, please add below-mentioned line in your theme `functions.php`:
143
+
144
+ `
145
+ function yasglobal_redundant_hyphens() {
146
+ return true;
147
+ }
148
+ add_filter( 'custom_permalinks_redundant_hyphens', 'yasglobal_redundant_hyphens' );
149
+ `
150
+
151
  === Manipulate Permalink Before Saving ===
152
 
153
  To make changes in permalink before saving, please use `custom_permalink_before_saving` filter. Here is an example to see how it works.
199
 
200
  == Changelog ==
201
 
202
+ = 2.4.0 - Nov 26, 2021 =
203
+
204
+ * Bugs
205
+ * [filter for leading special characters](https://wordpress.org/support/topic/filter-for-leading-special-characters/)
206
+ * [“search Permalinks” button doesn’t work. (part2)](https://wordpress.org/support/topic/search-permalinks-button-doesnt-work-part2/)
207
+ * [PHP 8 errors on first visit of Taxonomy Permalinks tab](https://github.com/samiahmedsiddiqui/custom-permalinks/issues/59)
208
+ * [Notice: Undefined variable: site_url in custom-permalinks/admin/class-custom-permalinks-post-types-table.php on line 306](https://github.com/samiahmedsiddiqui/custom-permalinks/issues/56)
209
+ * Enhancements
210
+ * [Pending Post Preview Link](https://wordpress.org/support/topic/pending-post-preview-link/)
211
+
212
  = 2.3.0 - Sep 21, 2021 =
213
 
214
  * Bugs
219
  * Enhancements
220
  * Allow period in the permalink
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  = Earlier versions =
223
 
224
  * For the changelog of earlier versions, please refer to the separate changelog.txt file.