Print, PDF, Email by PrintFriendly - Version 3.2.2

Version Description

  • Add printfriendly post_class.
  • Add printfriendly button display settings per individual category.
  • Fixed minor JS bug.
  • Added redundancy to uninstall script.
Download this release

Release Info

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

Code changes from version 3.2.0 to 3.2.2

Files changed (6) hide show
  1. admin.css +339 -312
  2. admin.js +93 -0
  3. pf.php +203 -56
  4. readme.txt +13 -3
  5. screenshot-2.png +0 -0
  6. uninstall.php +17 -2
admin.css CHANGED
@@ -1,319 +1,346 @@
1
- label{
2
- display: block;
3
- margin: 1.5em 0;
4
- }
5
-
6
- h3{
7
- margin: 3em 0 2em;
8
- border-bottom: 1px solid #ccc;
9
- padding-bottom:.75em;
10
- clear: both;
11
- }
12
-
13
- #buttongroup1, #buttongroup2, #buttongroup3, #custom-txt div, #button-placement div{
14
- display: block;
15
- margin-right: 3em;
16
- float: left;
17
- }
18
- #custom-txt div#txt-size, div#button-placement-options{
19
- margin-right: 0;
20
- }
21
- #custom-button-preview {
22
- clear:both;
23
- padding-top: 20px;
24
- margin-left: 2em;
25
- }
26
- #custom-button-preview img{
27
- margin-right: 6px;
28
- }
29
- #custom, #placement-adv-options{
30
- float: left;
31
- }
32
-
33
- #custom-txt, #custom-img {
34
- margin: 2em 0 2em 2em;
35
- clear: both;
36
- }
37
-
38
- .description{
39
- color: #cacaca;
40
- }
41
- .printfriendly-text2{
42
- font-family: verdana;
43
- font-size: 14px;
44
- color: #6D9F00;
45
- }
46
- select{
47
- display: block;
48
- margin: .5em .5em 2em 0;
49
- }
50
- select#javascript, select#website_protocol{
51
- display: inline-block;
52
- margin-bottom: 0;
53
- }
54
- input[type="radio"], input[type="checkbox"] {
55
- cursor: pointer;
56
- margin-right: 10px;
57
- vertical-align: middle;
58
- }
59
-
60
-
61
- /* WP lacks styling for type="number", so in here for now */
62
- input[type="number"] {
63
- border-color: #DFDFDF;
64
- background-color: white;
65
- border-width: 1px;
66
- border-style: solid;
67
- -moz-border-radius: 3px;
68
- -khtml-border-radius: 3px;
69
- -webkit-border-radius: 3px;
70
- border-radius: 3px;
71
- -moz-box-sizing: border-box;
72
- -webkit-box-sizing: border-box;
73
- -ms-box-sizing: border-box;
74
- box-sizing: border-box;
75
- width: 36px;
76
- margin-right: .5em;
77
- }
78
- #css{
79
- font-size: 11px;
80
- color:#bbb;
81
- }
82
- #css input{
83
- margin: 0 6px 0 12px;
84
- vertical-align: baseline;
85
- }
86
- #pf-shortcode{
87
-
88
- margin-left: 2em;
89
- }
90
- .custom-logo label, .custom-logo input, #pf-favicon {
91
- display: inline-block;
92
- }
93
-
94
- .custom-logo input {
95
- width: 20em;
96
- }
97
-
98
- .custom-logo label {
99
- margin-left: 5px;
100
- margin-right: 2px;
101
- }
102
-
103
- label#pf-favicon {
104
- vertical-align: baseline;
105
- margin: 0;
106
- }
107
-
108
- .printfriendly-details input {
109
- width: 20em;
110
- }
111
-
112
- .printfriendly-details label {
113
- margin-left: 5px;
114
- margin-right: 2px;
115
- }
116
-
117
- .icon32 {
118
- background: url(images/pf-icon.png) center center no-repeat;
119
- }
120
-
121
- #after-submit{
122
- border-top: 2px dashed #dfdfdf;
123
- margin:4em 0;
124
- padding-top:1em;
125
- }
126
- #addmanual-help {
127
- display: none;
128
- }
129
-
130
- #colorSelector {
131
- position: relative;
 
 
 
 
 
 
132
  width: 36px;
133
  height: 36px;
134
- background: url(images/select2.png);
135
- display: inline-block;
136
- cursor: pointer;
137
- }
138
-
139
- #colorSelector div {
140
  position: absolute;
141
  top: 4px;
142
  left: 4px;
143
  width: 28px;
144
  height: 28px;
