Custom Permalinks - Version 1.2.8

Version Description

  • Add Order by in request query
Download this release

Release Info

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

Code changes from version 1.2.7 to 1.2.8

custom-permalinks-main.php CHANGED
@@ -15,7 +15,7 @@ if ( ! function_exists( "add_action" ) || ! function_exists( "add_filter" ) ) {
15
  exit();
16
  }
17
 
18
- define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.7' );
19
 
20
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
21
  define( 'CUSTOM_PERMALINKS_PATH', plugin_dir_path( __FILE__ ) );
15
  exit();
16
  }
17
 
18
+ define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.8' );
19
 
20
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
21
  define( 'CUSTOM_PERMALINKS_PATH', plugin_dir_path( __FILE__ ) );
custom-permalinks.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Custom Permalinks
5
  * Plugin URI: https://wordpress.org/plugins/custom-permalinks/
6
  * Description: Set custom permalinks on a per-post basis
7
- * Version: 1.2.7
8
  * Author: Sami Ahmed Siddiqui
9
  * Author URI: https://www.yasglobal.com/web-design-development/wordpress/custom-permalinks/
10
  * Donate link: https://www.paypal.me/yasglobal
4
  * Plugin Name: Custom Permalinks
5
  * Plugin URI: https://wordpress.org/plugins/custom-permalinks/
6
  * Description: Set custom permalinks on a per-post basis
7
+ * Version: 1.2.8
8
  * Author: Sami Ahmed Siddiqui
9
  * Author URI: https://www.yasglobal.com/web-design-development/wordpress/custom-permalinks/
10
  * Donate link: https://www.paypal.me/yasglobal
frontend/class-custom-permalinks-frontend.php CHANGED
@@ -66,7 +66,8 @@ class Custom_Permalinks_Frontend {
66
  " WHERE pm.meta_key = 'custom_permalink' " .
67
  " AND (pm.meta_value = '%s' OR pm.meta_value = '%s') " .
68
  " AND p.post_status != 'trash' AND p.post_type != 'nav_menu_item' " .
69
- " LIMIT 1", $request_noslash, $request_noslash . "/" );
 
70
 
71
  $posts = $wpdb->get_results( $sql );
72
 
@@ -186,7 +187,6 @@ class Custom_Permalinks_Frontend {
186
  * Action to redirect to the custom permalink
187
  */
188
  public function custom_permalinks_redirect() {
189
-
190
  global $wpdb;
191
 
192
  $custom_permalink = '';
@@ -208,13 +208,13 @@ class Custom_Permalinks_Frontend {
208
  }
209
  $request_noslash = preg_replace( '@/+@','/', trim( $request, '/' ) );
210
 
211
-
212
  $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status " .
213
  " FROM $wpdb->posts AS p INNER JOIN $wpdb->postmeta AS pm ON (pm.post_id = p.ID) " .
214
  " WHERE pm.meta_key = 'custom_permalink' " .
215
  " AND (pm.meta_value = '%s' OR pm.meta_value = '%s') " .
216
  " AND p.post_status != 'trash' AND p.post_type != 'nav_menu_item' " .
217
- " LIMIT 1", $request_noslash, $request_noslash . "/" );
 
218
  $posts = $wpdb->get_results( $sql );
219
 
220
  if ( ! $posts ) {
66
  " WHERE pm.meta_key = 'custom_permalink' " .
67
  " AND (pm.meta_value = '%s' OR pm.meta_value = '%s') " .
68
  " AND p.post_status != 'trash' AND p.post_type != 'nav_menu_item' " .
69
+ " ORDER BY FIELD(post_status,'publish','private','draft','auto-draft','inherit')," .
70
+ " FIELD(post_type,'post','page') LIMIT 1", $request_noslash, $request_noslash . "/" );
71
 
72
  $posts = $wpdb->get_results( $sql );
73
 
187
  * Action to redirect to the custom permalink
188
  */
189
  public function custom_permalinks_redirect() {
 
190
  global $wpdb;
191
 
192
  $custom_permalink = '';
208
  }
209
  $request_noslash = preg_replace( '@/+@','/', trim( $request, '/' ) );
210
 
 
211
  $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status " .
212
  " FROM $wpdb->posts AS p INNER JOIN $wpdb->postmeta AS pm ON (pm.post_id = p.ID) " .
213
  " WHERE pm.meta_key = 'custom_permalink' " .
214
  " AND (pm.meta_value = '%s' OR pm.meta_value = '%s') " .
215
  " AND p.post_status != 'trash' AND p.post_type != 'nav_menu_item' " .
216
+ " ORDER BY FIELD(post_status,'publish','private','draft','auto-draft','inherit')," .
217
+ " FIELD(post_type,'post','page') LIMIT 1", $request_noslash, $request_noslash . "/" );
218
  $posts = $wpdb->get_results( $sql );
219
 
220
  if ( ! $posts ) {
readme.txt CHANGED
@@ -4,8 +4,8 @@ Contributors: sasiddiqui, michaeltyson
4
  Donate link: https://www.paypal.me/yasglobal
5
  Tags: permalink, url, link, address, custom, redirect, custom post type
6
  Requires at least: 2.6
7
- Tested up to: 4.8
8
- Stable tag: 1.2.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -67,6 +67,10 @@ The support from the users that love Custom Permalinks is huge. You can support
67
 
68
  == Changelog ==
69
 
 
 
 
 
70
  = 1.2.7 =
71
 
72
  * Fixed Parse Error
4
  Donate link: https://www.paypal.me/yasglobal
5
  Tags: permalink, url, link, address, custom, redirect, custom post type
6
  Requires at least: 2.6
7
+ Tested up to: 4.9
8
+ Stable tag: 1.2.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
67
 
68
  == Changelog ==
69
 
70
+ = 1.2.8 =
71
+
72
+ * Add Order by in request query
73
+
74
  = 1.2.7 =
75
 
76
  * Fixed Parse Error