Version Description
- FIXED: Use get_stylesheet_directory() instead of TEMPLATEPATH
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-Print |
Version | 2.53 |
Comparing to | |
See all releases |
Code changes from version 2.52 to 2.53
- print-comments.php +33 -35
- print-css-rtl.css +19 -19
- print-css.css +72 -72
- print-options.php +288 -290
- print-posts.php +63 -63
- print.php +34 -35
- readme.txt +209 -217
- 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 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
<?php
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
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 |
-
$
|
20 |
-
$
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
$print_options =
|
29 |
-
$print_options['
|
30 |
-
$print_options['
|
31 |
-
$print_options['
|
32 |
-
$print_options['
|
33 |
-
$print_options['
|
34 |
-
$print_options['
|
35 |
-
$print_options['
|
36 |
-
$print_options['
|
37 |
-
$print_options['
|
38 |
-
$
|
39 |
-
$
|
40 |
-
$
|
41 |
-
$
|
42 |
-
$
|
43 |
-
$
|
44 |
-
$
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
echo '<
|
61 |
-
|
62 |
-
|
63 |
-
$delete_setting
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
echo '</
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
echo '<
|
91 |
-
echo '<
|
92 |
-
echo '
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
</
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
<
|
130 |
-
<
|
131 |
-
|
132 |
-
|
133 |
-
<
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
<
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
<
|
146 |
-
|
147 |
-
|
148 |
-
$
|
149 |
-
$
|
150 |
-
$
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
echo '
|
162 |
-
echo '
|
163 |
-
echo '
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
<
|
175 |
-
|
176 |
-
|
177 |
-
<option value="
|
178 |
-
<option value="
|
179 |
-
<option value="
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
<?php _e('
|
185 |
-
%
|
186 |
-
%
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
<
|
194 |
-
|
195 |
-
|
196 |
-
<
|
197 |
-
|
198 |
-
|
199 |
-
<option value="
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
<
|
206 |
-
|
207 |
-
|
208 |
-
<option value="
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
<
|
215 |
-
|
216 |
-
|
217 |
-
<option value="
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
<
|
224 |
-
|
225 |
-
|
226 |
-
<option value="
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
<
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
</
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
<
|
251 |
-
<
|
252 |
-
<
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
<p
|
282 |
-
|
283 |
-
<input type="
|
284 |
-
|
285 |
-
|
286 |
-
</
|
287 |
-
|
288 |
-
|
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&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 © %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 ' ';
|
161 |
+
echo '<img src="'.$print_icon_url.'/'.$filename.'" alt="'.$filename.'" />'."\n";
|
162 |
+
echo ' ('.$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> </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> </p>
|
281 |
+
<p style="text-align: center;">
|
282 |
+
<input type="checkbox" name="uninstall_print_yes" value="yes" /> <?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 |
-
|
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(
|
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(
|
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(
|
31 |
-
include(
|
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
|
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.
|
7 |
-
Stable tag:
|
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 |
-
=
|
16 |
-
* [
|
17 |
-
|
18 |
-
|
19 |
-
* [
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
* [
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
1.
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
1.
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
1.
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
if
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
*
|
98 |
-
|
99 |
-
=
|
100 |
-
*
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
*
|
109 |
-
|
110 |
-
|
111 |
-
*
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
* NEW:
|
116 |
-
* NEW:
|
117 |
-
* NEW:
|
118 |
-
*
|
119 |
-
*
|
120 |
-
|
121 |
-
|
122 |
-
*
|
123 |
-
*
|
124 |
-
*
|
125 |
-
|
126 |
-
|
127 |
-
* NEW:
|
128 |
-
* NEW:
|
129 |
-
* NEW:
|
130 |
-
* FIXED:
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
* NEW:
|
136 |
-
* NEW: Added
|
137 |
-
* NEW:
|
138 |
-
*
|
139 |
-
|
140 |
-
|
141 |
-
* NEW:
|
142 |
-
* NEW:
|
143 |
-
* NEW:
|
144 |
-
* NEW:
|
145 |
-
*
|
146 |
-
|
147 |
-
|
148 |
-
* NEW:
|
149 |
-
* NEW:
|
150 |
-
* NEW:
|
151 |
-
* NEW:
|
152 |
-
* NEW:
|
153 |
-
*
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
* NEW:
|
159 |
-
*
|
160 |
-
*
|
161 |
-
|
162 |
-
|
163 |
-
*
|
164 |
-
|
165 |
-
|
166 |
-
* NEW:
|
167 |
-
*
|
168 |
-
* FIXED:
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
* NEW:
|
173 |
-
* NEW:
|
174 |
-
* NEW:
|
175 |
-
*
|
176 |
-
* FIXED:
|
177 |
-
* FIXED:
|
178 |
-
|
179 |
-
= 2.
|
180 |
-
* NEW:
|
181 |
-
* NEW:
|
182 |
-
*
|
183 |
-
|
184 |
-
|
185 |
-
*
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
*
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
* FIXED:
|
196 |
-
|
197 |
-
= 2.
|
198 |
-
* NEW:
|
199 |
-
* NEW: Automatically
|
200 |
-
*
|
201 |
-
|
202 |
-
|
203 |
-
* FIXED:
|
204 |
-
|
205 |
-
= 2.
|
206 |
-
* NEW:
|
207 |
-
|
208 |
-
|
209 |
-
* NEW:
|
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 <center> With <div style="margin: 0px auto 0px auto;">
|
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: <IMG> And <A> 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: <abbr> Tag Mixed Up With <a>
|
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.
|
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 |
-
|
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.'&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> <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(']]>', ']]>', $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(
|
391 |
-
$file =
|
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 .= ' » '.__('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 © %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.'&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> <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(']]>', ']]>', $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 .= ' » '.__('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 © %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'));
|
454 |
+
add_option('print_options', $print_options, 'Print Options');
|
455 |
+
}
|
|