145
- background: url(images/select2.png) center;
146
- }
147
-
148
- .colorpicker {
149
- width: 356px;
150
- height: 176px;
151
- overflow: hidden;
152
- position: absolute;
153
- background: url(images/custom_background.png);
154
- font-family: Arial, Helvetica, sans-serif;
155
- display: none;
156
- }
157
-
158
- .colorpicker_color {
159
- width: 150px;
160
- height: 150px;
161
- left: 14px;
162
- top: 13px;
163
- position: absolute;
164
- background: #f00;
165
- overflow: hidden;
166
- cursor: crosshair;
167
- }
168
-
169
- .colorpicker_color div {
170
- position: absolute;
171
- top: 0;
172
- left: 0;
173
- width: 150px;
174
- height: 150px;
175
- background: url(images/colorpicker_overlay.png);
176
- }
177
-
178
- .colorpicker_color div div {
179
- position: absolute;
180
- top: 0;
181
- left: 0;
182
- width: 11px;
183
- height: 11px;
184
- overflow: hidden;
185
- background: url(images/colorpicker_select.gif);
186
- margin: -5px 0 0 -5px;
187
- }
188
-
189
- .colorpicker_hue {
190
- position: absolute;
191
- top: 13px;
192
- left: 171px;
193
- width: 35px;
194
- height: 150px;
195
- cursor: n-resize;
196
- }
197
-
198
- .colorpicker_hue div {
199
- position: absolute;
200
- width: 35px;
201
- height: 9px;
202
- overflow: hidden;
203
- background: url(images/custom_indic.gif) left top;
204
- margin: -4px 0 0 0;
205
- left: 0px;
206
- }
207
-
208
- .colorpicker_new_color {
209
- position: absolute;
210
- width: 60px;
211
- height: 30px;
212
- left: 213px;
213
- top: 13px;
214
- background: #f00;
215
- }
216
-
217
- .colorpicker_current_color {
218
- position: absolute;
219
- width: 60px;
220
- height: 30px;
221
- left: 283px;
222
- top: 13px;
223
- background: #f00;
224
- }
225
-
226
- .colorpicker input {
227
- background-color: transparent;
228
- border: 1px solid transparent !important;
229
- position: absolute;
230
- font-size: 10px;
231
- font-family: Arial, Helvetica, sans-serif;
232
- color: #778398;
233
- top: 4px;
234
- right: 11px;
235
- text-align: right;
236
- margin: 0;
237
- padding: 0 !important;
238
- height: 11px;
239
- line-height: 11px;
240
- outline: none;
241
- }
242
-
243
- .colorpicker_hex {
244
- position: absolute;
245
- width: 72px;
246
- height: 22px;
247
- background: url(images/custom_hex.png) top;
248
- left: 212px;
249
- top: 142px;
250
- }
251
-
252
- .colorpicker_hex input {
253
- right: 6px;
254
- }
255
-
256
- .colorpicker_field {
257
- height: 22px;
258
- width: 62px;
259
- background-position: top;
260
- position: absolute;
261
- }
262
-
263
- .colorpicker_field span {
264
- position: absolute;
265
- width: 12px;
266
- height: 22px;
267
- overflow: hidden;
268
- top: 0;
269
- right: 0;
270
- cursor: n-resize;
271
- }
272
-
273
- .colorpicker_rgb_r {
274
- background-image: url(images/custom_rgb_r.png);
275
- top: 52px;
276
- left: 212px;
277
- }
278
-
279
- .colorpicker_rgb_g {
280
- background-image: url(images/custom_rgb_g.png);
281
- top: 82px;
282
- left: 212px;
283
- }
284
-
285
- .colorpicker_rgb_b {
286
- background-image: url(images/custom_rgb_b.png);
287
- top: 112px;
288
- left: 212px;
289
- }
290
-
291
- .colorpicker_hsb_h, .colorpicker_hsb_s, .colorpicker_hsb_b {
292
- display: none;
293
- }
294
-
295
- .colorpicker_submit {
296
- position: absolute;
297
- width: 22px;
298
- height: 22px;
299
- background: url(images/custom_submit.png) top;
300
- left: 322px;
301
- top: 142px;
302
- overflow: hidden;
303
- }
304
-
305
- .colorpicker_focus {
306
- background-position: center;
307
- }
308
-
309
- .colorpicker_hex.colorpicker_focus {
310
- background-position: bottom;
311
- }
312
-
313
- .colorpicker_submit.colorpicker_focus {
314
- background-position: bottom;
315
- }
316
-
317
- .colorpicker_slider {
318
- background-position: bottom;
319
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ label {
2
+ display: block;
3
+ margin: 1.5em 0;
4
+ }
5
+
6
+ h3 {
7
+ margin: 3em 0 2em;
8
+ border-bottom: 1px solid #ccc;
9
+ padding-bottom:.75em;
10
+ clear: both;
11
+ }
12
+
13
+ h3.hndle {
14
+ clear:none;
15
+ padding: 7px 5px;
16
+ }
17
+
18
+ #buttongroup1, #buttongroup2, #buttongroup3, #custom-txt div, #button-positioning div, #button-placement div {
19
+ display: block;
20
+ margin-right: 3em;
21
+ float: left;
22
+ }
23
+ #custom-txt div#txt-size, div#button-positioning-options {
24
+ margin-right: 0;
25
+ }
26
+
27
+ #custom-button-preview {
28
+ clear:both;
29
+ padding-top: 20px;
30
+ margin-left: 2em;
31
+ }
32
+ #custom-button-preview img {
33
+ margin-right: 6px;
34
+ }
35
+ #custom, #placement-adv-options {
36
+ float: left;
37
+ }
38
+
39
+ #custom-txt, #custom-img {
40
+ margin: 2em 0 2em 2em;
41
+ clear: both;
42
+ }
43
+
44
+ .description {
45
+ color: #cacaca;
46
+ }
47
+ .printfriendly-text2 {
48
+ font-family: verdana;
49
+ font-size: 14px;
50
+ color: #6D9F00;
51
+ }
52
+ select{
53
+ display: block;
54
+ margin: .5em .5em 2em 0;
55
+ }
56
+ select#javascript, select#website_protocol {
57
+ display: inline-block;
58
+ margin-bottom: 0;
59
+ }
60
+ input[type="radio"], input[type="checkbox"] {
61
+ cursor: pointer;
62
+ margin-right: 10px;
63
+ vertical-align: middle;
64
+ }
65
+
66
+
67
+ /* WP lacks styling for type="number", so in here for now */
68
+ input[type="number"] {
69
+ border-color: #DFDFDF;
70
+ background-color: white;
71
+ border-width: 1px;
72
+ border-style: solid;
73
+ -moz-border-radius: 3px;
74
+ -khtml-border-radius: 3px;
75
+ -webkit-border-radius: 3px;
76
+ border-radius: 3px;
77
+ -moz-box-sizing: border-box;
78
+ -webkit-box-sizing: border-box;
79
+ -ms-box-sizing: border-box;
80
+ box-sizing: border-box;
81
+ width: 36px;
82
+ margin-right: .5em;
83
+ }
84
+ #css {
85
+ font-size: 11px;
86
+ color:#bbb;
87
+ }
88
+ #css input {
89
+ margin: 0 6px 0 12px;
90
+ vertical-align: baseline;
91
+ }
92
+ #pf-shortcode {
93
+
94
+ margin-left: 2em;
95
+ }
96
+ .custom-logo label, .custom-logo input, #pf-favicon {
97
+ display: inline-block;
98
+ }
99
+
100
+ .custom-logo input {
101
+ width: 20em;
102
+ }
103
+
104
+ .custom-logo label {
105
+ margin-left: 5px;
106
+ margin-right: 2px;
107
+ }
108
+
109
+ label#pf-favicon {
110
+ vertical-align: baseline;
111
+ margin: 0;
112
+ }
113
+
114
+ .printfriendly-details input {
115
+ width: 20em;
116
+ }
117
+
118
+ .printfriendly-details label {
119
+ margin-left: 5px;
120
+ margin-right: 2px;
121
+ }
122
+
123
+ .icon32 {
124
+ background: url(images/pf-icon.png) center center no-repeat;
125
+ }
126
+
127
+ #after-submit {
128
+ border-top: 2px dashed #dfdfdf;
129
+ margin:4em 0;
130
+ padding-top:1em;
131
+ }
132
+ #addmanual-help {
133
+ display: none;
134
+ }
135
+
136
+ #colorSelector {
137
+ position: relative;
138
  width: 36px;
139
  height: 36px;
140
+ background: url(images/select2.png);
141
+ display: inline-block;
142
+ cursor: pointer;
143
+ }
144
+
145
+ #colorSelector div {
146
  position: absolute;
147
  top: 4px;
148
  left: 4px;
149
  width: 28px;
150
  height: 28px;
