WP-Print - Version 2.03

Version Description

Download this release

Release Info

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

Version 2.03

Files changed (6) hide show
  1. print/images/print.gif +0 -0
  2. print/print.php +188 -0
  3. readme-install.txt +46 -0
  4. readme-upgrade.txt +27 -0
  5. readme.txt +32 -0
  6. wp-print.php +97 -0
print/images/print.gif ADDED
Binary file
print/print.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.03
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('siteurl').'/wp-print.php?page_id='.$id.'">'.$text_page.'</a>';
68
+ } else {
69
+ echo '<a href="'.get_settings('siteurl').'/wp-print.php?p='.$id.'">'.$text_post.'</a>';
70
+ }
71
+ }
72
+ }
73
+
74
+
75
+ ### Function: Display Print Image Link
76
+ function print_link_image() {
77
+ global $id;
78
+ $using_permalink = get_settings('permalink_structure');
79
+ $permalink = get_permalink();
80
+ if(file_exists(ABSPATH.'/wp-content/plugins/print/images/print.gif')) {
81
+ $print_image = '<img src="'.get_settings('siteurl').'/wp-content/plugins/print/images/print.gif" alt="Print This Post/Page" />';
82
+ } else {
83
+ $print_image = 'Print';
84
+ }
85
+ if(!empty($using_permalink)) {
86
+ if(is_page()) {
87
+ echo '<a href="'.$permalink.'printpage/">'.$print_image.'</a>';
88
+ } else {
89
+ echo '<a href="'.$permalink.'print/">'.$print_image.'</a>';
90
+ }
91
+ } else {
92
+ if(is_page()) {
93
+ echo '<a href="'.get_settings('siteurl').'/wp-print.php?page_id='.$id.'">'.$print_image.'</a>';
94
+ } else {
95
+ echo '<a href="'.get_settings('siteurl').'/wp-print.php?p='.$id.'">'.$print_image.'</a>';
96
+ }
97
+ }
98
+ }
99
+
100
+
101
+ ### Function: Print Content
102
+ function print_content($display = true) {
103
+ global $links_text, $link_number, $pages, $multipage, $numpages, $post;
104
+ $max_url_char = 100;
105
+ if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
106
+ $content = get_the_password_form();
107
+ } else {
108
+ if($multipage) {
109
+ for($page = 0; $page < $numpages; $page++) {
110
+ $content .= $pages[$page];
111
+ }
112
+ } else {
113
+ $content = $pages[0];
114
+ }
115
+ $content = wptexturize($content);
116
+ $content = convert_smilies($content);
117
+ $content = convert_chars($content);
118
+ $content = wpautop($content);
119
+ $content = apply_filters('the_content', $content);
120
+ $content = str_replace(']]>', ']]&gt;', $content);
121
+ preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches);
122
+ for ($i=0; $i < count($matches[0]); $i++) {
123
+ $link_match = $matches[0][$i];
124
+ $link_number++;
125
+ $link_url = $matches[2][$i];
126
+ $link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
127
+ $link_text = $matches[4][$i];
128
+ $content = str_replace($link_match, '['.$link_number."] <a href=\"$link_url\" target=\"_blank\">".$link_text.'</a>', $content);
129
+ if(strlen($link_url) > $max_url_char) {
130
+ $link_url = substr($link_url, 0, $max_url_char).'<br />'.substr($link_url, $max_url_char, strlen($link_url));
131
+ }
132
+ if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
133
+ $links_text .= '<br />['.$link_number.'] '.__('Image').': <b>'.$link_url.'</b>';
134
+ } else {
135
+ $links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
136
+ }
137
+ }
138
+ }
139
+ if($display) {
140
+ echo $content;
141
+ } else {
142
+ return $content;
143
+ }
144
+ }
145
+
146
+
147
+ ### Function: Print Comments
148
+ function print_comments($link = true) {
149
+ global $post;
150
+ $comment_text = '';
151
+ $num_comments = get_comments_number();
152
+ if($num_comments == 0) {
153
+ $comment_text = __('No Comments');
154
+ } elseif($num_comments == 1) {
155
+ $comment_text = __('1 Comment');
156
+ } else {
157
+ $comment_text = __($num_comments.' Comments');
158
+ }
159
+ if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
160
+ _e('Comments Hidden');
161
+ } else {
162
+ if($link) {
163
+ echo '<a href="'.get_comments_link().'">'.$comment_text.'</a>';
164
+ } else {
165
+ echo $comment_text;
166
+ }
167
+ }
168
+ }
169
+
170
+
171
+ ### Function: Print Links
172
+ function print_links($text_links = 'URLs in this post:') {
173
+ global $links_text;
174
+ if(!empty($links_text)) {
175
+ echo $text_links.$links_text;
176
+ }
177
+ }
178
+
179
+
180
+ ### Function: Load WP-Print
181
+ add_action('template_redirect', 'wp_print');
182
+ function wp_print() {
183
+ if(intval(get_query_var('print')) == 1) {
184
+ include(ABSPATH . '/wp-print.php');
185
+ exit;
186
+ }
187
+ }
188
+ ?>
readme-install.txt ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Installation Instructions
2
+ --------------------------------------------------
3
+ // Open wp-content/plugins folder
4
+
5
+ Put:
6
+ ------------------------------------------------------------------
7
+ Folder: print
8
+ ------------------------------------------------------------------
9
+
10
+
11
+ // Open root Wordpress folder
12
+
13
+ Put:
14
+ ------------------------------------------------------------------
15
+ wp-print.php
16
+ ------------------------------------------------------------------
17
+
18
+
19
+ // Activate WP-Print 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
+
44
+ If you want to use an image/icon instead, replace print_link()
45
+ with print_link_image()
46
+ ------------------------------------------------------------------
readme-upgrade.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Upgrade Instructions For Version 1.0x To Version 2.03
2
+ ------------------------------------------------------------------
3
+ // Deactivate WP-Print plugin
4
+
5
+
6
+ // Open wp-content/plugins folder
7
+
8
+ Delete:
9
+ ------------------------------------------------------------------
10
+ print.php
11
+ ------------------------------------------------------------------
12
+
13
+ Put:
14
+ ------------------------------------------------------------------
15
+ Folder: print
16
+ ------------------------------------------------------------------
17
+
18
+
19
+ // Open root Wordpress folder
20
+
21
+ Overwrite:
22
+ ------------------------------------------------------------------
23
+ wp-print.php
24
+ ------------------------------------------------------------------
25
+
26
+
27
+ // Activate WP-Print plugin
readme.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 March 2006
10
+ --------------------------------------------------
11
+
12
+ // Version 2.03 (01-03-2006)
13
+ - NEW: Added Print Image With print_link_image()
14
+ - NEW: Automatically Break To Next Line If Link Contains More Than 100 Chars
15
+ - FIXED: Comment Numbers Showing In Password Protected Post
16
+
17
+ // Version 2.02 (01-02-2006)
18
+ - FIXED: Able To View Password Protected Blog
19
+
20
+ // Version 2.01 (01-01-2006)
21
+ - NEW: Compatible With WordPress 2.0
22
+ - NEW: Automatically Detect Whether You Are Using Nice Permalink
23
+ - NEW: Automated Permalink
24
+ - NEW: Now You Only Need To Insert 1 Line Into Your index.php Of Your Theme
25
+ - NEW: GPL License Added
26
+ - FIXED: Links Not Displaying Properly When Printing More Than 1 Post On A Single Page
27
+
28
+ // Version 2.00a (17-11-2005)
29
+ - NEW: Permlink For The Page Feature
30
+
31
+ // Version 2.00 (10-11-2005)
32
+ - 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.03 |
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(', '); ?> | <?php print_comments(); ?></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>