Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tweak filter_post_type_link function - return original permalink if w…

…ildcard; fix function comments
  • Loading branch information...
commit 01e158b6d748474ac6ad5cf136ed47a20c77f14c 1 parent e8b347e
@tlovett1 authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 safe-redirect-manager.php
View
11 safe-redirect-manager.php
@@ -899,19 +899,26 @@ public function sanitize_redirect_from( $path, $allow_regex = false ) {
* Return a permalink for a redirect post, which is the "redirect from"
* URL for that redirect.
*
+ * @since 1.7
* @param string $permalink The permalink
* @param object $post A Post object
+ * @uses home_url, get_post_meta
* @return string The permalink
*/
public function filter_post_type_link( $permalink, $post ) {
- if ( 'redirect_rule' != $post->post_type )
+ if ( $this->redirect_post_type != $post->post_type )
return $permalink;
+
// We can't do anything to provide a permalink
// for regex enabled redirects.
if ( get_post_meta( $post->ID, $this->meta_key_enable_redirect_from_regex, true ) )
return $permalink;
- // Provide a permalink for the simple redirects
+
+ // We can't do anything if there is a wildcard in the redirect from
$redirect_from = get_post_meta( $post->ID, $this->meta_key_redirect_from, true );
+ if ( false !== strpos( $redirect_from, '*' ) )
+ return $permalink;
+
return home_url( $redirect_from );
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.