151
+ background: url(images/select2.png) center;
152
+ }
153
+
154
+ .colorpicker {
155
+ width: 356px;
156
+ height: 176px;
157
+ overflow: hidden;
158
+ position: absolute;
159
+ background: url(images/custom_background.png);
160
+ font-family: Arial, Helvetica, sans-serif;
161
+ display: none;
162
+ }
163
+
164
+ .colorpicker_color {
165
+ width: 150px;
166
+ height: 150px;
167
+ left: 14px;
168
+ top: 13px;
169
+ position: absolute;
170
+ background: #f00;
171
+ overflow: hidden;
172
+ cursor: crosshair;
173
+ }
174
+
175
+ .colorpicker_color div {
176
+ position: absolute;
177
+ top: 0;
178
+ left: 0;
179
+ width: 150px;
180
+ height: 150px;
181
+ background: url(images/colorpicker_overlay.png);
182
+ }
183
+
184
+ .colorpicker_color div div {
185
+ position: absolute;
186
+ top: 0;
187
+ left: 0;
188
+ width: 11px;
189
+ height: 11px;
190
+ overflow: hidden;
191
+ background: url(images/colorpicker_select.gif);
192
+ margin: -5px 0 0 -5px;
193
+ }
194
+
195
+ .colorpicker_hue {
196
+ position: absolute;
197
+ top: 13px;
198
+ left: 171px;
199
+ width: 35px;
200
+ height: 150px;
201
+ cursor: n-resize;
202
+ }
203
+
204
+ .colorpicker_hue div {
205
+ position: absolute;
206
+ width: 35px;
207
+ height: 9px;
208
+ overflow: hidden;
209
+ background: url(images/custom_indic.gif) left top;
210
+ margin: -4px 0 0 0;
211
+ left: 0px;
212
+ }
213
+
214
+ .colorpicker_new_color {
215
+ position: absolute;
216
+ width: 60px;
217
+ height: 30px;
218
+ left: 213px;
219
+ top: 13px;
220
+ background: #f00;
221
+ }
222
+
223
+ .colorpicker_current_color {
224
+ position: absolute;
225
+ width: 60px;
226
+ height: 30px;
227
+ left: 283px;
228
+ top: 13px;
229
+ background: #f00;
230
+ }
231
+
232
+ .colorpicker input {
233
+ background-color: transparent;
234
+ border: 1px solid transparent !important;
235
+ position: absolute;
236
+ font-size: 10px;
237
+ font-family: Arial, Helvetica, sans-serif;
238
+ color: #778398;
239
+ top: 4px;
240
+ right: 11px;
241
+ text-align: right;
242
+ margin: 0;
243
+ padding: 0 !important;
244
+ height: 11px;
245
+ line-height: 11px;
246
+ outline: none;
247
+ }
248
+
249
+ .colorpicker_hex {
250
+ position: absolute;
251
+ width: 72px;
252
+ height: 22px;
253
+ background: url(images/custom_hex.png) top;
254
+ left: 212px;
255
+ top: 142px;
256
+ }
257
+
258
+ .colorpicker_hex input {
259
+ right: 6px;
260
+ }
261
+
262
+ .colorpicker_field {
263
+ height: 22px;
264
+ width: 62px;
265
+ background-position: top;
266
+ position: absolute;
267
+ }
268
+
269
+ .colorpicker_field span {
270
+ position: absolute;
271
+ width: 12px;
272
+ height: 22px;
273
+ overflow: hidden;
274
+ top: 0;
275
+ right: 0;
276
+ cursor: n-resize;
277
+ }
278
+
279
+ .colorpicker_rgb_r {
280
+ background-image: url(images/custom_rgb_r.png);
281
+ top: 52px;
282
+ left: 212px;
283
+ }
284
+
285
+ .colorpicker_rgb_g {
286
+ background-image: url(images/custom_rgb_g.png);
287
+ top: 82px;
288
+ left: 212px;
289
+ }
290
+
291
+ .colorpicker_rgb_b {
292
+ background-image: url(images/custom_rgb_b.png);
293
+ top: 112px;
294
+ left: 212px;
295
+ }
296
+
297
+ .colorpicker_hsb_h, .colorpicker_hsb_s, .colorpicker_hsb_b {
298
+ display: none;
299
+ }
300
+
301
+ .colorpicker_submit {
302
+ position: absolute;
303
+ width: 22px;
304
+ height: 22px;
305
+ background: url(images/custom_submit.png) top;
306
+ left: 322px;
307
+ top: 142px;
308
+ overflow: hidden;
309
+ }
310
+
311
+ .colorpicker_focus {
312
+ background-position: center;
313
+ }
314
+
315
+ .colorpicker_hex.colorpicker_focus {
316
+ background-position: bottom;
317
+ }
318
+
319
+ .colorpicker_submit.colorpicker_focus {
320
+ background-position: bottom;
321
+ }
322
+
323
+ .colorpicker_slider {
324
+ background-position: bottom;
325
+ }
326
+
327
+ #button-placement div#pages label {
328
+ clear: left;
329
+ }
330
+
331
+ div#category-adder {
332
+ float: none;
333
+ }
334
+
335
+ #pf-categories {
336
+ display: none;
337
+ float: left;
338
+ position: relative;
339
+ top: 1.5em;
340
+ left: -50px;
341
+ width: 270px;
342
+ }
343
+
344
+ #pf-categories-metabox, #category-adder {
345
+ display: none;
346
+ }
admin.js CHANGED
@@ -4,12 +4,57 @@ jQuery(document).ready(function() {
4
  if (jQuery('.show_list:checked').length == 0) {
5
  jQuery('.content_placement').hide('slow');
6
  jQuery('.content_placement input').attr('disabled','disabled');
 
7
  } else {
 
8
  jQuery('.content_placement').show('slow');
9
  jQuery('.content_placement input').removeAttr('disabled');
10
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }).change();
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  jQuery('#colorSelector').ColorPicker({
14
  color: jQuery('#text_color').val(),
15
  onShow: function (colpkr) {
@@ -158,4 +203,52 @@ jQuery(document).ready(function() {
158
  jQuery('.printfriendly-text2').css('font-size',parseInt(size));
159
  }
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  });
4
  if (jQuery('.show_list:checked').length == 0) {
5
  jQuery('.content_placement').hide('slow');
6
  jQuery('.content_placement input').attr('disabled','disabled');
7
+ jQuery('.show_template').attr('checked', 'checked');
8
  } else {
9
+ jQuery('.show_template').attr('checked', false);
10
  jQuery('.content_placement').show('slow');
11
  jQuery('.content_placement input').removeAttr('disabled');
12
  }
13
+
14
+ var postName = 'printfriendly_option[show_on_posts]';
15
+ var homeName = 'printfriendly_option[show_on_homepage]';
16
+
17
+ var optionName = jQuery(this).attr('name');
18
+ if (optionName == homeName || optionName == postName){
19
+ if(jQuery(this).is(':checked')) {
20
+ jQuery('#pf-categories').show('slow');
21
+ } else if(!jQuery('input[name="' + homeName + '"]').is(':checked')
22
+ && !jQuery('input[name="' + postName + '"]').is(':checked')) {
23
+ jQuery('#pf-categories').hide('slow');
24
+ }
25
+ }
26
  }).change();
27
 
28
+ jQuery('.show_template').change(function() {
29
+ if(jQuery(this).is(':checked')) {
30
+ jQuery('.show_list').attr('checked', false);
31
+ jQuery('.show_list').attr('disabled', 'disabled');
32
+ jQuery('.content_placement').hide('slow');
33
+ jQuery('.content_placement input').attr('disabled','disabled');
34
+ jQuery('#pf-categories-metabox').hide('slow');
35
+ } else {
36
+ jQuery('.show_list').removeAttr('disabled');
37
+ jQuery('.content_placement').show('slow');
38
+ jQuery('.content_placement input').removeAttr('disabled');
39
+ }
40
+ }).change();
41
+
42
+ jQuery('#toggle-categories').click(function() {
43
+ if(jQuery('#pf-categories-metabox').is(':visible')) {
44
+ jQuery('#pf-categories-metabox').hide('slow');
45
+ } else {
46
+ jQuery('#pf-categories-metabox').show('slow');
47
+ }
48
+ });
49
+
50
+ jQuery(document).mouseup(function (e) {
51
+ var container = jQuery("#pf-categories");
52
+
53
+ if (container.has(e.target).length === 0) {
54
+ jQuery('#pf-categories-metabox').hide('slow');
55
+ }
56
+ });
57
+
58
  jQuery('#colorSelector').ColorPicker({
59
  color: jQuery('#text_color').val(),
60
  onShow: function (colpkr) {
203
  jQuery('.printfriendly-text2').css('font-size',parseInt(size));
204
  }
205
 
206
+ // postboxes setup
207
+ jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
208
+
209
+ // categories checkboxes
210
+ var category_ids = jQuery('#category_ids').val().split(',');
211
+ if(category_ids[0] == 'all') {
212
+ var ids = [];
213
+ jQuery('#categorydiv :checkbox').each(function() {
214
+ jQuery(this).attr('checked', 'checked');
215
+ });
216
+ jQuery('#category-all :checkbox').each(function() {
217
+ ids.push(jQuery(this).val());
218
+ });
219
+ // for older wp versions we do not have per category settings so
220
+ // ids array will be empty and in that case we shouldn't replace 'all'
221
+ if(ids.length != 0) {
222
+ jQuery('#category_ids').val(ids.join(','));
223
+ }
224
+ } else {
225
+
226
+ jQuery('#categorydiv :checkbox').each(function() {
227
+ if(jQuery.inArray(jQuery(this).val(), category_ids) != -1) {
228
+ jQuery(this).attr('checked', 'checked');
229
+ }
230
+ });
231
+ }
232
+
233
+ jQuery('#categorydiv :checkbox').click(function() {
234
+ var values = jQuery('#category_ids').val();
235
+ var ids = [];
236
+ if(values != '')
237
+ ids = values.split(',');
238
+
239
+ var id = jQuery(this).val();
240
+
241
+ if(jQuery(this).is(':checked'))
242
+ ids.push(id);
243
+ else {
244
+ ids = jQuery.grep(ids, function(value) {
245
+ return value != id;
246
+ });
247
+ }
248
+
249
+ jQuery('#category_ids').val(ids.join(','));
250
+ });
251
+
252
+ // page checkboxes TODO...
253
+
254
  });
pf.php CHANGED
@@ -1,14 +1,17 @@
1
  <?php
 
2
  /*
3
  Plugin Name: Print Friendly and PDF
4
  Plugin URI: http://www.printfriendly.com
5
  Description: PrintFriendly & PDF button for your website. Optimizes your pages and brand for print, pdf, and email.
6
  Name and URL are included to ensure repeat visitors and new visitors when printed versions are shared.
7
- Version: 3.2.0
8
  Author: Print Friendly
9
  Author URI: http://www.PrintFriendly.com
10
 
11
  Changelog :
 
 
12
  3.2.0 - Important chrome issue fix. Ie syntax error fix.
13
  3.1.9 - Minor css detail.
14
  3.1.8 - Add printfriendly options to allow/not allow print, pdf, email from the Printfriendly and PDF dialog.
@@ -81,7 +84,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
81
  * Database version, used to allow for easy upgrades to / additions in plugin options between plugin versions.
82
  * @var int
83
  */
84
- var $db_version = 4;
85
 
86
  /**
87
  * Settings page, used within the plugin to reliably load the plugins admin JS and CSS files only on the admin page.
@@ -115,24 +118,28 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
115
  add_filter( 'the_excerpt', array( &$this, 'show_link' ) );
116
  }
117
 
118
- if ( !is_admin() )
119
- return;
120
 
121
- // Hook into init for registration of the option and the language files
122
- add_action( 'admin_init', array( &$this, 'init' ) );
 
123
 
124
- // Register the settings page
125
- add_action( 'admin_menu', array( &$this, 'add_config_page' ) );
 
 
126
 
127
- // Register the contextual help
128
- add_filter( 'contextual_help', array( &$this, 'contextual_help' ), 10, 2 );
129
 
130
- // Enqueue the needed scripts and styles
131
- add_action( 'admin_enqueue_scripts',array( &$this, 'admin_enqueue_scripts' ) );
132
 
133
- // Register a link to the settings page on the plugins overview page
134
- add_filter( 'plugin_action_links', array( &$this, 'filter_plugin_actions' ), 10, 2 );
135
 
 
 
 
136
  }
137
 
138
  /**
@@ -154,10 +161,11 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
154
  if ( isset( $this->options['enable_css'] ) && $this->options['enable_css'] != 'on' )
155
  return;
156
 
 
157
  ?>
158
  <style type="text/css" media="screen">
159
  div.printfriendly {
160
- margin: <?php echo $this->options['margin_top'].'px '.$this->options['margin_right'].'px '.$this->options['margin_bottom'].'px '.$this->options['margin_left'].'px'; ?>;
161
  }
162
  div.printfriendly a, div.printfriendly a:link, div.printfriendly a:visited {
163
  text-decoration: none;
@@ -204,6 +212,18 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
204
  <?php
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  /**
208
  * Prints the PrintFriendly JavaScript, in the footer, and loads it asynchronously.
209
  *
@@ -222,7 +242,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
222
  }
223
 
224
  // Currently we use v3 for both: normal and password protected sites
225
- $pf_src = '//cdn.printfriendly.com/printfriendly.js';
226
  if($this->options['website_protocol'] == 'https')
227
  $pf_src = 'https://pf-cdn.printfriendly.com/ssl/main.js';
228
 
@@ -239,7 +259,6 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
239
 
240
  // PrintFriendly
241
  var e = document.createElement('script'); e.type="text/javascript";
242
- e.async = true;
243
  e.src = '<?php echo $pf_src ?>';
244
  document.getElementsByTagName('head')[0].appendChild(e);
245
  </script>
@@ -285,11 +304,11 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
285
  }
286
  else
287
  {
288
- if ( (is_page() && isset($this->options['show_on_pages']))
289
- || (is_home() && isset($this->options['show_on_homepage']))
290
- || (is_tax() && isset($this->options['show_on_taxonomies']))
291
- || (is_category() && isset($this->options['show_on_categories']))
292
- || (is_single() && isset($this->options['show_on_posts'])) )
293
  {
294
  // Hook the script call now, so it only get's loaded when needed, and need is determined by the user calling pf_button
295
  add_action( 'wp_footer', array( &$this, 'print_script_footer' ) );
@@ -308,6 +327,17 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
308
 
309
  }
310
 
 
 
 
 
 
 
 
 
 
 
 
311
  /**
312
  * Register the textdomain and the options array along with the validation function
313
  *
@@ -331,8 +361,29 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
331
  function options_validate( $input ) {
332
  $valid_input = $input;
333
 
334
- // echo '<pre>'.print_r($input,1).'</pre>';
335
- // die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
 
337
  if ( !in_array( $input['button_type'], array( 'pf-button.gif', 'button-print-grnw20.png', 'button-print-blu20.png', 'button-print-gry20.png', 'button-print-whgn20.png', 'pf_button_sq_gry_m.png', 'pf_button_sq_gry_l.png', 'pf_button_sq_grn_m.png', 'pf_button_sq_grn_l.png', 'pf-button-big.gif', 'pf-icon-small.gif', 'pf-icon.gif', 'pf-button-both.gif', 'pf-icon-both.gif', 'text-only', 'custom-image') ) )
338
  $valid_input['button_type'] = 'pf-button.gif';
@@ -378,6 +429,9 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
378
  */
379
  function add_config_page() {
380
  $this->settings_page = add_options_page( __( 'PrintFriendly Options', $this->hook ), __( 'Print Friendly & PDF', $this->hook ), 'manage_options', $this->hook, array( &$this, 'config_page' ) );
 
 
 
381
  }
382
 
383
  /**
@@ -401,13 +455,14 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
401
  */
402
  function admin_enqueue_scripts( $screen_id ) {
403
  if ( $this->settings_page == $screen_id ) {
404
- $ver = '3.2.0';
405
  wp_register_script( 'pf-color-picker', plugins_url( 'colorpicker.js', __FILE__ ), array( 'jquery', 'media-upload' ), $ver );
406
  wp_register_script( 'pf-admin-js', plugins_url( 'admin.js', __FILE__ ), array( 'jquery', 'media-upload' ), $ver );
407
 
408
  wp_enqueue_script( 'pf-color-picker' );
409
  wp_enqueue_script( 'pf-admin-js' );
410
 
 
411
  wp_enqueue_style( 'printfriendly-admin-css', plugins_url( 'admin.css', __FILE__ ), array(), $ver);
412
  }
413
  }
@@ -465,6 +520,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
465
  'password_protected' => 'no',
466
  'javascript' => 'yes',
467
  'custom_css_url' => '',
 
468
  );
