Skip to content

Commit

Permalink
Version bump to 1.2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
samiahmedsiddiqui committed Jan 15, 2018
1 parent 0c49674 commit 5a95d88
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 33 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ within that category.
## Filters

If you want to exclude some Permalink to processed with the plugin so, just add the filter looks like this:
To exclude any Permalink to processed with the plugin so, just add the filter looks like this:
```
function check_xml_sitemap_url( $permalink ) {
if ( false !== strpos( $permalink, 'sitemap.xml' )) {
Expand All @@ -28,9 +28,7 @@ function check_xml_sitemap_url( $permalink ) {
add_filter( 'custom_permalinks_request_ignore', 'check_xml_sitemap_url' );
```

If you want to exclude permalink from any post type so, use `custom_permalinks_exclude_post_type` filter.

`custom_permalinks_exclude_post_type` filter looks like this:
To exclude permalink from any post type so, just add the filter looks like this:
```
function yasglobal_exclude_post_types( $post_type ) {
if ( $post_type == 'custompost' ) {
Expand All @@ -42,6 +40,12 @@ add_filter( 'custom_permalinks_exclude_post_type', 'yasglobal_exclude_post_types
```
Note: `custom_permalinks_exclude_post_type` doesn't work on the posts permalink which has been created previously.

To make the like query works as it was before so, just add this line in your theme's functions.php:
```
add_filter( 'custom_permalinks_like_query', '__return_true');
```
Note: Use `custom_permalinks_like_query` filter if the URLs doesn't works for you after upgrading to v1.2.9

## Thanks for the Support!

The support from the users that love Custom Permalinks is huge. You can support Custom Permalinks's future development and help to make it even better by donating or even giving a 5 star rating with a nice message to me :)
Expand Down
4 changes: 2 additions & 2 deletions custom-permalinks-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
exit;
}

