Custom Permalinks - Version 1.2.21

Version Description

  • April 17, 2018 =

    • Bug
    • Removed final keyword with the classes. For further details: https://wordpress.org/support/topic/page-not-found-404-errors-after-latest-update/ https://wordpress.org/support/topic/throws-404-here-and-there/
Download this release

Release Info

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

Code changes from version 1.2.20 to 1.2.21

admin/class-custom-permalinks-about.php CHANGED
@@ -3,7 +3,7 @@
3
  * @package CustomPermalinks\Admin
4
  */
5
 
6
- final class Custom_Permalinks_About {
7
 
8
  /**
9
  * Class constructor.
@@ -25,27 +25,27 @@ final class Custom_Permalinks_About {
25
  wp_enqueue_style( 'style', $plugin_url . '/css/about-plugins.min.css' );
26
  $plugin_name = __( 'Custom Permalinks', 'custom-permalinks' );
27
  $button_text = __( 'Check it out', 'custom-permalinks' );
28
- $five_star = '<span class="star">
29
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
30
- <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
31
  10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
32
- </svg>
33
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
34
- <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
35
- 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
36
- </svg>
37
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
38
- <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
39
- 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
40
- </svg>
41
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
42
- <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
43
- 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
44
- </svg>
45
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
46
- <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
47
- 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
48
- </svg>
49
  </span>';
50
  ?>
51
 
3
  * @package CustomPermalinks\Admin
4
  */
5
 
6
+ class Custom_Permalinks_About {
7
 
8
  /**
9
  * Class constructor.
25
  wp_enqueue_style( 'style', $plugin_url . '/css/about-plugins.min.css' );
26
  $plugin_name = __( 'Custom Permalinks', 'custom-permalinks' );
27
  $button_text = __( 'Check it out', 'custom-permalinks' );
28
+ $five_star = '<span class="star">
29
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
30
+ <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
31
  10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
32
+ </svg>
33
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
34
+ <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
35
+ 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
36
+ </svg>
37
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
38
+ <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
39
+ 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
40
+ </svg>
41
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
42
+ <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
43
+ 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
44
+ </svg>
45
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
46
+ <polygon points="26.934,1.318 35.256,18.182 53.867,20.887 40.4,34.013 43.579,52.549 26.934,43.798
47
+ 10.288,52.549 13.467,34.013 0,20.887 18.611,18.182 "/>
48
+ </svg>
49
  </span>';
50
  ?>
51
 
admin/class-custom-permalinks-admin.php CHANGED
@@ -3,7 +3,7 @@
3
  * @package CustomPermalinks\Admin
4
  */
5
 
6
- final class Custom_Permalinks_Admin {
7
 
8
  /**
9
  * Initializes WordPress hooks
3
  * @package CustomPermalinks\Admin
4
  */
5
 
6
+ class Custom_Permalinks_Admin {
7
 
8
  /**
9
  * Initializes WordPress hooks
custom-permalinks.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Custom Permalinks
4
  * Plugin URI: https://wordpress.org/plugins/custom-permalinks/
5
  * Description: Set custom permalinks on a per-post basis
6
- * Version: 1.2.20
7
  * Author: Sami Ahmed Siddiqui
8
  * Author URI: https://www.custompermalinks.com/
9
  * Donate link: https://www.paypal.me/yasglobal
@@ -39,7 +39,7 @@ if ( ! defined( 'ABSPATH' ) ) {
39
  exit;
40
  }
41
 
42
- final class Custom_Permalinks {
43
 
44
  /**
45
  * Class constructor.
@@ -64,7 +64,7 @@ final class Custom_Permalinks {
64
  }
65
 
66
  if ( ! defined( 'CUSTOM_PERMALINKS_PLUGIN_VERSION' ) ) {
67
- define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.20' );
68
  }
69
 
70
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
3
  * Plugin Name: Custom Permalinks
4
  * Plugin URI: https://wordpress.org/plugins/custom-permalinks/
5
  * Description: Set custom permalinks on a per-post basis
6
+ * Version: 1.2.21
7
  * Author: Sami Ahmed Siddiqui
8
  * Author URI: https://www.custompermalinks.com/
9
  * Donate link: https://www.paypal.me/yasglobal
39
  exit;
40
  }
41
 
42
+ class Custom_Permalinks {
43
 
44
  /**
45
  * Class constructor.
64
  }
65
 
66
  if ( ! defined( 'CUSTOM_PERMALINKS_PLUGIN_VERSION' ) ) {
67
+ define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.21' );
68
  }
69
 
70
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
frontend/class-custom-permalinks-form.php CHANGED
@@ -3,7 +3,7 @@
3
  * @package CustomPermalinks\Frontend\Form
4
  */
5
 
6
- final class Custom_Permalinks_Form {
7
 
8
  /**
9
  * Initialize WordPress Hooks
3
  * @package CustomPermalinks\Frontend\Form
4
  */
5
 
6
+ class Custom_Permalinks_Form {
7
 
8
  /**
9
  * Initialize WordPress Hooks
frontend/class-custom-permalinks-frontend.php CHANGED
@@ -3,7 +3,7 @@
3
  * @package CustomPermalinks\Frontend
4
  */
5
 
6
- final class Custom_Permalinks_Frontend {
7
 
8
  /**
9
  * Initialize WordPress Hooks
@@ -12,7 +12,7 @@ final class Custom_Permalinks_Frontend {
12
  * @since 1.2
13
  * @return void
14
  */
15
- public function init() {
16
  add_filter( 'request', array( $this, 'parse_request' ), 10, 1 );
17
 
18
  add_action( 'template_redirect', array( $this, 'make_redirect' ), 5 );
@@ -37,52 +37,53 @@ final class Custom_Permalinks_Frontend {
37
  add_filter( 'user_trailingslashit',
38
  array( $this, 'custom_permalinks_trailingslash' ), 10, 2
39
  );
40
- }
41
 
42
  /**
43
  * Filter to rewrite the query if we have a matching post
44
  *
45
  * @access public
 
46
  * @return void
47
  */
48
- public function parse_request( $query ) {
49
- global $wpdb;
50
- global $_CPRegisteredURL;
51
-
52
- // First, search for a matching custom permalink,
53
- // and if found, generate the corresponding original URL
54
-
55
- $original_url = NULL;
56
-
57
- // Get request URI, strip parameters and /'s
58
- $url = parse_url( get_bloginfo( 'url' ) );
59
- $url = isset( $url['path'] ) ? $url['path'] : '';
60
- $request = ltrim( substr( $_SERVER['REQUEST_URI'], strlen( $url ) ), '/' );
61
- $pos = strpos( $request, '?' );
62
- if ( $pos ) {
63
- $request = substr( $request, 0, $pos );
64
- }
65
-
66
- if ( ! $request ) {
67
- return $query;
68
- }
69
-
70
- $ignore = apply_filters( 'custom_permalinks_request_ignore', $request );
71
-
72
- if ( '__true' === $ignore ) {
73
- return $query;
74
- }
75
-
76
- if ( defined( 'POLYLANG_VERSION' ) ) {
77
- require_once(
78
- CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-form.php'
79
- );
80
- $cp_form = new Custom_Permalinks_Form();
81
- $request = $cp_form->custom_permalinks_check_conflicts( $request );
82
- }
83
  $request_noslash = preg_replace( '@/+@','/', trim( $request, '/' ) );
84
 
85
- $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status " .
86
  " FROM $wpdb->posts AS p INNER JOIN $wpdb->postmeta AS pm ON (pm.post_id = p.ID) " .
87
  " WHERE pm.meta_key = 'custom_permalink' " .
88
  " AND (pm.meta_value = '%s' OR pm.meta_value = '%s') " .
@@ -90,10 +91,10 @@ final class Custom_Permalinks_Frontend {
90
  " ORDER BY FIELD(post_status,'publish','private','draft','auto-draft','inherit')," .
91
  " FIELD(post_type,'post','page') LIMIT 1", $request_noslash, $request_noslash . "/" );
92
 
93
- $posts = $wpdb->get_results( $sql );
94
 
95
  $remove_like_query = apply_filters( 'cp_remove_like_query', '__true' );
96
- if ( ! $posts && '__false' !== $remove_like_query ) {
97
  $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status FROM $wpdb->posts AS p " .
98
  " LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE " .
99
  " meta_key = 'custom_permalink' AND meta_value != '' AND " .
@@ -106,7 +107,7 @@ final class Custom_Permalinks_Frontend {
106
  $request_noslash, $request_noslash . "/" );
107
 
108
  $posts = $wpdb->get_results( $sql );
109
- }
110
 
111
  if ( $posts ) {
112
  // A post matches our request
@@ -227,6 +228,7 @@ final class Custom_Permalinks_Frontend {
227
  * Action to redirect to the custom permalink
228
  *
229
  * @access public
 
230
  * @return void
231
  */
232
  public function make_redirect() {
3
  * @package CustomPermalinks\Frontend
4
  */
5
 
6
+ class Custom_Permalinks_Frontend {
7
 
8
  /**
9
  * Initialize WordPress Hooks
12
  * @since 1.2
13
  * @return void
14
  */
15
+ public function init() {
16
  add_filter( 'request', array( $this, 'parse_request' ), 10, 1 );
17
 
18
  add_action( 'template_redirect', array( $this, 'make_redirect' ), 5 );
37
  add_filter( 'user_trailingslashit',
38
  array( $this, 'custom_permalinks_trailingslash' ), 10, 2
39
  );
40
+ }
41
 
42
  /**
43
  * Filter to rewrite the query if we have a matching post
44
  *
45
  * @access public
46
+ * @since 0.1
47
  * @return void
48
  */
49
+ public function parse_request( $query ) {
50
+ global $wpdb;
51
+ global $_CPRegisteredURL;
52
+
53
+ // First, search for a matching custom permalink,
54
+ // and if found, generate the corresponding original URL
55
+
56
+ $original_url = NULL;
57
+
58
+ // Get request URI, strip parameters and /'s
59
+ $url = parse_url( get_bloginfo( 'url' ) );
60
+ $url = isset( $url['path'] ) ? $url['path'] : '';
61
+ $request = ltrim( substr( $_SERVER['REQUEST_URI'], strlen( $url ) ), '/' );
62
+ $pos = strpos( $request, '?' );
63
+ if ( $pos ) {
64
+ $request = substr( $request, 0, $pos );
65
+ }
66
+
67
+ if ( ! $request ) {
68
+ return $query;
69
+ }
70
+
71
+ $ignore = apply_filters( 'custom_permalinks_request_ignore', $request );
72
+
73
+ if ( '__true' === $ignore ) {
74
+ return $query;
75
+ }
76
+
77
+ if ( defined( 'POLYLANG_VERSION' ) ) {
78
+ require_once(
79
+ CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-form.php'
80
+ );
81
+ $cp_form = new Custom_Permalinks_Form();
82
+ $request = $cp_form->custom_permalinks_check_conflicts( $request );
83
+ }
84
  $request_noslash = preg_replace( '@/+@','/', trim( $request, '/' ) );
85
 
86
+ $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status " .
87
  " FROM $wpdb->posts AS p INNER JOIN $wpdb->postmeta AS pm ON (pm.post_id = p.ID) " .
88
  " WHERE pm.meta_key = 'custom_permalink' " .
89
  " AND (pm.meta_value = '%s' OR pm.meta_value = '%s') " .
91
  " ORDER BY FIELD(post_status,'publish','private','draft','auto-draft','inherit')," .
92
  " FIELD(post_type,'post','page') LIMIT 1", $request_noslash, $request_noslash . "/" );
93
 
94
+ $posts = $wpdb->get_results( $sql );
95
 
96
  $remove_like_query = apply_filters( 'cp_remove_like_query', '__true' );
97
+ if ( ! $posts && '__false' !== $remove_like_query ) {
98
  $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status FROM $wpdb->posts AS p " .
99
  " LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE " .
100
  " meta_key = 'custom_permalink' AND meta_value != '' AND " .
107
  $request_noslash, $request_noslash . "/" );
108
 
109
  $posts = $wpdb->get_results( $sql );
110
+ }
111
 
112
  if ( $posts ) {
113
  // A post matches our request
228
  * Action to redirect to the custom permalink
229
  *
230
  * @access public
231
+ * @since 0.1
232
  * @return void
233
  */
234
  public function make_redirect() {
frontend/js/script-form.js CHANGED
@@ -48,4 +48,4 @@ function changeSEOLink () {
48
 
49
  if ( checkYoastSEO ) {
50
  window.addEventListener("load", changeSEOLink, false);
51
- }
48
 
49
  if ( checkYoastSEO ) {
50
  window.addEventListener("load", changeSEOLink, false);
51
+ }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/yasglobal
4
  Tags: permalink, url, link, address, custom, redirect, custom post type
5
  Requires at least: 2.6
6
  Tested up to: 4.9
7
- Stable tag: 1.2.20
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl.html
10
 
@@ -83,16 +83,22 @@ This process defines you the steps to follow either you are installing through W
83
  1. Visit 'Plugins > Add New'
84
  2. Search for Custom Permalinks
85
  3. Activate Custom Permalinks from your Plugins page.
86
- 4. Go to "after activation" below.
87
 
88
  **Manually**
89
 
90
  1. Upload the `custom-permalinks` folder to the `/wp-content/plugins/` directory
91
  2. Activate Custom Permalinks through the 'Plugins' menu in WordPress
92
- 3. Go to "after activation" below.
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
 
 
 
96
  = 1.2.20 - April 11, 2018 =
97
 
98
  * Bug
4
  Tags: permalink, url, link, address, custom, redirect, custom post type
5
  Requires at least: 2.6
6
  Tested up to: 4.9
7
+ Stable tag: 1.2.21
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl.html
10
 
83
  1. Visit 'Plugins > Add New'
84
  2. Search for Custom Permalinks
85
  3. Activate Custom Permalinks from your Plugins page.
 
86
 
87
  **Manually**
88
 
89
  1. Upload the `custom-permalinks` folder to the `/wp-content/plugins/` directory
90
  2. Activate Custom Permalinks through the 'Plugins' menu in WordPress
 
91
 
92
  == Changelog ==
93
 
94
+ = 1.2.21 - April 17, 2018 =
95
+
96
+ * Bug
97
+ * Removed final keyword with the classes.
98
+ For further details:
99
+ https://wordpress.org/support/topic/page-not-found-404-errors-after-latest-update/
100
+ https://wordpress.org/support/topic/throws-404-here-and-there/
101
+
102
  = 1.2.20 - April 11, 2018 =
103
 
104
  * Bug