469
 
470
  // Check whether the old badly named singular options are there, if so, use the data and delete them.
@@ -518,7 +574,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
518
  // check whether image we do not list any more was used
519
  if(in_array($this->options['button_type'], array('button-print-whgn20.png', 'pf_button_sq_qry_m.png', 'pf_button_sq_qry_l.png', 'pf_button_sq_grn_m.png', 'pf_button_sq_grn_l.png'))) {
520
  // previous version had a bug with button name
521
- if(in_array($this->options['button_type'], array('pf_button_sq_qry_m.png', 'pf_button_sq_qry_l.png')))
522
  $this->options['button_type'] = str_replace('qry', 'gry', $this->options['button_type']);
523
 
524
  $image_address = '//cdn.printfriendly.com/'.$this->options['button_type'];
@@ -577,6 +633,19 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
577
  $this->options = array_merge($this->options, $additional_options);
578
  }
579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
  $this->options['db_version'] = $this->db_version;
581
  update_option( $this->option_name, $this->options );
582
  }
@@ -617,7 +686,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
617
 
618
  switch($name){
619
  case "custom-image":
620
- if( '' == $this->options['custom_image'] )
621
  $return = '';
622
  else
623
  $return = '<img src="'.$this->options['custom_image'].'" alt="Print Friendly" />';
@@ -703,11 +772,11 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
703
  * @param string $name string used for various parts of checkbox
704
  *
705
  */
706
- function create_checkbox($name) {
707
- echo '<input type="checkbox" class="show_list" name="' . $this->option_name . '[show_on_' . $name . ']" value="on" ';
 
708
  $this->checked( 'show_on_' . $name, 'on');
709
- echo ' />';
710
- _e( ucfirst($name), $this->hook );
711
  }
712
 
713
 
@@ -723,6 +792,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
723
  isset($this->options['show_on_pages']) ||
724
  isset($this->options['show_on_homepage']) ||
725
  isset($this->options['show_on_categories']) ||
 
726
  isset($this->options['show_on_taxonomies']));
