generate_rewrite_rule($wp_rewrite->permalink_structure.'print');
array_splice($rewrite_rules2, 1);
$r_rule = array_shift(array_keys($rewrite_rules2));
$r_rule = str_replace('/trackback', '',$r_rule);
$r_link = array_shift(array_values($rewrite_rules2));
$r_link = str_replace('tb=1', 'print=1', $r_link);
$print_rules = array($r_rule => $r_link, '(.+)/printpage/?$' => 'index.php?pagename='.$wp_rewrite->preg_index(1).'&print=1');
$wp_rewrite->rules = $print_rules + $wp_rewrite->rules;
}
### Function: Print Public Variables
add_filter('query_vars', 'print_variables');
function print_variables($public_query_vars) {
$public_query_vars[] = 'print';
return $public_query_vars;
}
### Function: Display Print Link
function print_link($text_post = 'Print This Post', $text_page = 'Print This Page') {
global $id;
$using_permalink = get_settings('permalink_structure');
$permalink = get_permalink();
if(!empty($using_permalink)) {
if(is_page()) {
echo ''.$text_page.'';
} else {
echo ''.$text_post.'';
}
} else {
if(is_page()) {
echo ''.$text_page.'';
} else {
echo ''.$text_post.'';
}
}
}
### Function: Print Content
function print_content($display = true) {
global $links_text, $link_number, $pages, $multipage, $numpages, $post;
if (!empty($post->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 = wptexturize($content);
$content = convert_smilies($content);
$content = convert_chars($content);
$content = wpautop($content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
preg_match_all('/(.+?)<\/a>/', $content, $matches);
for ($i=0; $i < count($matches[0]); $i++) {
$link_match = $matches[0][$i];
$link_number++;
$link_url = $matches[2][$i];
$link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
$link_text = $matches[4][$i];
$content = str_replace($link_match, '['.$link_number."] ".$link_text.'', $content);
if(preg_match('/
/',$link_text)) {
$links_text .= '
['.$link_number.'] '.__('Image').': '.$link_url.'';
} else {
$links_text .= '
['.$link_number.'] '.$link_text.': '.$link_url.'';
}
}
}
if($display) {
echo $content;
} else {
return $content;
}
}
### Function: Print Links
function print_links($text_links = 'URLs in this post:') {
global $links_text;
if(!empty($links_text)) {
echo $text_links.$links_text;
}
}
### Function: Load WP-Print
add_action('template_redirect', 'wp_print');
function wp_print() {
if(intval(get_query_var('print')) == 1) {
include(ABSPATH . '/wp-print.php');
exit;
}
}
?>