WP-Print - Version 2.02

Version Description

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-Print
Version 2.02
Comparing to
See all releases

Version 2.02

Files changed (5) hide show
  1. print.php +134 -0
  2. readme-install.txt +43 -0
  3. readme-upgrade.txt +8 -0
  4. readme.txt +28 -0
  5. wp-print.php +97 -0
print.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP-Print
4
+ Plugin URI: http://www.lesterchan.net/portfolio/programming.php
5
+ Description: Displays A Printable Version Of Your WordPress Weblog Post.
6
+ Version: 2.02
7
+ Author: GaMerZ
8
+ Author URI: http://www.lesterchan.net
9
+ */
10
+
11
+
12
+ /* Copyright 2005 Lester Chan (email : gamerz84@hotmail.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
+ */
28
+
29
+
30
+ ### Function: Print htaccess ReWrite Rules
31
+ add_filter('generate_rewrite_rules', 'print_rewrite');
32
+ function print_rewrite($wp_rewrite) {
33
+ $r_rule = '';
34
+ $r_link = '';
35
+ $rewrite_rules2 = $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.'print');
36
+ array_splice($rewrite_rules2, 1);
37
+ $r_rule = array_shift(array_keys($rewrite_rules2));
38
+ $r_rule = str_replace('/trackback', '',$r_rule);
39
+ $r_link = array_shift(array_values($rewrite_rules2));
40
+ $r_link = str_replace('tb=1', 'print=1', $r_link);
41
+ $print_rules = array($r_rule => $r_link, '(.+)/printpage/?$' => 'index.php?pagename='.$wp_rewrite->preg_index(1).'&print=1');
42
+ $wp_rewrite->rules = $print_rules + $wp_rewrite->rules;
43
+ }
44
+
45
+
46
+ ### Function: Print Public Variables
47
+ add_filter('query_vars', 'print_variables');
48
+ function print_variables($public_query_vars) {
49
+ $public_query_vars[] = 'print';
50
+ return $public_query_vars;
51
+ }
52
+
53
+
54
+ ### Function: Display Print Link
55
+ function print_link($text_post = 'Print This Post', $text_page = 'Print This Page') {
56
+ global $id;
57
+ $using_permalink = get_settings('permalink_structure');
58
+ $permalink = get_permalink();
59
+ if(!empty($using_permalink)) {
60
+ if(is_page()) {
61
+ echo '<a href="'.$permalink.'printpage/">'.$text_page.'</a>';
62
+ } else {
63
+ echo '<a href="'.$permalink.'print/">'.$text_post.'</a>';
64
+ }
65
+ } else {
66
+ if(is_page()) {
67
+ echo '<a href="'.get_settings('home').'/wp-print.php?page_id='.$id.'">'.$text_page.'</a>';
68
+ } else {
69
+ echo '<a href="'.get_settings('home').'/wp-print.php?p='.$id.'">'.$text_post.'</a>';
70
+ }
71
+ }
72
+ }
73
+
74
+
75
+ ### Function: Print Content
76
+ function print_content($display = true) {
77
+ global $links_text, $link_number, $pages, $multipage, $numpages, $post;
78
+ if (!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
79
+ $content = get_the_password_form();
80
+ } else {
81
+ if($multipage) {
82
+ for($page = 0; $page < $numpages; $page++) {
83
+ $content .= $pages[$page];
84
+ }
85
+ } else {
86
+ $content = $pages[0];
87
+ }
88
+ $content = wptexturize($content);
89
+ $content = convert_smilies($content);
90
+ $content = convert_chars($content);
91
+ $content = wpautop($content);
92
+ $content = apply_filters('the_content', $content);
93
+ $content = str_replace(']]>', ']]&gt;', $content);
94
+ preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches);
95
+ for ($i=0; $i < count($matches[0]); $i++) {
96
+ $link_match = $matches[0][$i];
97
+ $link_number++;
98
+ $link_url = $matches[2][$i];
99
+ $link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
100
+ $link_text = $matches[4][$i];
101
+ $content = str_replace($link_match, '['.$link_number."] <a href=\"$link_url\" target=\"_blank\">".$link_text.'</a>', $content);
102
+ if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
103
+ $links_text .= '<br />['.$link_number.'] '.__('Image').': <b>'.$link_url.'</b>';
104
+ } else {
105
+ $links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
106
+ }
107
+ }
108
+ }
109
+ if($display) {
110
+ echo $content;
111
+ } else {
112
+ return $content;
113
+ }
114
+ }
115
+
116
+
117
+ ### Function: Print Links
118
+ function print_links($text_links = 'URLs in this post:') {
119
+ global $links_text;
120
+ if(!empty($links_text)) {
121
+ echo $text_links.$links_text;
122
+ }
123
+ }
124
+
125
+
126
+ ### Function: Load WP-Print
127
+ add_action('template_redirect', 'wp_print');
128
+ function wp_print() {
129
+ if(intval(get_query_var('print')) == 1) {
130
+ include(ABSPATH . '/wp-print.php');
131
+ exit;
132
+ }
133
+ }
134
+ ?>
readme-install.txt ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Installation Instructions
2
+ --------------------------------------------------
3
+ // Open wp-content/plugins folder
4
+
5
+ Put:
6
+ ------------------------------------------------------------------
7
+ print.php
8
+ ------------------------------------------------------------------
9
+
10
+
11
+ // Open root Wordpress folder
12
+
13
+ Put
14
+ ------------------------------------------------------------------
15
+ wp-print.php
16
+ ------------------------------------------------------------------
17
+
18
+
19
+ // Activate the polls plugin
20
+
21
+ Note:
22
+ ------------------------------------------------------------------
23
+ You MAY Need To Re-Generate The Permalink.
24
+ Options -> Permalinks Options -> Update Permalink Structure
25
+ ------------------------------------------------------------------
26
+
27
+
28
+ // Open wp-content/themes/<YOUR THEME NAME>/index.php
29
+
30
+ Find:
31
+ ------------------------------------------------------------------
32
+ <?php while (have_posts()) : the_post(); ?>
33
+ ------------------------------------------------------------------
34
+ Add Anywhere Below It:
35
+ ------------------------------------------------------------------
36
+ <?php if(function_exists('wp_print')) { print_link(); } ?>
37
+ ------------------------------------------------------------------
38
+ Note:
39
+ ------------------------------------------------------------------
40
+ The first value you pass in is the text for printing post.
41
+ The second value is the text for printing page.
42
+ Default: print_link('Print This Post', 'Print This Page')
43
+ ------------------------------------------------------------------
readme-upgrade.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ -> Upgrade Instructions For Version 2.01 To Version 2.02
2
+ ------------------------------------------------------------------
3
+ // Open wp-content/plugins folder
4
+
5
+ Overwrite:
6
+ ------------------------------------------------------------------
7
+ print.php
8
+ ------------------------------------------------------------------
readme.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Print Plugin For WordPress 2.0
2
+ --------------------------------------------------
3
+ Author -> Lester 'GaMerZ' Chan
4
+ Email -> gamerz84@hotmail.com
5
+ Website -> http://www.lesterchan.net/
6
+ Demo -> htp://www.lesterchan.net/blogs/wp-print.php?p=647
7
+ Documentation -> http://dev.wp-plugins.org/wiki/wp-print
8
+ Development -> http://dev.wp-plugins.org/browser/wp-print/
9
+ Updated -> 1st February 2006
10
+ --------------------------------------------------
11
+
12
+
13
+ // Version 2.02 (01-02-2006)
14
+ - FIXED: Able To View Password Protected Blog
15
+
16
+ // Version 2.01 (01-01-2006)
17
+ - NEW: Compatible With WordPress 2.0
18
+ - NEW: Automatically Detect Whether You Are Using Nice Permalink
19
+ - NEW: Automated Permalink
20
+ - NEW: Now You Only Need To Insert 1 Line Into Your index.php Of Your Theme
21
+ - NEW: GPL License Added
22
+ - FIXED: Links Not Displaying Properly When Printing More Than 1 Post On A Single Page
23
+
24
+ // Version 2.00a (17-11-2005)
25
+ - NEW: Permlink For The Page Feature
26
+
27
+ // Version 2.00 (10-11-2005)
28
+ - NEW: Print Out A Summary Of URLS In The Post At The Bottom Of The Page
wp-print.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Print 2.02 |
6
+ | Copyright (c) 2005 Lester "GaMerZ" Chan |
7
+ | |
8
+ | File Written By: |
9
+ | - Lester "GaMerZ" Chan |
10
+ | - http://www.lesterchan.net |
11
+ | |
12
+ | File Information: |
13
+ | - Printer Friendly Page |
14
+ | - wp-print.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### If wp-print.php Loaded Directly, Load wp-blog-header.php
21
+ if(intval($_GET['p']) > 0 || !function_exists('single_post_title')) {
22
+ require(dirname(__FILE__).'/wp-blog-header.php');
23
+ }
24
+
25
+ ### Variables
26
+ $links_text = '';
27
+
28
+ ### Load Print Content Function
29
+ add_action('init', 'print_content');
30
+
31
+ ### Function: Print Page Title
32
+ add_filter('wp_title', 'print_pagetitle');
33
+ function print_pagetitle($print_pagetitle) {
34
+ return '&raquo; Print'.$print_pagetitle;
35
+ }
36
+ ?>
37
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
38
+ <html xmlns="http://www.w3.org/1999/xhtml">
39
+ <head>
40
+ <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
41
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
42
+ <style type="text/css" media="screen, print">
43
+ Body {
44
+ font-family: Verdana, Arial, Tahoma;
45
+ font-size: 12px;
46
+ color: #000000;
47
+ }
48
+ #Outline {
49
+ text-align: left;
50
+ width: 90%;
51
+ margin-left: auto;
52
+ margin-right: auto;
53
+ padding: 10px;
54
+ border: 1px solid #000000;
55
+ }
56
+ #BlogTitle {
57
+ font-weight: bold;
58
+ font-size: 16px;
59
+ margin-bottom: 5px;
60
+ }
61
+ #BlogDate {
62
+ margin-top: 5px;
63
+ margin-bottom: 10px;
64
+ }
65
+ #BlogContent {
66
+ padding: 10px;
67
+ margin-top: 10px;
68
+ }
69
+ HR#Divider {
70
+ width: 80%;
71
+ height: 1px;
72
+ color: #000000;
73
+ }
74
+ </style>
75
+ </head>
76
+ <body>
77
+ <p align="center"><b>- <?php bloginfo('name'); ?> - <?php bloginfo('url')?> -</b></p>
78
+ <center>
79
+ <div id="Outline">
80
+ <?php if (have_posts()) : ?>
81
+ <?php while (have_posts()) : the_post(); ?>
82
+ <p id="BlogTitle"><?php the_title(); ?></p>
83
+ <p id="BlogDate">Posted By <?php the_author(); ?> On <?php the_time('jS F Y @ H:i'); ?> In <?php the_category(', '); ?> | <a href="<?php comments_link(); ?>"><?php comments_number(); ?></a></p>
84
+ <div id="BlogContent"><?php print_content(); ?></div>
85
+ <?php endwhile; ?>
86
+ <hr id="Divider" align="center" />
87
+ <p align="left">Article printed from <?php bloginfo('name'); ?>: <b><?php bloginfo('url'); ?></b></p>
88
+ <p align="left">URL to article: <b><?php the_permalink(); ?></b></p>
89
+ <p align="left"><?php print_links(); ?></p>
90
+ <p align="right">Click <a href="javascript:window.print();">here</a> to print.</p>
91
+ <?php else : ?>
92
+ <p align="center">No posts matched your criteria.</p>
93
+ <?php endif; ?>
94
+ </div>
95
+ </center>
96
+ </body>
97
+ </html>