727
  }
728
 
@@ -742,6 +812,61 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
742
  return selected ($this->options[$val], $check_against);
743
  }
744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
745
  /**
746
  * Output the config page
747
  *
@@ -751,7 +876,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
751
 
752
  // Since WP 3.2 outputs these errors by default, only display them when we're on versions older than 3.2 that do support the settings errors.
753
  global $wp_version;
754
- if ( version_compare( $wp_version, '3.2', '<' ) )
755
  settings_errors();
756
 
757
  // Show the content of the options array when debug is enabled
@@ -759,15 +884,15 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
759
  echo '<pre>Options:<br><br>' . print_r( $this->options, 1 ) . '</pre>';
760
  ?>
761
  <div id="pf_settings" class="wrap">
762
-
763
  <div class="icon32" id="printfriendly"></div>
764
  <h2><?php _e( 'Print Friendly & PDF Settings', $this->hook ); ?></h2>
765
-
766
  <form action="options.php" method="post">
767
  <?php settings_fields( $this->option_name ); ?>
768
-
769
  <h3><?php _e( "Pick Your Button Style", $this->hook ); ?></h3>
770
-
771
  <fieldset id="button-style">
772
  <div id="buttongroup1">
773
  <?php $this->radio('pf-button.gif'); ?>
@@ -820,13 +945,13 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
820
  </div>
821
  </fieldset>
822
  <br class="clear">
823
-
824
- <!--Section 2 Button Placement-->
825
- <div id="button-placement">
826
- <h3><?php _e( "Button Placement", $this->hook ); ?>
827
  <span id="css"><input type="checkbox" name="<?php echo $this->option_name; ?>[enable_css]" value="<?php $this->val('enable_css');?>" <?php $this->checked('enable_css', 'off'); ?> />Do not use CSS for button styles</span>
828
  </h3>
829
- <div id="button-placement-options">
830
  <div id="alignment">
831
  <label>
832
  <select id="pf_content_position" name="<?php echo $this->option_name; ?>[content_position]" >
@@ -861,19 +986,41 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
861
  </label>
862
  </div>
863
  </div>
 
 
 
 
 
 
864
  <div id="pages">
865
- <label><?php $this->create_checkbox('pages'); ?></label>
866
- <label><?php $this->create_checkbox('posts'); ?></label>
867
- <label><?php $this->create_checkbox('homepage'); ?></label>
868
- <label><?php $this->create_checkbox('categories'); ?></label>
869
- <label><?php $this->create_checkbox('taxonomies'); ?></label>
870
- <label><strong>Note: </strong><em><?php _e( "Uncheck all of the above to use the shortcodes below:", $this->hook ); ?></em></label>
871
- <label><?php _e( "Use [printfriendly] inside your page/article or put the following code in your template:", $this->hook ); ?></label>
872
- <textarea id="pf-shortcode" class="code" rows="2" cols="40">&lt;?php if(function_exists('pf_show_link')){echo pf_show_link();} ?&gt;</textarea>
 
 
873
  </div>
874
  </div>
875
-
876
- <!--Section 3 Button Print Options-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
877
  <div id="print-options">
878
  <h3><?php _e( "Print PDF Options", $this->hook ); ?></h3>
879
  <label id="pf-favicon" for="favicon">
@@ -919,10 +1066,10 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
919
  <input id="custom_css_url" type="text" class="regular-text" name="<?php echo $this->option_name; ?>[custom_css_url]" value="<?php $this->val( 'custom_css_url' ); ?>" />
920
  </label>
921
  </div>
922
-
923
- <!--Section 4 WebMaster-->
924
  <h3><?php _e( "Webmaster Settings", $this->hook ); ?></h3>
925
-
926
  <label for="protocol">Website Protocol<br>
927
  <select id="website_protocol" name="<?php echo $this->option_name; ?>[website_protocol]" >
928
  <option value="http" <?php selected( $this->options['website_protocol'], 'http' ); ?>><?php _e( "http (common)", $this->hook ); ?></option>
@@ -949,7 +1096,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
949
  <?php _e( "Display print preview on PrintFriendly.com (No JavaScript)", $this->hook ); ?>
950
  </span>
951
  </label>
952
-
953
  <p class="submit">
954
  <input type="submit" class="button-primary" value="<?php esc_attr_e( "Save Options", $this->hook ); ?>"/>
955
  <input type="reset" class="button-secondary" value="<?php esc_attr_e( "Cancel", $this->hook ); ?>"/>
@@ -959,7 +1106,7 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
959
  <p>
960
  <?php _e( "Like PrintFriendly?", $this->hook ); ?> <a href="http://wordpress.org/extend/plugins/printfriendly/"><?php _e( "Give us a rating", $this->hook ); ?></a>. <?php _e( "Need help or have suggestions?", $this->hook ); ?> <a href="mailto:support@printfriendly.com?subject=Support%20for%20PrintFriendly%20WordPress%20plugin">support@PrintFriendly.com</a>.</p>
961
  </div>
962
-
963
  </form>
964
  </div>
965
  <?php
1
  <?php
2
+
3
  /*
4
  Plugin Name: Print Friendly and PDF
5
  Plugin URI: http://www.printfriendly.com
6
  Description: PrintFriendly & PDF button for your website. Optimizes your pages and brand for print, pdf, and email.
7
  Name and URL are included to ensure repeat visitors and new visitors when printed versions are shared.
8
+ Version: 3.2.2
9
  Author: Print Friendly
10
  Author URI: http://www.PrintFriendly.com
11
 
12
  Changelog :
13
+ 3.2.2 - Add printfriendly post_class. Add printfriendly button display settings per individual category. Fixed minor JS bug. Added redundancy to uninstall script.
14
+ 3.2.1 - Improve script loading.
15
  3.2.0 - Important chrome issue fix. Ie syntax error fix.
16
  3.1.9 - Minor css detail.
17
  3.1.8 - Add printfriendly options to allow/not allow print, pdf, email from the Printfriendly and PDF dialog.
84
  * Database version, used to allow for easy upgrades to / additions in plugin options between plugin versions.
85
  * @var int
86
  */