if ( ! function_exists( "add_action" ) || ! function_exists( "add_filter" ) ) {
if ( ! function_exists( 'add_action' ) || ! function_exists( 'add_filter' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}

define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.8' );
define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.9' );

if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
define( 'CUSTOM_PERMALINKS_PATH', plugin_dir_path( __FILE__ ) );
Expand Down
12 changes: 3 additions & 9 deletions custom-permalinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Plugin Name: Custom Permalinks
* Plugin URI: https://wordpress.org/plugins/custom-permalinks/
* Description: Set custom permalinks on a per-post basis
* Version: 1.2.8
* Version: 1.2.9
* Author: Sami Ahmed Siddiqui
* Author URI: https://www.yasglobal.com/web-design-development/wordpress/custom-permalinks/
* Author URI: https://www.custompermalinks.com
* Donate link: https://www.paypal.me/yasglobal
* License: GPLv2 or later
*
Expand All @@ -18,7 +18,7 @@

/**
* Custom Permalinks Plugin
* Copyright 2008-2017 Sami Ahmed Siddiqui <[email protected]>
* Copyright 2008-2018 Sami Ahmed Siddiqui <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -41,12 +41,6 @@
exit;
}

if ( ! function_exists( "add_action" ) || ! function_exists( "add_filter" ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}

if ( ! defined( 'CUSTOM_PERMALINKS_FILE' ) ) {
define( 'CUSTOM_PERMALINKS_FILE', __FILE__ );
}
Expand Down
37 changes: 24 additions & 13 deletions frontend/class-custom-permalinks-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,19 @@ public function custom_permalinks_request( $query ) {
return $query;
}

$ignore = apply_filters( 'custom_permalinks_request_ignore', $request );
$ignore = apply_filters( 'custom_permalinks_request_ignore', $request );
$def_query = apply_filters( 'custom_permalinks_like_query', '__false' );

if ( '__true' === $ignore ) {
return $query;
}

if ( defined( 'POLYLANG_VERSION' ) ) {
require_once( CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-form.php' );
$custom_permalinks_form = new Custom_Permalinks_Form();
$request = $custom_permalinks_form->custom_permalinks_check_conflicts( $request );
require_once(
CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-form.php'
);
$cp_form = new Custom_Permalinks_Form();
$request = $cp_form->custom_permalinks_check_conflicts( $request );
}
$request_noslash = preg_replace( '@/+@','/', trim( $request, '/' ) );

Expand All @@ -71,7 +74,8 @@ public function custom_permalinks_request( $query ) {

$posts = $wpdb->get_results( $sql );

if ( ! $posts ) {
if ( ! $posts && ( defined( 'POLYLANG_VERSION' )
|| defined( 'AMP__VERSION' ) || '__true' === $def_query ) ) {
$sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status FROM $wpdb->posts AS p " .
" LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE " .
" meta_key = 'custom_permalink' AND meta_value != '' AND " .
Expand Down Expand Up @@ -135,11 +139,13 @@ public function custom_permalinks_request( $query ) {

if ( $term['kind'] == 'category' ) {
$category_link = $this->custom_permalinks_original_category_link( $term['id'] );
$original_url = str_replace( trim( $permalink, '/' ), $category_link, trim( $request, '/' ) );
} else {
$category_link = $this->custom_permalinks_original_tag_link( $term['id'] );
$original_url = str_replace( trim( $permalink, '/' ), $category_link, trim( $request, '/' ) );
}

$original_url = str_replace(
trim( $permalink, '/' ), $category_link, trim( $request, '/' )
);
}
}
}
Expand All @@ -148,14 +154,18 @@ public function custom_permalinks_request( $query ) {
$original_url = str_replace( '//', '/', $original_url );

if ( ( $pos = strpos( $_SERVER['REQUEST_URI'], '?' ) ) !== false ) {
$query_vars = substr( $_SERVER['REQUEST_URI'], $pos + 1);
$query_vars = substr( $_SERVER['REQUEST_URI'], $pos + 1);
$original_url .= ( strpos( $original_url, '?' ) === false ? '?' : '&' ) . $query_vars;
}

// Now we have the original URL, run this back through WP->parse_request, in order to
// parse parameters properly. We set $_SERVER variables to fool the function.
$old_request_uri = $_SERVER['REQUEST_URI']; $old_query_string = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = '/' . ltrim( $original_url, '/' );
$old_request_uri = $_SERVER['REQUEST_URI'];
$old_query_string = '';
if ( isset( $_SERVER['QUERY_STRING'] ) ) {
$old_query_string = $_SERVER['QUERY_STRING'];
}
$_SERVER['REQUEST_URI'] = '/' . ltrim( $original_url, '/' );
$_SERVER['QUERY_STRING'] = ( ( $pos = strpos( $original_url, '?' ) ) !== false ? substr( $original_url, $pos + 1 ) : '' );
parse_str( $_SERVER['QUERY_STRING'], $query_array );
$old_values = array();
Expand All @@ -174,7 +184,8 @@ public function custom_permalinks_request( $query ) {
add_filter( 'request', array( $this, 'custom_permalinks_request' ), 10, 1 );

// Restore values
$_SERVER['REQUEST_URI'] = $old_request_uri; $_SERVER['QUERY_STRING'] = $old_query_string;
$_SERVER['REQUEST_URI'] = $old_request_uri;
$_SERVER['QUERY_STRING'] = $old_query_string;
foreach ( $old_values as $key => $value ) {
$_REQUEST[$key] = $value;
}
Expand Down Expand Up @@ -203,8 +214,8 @@ public function custom_permalinks_redirect() {

if ( defined( 'POLYLANG_VERSION' ) ) {
require_once( CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-form.php' );
$custom_permalinks_form = new Custom_Permalinks_Form();
$request = $custom_permalinks_form->custom_permalinks_check_conflicts( $request );
$cp_form = new Custom_Permalinks_Form();
$request = $cp_form->custom_permalinks_check_conflicts( $request );
}
$request_noslash = preg_replace( '@/+@','/', trim( $request, '/' ) );

Expand Down
27 changes: 22 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Donate link: https://www.paypal.me/yasglobal
Tags: permalink, url, link, address, custom, redirect, custom post type
Requires at least: 2.6
Tested up to: 4.9
Stable tag: 1.2.8
Stable tag: 1.2.9
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -28,7 +28,9 @@ within that category.

== Filters ==

If you want to exclude some Permalink to processed with the plugin so, just add the filter looks like this:
Plugin provides some filter which maybe used according to your needs.

To exclude any Permalink to processed with the plugin so, just add the filter looks like this:
`
function check_xml_sitemap_url( $permalink ) {
if ( false !== strpos( $permalink, 'sitemap.xml' )) {
Expand All @@ -39,9 +41,7 @@ function check_xml_sitemap_url( $permalink ) {
add_filter( 'custom_permalinks_request_ignore', 'check_xml_sitemap_url' );
`

If you want to exclude permalink from any post type so, use `custom_permalinks_exclude_post_type` filter.

custom_permalinks_exclude_post_type filter looks like this:
To exclude permalink from any post type so, just add the filter looks like this:
`
function yasglobal_exclude_post_types( $post_type ) {
if ( $post_type == 'custompost' ) {
Expand All @@ -51,8 +51,16 @@ function yasglobal_exclude_post_types( $post_type ) {
}
add_filter( 'custom_permalinks_exclude_post_type', 'yasglobal_exclude_post_types');
`

Note: custom_permalinks_exclude_post_type doesn't work on the posts permalink which has been created previously.

To make the like query works as it was before so, just add this line in your theme's functions.php:
`
add_filter( 'custom_permalinks_like_query', '__return_true');
`

Note: Use `custom_permalinks_like_query` filter if the URLs doesn't works for you after upgrading to v1.2.9

== Thanks for the Support! ==

The support from the users that love Custom Permalinks is huge. You can support Custom Permalinks's future development and help to make it even better by donating or even giving a 5 star rating with a nice message to me :)
Expand All @@ -67,6 +75,15 @@ The support from the users that love Custom Permalinks is huge. You can support

== Changelog ==

= 1.2.9 =

* Enhancements
* Added Filter to enable the like query
* Bugs
* PHP error displayed on all pages using custom permalinks
* Removed LIKE Query in default. It only works if the site uses PolyLang,
AMP Plugins or separately enabled using the provided filter.

= 1.2.8 =

* Add Order by in request query
Expand Down

0 comments on commit 5a95d88

Please sign in to comment.