Print, PDF, Email by PrintFriendly - Version 2.1

Version Description

Download this release

Release Info

Developer printfriendly
Plugin Icon 128x128 Print, PDF, Email by PrintFriendly
Version 2.1
Comparing to
See all releases

Code changes from version 2.0 to 2.1

admin.css CHANGED
@@ -1,305 +1,312 @@
1
- #pf_button_options{
2
- float:left;
3
- width:430px;
4
- }
5
-
6
- #pf_buttons{
7
- clear:both;
8
- overflow:hidden;
9
- width:400px;
10
- float:left;
11
- }
12
-
13
- #pf_buttons .buttongroup{
14
- float:left;
15
- width:200px;
16
- height:125px;
17
- }
18
- #pf_buttons .buttongroup.larger{
19
- width:395px;
20
- height:inherit;
21
- }
22
-
23
- #pf_buttons .buttongroup p{
24
- margin: 15px 0;
25
- }
26
- #pf_buttons .buttongroup p label input{
27
- position:relative;
28
- bottom:6px;
29
- margin-right:8px;
30
- }
31
-
32
- #pf_buttons .buttongroup p label input.bigger{
33
- bottom:10px;
34
- }
35
-
36
- #pf_left{
37
- width:400px;
38
- float:left;
39
- margin-right:30px;
40
- }
41
- #pf_designer{
42
- float:left;
43
- width:430px;
44
- }
45
- .pf_check{
46
- display:block;
47
- margin-top:4px;
48
- }
49
- .pf_check.disabled{
50
- color:#ccc:
51
- }
52
- .pf_check input[type="radio"],.pf_check input[type="checkbox"]{
53
- position:relative;
54
- bottom:2px;
55
- margin-right:4px;
56
- }
57
-
58
- .pf_px{
59
- width:45px;
60
- }
61
- .pf_label{
62
- display:block;
63
- font-weight:bold;
64
- }
65
-
66
- .pf_tip{
67
- font-size:10px;
68
- color:#888;
69
- text-shadow:1px 1px 1px #fff;
70
- }
71
-
72
- #pf_uploader{
73
- background: #e8e8e8;
74
- border: 1px solid #ccc;
75
- -webkit-border-radius: 4px;
76
- -moz-border-radius: 4px;
77
- border-radius: 4px;
78
- padding:10px 15px;
79
- width:400px;
80
- }
81
- #pf_uploader input[type="text"]{
82
- width:275px;
83
- }
84
- #pf_uploader p{
85
- margin-top:4px;
86
- line-height:16px;
87
- margin:0;
88
- color:#888;
89
- }
90
-
91
- /* color picker css */
92
- #colorSelector {
93
- position: relative;
94
- width: 36px;
95
- height: 36px;
96
- background: url(../images/select.png);
97
- }
98
- #colorSelector div {
99
- position: absolute;
100
- top: 3px;
101
- left: 3px;
102
- width: 30px;
103
- height: 30px;
104
- background: url(../images/select.png) center;
105
- }
106
-
107
- .colorpicker {
108
- width: 356px;
109
- height: 176px;
110
- overflow: hidden;
111
- position: absolute;
112
- background: url(../images/colorpicker_background.png);
113
- font-family: Arial, Helvetica, sans-serif;
114
- display: none;
115
- }
116
- .colorpicker_color {
117
- width: 150px;
118
- height: 150px;
119
- left: 14px;
120
- top: 13px;
121
- position: absolute;
122
- background: #f00;
123
- overflow: hidden;
124
- cursor: crosshair;
125
- }
126
- .colorpicker_color div {
127
- position: absolute;
128
- top: 0;
129
- left: 0;
130
- width: 150px;
131
- height: 150px;
132
- background: url(../images/colorpicker_overlay.png);
133
- }
134
- .colorpicker_color div div {
135
- position: absolute;
136
- top: 0;
137
- left: 0;
138
- width: 11px;
139
- height: 11px;
140
- overflow: hidden;
141
- background: url(../images/colorpicker_select.gif);
142
- margin: -5px 0 0 -5px;
143
- }
144
- .colorpicker_hue {
145
- position: absolute;
146
- top: 13px;
147
- left: 171px;
148
- width: 35px;
149
- height: 150px;
150
- cursor: n-resize;
151
- }
152
- .colorpicker_hue div {
153
- position: absolute;
154
- width: 35px;
155
- height: 9px;
156
- overflow: hidden;
157
- background: url(../images/colorpicker_indic.gif) left top;
158
- margin: -4px 0 0 0;
159
- left: 0px;
160
- }
161
- .colorpicker_new_color {
162
- position: absolute;
163
- width: 60px;
164
- height: 30px;
165
- left: 213px;
166
- top: 13px;
167
- background: #f00;
168
- }
169
- .colorpicker_current_color {
170
- position: absolute;
171
- width: 60px;
172
- height: 30px;
173
- left: 283px;
174
- top: 13px;
175
- background: #f00;
176
- }
177
- .colorpicker input {
178
- background-color: transparent;
179
- border: 1px solid transparent;
180
- position: absolute;
181
- font-size: 10px;
182
- font-family: Arial, Helvetica, sans-serif;
183
- color: #898989;
184
- top: 4px;
185
- right: 11px;
186
- text-align: right;
187
- margin: 0;
188
- padding: 0;
189
- height: 11px;
190
- }
191
- .colorpicker_hex {
192
- position: absolute;
193
- width: 72px;
194
- height: 22px;
195
- background: url(../images/colorpicker_hex.png) top;
196
- left: 212px;
197
- top: 142px;
198
- }
199
- .colorpicker_hex input {
200
- right: 6px;
201
- }
202
- .colorpicker_field {
203
- height: 22px;
204
- width: 62px;
205
- background-position: top;
206
- position: absolute;
207
- }
208
- .colorpicker_field span {
209
- position: absolute;
210
- width: 12px;
211
- height: 22px;
212
- overflow: hidden;
213
- top: 0;
214
- right: 0;
215
- cursor: n-resize;
216
- }
217
- .colorpicker_rgb_r {
218
- background-image: url(../images/colorpicker_rgb_r.png);
219
- top: 52px;
220
- left: 212px;
221
- }
222
- .colorpicker_rgb_g {
223
- background-image: url(../images/colorpicker_rgb_g.png);
224
- top: 82px;
225
- left: 212px;
226
- }
227
- .colorpicker_rgb_b {
228
- background-image: url(../images/colorpicker_rgb_b.png);
229
- top: 112px;
230
- left: 212px;
231
- }
232
- .colorpicker_hsb_h {
233
- background-image: url(../images/colorpicker_hsb_h.png);
234
- top: 52px;
235
- left: 282px;
236
- }
237
- .colorpicker_hsb_s {
238
- background-image: url(../images/colorpicker_hsb_s.png);
239
- top: 82px;
240
- left: 282px;
241
- }
242
- .colorpicker_hsb_b {
243
- background-image: url(../images/colorpicker_hsb_b.png);
244
- top: 112px;
245
- left: 282px;
246
- }
247
- .colorpicker_submit {
248
- position: absolute;
249
- width: 22px;
250
- height: 22px;
251
- background: url(../images/colorpicker_submit.png) top;
252
- left: 322px;
253
- top: 142px;
254
- overflow: hidden;
255
- }
256
- .colorpicker_focus {
257
- background-position: center;
258
- }
259
- .colorpicker_hex.colorpicker_focus {
260
- background-position: bottom;
261
- }
262
- .colorpicker_submit.colorpicker_focus {
263
- background-position: bottom;
264
- }
265
- .colorpicker_slider {
266
- background-position: bottom;
267
- }
268
-
269
-
270
- .pf_box{
271
- clear:both;
272
- /* Borders Radius */
273
- -moz-border-radius: 6px ;
274
- -webkit-border-radius: 6px ;
275
- border-radius: 6px;
276
- border:1px solid #DFDFDF;
277
- background: #fff;
278
- margin-bottom: 24px;
279
- }
280
- .pf_box .pf_c{
281
- padding:0px 10px 10px;
282
- overflow:hidden;
283
- clear:both;
284
- }
285
-
286
- .pf_box h3{
287
- font-size:13px;
288
- line-height: 1;
289
- text-shadow: 0 1px 0 #FFFFFF;
290
- padding: 7px 9px;
291
- margin:0;
292
- /* Background Gradient */
293
- background-color: #e1e1e1;
294
- background-image: -moz-linear-gradient(top, #ededed, #e1e1e1);
295
- background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #ededed),color-stop(1, #e1e1e1));
296
- filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ededed', EndColorStr='#e1e1e1');
297
- -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ededed', EndColorStr='#e1e1e1')";
298
- }
299
- .pf_box .pf_c .pf_float{
300
- float:left;
301
- margin-right:16px;
302
- }
303
- #pf_custom_text{
304
- width:200px;
 
 
 
 
 
 
 
305
  }