87
+ var $db_version = 5;
88
 
89
  /**
90
  * Settings page, used within the plugin to reliably load the plugins admin JS and CSS files only on the admin page.
118
  add_filter( 'the_excerpt', array( &$this, 'show_link' ) );
119
  }
120
 
 
 
121
 
122
+ if ( !is_admin() ) {
123
+ // Register function that adds pf content class to article content
124
+ add_filter("post_class", array( &$this, 'add_pf_content_class' ) );
125
 
126
+ }
127
+ else {
128
+ // Hook into init for registration of the option and the language files
129
+ add_action( 'admin_init', array( &$this, 'init' ) );
130
 
131
+ // Register the settings page
132
+ add_action( 'admin_menu', array( &$this, 'add_config_page' ) );
133
 
134
+ // Register the contextual help
135
+ add_filter( 'contextual_help', array( &$this, 'contextual_help' ), 10, 2 );
136
 
137
+ // Enqueue the needed scripts and styles
138
+ add_action( 'admin_enqueue_scripts',array( &$this, 'admin_enqueue_scripts' ) );
139
 
140
+ // Register a link to the settings page on the plugins overview page
141
+ add_filter( 'plugin_action_links', array( &$this, 'filter_plugin_actions' ), 10, 2 );
142
+ }
143
  }
144
 
145
  /**
161
  if ( isset( $this->options['enable_css'] ) && $this->options['enable_css'] != 'on' )
162
  return;
163
 
164
+
165
  ?>
166
  <style type="text/css" media="screen">
167
  div.printfriendly {
168
+ margin: <?php echo $this->options['margin_top'].'px '.$this->options['margin_right'].'px '.$this->options['margin_bottom'].'px '.$this->options['margin_left'].'px;'; ?>;
169
  }
170
  div.printfriendly a, div.printfriendly a:link, div.printfriendly a:visited {
171
  text-decoration: none;
212
  <?php
213
  }
214
 
215
+
216
+ /**
217
+ * Adds class=wp-pf-content to the content container.
218
+ *
219
+ * @since 3.2.2
220
+ */
221
+ function add_pf_content_class( $classes = array() ) {
222
+ $classes[] = esc_attr( 'wp-pf-content' );
223
+ return array_unique( $classes );
224
+ }
225
+
226
+
227
  /**
228
  * Prints the PrintFriendly JavaScript, in the footer, and loads it asynchronously.
229
  *
242
  }
243
 
244
  // Currently we use v3 for both: normal and password protected sites
245
+ $pf_src = 'http://cdn.printfriendly.com/printfriendly.js';
246
  if($this->options['website_protocol'] == 'https')
247
  $pf_src = 'https://pf-cdn.printfriendly.com/ssl/main.js';
248
 
259
 
260
  // PrintFriendly
261
  var e = document.createElement('script'); e.type="text/javascript";
 
262
  e.src = '<?php echo $pf_src ?>';
263
  document.getElementsByTagName('head')[0].appendChild(e);
264
  </script>
304
  }
305
  else
306
  {
307
+ if ( (is_page() && ( isset($this->options['show_on_pages']) && 'on' === $this->options['show_on_pages'] ) )
308
+ || (is_home() && ( ( isset($this->options['show_on_homepage']) && 'on' === $this->options['show_on_homepage'] ) && $this->category_included() ) )
309
+ || (is_tax() && ( ( isset($this->options['show_on_taxonomies']) && 'on' === $this->options['show_on_taxonomies'] ) && $this->category_included() ) )
310
+ || (is_category() && ( ( isset($this->options['show_on_categories']) && 'on' === $this->options['show_on_categories'] ) && $this->category_included() ) )
311
+ || (is_single() && ( ( isset($this->options['show_on_posts']) && 'on' === $this->options['show_on_posts'] ) && $this->category_included() ) ) )
312
  {
313
  // Hook the script call now, so it only get's loaded when needed, and need is determined by the user calling pf_button
314
  add_action( 'wp_footer', array( &$this, 'print_script_footer' ) );
327
 
328
  }
329
 
330
+
331
+ /**
332
+ * Filter posts by category.
333
+ *
334
+ * @since 3.2.2
335
+ * @return boolean true if post belongs to category selected for button display
336
+ */
337
+ function category_included() {
338
+ return ( 'all' === $this->options['category_ids'][0] || in_category($this->options['category_ids']) );
339
+ }
340
+
341
  /**
342
  * Register the textdomain and the options array along with the validation function
343
  *
361
  function options_validate( $input ) {
362
  $valid_input = $input;
363
 
364
+ if( isset( $input['category_ids'] ) ) {
365
+ /**
366
+ * Validate received category ids:
367
+ * - Is there only one array item and does it contain the string text 'all' ? => pass
368
+ * - Otherwise, make sure the ids are integer values
369
+ */
370
+ $valid_input['category_ids'] = explode(',', $input['category_ids']);
371
+ $valid_input['category_ids'] = array_map( 'trim', $valid_input['category_ids'] );
372
+ if( ( count( $valid_input['category_ids'] ) === 1 && 'all' === $valid_input['category_ids'][0] ) === false ) {
373
+ foreach( $valid_input['category_ids'] as $k => $v ) {
374
+ if( $v !== '' && ( ctype_digit( (string) $v ) === true && ( intval( $v ) == $v ) ) ) {
375
+ $valid_input['category_ids'][$k] = intval( $v );
376
+ }
377
+ else {
378
+ // Invalid input - Show error message ?
379
+ unset( $valid_input['category_ids'][$k] );
380
+ }
381
+ }
382
+ }
383
+ }
384
+
385
+ //echo '<pre>'.print_r($input,1).'</pre>';
386
+ //die;
387
 
388
  if ( !in_array( $input['button_type'], array( 'pf-button.gif', 'button-print-grnw20.png', 'button-print-blu20.png', 'button-print-gry20.png', 'button-print-whgn20.png', 'pf_button_sq_gry_m.png', 'pf_button_sq_gry_l.png', 'pf_button_sq_grn_m.png', 'pf_button_sq_grn_l.png', 'pf-button-big.gif', 'pf-icon-small.gif', 'pf-icon.gif', 'pf-button-both.gif', 'pf-icon-both.gif', 'text-only', 'custom-image') ) )
