Version Description
- Fixed Typo of Class Object for term on Admin Page
Download this release
Release Info
Developer | sasiddiqui |
Plugin | Custom Permalinks |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- admin/class-custom-permalinks-admin.php +23 -23
- admin/class-custom-permalinks-form.php +7 -7
- custom-permalinks-main.php +1 -1
- custom-permalinks.php +1 -1
- frontend/class-custom-permalinks-frontend.php +15 -15
- readme.txt +5 -1
admin/class-custom-permalinks-admin.php
CHANGED
@@ -26,15 +26,15 @@ class Custom_Permalinks_Admin {
|
|
26 |
*/
|
27 |
public function custom_permalinks_post_permalinks() {
|
28 |
global $wpdb;
|
29 |
-
$filter_options
|
30 |
$search_permalink = '';
|
31 |
-
$html
|
32 |
-
$error
|
33 |
|
34 |
// Handle Bulk Operations
|
35 |
if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'delete' )
|
36 |
|| ( isset( $_POST['action2'] ) && $_POST['action2'] == 'delete' )
|
37 |
-
&& isset( $_POST['permalink'] ) && !empty( $_POST['permalink'] ) ) {
|
38 |
$post_ids = implode( ',', $_POST['permalink'] );
|
39 |
if ( preg_match( '/^\d+(?:,\d+)*$/', $post_ids ) ) {
|
40 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids) AND meta_key = 'custom_permalink'" );
|
@@ -50,8 +50,8 @@ class Custom_Permalinks_Admin {
|
|
50 |
if ( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ) {
|
51 |
$filter_permalink = 'AND pm.meta_value LIKE "%' . $_GET['s'] . '%"';
|
52 |
$search_permalink = '&s=' . $_GET['s'] . '';
|
53 |
-
$search_value
|
54 |
-
$html
|
55 |
}
|
56 |
$page_limit = 'LIMIT 0, 20';
|
57 |
if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
@@ -64,14 +64,14 @@ class Custom_Permalinks_Admin {
|
|
64 |
if ( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'title' ) {
|
65 |
$filter_options .= '<input type="hidden" name="orderby" value="title" />';
|
66 |
if ( isset( $_GET['order'] ) && $_GET['order'] == 'desc' ) {
|
67 |
-
$sorting_by
|
68 |
-
$order_by
|
69 |
-
$order_by_class
|
70 |
$filter_options .= '<input type="hidden" name="order" value="desc" />';
|
71 |
} else {
|
72 |
-
$sorting_by
|
73 |
-
$order_by
|
74 |
-
$order_by_class
|
75 |
$filter_options .= '<input type="hidden" name="order" value="asc" />';
|
76 |
}
|
77 |
}
|
@@ -176,7 +176,7 @@ class Custom_Permalinks_Admin {
|
|
176 |
public function custom_permalinks_category_permalinks() {
|
177 |
|
178 |
$search_permalink = '';
|
179 |
-
$html
|
180 |
|
181 |
// Handle Bulk Operations
|
182 |
if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'delete' )
|
@@ -204,11 +204,11 @@ class Custom_Permalinks_Admin {
|
|
204 |
$search_value = '';
|
205 |
if ( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ) {
|
206 |
$search_permalink = '&s=' . $_GET['s'] . '';
|
207 |
-
$search_value
|
208 |
-
$html
|
209 |
}
|
210 |
$pager_offset = '0';
|
211 |
-
$page_limit
|
212 |
if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
213 |
$pager_offset = 20 * ( $_GET['paged'] - 1 );
|
214 |
$page_limit = $pager_offset + 20;
|
@@ -231,8 +231,8 @@ class Custom_Permalinks_Admin {
|
|
231 |
<input type="submit" id="doaction" class="button action" value="Apply">
|
232 |
</div>';
|
233 |
|
234 |
-
$posts
|
235 |
-
$table
|
236 |
$count_tags = count( $table );
|
237 |
if ( isset( $table ) && is_array( $table ) && $count_tags > 0 ) {
|
238 |
|
@@ -282,11 +282,11 @@ class Custom_Permalinks_Admin {
|
|
282 |
if ( $i >= $page_limit )
|
283 |
break;
|
284 |
|
285 |
-
$type
|
286 |
-
$term
|
287 |
-
$html .=
|
288 |
-
$html .=
|
289 |
-
$html .=
|
290 |
$html .= '<td>' . ucwords( $info['kind'] ) . '</td>';
|
291 |
$html .= '<td><a href="/' . $permalink . '" target="_blank" title="' . __( "Visit " . $term->name, "custom-permalinks" ) . '">/' . $permalink . '</a></td></tr>';
|
292 |
}
|
26 |
*/
|
27 |
public function custom_permalinks_post_permalinks() {
|
28 |
global $wpdb;
|
29 |
+
$filter_options = '';
|
30 |
$search_permalink = '';
|
31 |
+
$html = '';
|
32 |
+
$error = '';
|
33 |
|
34 |
// Handle Bulk Operations
|
35 |
if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'delete' )
|
36 |
|| ( isset( $_POST['action2'] ) && $_POST['action2'] == 'delete' )
|
37 |
+
&& isset( $_POST['permalink'] ) && ! empty( $_POST['permalink'] ) ) {
|
38 |
$post_ids = implode( ',', $_POST['permalink'] );
|
39 |
if ( preg_match( '/^\d+(?:,\d+)*$/', $post_ids ) ) {
|
40 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids) AND meta_key = 'custom_permalink'" );
|
50 |
if ( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ) {
|
51 |
$filter_permalink = 'AND pm.meta_value LIKE "%' . $_GET['s'] . '%"';
|
52 |
$search_permalink = '&s=' . $_GET['s'] . '';
|
53 |
+
$search_value = ltrim( htmlspecialchars( $_GET['s'] ), '/' );
|
54 |
+
$html .= '<span class="subtitle">Search results for "' . $search_value . '"</span>';
|
55 |
}
|
56 |
$page_limit = 'LIMIT 0, 20';
|
57 |
if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
64 |
if ( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'title' ) {
|
65 |
$filter_options .= '<input type="hidden" name="orderby" value="title" />';
|
66 |
if ( isset( $_GET['order'] ) && $_GET['order'] == 'desc' ) {
|
67 |
+
$sorting_by = 'ORDER By p.post_title DESC';
|
68 |
+
$order_by = 'asc';
|
69 |
+
$order_by_class = 'desc';
|
70 |
$filter_options .= '<input type="hidden" name="order" value="desc" />';
|
71 |
} else {
|
72 |
+
$sorting_by = 'ORDER By p.post_title';
|
73 |
+
$order_by = 'desc';
|
74 |
+
$order_by_class = 'asc';
|
75 |
$filter_options .= '<input type="hidden" name="order" value="asc" />';
|
76 |
}
|
77 |
}
|
176 |
public function custom_permalinks_category_permalinks() {
|
177 |
|
178 |
$search_permalink = '';
|
179 |
+
$html = '';
|
180 |
|
181 |
// Handle Bulk Operations
|
182 |
if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'delete' )
|
204 |
$search_value = '';
|
205 |
if ( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ) {
|
206 |
$search_permalink = '&s=' . $_GET['s'] . '';
|
207 |
+
$search_value = ltrim( htmlspecialchars( $_GET['s'] ), '/' );
|
208 |
+
$html .= '<span class="subtitle">Search results for "' . $search_value . '"</span>';
|
209 |
}
|
210 |
$pager_offset = '0';
|
211 |
+
$page_limit = 20;
|
212 |
if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
213 |
$pager_offset = 20 * ( $_GET['paged'] - 1 );
|
214 |
$page_limit = $pager_offset + 20;
|
231 |
<input type="submit" id="doaction" class="button action" value="Apply">
|
232 |
</div>';
|
233 |
|
234 |
+
$posts = 0;
|
235 |
+
$table = get_option( 'custom_permalink_table' );
|
236 |
$count_tags = count( $table );
|
237 |
if ( isset( $table ) && is_array( $table ) && $count_tags > 0 ) {
|
238 |
|
282 |
if ( $i >= $page_limit )
|
283 |
break;
|
284 |
|
285 |
+
$type = $info['kind'] == 'tag' ? 'post_tag' : 'category';
|
286 |
+
$term = get_term( $info['id'], $type );
|
287 |
+
$html .= '<tr valign="top">';
|
288 |
+
$html .= '<th scope="row" class="check-column"><input type="checkbox" name="permalink[]" value="' . $info['id'] . '" /></th>';
|
289 |
+
$html .= '<td><strong><a class="row-title" href="edit-tags.php?action=edit&taxonomy=' . $type . '&tag_ID=' . $info['id'] . ' ">' . $term->name . '</a></strong></td>';
|
290 |
$html .= '<td>' . ucwords( $info['kind'] ) . '</td>';
|
291 |
$html .= '<td><a href="/' . $permalink . '" target="_blank" title="' . __( "Visit " . $term->name, "custom-permalinks" ) . '">/' . $permalink . '</a></td></tr>';
|
292 |
}
|
admin/class-custom-permalinks-form.php
CHANGED
@@ -99,7 +99,7 @@ class Custom_Permalinks_Form {
|
|
99 |
}
|
100 |
}
|
101 |
|
102 |
-
return '<strong>' . __('Permalink:', 'custom-permalinks') . "</strong>\n" . $content .
|
103 |
( isset( $view_post ) ? "<span id='view-post-btn'><a href='$permalink' class='button button-small' target='_blank'>$view_post</a></span>\n" : "" );
|
104 |
}
|
105 |
|
@@ -121,7 +121,7 @@ class Custom_Permalinks_Form {
|
|
121 |
<?php
|
122 |
require_once( CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-frontend.php' );
|
123 |
$custom_permalinks_frontend = new Custom_Permalinks_Frontend();
|
124 |
-
$custom_permalinks_frontend->custom_permalinks_get_form( $permalink, $
|
125 |
?>
|
126 |
</div>
|
127 |
</div>
|
@@ -160,11 +160,11 @@ class Custom_Permalinks_Form {
|
|
160 |
*/
|
161 |
public function custom_permalinks_term_options( $object ) {
|
162 |
if ( is_object( $object ) && isset( $object->term_id ) ) {
|
163 |
-
|
|
|
|
|
164 |
|
165 |
-
if ( $object->term_id ) {
|
166 |
-
require_once( CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-frontend.php' );
|
167 |
-
$custom_permalinks_frontend = new Custom_Permalinks_Frontend();
|
168 |
if ( $object->taxonomy == 'post_tag' ) {
|
169 |
$originalPermalink = $custom_permalinks_frontend->custom_permalinks_original_tag_link( $object->term_id );
|
170 |
} else {
|
@@ -318,7 +318,7 @@ class Custom_Permalinks_Form {
|
|
318 |
if ( strpos( $requested_url, 'language/' ) !== false )
|
319 |
$requested_url = str_replace( "language/", "", $requested_url );
|
320 |
|
321 |
-
$remove_lang = ltrim( strstr( $requested_url, '/' ), '/');
|
322 |
if ( $remove_lang != '' )
|
323 |
return $remove_lang;
|
324 |
}
|
99 |
}
|
100 |
}
|
101 |
|
102 |
+
return '<strong>' . __( 'Permalink:', 'custom-permalinks' ) . "</strong>\n" . $content .
|
103 |
( isset( $view_post ) ? "<span id='view-post-btn'><a href='$permalink' class='button button-small' target='_blank'>$view_post</a></span>\n" : "" );
|
104 |
}
|
105 |
|
121 |
<?php
|
122 |
require_once( CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-frontend.php' );
|
123 |
$custom_permalinks_frontend = new Custom_Permalinks_Frontend();
|
124 |
+
$custom_permalinks_frontend->custom_permalinks_get_form( $permalink, $custom_permalinks_frontend->custom_permalinks_original_post_link( $post_id ) );
|
125 |
?>
|
126 |
</div>
|
127 |
</div>
|
160 |
*/
|
161 |
public function custom_permalinks_term_options( $object ) {
|
162 |
if ( is_object( $object ) && isset( $object->term_id ) ) {
|
163 |
+
require_once( CUSTOM_PERMALINKS_PATH . 'frontend/class-custom-permalinks-frontend.php' );
|
164 |
+
$custom_permalinks_frontend = new Custom_Permalinks_Frontend();
|
165 |
+
$permalink = $custom_permalinks_frontend->custom_permalinks_permalink_for_term( $object->term_id );
|
166 |
|
167 |
+
if ( $object->term_id ) {
|
|
|
|
|
168 |
if ( $object->taxonomy == 'post_tag' ) {
|
169 |
$originalPermalink = $custom_permalinks_frontend->custom_permalinks_original_tag_link( $object->term_id );
|
170 |
} else {
|
318 |
if ( strpos( $requested_url, 'language/' ) !== false )
|
319 |
$requested_url = str_replace( "language/", "", $requested_url );
|
320 |
|
321 |
+
$remove_lang = ltrim( strstr( $requested_url, '/' ), '/' );
|
322 |
if ( $remove_lang != '' )
|
323 |
return $remove_lang;
|
324 |
}
|
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.
|
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.2' );
|
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.
|
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.2
|
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
@@ -71,7 +71,7 @@ class Custom_Permalinks_Frontend {
|
|
71 |
// A post matches our request
|
72 |
|
73 |
// Preserve this url for later if it's the same as the permalink (no extra stuff)
|
74 |
-
if ( $request_noslash == trim( $posts[0]->meta_value, '/') )
|
75 |
$_CPRegisteredURL = $request;
|
76 |
|
77 |
if ( $posts[0]->post_status == 'draft' ) {
|
@@ -98,7 +98,7 @@ class Custom_Permalinks_Frontend {
|
|
98 |
|
99 |
if ( $original_url === NULL ) {
|
100 |
// See if any terms have a matching permalink
|
101 |
-
$table = get_option('custom_permalink_table');
|
102 |
if ( ! $table ) return $query;
|
103 |
|
104 |
foreach ( array_keys( $table ) as $permalink ) {
|
@@ -110,7 +110,7 @@ class Custom_Permalinks_Frontend {
|
|
110 |
if ( $request_noslash == trim( $permalink, '/' ) )
|
111 |
$_CPRegisteredURL = $request;
|
112 |
|
113 |
-
if ( $term['kind'] == 'category') {
|
114 |
$category_link = $this->custom_permalinks_original_category_link( $term['id'] );
|
115 |
$original_url = str_replace( trim( $permalink, '/' ), $category_link, trim( $request, '/' ) );
|
116 |
} else {
|
@@ -126,14 +126,14 @@ class Custom_Permalinks_Frontend {
|
|
126 |
|
127 |
if ( ( $pos = strpos( $_SERVER['REQUEST_URI'], '?' ) ) !== false ) {
|
128 |
$query_vars = substr( $_SERVER['REQUEST_URI'], $pos + 1);
|
129 |
-
$original_url .= ( strpos( $original_url, '?' ) === false ? '?' : '&') . $query_vars;
|
130 |
}
|
131 |
|
132 |
// Now we have the original URL, run this back through WP->parse_request, in order to
|
133 |
// parse parameters properly. We set $_SERVER variables to fool the function.
|
134 |
$old_request_uri = $_SERVER['REQUEST_URI']; $old_query_string = $_SERVER['QUERY_STRING'];
|
135 |
-
$_SERVER['REQUEST_URI'] = '/' . ltrim( $original_url, '/');
|
136 |
-
$_SERVER['QUERY_STRING'] = ( ( $pos = strpos( $original_url, '?' ) ) !== false ? substr( $original_url, $pos + 1 ) : '');
|
137 |
parse_str( $_SERVER['QUERY_STRING'], $query_array );
|
138 |
$old_values = array();
|
139 |
if ( is_array( $query_array ) )
|
@@ -143,11 +143,11 @@ class Custom_Permalinks_Frontend {
|
|
143 |
}
|
144 |
|
145 |
// Re-run the filter, now with original environment in place
|
146 |
-
remove_filter( 'request', array( $this, 'custom_permalinks_request'), 10, 1 );
|
147 |
global $wp;
|
148 |
$wp->parse_request();
|
149 |
$query = $wp->query_vars;
|
150 |
-
add_filter( 'request', array( $this, 'custom_permalinks_request'), 10, 1 );
|
151 |
|
152 |
// Restore values
|
153 |
$_SERVER['REQUEST_URI'] = $old_request_uri; $_SERVER['QUERY_STRING'] = $old_query_string;
|
@@ -189,7 +189,7 @@ class Custom_Permalinks_Frontend {
|
|
189 |
} else {
|
190 |
$original_permalink = $this->custom_permalinks_original_post_link( $post->ID );
|
191 |
}
|
192 |
-
}
|
193 |
$theTerm = $wp_query->get_queried_object();
|
194 |
$custom_permalink = $this->custom_permalinks_permalink_for_term( $theTerm->term_id );
|
195 |
if ( is_tag() ) {
|
@@ -200,7 +200,7 @@ class Custom_Permalinks_Frontend {
|
|
200 |
}
|
201 |
|
202 |
if ( $custom_permalink
|
203 |
-
&& ( substr($request, 0, strlen( $custom_permalink ) ) != $custom_permalink
|
204 |
|| $request == $custom_permalink . "/" ) ) {
|
205 |
|
206 |
// Request doesn't match permalink - redirect
|
@@ -258,9 +258,9 @@ class Custom_Permalinks_Frontend {
|
|
258 |
* Filter to replace the term permalink with the custom one
|
259 |
*/
|
260 |
public function custom_permalinks_term_link( $permalink, $term ) {
|
261 |
-
$table = get_option('custom_permalink_table');
|
262 |
-
if ( is_object($term) ) $term = $term->term_id;
|
263 |
-
|
264 |
$custom_permalink = $this->custom_permalinks_permalink_for_term( $term );
|
265 |
if ( $custom_permalink ) {
|
266 |
$taxonomy = get_term( $term );
|
@@ -343,14 +343,14 @@ class Custom_Permalinks_Frontend {
|
|
343 |
|
344 |
remove_filter( 'user_trailingslashit', array( $this, 'custom_permalinks_trailingslash' ), 10, 2 );
|
345 |
$url = parse_url( get_bloginfo( 'url' ) );
|
346 |
-
$request = ltrim( isset( $url['path'] ) ? substr( $string, strlen( $url['path'] ) ) : $string, '/');
|
347 |
add_filter( 'user_trailingslashit', array( $this, 'custom_permalinks_trailingslash' ), 10, 2 );
|
348 |
|
349 |
if ( ! trim( $request ) ) return $string;
|
350 |
|
351 |
if ( trim( $_CPRegisteredURL, '/' ) == trim( $request, '/' ) ) {
|
352 |
if ( isset( $url['path'] ) ) {
|
353 |
-
return ( $string{0} == '/' ? '/' : '') . trailingslashit( $url['path'] ) . $_CPRegisteredURL;
|
354 |
} else {
|
355 |
return ( $string{0} == '/' ? '/' : '' ) . $_CPRegisteredURL;
|
356 |
}
|
71 |
// A post matches our request
|
72 |
|
73 |
// Preserve this url for later if it's the same as the permalink (no extra stuff)
|
74 |
+
if ( $request_noslash == trim( $posts[0]->meta_value, '/' ) )
|
75 |
$_CPRegisteredURL = $request;
|
76 |
|
77 |
if ( $posts[0]->post_status == 'draft' ) {
|
98 |
|
99 |
if ( $original_url === NULL ) {
|
100 |
// See if any terms have a matching permalink
|
101 |
+
$table = get_option( 'custom_permalink_table' );
|
102 |
if ( ! $table ) return $query;
|
103 |
|
104 |
foreach ( array_keys( $table ) as $permalink ) {
|
110 |
if ( $request_noslash == trim( $permalink, '/' ) )
|
111 |
$_CPRegisteredURL = $request;
|
112 |
|
113 |
+
if ( $term['kind'] == 'category' ) {
|
114 |
$category_link = $this->custom_permalinks_original_category_link( $term['id'] );
|
115 |
$original_url = str_replace( trim( $permalink, '/' ), $category_link, trim( $request, '/' ) );
|
116 |
} else {
|
126 |
|
127 |
if ( ( $pos = strpos( $_SERVER['REQUEST_URI'], '?' ) ) !== false ) {
|
128 |
$query_vars = substr( $_SERVER['REQUEST_URI'], $pos + 1);
|
129 |
+
$original_url .= ( strpos( $original_url, '?' ) === false ? '?' : '&' ) . $query_vars;
|
130 |
}
|
131 |
|
132 |
// Now we have the original URL, run this back through WP->parse_request, in order to
|
133 |
// parse parameters properly. We set $_SERVER variables to fool the function.
|
134 |
$old_request_uri = $_SERVER['REQUEST_URI']; $old_query_string = $_SERVER['QUERY_STRING'];
|
135 |
+
$_SERVER['REQUEST_URI'] = '/' . ltrim( $original_url, '/' );
|
136 |
+
$_SERVER['QUERY_STRING'] = ( ( $pos = strpos( $original_url, '?' ) ) !== false ? substr( $original_url, $pos + 1 ) : '' );
|
137 |
parse_str( $_SERVER['QUERY_STRING'], $query_array );
|
138 |
$old_values = array();
|
139 |
if ( is_array( $query_array ) )
|
143 |
}
|
144 |
|
145 |
// Re-run the filter, now with original environment in place
|
146 |
+
remove_filter( 'request', array( $this, 'custom_permalinks_request' ), 10, 1 );
|
147 |
global $wp;
|
148 |
$wp->parse_request();
|
149 |
$query = $wp->query_vars;
|
150 |
+
add_filter( 'request', array( $this, 'custom_permalinks_request' ), 10, 1 );
|
151 |
|
152 |
// Restore values
|
153 |
$_SERVER['REQUEST_URI'] = $old_request_uri; $_SERVER['QUERY_STRING'] = $old_query_string;
|
189 |
} else {
|
190 |
$original_permalink = $this->custom_permalinks_original_post_link( $post->ID );
|
191 |
}
|
192 |
+
} elseif ( is_tag() || is_category() ) {
|
193 |
$theTerm = $wp_query->get_queried_object();
|
194 |
$custom_permalink = $this->custom_permalinks_permalink_for_term( $theTerm->term_id );
|
195 |
if ( is_tag() ) {
|
200 |
}
|
201 |
|
202 |
if ( $custom_permalink
|
203 |
+
&& ( substr( $request, 0, strlen( $custom_permalink ) ) != $custom_permalink
|
204 |
|| $request == $custom_permalink . "/" ) ) {
|
205 |
|
206 |
// Request doesn't match permalink - redirect
|
258 |
* Filter to replace the term permalink with the custom one
|
259 |
*/
|
260 |
public function custom_permalinks_term_link( $permalink, $term ) {
|
261 |
+
$table = get_option( 'custom_permalink_table' );
|
262 |
+
if ( is_object( $term ) ) $term = $term->term_id;
|
263 |
+
|
264 |
$custom_permalink = $this->custom_permalinks_permalink_for_term( $term );
|
265 |
if ( $custom_permalink ) {
|
266 |
$taxonomy = get_term( $term );
|
343 |
|
344 |
remove_filter( 'user_trailingslashit', array( $this, 'custom_permalinks_trailingslash' ), 10, 2 );
|
345 |
$url = parse_url( get_bloginfo( 'url' ) );
|
346 |
+
$request = ltrim( isset( $url['path'] ) ? substr( $string, strlen( $url['path'] ) ) : $string, '/' );
|
347 |
add_filter( 'user_trailingslashit', array( $this, 'custom_permalinks_trailingslash' ), 10, 2 );
|
348 |
|
349 |
if ( ! trim( $request ) ) return $string;
|
350 |
|
351 |
if ( trim( $_CPRegisteredURL, '/' ) == trim( $request, '/' ) ) {
|
352 |
if ( isset( $url['path'] ) ) {
|
353 |
+
return ( $string{0} == '/' ? '/' : '' ) . trailingslashit( $url['path'] ) . $_CPRegisteredURL;
|
354 |
} else {
|
355 |
return ( $string{0} == '/' ? '/' : '' ) . $_CPRegisteredURL;
|
356 |
}
|
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: 1.2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -47,6 +47,10 @@ add_filter( 'custom_permalinks_request_ignore', 'check_xml_sitemap_url' );
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
|
|
50 |
= 1.2.1 =
|
51 |
* Fixed Class Typo
|
52 |
|
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.2
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
47 |
|
48 |
== Changelog ==
|
49 |
|
50 |
+
= 1.2.2 =
|
51 |
+
|
52 |
+
* Fixed Typo of Class Object for term on Admin Page
|
53 |
+
|
54 |
= 1.2.1 =
|
55 |
* Fixed Class Typo
|
56 |
|