WP-Print - Version 2.53

Version Description

  • FIXED: Use get_stylesheet_directory() instead of TEMPLATEPATH
Download this release

Release Info

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

Code changes from version 2.52 to 2.53

Files changed (8) hide show
  1. print-comments.php +33 -35
  2. print-css-rtl.css +19 -19
  3. print-css.css +72 -72
  4. print-options.php +288 -290
  5. print-posts.php +63 -63
  6. print.php +34 -35
  7. readme.txt +209 -217
  8. wp-print.php +455 -456
print-comments.php CHANGED
@@ -1,36 +1,34 @@
1
- <?php
2
- /*
3
- * WordPress Plugin: WP-Print
4
- * Copyright (c) 2012 Lester "GaMerZ" Chan
5
- *
6
- * File Written By:
7
- * - Lester "GaMerZ" Chan
8
- * - http://lesterchan.net
9
- *
10
- * File Information:
11
- * - Printer Friendly Comments Template
12
- * - wp-content/plugins/wp-print/print-comments.php
13
- */
14
- ?>
15
-
16
-
17
- <?php if($comments) : ?>
18
- <?php $comment_count = 1; global $text_direction; ?>
19
- <span style='float:<?php echo ('rtl' == $text_direction) ? 'left' : 'right'; ?>' id='comments_controls'><?php print_comments_number(); ?> (<a href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'block'; return false;"><?php _e('Open', 'wp-print'); ?></a> | <a href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'none'; return false;"><?php _e('Close', 'wp-print'); ?></a>)</span>
20
- <div id="comments_box">
21
- <p id="CommentTitle"><?php print_comments_number(); ?> <?php _e('To', 'wp-print'); ?> "<?php the_title(); ?>"</p>
22
- <?php foreach ($comments as $comment) : ?>
23
- <p class="CommentDate">
24
- <strong>#<?php echo number_format_i18n($comment_count); ?> <?php comment_type(__('Comment', 'wp-print'), __('Trackback', 'wp-print'), __('Pingback', 'wp-print')); ?></strong> <?php _e('By', 'wp-print'); ?> <u><?php comment_author(); ?></u> <?php _e('On', 'wp-print'); ?> <?php comment_date(sprintf(__('%s @ %s', 'wp-print'), get_option('date_format'), get_option('time_format'))); ?>
25
- </p>
26
- <div class="CommentContent">
27
- <?php if ($comment->comment_approved == '0') : ?>
28
- <p><em><?php _e('Your comment is awaiting moderation.', 'wp-print'); ?></em></p>
29
- <?php endif; ?>
30
- <?php print_comments_content(); ?>
31
- </div>
32
- <?php $comment_count++; ?>
33
- <?php endforeach; ?>
34
- <hr class="Divider" style="text-align: center;" />
35
- </div>
36
  <?php endif; ?>
1
+ <?php
2
+ /*
3
+ * WordPress Plugin: WP-Print
4
+ * Copyright (c) 2012 Lester "GaMerZ" Chan
5
+ *
6
+ * File Written By:
7
+ * - Lester "GaMerZ" Chan
8
+ * - http://lesterchan.net
9
+ *
10
+ * File Information:
11
+ * - Printer Friendly Comments Template
12
+ * - wp-content/plugins/wp-print/print-comments.php
13
+ */
14
+
15
+ if($comments) : ?>
16
+ <?php $comment_count = 1; global $text_direction; ?>
17
+ <span style='float:<?php echo ('rtl' == $text_direction) ? 'left' : 'right'; ?>' id='comments_controls'><?php print_comments_number(); ?> (<a href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'block'; return false;"><?php _e('Open', 'wp-print'); ?></a> | <a href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'none'; return false;"><?php _e('Close', 'wp-print'); ?></a>)</span>
18
+ <div id="comments_box">
19
+ <p id="CommentTitle"><?php print_comments_number(); ?> <?php _e('To', 'wp-print'); ?> "<?php the_title(); ?>"</p>
20
+ <?php foreach ($comments as $comment) : ?>
21
+ <p class="CommentDate">
22
+ <strong>#<?php echo number_format_i18n($comment_count); ?> <?php comment_type(__('Comment', 'wp-print'), __('Trackback', 'wp-print'), __('Pingback', 'wp-print')); ?></strong> <?php _e('By', 'wp-print'); ?> <u><?php comment_author(); ?></u> <?php _e('On', 'wp-print'); ?> <?php comment_date(sprintf(__('%s @ %s', 'wp-print'), get_option('date_format'), get_option('time_format'))); ?>
23
+ </p>
24
+ <div class="CommentContent">
25
+ <?php if ($comment->comment_approved == '0') : ?>
26
+ <p><em><?php _e('Your comment is awaiting moderation.', 'wp-print'); ?></em></p>
27
+ <?php endif; ?>
28
+ <?php print_comments_content(); ?>
29
+ </div>
30
+ <?php $comment_count++; ?>
31
+ <?php endforeach; ?>
32
+ <hr class="Divider" style="text-align: center;" />
33
+ </div>
 
 
34
  <?php endif; ?>
print-css-rtl.css CHANGED
@@ -1,20 +1,20 @@
1
- /*
2
- * WordPress Plugin: WP-Print
3
- * Copyright (c) 2012 Lester "GaMerZ" Chan
4
- *
5
- * File Written By:
6
- * - Lester "GaMerZ" Chan
7
- * - http://lesterchan.net
8
- *
9
- * File Information:
10
- * - CSS Style For Printer Friendly Page (RTL)
11
- * - wp-content/plugins/wp-print/print-css-rtl.css
12
- */
13
-
14
- Body {
15
- font-family: Tahoma, Arial, Sans-Serif;
16
- }
17
-
18
- pre {
19
- direction: ltr;
20
  }
1
+ /*
2
+ * WordPress Plugin: WP-Print
3
+ * Copyright (c) 2012 Lester "GaMerZ" Chan
4
+ *
5
+ * File Written By:
6
+ * - Lester "GaMerZ" Chan
7
+ * - http://lesterchan.net
8
+ *
9
+ * File Information:
10
+ * - CSS Style For Printer Friendly Page (RTL)
11
+ * - wp-content/plugins/wp-print/print-css-rtl.css
12
+ */
13
+
14
+ Body {
15
+ font-family: Tahoma, Arial, Sans-Serif;
16
+ }
17
+
18
+ pre {
19
+ direction: ltr;
20
  }
print-css.css CHANGED
@@ -1,73 +1,73 @@
1
- /*
2
- * WordPress Plugin: WP-Print
3
- * Copyright (c) 2012 Lester "GaMerZ" Chan
4
- *
5
- * File Written By:
6
- * - Lester "GaMerZ" Chan
7
- * - http://lesterchan.net
8
- *
9
- * File Information:
10
- * - CSS Style For Printer Friendly Page
11
- * - wp-content/plugins/wp-print/print-css.css
12
- */
13
-
14
-
15
- Body {
16
- font-family: Verdana, Arial, Tahoma;
17
- font-size: 12px;
18
- color: #000000;
19
- }
20
- .Center {
21
- margin: 0px auto 0px auto;
22
- }
23
- #Outline {
24
- width: 90%;
25
- margin-left: auto;
26
- margin-right: auto;
27
- padding: 10px;
28
- border: 1px solid #000000;
29
- }
30
- #BlogTitle {
31
- font-weight: bold;
32
- font-size: 16px;
33
- margin-bottom: 5px;
34
- }
35
- #BlogDate {
36
- margin-top: 5px;
37
- margin-bottom: 10px;
38
- }
39
- #BlogContent {
40
- padding: 10px;
41
- margin-top: 10px;
42
- }
43
- HR.Divider {
44
- width: 80%;
45
- height: 1px;
46
- color: #000000;
47
- }
48
- #CommentTitle {
49
- font-weight: bold;
50
- font-size: 16px;
51
- padding-bottom: 10px;
52
- }
53
- .CommentDate {
54
- margin-top: 5px;
55
- margin-bottom: 10px;
56
- }
57
- .CommentContent {
58
- padding: 2px 10px 10px 10px;
59
- }
60
- @media print {
61
- #comments_controls,
62
- #print-link {
63
- display: none;
64
- }
65
- }
66
- .alignleft, div.alignleft {
67
- float: left;
68
- margin: 10px 10px 5px 0;
69
- }
70
- .alignright, div.alignright {
71
- float: right;
72
- margin: 10px 0 5px 10px;
73
  }
1
+ /*
2
+ * WordPress Plugin: WP-Print
3
+ * Copyright (c) 2012 Lester "GaMerZ" Chan
4
+ *
5
+ * File Written By:
6
+ * - Lester "GaMerZ" Chan
7
+ * - http://lesterchan.net
8
+ *
9
+ * File Information:
10
+ * - CSS Style For Printer Friendly Page
11
+ * - wp-content/plugins/wp-print/print-css.css
12
+ */
13
+
14
+
15
+ Body {
16
+ font-family: Verdana, Arial, Tahoma;
17
+ font-size: 12px;
18
+ color: #000000;
19
+ }
20
+ .Center {
21
+ margin: 0px auto 0px auto;
22
+ }
23
+ #Outline {
24
+ width: 90%;
25
+ margin-left: auto;
26
+ margin-right: auto;
27
+ padding: 10px;
28
+ border: 1px solid #000000;
29
+ }
30
+ #BlogTitle {
31
+ font-weight: bold;
32
+ font-size: 16px;
33
+ margin-bottom: 5px;
34
+ }
35
+ #BlogDate {
36
+ margin-top: 5px;
37
+ margin-bottom: 10px;
38
+ }
39
+ #BlogContent {
40
+ padding: 10px;
41
+ margin-top: 10px;
42
+ }
43
+ HR.Divider {
44
+ width: 80%;
45
+ height: 1px;
46
+ color: #000000;
47
+ }
48
+ #CommentTitle {
49
+ font-weight: bold;
50
+ font-size: 16px;
51
+ padding-bottom: 10px;
52
+ }
53
+ .CommentDate {
54
+ margin-top: 5px;
55
+ margin-bottom: 10px;
56
+ }
57
+ .CommentContent {
58
+ padding: 2px 10px 10px 10px;
59
+ }
60
+ @media print {
61
+ #comments_controls,
62
+ #print-link {
63
+ display: none;
64
+ }
65
+ }
66
+ .alignleft, div.alignleft {
67
+ float: left;
68
+ margin: 10px 10px 5px 0;
69
+ }
70
+ .alignright, div.alignright {
71
+ float: right;
72
+ margin: 10px 0 5px 10px;
73
  }