1
+ /*v2.1*/
2
+ #pf_button_options{
3
+ float:left;
4
+ width:430px;
5
+ }
6
+
7
+ #pf_buttons{
8
+ clear:both;
9
+ overflow:hidden;
10
+ width:400px;
11
+ float:left;
12
+ }
13
+
14
+ #pf_buttons .buttongroup{
15
+ float:left;
16
+ width:200px;
17
+ height:125px;
18
+ }
19
+ #pf_buttons .buttongroup.larger{
20
+ width:395px;
21
+ height:inherit;
22
+ }
23
+
24
+ #pf_buttons .buttongroup p{
25
+ margin: 15px 0;
26
+ }
27
+ #pf_buttons .buttongroup p label input{
28
+ position:relative;
29
+ bottom:6px;
30
+ margin-right:8px;
31
+ }
32
+
33
+ #pf_buttons .buttongroup p label input.bigger{
34
+ bottom:10px;
35
+ }
36
+
37
+ #pf_left{
38
+ width:400px;
39
+ float:left;
40
+ margin-right:30px;
41
+ }
42
+ #pf_designer{
43
+ float:left;
44
+ width:430px;
45
+ }
46
+ .pf_check{
47
+ display:block;
48
+ margin-top:4px;
49
+ }
50
+ .pf_check.disabled{
51
+ color:#ccc:
52
+ }
53
+ .pf_check input[type="radio"],.pf_check input[type="checkbox"]{
54
+ position:relative;
55
+ bottom:2px;
56
+ margin-right:4px;
57
+ }
58
+
59
+ .pf_px{
60
+ width:45px;
61
+ }
62
+ .pf_label{
63
+ display:block;
64
+ font-weight:bold;
65
+ }
66
+
67
+ .pf_tip{
68
+ font-size:10px;
69
+ color:#888;
70
+ text-shadow:1px 1px 1px #fff;
71
+ }
72
+
73
+ #pf_uploader{
74
+ background: #e8e8e8;
75
+ border: 1px solid #ccc;
76
+ -webkit-border-radius: 4px;
77
+ -moz-border-radius: 4px;
78
+ border-radius: 4px;
79
+ padding:10px 15px;
80
+ width:400px;
81
+ }
82
+ #pf_uploader input[type="text"]{
83
+ width:275px;
84
+ }
85
+ #pf_uploader p{
86
+ margin-top:4px;
87
+ line-height:16px;
88
+ margin:0;
89
+ color:#888;
90
+ }
91
+
92
+ /* color picker css */
93
+ #colorSelector {
94
+ position: relative;
95
+ width: 36px;
96
+ height: 36px;
97
+ background: url(../images/select.png);
98
+ }
99
+ #colorSelector div {
100
+ position: absolute;
101
+ top: 3px;
102
+ left: 3px;
103
+ width: 30px;
104
+ height: 30px;
105
+ background: url(../images/select.png) center;
106
+ }
107
+
108
+ .colorpicker {
109
+ width: 356px;
110
+ height: 176px;
111
+ overflow: hidden;
112
+ position: absolute;
113
+ background: url(../images/colorpicker_background.png);
114
+ font-family: Arial, Helvetica, sans-serif;
115
+ display: none;
116
+ }
117
+ .colorpicker_color {
118
+ width: 150px;
119
+ height: 150px;
120
+ left: 14px;
121
+ top: 13px;
122
+ position: absolute;
123
+ background: #f00;
124
+ overflow: hidden;
125
+ cursor: crosshair;
126
+ }
127
+ .colorpicker_color div {
128
+ position: absolute;
129
+ top: 0;
130
+ left: 0;
131
+ width: 150px;
132
+ height: 150px;
133
+ background: url(../images/colorpicker_overlay.png);
134
+ }
135
+ .colorpicker_color div div {
136
+ position: absolute;
137
+ top: 0;
138
+ left: 0;
139
+ width: 11px;
140
+ height: 11px;
141
+ overflow: hidden;
142
+ background: url(../images/colorpicker_select.gif);
143
+ margin: -5px 0 0 -5px;
144
+ }
145
+ .colorpicker_hue {
146
+ position: absolute;
147
+ top: 13px;
148
+ left: 171px;
149
+ width: 35px;
150
+ height: 150px;
151
+ cursor: n-resize;
152
+ }
153
+ .colorpicker_hue div {
154
+ position: absolute;
155
+ width: 35px;
156
+ height: 9px;
157
+ overflow: hidden;
158
+ background: url(../images/colorpicker_indic.gif) left top;
159
+ margin: -4px 0 0 0;
160
+ left: 0px;
161
+ }
162
+ .colorpicker_new_color {
163
+ position: absolute;
164
+ width: 60px;
165
+ height: 30px;
166
+ left: 213px;
167
+ top: 13px;
168
+ background: #f00;
169
+ }
170
+ .colorpicker_current_color {
171
+ position: absolute;
172
+ width: 60px;
173
+ height: 30px;
174
+ left: 283px;
175
+ top: 13px;
176
+ background: #f00;
177
+ }
178
+ .colorpicker input {
179
+ background-color: transparent;
180
+ border: 1px solid transparent;
181
+ position: absolute;
182
+ font-size: 10px;
183
+ font-family: Arial, Helvetica, sans-serif;
184
+ color: #898989;
185
+ top: 4px;
186
+ right: 11px;
187
+ text-align: right;
188
+ margin: 0;
189
+ padding: 0;
190
+ height: 11px;
191
+ }
192
+ .colorpicker_hex {
193
+ position: absolute;
194
+ width: 72px;
195
+ height: 22px;
196
+ background: url(../images/colorpicker_hex.png) top;
197
+ left: 212px;
198
+ top: 142px;
199
+ }
200
+ .colorpicker_hex input {
201
+ right: 6px;
202
+ }
203
+ .colorpicker_field {
204
+ height: 22px;
205
+ width: 62px;
206
+ background-position: top;
207
+ position: absolute;
208
+ }
209
+ .colorpicker_field span {
210
+ position: absolute;
211
+ width: 12px;
212
+ height: 22px;
213
+ overflow: hidden;
214
+ top: 0;
215
+ right: 0;
216
+ cursor: n-resize;
217
+ }
218
+ .colorpicker_rgb_r {
219
+ background-image: url(../images/colorpicker_rgb_r.png);
220
+ top: 52px;
221
+ left: 212px;
222
+ }
223
+ .colorpicker_rgb_g {
224
+ background-image: url(../images/colorpicker_rgb_g.png);
225
+ top: 82px;
226
+ left: 212px;
227
+ }
228
+ .colorpicker_rgb_b {
229
+ background-image: url(../images/colorpicker_rgb_b.png);
230
+ top: 112px;
231
+ left: 212px;
232
+ }
233
+ .colorpicker_hsb_h {
234
+ background-image: url(../images/colorpicker_hsb_h.png);
235
+ top: 52px;
236
+ left: 282px;
237
+ }
238
+ .colorpicker_hsb_s {
239
+ background-image: url(../images/colorpicker_hsb_s.png);
240
+ top: 82px;
241
+ left: 282px;
242
+ }
243
+ .colorpicker_hsb_b {
244
+ background-image: url(../images/colorpicker_hsb_b.png);
245
+ top: 112px;
246
+ left: 282px;
247
+ }
248
+ .colorpicker_submit {
249
+ position: absolute;
250
+ width: 22px;
251
+ height: 22px;
252
+ background: url(../images/colorpicker_submit.png) top;
253
+ left: 322px;
254
+ top: 142px;
255
+ overflow: hidden;
256
+ }
257
+ .colorpicker_focus {
258
+ background-position: center;
259
+ }
260
+ .colorpicker_hex.colorpicker_focus {
261
+ background-position: bottom;
262
+ }
263
+ .colorpicker_submit.colorpicker_focus {
264
+ background-position: bottom;
265
+ }
266
+ .colorpicker_slider {
267
+ background-position: bottom;
268
+ }
269
+
270
+
271
+ .pf_box{
272
+ clear:both;
273
+ /* Borders Radius */
274
+ -moz-border-radius: 6px ;
275
+ -webkit-border-radius: 6px ;
276
+ border-radius: 6px;
277
+ border:1px solid #DFDFDF;
278
+ background: #fff;
279
+ margin-bottom: 24px;
280
+ }
281
+ .pf_box .pf_c{
282
+ padding:0px 10px 10px;
283
+ overflow:hidden;
284
+ clear:both;
285
+ }
286
+
287
+ .pf_box h3{
288
+ font-size:13px;
289
+ line-height: 1;
290
+ text-shadow: 0 1px 0 #FFFFFF;
291
+ padding: 7px 9px;
292
+ margin:0;
293
+ /* Background Gradient */
294
+ background-color: #e1e1e1;
295
+ background-image: -moz-linear-gradient(top, #ededed, #e1e1e1);
296
+ background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #ededed),color-stop(1, #e1e1e1));
297
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ededed', EndColorStr='#e1e1e1');
298
+ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ededed', EndColorStr='#e1e1e1')";
299
+ }
300
+ .pf_box .pf_c .pf_float{
301
+ float:left;
302
+ margin-right:36px;
303
+ }
304
+ #manual {
305
+ display: none;
306
+ }
307
+ #imgurl {
308
+ display: none;
309
+ }
310
+ div.pf_content_placement{
311
+ display:none;
312
  }
