Select Page

The plugin appears to be made up of effectively three files?

wordpress-print-this-section.php

This file has the chunk of code with if statements and has this as the last line

// Add Shortcodes add_shortcode( ‘print_this’, array( &$print_this_plugin, ‘print_this_shortcode’ ) );

class-wp-print-this-plugin.php

This appears to be where he is defining all the functions and has this as the last thing in it

/* FUNCTION: shortcode adds button and div container */
function print_this_shortcode( $atts, $content = null ) {
global $print_this_counter;
global $wp_rewrite;
global $post;

extract( shortcode_atts( array( ‘button_text’ => ‘Default’ ), $atts ) );

if ( ‘Default’ == $button_text ) $button_text = $this->admin_options[‘button_text’];
if ( ‘none’ == $this->admin_options[‘button_image’] && empty( $button_text ) ) { $button_text = __( ‘Print’, ‘print-this-section’ ); }

$button_image_src = FALSE;
if ( ‘none’ != $this->admin_options[‘button_image’] ) {
$button_image_src = WPPTS_PLUGIN_URL . “/images/” . $this->admin_options[‘button_image’];
}

/* Instead of using redirection and $wp-rewrite rules, I decided to go with simpler template redirection.
* Although it is not as pretty or sexy, the functionality and realability is greatly increased. This section
* takes the permalink and appends the propper query vars. The link is still bookmarkable, but not as SEO
* friendly. But we really don’t want our print page SEO friendly. This also works better with the default
* permalink structures which were causing the page to just reload instead of redirecting. This change also
* eliminated 3 functions making the plugin smaller and more efficient. -Version 2.0.4-
*/
if ( 1 == substr_count( get_permalink($post->ID), ‘?’ ) ) {
$print_this_link = get_permalink( $post->ID ) . ‘&printthis=1&printsect=’ . $print_this_counter;
} else {
$print_this_link = get_permalink( $post->ID ) . ‘?printthis=1&printsect=’ . $print_this_counter;
}

$output = ‘<div class=”print-this-button-shell”>’ . “n”;
$output .= ‘<button type=”button” class=”print-this-button” onClick=”parent.location=” . $print_this_link . ””>&nbsp;&nbsp;&nbsp;&nbsp;’;

if ( $button_image_src ) {
$output .= ‘<img src=”‘ . $button_image_src . ‘” /> &nbsp; ‘;
}

$output .= $button_text . ‘&nbsp;&nbsp;&nbsp;&nbsp;</button>’ . “n”;
$output .= “</div>n”;
$output .= “<!– Print This Section $print_this_counter Start –>n”;
$output .= ‘<div class=”print-this-content”>’;
$output .= do_shortcode( $content );
$output .= ‘<div class=”clear”></div>’ . “</div>n”;
$output .= “<!– Print This Section $print_this_counter End –>n”;

$print_this_counter++;

return $output;

print-this.php

This seems to be the code for the actual print page that is created when yo click the Print This button….. it is this page that is not parsing/processing the 2nd shortcode

I believe it is due to the way it is extracting the content of the post

<div id=”BlogContent”><?php extract_content(); ?></div>

post_password) && stripslashes($_COOKIE[‘wp-postpass_’.COOKIEHASH]) != $post->post_password) { $content = get_the_password_form(); } else { if($multipage) { for($page = 0; $page < $numpages; $page++) { $content .= $pages[$page]; } } else { $content = $pages[0]; } $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); // extract Print This Section from content. $print_this_sect_number = intval( get_query_var( ‘printsect’ ) ); $print_this_starting_marker = ““; $print_this_ending_marker = ““; $content_chunks = explode( $print_this_starting_marker, $content, 2 ); $content = $content_chunks[1]; $content_chunks = explode( $print_this_ending_marker, $content, 2 ); $content = $content_chunks[0]; if ( !$content ) { $content = __( ‘Print This was unable to locate the section you requested. Please contact the site administrator’, ‘print-this-section’ ); } } echo $content; } /* FUNCTION: retrieves the specified print this option. */ function get_print_this_option( $option ) { global $print_this_plugin; return $print_this_plugin->admin_options[$option]; } ?> ><?php bloginfo(‘name’); ?> <?php wp_title(); ?>

 

wordpress-print-this-section (zip file of the plugin)

 

 

Facebooktwitterredditpinterestlinkedinmail