389
  $valid_input['button_type'] = 'pf-button.gif';
429
  */
430
  function add_config_page() {
431
  $this->settings_page = add_options_page( __( 'PrintFriendly Options', $this->hook ), __( 'Print Friendly & PDF', $this->hook ), 'manage_options', $this->hook, array( &$this, 'config_page' ) );
432
+
433
+ //register callback gets call prior your own page gets rendered
434
+ add_action('load-'.$this->settings_page, array(&$this, 'on_load_printfriendly'));
435
  }
436
 
437
  /**
455
  */
456
  function admin_enqueue_scripts( $screen_id ) {
457
  if ( $this->settings_page == $screen_id ) {
458
+ $ver = '3.2.2';
459
  wp_register_script( 'pf-color-picker', plugins_url( 'colorpicker.js', __FILE__ ), array( 'jquery', 'media-upload' ), $ver );
460
  wp_register_script( 'pf-admin-js', plugins_url( 'admin.js', __FILE__ ), array( 'jquery', 'media-upload' ), $ver );
461
 
462
  wp_enqueue_script( 'pf-color-picker' );
463
  wp_enqueue_script( 'pf-admin-js' );
464
 
465
+
466
  wp_enqueue_style( 'printfriendly-admin-css', plugins_url( 'admin.css', __FILE__ ), array(), $ver);
467
  }
468
  }
520
  'password_protected' => 'no',
521
  'javascript' => 'yes',
522
  'custom_css_url' => '',
523
+ 'category_ids' => array('all'),
524
  );
525
 
526
  // Check whether the old badly named singular options are there, if so, use the data and delete them.
574
  // check whether image we do not list any more was used
575
  if(in_array($this->options['button_type'], array('button-print-whgn20.png', 'pf_button_sq_qry_m.png', 'pf_button_sq_qry_l.png', 'pf_button_sq_grn_m.png', 'pf_button_sq_grn_l.png'))) {
576
  // previous version had a bug with button name
577
+ if(in_array($this->options['button_type'], array('pf_button_sq_qry_m.png', 'pf_button_sq_qry_l.png')))
578
  $this->options['button_type'] = str_replace('qry', 'gry', $this->options['button_type']);
579
 
580
  $image_address = '//cdn.printfriendly.com/'.$this->options['button_type'];
633
  $this->options = array_merge($this->options, $additional_options);
634
  }
635
 
636
+ // update options to version 5
637
+ if($this->options['db_version'] < 5) {
638
+
639
+ $additional_options = array(
640
+ 'category_ids' => array(),
641
+ );
642
+
643
+ if( isset( $this->options['show_on_categories'] ) && 'on' === $this->options['show_on_categories'] ) {
644
+ $additional_options['category_ids'][] = 'all';
645
+ }
646
+
647
+ $this->options = array_merge($this->options, $additional_options);
648
+ }
649
  $this->options['db_version'] = $this->db_version;
650
  update_option( $this->option_name, $this->options );
651
  }
686
 
687
  switch($name){
688
  case "custom-image":
689
+ if( '' == trim($this->options['custom_image']) )
690
  $return = '';
691
  else
692
  $return = '<img src="'.$this->options['custom_image'].'" alt="Print Friendly" />';
772
  * @param string $name string used for various parts of checkbox
773
  *
774
  */
775
+ function create_checkbox($name, $label='', $labelid='' ) {
776
+ $label = ( !empty( $label) ? $label : $name );
777
+ echo '<label' . ( !empty( $labelid ) ? ' id=' . $labelid : '' ) . '><input type="checkbox" class="show_list" name="' . $this->option_name . '[show_on_' . $name . ']" value="on" ';
778
  $this->checked( 'show_on_' . $name, 'on');
779
+ echo ' />' . __( ucfirst($label), $this->hook ) . '</label>';
 
780
  }
781
 
782
 
792
  isset($this->options['show_on_pages']) ||
793
  isset($this->options['show_on_homepage']) ||
794
  isset($this->options['show_on_categories']) ||
795
+ // (isset($this->options['category_ids']) && count($this->options['category_ids']) > 0) ||
796
  isset($this->options['show_on_taxonomies']));
797
  }
798
 
812
  return selected ($this->options[$val], $check_against);
813
  }
814
 