print-options.php CHANGED
@@ -1,290 +1,288 @@
1
- <?php
2
- /*
3
- * WordPress Plugin: WP-Print
4
- * Copyright (c) 2013 Lester "GaMerZ" Chan
5
- *
6
- * File Written By:
7
- * - Lester "GaMerZ" Chan
8
- * - http://lesterchan.net
9
- *
10
- * File Information:
11
- * - Print Options Page
12
- * - wp-content/plugins/wp-print/print-options.php
13
- */
14
-
15
-
16
- ### Variables Variables Variables
17
- $base_name = plugin_basename('wp-print/print-options.php');
18
- $base_page = 'admin.php?page='.$base_name;
19
- $id = intval($_GET['id']);
20
- $mode = trim($_GET['mode']);
21
- $print_settings = array('print_options');
22
-
23
-
24
- ### Form Processing
25
- // Update Options
26
- if(!empty($_POST['Submit'])) {
27
- check_admin_referer('wp-print_options');
28
- $print_options = array();
29
- $print_options['post_text'] = addslashes(trim(wp_filter_kses($_POST['print_post_text'])));
30
- $print_options['page_text'] = addslashes(trim(wp_filter_kses($_POST['print_page_text'])));
31
- $print_options['print_icon'] = trim($_POST['print_icon']);
32
- $print_options['print_style'] = intval($_POST['print_style']);
33
- $print_options['print_html'] = trim($_POST['print_html']);
34
- $print_options['comments'] = intval($_POST['print_comments']);
35
- $print_options['links'] = intval($_POST['print_links']);
36
- $print_options['images'] = intval($_POST['print_images']);
37
- $print_options['videos'] = intval($_POST['print_videos']);
38
- $print_options['disclaimer'] = trim($_POST['print_disclaimer']);
39
- $update_print_queries = array();
40
- $update_print_text = array();
41
- $update_print_queries[] = update_option('print_options', $print_options);
42
- $update_print_text[] = __('Print Options', 'wp-print');
43
- $i=0;
44
- $text = '';
45
- foreach($update_print_queries as $update_print_query) {
46
- if($update_print_query) {
47
- $text .= '<font color="green">'.$update_print_text[$i].' '.__('Updated', 'wp-print').'</font><br />';
48
- }
49
- $i++;
50
- }
51
- if(empty($text)) {
52
- $text = '<font color="red">'.__('No Print Option Updated', 'wp-print').'</font>';
53
- }
54
- }
55
- // Uninstall WP-Print
56
- if(!empty($_POST['do'])) {
57
- switch($_POST['do']) {
58
- case __('UNINSTALL WP-Print', 'wp-print') :
59
- if(trim($_POST['uninstall_print_yes']) == 'yes') {
60
- echo '<div id="message" class="updated fade">';
61
- echo '<p>';
62
- foreach($print_settings as $setting) {
63
- $delete_setting = delete_option($setting);
64
- if($delete_setting) {
65
- echo '<font color="green">';
66
- printf(__('Setting Key \'%s\' has been deleted.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
67
- echo '</font><br />';
68
- } else {
69
- echo '<font color="red">';
70
- printf(__('Error deleting Setting Key \'%s\'.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
71
- echo '</font><br />';
72
- }
73
- }
74
- echo '</p>';
75
- echo '</div>';
76
- $mode = 'end-UNINSTALL';
77
- }
78
- break;
79
- }
80
- }
81
-
82
- ### Determines Which Mode It Is
83
- switch($mode) {
84
- // Deactivating WP-Print
85
- case 'end-UNINSTALL':
86
- $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-print/wp-print.php';
87
- if(function_exists('wp_nonce_url')) {
88
- $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-print/wp-print.php');
89
- }
90
- echo '<div class="wrap">';
91
- echo '<h2>'.__('Uninstall WP-Print', 'wp-print').'</h2>';
92
- echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-Print Will Be Deactivated Automatically.', 'wp-print'), $deactivate_url).'</strong></p>';
93
- echo '</div>';
94
- break;
95
- // Main Page
96
- default:
97
- $print_options = get_option('print_options');
98
- ?>
99
- <script type="text/javascript">
100
- /* <![CDATA[*/
101
- function check_print_style() {
102
- if (parseInt(jQuery("#print_style").val()) == 4) {
103
- jQuery("#print_style_custom").show();
104
- } else {
105
- if(jQuery("#print_style_custom").is(":visible")) {
106
- jQuery("#print_style_custom").hide();
107
- }
108
- }
109
- }
110
- function print_default_templates(template) {
111
- var default_template;
112
- switch(template) {
113
- case 'html':
114
- default_template = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
115
- break;
116
- case 'disclaimer':
117
- default_template = '<?php echo js_escape(sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'))); ?>';
118
- break;
119
- }
120
- jQuery("#print_template_" + template).val(default_template);
121
- }
122
- /* ]]> */
123
- </script>
124
- <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
125
- <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
126
- <?php wp_nonce_field('wp-print_options'); ?>
127
- <div class="wrap">
128
- <?php screen_icon(); ?>
129
- <h2><?php _e('Print Options', 'wp-print'); ?></h2>
130
- <h3><?php _e('Print Styles', 'wp-print'); ?></h3>
131
- <table class="form-table">
132
- <tr>
133
- <th scope="row" valign="top"><?php _e('Print Text Link For Post', 'wp-print'); ?></th>
134
- <td>
135
- <input type="text" name="print_post_text" value="<?php echo stripslashes($print_options['post_text']); ?>" size="30" />
136
- </td>
137
- </tr>
138
- <tr>
139
- <th scope="row" valign="top"><?php _e('Print Text Link For Page', 'wp-print'); ?></th>
140
- <td>
141
- <input type="text" name="print_page_text" value="<?php echo stripslashes($print_options['page_text']); ?>" size="30" />
142
- </td>
143
- </tr>
144
- <tr>
145
- <th scope="row" valign="top"><?php _e('Print Icon', 'wp-print'); ?></th>
146
- <td>
147
- <?php
148
- $print_icon = $print_options['print_icon'];
149
- $print_icon_url = plugins_url('wp-print/images');
150
- $print_icon_path = WP_PLUGIN_DIR.'/wp-print/images';
151
- if($handle = @opendir($print_icon_path)) {
152
- while (false !== ($filename = readdir($handle))) {
153
- if ($filename != '.' && $filename != '..') {
154
- if(is_file($print_icon_path.'/'.$filename)) {
155
- echo '<p>';
156
- if($print_icon == $filename) {
157
- echo '<input type="radio" name="print_icon" value="'.$filename.'" checked="checked" />'."\n";
158
- } else {
159
- echo '<input type="radio" name="print_icon" value="'.$filename.'" />'."\n";
160
- }
161
- echo '&nbsp;&nbsp;&nbsp;';
162
- echo '<img src="'.$print_icon_url.'/'.$filename.'" alt="'.$filename.'" />'."\n";
163
- echo '&nbsp;&nbsp;&nbsp;('.$filename.')';
164
- echo '</p>'."\n";
165
- }
166
- }
167
- }
168
- closedir($handle);
169
- }
170
- ?>
171
- </td>
172
- </tr>
173
- <tr>
174
- <th scope="row" valign="top"><?php _e('Print Text Link Style', 'wp-print'); ?></th>
175
- <td>
176
- <select name="print_style" id="print_style" size="1" onchange="check_print_style();">
177
- <option value="1"<?php selected('1', $print_options['print_style']); ?>><?php _e('Print Icon With Text Link', 'wp-print'); ?></option>
178
- <option value="2"<?php selected('2', $print_options['print_style']); ?>><?php _e('Print Icon Only', 'wp-print'); ?></option>
179
- <option value="3"<?php selected('3', $print_options['print_style']); ?>><?php _e('Print Text Link Only', 'wp-print'); ?></option>
180
- <option value="4"<?php selected('4', $print_options['print_style']); ?>><?php _e('Custom', 'wp-print'); ?></option>
181
- </select>
182
- <div id="print_style_custom" style="display: <?php if(intval($print_options['print_style']) == 4) { echo 'block'; } else { echo 'none'; } ?>; margin-top: 20px;">
183
- <textarea rows="2" cols="80" name="print_html" id="print_template_html"><?php echo htmlspecialchars(stripslashes($print_options['print_html'])); ?></textarea><br />
184
- <?php _e('HTML is allowed.', 'wp-print'); ?><br />
185
- %PRINT_URL% - <?php _e('URL to the printable post/page.', 'wp-print'); ?><br />
186
- %PRINT_TEXT% - <?php _e('Print text link of the post/page that you have typed in above.', 'wp-print'); ?><br />
187
- %PRINT_ICON_URL% - <?php _e('URL to the print icon you have chosen above.', 'wp-print'); ?><br />
188
- <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('html');" class="button" />
189
- </div>
190
- </td>
191
- </tr>
192
- </table>
193
- <h3><?php _e('Print Options', 'wp-print'); ?></h3>
194
- <table class="form-table">
195
- <tr>
196
- <th scope="row" valign="top"><?php _e('Print Comments?', 'wp-print'); ?></th>
197
- <td>
198
- <select name="print_comments" size="1">
199
- <option value="1"<?php selected('1', $print_options['comments']); ?>><?php _e('Yes', 'wp-print'); ?></option>
200
- <option value="0"<?php selected('0', $print_options['comments']); ?>><?php _e('No', 'wp-print'); ?></option>
201
- </select>
202
- </td>
203
- </tr>
204
- <tr>
205
- <th scope="row" valign="top"><?php _e('Print Links?', 'wp-print'); ?></th>
206
- <td>
207
- <select name="print_links" size="1">
208
- <option value="1"<?php selected('1', $print_options['links']); ?>><?php _e('Yes', 'wp-print'); ?></option>
209
- <option value="0"<?php selected('0', $print_options['links']); ?>><?php _e('No', 'wp-print'); ?></option>
210
- </select>
211
- </td>
212
- </tr>
213
- <tr>
214
- <th scope="row" valign="top"><?php _e('Print Images?', 'wp-print'); ?></th>
215
- <td>
216
- <select name="print_images" size="1">
217
- <option value="1"<?php selected('1', $print_options['images']); ?>><?php _e('Yes', 'wp-print'); ?></option>
218
- <option value="0"<?php selected('0', $print_options['images']); ?>><?php _e('No', 'wp-print'); ?></option>
219
- </select>
220
- </td>
221
- </tr>
222
- <tr>
223
- <th scope="row" valign="top"><?php _e('Print Videos?', 'wp-print'); ?></th>
224
- <td>
225
- <select name="print_videos" size="1">
226
- <option value="1"<?php selected('1', $print_options['videos']); ?>><?php _e('Yes', 'wp-print'); ?></option>
227
- <option value="0"<?php selected('0', $print_options['videos']); ?>><?php _e('No', 'wp-print'); ?></option>
228
- </select>
229
- </td>
230
- </tr>
231
- <tr>
232
- <th scope="row" valign="top">
233
- <?php _e('Disclaimer/Copyright Text?', 'wp-print'); ?>
234
- <br /><br />
235
- <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('disclaimer');" class="button" />
236
- </th>
237
- <td>
238
- <textarea rows="2" cols="80" name="print_disclaimer" id="print_template_disclaimer"><?php echo htmlspecialchars(stripslashes($print_options['disclaimer'])); ?></textarea><br /><?php _e('HTML is allowed.', 'wp-print'); ?><br />
239
- </td>
240
- </tr>
241
- </table>
242
- <p class="submit">
243
- <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
244
- </p>
245
- </div>
246
- </form>
247
- <p>&nbsp;</p>
248
-
249
- <!-- Uninstall WP-Print -->
250
- <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
251
- <div class="wrap">
252
- <h3><?php _e('Uninstall WP-Print', 'wp-print'); ?></h3>
253
- <p>
254
- <?php _e('Deactivating WP-Print plugin does not remove any data that may have been created, such as the print options. To completely remove this plugin, you can uninstall it here.', 'wp-print'); ?>
255
- </p>
256
- <p style="color: red">
257
- <strong><?php _e('WARNING:', 'wp-print'); ?></strong><br />
258
- <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', 'wp-print'); ?>
259
- </p>
260
- <p style="color: red">
261
- <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-print'); ?></strong><br />
262
- </p>
263
- <table class="widefat">
264
- <thead>
265
- <tr>
266
- <th><?php _e('WordPress Options', 'wp-print'); ?></th>
267
- </tr>
268
- </thead>
269
- <tr>
270
- <td valign="top">
271
- <ol>
272
- <?php
273
- foreach($print_settings as $settings) {
274
- echo '<li>'.$settings.'</li>'."\n";
275
- }
276
- ?>
277
- </ol>
278
- </td>
279
- </tr>
280
- </table>
281
- <p>&nbsp;</p>
282
- <p style="text-align: center;">
283
- <input type="checkbox" name="uninstall_print_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-print'); ?><br /><br />
284
- <input type="submit" name="do" value="<?php _e('UNINSTALL WP-Print', 'wp-print'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-Print From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-print'); ?>')" />
285
- </p>
286
- </div>
287
- </form>
288
- <?php
289
- } // End switch($mode)
290
- ?>
1
+ <?php
2
+ /*
3
+ * WordPress Plugin: WP-Print
4
+ * Copyright (c) 2013 Lester "GaMerZ" Chan
5
+ *
6
+ * File Written By:
7
+ * - Lester "GaMerZ" Chan
8
+ * - http://lesterchan.net
9
+ *
10
+ * File Information:
11
+ * - Print Options Page
12
+ * - wp-content/plugins/wp-print/print-options.php
13
+ */
14
+
15
+
16
+ ### Variables Variables Variables
17
+ $base_name = plugin_basename('wp-print/print-options.php');
18
+ $base_page = 'admin.php?page='.$base_name;
19
+ $mode = isset($_GET['mode']) ? trim($_GET['mode']) : '';
20
+ $print_settings = array('print_options');
21
+
22
+
23
+ ### Form Processing
24
+ // Update Options
25
+ if(!empty($_POST['Submit'])) {
26
+ check_admin_referer('wp-print_options');
27
+ $print_options = array();
28
+ $print_options['post_text'] = addslashes(trim(wp_filter_kses($_POST['print_post_text'])));
29
+ $print_options['page_text'] = addslashes(trim(wp_filter_kses($_POST['print_page_text'])));
30
+ $print_options['print_icon'] = trim($_POST['print_icon']);
31
+ $print_options['print_style'] = intval($_POST['print_style']);
32
+ $print_options['print_html'] = trim($_POST['print_html']);
33
+ $print_options['comments'] = intval($_POST['print_comments']);
34
+ $print_options['links'] = intval($_POST['print_links']);
35
+ $print_options['images'] = intval($_POST['print_images']);
36
+ $print_options['videos'] = intval($_POST['print_videos']);
37
+ $print_options['disclaimer'] = trim($_POST['print_disclaimer']);
38
+ $update_print_queries = array();
39
+ $update_print_text = array();
40
+ $update_print_queries[] = update_option('print_options', $print_options);
41
+ $update_print_text[] = __('Print Options', 'wp-print');
42
+ $i=0;
43
+ $text = '';
44
+ foreach($update_print_queries as $update_print_query) {
45
+ if($update_print_query) {
46
+ $text .= '<font color="green">'.$update_print_text[$i].' '.__('Updated', 'wp-print').'</font><br />';
47
+ }
48
+ $i++;
49
+ }
50
+ if(empty($text)) {
51
+ $text = '<font color="red">'.__('No Print Option Updated', 'wp-print').'</font>';
52
+ }
53
+ }
54
+ // Uninstall WP-Print
55
+ if(!empty($_POST['do'])) {
56
+ switch($_POST['do']) {
57
+ case __('UNINSTALL WP-Print', 'wp-print') :
58
+ if(trim($_POST['uninstall_print_yes']) == 'yes') {
59
+ echo '<div id="message" class="updated fade">';
60
+ echo '<p>';
61
+ foreach($print_settings as $setting) {
62
+ $delete_setting = delete_option($setting);
63
+ if($delete_setting) {
64
+ echo '<font color="green">';
65
+ printf(__('Setting Key \'%s\' has been deleted.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
66
+ echo '</font><br />';
67
+ } else {
68
+ echo '<font color="red">';
69
+ printf(__('Error deleting Setting Key \'%s\'.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
70
+ echo '</font><br />';
71
+ }
72
+ }
73
+ echo '</p>';
74
+ echo '</div>';
75
+ $mode = 'end-UNINSTALL';
76
+ }
77
+ break;
78
+ }
79
+ }
80
+
81
+ ### Determines Which Mode It Is
82
+ switch($mode) {
83
+ // Deactivating WP-Print
84
+ case 'end-UNINSTALL':
85
+ $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-print/wp-print.php';
86
+ if(function_exists('wp_nonce_url')) {
87
+ $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-print/wp-print.php');
88
+ }
89
+ echo '<div class="wrap">';
90
+ echo '<h2>'.__('Uninstall WP-Print', 'wp-print').'</h2>';
91
+ echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-Print Will Be Deactivated Automatically.', 'wp-print'), $deactivate_url).'</strong></p>';
92
+ echo '</div>';
93
+ break;
94
+ // Main Page
95
+ default:
96
+ $print_options = get_option('print_options');
97
+ ?>
98
+ <script type="text/javascript">
99
+ /* <![CDATA[*/
100
+ function check_print_style() {
101
+ if (parseInt(jQuery("#print_style").val()) == 4) {
102
+ jQuery("#print_style_custom").show();
103
+ } else {
104
+ if(jQuery("#print_style_custom").is(":visible")) {
105
+ jQuery("#print_style_custom").hide();
106
+ }
107
+ }
108
+ }
109
+ function print_default_templates(template) {
110
+ var default_template;
111
+ switch(template) {
112
+ case 'html':
113
+ default_template = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
114
+ break;
115
+ case 'disclaimer':
116
+ default_template = '<?php echo js_escape(sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'))); ?>';
117
+ break;
118
+ }
119
+ jQuery("#print_template_" + template).val(default_template);
120
+ }
121
+ /* ]]> */
122
+ </script>
123
+ <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
124
+ <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
125
+ <?php wp_nonce_field('wp-print_options'); ?>
126
+ <div class="wrap">
127
+ <?php screen_icon(); ?>
128
+ <h2><?php _e('Print Options', 'wp-print'); ?></h2>
129
+ <h3><?php _e('Print Styles', 'wp-print'); ?></h3>
130
+ <table class="form-table">
131
+ <tr>
132
+ <th scope="row" valign="top"><?php _e('Print Text Link For Post', 'wp-print'); ?></th>
133
+ <td>
134
+ <input type="text" name="print_post_text" value="<?php echo stripslashes($print_options['post_text']); ?>" size="30" />
135
+ </td>
136
+ </tr>
137
+ <tr>
138
+ <th scope="row" valign="top"><?php _e('Print Text Link For Page', 'wp-print'); ?></th>
139
+ <td>
140
+ <input type="text" name="print_page_text" value="<?php echo stripslashes($print_options['page_text']); ?>" size="30" />
141
+ </td>
142
+ </tr>
143
+ <tr>
144
+ <th scope="row" valign="top"><?php _e('Print Icon', 'wp-print'); ?></th>
145
+ <td>
146
+ <?php
147
+ $print_icon = $print_options['print_icon'];
148
+ $print_icon_url = plugins_url('wp-print/images');
149
+ $print_icon_path = WP_PLUGIN_DIR.'/wp-print/images';
150
+ if($handle = @opendir($print_icon_path)) {
151
+ while (false !== ($filename = readdir($handle))) {
152
+ if ($filename != '.' && $filename != '..') {
153
+ if(is_file($print_icon_path.'/'.$filename)) {
154
+ echo '<p>';
155
+ if($print_icon == $filename) {
156
+ echo '<input type="radio" name="print_icon" value="'.$filename.'" checked="checked" />'."\n";
157
+ } else {
158
+ echo '<input type="radio" name="print_icon" value="'.$filename.'" />'."\n";
159
+ }
160
+ echo '&nbsp;&nbsp;&nbsp;';
161
+ echo '<img src="'.$print_icon_url.'/'.$filename.'" alt="'.$filename.'" />'."\n";
162
+ echo '&nbsp;&nbsp;&nbsp;('.$filename.')';
163
+ echo '</p>'."\n";
164
+ }
165
+ }
166
+ }
167
+ closedir($handle);
168
+ }
169
+ ?>
170
+ </td>
171
+ </tr>
172
+ <tr>
173
+ <th scope="row" valign="top"><?php _e('Print Text Link Style', 'wp-print'); ?></th>
174
+ <td>
175
+ <select name="print_style" id="print_style" size="1" onchange="check_print_style();">
176
+ <option value="1"<?php selected('1', $print_options['print_style']); ?>><?php _e('Print Icon With Text Link', 'wp-print'); ?></option>
177
+ <option value="2"<?php selected('2', $print_options['print_style']); ?>><?php _e('Print Icon Only', 'wp-print'); ?></option>
178
+ <option value="3"<?php selected('3', $print_options['print_style']); ?>><?php _e('Print Text Link Only', 'wp-print'); ?></option>
179
+ <option value="4"<?php selected('4', $print_options['print_style']); ?>><?php _e('Custom', 'wp-print'); ?></option>
180
+ </select>
181
+ <div id="print_style_custom" style="display: <?php if(intval($print_options['print_style']) == 4) { echo 'block'; } else { echo 'none'; } ?>; margin-top: 20px;">
182
+ <textarea rows="2" cols="80" name="print_html" id="print_template_html"><?php echo htmlspecialchars(stripslashes($print_options['print_html'])); ?></textarea><br />
183
+ <?php _e('HTML is allowed.', 'wp-print'); ?><br />
184
+ %PRINT_URL% - <?php _e('URL to the printable post/page.', 'wp-print'); ?><br />
185
+ %PRINT_TEXT% - <?php _e('Print text link of the post/page that you have typed in above.', 'wp-print'); ?><br />
186
+ %PRINT_ICON_URL% - <?php _e('URL to the print icon you have chosen above.', 'wp-print'); ?><br />
187
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('html');" class="button" />
188
+ </div>
189
+ </td>
190
+ </tr>
191
+ </table>
192
+ <h3><?php _e('Print Options', 'wp-print'); ?></h3>
193
+ <table class="form-table">
194
+ <tr>
195
+ <th scope="row" valign="top"><?php _e('Print Comments?', 'wp-print'); ?></th>
196
+ <td>
197
+ <select name="print_comments" size="1">
198
+ <option value="1"<?php selected('1', $print_options['comments']); ?>><?php _e('Yes', 'wp-print'); ?></option>
199
+ <option value="0"<?php selected('0', $print_options['comments']); ?>><?php _e('No', 'wp-print'); ?></option>
200
+ </select>
201
+ </td>
202
+ </tr>
203
+ <tr>
204
+ <th scope="row" valign="top"><?php _e('Print Links?', 'wp-print'); ?></th>
205
+ <td>
206
+ <select name="print_links" size="1">
207
+ <option value="1"<?php selected('1', $print_options['links']); ?>><?php _e('Yes', 'wp-print'); ?></option>
208
+ <option value="0"<?php selected('0', $print_options['links']); ?>><?php _e('No', 'wp-print'); ?></option>
209
+ </select>
210
+ </td>
211
+ </tr>
212
+ <tr>
213
+ <th scope="row" valign="top"><?php _e('Print Images?', 'wp-print'); ?></th>
214
+ <td>
215
+ <select name="print_images" size="1">
216
+ <option value="1"<?php selected('1', $print_options['images']); ?>><?php _e('Yes', 'wp-print'); ?></option>
217
+ <option value="0"<?php selected('0', $print_options['images']); ?>><?php _e('No', 'wp-print'); ?></option>
218
+ </select>
219
+ </td>
220
+ </tr>
221
+ <tr>
222
+ <th scope="row" valign="top"><?php _e('Print Videos?', 'wp-print'); ?></th>
223
+ <td>
224
+ <select name="print_videos" size="1">
225
+ <option value="1"<?php selected('1', $print_options['videos']); ?>><?php _e('Yes', 'wp-print'); ?></option>
226
+ <option value="0"<?php selected('0', $print_options['videos']); ?>><?php _e('No', 'wp-print'); ?></option>
227
+ </select>
228
+ </td>
229
+ </tr>
230
+ <tr>
231
+ <th scope="row" valign="top">
232
+ <?php _e('Disclaimer/Copyright Text?', 'wp-print'); ?>
233
+ <br /><br />
234
+ <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-print'); ?>" onclick="print_default_templates('disclaimer');" class="button" />
235
+ </th>
236
+ <td>
237
+ <textarea rows="2" cols="80" name="print_disclaimer" id="print_template_disclaimer"><?php echo htmlspecialchars(stripslashes($print_options['disclaimer'])); ?></textarea><br /><?php _e('HTML is allowed.', 'wp-print'); ?><br />
238
+ </td>
239
+ </tr>
240
+ </table>
241
+ <p class="submit">
242
+ <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
243
+ </p>
244
+ </div>
245
+ </form>
246
+ <p>&nbsp;</p>
247
+
248
+ <!-- Uninstall WP-Print -->
249
+ <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
250
+ <div class="wrap">
251
+ <h3><?php _e('Uninstall WP-Print', 'wp-print'); ?></h3>
252
+ <p>
253
+ <?php _e('Deactivating WP-Print plugin does not remove any data that may have been created, such as the print options. To completely remove this plugin, you can uninstall it here.', 'wp-print'); ?>
254
+ </p>
255
+ <p style="color: red">
256
+ <strong><?php _e('WARNING:', 'wp-print'); ?></strong><br />
257
+ <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', 'wp-print'); ?>
258
+ </p>
259
+ <p style="color: red">
260
+ <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-print'); ?></strong><br />
261
+ </p>
262
+ <table class="widefat">
263
+ <thead>
264
+ <tr>
265
+ <th><?php _e('WordPress Options', 'wp-print'); ?></th>
266
+ </tr>
267
+ </thead>
268
+ <tr>
269
+ <td valign="top">
270
+ <ol>
271
+ <?php
272
+ foreach($print_settings as $settings) {
273
+ echo '<li>'.$settings.'</li>'."\n";
274
+ }
275
+ ?>
276
+ </ol>
277
+ </td>
278
+ </tr>
279
+ </table>
280
+ <p>&nbsp;</p>
281
+ <p style="text-align: center;">
282
+ <input type="checkbox" name="uninstall_print_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-print'); ?><br /><br />
283
+ <input type="submit" name="do" value="<?php _e('UNINSTALL WP-Print', 'wp-print'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-Print From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-print'); ?>')" />
284
+ </p>
285
+ </div>
286
+ </form>
287
+ <?php
288
+ } // End switch($mode)
 
 
print-posts.php CHANGED
@@ -1,64 +1,64 @@
1
- <?php
2
- /*
3
- * WordPress Plugin: WP-Print
4
- * Copyright (c) 2012 Lester "GaMerZ" Chan
5
- *
6
- * File Written By:
7
- * - Lester "GaMerZ" Chan
8
- * - http://lesterchan.net
9
- *
10
- * File Information:
11
- * - Printer Friendly Post/Page Template
12
- * - wp-content/plugins/wp-print/print-posts.php
13
- */
14
- ?>
15
-
16
- <?php global $text_direction; ?>
17
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
- <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
19
- <head>
20
- <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
21
- <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
22
- <meta name="Robots" content="noindex, nofollow" />
23
- <?php if(@file_exists(TEMPLATEPATH.'/print-css.css')): ?>
24
- <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/print-css.css" type="text/css" media="screen, print" />
25
- <?php else: ?>
26
- <link rel="stylesheet" href="<?php echo plugins_url('wp-print/print-css.css'); ?>" type="text/css" media="screen, print" />
27
- <?php endif; ?>
28
- <?php if('rtl' == $text_direction): ?>
29
- <?php if(@file_exists(TEMPLATEPATH.'/print-css-rtl.css')): ?>
30
- <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/print-css-rtl.css" type="text/css" media="screen, print" />
31
- <?php else: ?>
32
- <link rel="stylesheet" href="<?php echo plugins_url('wp-print/print-css-rtl.css'); ?>" type="text/css" media="screen, print" />
33
- <?php endif; ?>
34
- <?php endif; ?>
35
- <link rel="canonical" href="<?php the_permalink(); ?>" />
36
- </head>
37
- <body>
38
- <p style="text-align: center;"><strong>- <?php bloginfo('name'); ?> - <span dir="ltr"><?php bloginfo('url')?></span> -</strong></p>
39
- <div class="Center">
40
- <div id="Outline">
41
- <?php if (have_posts()): ?>
42
- <?php while (have_posts()): the_post(); ?>
43
- <p id="BlogTitle"><?php the_title(); ?></p>
44
- <p id="BlogDate"><?php _e('Posted By', 'wp-print'); ?> <u><?php the_author(); ?></u> <?php _e('On', 'wp-print'); ?> <?php the_time(sprintf(__('%s @ %s', 'wp-print'), get_option('date_format'), get_option('time_format'))); ?> <?php _e('In', 'wp-print'); ?> <?php print_categories('<u>', '</u>'); ?> | <u><a href='#comments_controls'><?php print_comments_number(); ?></a></u></p>
45
- <div id="BlogContent"><?php print_content(); ?></div>
46
- <?php endwhile; ?>
47
- <hr class="Divider" style="text-align: center;" />
48
- <?php if(print_can('comments')): ?>
49
- <?php comments_template(); ?>
50
- <?php endif; ?>
51
- <p><?php _e('Article printed from', 'wp-print'); ?> <?php bloginfo('name'); ?>: <strong dir="ltr"><?php bloginfo('url'); ?></strong></p>
52
- <p><?php _e('URL to article', 'wp-print'); ?>: <strong dir="ltr"><?php the_permalink(); ?></strong></p>
53
- <?php if(print_can('links')): ?>
54
- <p><?php print_links(); ?></p>
55
- <?php endif; ?>
56
- <p style="text-align: <?php echo ('rtl' == $text_direction) ? 'left' : 'right'; ?>;" id="print-link"><?php _e('Click', 'wp-print'); ?> <a href="#Print" onclick="window.print(); return false;" title="<?php _e('Click here to print.', 'wp-print'); ?>"><?php _e('here', 'wp-print'); ?></a> <?php _e('to print.', 'wp-print'); ?></p>
57
- <?php else: ?>
58
- <p><?php _e('No posts matched your criteria.', 'wp-print'); ?></p>
59
- <?php endif; ?>
60
- </div>
61
- </div>
62
- <p style="text-align: center;"><?php echo stripslashes($print_options['disclaimer']); ?></p>
63
- </body>
64
  </html>
1
+ <?php
2
+ /*
3
+ * WordPress Plugin: WP-Print
4
+ * Copyright (c) 2012 Lester "GaMerZ" Chan
5
+ *
6
+ * File Written By:
7
+ * - Lester "GaMerZ" Chan
8
+ * - http://lesterchan.net
9
+ *
10
+ * File Information:
11
+ * - Printer Friendly Post/Page Template
12
+ * - wp-content/plugins/wp-print/print-posts.php
13
+ */
14
+
15
+ global $text_direction;
16
+ ?>
17
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
+ <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
19
+ <head>
20
+ <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
21
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
22
+ <meta name="Robots" content="noindex, nofollow" />
23
+ <?php if(@file_exists(get_stylesheet_directory().'/print-css.css')): ?>
24
+ <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/print-css.css" type="text/css" media="screen, print" />
25
+ <?php else: ?>
26
+ <link rel="stylesheet" href="<?php echo plugins_url('wp-print/print-css.css'); ?>" type="text/css" media="screen, print" />
27
+ <?php endif; ?>
28
+ <?php if('rtl' == $text_direction): ?>
29
+ <?php if(@file_exists(get_stylesheet_directory().'/print-css-rtl.css')): ?>
30
+ <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/print-css-rtl.css" type="text/css" media="screen, print" />
31
+ <?php else: ?>
32
+ <link rel="stylesheet" href="<?php echo plugins_url('wp-print/print-css-rtl.css'); ?>" type="text/css" media="screen, print" />
33
+ <?php endif; ?>
34
+ <?php endif; ?>
35
+ <link rel="canonical" href="<?php the_permalink(); ?>" />
36
+ </head>
37
+ <body>
38
+ <p style="text-align: center;"><strong>- <?php bloginfo('name'); ?> - <span dir="ltr"><?php bloginfo('url')?></span> -</strong></p>
39
+ <div class="Center">
40
+ <div id="Outline">
41
+ <?php if (have_posts()): ?>
42
+ <?php while (have_posts()): the_post(); ?>
43
+ <p id="BlogTitle"><?php the_title(); ?></p>
44
+ <p id="BlogDate"><?php _e('Posted By', 'wp-print'); ?> <u><?php the_author(); ?></u> <?php _e('On', 'wp-print'); ?> <?php the_time(sprintf(__('%s @ %s', 'wp-print'), get_option('date_format'), get_option('time_format'))); ?> <?php _e('In', 'wp-print'); ?> <?php print_categories('<u>', '</u>'); ?> | <u><a href='#comments_controls'><?php print_comments_number(); ?></a></u></p>
45
+ <div id="BlogContent"><?php print_content(); ?></div>
46
+ <?php endwhile; ?>
47
+ <hr class="Divider" style="text-align: center;" />
48
+ <?php if(print_can('comments')): ?>
49
+ <?php comments_template(); ?>
50
+ <?php endif; ?>
51
+ <p><?php _e('Article printed from', 'wp-print'); ?> <?php bloginfo('name'); ?>: <strong dir="ltr"><?php bloginfo('url'); ?></strong></p>
52
+ <p><?php _e('URL to article', 'wp-print'); ?>: <strong dir="ltr"><?php the_permalink(); ?></strong></p>
53
+ <?php if(print_can('links')): ?>
54
+ <p><?php print_links(); ?></p>
55
+ <?php endif; ?>
56
+ <p style="text-align: <?php echo ('rtl' == $text_direction) ? 'left' : 'right'; ?>;" id="print-link"><?php _e('Click', 'wp-print'); ?> <a href="#Print" onclick="window.print(); return false;" title="<?php _e('Click here to print.', 'wp-print'); ?>"><?php _e('here', 'wp-print'); ?></a> <?php _e('to print.', 'wp-print'); ?></p>
57
+ <?php else: ?>
58
+ <p><?php _e('No posts matched your criteria.', 'wp-print'); ?></p>
59
+ <?php endif; ?>
60
+ </div>
61
+ </div>
62
+ <p style="text-align: center;"><?php echo stripslashes($print_options['disclaimer']); ?></p>
63
+ </body>
64
  </html>
print.php CHANGED
@@ -1,35 +1,34 @@
1
- <?php
2
- /*
3
- * WordPress Plugin: WP-Print
4
- * Copyright (c) 2012 Lester "GaMerZ" Chan
5
- *
6
- * File Written By:
7
- * - Lester "GaMerZ" Chan
8
- * - http://lesterchan.net
9
- *
10
- * File Information:
11
- * - Process Printing Page
12
- * - wp-content/plugins/wp-print/print.php
13
- */
14
-
15
-
16
- ### Variables
17
- $links_text = '';
18
-
19
- ### Actions
20
- add_action('init', 'print_content');
21
-
22
- ### Filters
23
- add_filter('wp_title', 'print_pagetitle');
24
- add_filter('comments_template', 'print_template_comments');
25
-
26
- ### Print Options
27
- $print_options = get_option('print_options');
28
-
29
- ### Load Print Post/Page Template
30
- if(file_exists(TEMPLATEPATH.'/print-posts.php')) {
31
- include(TEMPLATEPATH.'/print-posts.php');
32
- } else {
33
- include(WP_PLUGIN_DIR.'/wp-print/print-posts.php');
34
- }
35
- ?>
1
+ <?php
2
+ /*
3
+ * WordPress Plugin: WP-Print
4
+ * Copyright (c) 2012 Lester "GaMerZ" Chan
5
+ *
6
+ * File Written By:
7
+ * - Lester "GaMerZ" Chan
8
+ * - http://lesterchan.net
9
+ *
10
+ * File Information:
11
+ * - Process Printing Page
12
+ * - wp-content/plugins/wp-print/print.php
13
+ */
14
+
15
+
16
+ ### Variables
17
+ $links_text = '';
18
+
19
+ ### Actions
20
+ add_action('init', 'print_content');
21
+
22
+ ### Filters
23
+ add_filter('wp_title', 'print_pagetitle');
24
+ add_filter('comments_template', 'print_template_comments');
25
+
26
+ ### Print Options
27
+ $print_options = get_option('print_options');
28
+
29
+ ### Load Print Post/Page Template
30
+ if(file_exists(get_stylesheet_directory().'/print-posts.php')) {
31
+ include(get_stylesheet_directory().'/print-posts.php');
32
+ } else {
33
+ include(WP_PLUGIN_DIR.'/wp-print/print-posts.php');
34
+ }
 
readme.txt CHANGED
@@ -1,217 +1,209 @@
1
- === WP-Print ===
2
- Contributors: GamerZ, aaroncampbell
3
- Donate link: http://lesterchan.net/site/donation/
4
- Tags: print, printer, wp-print
5
- Requires at least: 2.8
6
- Tested up to: 3.5.1
7
- Stable tag: trunk
8
-
9
- Displays a printable version of your WordPress blog's post/page.
10
-
11
- == Description ==
12
-
13
- Displays a printable version of your WordPress blog's post/page.
14
-
15
- = Previous Versions =
16
- * [WP-Print 2.50 For WordPress 2.7.x And 2.8.x](http://downloads.wordpress.org/plugin/wp-print.2.50.zip "WP-Print 2.50 For WordPress 2.7.x And 2.8.x")
17
- * [WP-Print 2.50 For WordPress 2.7.x And 2.8.x](http://downloads.wordpress.org/plugin/wp-print.2.50.zip "WP-Print 2.50 For WordPress 2.7.x And 2.8.x")
18
- * [WP-Print 2.31 For WordPress 2.5.x And 2.6.x](http://downloads.wordpress.org/plugin/wp-print.2.31.zip "WP-Print 2.31 For WordPress 2.5.x And 2.6.x")
19
- * [WP-Print 2.20 For WordPress 2.1.x, 2.2.x And 2.3.x](http://downloads.wordpress.org/plugin/wp-print.2.20.zip "WP-Print 2.20 For WordPress 2.1.x, 2.2.x And 2.3.x")
20
- * [WP-Print 2.06 For WordPress 2.0.x](http://downloads.wordpress.org/plugin/wp-print.2.06.zip "WP-Print 2.06 For WordPress 2.0.x")
21
- * [WP-Print 2.00 For WordPress 1.5.2](http://downloads.wordpress.org/plugin/wp-print.2.00.zip "WP-Print 2.00 For WordPress 1.5.2")
22
-
23
- = Development =
24
- * [http://dev.wp-plugins.org/browser/wp-print/](http://dev.wp-plugins.org/browser/wp-print/ "http://dev.wp-plugins.org/browser/wp-print/")
25
-
26
- = Translations =
27
- * [http://dev.wp-plugins.org/browser/wp-print/i18n/](http://dev.wp-plugins.org/browser/wp-print/i18n/ "http://dev.wp-plugins.org/browser/wp-print/i18n/")
28
-
29
- = Support Forums =
30
- * [http://forums.lesterchan.net/index.php?board=18.0](http://forums.lesterchan.net/index.php?board=18.0 "http://forums.lesterchan.net/index.php?board=18.0")
31
-
32
- = Credits =
33
- * Icons courtesy of [FamFamFam](http://www.famfamfam.com/)
34
- * __ngetext() by [Anna Ozeritskaya](http://hweia.ru/)
35
- * Right-to-left language support by [Kambiz R. Khojasteh](http://persian-programming.com/)
36
- * Do Not Print idea by [Robert "Nilpo" Dunham](http://www.nilpo.com/)
37
-
38
- = Donations =
39
- I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks as my school allowance, I will really appreciate it. If not feel free to use it without any obligations. Thank You. My Paypal account is lesterchan@gmail.com.
40
-
41
- == Installation ==
42
-
43
- You can either install it automatically from the WordPress admin, or do it manually:
44
-
45
- 1. Upload the whole `wp-print` directory into your plugins folder(`/wp-content/plugins/`)
46
- 1. Activate the plugin through the 'Plugins' menu in WordPress
47
-
48
- Once installed take the following steps to set it up:
49
-
50
- 1. WP-Print settings page is located in WP-Admin -> Settings -> Print
51
- 1. You Need To Re-Generate The Permalink (WP-Admin -> Settings -> Permalinks -> Save Changes)
52
- 1. Refer To Usage For Further Instructions
53
-
54
- = Usage =
55
-
56
- 1. Open `wp-content/themes/<YOUR THEME NAME>/index.php`
57
- You may place it in single.php, post.php, page.php, etc also.
58
- 1. Find: `<?php while (have_posts()) : the_post(); ?>`
59
- 1. Add Anywhere Below It: `<?php if(function_exists('wp_print')) { print_link(); } ?>`
60
-
61
- * The first value is the text for printing post.
62
- * The second value is the text for printing page.
63
- * Default: print_link('', '')
64
- * Alternatively, you can set the text in 'WP-Admin -> Settings -> Print'.
65
- * If you DO NOT want the print link to appear in every post/page, DO NOT use the code above. Just type in <strong>[print_link]</strong> into the selected post/page content and it will embed the print link into that post/page only.
66
-
67
-
68
- == Screenshots ==
69
-
70
- 1. Admin Print Options
71
- 2. Print Post Link
72
- 3. Print Page link
73
- 4. Print Page
74
-
75
- == Frequently Asked Questions ==
76
-
77
- = How do I add this to my theme? =
78
-
79
- 1. Open `wp-content/themes/<YOUR THEME NAME>/index.php`
80
- You may place it in single.php, post.php, page.php, etc also.
81
- 1. Find: `<?php while (have_posts()) : the_post(); ?>`
82
- 1. Add Anywhere Below It: `<?php if(function_exists('wp_print')) { print_link(); } ?>`
83
-
84
- Simply add this code <strong>inside the loop = where you want the print link to display:
85
- <code>
86
- if(function_exists('wp_print')) {
87
- print_link();
88
- }
89
- </code>
90
-
91
- = If you do not want to print a portion of your post's content =
92
- <code>
93
- [donotprint]Text within this tag will not be displayed when printing[/donotprint]
94
- </code>
95
- * The text within [donotprint][/donotprint] will not be displayed when you are viewing a printer friendly version of a post or page.
96
- * However, it will still be displayed as normal on a normal post or page view.
97
- * Do note that if you are using WP-Email, any text within [donotprint][/donotprint] will not be emailed as well.
98
-
99
- = Custom Template =
100
- * WP-Print will load 'print-css.css', '<strong>print-posts.php' and 'print-comments.php' from your theme's directory if it exists.
101
- * If it doesn't exists, it will just load the respective default file that comes with WP-Print.
102
- * This will allow you to upgrade WP-Print without worrying about overwriting your printing styles or templates that you have created.
103
-
104
-
105
- == Changelog ==
106
-
107
- = 2.52 =
108
- * FIXED: Added nonce to Options. Credits to Charlie Eriksen via Secunia SVCRP.
109
-
110
- = 2.51 =
111
- * NEW: Support for links that start with "//"
112
- * FIXED: Unable to load WP-Print on Password Protected posts
113
-
114
- = 2.50 =
115
- * NEW: Uses jQuery Framework
116
- * NEW: [donotprint][/donotprint] ShortCode Will Not Be Displayed As Well When Using WP-Email (Refer To Usage Tab)
117
- * NEW: Use _n() Instead Of __ngettext() And _n_noop() Instead Of __ngettext_noop()
118
- * FIXED: Uses $_SERVER['PHP_SELF'] With plugin_basename(__FILE__) Instead Of Just $_SERVER['REQUEST_URI']
119
- * FIXED: Nested ShortCode Issues
120
-
121
- = 2.40 =
122
- * NEW: Works For WordPress 2.7 Only
123
- * NEW: Better Translation Using __ngetext() by Anna Ozeritskaya
124
- * NEW: Right To Left Language Support by Kambiz R. Khojasteh
125
- * NEW: Call print_textdomain() In print_init() by Kambiz R. Khojasteh
126
- * NEW: Replace "text_direction" Option With $text_direction And language_attributes() by Kambiz R. Khojasteh
127
- * NEW: Added "print-css-rtl.css" by Kambiz R. Khojasteh
128
- * NEW: Page Title Is Now "Post Title -> Print" Instead Of "Print -> Post Title" by Kambiz R. Khojasteh
129
- * NEW: Modified "print-css.css" To Hide "comments_controls" Element For Print by Kambiz R. Khojasteh
130
- * FIXED: Footnotes Referencing Is Now "link1 <sup>[1]</sup>" Instead Of "[1] link1" by Kambiz R. Khojasteh
131
- * FIXED: Remove chunk_split() As Browser Will Try To Wrap Word Boundaries Based On Page Width by Kambiz R. Khojasteh
132
- * FIXED: Remove [print_link] ShortCode In Print Pages
133
-
134
- = 2.31 =
135
- * NEW: Works For WordPress 2.6
136
- * NEW: Added donotprint ShortCode. See Usage Tab
137
- * NEW: WP-Print Will Load print-posts.php And print-comments.php Templates From Your Theme Directory First If The Exist
138
- * FIXED: Replace &lt;center&gt; With &lt;div style="margin: 0px auto 0px auto;"&gt;
139
-
140
- = 2.30 =
141
- * NEW: Works For WordPress 2.5 Only
142
- * NEW: WP-Print Will Load 'print-css.css' Inside Your Theme Directory If It Exists. If Not, It Will Just Load The Default 'print-css.css' By WP-Print
143
- * NEW: Uses Shortcode API
144
- * NEW: Added "Right To Left" And "Left To Right Text" Direction Option
145
- * NEW: Option To Remove Videos From Post
146
- * NEW: Duplicate Links Now Uses A Single Number And Printed Only Once By Constantinos Neophytou
147
- * NEW: &lt;IMG&gt; And &lt;A&gt; Tag Now Matches Single Quotes By Constantinos Neophytou
148
- * NEW: Uses /wp-print/ Folder Instead Of /print/
149
- * NEW: Uses wp-print.php Instead Of print.php
150
- * NEW: Changed wp-print.php To print-posts.php
151
- * NEW: Changed wp-print-comments.php To print-comments.php
152
- * NEW: Changed wp-print-css.css To print-css.css
153
- * FIXED: Comment Type Not Translated
154
-
155
- = 2.20 =
156
- * NEW: Works For WordPress 2.3 Only
157
- * NEW: Ability To Embed [print_link] Into Excerpt
158
- * NEW: wp-print-css.css Now Controls The CSS Styles For The Printer Friendly Page
159
- * NEW: Disclaimer/Copyright Text Option By Duane Craig
160
- * NEW: Anchor Link To Comments By Reinventia
161
- * NEW: Collapsable Comments By Reinventia
162
- * NEW: Ability To Uninstall WP-Print
163
- * FIXED: If There Is No Trailing Slash In Your Permalink, WP-Print Will Add It For You
164
-
165
- = 2.11 =
166
- * NEW: Putting [print_link] In Your Post/Page Content Will Display A Link To The Printable Post/Page
167
- * FIXED: Worked With Polyglot Plugin, Fixed By zeridon
168
- * FIXED: Wrong URL If Front Page Is A Static Page
169
-
170
- = 2.10 =
171
- * NEW: Added Fam Fam Fam's Printer Icon
172
- * NEW: Works For WordPress 2.1 Only
173
- * NEW: Localize WP-Print
174
- * NEW: Ability To Configure The Text For Print Links Via 'WP-Admin -> Options -> Print'
175
- * NEW: The Text For Print Links Can No Longer Be Pass To The Function print_link() or print_link_image()
176
- * FIXED: MUltiple URL Type Fixed By Virgil
177
- * FIXED: 'Click Here To Print' Will Be Hidden When Printing By Joe (Ttech)
178
-
179
- = 2.06 =
180
- * NEW: Used Default Date/Time Format Under WordPress Options
181
- * NEW: Added robots: noindex To Printer Friendly Pages
182
- * NEW: Added rel="nofollow" To All Links Generated By WP-Print
183
- * FIXED: &lt;abbr&gt; Tag Mixed Up With &lt;a&gt;
184
- * FIXED: PHP5 Compatibility Issue
185
- * FIXED: Long URL Will Not Break Into More Than 1 Line
186
-
187
- = 2.05 =
188
- * NEW: Added Print Options In WP Administration Panel Under 'Options -> Print'
189
- * NEW: Print Administration Panel And The Code That WP-Print Generated Is XHTML 1.0 Transitional
190
- * FIXED: Comment's Content Formatting
191
-
192
- = 2.04 =
193
- * NEW: Able To Print Comments Together With Post Using $can_print_comments In wp-print.php
194
- * NEW: Moved wp-print.php To Plugin Folder
195
- * FIXED: Removed Link From Post Comment Count And Post Category
196
-
197
- = 2.03 =
198
- * NEW: Added Print Image With print_link_image()
199
- * NEW: Automatically Break To Next Line If Link Contains More Than 100 Chars
200
- * FIXED: Comment Numbers Showing In Password Protected Post
201
-
202
- = 2.02 =
203
- * FIXED: Able To View Password Protected Blog
204
-
205
- = 2.01 =
206
- * NEW: Compatible With WordPress 2.0
207
- * NEW: Automatically Detect Whether You Are Using Nice Permalink
208
- * NEW: Automated Permalink
209
- * NEW: Now You Only Need To Insert 1 Line Into Your index.php Of Your Theme
210
- * NEW: GPL License Added
211
- * FIXED: Links Not Displaying Properly When Printing More Than 1 Post On A Single Page
212
-
213
- = 2.00a =
214
- * NEW: Permlink For The Page Feature
215
-
216
- = 2.00 =
217
- * NEW: Print Out A Summary Of URLS In The Post At The Bottom Of The Page
1
+ === WP-Print ===
2
+ Contributors: GamerZ
3
+ Donate link: http://lesterchan.net/site/donation/
4
+ Tags: print, printer, wp-print
5
+ Requires at least: 2.8
6
+ Tested up to: 3.9
7
+ Stable tag: 2.53
8
+
9
+ Displays a printable version of your WordPress blog's post/page.
10
+
11
+ == Description ==
12
+
13
+ Displays a printable version of your WordPress blog's post/page.
14
+
15
+ = Development =
16
+ * [https://github.com/lesterchan/wp-print](https://github.com/lesterchan/wp-print "https://github.com/lesterchan/wp-print")
17
+
18
+ = Translations =
19
+ * [http://dev.wp-plugins.org/browser/wp-print/i18n/](http://dev.wp-plugins.org/browser/wp-print/i18n/ "http://dev.wp-plugins.org/browser/wp-print/i18n/")
20
+
21
+ = Credits =
22
+ * Icons courtesy of [FamFamFam](http://www.famfamfam.com/)
23
+ * __ngetext() by [Anna Ozeritskaya](http://hweia.ru/)
24
+ * Right-to-left language support by [Kambiz R. Khojasteh](http://persian-programming.com/)
25
+ * Do Not Print idea by [Robert "Nilpo" Dunham](http://www.nilpo.com/)
26
+
27
+ = Donations =
28
+ I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks as my school allowance, I will really appreciate it. If not feel free to use it without any obligations. Thank You. My Paypal account is lesterchan@gmail.com.
29
+
30
+ == Installation ==
31
+
32
+ You can either install it automatically from the WordPress admin, or do it manually:
33
+
34
+ 1. Upload the whole `wp-print` directory into your plugins folder(`/wp-content/plugins/`)
35
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
36
+
37
+ Once installed take the following steps to set it up:
38
+
39
+ 1. WP-Print settings page is located in WP-Admin -> Settings -> Print
40
+ 1. You Need To Re-Generate The Permalink (WP-Admin -> Settings -> Permalinks -> Save Changes)
41
+ 1. Refer To Usage For Further Instructions
42
+
43
+ = Usage =
44
+
45
+ 1. Open `wp-content/themes/<YOUR THEME NAME>/index.php`
46
+ You may place it in single.php, post.php, page.php, etc also.
47
+ 1. Find: `<?php while (have_posts()) : the_post(); ?>`
48
+ 1. Add Anywhere Below It: `<?php if(function_exists('wp_print')) { print_link(); } ?>`
49
+
50
+ * The first value is the text for printing post.
51
+ * The second value is the text for printing page.
52
+ * Default: print_link('', '')
53
+ * Alternatively, you can set the text in 'WP-Admin -> Settings -> Print'.
54
+ * If you DO NOT want the print link to appear in every post/page, DO NOT use the code above. Just type in <strong>[print_link]</strong> into the selected post/page content and it will embed the print link into that post/page only.
55
+
56
+
57
+ == Screenshots ==
58
+
59
+ 1. Admin Print Options
60
+ 2. Print Post Link
61
+ 3. Print Page link
62
+ 4. Print Page
63
+
64
+ == Frequently Asked Questions ==
65
+
66
+ = How do I add this to my theme? =
67
+
68
+ 1. Open `wp-content/themes/<YOUR THEME NAME>/index.php`
69
+ You may place it in single.php, post.php, page.php, etc also.
70
+ 1. Find: `<?php while (have_posts()) : the_post(); ?>`
71
+ 1. Add Anywhere Below It: `<?php if(function_exists('wp_print')) { print_link(); } ?>`
72
+
73
+ Simply add this code <strong>inside the loop ### where you want the print link to display:
74
+ <code>
75
+ if(function_exists('wp_print')) {
76
+ print_link();
77
+ }
78
+ </code>
79
+
80
+ = If you do not want to print a portion of your post's content =
81
+ <code>
82
+ [donotprint]Text within this tag will not be displayed when printing[/donotprint]
83
+ </code>
84
+ * The text within [donotprint][/donotprint] will not be displayed when you are viewing a printer friendly version of a post or page.
85
+ * However, it will still be displayed as normal on a normal post or page view.
86
+ * Do note that if you are using WP-Email, any text within [donotprint][/donotprint] will not be emailed as well.
87
+
88
+ = Custom Template =
89
+ * WP-Print will load 'print-css.css', '<strong>print-posts.php' and 'print-comments.php' from your theme's directory if it exists.
90
+ * If it doesn't exists, it will just load the respective default file that comes with WP-Print.
91
+ * This will allow you to upgrade WP-Print without worrying about overwriting your printing styles or templates that you have created.
92
+
93
+
94
+ == Changelog ==
95
+
96
+ = 2.53 =
97
+ * FIXED: Use get_stylesheet_directory() instead of TEMPLATEPATH
98
+
99
+ = 2.52 =
100
+ * FIXED: Added nonce to Options. Credits to Charlie Eriksen via Secunia SVCRP.
101
+
102
+ = 2.51 =
103
+ * NEW: Support for links that start with "//"
104
+ * FIXED: Unable to load WP-Print on Password Protected posts
105
+
106
+ = 2.50 =
107
+ * NEW: Uses jQuery Framework
108
+ * NEW: [donotprint][/donotprint] ShortCode Will Not Be Displayed As Well When Using WP-Email (Refer To Usage Tab)
109
+ * NEW: Use _n() Instead Of __ngettext() And _n_noop() Instead Of __ngettext_noop()
110
+ * FIXED: Uses $_SERVER['PHP_SELF'] With plugin_basename(__FILE__) Instead Of Just $_SERVER['REQUEST_URI']
111
+ * FIXED: Nested ShortCode Issues
112
+
113
+ = 2.40 =
114
+ * NEW: Works For WordPress 2.7 Only
115
+ * NEW: Better Translation Using __ngetext() by Anna Ozeritskaya
116
+ * NEW: Right To Left Language Support by Kambiz R. Khojasteh
117
+ * NEW: Call print_textdomain() In print_init() by Kambiz R. Khojasteh
118
+ * NEW: Replace "text_direction" Option With $text_direction And language_attributes() by Kambiz R. Khojasteh
119
+ * NEW: Added "print-css-rtl.css" by Kambiz R. Khojasteh
120
+ * NEW: Page Title Is Now "Post Title -> Print" Instead Of "Print -> Post Title" by Kambiz R. Khojasteh
121
+ * NEW: Modified "print-css.css" To Hide "comments_controls" Element For Print by Kambiz R. Khojasteh
122
+ * FIXED: Footnotes Referencing Is Now "link1 <sup>[1]</sup>" Instead Of "[1] link1" by Kambiz R. Khojasteh
123
+ * FIXED: Remove chunk_split() As Browser Will Try To Wrap Word Boundaries Based On Page Width by Kambiz R. Khojasteh
124
+ * FIXED: Remove [print_link] ShortCode In Print Pages
125
+
126
+ = 2.31 =
127
+ * NEW: Works For WordPress 2.6
128
+ * NEW: Added donotprint ShortCode. See Usage Tab
129
+ * NEW: WP-Print Will Load print-posts.php And print-comments.php Templates From Your Theme Directory First If The Exist
130
+ * FIXED: Replace &lt;center&gt; With &lt;div style="margin: 0px auto 0px auto;"&gt;
131
+
132
+ = 2.30 =
133
+ * NEW: Works For WordPress 2.5 Only
134
+ * NEW: WP-Print Will Load 'print-css.css' Inside Your Theme Directory If It Exists. If Not, It Will Just Load The Default 'print-css.css' By WP-Print
135
+ * NEW: Uses Shortcode API
136
+ * NEW: Added "Right To Left" And "Left To Right Text" Direction Option
137
+ * NEW: Option To Remove Videos From Post
138
+ * NEW: Duplicate Links Now Uses A Single Number And Printed Only Once By Constantinos Neophytou
139
+ * NEW: &lt;IMG&gt; And &lt;A&gt; Tag Now Matches Single Quotes By Constantinos Neophytou
140
+ * NEW: Uses /wp-print/ Folder Instead Of /print/
141
+ * NEW: Uses wp-print.php Instead Of print.php
142
+ * NEW: Changed wp-print.php To print-posts.php
143
+ * NEW: Changed wp-print-comments.php To print-comments.php
144
+ * NEW: Changed wp-print-css.css To print-css.css
145
+ * FIXED: Comment Type Not Translated
146
+
147
+ = 2.20 =
148
+ * NEW: Works For WordPress 2.3 Only
149
+ * NEW: Ability To Embed [print_link] Into Excerpt
150
+ * NEW: wp-print-css.css Now Controls The CSS Styles For The Printer Friendly Page
151
+ * NEW: Disclaimer/Copyright Text Option By Duane Craig
152
+ * NEW: Anchor Link To Comments By Reinventia
153
+ * NEW: Collapsable Comments By Reinventia
154
+ * NEW: Ability To Uninstall WP-Print
155
+ * FIXED: If There Is No Trailing Slash In Your Permalink, WP-Print Will Add It For You
156
+
157
+ = 2.11 =
158
+ * NEW: Putting [print_link] In Your Post/Page Content Will Display A Link To The Printable Post/Page
159
+ * FIXED: Worked With Polyglot Plugin, Fixed By zeridon
160
+ * FIXED: Wrong URL If Front Page Is A Static Page
161
+
162
+ = 2.10 =
163
+ * NEW: Added Fam Fam Fam's Printer Icon
164
+ * NEW: Works For WordPress 2.1 Only
165
+ * NEW: Localize WP-Print
166
+ * NEW: Ability To Configure The Text For Print Links Via 'WP-Admin -> Options -> Print'
167
+ * NEW: The Text For Print Links Can No Longer Be Pass To The Function print_link() or print_link_image()
168
+ * FIXED: MUltiple URL Type Fixed By Virgil
169
+ * FIXED: 'Click Here To Print' Will Be Hidden When Printing By Joe (Ttech)
170
+
171
+ = 2.06 =
172
+ * NEW: Used Default Date/Time Format Under WordPress Options
173
+ * NEW: Added robots: noindex To Printer Friendly Pages
174
+ * NEW: Added rel="nofollow" To All Links Generated By WP-Print
175
+ * FIXED: &lt;abbr&gt; Tag Mixed Up With &lt;a&gt;
176
+ * FIXED: PHP5 Compatibility Issue
177
+ * FIXED: Long URL Will Not Break Into More Than 1 Line
178
+
179
+ = 2.05 =
180
+ * NEW: Added Print Options In WP Administration Panel Under 'Options -> Print'
181
+ * NEW: Print Administration Panel And The Code That WP-Print Generated Is XHTML 1.0 Transitional
182
+ * FIXED: Comment's Content Formatting
183
+
184
+ = 2.04 =
185
+ * NEW: Able To Print Comments Together With Post Using $can_print_comments In wp-print.php
186
+ * NEW: Moved wp-print.php To Plugin Folder
187
+ * FIXED: Removed Link From Post Comment Count And Post Category
188
+
189
+ = 2.03 =
190
+ * NEW: Added Print Image With print_link_image()
191
+ * NEW: Automatically Break To Next Line If Link Contains More Than 100 Chars
192
+ * FIXED: Comment Numbers Showing In Password Protected Post
193
+
194
+ = 2.02 =
195
+ * FIXED: Able To View Password Protected Blog
196
+
197
+ = 2.01 =
198
+ * NEW: Compatible With WordPress 2.0
199
+ * NEW: Automatically Detect Whether You Are Using Nice Permalink
200
+ * NEW: Automated Permalink
201
+ * NEW: Now You Only Need To Insert 1 Line Into Your index.php Of Your Theme
202
+ * NEW: GPL License Added
203
+ * FIXED: Links Not Displaying Properly When Printing More Than 1 Post On A Single Page
204
+
205
+ = 2.00a =
206
+ * NEW: Permlink For The Page Feature
207
+
208
+ = 2.00 =
209
+ * NEW: Print Out A Summary Of URLS In The Post At The Bottom Of The Page
 
 
 
 
 
 
 
 
wp-print.php CHANGED
@@ -1,456 +1,455 @@
1
- <?php
2
- /*
3
- Plugin Name: WP-Print
4
- Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
- Description: Displays a printable version of your WordPress blog's post/page.
6
- Version: 2.52
7
- Author: Lester 'GaMerZ' Chan
8
- Author URI: http://lesterchan.net
9
- Text Domain: wp-print
10
- */
11
-
12
-
13
- /*
14
- Copyright 2013 Lester Chan (email : lesterchan@gmail.com)
15
-
16
- This program is free software; you can redistribute it and/or modify
17
- it under the terms of the GNU General Public License as published by
18
- the Free Software Foundation; either version 2 of the License, or
19
- (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
- */
30
-
31
-
32
- ### Create Text Domain For Translations
33
- add_action('init', 'print_textdomain');
34
- function print_textdomain() {
35
- load_plugin_textdomain('wp-print', false, 'wp-print');
36
- }
37
-
38
-
39
- ### Function: Print Option Menu
40
- add_action('admin_menu', 'print_menu');
41
- function print_menu() {
42
- if (function_exists('add_options_page')) {
43
- add_options_page(__('Print', 'wp-print'), __('Print', 'wp-print'), 'manage_options', 'wp-print/print-options.php') ;
44
- }
45
- }
46
-
47
-
48
- ### Function: Print htaccess ReWrite Rules
49
- add_filter('generate_rewrite_rules', 'print_rewrite');
50
- function print_rewrite($wp_rewrite) {
51
- // Print Rules For Posts
52
- $r_rule = '';
53
- $r_link = '';
54
- $print_link = get_permalink();
55
- if(substr($print_link, -1, 1) != '/' && substr($wp_rewrite->permalink_structure, -1, 1) != '/') {
56
- $print_link_text = '/print';
57
- } else {
58
- $print_link_text = 'print';
59
- }
60
- $rewrite_rules = $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.$print_link_text, EP_PERMALINK);
61
- $rewrite_rules = array_slice($rewrite_rules, 5, 1);
62
- $r_rule = array_keys($rewrite_rules);
63
- $r_rule = array_shift($r_rule);
64
- $r_rule = str_replace('/trackback', '',$r_rule);
65
- $r_link = array_values($rewrite_rules);
66
- $r_link = array_shift($r_link);
67
- $r_link = str_replace('tb=1', 'print=1', $r_link);
68
- $wp_rewrite->rules = array_merge(array($r_rule => $r_link), $wp_rewrite->rules);
69
- // Print Rules For Pages
70
- $page_uris = $wp_rewrite->page_uri_index();
71
- $uris = $page_uris[0];
72
- if(is_array($uris)) {
73
- $print_page_rules = array();
74
- foreach ($uris as $uri => $pagename) {
75
- $wp_rewrite->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
76
- $rewrite_rules = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_page_permastruct().'/printpage', EP_PAGES);
77
- $rewrite_rules = array_slice($rewrite_rules, 5, 1);
78
- $r_rule = array_keys($rewrite_rules);
79
- $r_rule = array_shift($r_rule);
80
- $r_rule = str_replace('/trackback', '',$r_rule);
81
- $r_link = array_values($rewrite_rules);
82
- $r_link = array_shift($r_link);
83
- $r_link = str_replace('tb=1', 'print=1', $r_link);
84
- $print_page_rules = array_merge($print_page_rules, array($r_rule => $r_link));
85
- }
86
- $wp_rewrite->rules = array_merge($print_page_rules, $wp_rewrite->rules);
87
- }
88
- }
89
-
90
-
91
- ### Function: Print Public Variables
92
- add_filter('query_vars', 'print_variables');
93
- function print_variables($public_query_vars) {
94
- $public_query_vars[] = 'print';
95
- $public_query_vars[] = 'printpage';
96
- return $public_query_vars;
97
- }
98
-
99
-
100
- ### Function: Display Print Link
101
- function print_link($print_post_text = '', $print_page_text = '', $echo = true) {
102
- global $id;
103
- if (function_exists('polyglot_get_lang')){
104
- global $polyglot_settings;
105
- $polyglot_append = $polyglot_settings['uri_helpers']['lang_view'].'/'.polyglot_get_lang().'/';
106
- }
107
- $output = '';
108
- $using_permalink = get_option('permalink_structure');
109
- $print_options = get_option('print_options');
110
- $print_style = intval($print_options['print_style']);
111
- if(empty($print_post_text)) {
112
- $print_text = stripslashes($print_options['post_text']);
113
- } else {
114
- $print_text = $print_post_text;
115
- }
116
- $print_icon = plugins_url('wp-print/images/'.$print_options['print_icon']);
117
- $print_link = get_permalink();
118
- $print_html = stripslashes($print_options['print_html']);
119
- // Fix For Static Page
120
- if(get_option('show_on_front') == 'page' && is_page()) {
121
- if(intval(get_option('page_on_front')) > 0) {
122
- $print_link = _get_page_link();
123
- }
124
- }
125
- if(!empty($using_permalink)) {
126
- if(substr($print_link, -1, 1) != '/') {
127
- $print_link = $print_link.'/';
128
- }
129
- if(is_page()) {
130
- if(empty($print_page_text)) {
131
- $print_text = stripslashes($print_options['page_text']);
132
- } else {
133
- $print_text = $print_page_text;
134
- }
135
- $print_link = $print_link.'printpage/'.$polyglot_append;
136
- } else {
137
- $print_link = $print_link.'print/'.$polyglot_append;
138
- }
139
- } else {
140
- if(is_page()) {
141
- if(empty($print_page_text)) {
142
- $print_text = stripslashes($print_options['page_text']);
143
- } else {
144
- $print_text = $print_page_text;
145
- }
146
- }
147
- $print_link = $print_link.'&amp;print=1';
148
- }
149
- unset($print_options);
150
- switch($print_style) {
151
- // Icon + Text Link
152
- case 1:
153
- $output = '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>&nbsp;<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
154
- break;
155
- // Icon Only
156
- case 2:
157
- $output = '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>';
158
- break;
159
- // Text Link Only
160
- case 3:
161
- $output = '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
162
- break;
163
- case 4:
164
- $print_html = str_replace("%PRINT_URL%", $print_link, $print_html);
165
- $print_html = str_replace("%PRINT_TEXT%", $print_text, $print_html);
166
- $print_html = str_replace("%PRINT_ICON_URL%", $print_icon, $print_html);
167
- $output = $print_html;
168
- break;
169
- }
170
- if($echo) {
171
- echo $output."\n";
172
- } else {
173
- return $output;
174
- }
175
- }
176
-
177
-
178
- ### Function: Short Code For Inserting Prink Links Into Posts/Pages
179
- add_shortcode('print_link', 'print_link_shortcode');
180
- function print_link_shortcode($atts) {
181
- if(!is_feed()) {
182
- return print_link('', '', false);
183
- } else {
184
- return __('Note: There is a print link embedded within this post, please visit this post to print it.', 'wp-print');
185
- }
186
- }
187
- function print_link_shortcode2($atts) {
188
- return;
189
- }
190
-
191
-
192
- ### Function: Short Code For DO NOT PRINT Content
193
- add_shortcode('donotprint', 'print_donotprint_shortcode');
194
- function print_donotprint_shortcode($atts, $content = null) {
195
- return do_shortcode($content);
196
- }
197
- function print_donotprint_shortcode2($atts, $content = null) {
198
- return;
199
- }
200
-
201
-
202
- ### Function: Print Content
203
- function print_content($display = true) {
204
- global $links_text, $link_number, $max_link_number, $matched_links, $pages, $multipage, $numpages, $post;
205
- if (!isset($matched_links)) {
206
- $matched_links = array();
207
- }
208
- if(post_password_required()) {
209
- $content = get_the_password_form();
210
- } else {
211
- if($multipage) {
212
- for($page = 0; $page < $numpages; $page++) {
213
- $content .= $pages[$page];
214
- }
215
- } else {
216
- $content = $pages[0];
217
- }
218
- if(function_exists('email_rewrite')) {
219
- remove_shortcode('donotemail');
220
- add_shortcode('donotemail', 'email_donotemail_shortcode2');
221
- }
222
- remove_shortcode('donotprint');
223
- add_shortcode('donotprint', 'print_donotprint_shortcode2');
224
- remove_shortcode('print_link');
225
- add_shortcode('print_link', 'print_link_shortcode2');
226
- $content = apply_filters('the_content', $content);
227
- $content = str_replace(']]>', ']]&gt;', $content);
228
- if(!print_can('images')) {
229
- $content = remove_image($content);
230
- }
231
- if(!print_can('videos')) {
232
- $content = remove_video($content);
233
- }
234
- if(print_can('links')) {
235
- preg_match_all('/<a(.+?)href=[\"\'](.+?)[\"\'](.*?)>(.+?)<\/a>/', $content, $matches);
236
- for ($i=0; $i < count($matches[0]); $i++) {
237
- $link_match = $matches[0][$i];
238
- $link_url = $matches[2][$i];
239
- if(substr($link_url, 0, 2) == '//') {
240
- $link_url = (is_ssl() ? 'https:' : 'http:') . $link_url;
241
- } elseif(stristr($link_url, 'https://')) {
242
- $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url : $link_url;
243
- } else if(stristr($link_url, 'mailto:')) {
244
- $link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url : $link_url;
245
- } else if($link_url[0] == '#') {
246
- $link_url = $link_url;
247
- } else {
248
- $link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url : $link_url;
249
- }
250
- $link_text = $matches[4][$i];
251
- $new_link = true;
252
- $link_url_hash = md5($link_url);
253
- if (!isset($matched_links[$link_url_hash])) {
254
- $link_number = ++$max_link_number;
255
- $matched_links[$link_url_hash] = $link_number;
256
- } else {
257
- $new_link = false;
258
- $link_number = $matched_links[$link_url_hash];
259
- }
260
- $content = str_replace_one($link_match, "<a href=\"$link_url\" rel=\"external\">".$link_text.'</a> <sup>['.number_format_i18n($link_number).']</sup>', $content);
261
- if ($new_link) {
262
- if(preg_match('/<img(.+?)src=[\"\'](.+?)[\"\'](.*?)>/',$link_text)) {
263
- $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.__('Image', 'wp-print').': <b><span dir="ltr">'.$link_url.'</span></b></p>';
264
- } else {
265
- $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.$link_text.': <b><span dir="ltr">'.$link_url.'</span></b></p>';
266
- }
267
- }
268
- }
269
- }
270
- }
271
- if($display) {
272
- echo $content;
273
- } else {
274
- return $content;
275
- }
276
- }
277
-
278
-
279
- ### Function: Print Categories
280
- function print_categories($before = '', $after = '') {
281
- $temp_cat = strip_tags(get_the_category_list(',', $parents));
282
- $temp_cat = explode(', ', $temp_cat);
283
- $temp_cat = implode($after.__(',', 'wp-print').' '.$before, $temp_cat);
284
- echo $before.$temp_cat.$after;
285
- }
286
-
287
-
288
- ### Function: Print Comments Content
289
- function print_comments_content($display = true) {
290
- global $links_text, $link_number, $max_link_number, $matched_links;
291
- if (!isset($matched_links)) {
292
- $matched_links = array();
293
- }
294
- $content = get_comment_text();
295
- $content = apply_filters('comment_text', $content);
296
- if(!print_can('images')) {
297
- $content = remove_image($content);
298
- }
299
- if(!print_can('videos')) {
300
- $content = remove_video($content);
301
- }
302
- if(print_can('links')) {
303
- preg_match_all('/<a(.+?)href=[\"\'](.+?)[\"\'](.*?)>(.+?)<\/a>/', $content, $matches);
304
- for ($i=0; $i < count($matches[0]); $i++) {
305
- $link_match = $matches[0][$i];
306
- $link_url = $matches[2][$i];
307
- if(stristr($link_url, 'https://')) {
308
- $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url : $link_url;
309
- } else if(stristr($link_url, 'mailto:')) {
310
- $link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url : $link_url;
311
- } else if($link_url[0] == '#') {
312
- $link_url = $link_url;
313
- } else {
314
- $link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url : $link_url;
315
- }
316
- $new_link = true;
317
- $link_url_hash = md5($link_url);
318
- if (!isset($matched_links[$link_url_hash])) {
319
- $link_number = ++$max_link_number;
320
- $matched_links[$link_url_hash] = $link_number;
321
- } else {
322
- $new_link = false;
323
- $link_number = $matched_links[$link_url_hash];
324
- }
325
- $content = str_replace_one($link_match, "<a href=\"$link_url\" rel=\"external\">".$link_text.'</a> <sup>['.number_format_i18n($link_number).']</sup>', $content);
326
- if ($new_link) {
327
- if(preg_match('/<img(.+?)src=[\"\'](.+?)[\"\'](.*?)>/',$link_text)) {
328
- $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.__('Image', 'wp-print').': <b><span dir="ltr">'.$link_url.'</span></b></p>';
329
- } else {
330
- $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.$link_text.': <b><span dir="ltr">'.$link_url.'</span></b></p>';
331
- }
332
- }
333
- }
334
- }
335
- if($display) {
336
- echo $content;
337
- } else {
338
- return $content;
339
- }
340
- }
341
-
342
-
343
- ### Function: Print Comments
344
- function print_comments_number() {
345
- global $post;
346
- $comment_text = '';
347
- $comment_status = $post->comment_status;
348
- if($comment_status == 'open') {
349
- $num_comments = get_comments_number();
350
- if($num_comments == 0) {
351
- $comment_text = __('No Comments', 'wp-print');
352
- } else {
353
- $comment_text = sprintf(_n('%s Comment', '%s Comments', $num_comments, 'wp-print'), number_format_i18n($num_comments));
354
- }
355
- } else {
356
- $comment_text = __('Comments Disabled', 'wp-print');
357
- }
358
- if(post_password_required()) {
359
- _e('Comments Hidden', 'wp-print');
360
- } else {
361
- echo $comment_text;
362
- }
363
- }
364
-
365
-
366
- ### Function: Print Links
367
- function print_links($text_links = '') {
368
- global $links_text;
369
- if(empty($text_links)) {
370
- $text_links = __('URLs in this post:', 'wp-print');
371
- }
372
- if(!empty($links_text)) {
373
- echo $text_links.$links_text;
374
- }
375
- }
376
-
377
-
378
- ### Function: Load WP-Print
379
- add_action('template_redirect', 'wp_print', 5);
380
- function wp_print() {
381
- if(intval(get_query_var('print')) == 1 || intval(get_query_var('printpage')) == 1) {
382
- include(WP_PLUGIN_DIR.'/wp-print/print.php');
383
- exit();
384
- }
385
- }
386
-
387
-
388
- ### Function: Add Print Comments Template
389
- function print_template_comments($file = '') {
390
- if(file_exists(TEMPLATEPATH.'/print-comments.php')) {
391
- $file = TEMPLATEPATH.'/print-comments.php';
392
- } else {
393
- $file = WP_PLUGIN_DIR.'/wp-print/print-comments.php';
394
- }
395
- return $file;
396
- }
397
-
398
-
399
- ### Function: Print Page Title
400
- function print_pagetitle($page_title) {
401
- $page_title .= ' &raquo; '.__('Print', 'wp-print');
402
- return $page_title;
403
- }
404
-
405
-
406
- ### Function: Can Print?
407
- function print_can($type) {
408
- $print_options = get_option('print_options');
409
- return intval($print_options[$type]);
410
- }
411
-
412
-
413
- ### Function: Remove Image From Text
414
- function remove_image($content) {
415
- $content= preg_replace('/<img(.+?)src=[\"\'](.+?)[\"\'](.*?)>/', '',$content);
416
- return $content;
417
- }
418
-
419
-
420
- ### Function: Remove Video From Text
421
- function remove_video($content) {
422
- $content= preg_replace('/<object[^>]*?>.*?<\/object>/', '',$content);
423
- $content= preg_replace('/<embed[^>]*?>.*?<\/embed>/', '',$content);
424
- return $content;
425
- }
426
-
427
-
428
- ### Function: Replace One Time Only
429
- function str_replace_one($search, $replace, $content){
430
- if ($pos = strpos($content, $search)) {
431
- return substr($content, 0, $pos).$replace.substr($content, $pos+strlen($search));
432
- } else {
433
- return $content;
434
- }
435
- }
436
-
437
-
438
- ### Function: Print Options
439
- add_action('activate_wp-print/wp-print.php', 'print_init');
440
- function print_init() {
441
- print_textdomain();
442
- // Add Options
443
- $print_options = array();
444
- $print_options['post_text'] = __('Print This Post', 'wp-print');
445
- $print_options['page_text'] = __('Print This Page', 'wp-print');
446
- $print_options['print_icon'] = 'print.gif';
447
- $print_options['print_style'] = 1;
448
- $print_options['print_html'] = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
449
- $print_options['comments'] = 0;
450
- $print_options['links'] = 1;
451
- $print_options['images'] = 1;
452
- $print_options['videos'] = 0;
453
- $print_options['disclaimer'] = sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'));
454
- add_option('print_options', $print_options, 'Print Options');
455
- }
456
- ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: WP-Print
4
+ Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
+ Description: Displays a printable version of your WordPress blog's post/page.
6
+ Version: 2.53
7
+ Author: Lester 'GaMerZ' Chan
8
+ Author URI: http://lesterchan.net
9
+ Text Domain: wp-print
10
+ */
11
+
12
+
13
+ /*
14
+ Copyright 2013 Lester Chan (email : lesterchan@gmail.com)
15
+
16
+ This program is free software; you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation; either version 2 of the License, or
19
+ (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program; if not, write to the Free Software
28
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
+ */
30
+
31
+
32
+ ### Create Text Domain For Translations
33
+ add_action('init', 'print_textdomain');
34
+ function print_textdomain() {
35
+ load_plugin_textdomain('wp-print', false, 'wp-print');
36
+ }
37
+
38
+
39
+ ### Function: Print Option Menu
40
+ add_action('admin_menu', 'print_menu');
41
+ function print_menu() {
42
+ if (function_exists('add_options_page')) {
43
+ add_options_page(__('Print', 'wp-print'), __('Print', 'wp-print'), 'manage_options', 'wp-print/print-options.php') ;
44
+ }
45
+ }
46
+
47
+
48
+ ### Function: Print htaccess ReWrite Rules
49
+ add_filter('generate_rewrite_rules', 'print_rewrite');
50
+ function print_rewrite($wp_rewrite) {
51
+ // Print Rules For Posts
52
+ $r_rule = '';
53
+ $r_link = '';
54
+ $print_link = get_permalink();
55
+ if(substr($print_link, -1, 1) != '/' && substr($wp_rewrite->permalink_structure, -1, 1) != '/') {
56
+ $print_link_text = '/print';
57
+ } else {
58
+ $print_link_text = 'print';
59
+ }
60
+ $rewrite_rules = $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.$print_link_text, EP_PERMALINK);
61
+ $rewrite_rules = array_slice($rewrite_rules, 5, 1);
62
+ $r_rule = array_keys($rewrite_rules);
63
+ $r_rule = array_shift($r_rule);
64
+ $r_rule = str_replace('/trackback', '',$r_rule);
65
+ $r_link = array_values($rewrite_rules);
66
+ $r_link = array_shift($r_link);
67
+ $r_link = str_replace('tb=1', 'print=1', $r_link);
68
+ $wp_rewrite->rules = array_merge(array($r_rule => $r_link), $wp_rewrite->rules);
69
+ // Print Rules For Pages
70
+ $page_uris = $wp_rewrite->page_uri_index();
71
+ $uris = $page_uris[0];
72
+ if(is_array($uris)) {
73
+ $print_page_rules = array();
74
+ foreach ($uris as $uri => $pagename) {
75
+ $wp_rewrite->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
76
+ $rewrite_rules = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_page_permastruct().'/printpage', EP_PAGES);
77
+ $rewrite_rules = array_slice($rewrite_rules, 5, 1);
78
+ $r_rule = array_keys($rewrite_rules);
79
+ $r_rule = array_shift($r_rule);
80
+ $r_rule = str_replace('/trackback', '',$r_rule);
81
+ $r_link = array_values($rewrite_rules);
82
+ $r_link = array_shift($r_link);
83
+ $r_link = str_replace('tb=1', 'print=1', $r_link);
84
+ $print_page_rules = array_merge($print_page_rules, array($r_rule => $r_link));
85
+ }
86
+ $wp_rewrite->rules = array_merge($print_page_rules, $wp_rewrite->rules);
87
+ }
88
+ }
89
+
90
+
91
+ ### Function: Print Public Variables
92
+ add_filter('query_vars', 'print_variables');
93
+ function print_variables($public_query_vars) {
94
+ $public_query_vars[] = 'print';
95
+ $public_query_vars[] = 'printpage';
96
+ return $public_query_vars;
97
+ }
98
+
99
+
100
+ ### Function: Display Print Link
101
+ function print_link($print_post_text = '', $print_page_text = '', $echo = true) {
102
+ $polyglot_append = '';
103
+ if (function_exists('polyglot_get_lang')){
104
+ global $polyglot_settings;
105
+ $polyglot_append = $polyglot_settings['uri_helpers']['lang_view'].'/'.polyglot_get_lang().'/';
106
+ }
107
+ $output = '';
108
+ $using_permalink = get_option('permalink_structure');
109
+ $print_options = get_option('print_options');
110
+ $print_style = intval($print_options['print_style']);
111
+ if(empty($print_post_text)) {
112
+ $print_text = stripslashes($print_options['post_text']);
113
+ } else {
114
+ $print_text = $print_post_text;
115
+ }
116
+ $print_icon = plugins_url('wp-print/images/'.$print_options['print_icon']);
117
+ $print_link = get_permalink();
118
+ $print_html = stripslashes($print_options['print_html']);
119
+ // Fix For Static Page
120
+ if(get_option('show_on_front') == 'page' && is_page()) {
121
+ if(intval(get_option('page_on_front')) > 0) {
122
+ $print_link = _get_page_link();
123
+ }
124
+ }
125
+ if(!empty($using_permalink)) {
126
+ if(substr($print_link, -1, 1) != '/') {
127
+ $print_link = $print_link.'/';
128
+ }
129
+ if(is_page()) {
130
+ if(empty($print_page_text)) {
131
+ $print_text = stripslashes($print_options['page_text']);
132
+ } else {
133
+ $print_text = $print_page_text;
134
+ }
135
+ $print_link = $print_link.'printpage/'.$polyglot_append;
136
+ } else {
137
+ $print_link = $print_link.'print/'.$polyglot_append;
138
+ }
139
+ } else {
140
+ if(is_page()) {
141
+ if(empty($print_page_text)) {
142
+ $print_text = stripslashes($print_options['page_text']);
143
+ } else {
144
+ $print_text = $print_page_text;
145
+ }
146
+ }
147
+ $print_link = $print_link.'&amp;print=1';
148
+ }
149
+ unset($print_options);
150
+ switch($print_style) {
151
+ // Icon + Text Link
152
+ case 1:
153
+ $output = '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>&nbsp;<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
154
+ break;
155
+ // Icon Only
156
+ case 2:
157
+ $output = '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>';
158
+ break;
159
+ // Text Link Only
160
+ case 3:
161
+ $output = '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
162
+ break;
163
+ case 4:
164
+ $print_html = str_replace("%PRINT_URL%", $print_link, $print_html);
165
+ $print_html = str_replace("%PRINT_TEXT%", $print_text, $print_html);
166
+ $print_html = str_replace("%PRINT_ICON_URL%", $print_icon, $print_html);
167
+ $output = $print_html;
168
+ break;
169
+ }
170
+ if($echo) {
171
+ echo $output."\n";
172
+ } else {
173
+ return $output;
174
+ }
175
+ }
176
+
177
+
178
+ ### Function: Short Code For Inserting Prink Links Into Posts/Pages
179
+ add_shortcode('print_link', 'print_link_shortcode');
180
+ function print_link_shortcode($atts) {
181
+ if(!is_feed()) {
182
+ return print_link('', '', false);
183
+ } else {
184
+ return __('Note: There is a print link embedded within this post, please visit this post to print it.', 'wp-print');
185
+ }
186
+ }
187
+ function print_link_shortcode2($atts) {
188
+ return;
189
+ }
190
+
191
+
192
+ ### Function: Short Code For DO NOT PRINT Content
193
+ add_shortcode('donotprint', 'print_donotprint_shortcode');
194
+ function print_donotprint_shortcode($atts, $content = null) {
195
+ return do_shortcode($content);
196
+ }
197
+ function print_donotprint_shortcode2($atts, $content = null) {
198
+ return;
199
+ }
200
+
201
+
202
+ ### Function: Print Content
203
+ function print_content($display = true) {
204
+ global $links_text, $link_number, $max_link_number, $matched_links, $pages, $multipage, $numpages, $post;
205
+ if (!isset($matched_links)) {
206
+ $matched_links = array();
207
+ }
208
+ if(post_password_required()) {
209
+ $content = get_the_password_form();
210
+ } else {
211
+ if($multipage) {
212
+ for($page = 0; $page < $numpages; $page++) {
213
+ $content .= $pages[$page];
214
+ }
215
+ } else {
216
+ $content = $pages[0];
217
+ }
218
+ if(function_exists('email_rewrite')) {
219
+ remove_shortcode('donotemail');
220
+ add_shortcode('donotemail', 'email_donotemail_shortcode2');
221
+ }
222
+ remove_shortcode('donotprint');
223
+ add_shortcode('donotprint', 'print_donotprint_shortcode2');
224
+ remove_shortcode('print_link');
225
+ add_shortcode('print_link', 'print_link_shortcode2');
226
+ $content = apply_filters('the_content', $content);
227
+ $content = str_replace(']]>', ']]&gt;', $content);
228
+ if(!print_can('images')) {
229
+ $content = remove_image($content);
230
+ }
231
+ if(!print_can('videos')) {
232
+ $content = remove_video($content);
233
+ }
234
+ if(print_can('links')) {
235
+ preg_match_all('/<a(.+?)href=[\"\'](.+?)[\"\'](.*?)>(.+?)<\/a>/', $content, $matches);
236
+ for ($i=0; $i < count($matches[0]); $i++) {
237
+ $link_match = $matches[0][$i];
238
+ $link_url = $matches[2][$i];
239
+ if(substr($link_url, 0, 2) == '//') {
240
+ $link_url = (is_ssl() ? 'https:' : 'http:') . $link_url;
241
+ } elseif(stristr($link_url, 'https://')) {
242
+ $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url : $link_url;
243
+ } else if(stristr($link_url, 'mailto:')) {
244
+ $link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url : $link_url;
245
+ } else if($link_url[0] == '#') {
246
+ $link_url = $link_url;
247
+ } else {
248
+ $link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url : $link_url;
249
+ }
250
+ $link_text = $matches[4][$i];
251
+ $new_link = true;
252
+ $link_url_hash = md5($link_url);
253
+ if (!isset($matched_links[$link_url_hash])) {
254
+ $link_number = ++$max_link_number;
255
+ $matched_links[$link_url_hash] = $link_number;
256
+ } else {
257
+ $new_link = false;
258
+ $link_number = $matched_links[$link_url_hash];
259
+ }
260
+ $content = str_replace_one($link_match, "<a href=\"$link_url\" rel=\"external\">".$link_text.'</a> <sup>['.number_format_i18n($link_number).']</sup>', $content);
261
+ if ($new_link) {
262
+ if(preg_match('/<img(.+?)src=[\"\'](.+?)[\"\'](.*?)>/',$link_text)) {
263
+ $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.__('Image', 'wp-print').': <b><span dir="ltr">'.$link_url.'</span></b></p>';
264
+ } else {
265
+ $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.$link_text.': <b><span dir="ltr">'.$link_url.'</span></b></p>';
266
+ }
267
+ }
268
+ }
269
+ }
270
+ }
271
+ if($display) {
272
+ echo $content;
273
+ } else {
274
+ return $content;
275
+ }
276
+ }
277
+
278
+
279
+ ### Function: Print Categories
280
+ function print_categories($before = '', $after = '') {
281
+ $temp_cat = strip_tags(get_the_category_list(',', $parents));
282
+ $temp_cat = explode(', ', $temp_cat);
283
+ $temp_cat = implode($after.__(',', 'wp-print').' '.$before, $temp_cat);
284
+ echo $before.$temp_cat.$after;
285
+ }
286
+
287
+
288
+ ### Function: Print Comments Content
289
+ function print_comments_content($display = true) {
290
+ global $links_text, $link_number, $max_link_number, $matched_links;
291
+ if (!isset($matched_links)) {
292
+ $matched_links = array();
293
+ }
294
+ $content = get_comment_text();
295
+ $content = apply_filters('comment_text', $content);
296
+ if(!print_can('images')) {
297
+ $content = remove_image($content);
298
+ }
299
+ if(!print_can('videos')) {
300
+ $content = remove_video($content);
301
+ }
302
+ if(print_can('links')) {
303
+ preg_match_all('/<a(.+?)href=[\"\'](.+?)[\"\'](.*?)>(.+?)<\/a>/', $content, $matches);
304
+ for ($i=0; $i < count($matches[0]); $i++) {
305
+ $link_match = $matches[0][$i];
306
+ $link_url = $matches[2][$i];
307
+ if(stristr($link_url, 'https://')) {
308
+ $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url : $link_url;
309
+ } else if(stristr($link_url, 'mailto:')) {
310
+ $link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url : $link_url;
311
+ } else if($link_url[0] == '#') {
312
+ $link_url = $link_url;
313
+ } else {
314
+ $link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url : $link_url;
315
+ }
316
+ $new_link = true;
317
+ $link_url_hash = md5($link_url);
318
+ if (!isset($matched_links[$link_url_hash])) {
319
+ $link_number = ++$max_link_number;
320
+ $matched_links[$link_url_hash] = $link_number;
321
+ } else {
322
+ $new_link = false;
323
+ $link_number = $matched_links[$link_url_hash];
324
+ }
325
+ $content = str_replace_one($link_match, "<a href=\"$link_url\" rel=\"external\">".$link_text.'</a> <sup>['.number_format_i18n($link_number).']</sup>', $content);
326
+ if ($new_link) {
327
+ if(preg_match('/<img(.+?)src=[\"\'](.+?)[\"\'](.*?)>/',$link_text)) {
328
+ $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.__('Image', 'wp-print').': <b><span dir="ltr">'.$link_url.'</span></b></p>';
329
+ } else {
330
+ $links_text .= '<p style="margin: 2px 0;">['.number_format_i18n($link_number).'] '.$link_text.': <b><span dir="ltr">'.$link_url.'</span></b></p>';
331
+ }
332
+ }
333
+ }
334
+ }
335
+ if($display) {
336
+ echo $content;
337
+ } else {
338
+ return $content;
339
+ }
340
+ }
341
+
342
+
343
+ ### Function: Print Comments
344
+ function print_comments_number() {
345
+ global $post;
346
+ $comment_text = '';
347
+ $comment_status = $post->comment_status;
348
+ if($comment_status == 'open') {
349
+ $num_comments = get_comments_number();
350
+ if($num_comments == 0) {
351
+ $comment_text = __('No Comments', 'wp-print');
352
+ } else {
353
+ $comment_text = sprintf(_n('%s Comment', '%s Comments', $num_comments, 'wp-print'), number_format_i18n($num_comments));
354
+ }
355
+ } else {
356
+ $comment_text = __('Comments Disabled', 'wp-print');
357
+ }
358
+ if(post_password_required()) {
359
+ _e('Comments Hidden', 'wp-print');
360
+ } else {
361
+ echo $comment_text;
362
+ }
363
+ }
364
+
365
+
366
+ ### Function: Print Links
367
+ function print_links($text_links = '') {
368
+ global $links_text;
369
+ if(empty($text_links)) {
370
+ $text_links = __('URLs in this post:', 'wp-print');
371
+ }
372
+ if(!empty($links_text)) {
373
+ echo $text_links.$links_text;
374
+ }
375
+ }
376
+
377
+
378
+ ### Function: Load WP-Print
379
+ add_action('template_redirect', 'wp_print', 5);
380
+ function wp_print() {
381
+ if(intval(get_query_var('print')) == 1 || intval(get_query_var('printpage')) == 1) {
382
+ include(WP_PLUGIN_DIR.'/wp-print/print.php');
383
+ exit();
384
+ }
385
+ }
386
+
387
+
388
+ ### Function: Add Print Comments Template
389
+ function print_template_comments() {
390
+ if(file_exists(get_stylesheet_directory().'/print-comments.php')) {
391
+ $file = get_stylesheet_directory().'/print-comments.php';
392
+ } else {
393
+ $file = WP_PLUGIN_DIR.'/wp-print/print-comments.php';
394
+ }
395
+ return $file;
396
+ }
397
+
398
+
399
+ ### Function: Print Page Title
400
+ function print_pagetitle($page_title) {
401
+ $page_title .= ' &raquo; '.__('Print', 'wp-print');
402
+ return $page_title;
403
+ }
404
+
405
+
406
+ ### Function: Can Print?
407
+ function print_can($type) {
408
+ $print_options = get_option('print_options');
409
+ return intval($print_options[$type]);
410
+ }
411
+
412
+
413
+ ### Function: Remove Image From Text
414
+ function remove_image($content) {
415
+ $content= preg_replace('/<img(.+?)src=[\"\'](.+?)[\"\'](.*?)>/', '',$content);
416
+ return $content;
417
+ }
418
+
419
+
420
+ ### Function: Remove Video From Text
421
+ function remove_video($content) {
422
+ $content= preg_replace('/<object[^>]*?>.*?<\/object>/', '',$content);
423
+ $content= preg_replace('/<embed[^>]*?>.*?<\/embed>/', '',$content);
424
+ return $content;
425
+ }
426
+
427
+
428
+ ### Function: Replace One Time Only
429
+ function str_replace_one($search, $replace, $content){
430
+ if ($pos = strpos($content, $search)) {
431
+ return substr($content, 0, $pos).$replace.substr($content, $pos+strlen($search));
432
+ } else {
433
+ return $content;
434
+ }
435
+ }
436
+
437
+
438
+ ### Function: Print Options
439
+ add_action('activate_wp-print/wp-print.php', 'print_init');
440
+ function print_init() {
441
+ print_textdomain();
442
+ // Add Options
443
+ $print_options = array();
444
+ $print_options['post_text'] = __('Print This Post', 'wp-print');
445
+ $print_options['page_text'] = __('Print This Page', 'wp-print');
446
+ $print_options['print_icon'] = 'print.gif';
447
+ $print_options['print_style'] = 1;
448
+ $print_options['print_html'] = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
449
+ $print_options['comments'] = 0;
450
+ $print_options['links'] = 1;
451
+ $print_options['images'] = 1;
452
+ $print_options['videos'] = 0;
453
+ $print_options['disclaimer'] = sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'));
454
+ add_option('print_options', $print_options, 'Print Options');
455
+ }