WP-Print - Version 2.04

Version Description

Download this release

Release Info

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

Version 2.04

print/images/print.gif ADDED
Binary file
print/print.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.04
7
+ Author: GaMerZ
8
+ Author URI: http://www.lesterchan.net
9
+ */
10
+
11
+
12
+ /* Copyright 2006 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/" title="'.$text_page.'">'.$text_page.'</a>';
62
+ } else {
63
+ echo '<a href="'.$permalink.'print/" title="'.$test_post.'">'.$text_post.'</a>';
64
+ }
65
+ } else {
66
+ echo '<a href="'.$permalink.'&amp;print=1" title="'.$text_post.'">'.$text_post.'</a>';
67
+ }
68
+ }
69
+
70
+
71
+ ### Function: Display Print Image Link
72
+ function print_link_image() {
73
+ global $id;
74
+ $using_permalink = get_settings('permalink_structure');
75
+ $permalink = get_permalink();
76
+ if(file_exists(ABSPATH.'/wp-content/plugins/print/images/print.gif')) {
77
+ $print_image = '<img src="'.get_settings('siteurl').'/wp-content/plugins/print/images/print.gif" alt="Print This Post/Page" />';
78
+ } else {
79
+ $print_image = 'Print';
80
+ }
81
+ if(!empty($using_permalink)) {
82
+ if(is_page()) {
83
+ echo '<a href="'.$permalink.'printpage/" title="Print This Page">'.$print_image.'</a>';
84
+ } else {
85
+ echo '<a href="'.$permalink.'print/" title="Print This Post">'.$print_image.'</a>';
86
+ }
87
+ } else {
88
+ echo '<a href="'.$permalink.'&amp;print=1" title="Print This Post/Page">'.$print_image.'</a>';
89
+ }
90
+ }
91
+
92
+
93
+ ### Function: Print Content
94
+ function print_content($display = true) {
95
+ global $links_text, $link_number, $pages, $multipage, $numpages, $post;
96
+ $max_url_char = 100;
97
+ if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
98
+ $content = get_the_password_form();
99
+ } else {
100
+ if($multipage) {
101
+ for($page = 0; $page < $numpages; $page++) {
102
+ $content .= $pages[$page];
103
+ }
104
+ } else {
105
+ $content = $pages[0];
106
+ }
107
+ $content = wptexturize($content);
108
+ $content = convert_smilies($content);
109
+ $content = convert_chars($content);
110
+ $content = wpautop($content);
111
+ $content = apply_filters('the_content', $content);
112
+ $content = str_replace(']]>', ']]&gt;', $content);
113
+ preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches);
114
+ for ($i=0; $i < count($matches[0]); $i++) {
115
+ $link_match = $matches[0][$i];
116
+ $link_number++;
117
+ $link_url = $matches[2][$i];
118
+ $link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
119
+ $link_text = $matches[4][$i];
120
+ $content = str_replace($link_match, '['.$link_number."] <a href=\"$link_url\" target=\"_blank\">".$link_text.'</a>', $content);
121
+ if(strlen($link_url) > $max_url_char) {
122
+ $link_url = substr($link_url, 0, $max_url_char).'<br />'.substr($link_url, $max_url_char, strlen($link_url));
123
+ }
124
+ if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
125
+ $links_text .= '<br />['.$link_number.'] '.__('Image').': <b>'.$link_url.'</b>';
126
+ } else {
127
+ $links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
128
+ }
129
+ }
130
+ }
131
+ if($display) {
132
+ echo $content;
133
+ } else {
134
+ return $content;
135
+ }
136
+ }
137
+
138
+
139
+ ### Function: Print Categories
140
+ function print_categories($before = '', $after = '') {
141
+ $temp_cat = strip_tags(get_the_category_list(',' , $parents));
142
+ $temp_cat = explode(', ', $temp_cat);
143
+ $temp_cat = implode($after.', '.$before, $temp_cat);
144
+ echo $before.$temp_cat.$after;
145
+ }
146
+
147
+
148
+ ### Function: Print Comments Content
149
+ function print_comments_content($display = true) {
150
+ global $links_text, $link_number;
151
+ $max_url_char = 100;
152
+ $content = get_comment_text();
153
+ preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches);
154
+ for ($i=0; $i < count($matches[0]); $i++) {
155
+ $link_match = $matches[0][$i];
156
+ $link_number++;
157
+ $link_url = $matches[2][$i];
158
+ $link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
159
+ $link_text = $matches[4][$i];
160
+ $content = str_replace($link_match, '['.$link_number."] <a href=\"$link_url\" target=\"_blank\">".$link_text.'</a>', $content);
161
+ if(strlen($link_url) > $max_url_char) {
162
+ $link_url = substr($link_url, 0, $max_url_char).'<br />'.substr($link_url, $max_url_char, strlen($link_url));
163
+ }
164
+ if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
165
+ $links_text .= '<br />['.$link_number.'] '.__('Image').': <b>'.$link_url.'</b>';
166
+ } else {
167
+ $links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
168
+ }
169
+ }
170
+ if($display) {
171
+ echo $content;
172
+ } else {
173
+ return $content;
174
+ }
175
+ }
176
+
177
+
178
+ ### Function: Print Comments
179
+ function print_comments_number() {
180
+ global $post;
181
+ $comment_text = '';
182
+ $comment_status = $post->comment_status;
183
+ if($comment_status == 'open') {
184
+ $num_comments = get_comments_number();
185
+ if($num_comments == 0) {
186
+ $comment_text = __('No Comments');
187
+ } elseif($num_comments == 1) {
188
+ $comment_text = __('1 Comment');
189
+ } else {
190
+ $comment_text = __($num_comments.' Comments');
191
+ }
192
+ } else {
193
+ $comment_text = __('Comments Disabled');
194
+ }
195
+ if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
196
+ _e('Comments Hidden');
197
+ } else {
198
+ echo $comment_text;
199
+ }
200
+ }
201
+
202
+
203
+ ### Function: Print Links
204
+ function print_links($text_links = 'URLs in this post:') {
205
+ global $links_text;
206
+ if(!empty($links_text)) {
207
+ echo $text_links.$links_text;
208
+ }
209
+ }
210
+
211
+
212
+ ### Function: Load WP-Print
213
+ add_action('template_redirect', 'wp_print');
214
+ function wp_print() {
215
+ if(intval(get_query_var('print')) == 1) {
216
+ include(ABSPATH.'wp-content/plugins/print/wp-print.php');
217
+ exit;
218
+ }
219
+ }
220
+
221
+
222
+ ### Function: Add Print Comments Template
223
+ function print_template_comments($file = '') {
224
+ $file = ABSPATH.'wp-content/plugins/print/wp-print-comments.php';
225
+ return $file;
226
+ }
227
+
228
+
229
+ ### Function: Print Page Title
230
+ function print_pagetitle($print_pagetitle) {
231
+ return '&raquo; Print'.$print_pagetitle;
232
+ }
233
+ ?>
print/wp-print-comments.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Print 2.04 |
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 For Comments |
14
+ | - wp-print-comments.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+ ?>
19
+ <?php if($comments) : ?>
20
+ <?php $comment_count = 1; ?>
21
+ <p id="CommentTitle"><?php print_comments_number(); ?> To "<?php the_title(); ?>"</p>
22
+ <?php foreach ($comments as $comment) : ?>
23
+ <p class="CommentDate"><b>#<?php echo $comment_count; ?> <?php comment_type(); ?></b> By <u><?php comment_author(); ?></u> On <?php comment_date('jS F Y @ H:i'); ?></p>
24
+ <p class="CommentContent"><?php print_comments_content(); ?></p>
25
+ <?php $comment_count++; ?>
26
+ <?php endforeach; ?>
27
+ <hr id="Divider" align="center" />
28
+ <?php endif; ?>
print/wp-print.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-Print 2.04 |
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
+ ### Variables
21
+ $can_print_comments = false;
22
+ $links_text = '';
23
+
24
+ ### Actions
25
+ add_action('init', 'print_content');
26
+
27
+ ### Filters
28
+ add_filter('wp_title', 'print_pagetitle');
29
+ add_filter('comments_template', 'print_template_comments');
30
+ ?>
31
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
+ <html xmlns="http://www.w3.org/1999/xhtml">
33
+ <head>
34
+ <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
35
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
36
+ <style type="text/css" media="screen, print">
37
+ Body {
38
+ font-family: Verdana, Arial, Tahoma;
39
+ font-size: 12px;
40
+ color: #000000;
41
+ }
42
+ #Outline {
43
+ text-align: left;
44
+ width: 90%;
45
+ margin-left: auto;
46
+ margin-right: auto;
47
+ padding: 10px;
48
+ border: 1px solid #000000;
49
+ }
50
+ #BlogTitle {
51
+ font-weight: bold;
52
+ font-size: 16px;
53
+ margin-bottom: 5px;
54
+ }
55
+ #BlogDate {
56
+ margin-top: 5px;
57
+ margin-bottom: 10px;
58
+ }
59
+ #BlogContent {
60
+ padding: 10px;
61
+ margin-top: 10px;
62
+ }
63
+ HR#Divider {
64
+ width: 80%;
65
+ height: 1px;
66
+ color: #000000;
67
+ }
68
+ #CommentTitle {
69
+ font-weight: bold;
70
+ font-size: 16px;
71
+ padding-bottom: 10px;
72
+ }
73
+ .CommentDate {
74
+ margin-top: 5px;
75
+ margin-bottom: 10px;
76
+ }
77
+ .CommentContent {
78
+ padding: 10px;
79
+ margin-top: 10px;
80
+ }
81
+ </style>
82
+ </head>
83
+ <body>
84
+ <p align="center"><b>- <?php bloginfo('name'); ?> - <?php bloginfo('url')?> -</b></p>
85
+ <center>
86
+ <div id="Outline">
87
+ <?php if (have_posts()): ?>
88
+ <?php while (have_posts()): the_post(); ?>
89
+ <p id="BlogTitle"><?php the_title(); ?></p>
90
+ <p id="BlogDate">Posted By <u><?php the_author(); ?></u> On <?php the_time('jS F Y @ H:i'); ?> In <?php print_categories('<u>', '</u>'); ?> | <u><?php print_comments_number(); ?></u></p>
91
+ <div id="BlogContent"><?php print_content(); ?></div>
92
+ <?php endwhile; ?>
93
+ <hr id="Divider" align="center" />
94
+ <?php if($can_print_comments) { comments_template(); } ?>
95
+ <p align="left">Article printed from <?php bloginfo('name'); ?>: <b><?php bloginfo('url'); ?></b></p>
96
+ <p align="left">URL to article: <b><?php the_permalink(); ?></b></p>
97
+ <p align="left"><?php print_links(); ?></p>
98
+ <p align="right">Click <a href="javascript:window.print();">here</a> to print.</p>
99
+ <?php else: ?>
100
+ <p align="center">No posts matched your criteria.</p>
101
+ <?php endif; ?>
102
+ </div>
103
+ </center>
104
+ </body>
105
+ </html>
readme-install.txt ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Installation Instructions
2
+ --------------------------------------------------
3
+ // Open wp-content/plugins folder
4
+
5
+ Put:
6
+ ------------------------------------------------------------------
7
+ Folder: print
8
+ ------------------------------------------------------------------
9
+
10
+
11
+ // Activate WP-Print plugin
12
+
13
+ Note:
14
+ ------------------------------------------------------------------
15
+ You MAY Need To Re-Generate The Permalink.
16
+ Options -> Permalinks Options -> Update Permalink Structure
17
+ ------------------------------------------------------------------
18
+
19
+
20
+ // Open wp-content/themes/<YOUR THEME NAME>/index.php
21
+
22
+ Find:
23
+ ------------------------------------------------------------------
24
+ <?php while (have_posts()) : the_post(); ?>
25
+ ------------------------------------------------------------------
26
+ Add Anywhere Below It:
27
+ ------------------------------------------------------------------
28
+ <?php if(function_exists('wp_print')) { print_link(); } ?>
29
+ ------------------------------------------------------------------
30
+ Note:
31
+ ------------------------------------------------------------------
32
+ The first value you pass in is the text for printing post.
33
+ The second value is the text for printing page.
34
+ Default: print_link('Print This Post', 'Print This Page')
35
+
36
+ If you want to use an image/icon instead, replace print_link()
37
+ with print_link_image()
38
+ ------------------------------------------------------------------
39
+
40
+
41
+ // To Print Comments Together With Post
42
+
43
+ Open wp-content/plugins/print/wp-print.php, Find:
44
+ ------------------------------------------------------------------
45
+ $can_print_comments = false;
46
+ ------------------------------------------------------------------
47
+ Replace
48
+ ------------------------------------------------------------------
49
+ $can_print_comments = true;
50
+ ------------------------------------------------------------------
readme-upgrade.txt ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Upgrade Instructions For Version 2.03 To Version 2.04
2
+ ------------------------------------------------------------------
3
+ // Deactivate WP-Print plugin
4
+
5
+
6
+ // Open wp-content/plugins folder
7
+
8
+ Overwrite:
9
+ ------------------------------------------------------------------
10
+ Folder: print
11
+ ------------------------------------------------------------------
12
+
13
+
14
+ // Open root Wordpress folder
15
+
16
+ Delete:
17
+ ------------------------------------------------------------------
18
+ wp-print.php
19
+ ------------------------------------------------------------------
20
+
21
+
22
+ // Activate WP-Print plugin
23
+
24
+
25
+
26
+
27
+
28
+ -> Upgrade Instructions For Version 1.0x To Version 2.04
29
+ ------------------------------------------------------------------
30
+ // Deactivate WP-Print plugin
31
+
32
+
33
+ // Open wp-content/plugins folder
34
+
35
+ Delete:
36
+ ------------------------------------------------------------------
37
+ print.php
38
+ ------------------------------------------------------------------
39
+
40
+ Put:
41
+ ------------------------------------------------------------------
42
+ Folder: print
43
+ ------------------------------------------------------------------
44
+
45
+
46
+ // Open root Wordpress folder
47
+
48
+ Delete:
49
+ ------------------------------------------------------------------
50
+ wp-print.php
51
+ ------------------------------------------------------------------
52
+
53
+
54
+ // Activate WP-Print plugin
readme.txt ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 April 2006
10
+ --------------------------------------------------
11
+
12
+
13
+ // Version 2.04 (01-04-2006)
14
+ - NEW: Able To Print Comments Together With Post Using $can_print_comments In wp-print.php
15
+ - NEW: Moved wp-print.php To Plugin Folder
16
+ - FIXED: Removed Link From Post Comment Count And Post Category
17
+
18
+ // Version 2.03 (01-03-2006)
19
+ - NEW: Added Print Image With print_link_image()
20
+ - NEW: Automatically Break To Next Line If Link Contains More Than 100 Chars
21
+ - FIXED: Comment Numbers Showing In Password Protected Post
22
+
23
+ // Version 2.02 (01-02-2006)
24
+ - FIXED: Able To View Password Protected Blog
25
+
26
+ // Version 2.01 (01-01-2006)
27
+ - NEW: Compatible With WordPress 2.0
28
+ - NEW: Automatically Detect Whether You Are Using Nice Permalink
29
+ - NEW: Automated Permalink
30
+ - NEW: Now You Only Need To Insert 1 Line Into Your index.php Of Your Theme
31
+ - NEW: GPL License Added
32
+ - FIXED: Links Not Displaying Properly When Printing More Than 1 Post On A Single Page
33
+
34
+ // Version 2.00a (17-11-2005)
35
+ - NEW: Permlink For The Page Feature
36
+
37
+ // Version 2.00 (10-11-2005)
38
+ - NEW: Print Out A Summary Of URLS In The Post At The Bottom Of The Page