admin.js CHANGED
File without changes
colorpicker.js CHANGED
File without changes
images/blank.gif CHANGED
File without changes
images/colorpicker_background.png CHANGED
File without changes
images/colorpicker_hex.png CHANGED
File without changes
images/colorpicker_hsb_b.png CHANGED
File without changes
images/colorpicker_hsb_h.png CHANGED
File without changes
images/colorpicker_hsb_s.png CHANGED
File without changes
images/colorpicker_indic.gif CHANGED
File without changes
images/colorpicker_overlay.png CHANGED
File without changes
images/colorpicker_rgb_b.png CHANGED
File without changes
images/colorpicker_rgb_g.png CHANGED
File without changes
images/colorpicker_rgb_r.png CHANGED
File without changes
images/colorpicker_select.gif CHANGED
File without changes
images/colorpicker_submit.png CHANGED
File without changes
images/custom_background.png CHANGED
File without changes
images/custom_hex.png CHANGED
File without changes
images/custom_hsb_b.png CHANGED
File without changes
images/custom_hsb_h.png CHANGED
File without changes
images/custom_hsb_s.png CHANGED
File without changes
images/custom_indic.gif CHANGED
File without changes
images/custom_rgb_b.png CHANGED
File without changes
images/custom_rgb_g.png CHANGED
File without changes
images/custom_rgb_r.png CHANGED
File without changes
images/custom_submit.png CHANGED
File without changes
images/noimage.png CHANGED
File without changes
images/select.png CHANGED
File without changes
images/select2.png CHANGED
File without changes
images/slider.png CHANGED
File without changes
pf.php CHANGED
@@ -1,229 +1,229 @@
1
- <?php
2
- /*
3
- Plugin Name: Print Friendly &amp; PDF
4
- Plugin URI: http://www.printfriendly.com/button
5
- Description: Adds a Print Friendly &amp; PDF button for your pages. Help your users save paper and ink, and engage with your content. Developed by <a href="http://wordpresswrench.com?ref=printfriendly" target="_blank">WordPress Wrench</a>
6
- Version: 2.0
7
- Author: PrintFriendly
8
- Author URI: http://www.PrintFriendly.com
9
-
10
- Changelog :
11
- 2.0 - New Revision by WordPressWrench.com with a plethora of changes. You may now style your print button much easier.
12
- 1.5 - Added developer ability to disable hook and use the pf_show_link() function to better be used in a custom theme & Uninstall cleanup - by WordpressWrench.com
13
- 1.4 - Changed Name
14
- 1.3 - Added new buttons, removed redundant code.
15
- 1.2 - User can choose to show or not show buttons on the listing page.
16
-
17
- */
18
-
19
-
20
-
21
- ////////////////////////////// Wordpress hooks
22
-
23
- // add the settings page
24
- add_action('admin_menu', 'pf_menu');
25
- function pf_menu() {
26
- add_options_page('PrintFriendly Options', 'PrintFriendly', 'publish_posts', 'printfriendly', 'pf_options');
27
- }
28
-
29
- // add the settings link to the plugin page
30
-
31
- function pf_settings_link($links) {
32
- $settings_link = '<a href="options-general.php?page=printfriendly">Settings</a>';
33
- array_unshift($links, $settings_link);
34
- return $links;
35
- }
36
-
37
- // add css, js, and check for updates
38
- if (isset($_GET['page']) && $_GET['page'] == 'printfriendly') {
39
- add_action('admin_print_scripts', 'pf_admin_scripts');
40
- add_action('admin_print_styles', 'pf_admin_styles');
41
- add_action('admin_head', 'pf_css_in_admin_head');
42
- if(get_option('pf_text_color')==null){
43
- //old install or something is fishy! lets run the install!
44
- printfriendly_activation_handler();
45
- }
46
- }
47
-
48
- $pf_pluginbase = plugin_basename(__FILE__);
49
- add_filter('plugin_action_links_'.$pf_pluginbase, 'pf_settings_link');
50
-
51
- // automaticaly add the link
52
- add_action('the_content', 'pf_show_link');
53
-
54
- // lets start our mess!
55
- function printfriendly_activation_handler(){
56
- update_option('pf_margin_top',0);
57
- update_option('pf_margin_right',0);
58
- update_option('pf_margin_bottom',0);
59
- update_option('pf_margin_left',0);
60
-
61
-
62
- update_option('pf_text_color','#55750C');
63
- update_option('pf_text_size','12');
64
- if(get_option('pf_show_list')==0){
65
- update_option('pf_show_list','all');
66
- }elseif(get_option('pf_show_list')==1){
67
- update_option('pf_show_list','single');
68
- }
69
- if(get_option('pf_disable_prepend')==1){
70
- update_option('pf_show_list','manual');
71
- }
72
- delete_option('pf_disable_prepend');
73
- }
74
-
75
- // lets clean our mess when we are done and properly
76
- function printfriendly_deactivation_handler(){
77
- delete_option('pf_button_type');
78
- delete_option('pf_custom_text');
79
-
80
- delete_option('pf_custom_image');
81
-
82
- delete_option('pf_show_list');
83
- delete_option('pf_content_placement');
84
- delete_option('pf_content_position');
85
-
86
- delete_option('pf_margin_top');
87
- delete_option('pf_margin_right');
88
- delete_option('pf_margin_bottom');
89
- delete_option('pf_margin_left');
90
- }
91
- register_activation_hook(__FILE__, 'printfriendly_activation_handler');
92
- register_uninstall_hook(__FILE__, 'printfriendly_deactivation_handler');
93
-
94
- // add CSS into admin panel
95
- function pf_css_in_admin_head() {
96
- $url = plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/admin.css';
97
- echo "<link rel='stylesheet' type='text/css' href='$url' />\n";
98
- }
99
-
100
- ////////////////////////////// Admin Settings
101
-
102
- function pf_options(){
103
- include_once('pf_admin.php');
104
- }
105
-
106
- // setup for uploads
107
- function pf_admin_scripts() {
108
- wp_enqueue_script('media-upload');
109
- wp_enqueue_script('thickbox');
110
- wp_register_script('pf-color-picker', plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/colorpicker.js', array('jquery','media-upload','thickbox'));
111
- wp_register_script('pf-admin-js', plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/admin.js', array('jquery','media-upload','thickbox'));
112
- wp_enqueue_script('pf-color-picker');
113
- wp_enqueue_script('pf-admin-js');
114
- }
115
- function pf_admin_styles() {
116
- wp_enqueue_style('thickbox');
117
- }
118
-
119
- ////////////////////////////// Where all the magic happens
120
-
121
- // add js into the head
122
- function pf_js(){
123
- return '<script src="http://cdn.printfriendly.com/printfriendly.js" type="text/javascript"></script>';
124
- }
125
-
126
- function pf_radio($name){
127
- $var = '<input name="pf_button_type" type="radio" value="'.$name.'"'; if($name=="pf-button-big.gif"){$var .= ' class="bigger"';} if( get_option('pf_button_type') == $name || ($name=="pf-button.gif" && get_option('pf_button_type')==null) ){$var .= ' checked="checked"'; } $var .= '/>';
128
- return $var.pf_button($name);
129
- }
130
-
131
- function pf_button($name=false){
132
- if($name==false){
133
- $name = get_option('pf_button_type');
134
- //null
135
- if($name==null){
136
- $name='pf-button.gif';
137
- }
138
- }
139
- $text = get_option('pf_custom_text');
140
- if( $text == null){
141
- $text = 'Print Friendly';
142
- }
143
- switch($name){
144
- case "custom-image":
145
- $custom_image = get_option('pf_custom_image');
146
- if($custom_image==null){
147
- return '';
148
- }
149
- $return = '<img class="printfriendly" src="'.$custom_image.'" />';
150
- if( get_option('pf_custom_text') != null){
151
- $return .='<span class="printfriendly" style="font-size:'.get_option('pf_text_size').'px; margin-left:3px; color: '.get_option('pf_text_color').';">'.$text.'</span>';
152
- }
153
- return $return;
154
- break;
155
-
156
- case "text-only":
157
- return '<span class="printfriendly" style="font-size: '.get_option('pf_text_size').'px; margin-left:3px; color: '.get_option('pf_text_color').';">'.$text.'</span>';
158
- break;
159
-
160
- case "pf-icon-both.gif":
161
- return '<img class="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-print-icon.gif" alt="Print Friendly"/><span class="printandpdf" style="font-size:'.get_option('pf_text_size').'; margin-left:3px; color:'.get_option('pf_text_color').';"> Print <img src="http://cdn.printfriendly.com/pf-pdf-icon.gif" alt="Get a PDF version of this webpage" /> PDF </span>';
162
- break;
163
-
164
- case "pf-icon-small.gif":
165
- case "pf-icon.gif":
166
- $size = get_option('pf_text_size');
167
- if($name=="pf-icon.gif" && $size==12){
168
- $size= 'font-size:'.($size+3).'px; ';
169
- }else{
170
- $size ='font-size:'.$size.'px; ';
171
- }
172
- return '<img class="printfriendly" src="http://cdn.printfriendly.com/'.$name.'" alt="Print Friendly"/><span style="'.$size.'margin-left:3px; color: '.get_option('pf_text_color').';">'.$text.'</span>';
173
- break;
174
-
175
- case "pf-button.gif":
176
- case "pf-button-big.gif":
177
- case "pf-button-both.gif":
178
- return '<img class="printfriendly" src="http://cdn.printfriendly.com/'.$name.'" alt="PrintFriendly" />';
179
- break;
180
- }
181
- }
182
-
183
- function pf_margin_down($dir){
184
- $margin = get_option('pf_margin_'.$dir);
185
- if($margin == null){
186
- return '0';
187
- }else{
188
- return $margin;
189
- }
190
- }
191
-
192
- // add button
193
- function pf_show_link($content=false){
194
- $pf_display = get_option('pf_show_list');
195
- if( ($pf_display=='all' || $pf_display == null) || ($pf_display=='single' && (is_single() || is_page()) ) || ($pf_display=='manual' && $content==false) ){
196
- if($content==false){$content = '';}
197
- // now lets get options setup before we start ouputting data
198
- $style=' style="text-align:';
199
- // position
200
- $pos = get_option('pf_content_position');
201
- if($pos==null){$pos='left';}
202
- $style.=$pos.';';
203
-
204
- //margin
205
- $style.=' margin: '.pf_margin_down('top').'px '.pf_margin_down('right').'px '.pf_margin_down('bottom').'px '.pf_margin_down('left').'px;';
206
-
207
- $style.='" ';
208
-
209
- if(is_single() || is_page()){
210
- $add = pf_js();
211
- }else{
212
- $add = '';
213
- }
214
- $post_url = get_permalink();
215
- $separator = "?pfstyle=wp";
216
- if (strpos($post_url,"?")!=false){
217
- $separator = "&pfstyle=wp";
218
- }
219
- $plink_url = $post_url . $separator;
220
- $button = '<div'.$style.'class="pfButton">'.$add.'<a href="'.$plink_url.'">'.pf_button().'</a></div>';
221
- if(get_option('pf_content_placement')==null){
222
- return $content.$button;
223
- }else{
224
- return $button.$content;
225
- }
226
- }else{
227
- return $content;
228
- }
229
  }
1
+ <?php
2
+ /*
3
+ Plugin Name: Print Friendly &amp; PDF
4
+ Plugin URI: http://www.printfriendly.com/button
5
+ Description: Adds a Print Friendly &amp; PDF button for your pages. Help your users save paper and ink, and engage with your content. Developed by <a href="http://printfriendly.com" target="_blank">PrintFriendly</a>
6
+ Version: 2.1
7
+ Author: PrintFriendly
8
+ Author URI: http://www.PrintFriendly.com
9
+
10
+ Changelog :
11
+ 2.1.1 - Fixed admin settings bug.
12
+ 2.1 - Update for mult-author websites. Improvements to Settings page.
13
+ 2.0 - Customize the style, placement, and pages your printfriendly button appears.
14
+ 1.5 - Added developer ability to disable hook and use the pf_show_link() function to better be used in a custom theme & Uninstall cleanup.
15
+ 1.4 - Changed Name
16
+ 1.3 - Added new buttons, removed redundant code.
17
+ 1.2 - User can choose to show or not show buttons on the listing page.
18
+
19
+ */
20
+
21
+ ////////////////////////////// Wordpress hooks
22
+
23
+ // add the settings page
24
+ add_action('admin_menu', 'pf_menu');
25
+ function pf_menu() {
26
+ add_options_page('PrintFriendly Options', 'PrintFriendly', 'publish_posts', 'printfriendly', 'pf_options');
27
+ }
28
+
29
+ // add the settings link to the plugin page
30
+
31
+ function pf_settings_link($links) {
32
+ $settings_link = '<a href="options-general.php?page=printfriendly">Settings</a>';
33
+ array_unshift($links, $settings_link);
34
+ return $links;
35
+ }
36
+
37
+ // add css, js, and check for updates
38
+ if (isset($_GET['page']) && $_GET['page'] == 'printfriendly') {
39
+ add_action('admin_print_scripts', 'pf_admin_scripts');
40
+ add_action('admin_print_styles', 'pf_admin_styles');
41
+ add_action('admin_head', 'pf_css_in_admin_head');
42
+ if(get_option('pf_text_color')==null){
43
+ //old install or something is fishy! lets run the install!
44
+ printfriendly_activation_handler();
45
+ }
46
+ }
47
+
48
+ $pf_pluginbase = plugin_basename(__FILE__);
49
+ add_filter('plugin_action_links_'.$pf_pluginbase, 'pf_settings_link');
50
+
51
+ // automaticaly add the link
52
+ add_action('the_content', 'pf_show_link');
53
+
54
+ // lets start our mess!
55
+ function printfriendly_activation_handler(){
56
+ update_option('pf_margin_top',0);
57
+ update_option('pf_margin_right',0);
58
+ update_option('pf_margin_bottom',0);
59
+ update_option('pf_margin_left',0);
60
+
61
+
62
+ update_option('pf_text_color','#55750C');
63
+ update_option('pf_text_size','14');
64
+ if(get_option('pf_show_list')==0){
65
+ update_option('pf_show_list','all');
66
+ }elseif(get_option('pf_show_list')==1){
67
+ update_option('pf_show_list','single');
68
+ }
69
+ if(get_option('pf_disable_prepend')==1){
70
+ update_option('pf_show_list','manual');
71
+ }
72
+ delete_option('pf_disable_prepend');
73
+ }
74
+
75
+ // lets clean our mess when we are done and properly
76
+ function printfriendly_deactivation_handler(){
77
+ delete_option('pf_button_type');
78
+ delete_option('pf_custom_text');
79
+
80
+ delete_option('pf_custom_image');
81
+
82
+ delete_option('pf_show_list');
83
+ delete_option('pf_content_placement');
84
+ delete_option('pf_content_position');
85
+
86
+ delete_option('pf_margin_top');
87
+ delete_option('pf_margin_right');
88
+ delete_option('pf_margin_bottom');
89
+ delete_option('pf_margin_left');
90
+ }
91
+ register_activation_hook(__FILE__, 'printfriendly_activation_handler');
92
+ register_uninstall_hook(__FILE__, 'printfriendly_deactivation_handler');
93
+
94
+ // add CSS into admin panel
95
+ function pf_css_in_admin_head() {
96
+ $url = plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/admin.css';
97
+ echo "<link rel='stylesheet' type='text/css' href='$url' />\n";
98
+ }
99
+
100
+ ////////////////////////////// Admin Settings
101
+
102
+ function pf_options(){
103
+ include_once('pf_admin.php');
104
+ }
105
+
106
+ // setup for uploads
107
+ function pf_admin_scripts() {
108
+ wp_enqueue_script('media-upload');
109
+ wp_enqueue_script('thickbox');
110
+ wp_register_script('pf-color-picker', plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/colorpicker.js', array('jquery','media-upload','thickbox'));
111
+ wp_register_script('pf-admin-js', plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/admin.js', array('jquery','media-upload','thickbox'));
112
+ wp_enqueue_script('pf-color-picker');
113
+ wp_enqueue_script('pf-admin-js');
114
+ }
115
+ function pf_admin_styles() {
116
+ wp_enqueue_style('thickbox');
117
+ }
118
+
119
+ ////////////////////////////// Where all the magic happens
120
+
121
+ // add js into the head
122
+ function pf_js(){
123
+ return '<script src="http://cdn.printfriendly.com/printfriendly.js" type="text/javascript"></script>';
124
+ }
125
+
126
+ function pf_radio($name){
127
+ $var = '<input name="pf_button_type" type="radio" value="'.$name.'"'; if($name=="custom-image"){$var .= ' onclick="Toggle(\'imgurl\');" ';} else{$var .= ' onclick="Toggle(\'hide\');" ';} if($name=="pf-button-big.gif"){$var .= ' class="bigger"';} if( get_option('pf_button_type') == $name || ($name=="pf-button.gif" && get_option('pf_button_type')==null) ){$var .= ' checked="checked"'; } $var .= '/>';
128
+ return $var.pf_button($name);
129
+ }
130
+
131
+ function pf_button($name=false){
132
+ if($name==false){
133
+ $name = get_option('pf_button_type');
134
+ //null
135
+ if($name==null){
136
+ $name='pf-button.gif';
137
+ }
138
+ }
139
+ $text = get_option('pf_custom_text');
140
+ if( $text == null){
141
+ $text = 'Print Friendly';
142
+ }
143
+ switch($name){
144
+ case "custom-image":
145
+ $custom_image = get_option('pf_custom_image');
146
+ if($custom_image==null){
147
+ return '';
148
+ }
149
+ $return = '<img class="printfriendly" src="'.$custom_image.'" />';
150
+ if( get_option('pf_custom_text') != null){
151
+ $return .='<span class="printfriendly" style="font-size:'.get_option('pf_text_size').'px; margin-left:3px; color: '.get_option('pf_text_color').';">'.$text.'</span>';
152
+ }
153
+ return $return;
154
+ break;
155
+
156
+ case "text-only":
157
+ return '<span class="printfriendly" style="font-size: '.get_option('pf_text_size').'px; margin-left:3px; color: '.get_option('pf_text_color').';">'.$text.'</span>';
158
+ break;
159
+
160
+ case "pf-icon-both.gif":
161
+ return '<img class="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-print-icon.gif" alt="Print Friendly"/><span class="printandpdf" style="font-size:'.get_option('pf_text_size').'; margin-left:3px; color:'.get_option('pf_text_color').';"> Print <img src="http://cdn.printfriendly.com/pf-pdf-icon.gif" alt="Get a PDF version of this webpage" /> PDF </span>';
162
+ break;
163
+
164
+ case "pf-icon-small.gif":
165
+ case "pf-icon.gif":
166
+ $size = get_option('pf_text_size');
167
+ if($name=="pf-icon.gif" && $size==12){
168
+ $size= 'font-size:'.($size+3).'px; ';
169
+ }else{
170
+ $size ='font-size:'.$size.'px; ';
171
+ }
172
+ return '<img class="printfriendly" src="http://cdn.printfriendly.com/'.$name.'" alt="Print Friendly"/><span style="'.$size.'margin-left:3px; color: '.get_option('pf_text_color').';">'.$text.'</span>';
173
+ break;
174
+
175
+ case "pf-button.gif":
176
+ case "pf-button-big.gif":
177
+ case "pf-button-both.gif":
178
+ return '<img class="printfriendly" src="http://cdn.printfriendly.com/'.$name.'" alt="PrintFriendly" />';
179
+ break;
180
+ }
181
+ }
182
+
183
+ function pf_margin_down($dir){
184
+ $margin = get_option('pf_margin_'.$dir);
185
+ if($margin == null){
186
+ return '0';
187
+ }else{
188
+ return $margin;
189
+ }
190
+ }
191
+
192
+ // add button
193
+ function pf_show_link($content=false){
194
+ $pf_display = get_option('pf_show_list');
195
+ if( ($pf_display=='all' || $pf_display == null) || ($pf_display=='single' && (is_single() || is_page()) ) || ($pf_display=='manual' && $content==false) ){
196
+ if($content==false){$content = '';}
197
+ // now lets get options setup before we start ouputting data
198
+ $style=' style="text-align:';
199
+ // position
200
+ $pos = get_option('pf_content_position');
201
+ if($pos==null){$pos='left';}
202
+ $style.=$pos.';';
203
+
204
+ //margin
205
+ $style.=' margin: '.pf_margin_down('top').'px '.pf_margin_down('right').'px '.pf_margin_down('bottom').'px '.pf_margin_down('left').'px;';
206
+
207
+ $style.='" ';
208
+
209
+ if(is_single() || is_page()){
210
+ $add = pf_js();
211
+ }else{
212
+ $add = '';
213
+ }
214
+ $post_url = get_permalink();
215
+ $separator = "?pfstyle=wp";
216
+ if (strpos($post_url,"?")!=false){
217
+ $separator = "&pfstyle=wp";
218
+ }
219
+ $plink_url = $post_url . $separator;
220
+ $button = '<div'.$style.'class="pfButton">'.$add.'<a href="'.$plink_url.'" style="text-decoration: none; color: '.get_option('pf_text_color').';">'.pf_button().'</a></div>';
221
+ if(get_option('pf_content_placement')==null){
222
+ return $content.$button;
223
+ }else{
224
+ return $button.$content;
225
+ }
226
+ }else{
227
+ return $content;
228
+ }
229
  }
pf_admin.php CHANGED
@@ -1,264 +1,272 @@
1
- <?php
2
- if(isset($_POST['pf_save'])){
3
- $error = false;
4
- // we should always have a response, but lets still validate it for security
5
- if($_POST['pf_button_type'] == 'pf-button.gif' || $_POST['pf_button_type'] == 'pf-button-big.gif' || $_POST['pf_button_type'] == 'pf-icon-small.gif' || $_POST['pf_button_type'] == 'pf-icon.gif' || $_POST['pf_button_type'] == 'pf-button-both.gif' || $_POST['pf_button_type'] == 'pf-icon-both.gif' || $_POST['pf_button_type'] == 'text-only' || $_POST['pf_button_type'] == 'custom-image'){
6
- update_option('pf_button_type',$_POST['pf_button_type']);
7
- }else{
8
- $error[] = 'Invalid entry for the "Pick Your Button" field. That isn\'t an option to select from! Quit messing with the DOM.';
9
- }
10
-
11
- // custom image
12
- if(isset($_POST['upload_image'])){
13
- if(trim($_POST['upload_image']) == ''){
14
- update_option('pf_custom_image',null);
15
- }else{
16
- $imagedata = @getimagesize($_POST['upload_image']);
17
- if(is_array($imagedata)){
18
- // well by golly we have an image
19
- update_option('pf_custom_image',$_POST['upload_image']);
20
- }else{
21
- // we need to trigger an error
22
- $error[] = 'Please provide a valid image link for the "Custom Image URL" field.';
23
- }
24
- }
25
- }
26
-
27
- // Custom Text
28
- if(isset($_POST['custom_text'])){
29
- update_option('pf_custom_text',htmlspecialchars($_POST['custom_text']) );
30
- }
31
-
32
- // Display custom image with custom text
33
- if(isset($_POST['custom_both'])){
34
- update_option('pf_custom_both',true);
35
- }else{
36
- update_option('pf_custom_both',null);
37
- }
38
-
39
- // display button
40
- if(isset($_POST['pf_show_list'])){
41
- if($_POST['pf_show_list']=="all" || $_POST['pf_show_list']=="single" || $_POST['pf_show_list']=="manual"){
42
- update_option('pf_show_list',$_POST['pf_show_list']);
43
- }else{
44
- // something isn't right
45
- $error[] = 'Invalid entry for the "Display Button" field. That isn\'t an option to select from! Quit messing with the DOM.';
46
- }
47
- }
48
-
49
- // now on to the right side
50
-
51
- // placement
52
- if(isset($_POST['pf_content_placement'])){
53
- if($_POST['pf_content_placement']=="before" || $_POST['pf_content_placement']=="after"){
54
- if($_POST['pf_content_placement']=='before'){
55
- update_option('pf_content_placement','before');
56
- }else{
57
- update_option('pf_content_placement',null);
58
- }
59
- }else{
60
- // something isn't right
61
- $error[] = 'Invalid entry for the "Placement" field. That isn\'t an option to select from! Quit messing with the DOM.';
62
- }
63
- }
64
-
65
- // position
66
- if(isset($_POST['pf_content_position'])){
67
-
68
- if($_POST['pf_content_position']=="left" || $_POST['pf_content_position']=="right" || $_POST['pf_content_position']=="center"){
69
- if($_POST['pf_content_position']=='left'){
70
- update_option('pf_content_position',null);
71
- }else{
72
- update_option('pf_content_position',$_POST['pf_content_position']);
73
- }
74
- }else{
75
- // something isn't right
76
- $error[] = 'Invalid entry for the "Position" field. That isn\'t an option to select from! Quit messing with the DOM.';
77
- }
78
- }
79
-
80
- //margin-top
81
- if(isset($_POST['pf_margin_top'])){
82
- if(is_numeric($_POST['pf_margin_top'])){
83
- update_option('pf_margin_top',$_POST['pf_margin_top']);
84
- }else{
85
- $error[] ='The value for "Margin Top" must be a number!';
86
- }
87
- }
88
- //margin-right
89
- if(isset($_POST['pf_margin_right'])){
90
- if(is_numeric($_POST['pf_margin_right'])){
91
- update_option('pf_margin_right',$_POST['pf_margin_right']);
92
- }else{
93
- $error[] ='The value for "Margin Right" must be a number!';
94
- }
95
- }
96
- //margin-bottom
97
- if(isset($_POST['pf_margin_bottom'])){
98
- if(is_numeric($_POST['pf_margin_bottom'])){
99
- update_option('pf_margin_bottom',$_POST['pf_margin_bottom']);
100
- }else{
101
- $error[] ='The value for "Margin Bottom" must be a number!';
102
- }
103
- }
104
- //margin-left
105
- if(isset($_POST['pf_margin_left'])){
106
- if(is_numeric($_POST['pf_margin_left'])){
107
- update_option('pf_margin_left',$_POST['pf_margin_left']);
108
- }else{
109
- $error[] ='The value for "Margin Left" must be a number!';
110
- }
111
- }
112
-
113
- //font color
114
- if(isset($_POST['pf_text_color'])){
115
- if(preg_match('/^#[a-f0-9]{6}$/i', $_POST['pf_text_color'])){
116
- update_option('pf_text_color',$_POST['pf_text_color']);
117
- }else{
118
- $error[] ='The value for "Font Color" must be a valid hex code!';
119
- }
120
- }
121
-
122
- //font size
123
- if(isset($_POST['pf_text_size'])){
124
- if(is_numeric($_POST['pf_text_size'])){
125
- update_option('pf_text_size',$_POST['pf_text_size']);
126
- }else{
127
- $error[] ='The value for "Font Size" must be a number!';
128
- }
129
- }
130
- }
131
-
132
- ?>
133
- <div class="wrap">
134
- <h2>PrintFriendly: Settings</h2>
135
- <?php
136
- if(isset($error)){
137
- if(is_array($error)){
138
- echo '<div class="error"><strong>Settings were not saved, The following problems exist:</strong>';
139
- foreach($error as $e){
140
- echo '<p>'.$e.'</p>';
141
- }
142
- echo '</div>';
143
- }else{
144
- echo '<div class="updated"><p><strong>Settings saved.</strong></p></div>';
145
- }
146
- }
147
- ?>
148
- <form action="" method="post" id="pf_admin">
149
- <div class="pf_box">
150
- <span>Feedback, questions, request a feature? <a href="mailto:support@printfriendly.com?subject=WordPress:"> Email PrintFriendly</a></span>
151
- <h3>Button Style</h3>
152
- <div class="pf_c">
153
- <div id="pf_buttons">
154
- <div class="buttongroup">
155
- <p><label class="preview_button">
156
- <?php echo pf_radio('pf-button.gif'); ?>
157
- </label></p>
158
- <p><label class="preview_button">
159
- <?php echo pf_radio('pf-button-big.gif'); ?>
160
- </label></p>
161
- <p><label class="preview_button">
162
- <?php echo pf_radio('pf-icon-small.gif'); ?>
163
- </label></p>
164
- </div>
165
- <div class="buttongroup">
166
- <p><label class="preview_button">
167
- <?php echo pf_radio('pf-icon.gif'); ?>
168
- </label></p>
169
- <p><label class="preview_button">
170
- <?php echo pf_radio('pf-button-both.gif'); ?>
171
- </label></p>
172
- <p><label class="preview_button">
173
- <?php echo pf_radio('pf-icon-both.gif'); ?>
174
- </label></p>
175
- </div>
176
- <div class="buttongroup larger">
177
- <p><label class="preview_button">
178
- <?php echo pf_radio('text-only'); ?> <span class="pf_tip">(text only)</span>
179
- </label></p>
180
- <p><label class="preview_button" id="pf_custom_image_label">
181
- <?php echo pf_radio('custom-image'); ?>
182
- <?php if(get_option('pf_custom_image') == false){
183
- echo '<img src="'.plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/images/noimage.png" alt="No Image"/>';
184
- } ?> <span class="pf_tip">(Custom Image)</span>
185
- </label></p>
186
- </div>
187
- </div>
188
- <div id="pf_button_options">
189
- <p>
190
- <label class="pf_label">Text Options</label>
191
- <div style="clear: both; overflow: hidden;">
192
- <div style="float:left; margin-right:5px;">
193
- <div id="colorSelector"><div style="background-color: <?php echo get_option('pf_text_color'); ?>;"></div></div>
194
- </div>
195
- <div style="float:left;">
196
- <input type="hidden" name="pf_text_color" id="pf_text_color" value="<?php echo get_option('pf_text_color'); ?>"/>
197
- <label class="pf_check"><input type="text" class="pf_px" id="pf_text_size" name="pf_text_size" value="<?php echo get_option('pf_text_size'); ?>"/><span>px <span class="pf_tip">(font size)</span></span></label>
198
- </div>
199
- </div>
200
- </p>
201
- <p>
202
- <label class="pf_label">Custom Text</label>
203
- <input type="text" name="custom_text" id="pf_custom_text" value="<?php echo get_option('pf_custom_text'); ?>"> <span class="pf_tip"> (optional, leave blank for default text)</span>
204
- </p>
205
- <p>
206
- <div id="pf_uploader">
207
- <label for="upload_image" class="pf_label">Custom Image URL: </label>
208
- <input id="upload_image" type="text" size="36" name="upload_image" value="<?php echo get_option('pf_custom_image'); ?>" />
209
- <input id="upload_image_button" type="button" value="Upload Image" class="button-primary"/>
210
- <p>Enter an URL or click "Upload Image" to Upload an Image.</p>
211
- </div>
212
- </p>
213
- </div>
214
-
215
- </div> <!-- end box c -->
216
- </div> <!-- end box -->
217
-
218
- <div class="pf_box">
219
- <h3>Button Position</h3>
220
- <div class="pf_c">
221
- <p class="pf_float">
222
- <label class="pf_label">Vertical Position</label>
223
- <label class="pf_check"><input type="radio" class="pf_content_placement" name="pf_content_placement" value="after"<?php if(get_option('pf_content_placement')==null){echo ' checked="checked"';} if(get_option('pf_show_list')=='manual'){echo ' disabled="disabled"';} ?>/><span>After Post/Page Content</span></label>
224
- <label class="pf_check"><input type="radio" class="pf_content_placement" name="pf_content_placement" value="before"<?php if(get_option('pf_content_placement')=='before'){echo ' checked="checked"';} if(get_option('pf_show_list')=='manual'){echo ' disabled="disabled"';} ?>/><span>Before Post/Page Content</span></label>
225
- </p>
226
- <p class="pf_float">
227
- <label class="pf_label">Horizontal Position</label>
228
- <label class="pf_check"><input type="radio" name="pf_content_position" value="left"<?php if(get_option('pf_content_position')==null){echo ' checked="checked"';} ?>/><span>Left</span></label>
229
- <label class="pf_check"><input type="radio" name="pf_content_position" value="center"<?php if(get_option('pf_content_position')=='center'){echo ' checked="checked"';} ?>/><span>Center</span></label>
230
- <label class="pf_check"><input type="radio" name="pf_content_position" value="right"<?php if(get_option('pf_content_position')=='right'){echo ' checked="checked"';} ?>/><span>Right</span></label>
231
- </p>
232
- <p class="pf_float">
233
- <label class="pf_label">Margin</label>
234
- <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_top" value="<?php echo pf_margin_down('top'); ?>"/><span>px Top</span></label>
235
- <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_right" value="<?php echo pf_margin_down('right'); ?>"/><span>px Right</span></label>
236
- <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_bottom" value="<?php echo pf_margin_down('bottom'); ?>"/><span>px Bottom</span></label>
237
- <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_left" value="<?php echo pf_margin_down('left'); ?>"/><span>px Left</span></label>
238
- </p>
239
- </div> <!-- end box c -->
240
- </div> <!-- end box -->
241
-
242
- <div class="pf_box">
243
- <h3>Pages</h3>
244
- <div class="pf_c">
245
- <p>
246
- <label class="pf_label">Display Button:</label>
247
- <label class="pf_check"><input type="radio" class="pf_show_list" name="pf_show_list" value="all"<?php if(get_option('pf_show_list')=='all' || get_option('pf_show_list')==null ){echo ' checked="checked"';} ?>/> <span>All Posts and Pages</span></label>
248
- <label class="pf_check"><input type="radio" class="pf_show_list" name="pf_show_list" value="single"<?php if(get_option('pf_show_list')=='single' || get_option('pf_show_list')==1){echo ' checked="checked"';} ?>/> <span>Individual Posts and Pages <span class="pf_tip">(Not on frontpage / latest posts) </span></span></label>
249
- <label class="pf_check"><input type="radio" class="pf_show_list" name="pf_show_list" value="manual"<?php if(get_option('pf_show_list')=='manual'){echo ' checked="checked"';} ?>/> <span>Manual <span class="pf_tip">(see explaination below) </span></span></label>
250
- </p>
251
- <p>
252
- PrintFriendly, by default, automatically inserts itself into your blog/site. When Manual mode is enabled this allows you to add the button wherever you like. Simply paste the following code into your template file. <br/><span class="pf_tip">WARNING: You need to know how to edit your Theme files or you might cause errors on your page.</span>
253
- <h4>Code</h4>
254
- <code style="display:block;">&lt;?php if(function_exists('pf_show_link')){echo pf_show_link();} ?&gt;</code>
255
- </p>
256
- </div> <!-- end box c -->
257
- </div> <!-- end Box -->
258
- <div style="clear:both;">
259
- <input type="submit" class="button-primary" value="Save Options" name="pf_save"/>
260
- <input type="reset" class="button-secondary" value="Cancel"/>
261
- </div>
262
- <br/><br/>
263
- </form>
264
- </div>
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ function Toggle(hide) {
3
+ document.getElementById("manual").style.display = "none";
4
+ document.getElementById("imgurl").style.display = "none";
5
+ document.getElementById(hide).style.display = "block";
6
+
7
+ }
8
+ </script>
9
+ <?php
10
+ if(isset($_POST['pf_save'])){
11
+ $error = false;
12
+ // we should always have a response, but lets still validate it for security
13
+ if($_POST['pf_button_type'] == 'pf-button.gif' || $_POST['pf_button_type'] == 'pf-button-big.gif' || $_POST['pf_button_type'] == 'pf-icon-small.gif' || $_POST['pf_button_type'] == 'pf-icon.gif' || $_POST['pf_button_type'] == 'pf-button-both.gif' || $_POST['pf_button_type'] == 'pf-icon-both.gif' || $_POST['pf_button_type'] == 'text-only' || $_POST['pf_button_type'] == 'custom-image'){
14
+ update_option('pf_button_type',$_POST['pf_button_type']);
15
+ }else{
16
+ $error[] = 'Invalid entry for the "Pick Your Button" field. That isn\'t an option to select from! Quit messing with the DOM.';
17
+ }
18
+
19
+ // custom image
20
+ if(isset($_POST['upload_image'])){
21
+ if(trim($_POST['upload_image']) == ''){
22
+ update_option('pf_custom_image',null);
23
+ }else{
24
+ $imagedata = @getimagesize($_POST['upload_image']);
25
+ if(is_array($imagedata)){
26
+ // well by golly we have an image
27
+ update_option('pf_custom_image',$_POST['upload_image']);
28
+ }else{
29
+ // we need to trigger an error
30
+ $error[] = 'Please provide a valid image link for the "Custom Image URL" field.';
31
+ }
32
+ }
33
+ }
34
+
35
+ // Custom Text
36
+ if(isset($_POST['custom_text'])){
37
+ update_option('pf_custom_text',htmlspecialchars($_POST['custom_text']) );
38
+ }
39
+
40
+ // Display custom image with custom text
41
+ if(isset($_POST['custom_both'])){
42
+ update_option('pf_custom_both',true);
43
+ }else{
44
+ update_option('pf_custom_both',null);
45
+ }
46
+
47
+ // display button
48
+ if(isset($_POST['pf_show_list'])){
49
+ if($_POST['pf_show_list']=="all" || $_POST['pf_show_list']=="single" || $_POST['pf_show_list']=="manual"){
50
+ update_option('pf_show_list',$_POST['pf_show_list']);
51
+ }else{
52
+ // something isn't right
53
+ $error[] = 'Invalid entry for the "Display Button" field. That isn\'t an option to select from! Quit messing with the DOM.';
54
+ }
55
+ }
56
+
57
+ // now on to the right side
58
+
59
+ // placement
60
+ if(isset($_POST['pf_content_placement'])){
61
+ if($_POST['pf_content_placement']=="before" || $_POST['pf_content_placement']=="after"){
62
+ if($_POST['pf_content_placement']=='before'){
63
+ update_option('pf_content_placement','before');
64
+ }else{
65
+ update_option('pf_content_placement',null);
66
+ }
67
+ }else{
68
+ // something isn't right
69
+ $error[] = 'Invalid entry for the "Placement" field. That isn\'t an option to select from! Quit messing with the DOM.';
70
+ }
71
+ }
72
+
73
+ // position
74
+ if(isset($_POST['pf_content_position'])){
75
+
76
+ if($_POST['pf_content_position']=="left" || $_POST['pf_content_position']=="right" || $_POST['pf_content_position']=="center"){
77
+ if($_POST['pf_content_position']=='left'){
78
+ update_option('pf_content_position',null);
79
+ }else{
80
+ update_option('pf_content_position',$_POST['pf_content_position']);
81
+ }
82
+ }else{
83
+ // something isn't right
84
+ $error[] = 'Invalid entry for the "Position" field. That isn\'t an option to select from! Quit messing with the DOM.';
85
+ }
86
+ }
87
+
88
+ //margin-top
89
+ if(isset($_POST['pf_margin_top'])){
90
+ if(is_numeric($_POST['pf_margin_top'])){
91
+ update_option('pf_margin_top',$_POST['pf_margin_top']);
92
+ }else{
93
+ $error[] ='The value for "Margin Top" must be a number!';
94
+ }
95
+ }
96
+ //margin-right
97
+ if(isset($_POST['pf_margin_right'])){
98
+ if(is_numeric($_POST['pf_margin_right'])){
99
+ update_option('pf_margin_right',$_POST['pf_margin_right']);
100
+ }else{
101
+ $error[] ='The value for "Margin Right" must be a number!';
102
+ }
103
+ }
104
+ //margin-bottom
105
+ if(isset($_POST['pf_margin_bottom'])){
106
+ if(is_numeric($_POST['pf_margin_bottom'])){
107
+ update_option('pf_margin_bottom',$_POST['pf_margin_bottom']);
108
+ }else{
109
+ $error[] ='The value for "Margin Bottom" must be a number!';
110
+ }
111
+ }
112
+ //margin-left
113
+ if(isset($_POST['pf_margin_left'])){
114
+ if(is_numeric($_POST['pf_margin_left'])){
115
+ update_option('pf_margin_left',$_POST['pf_margin_left']);
116
+ }else{
117
+ $error[] ='The value for "Margin Left" must be a number!';
118
+ }
119
+ }
120
+
121
+ //font color
122
+ if(isset($_POST['pf_text_color'])){
123
+ if(preg_match('/^#[a-f0-9]{6}$/i', $_POST['pf_text_color'])){
124
+ update_option('pf_text_color',$_POST['pf_text_color']);
125
+ }else{
126
+ $error[] ='The value for "Font Color" must be a valid hex code!';
127
+ }
128
+ }
129
+
130
+ //font size
131
+ if(isset($_POST['pf_text_size'])){
132
+ if(is_numeric($_POST['pf_text_size'])){
133
+ update_option('pf_text_size',$_POST['pf_text_size']);
134
+ }else{
135
+ $error[] ='The value for "Font Size" must be a number!';
136
+ }
137
+ }
138
+ }
139
+
140
+ ?>
141
+ <div class="wrap">
142
+ <h2>PrintFriendly: Settings</h2>
143
+ <?php
144
+ if(isset($error)){
145
+ if(is_array($error)){
146
+ echo '<div class="error"><strong>Settings were not saved, The following problems exist:</strong>';
147
+ foreach($error as $e){
148
+ echo '<p>'.$e.'</p>';
149
+ }
150
+ echo '</div>';
151
+ }else{
152
+ echo '<div class="updated"><p><strong>Settings saved.</strong></p></div>';
153
+ }
154
+ }
155
+ ?>
156
+ <form action="" method="post" id="pf_admin">
157
+ <div class="pf_box">
158
+ <h3>Button Style</h3>
159
+ <div class="pf_c">
160
+ <div id="pf_buttons">
161
+ <div class="buttongroup">
162
+ <p><label class="preview_button">
163
+ <?php echo pf_radio('pf-button.gif'); ?>
164
+ </label></p>
165
+ <p><label class="preview_button">
166
+ <?php echo pf_radio('pf-button-big.gif'); ?>
167
+ </label></p>
168
+ <p><label class="preview_button">
169
+ <?php echo pf_radio('pf-icon-small.gif'); ?>
170
+ </label></p>
171
+ </div>
172
+ <div class="buttongroup">
173
+ <p><label class="preview_button">
174
+ <?php echo pf_radio('pf-icon.gif'); ?>
175
+ </label></p>
176
+ <p><label class="preview_button">
177
+ <?php echo pf_radio('pf-button-both.gif'); ?>
178
+ </label></p>
179
+ <p><label class="preview_button">
180
+ <?php echo pf_radio('pf-icon-both.gif'); ?>
181
+ </label></p>
182
+ </div>
183
+ <div class="buttongroup larger">
184
+ <p><label class="preview_button">
185
+ <?php echo pf_radio('text-only'); ?> <span class="pf_tip">(text only)</span>
186
+ </label></p>
187
+ <p>
188
+ <?php echo pf_radio('custom-image'); ?> <label class="preview_button" id="pf_custom_image_label">Custom Image</label>
189
+ <div id="imgurl">Enter image URL
190
+ <input id="upload_image" type="text" size="50" name="upload_image" value="<?php echo get_option('pf_custom_image'); ?>" /></div>
191
+ </p>
192
+ </div>
193
+ </div>
194
+ <div id="pf_button_options">
195
+ <p>
196
+ <label class="pf_label">Text Options</label>
197
+ <div style="clear: both; overflow: hidden;">
198
+ <div style="float:left; margin-right:5px;">
199
+ <div id="colorSelector"><div style="background-color: <?php echo get_option('pf_text_color'); ?>;"></div></div>
200
+ </div>
201
+ <div style="float:left;">
202
+ <input type="hidden" name="pf_text_color" id="pf_text_color" value="<?php echo get_option('pf_text_color'); ?>"/>
203
+ <label class="pf_check"><input type="text" class="pf_px" id="pf_text_size" name="pf_text_size" value="<?php echo get_option('pf_text_size'); ?>"/><span>px <span class="pf_tip">(font size)</span></span></label>
204
+ </div>
205
+ </div>
206
+ </p>
207
+ <p>
208
+ <label class="pf_label">Custom Text</label>
209
+ <input type="text" name="custom_text" id="pf_custom_text" value="<?php echo get_option('pf_custom_text'); ?>"> <span class="pf_tip"> (optional, leave blank for default text)</span>
210
+ </p>
211
+ <!-- <p>
212
+ <div id="pf_uploader">
213
+ <label for="upload_image" class="pf_label">Custom Image URL: </label>
214
+
215
+ <input id="upload_image_button" type="button" value="Upload Image" class="button-primary"/>
216
+ <p>Enter an URL or click "Upload Image" to Upload an Image.</p>
217
+ </div>
218
+ </p>-->
219
+ </div>
220
+
221
+ </div> <!-- end box c -->
222
+ </div> <!-- end box -->
223
+
224
+ <div class="pf_box">
225
+ <h3>Button Position</h3>
226
+ <div class="pf_c">
227
+ <p class="pf_float">
228
+ <label class="pf_check"><input type="radio" class="pf_content_placement" name="pf_content_placement" value="after"<?php if(get_option('pf_content_placement')==null){echo ' checked="checked"';} if(get_option('pf_show_list')=='manual'){echo ' disabled="disabled"';} ?>/><span>Bottom of Page</span></label>
229
+ <label class="pf_check"><input type="radio" class="pf_content_placement" name="pf_content_placement" value="before"<?php if(get_option('pf_content_placement')=='before'){echo ' checked="checked"';} if(get_option('pf_show_list')=='manual'){echo ' disabled="disabled"';} ?>/><span>Top of Page</span></label>
230
+ </p>
231
+ <p class="pf_float">
232
+ <label class="pf_check"><input type="radio" name="pf_content_position" value="left"<?php if(get_option('pf_content_position')==null){echo ' checked="checked"';} ?>/>Left</label>
233
+ <label class="pf_check"><input type="radio" name="pf_content_position" value="center"<?php if(get_option('pf_content_position')=='center'){echo ' checked="checked"';} ?>/>Center</label>
234
+ <label class="pf_check"><input type="radio" name="pf_content_position" value="right"<?php if(get_option('pf_content_position')=='right'){echo ' checked="checked"';} ?>/>Right</label>
235
+ </p>
236
+ <p class="pf_float">
237
+ <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_top" value="<?php echo pf_margin_down('top'); ?>"/>px Top Margin</label>
238
+ <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_right" value="<?php echo pf_margin_down('right'); ?>"/>px Right Margin</label>
239
+ <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_bottom" value="<?php echo pf_margin_down('bottom'); ?>"/>px Bottom Margin</label>
240
+ <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_left" value="<?php echo pf_margin_down('left'); ?>"/>px Left Margin</label>
241
+ </p>
242
+ </div> <!-- end box c -->
243
+ </div> <!-- end box -->
244
+
245
+ <div class="pf_box">
246
+ <h3>Pages</h3>
247
+ <div class="pf_c">
248
+ <p>
249
+ <label class="pf_label">Select the pages you would like to add PrintFriendly button.</label>
250
+ <label class="pf_check">
251
+ <input type="radio" class="pf_show_list" name="pf_show_list" value="all" onclick="Toggle('hide');"<?php if(get_option('pf_show_list')=='all' || get_option('pf_show_list')==null ){echo ' checked="checked"';} ?>/> <span>All Posts and Pages</span></label>
252
+ <label class="pf_check">
253
+ <input type="radio" class="pf_show_list" name="pf_show_list" value="single" onclick="Toggle('hide');"<?php if(get_option('pf_show_list')=='single' || get_option('pf_show_list')==1){echo ' checked="checked"';} ?>/> <span>Individual Posts and Pages <span class="pf_tip">(Not on frontpage / latest posts) </span></span></label>
254
+ <label class="pf_check"><input type="radio" class="pf_show_list" name="pf_show_list" value="manual" onclick="Toggle('manual');"<?php if(get_option('pf_show_list')=='manual'){echo ' checked="checked"';} ?>/> <span>Manual <span class="pf_tip">(for WordPress Pros) </span></span></label>
255
+ </p>
256
+
257
+
258
+
259
+ <div id="manual">
260
+ <p>PrintFriendly, by default, automatically inserts itself into your blog/site. When Manual mode is enabled this allows you to add the button wherever you like. Simply paste the following code into your template file. You need to know how to edit your Theme files or you might cause errors on your page.
261
+ <h4>Code</h4>
262
+ <code style="display:block;">&lt;?php if(function_exists('pf_show_link')){echo pf_show_link();} ?&gt;</code>
263
+ </div>
264
+ </div> <!-- end box c -->
265
+ </div> <!-- end Box -->
266
+ <div style="clear:both;">
267
+ <input type="submit" class="button-primary" value="Save Options" name="pf_save"/>
268
+ <input type="reset" class="button-secondary" value="Cancel"/>
269
+ </div>
270
+ <br/><br/>
271
+ </form>
272
+ </div>
readme.txt CHANGED
@@ -1,29 +1,46 @@
1
  === Print Friendly &amp; PDF Button===
2
  Contributors: printfriendly
3
- Tags: print, printer, pdf, version, button
4
  Requires at least: 1.5
5
- Stable tag: 2.0
6
 
7
- Add the Print Friendly button to your WordPress site. Get beautiful print versions of your site, and help readers save paper and ink.
8
-
9
- Print Friendly cleans and optimizes your pages and lets readers get PDF versions too.
10
 
11
  == Description ==
12
 
13
- Add the Print Friendly button to your WordPress site. Get beautiful print versions of your site, and help readers save paper and ink.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- Features:
16
- - Automatically creates a print.css for your site
17
- - Customize the button
18
- - Users can remove images, content, and save as PDF.
19
 
20
 
21
  == Installation ==
22
 
23
  1. Download the printfriendly.zip file and unzip it.
24
- 2. Move the resulting folder into wp-content/plugins folder your wordpress install
25
  3. Activate the plugin in your Wordpress Admin area.
26
- 4. Choose your button style in the plugin settings area.
27
 
28
  == Support ==
29
 
1
  === Print Friendly &amp; PDF Button===
2
  Contributors: printfriendly
3
+ Tags: print, pdf, printer, printing, printable
4
  Requires at least: 1.5
5
+ Stable tag: trunk
6
 
7
+ #1 Print and PDF button for your wp site. Printer Friendly pages without coding, css, or print.css. Fast, easy, and professional.
 
 
8
 
9
  == Description ==
10
 
11
+ The Print Friendly & PDF button saves paper and ink when printing or creating a PDF. It's fast, easy, and looks great when printed. Add the button now, and you're users will see the difference.
12
+
13
+ ##How Pint Friendly & PDF Works
14
+
15
+ The Print Friendly & PDF button automatically creates printer friendly and PDF versions of your pages without the hassle of CSS or Print.CSS. No coding, hacking or programming required. Simply install the Print Friendly & PDF plugin, activate, and choose settings for full customization.
16
+
17
+ ##Cool Features For You:
18
+ * Get a Printer Friendly and PDF button for your users.
19
+ * Fully Customizable! Choose your favorite print and PDF button, use a text link, or use your own graphic.
20
+ * Get precision placement with easy to change margins, alignment, and pages for your Print and PDF button.
21
+ * On-Page-Lightbox. Have you noticed that most printer friendly buttons open new windows, or tabs? Not with Print Friendly & PDF button. It opens in a Lightbox so you your users stay on the page, and your wp website.
22
+ * Professional looking print and PDF buttons and user experience.
23
+ * More repeats and new users. Your brand/URL are printed on the page or saved in the PDF so users remember your site, or new users can find you.
24
+
25
+ ##Cool Print Features for Users:
26
+ * Optimizes pages for printing and PDF so you save money and the environment.
27
+ * You can Print or get a PDF
28
+ * Edit the page before printing or getting a PDF
29
+
30
+ ##[Get PrintFriendly & PDF Now](http://downloads.wordpress.org/plugin/printfriendly.zip "Download PrintFriendly & PDF")
31
+
32
+ PrintFriendly and PDF is the #1 print optimization technology, **featured in [Lifehacker](http://lifehacker.com/5272212/print-friendly-optimizes-web-pages-for-printing "PrintFriendly & PDF in Lifehacker"), [Mashable](http://mashable.com/2009/05/18/print-friendly/ "PrintFriendly & PDF in Mashable"), [makeuseof](http://www.makeuseof.com/dir/printfriendly-save-on-paper-and-ink/#comment-95052)**.
33
+
34
+ **Give PrintFriendly & PDF a test drive at [PrintFriendly.com](http://www.printfriendly.com "PrintFriendly & PDF")**
35
 
 
 
 
 
36
 
37
 
38
  == Installation ==
39
 
40
  1. Download the printfriendly.zip file and unzip it.
41
+ 2. Move the printfriendly folder into wp-content/plugins folder
42
  3. Activate the plugin in your Wordpress Admin area.
43
+ 4. Select "Settings" to customize button style and placement.
44
 
45
  == Support ==
46