815
+ /**
816
+ * For use with page metabox.
817
+ *
818
+ * @since 3.2.2
819
+ */
820
+ function get_page_post_type() {
821
+ $post_types = get_post_types( array( 'name' => 'page' ), 'object' );
822
+ //echo '<pre>'.print_r($post_types,1).'</pre>';
823
+ //die;
824
+
825
+ return $post_types['page'];
826
+ }
827
+
828
+
829
+ /**
830
+ * Helper that checks if wp versions is above 3.0.
831
+ *
832
+ * @since 3.2.2
833
+ * @return boolean true wp version is above 3.0
834
+ *
835
+ */
836
+ function wp_version_gt30() {
837
+ global $wp_version;
838
+ return version_compare($wp_version, '3.0', '>=');
839
+ }
840
+
841
+
842
+ /**
843
+ * Create box for picking individual categories.
844
+ *
845
+ * @since 3.2.2
846
+ */
847
+ function create_category_metabox() {
848
+ $obj = new stdClass();
849
+ $obj->ID = 0;
850
+ do_meta_boxes('settings_page_' . $this->hook, 'normal', $obj);
851
+ }
852
+
853
+
854
+ /**
855
+ * Load metaboxes advanced button display settings.
856
+ *
857
+ * @since 3.2.2
858
+ */
859
+ function on_load_printfriendly() {
860
+ global $wp_version;
861
+ if($this->wp_version_gt30()) {
862
+ require_once('includes/meta-boxes.php');
863
+ //require_once('includes/nav-menu.php');
864
+ wp_enqueue_script('post');
865
+
866
+ add_meta_box('categorydiv', __('Button categories:'), 'post_categories_meta_box', 'settings_page_'. $this->hook, 'normal', 'core');
867
+ }
868
+ }
869
+
870
  /**
871
  * Output the config page
872
  *
876
 
877
  // Since WP 3.2 outputs these errors by default, only display them when we're on versions older than 3.2 that do support the settings errors.
878
  global $wp_version;
879
+ if(version_compare($wp_version, '3.2', '<' ) && $this->wp_version_gt30() )
880
  settings_errors();
881
 
882
  // Show the content of the options array when debug is enabled
884
  echo '<pre>Options:<br><br>' . print_r( $this->options, 1 ) . '</pre>';
885
  ?>
886
  <div id="pf_settings" class="wrap">
887
+
888
  <div class="icon32" id="printfriendly"></div>
889
  <h2><?php _e( 'Print Friendly & PDF Settings', $this->hook ); ?></h2>
890
+
891
  <form action="options.php" method="post">
892
  <?php settings_fields( $this->option_name ); ?>
893
+
894
  <h3><?php _e( "Pick Your Button Style", $this->hook ); ?></h3>
895
+
896
  <fieldset id="button-style">
897
  <div id="buttongroup1">
898
  <?php $this->radio('pf-button.gif'); ?>
945
  </div>
946
  </fieldset>
947
  <br class="clear">
948
+
949
+ <!--Section 2 Button Positioning-->
950
+ <div id="button-positioning">
951
+ <h3><?php _e( "Button Positioning", $this->hook ); ?>
952
  <span id="css"><input type="checkbox" name="<?php echo $this->option_name; ?>[enable_css]" value="<?php $this->val('enable_css');?>" <?php $this->checked('enable_css', 'off'); ?> />Do not use CSS for button styles</span>
953
  </h3>
954
+ <div id="button-positioning-options">
955
  <div id="alignment">
956
  <label>
957
  <select id="pf_content_position" name="<?php echo $this->option_name; ?>[content_position]" >
986
  </label>
987
  </div>
988
  </div>
989
+ </div>
990
+ <br class="clear">
991
+
992
+ <!--Section 3 Button Placement-->
993
+ <div id="button-placement">
994
+ <h3><?php _e( "Button Placement", $this->hook ); ?></h3>
995
  <div id="pages">
996
+ <?php $this->create_checkbox('posts'); ?>
997
+ <?php $this->create_checkbox('pages'); ?>
998
+ <?php $this->create_checkbox('homepage'); ?>
999
+ <?php $this->create_checkbox('categories'); ?>
1000
+ <?php $this->create_checkbox('taxonomies'); ?>
1001
+ <label><input type="checkbox" class="show_template" name="show_on_template" /><?php echo _e( 'Add direct to template', $this->hook ); ?></label>
1002
+ <textarea id="pf-shortcode" class="code" rows="2" cols="40">&lt;?php if(function_exists('pf_show_link')){echo pf_show_link();} ?&gt;</textarea>
1003
+ <label><?php _e( "or use shortcode inside your page/article", $this->hook ); ?></label>
1004
+ <textarea id="pf-shortcode" class="code" rows="2" cols="40">[printfriendly]</textarea>
1005
+ <input type="hidden" name="<?php echo $this->option_name; ?>[category_ids]" id="category_ids" value="<?php echo implode(',', $this->options['category_ids']); ?>" />
1006
  </div>
1007
  </div>
1008
+ <?php if($this->wp_version_gt30()) { ?>
1009
+ <div id="pf-categories">
1010
+ <?php printf( __( 'Specify <a %s>specific categories</a>', $this->hook), ' href="javascript:void(0)" id="toggle-categories"' ); ?>
1011
+ <br/>
1012
+ <p class="description pf-categories">
1013
+ <?php _e( "Selecting categories will act as an additional filter for when to display the buttons.", $this->hook ); ?>
1014
+ </p>
1015
+ <div id="pf-categories-metabox">
1016
+ <?php $this->create_category_metabox(); ?>
1017
+ </div>
1018
+ </div>
1019
+ <?php } ?>
1020
+
1021
+ <br class="clear">
1022
+
1023
+ <!--Section 4 Button Print Options-->
1024
  <div id="print-options">
1025
  <h3><?php _e( "Print PDF Options", $this->hook ); ?></h3>
1026
  <label id="pf-favicon" for="favicon">
1066
  <input id="custom_css_url" type="text" class="regular-text" name="<?php echo $this->option_name; ?>[custom_css_url]" value="<?php $this->val( 'custom_css_url' ); ?>" />
1067
  </label>
1068
  </div>
1069
+
1070
+ <!--Section 5 WebMaster-->
1071
  <h3><?php _e( "Webmaster Settings", $this->hook ); ?></h3>
1072
+
1073
  <label for="protocol">Website Protocol<br>
1074
  <select id="website_protocol" name="<?php echo $this->option_name; ?>[website_protocol]" >
1075
  <option value="http" <?php selected( $this->options['website_protocol'], 'http' ); ?>><?php _e( "http (common)", $this->hook ); ?></option>
1096
  <?php _e( "Display print preview on PrintFriendly.com (No JavaScript)", $this->hook ); ?>
1097
  </span>
1098
  </label>
1099
+
1100
  <p class="submit">
1101
  <input type="submit" class="button-primary" value="<?php esc_attr_e( "Save Options", $this->hook ); ?>"/>
1102
  <input type="reset" class="button-secondary" value="<?php esc_attr_e( "Cancel", $this->hook ); ?>"/>
1106
  <p>
1107
  <?php _e( "Like PrintFriendly?", $this->hook ); ?> <a href="http://wordpress.org/extend/plugins/printfriendly/"><?php _e( "Give us a rating", $this->hook ); ?></a>. <?php _e( "Need help or have suggestions?", $this->hook ); ?> <a href="mailto:support@printfriendly.com?subject=Support%20for%20PrintFriendly%20WordPress%20plugin">support@PrintFriendly.com</a>.</p>
1108
  </div>
1109
+
1110
  </form>
1111
  </div>
1112
  <?php
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Print Friendly and PDF Button===
2
- Contributors: printfriendly,joostdevalk
3
  Tags: print, pdf, printer, printing, printable, widget, plugin
4
  Requires at least: 2.8
5
- Tested up to: 3.5
6
- Stable tag: 3.2.0
7
 
8
  The #1 Print and PDF button for your WordPress site. Printer Friendly pages without coding, css, or print.css. Fast, easy, and professional.
9
 
@@ -98,6 +98,16 @@ If you have any other issues with the plugin or the PrintFriendly widget, please
98
 
99
  == Changelog ==
100
 
 
 
 
 
 
 
 
 
 
 
101
 
102
  = 3.2.0 =
103
 
1
  === Print Friendly and PDF Button===
2
+ Contributors: printfriendly,joostdevalk, jrf
3
  Tags: print, pdf, printer, printing, printable, widget, plugin
4
  Requires at least: 2.8
5
+ Tested up to: 3.5.1
6
+ Stable tag: 3.2.2
7
 
8
  The #1 Print and PDF button for your WordPress site. Printer Friendly pages without coding, css, or print.css. Fast, easy, and professional.
9
 
98
 
99
  == Changelog ==
100
 
101
+ = 3.2.2 =
102
+
103
+ * Add printfriendly post_class.
104
+ * Add printfriendly button display settings per individual category.
105
+ * Fixed minor JS bug.
106
+ * Added redundancy to uninstall script.
107
+
108
+ = 3.2.1 =
109
+
110
+ * Improve script loading.
111
 
112
  = 3.2.0 =
113
 
screenshot-2.png CHANGED
Binary file
uninstall.php CHANGED
@@ -1,6 +1,21 @@
1
- <?php
2
 
3
  if( !defined( 'ABSPATH' ) && !defined( 'WP_UNINSTALL_PLUGIN' ) )
4
  exit();
5
 
6
- delete_option( 'printfriendly_option' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
 
3
  if( !defined( 'ABSPATH' ) && !defined( 'WP_UNINSTALL_PLUGIN' ) )
4
  exit();
5
 
6
+ delete_option( 'printfriendly_option' );
7
+
8
+ // Make sure any old options which may still lurking about get deleted as well
9
+ delete_option( 'pf_button_type' );
10
+ delete_option( 'pf_custom_image' );
11
+ delete_option( 'pf_custom_text' );
12
+ delete_option( 'pf_custom_both' );
13
+ delete_option( 'pf_show_list' );
14
+ delete_option( 'pf_content_placement' );
15
+ delete_option( 'pf_content_position' );
16
+ delete_option( 'pf_margin_top' );
17
+ delete_option( 'pf_margin_right' );
18
+ delete_option( 'pf_margin_bottom' );
19
+ delete_option( 'pf_margin_left' );
20
+ delete_option( 'pf_text_color' );
21
+ delete_option( 'pf_text_size' );