Skip to content

Commit

Permalink
Fixed WPML Conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
samiahmedsiddiqui committed Jul 16, 2017
1 parent d19ce3a commit 2fa938f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 9 additions & 5 deletions custom-permalinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://wordpress.org/plugins/custom-permalinks/
* Donate link: https://www.paypal.me/yasglobal
* Description: Set custom permalinks on a per-post basis
* Version: 0.9.1
* Version: 0.9.2
* Author: Michael Tyson
* Author URI: http://atastypixel.com/blog
* Text Domain: custom-permalinks
Expand All @@ -29,8 +29,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

// Make sure we don't expose any info if called directly
if ( ! defined( 'ABSPATH' ) ) {
exit; // don't access directly
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
exit;
}

/**
Expand All @@ -47,7 +49,7 @@
function custom_permalinks_post_link($permalink, $post) {
$custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true );
if ( $custom_permalink ) {
return home_url()."/".$custom_permalink;
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink );
}

return $permalink;
Expand All @@ -62,7 +64,7 @@ function custom_permalinks_post_link($permalink, $post) {
function custom_permalinks_page_link($permalink, $page) {
$custom_permalink = get_post_meta( $page, 'custom_permalink', true );
if ( $custom_permalink ) {
return home_url()."/".$custom_permalink;
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink );
}

return $permalink;
Expand All @@ -81,7 +83,7 @@ function custom_permalinks_term_link($permalink, $term) {
$custom_permalink = custom_permalinks_permalink_for_term($term);

if ( $custom_permalink ) {
return home_url()."/".$custom_permalink;
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink );
}

return $permalink;
Expand Down Expand Up @@ -280,8 +282,10 @@ function custom_permalinks_request($query) {
function custom_permalinks_trailingslash($string, $type) {
global $_CPRegisteredURL;

remove_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 );
$url = parse_url(get_bloginfo('url'));
$request = ltrim(isset($url['path']) ? substr($string, strlen($url['path'])) : $string, '/');
add_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 );

if ( !trim($request) ) return $string;

Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Contributors: sasiddiqui, michaeltyson
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.7
Stable tag: 0.9.1
Tested up to: 4.8
Stable tag: 0.9.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -34,6 +34,10 @@ within that category.

== Changelog ==

= 0.9.2 =

* Fixed WPML Conflicts

= 0.9.1 =

* Fixed issues of Filters and Actions (Replaces 'edit_files' with 10)
Expand Down

0 comments on commit 2fa938f

Please sign in to comment.