Commit 86187884 authored by Erick Hitter's avatar Erick Hitter

Version 0.5.1. Corrects problem with query string used with verbose page rules.

parent 2ee5c7da
......@@ -4,7 +4,7 @@ Donate link: http://www.thinkoomph.com/plugins-modules/wp-print-friendly/
Tags: print, template, printer, printable
Requires at least: 3.1
Tested up to: 3.4
Stable tag: 0.5
Stable tag: 0.5.1
Extends WordPress' template system to support printer-friendly templates. Works with permalink structures to support nice URLs.
......@@ -57,6 +57,9 @@ This plugin is known to conflict with certain plugins, many pertaining to SEO an
== Changelog ==
= 0.5.1 =
* Correct construction of query needed in situations where verbose page rules are required.
= 0.5 =
* Add additional rewrite rules for situations where verbose page rules are required.
* Disable canonical redirect when print template is requested.
......@@ -126,6 +129,9 @@ This plugin is known to conflict with certain plugins, many pertaining to SEO an
== Upgrade Notice ==
= 0.5.1 =
Ensure that proper query string is built when verbose page rules are required.
= 0.5 =
Adds better support for sites that use verbose page rules, resolving situations where requests for print template redirect to the post.
......
......@@ -4,7 +4,7 @@ Plugin Name: WP Print Friendly
Plugin URI: http://www.thinkoomph.com/plugins-modules/wp-print-friendly/
Description: Extends WordPress' template system to support printer-friendly templates. Works with permalink structures to support nice URLs.
Author: Erick Hitter (Oomph, Inc.)
Version: 0.5
Version: 0.5.1
Author URI: http://www.thinkoomph.com/
*/
......@@ -108,11 +108,28 @@ class wp_print_friendly {
//Extra rules needed if verbose page rules are requested
if ( $wp_rewrite->use_verbose_page_rules ) {
//Build regex
$regex = substr( str_replace( $wp_rewrite->rewritecode, $wp_rewrite->rewritereplace, $wp_rewrite->permalink_structure ), 1 );
$regex = trailingslashit( $regex );
$regex .= $this->query_var . '(/([0-9]*))?/?$';
add_rewrite_rule( $regex, $wp_rewrite->index . '?category_name=$matches[1]&name=$matches[2]&' . $this->query_var . '=$matches[4]', 'top' );
//Build corresponding query string
$query = substr( str_replace( $wp_rewrite->rewritecode, $wp_rewrite->queryreplace, $wp_rewrite->permalink_structure ), 1 );
$query = explode( '/', $query );
$query = array_filter( $query );
$i = 1;
foreach ( $query as $key => $qv ) {
$query[ $key ] .= '$matches[' . $i . ']';
$i++;
}
$query[] = $this->query_var . '=$matches[' . ( $i + 1 ) . ']';
$query = implode( '&', $query );
//Add rule
add_rewrite_rule( $regex, $wp_rewrite->index . '?' . $query, 'top' );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment