Version Description
- Fixed PolyLang Conflicts
Download this release
Release Info
Developer | sasiddiqui |
Plugin | Custom Permalinks |
Version | 0.9.3 |
Comparing to | |
See all releases |
Code changes from version 0.9.2 to 0.9.3
- README.md +22 -0
- custom-permalinks.php +24 -19
- readme.txt +5 -1
README.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Custom Permalinks
|
2 |
+
|
3 |
+
## Description
|
4 |
+
|
5 |
+
Lay out your site the way *you* want it. Set the URL of any post, page, tag or category to anything you want.
|
6 |
+
Old permalinks will redirect properly to the new address. Custom Permalinks gives you ultimate control
|
7 |
+
over your site structure.
|
8 |
+
|
9 |
+
Be warned: *This plugin is not a replacement for WordPress's built-in permalink system*. Check your WordPress
|
10 |
+
administration's "Permalinks" settings page first, to make sure that this doesn't already meet your needs.
|
11 |
+
|
12 |
+
This plugin is only useful for assigning custom permalinks for *individual* posts, pages, tags or categories.
|
13 |
+
It will not apply whole permalink structures, or automatically apply a category's custom permalink to the posts
|
14 |
+
within that category.
|
15 |
+
|
16 |
+
> If anyone wants the different Structure Tags for their Post types or use symbols in the URLs So, use the [Permalinks Customizer](https://wordpress.org/plugins/permalinks-customizer/) which is a fork of this plugin and contains the enhancement of this plugin.
|
17 |
+
|
18 |
+
## Installation
|
19 |
+
|
20 |
+
1. Unzip the package, and upload `custom-permalinks` to the `/wp-content/plugins/` directory
|
21 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
22 |
+
3. Edit any post, page, tag or category to set a custom permalink.
|
custom-permalinks.php
CHANGED
@@ -5,9 +5,9 @@
|
|
5 |
* Plugin URI: https://wordpress.org/plugins/custom-permalinks/
|
6 |
* Donate link: https://www.paypal.me/yasglobal
|
7 |
* Description: Set custom permalinks on a per-post basis
|
8 |
-
* Version: 0.9.
|
9 |
-
* Author:
|
10 |
-
* Author URI:
|
11 |
* Text Domain: custom-permalinks
|
12 |
*/
|
13 |
|
@@ -42,14 +42,16 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
42 |
|
43 |
/**
|
44 |
* Filter to replace the post permalink with the custom one
|
45 |
-
*
|
46 |
-
* @package CustomPermalinks
|
47 |
-
* @since 0.1
|
48 |
*/
|
49 |
function custom_permalinks_post_link($permalink, $post) {
|
50 |
$custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true );
|
51 |
if ( $custom_permalink ) {
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
return $permalink;
|
@@ -57,14 +59,15 @@ function custom_permalinks_post_link($permalink, $post) {
|
|
57 |
|
58 |
/**
|
59 |
* Filter to replace the page permalink with the custom one
|
60 |
-
*
|
61 |
-
* @package CustomPermalinks
|
62 |
-
* @since 0.4
|
63 |
*/
|
64 |
function custom_permalinks_page_link($permalink, $page) {
|
65 |
$custom_permalink = get_post_meta( $page, 'custom_permalink', true );
|
66 |
-
if ( $custom_permalink ) {
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
return $permalink;
|
@@ -72,18 +75,21 @@ function custom_permalinks_page_link($permalink, $page) {
|
|
72 |
|
73 |
/**
|
74 |
* Filter to replace the term permalink with the custom one
|
75 |
-
*
|
76 |
-
* @package CustomPermalinks
|
77 |
-
* @since 0.1
|
78 |
*/
|
79 |
function custom_permalinks_term_link($permalink, $term) {
|
80 |
$table = get_option('custom_permalink_table');
|
81 |
if ( is_object($term) ) $term = $term->term_id;
|
82 |
|
83 |
$custom_permalink = custom_permalinks_permalink_for_term($term);
|
84 |
-
|
85 |
if ( $custom_permalink ) {
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
return $permalink;
|
@@ -811,8 +817,7 @@ function custom_permalinks_check_conflicts($requested_url = '') {
|
|
811 |
if ($requested_url == '') return;
|
812 |
|
813 |
// Check if the Polylang Plugin is installed so, make changes in the URL
|
814 |
-
|
815 |
-
if (is_plugin_active("polylang/polylang.php")) {
|
816 |
$polylang_config = get_option('polylang');
|
817 |
if ($polylang_config['force_lang'] == 1) {
|
818 |
|
5 |
* Plugin URI: https://wordpress.org/plugins/custom-permalinks/
|
6 |
* Donate link: https://www.paypal.me/yasglobal
|
7 |
* Description: Set custom permalinks on a per-post basis
|
8 |
+
* Version: 0.9.3
|
9 |
+
* Author: Sami Ahmed Siddiqui
|
10 |
+
* Author URI: https://www.yasglobal.com/web-design-development/wordpress/custom-permalinks/
|
11 |
* Text Domain: custom-permalinks
|
12 |
*/
|
13 |
|
42 |
|
43 |
/**
|
44 |
* Filter to replace the post permalink with the custom one
|
|
|
|
|
|
|
45 |
*/
|
46 |
function custom_permalinks_post_link($permalink, $post) {
|
47 |
$custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true );
|
48 |
if ( $custom_permalink ) {
|
49 |
+
$post_type = isset($post->post_type) ? $post->post_type : 'post';
|
50 |
+
$language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $post->ID, 'element_type' => $post_type ) );
|
51 |
+
if ( $language_code )
|
52 |
+
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink, $language_code );
|
53 |
+
else
|
54 |
+
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink );
|
55 |
}
|
56 |
|
57 |
return $permalink;
|
59 |
|
60 |
/**
|
61 |
* Filter to replace the page permalink with the custom one
|
|
|
|
|
|
|
62 |
*/
|
63 |
function custom_permalinks_page_link($permalink, $page) {
|
64 |
$custom_permalink = get_post_meta( $page, 'custom_permalink', true );
|
65 |
+
if ( $custom_permalink ) {
|
66 |
+
$language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $page, 'element_type' => 'page' ) );
|
67 |
+
if ( $language_code )
|
68 |
+
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink, $language_code );
|
69 |
+
else
|
70 |
+
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink );
|
71 |
}
|
72 |
|
73 |
return $permalink;
|
75 |
|
76 |
/**
|
77 |
* Filter to replace the term permalink with the custom one
|
|
|
|
|
|
|
78 |
*/
|
79 |
function custom_permalinks_term_link($permalink, $term) {
|
80 |
$table = get_option('custom_permalink_table');
|
81 |
if ( is_object($term) ) $term = $term->term_id;
|
82 |
|
83 |
$custom_permalink = custom_permalinks_permalink_for_term($term);
|
|
|
84 |
if ( $custom_permalink ) {
|
85 |
+
$taxonomy = get_term($term);
|
86 |
+
if ( isset($taxonomy) && isset($taxonomy->term_taxonomy_id) ) {
|
87 |
+
$term_type = isset($taxonomy->taxonomy) ? $taxonomy->taxonomy : 'category';
|
88 |
+
$language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $taxonomy->term_taxonomy_id, 'element_type' => $term_type ) );
|
89 |
+
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink, $language_code );
|
90 |
+
} else {
|
91 |
+
return apply_filters( 'wpml_permalink', home_url()."/".$custom_permalink );
|
92 |
+
}
|
93 |
}
|
94 |
|
95 |
return $permalink;
|
817 |
if ($requested_url == '') return;
|
818 |
|
819 |
// Check if the Polylang Plugin is installed so, make changes in the URL
|
820 |
+
if (defined( 'POLYLANG_VERSION' )) {
|
|
|
821 |
$polylang_config = get_option('polylang');
|
822 |
if ($polylang_config['force_lang'] == 1) {
|
823 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ 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: 0.9.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -34,6 +34,10 @@ within that category.
|
|
34 |
|
35 |
== Changelog ==
|
36 |
|
|
|
|
|
|
|
|
|
37 |
= 0.9.2 =
|
38 |
|
39 |
* Fixed WPML Conflicts
|
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: 0.9.3
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
34 |
|
35 |
== Changelog ==
|
36 |
|
37 |
+
= 0.9.3 =
|
38 |
+
|
39 |
+
* Fixed PolyLang Conflicts
|
40 |
+
|
41 |
= 0.9.2 =
|
42 |
|
43 |
* Fixed WPML Conflicts
|