Print, PDF, Email by PrintFriendly - Version 3.0.9

Version Description

  • New features: Custom header, disable click-to-delete, https support (beta), PrintFriendly Pro (ad-free).
Download this release

Release Info

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

Code changes from version 3.0.8 to 3.0.9

Files changed (4) hide show
  1. admin.css +89 -11
  2. admin.js +137 -67
  3. pf.php +802 -672
  4. readme.txt +5 -1
admin.css CHANGED
@@ -1,7 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  input[type="radio"] {
2
  cursor: pointer;
 
 
 
3
  }
4
 
 
5
  /* WP lacks styling for type="number", so in here for now */
6
  input[type="number"] {
7
  border-color: #DFDFDF;
@@ -16,22 +71,49 @@ input[type="number"] {
16
  -webkit-box-sizing: border-box;
17
  -ms-box-sizing: border-box;
18
  box-sizing: border-box;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
20
 
21
- .radio {
22
- margin: 0 5px 0 0;
23
- vertical-align: text-top;
24
- height: 25px;
 
 
 
 
 
 
 
 
25
  }
26
 
27
  .icon32 {
28
  background: url(images/pf-icon.png) center center no-repeat;
29
  }
30
 
31
- .printfriendly-text {
32
- margin-left: 3px;
 
 
33
  }
34
-
35
  #addmanual-help {
36
  display: none;
37
  }
@@ -226,7 +308,3 @@ input[type="number"] {
226
  .colorpicker_slider {
227
  background-position: bottom;
228
  }
229
-
230
- .clear {
231
- clear: both;
232
- }
1
+ label{
2
+ display: block;
3
+ margin: 1.5em 0;
4
+ }
5
+ h3{
6
+ margin: 3em 0 2em;
7
+ border-bottom: 1px solid #ccc;
8
+ padding-bottom:.75em;
9
+ clear: both;
10
+ }
11
+
12
+ #buttongroup1, #buttongroup2, #buttongroup3, #custom-txt div, #button-placement div{
13
+ display: block;
14
+ margin-right: 3em;
15
+ float: left;
16
+ }
17
+ #custom-txt div#txt-size, div#button-placement-options{
18
+ margin-right: 0;
19
+ }
20
+ #custom-button-preview {
21
+ clear:both;
22
+ padding-top: 20px;
23
+ margin-left: 2em;
24
+ }
25
+ #custom-button-preview img{
26
+ margin-right: 6px;
27
+ }
28
+ #custom, #placement-adv-options{
29
+ float: left;
30
+ }
31
+ #custom-txt, #custom-img {
32
+ margin: 2em 0 2em 2em;
33
+ clear: both;
34
+
35
+ }
36
+ .description{
37
+ color: #cacaca;
38
+ }
39
+ .printfriendly-text2{
40
+ font-family: verdana;
41
+ font-size: 14px;
42
+ color: #6D9F00;
43
+ }
44
+ select{
45
+ display: block;
46
+ margin: .5em .5em 2em 0;
47
+ }
48
+ select#javascript, select#website_protocol{
49
+ display: inline-block;
50
+ margin-bottom: 0;
51
+ }
52
  input[type="radio"] {
53
  cursor: pointer;
54
+
55
+ margin-right: 10px;
56
+ vertical-align: middle;
57
  }
58
 
59
+
60
  /* WP lacks styling for type="number", so in here for now */
61
  input[type="number"] {
62
  border-color: #DFDFDF;
71
  -webkit-box-sizing: border-box;
72
  -ms-box-sizing: border-box;
73
  box-sizing: border-box;
74
+ width: 36px;
75
+ margin-right: .5em;
76
+ }
77
+ #pf-shortcode{
78
+
79
+ margin-left: 2em;
80
+ }
81
+ .custom-logo label, .custom-logo input, #pf-favicon {
82
+ display: inline-block;
83
+ }
84
+
85
+ .custom-logo input {
86
+ width: 20em;
87
+ }
88
+
89
+ .custom-logo label {
90
+ margin-left: 5px;
91
+ margin-right: 2px;
92
  }
93
 
94
+ label#pf-favicon {
95
+ vertical-align: baseline;
96
+ margin: 0;
97
+ }
98
+
99
+ .printfriendly-details input {
100
+ width: 20em;
101
+ }
102
+
103
+ .printfriendly-details label {
104
+ margin-left: 5px;
105
+ margin-right: 2px;
106
  }
107
 
108
  .icon32 {
109
  background: url(images/pf-icon.png) center center no-repeat;
110
  }
111
 
112
+ #after-submit{
113
+ border-top: 2px dashed #dfdfdf;
114
+ margin:4em 0;
115
+ padding-top:1em;
116
  }
 
117
  #addmanual-help {
118
  display: none;
119
  }
308
  .colorpicker_slider {
309
  background-position: bottom;
310
  }
 
 
 
 
admin.js CHANGED
@@ -1,69 +1,139 @@
1
  // Throughout the admin I chose to use slow animations to make it clear that stuff is being hidden or shown depending on settings.
2
  jQuery(document).ready(function() {
3
- jQuery('.show_list').change(function() {
4
- if (jQuery('.show_list:checked').val()=='manual') {
5
- jQuery('#addmanual-help').show('slow');
6
- jQuery('.content_placement').hide('slow');
7
- jQuery('.content_placement input').attr('disabled','disabled');
8
- } else {
9
- jQuery('#addmanual-help').hide('slow');
10
- jQuery('.content_placement').show('slow');
11
- jQuery('.content_placement input').removeAttr('disabled');
12
- }
13
- });
14
- if (jQuery('.show_list:checked').val()=='manual') {
15
- jQuery('#addmanual-help').show('slow');
16
- jQuery('.content_placement').hide();
17
- jQuery('.content_placement input').attr('disabled','disabled');
18
- }
19
-
20
- jQuery('#colorSelector').ColorPicker({
21
- color: jQuery('#text_color').val(),
22
- onShow: function (colpkr) {
23
- jQuery(colpkr).fadeIn(500);
24
- return false;
25
- },
26
- onHide: function (colpkr) {
27
- jQuery(colpkr).fadeOut(500);
28
- return false;
29
- },
30
- onChange: function (hsb, hex, rgb) {
31
- jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
32
- jQuery('#text_color').val('#' + hex);
33
- jQuery('.printfriendly-text').css('color','#' + hex)
34
- }
35
- });
36
-
37
- jQuery('#disable_css').change(function(){
38
- if ( jQuery('#disable_css').is(':checked') ) {
39
- jQuery('.css').show('slow');
40
- jQuery('.css input').removeAttr('disabled');
41
- } else {
42
- jQuery('.css').hide('slow');
43
- jQuery('.css input').attr('disabled','disabled');
44
- }
45
- });
46
- if ( !jQuery('#disable_css').is(':checked') ) {
47
- jQuery('.css').hide();
48
- jQuery('.css input').attr('disabled','disabled');
49
- }
50
-
51
- jQuery('#text_size').change(function(){
52
- size = jQuery('#text_size').val();
53
- jQuery('.printfriendly-text').css('font-size',parseInt(size));
54
- }).change();
55
-
56
- jQuery('#custom_text').change(function(){
57
- pf_custom_text_change();
58
- }).change();
59
-
60
- jQuery('#custom_text').keyup(function(){
61
- pf_custom_text_change();
62
- });
63
-
64
- function pf_custom_text_change(){
65
- jQuery('.button_preview span:not(.printandpdf)').text( jQuery('#custom_text').val() );
66
- }
67
-
68
- jQuery('.printfriendly-text').css('color', jQuery('#text_color').val() );
69
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  // Throughout the admin I chose to use slow animations to make it clear that stuff is being hidden or shown depending on settings.
2
  jQuery(document).ready(function() {
3
+ jQuery('.show_list').change(function() {
4
+ if (jQuery('.show_list:checked').val()=='manual') {
5
+ jQuery('#addmanual-help').show('slow');
6
+ jQuery('.content_placement').hide('slow');
7
+ jQuery('.content_placement input').attr('disabled','disabled');
8
+ } else {
9
+ jQuery('#addmanual-help').hide('slow');
10
+ jQuery('.content_placement').show('slow');
11
+ jQuery('.content_placement input').removeAttr('disabled');
12
+ }
13
+ });
14
+ if (jQuery('.show_list:checked').val()=='manual') {
15
+ jQuery('#addmanual-help').show('slow');
16
+ jQuery('.content_placement').hide();
17
+ jQuery('.content_placement input').attr('disabled','disabled');
18
+ }
19
+
20
+ jQuery('#colorSelector').ColorPicker({
21
+ color: jQuery('#text_color').val(),
22
+ onShow: function (colpkr) {
23
+ jQuery(colpkr).fadeIn(500);
24
+ return false;
25
+ },
26
+ onHide: function (colpkr) {
27
+ jQuery(colpkr).fadeOut(500);
28
+ return false;
29
+ },
30
+ onChange: function (hsb, hex, rgb) {
31
+ jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
32
+ jQuery('#text_color').val('#' + hex);
33
+ jQuery('.printfriendly-text2').css('color','#' + hex);
34
+ }
35
+ });
36
+
37
+ jQuery('#text_size').change(function(){
38
+ size = jQuery('#text_size').val();
39
+ jQuery('.printfriendly-text2').css('font-size',parseInt(size));
40
+ }).change();
41
+
42
+ jQuery('#custom_text').change(function(){
43
+ pf_custom_text_change();
44
+ }).change();
45
+
46
+ jQuery('#custom_text').keyup(function(){
47
+ pf_custom_text_change();
48
+ });
49
+
50
+ function pf_custom_text_change(){
51
+ jQuery('#buttongroup3 span:not(.printandpdf)').text( jQuery('#custom_text').val() );
52
+ jQuery('#custom span.printfriendly-text2').text( jQuery('#custom_text').val() );
53
+ }
54
+
55
+ jQuery('.printfriendly-text2').css('color', jQuery('#text_color').val() );
56
+
57
+ function pf_initialize_preview(urlInputSelector, previewSelector) {
58
+ var el = jQuery(urlInputSelector);
59
+ var preview = jQuery(previewSelector + '-preview');
60
+ var error = jQuery(previewSelector + '-error');
61
+ el.bind('input paste change keyup', function() {
62
+ setTimeout(function() {
63
+ var img = jQuery('<img />').on('error', function() {
64
+ preview.html('');
65
+ if(img.attr('src') != '') {
66
+ error.html('<div class="error settings-error"><p><strong>Invalid Image URL</strong></p></div>');
67
+ }
68
+ }).attr('src', jQuery.trim(el.val()));
69
+ error.html('');
70
+ preview.html('').append(img);
71
+ }, 100);
72
+ });
73
+ }
74
+
75
+ pf_initialize_preview('#custom_image', '#pf-custom-button');
76
+ pf_initialize_preview('#upload-an-image', '#pf-image');
77
+ jQuery('#custom_image, #upload-an-image').change();
78
+ jQuery('#custom_image').bind('focus', function() {
79
+ jQuery('#custom-image').attr('checked', 'checked');
80
+ jQuery('#pf-custom-button-error').show();
81
+ });
82
+ jQuery('#button-style input.radio').bind('change', function() {
83
+ if(jQuery('#custom-image').attr('checked')) {
84
+ jQuery('#pf-custom-button-error').show();
85
+ } else {
86
+ jQuery('#pf-custom-button-error').hide();
87
+ }
88
+ }).change();
89
+
90
+ jQuery('#pf-logo').bind('change', function() {
91
+ if(jQuery(this).val() == 'favicon') {
92
+ jQuery('.custom-logo, #image-preview').hide();
93
+ } else {
94
+ jQuery('.custom-logo').css('display', 'inline-block');
95
+ jQuery('#image-preview').show();
96
+ }
97
+ }).change();
98
+
99
+ jQuery('#website_protocol').bind('change', function() {
100
+ if(jQuery(this).val() == 'https') {
101
+ jQuery('#https-beta-registration').show('slow');
102
+ } else {
103
+ jQuery('#https-beta-registration').hide('slow');
104
+ }
105
+ }).change();
106
+
107
+ jQuery('#password_protected').bind('change', function() {
108
+ if(jQuery(this).val() == 'yes') {
109
+ jQuery('#javascript').val('yes').change();
110
+ pf_on_javascript();
111
+ jQuery('#javascript').attr('disabled', 'disabled');
112
+ jQuery('#pf-javascript-container').hide('slow');
113
+ } else {
114
+ jQuery('#javascript').removeAttr('disabled');
115
+ jQuery('#pf-javascript-container').show('slow');
116
+ }
117
+ }).change();
118
+
119
+ jQuery('#javascript').bind('change', function() {
120
+ if(jQuery(this).val() == 'yes') {
121
+ pf_on_javascript();
122
+ } else {
123
+ pf_on_no_javascript();
124
+ }
125
+ }).change();
126
+
127
+ function pf_on_javascript() {
128
+ jQuery('.javascript').show();
129
+ jQuery('.no-javascript').hide();
130
+ jQuery('#print-options').show('slow');
131
+ }
132
+
133
+ function pf_on_no_javascript() {
134
+ jQuery('.javascript').hide();
135
+ jQuery('.no-javascript').show();
136
+ jQuery('#print-options').hide('slow');
137
+ }
138
+
139
+ });
pf.php CHANGED
@@ -2,13 +2,14 @@
2
  /*
3
  Plugin Name: Print Friendly and PDF
4
  Plugin URI: http://www.printfriendly.com
5
- Description: PrintFriendly & PDF optimizes your pages for print. Help your readers save paper and ink, plus enjoy your content in printed form. Website
6
- Name and URL are included to ensure repeat visitors and new visitors when printed versions are shared.
7
- Version: 3.0.8
8
  Author: Print Friendly
9
  Author URI: http://www.PrintFriendly.com
10
 
11
  Changelog :
 
12
  3.0.8 - Reordered PrintFriendly & PDF buttons. CSS stylesheet option is now checked by default.
13
  3.0.7 - Added additional images for print button.
14
  3.0.6 - Fix bug that would display button on category pages when not wanted.
@@ -18,7 +19,7 @@ Changelog :
18
  3.0.2 - Fixed JS bug with Google Chrome not submitting and fixed input validation issues.
19
  3.0.1 - Fixed minor JS bug.
20
  3.0 - Complete overhaul of the plugin by Joost de Valk.
21
- 2.1.8 - The Print Button was showing up on printed, or PDF, pages. Junk! Print or PDF button no longer displayed on printed out page or PDF.
22
  2.1.7 - Changed button from span to div to support floating.
23
  2.1.6 - Added rel="nofollow" to links. Changed button from <a> to <span> to fix target_new or target_blank issues.
24
  2.1.5 - Fix conflict with link tracking plugins. Custom image support for hosted wordpress sites.
@@ -32,678 +33,807 @@ Changelog :
32
  1.4 - Changed Name.
33
  1.3 - Added new buttons, removed redundant code.
34
  1.2 - User can choose to show or not show buttons on the listing page.
35
- */
36
-
37
  /**
38
  * PrintFriendly WordPress plugin. Allows easy embedding of printfriendly.com buttons.
39
  * @package PrintFriendly_WordPress
40
- * @author Joost de Valk <joost@yoast.com>
41
- * @copyright Copyright (C) 2011, PrintFriendly
42
  */
43
  if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
44
 
45
- /**
46
- * Class containing all the plugins functionality.
47
- * @package PrintFriendly_WordPress
48
- */
49
- class PrintFriendly_WordPress {
50
- /**
51
- * The hook, used for text domain as well as hooks on pages and in get requests for admin.
52
- * @var string
53
- */
54
- var $hook = 'printfriendly';
55
-
56
- /**
57
- * The option name, used throughout to refer to the plugins option and option group.
58
- * @var string
59
- */
60
- var $option_name = 'printfriendly_option';
61
-
62
- /**
63
- * The plugins options, loaded on init containing all the plugins settings.
64
- * @var array
65
- */
66
- var $options = array();
67
-
68
- /**
69
- * Database version, used to allow for easy upgrades to / additions in plugin options between plugin versions.
70
- * @var int
71
- */
72
- var $db_version = 1;
73
-
74
- /**
75
- * Settings page, used within the plugin to reliably load the plugins admin JS and CSS files only on the admin page.
76
- * @var string
77
- */
78
- var $settings_page = '';
79
-
80
- /**
81
- * Constructor
82
- *
83
- * @since 3.0
84
- */
85
- function __construct() {
86
- // delete_option( $this->option_name );
87
-
88
- // Retrieve the plugin options
89
- $this->options = get_option( $this->option_name );
90
-
91
- // If the options array is empty, set defaults
92
- if ( ! is_array( $this->options ) )
93
- $this->set_defaults();
94
-
95
- // If the version number doesn't match, upgrade
96
- if ( $this->db_version > $this->options['db_version'] )
97
- $this->upgrade();
98
-
99
- // automaticaly add the link
100
- if( 'manual' != $this->options['show_list'] ) {
101
- add_action( 'wp_head', array( &$this, 'front_head' ) );
102
- add_filter( 'the_content', array( &$this, 'show_link' ) );
103
- add_filter( 'the_excerpt', array( &$this, 'show_link' ) );
104
- }
105
-
106
- if ( !is_admin() )
107
- return;
108
-
109
- // Hook into init for registration of the option and the language files
110
- add_action( 'admin_init', array( &$this, 'init' ) );
111
-
112
- // Register the settings page
113
- add_action( 'admin_menu', array( &$this, 'add_config_page' ) );
114
-
115
- // Register the contextual help
116
- add_filter( 'contextual_help', array( &$this, 'contextual_help' ), 10, 2 );
117
-
118
- // Enqueue the needed scripts and styles
119
- add_action( 'admin_enqueue_scripts',array( &$this, 'admin_enqueue_scripts' ) );
120
-
121
- // Register a link to the settings page on the plugins overview page
122
- add_filter( 'plugin_action_links', array( &$this, 'filter_plugin_actions' ), 10, 2 );
123
- }
124
-
125
- /**
126
- * PHP 4 Compatible Constructor
127
- *
128
- * @since 3.0
129
- */
130
- function PrintFriendly_WordPress() {
131
- $this->__construct();
132
- }
133
-
134
- /**
135
- * Prints the PrintFriendly button CSS, in the header. Possible to disable this in the plugin settings.
136
- *
137
- * @since 3.0
138
- */
139
- function front_head() {
140
-
141
- if ( !isset( $this->options['disable_css'] ) || $this->options['disable_css'] != 'on' )
142
- return;
143
-
144
- ?>
145
- <style type="text/css" media="screen">
146
- .printfriendly {
147
- margin: <?php echo $this->options['margin_top'].'px '.$this->options['margin_right'].'px '.$this->options['margin_bottom'].'px '.$this->options['margin_left'].'px'; ?>;
148
- }
149
- .printfriendly a {
150
- text-decoration: none;
151
- }
152
- .printfriendly a:hover {
153
- cursor: pointer;
154
- }
155
- .printfriendly .printfriendly-text {
156
- margin-left: 3px;
157
- color: <?php echo $this->options['text_color']; ?>;
158
- }
159
- .printfriendly a img {
160
- border:none;
161
- padding:0;
162
- }
163
- .alignleft {
164
- float:left;
165
- margin: 5px 20px 20px 0;
166
- }
167
- .alignright {
168
- float:right;
169
- margin: 5px 0 20px 20px;
170
- }
171
- .aligncenter {
172
- text-align: center;
173
- margin: 5px auto 5px auto;
174
- }
175
- </style>
176
- <style type="text/css" media="print">
177
- .printfriendly {
178
- display: none;
179
- }
180
- </style>
181
- <?php
182
- }
183
-
184
- /**
185
- * Prints the PrintFriendly JavaScript, in the footer, and loads it asynchronously.
186
- *
187
- * @since 3.0
188
- */
189
- function print_script_footer() {
190
- if ( !isset( $this->options['javascript_include'] ) || $this->options['javascript_include'] != 'on' )
191
- return;
192
-
193
- else
194
- ?>
195
- <script type="text/javascript">
196
- // PrintFriendly
197
- var e = document.createElement('script'); e.type="text/javascript"; e.async = true;
198
- e.src = '//cdn.printfriendly.com/printfriendly.js';
199
- document.getElementsByTagName('head')[0].appendChild(e);
200
- </script>
201
- <?php
202
-
203
- }
204
-
205
- /**
206
- * Primary frontend function, used either as a filter for the_content, or directly using pf_show_link
207
- *
208
- * @since 3.0
209
- * @param string $content the content of the post, when the function is used as a filter
210
- * @return string $button or $content with the button added to the content when appropriate, just the content when button shouldn't be added or just button when called manually.
211
- */
212
- function show_link( $content = false ) {
213
- if( !$content && 'manual' != $this->options['show_list'] )
214
- return "";
215
-
216
- $href = '#';
217
- $onclick = 'onclick="window.print(); return false;"';
218
-
219
- if ( !isset( $this->options['javascript_include'] ) || $this->options['javascript_include'] != 'on' || !isset( $this->options['javascript_fallback'] ) || $this->options['javascript_fallback'] )
220
- $href = 'http://www.printfriendly.com/print/v2?url='.get_permalink();
221
-
222
- if ( !isset( $this->options['javascript_include'] ) || $this->options['javascript_include'] != 'on' )
223
- $onclick = '';
224
-
225
- if ( !is_singular() && '' != $onclick ) {
226
- $onclick = '';
227
- $href = get_permalink().'?pfstyle=wp';
228
- }
229
-
230
- $align = '';
231
- if ( 'none' != $this->options['content_position'] )
232
- $align = ' align'.$this->options['content_position'];
233
-
234
- $button = apply_filters( 'printfriendly_button', '<div class="printfriendly'.$align.'"><a href="'.$href.'" rel="nofollow" '.$onclick.'>'.$this->button().'</a></div>' );
235
-
236
- if (is_singular())
237
- {
238
- // Hook the script call now, so it only get's loaded when needed, and need is determined by the user calling pf_button
239
- add_action( 'wp_footer', array( &$this, 'print_script_footer' ) );
240
- }
241
-
242
- if ( 'manual' == $this->options['show_list'] )
243
- {
244
- return $button;
245
- }
246
-
247
- else
248
- {
249
- if (is_single() || ( is_page() && 'posts' != $this->options['show_list'] ) || ((is_home() || is_category()) && 'all' == $this->options['show_list'] ))
250
- {
251
-
252
- if ( $this->options['content_placement'] == 'before' )
253
- return $button.$content;
254
- else
255
- return $content.$button;
256
- }
257
-
258
- else
259
- {
260
- return $content;
261
- }
262
-
263
- }
264
-
265
- }
266
-
267
- /**
268
- * Register the textdomain and the options array along with the validation function
269
- *
270
- * @since 3.0
271
- */
272
- function init() {
273
- // Allow for localization
274
- load_plugin_textdomain( $this->hook, false, basename( dirname( __FILE__ ) ) . '/languages' );
275
-
276
- // Register our option array
277
- register_setting( $this->option_name, $this->option_name, array( &$this, 'options_validate' ) );
278
- }
279
-
280
- /**
281
- * Validate the saved options.
282
- *
283
- * @since 3.0
284
- * @param array $input with unvalidated options.
285
- * @return array $valid_input with validated options.
286
- */
287
- function options_validate( $input ) {
288
- $valid_input = $input;
289
-
290
- // echo '<pre>'.print_r($input,1).'</pre>';
291
- // die;
292
-
293
- 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_qry_m.png', 'pf_button_sq_qry_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') ) )
294
- $valid_input['button_type'] = 'pf-button.gif';
295
-
296
- if ( !isset( $input['custom_image'] ) )
297
- $valid_input['custom_image'] = '';
298
-
299
- if ( !in_array( $input['show_list'], array( 'all', 'single', 'posts', 'manual') ) )
300
- $valid_input['show_list'] = 'all';
301
-
302
- if ( !in_array( $input['content_position'], array( 'none', 'left', 'center', 'right' ) ) )
303
- $valid_input['content_position'] = 'left';
304
-
305
- if ( !in_array( $input['content_placement'], array( 'before', 'after' ) ) )
306
- $valid_input['content_placement'] = 'after';
307
-
308
- foreach ( array( 'margin_top', 'margin_right', 'margin_bottom', 'margin_left' ) as $opt )
309
- $valid_input[$opt] = (int) $input[$opt];
310
-
311
- $valid_input['text_size'] = (int) $input['text_size'];
312
-
313
- if ( !isset($valid_input['text_size']) || 0 == $valid_input['text_size'] ) {
314
- $valid_input['text_size'] = 14;
315
- } else if ( 25 < $valid_input['text_size'] || 9 > $valid_input['text_size'] ) {
316
- $valid_input['text_size'] = 14;
317
- add_settings_error( $this->option_name, 'invalid_color', __( 'The text size you entered is too high, please stay below 25px.', $this->hook ) );
318
- }
319
-
320
- if ( !isset( $input['text_color'] )) {
321
- $valid_input['text_color'] = $this->options['text_color'];
322
- } else if ( ! preg_match('/^#[a-f0-9]{3,6}$/i', $input['text_color'] ) ) {
323
- // Revert to previous setting and throw error.
324
- $valid_input['text_color'] = $this->options['text_color'];
325
- add_settings_error( $this->option_name, 'invalid_color', __( 'The color you entered is not valid, it must be a valid hexadecimal RGB font color.', $this->hook ) );
326
- }
327
-
328
- $valid_input['db_version'] = $this->db_version;
329
-
330
- return $valid_input;
331
- }
332
-
333
- /**
334
- * Register the config page for all users that have the manage_options capability
335
- *
336
- * @since 3.0
337
- */
338
- function add_config_page() {
339
- $this->settings_page = add_options_page( __( 'PrintFriendly Options', $this->hook ), __( 'Print Friendly & PDF', $this->hook ), 'manage_options', $this->hook, array( &$this, 'config_page' ) );
340
- }
341
-
342
- /**
343
- * Shows help on the plugin page when clicking on the Help button, top right.
344
- *
345
- * @since 3.0
346
- */
347
- function contextual_help( $contextual_help, $screen_id ) {
348
- if ( $this->settings_page == $screen_id ) {
349
- $contextual_help = '<strong>'.__( "Need Help?", $this->hook ).'</strong><br/>'
350
- .sprintf( __( "Be sure to check out the %s!"), '<a href="http://wordpress.org/extend/plugins/printfriendly/faq/">'.__( "Frequently Asked Questions", $this->hook ).'</a>' );
351
- }
352
- return $contextual_help;
353
- }
354
-
355
- /**
356
- * Enqueue the scripts for the admin settings page
357
- *
358
- * @since 3.0
359
- * @param string $hook_suffix hook to check against whether the current page is the PrintFriendly settings page.
360
- */
361
- function admin_enqueue_scripts( $screen_id ) {
362
- if ( $this->settings_page == $screen_id ) {
363
- wp_register_script( 'pf-color-picker', plugins_url( 'colorpicker.js', __FILE__ ), array( 'jquery', 'media-upload' ) );
364
- wp_register_script( 'pf-admin-js', plugins_url( 'admin.js', __FILE__ ), array( 'jquery', 'media-upload' ) );
365
-
366
- wp_enqueue_script( 'pf-color-picker' );
367
- wp_enqueue_script( 'pf-admin-js' );
368
-
369
- wp_enqueue_style( 'printfriendly-admin-css', plugins_url( 'admin.css', __FILE__ ) );
370
- }
371
- }
372
-
373
- /**
374
- * Register the settings link for the plugins page
375
- *
376
- * @since 3.0
377
- * @param array $links the links for the plugins.
378
- * @param string $file filename to check against plugins filename.
379
- * @return array $links the links with the settings link added to it if appropriate.
380
- */
381
- function filter_plugin_actions( $links, $file ){
382
- // Static so we don't call plugin_basename on every plugin row.
383
- static $this_plugin;
384
- if ( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ );
385
-
386
- if ( $file == $this_plugin ){
387
- $settings_link = '<a href="options-general.php?page='.$this->hook.'">' . __( 'Settings', $this->hook ) . '</a>';
388
- array_unshift( $links, $settings_link ); // before other links
389
- }
390
- return $links;
391
- }
392
-
393
- /**
394
- * Set default values for the plugin. If old, as in pre 1.0, settings are there, use them and then delete them.
395
- *
396
- * @since 3.0
397
- */
398
- function set_defaults() {
399
- // Set some defaults
400
- $this->options = array(
401
- 'button_type' => 'pf-button.gif',
402
- 'content_position' => 'left',
403
- 'content_placement' => 'after',
404
- 'custom_image' => '',
405
- 'custom_text' => 'Print Friendly',
406
- 'disable_css' => 'on',
407
- 'javascript_include' => 'on',
408
- 'javascript_fallback' => 'on',
409
- 'margin_top' => 0,
410
- 'margin_right' => 0,
411
- 'margin_bottom' => 0,
412
- 'margin_left' => 0,
413
- 'show_list' => 'all',
414
- 'text_color' => '#55750C',
415
- 'text_size' => 14,
416
- );
417
-
418
- // Check whether the old badly named singular options are there, if so, use the data and delete them.
419
- foreach ( array_keys( $this->options ) as $opt ) {
420
- $old_opt = get_option( 'pf_'.$opt );
421
- if ( $old_opt !== false ) {
422
- $this->options[$opt] = $old_opt;
423
- delete_option( 'pf_'.$opt );
424
- }
425
- }
426
-
427
- // This should always be set to the latest immediately when defaults are pushed in.
428
- $this->options['db_version'] = $this->db_version;
429
-
430
- update_option( $this->option_name, $this->options );
431
- }
432
-
433
- /**
434
- * Upgrades the stored options, used to add new defaults if needed etc.
435
- *
436
- * @since 3.0
437
- */
438
- function upgrade() {
439
- // Do stuff
440
-
441
- $this->options['db_version'] = $this->db_version;
442
- update_option( $this->option_name, $this->options );
443
- }
444
-
445
- /**
446
- * Displays radio button in the admin area
447
- *
448
- * @since 3.0
449
- * @param string $name the name of the radio button to generate.
450
- * @param boolean $br whether or not to add an HTML <br> tag, defaults to true.
451
- */
452
- function radio($name, $br = true){
453
- $var = '<input id="'.$name.'" class="radio" name="'.$this->option_name.'[button_type]" type="radio" value="'.$name.'" '.$this->checked( 'button_type', $name, false ).'/>';
454
- $button = $this->button( $name );
455
- if ( '' != $button )
456
- echo '<label for="'.$name.'">' . $var . $button . '</label>';
457
- else
458
- echo $var;
459
-
460
- if ( $br )
461
- echo '<br>';
462
- }
463
-
464
- /**
465
- * Displays button image in the admin area
466
- *
467
- * @since 3.0
468
- * @param string $name the name of the button to generate.
469
- */
470
- function button( $name = false ){
471
- if( !$name )
472
- $name = $this->options['button_type'];
473
-
474
- $text = $this->options['custom_text'];
475
-
476
- switch($name){
477
- case "custom-image":
478
- if( '' == $this->options['custom_image'] )
479
- return '';
480
-
481
- $return = '<img src="'.$this->options['custom_image'].'" alt="Print Friendly" />';
482
-
483
- if( $this->options['custom_text'] != '' )
484
- $return .= '<span class="printfriendly-text">'.$this->options['custom_text'].'</span>';
485
-
486
- return $return;
487
- break;
488
-
489
- case "text-only":
490
- return '<span class="printfriendly-text">'.$text.'</span>';
491
- break;
492
-
493
- case "pf-icon-both.gif":
494
- return '<img src="//cdn.printfriendly.com/pf-print-icon.gif" alt="Print Friendly"/><span class="printandpdf printfriendly-text"> Print <img src="//cdn.printfriendly.com/pf-pdf-icon.gif" alt="Get a PDF version of this webpage" /> PDF </span>';
495
- break;
496
-
497
- case "pf-icon-small.gif":
498
- case "pf-icon.gif":
499
- return '<img src="//cdn.printfriendly.com/'.$name.'" alt="Print Friendly"/><span class="printfriendly-text">'.$text.'</span>';
500
- break;
501
-
502
- default:
503
- return '<img src="//cdn.printfriendly.com/'.$name.'" alt="Print Friendly" />';
504
- break;
505
- }
506
- }
507
-
508
- /**
509
- * Convenience function to output a value for an input
510
- *
511
- * @since 3.0
512
- * @param string $val value to check.
513
- */
514
- function val( $val ) {
515
- if ( isset( $this->options[$val] ) )
516
- echo esc_attr( $this->options[$val] );
517
- }
518
-
519
- /**
520
- * Like the WordPress checked() function but it doesn't throw notices when the array key isn't set and uses the plugins options array.
521
- *
522
- * @since 3.0
523
- * @param mixed $val value to check.
524
- * @param mixed $check_against value to check against.
525
- * @param boolean $echo whether or not to echo the output.
526
- * @return string checked, when true, empty, when false.
527
- */
528
- function checked( $val, $check_against = true, $echo = true ) {
529
- if ( !isset( $this->options[$val] ) )
530
- return;
531
-
532
- if ( $this->options[$val] == $check_against ) {
533
- if ( $echo )
534
- echo ' checked="checked" ';
535
- else
536
- return ' checked="checked" ';
537
- }
538
- }
539
-
540
- /**
541
- * Output the config page
542
- *
543
- * @since 3.0
544
- */
545
- function config_page() {
546
-
547
- // 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.
548
- global $wp_version;
549
- if ( version_compare( $wp_version, '3.2', '<' ) )
550
- settings_errors();
551
-
552
- // Show the content of the options array when debug is enabled
553
- if ( WP_DEBUG )
554
- echo '<pre>Options:<br><br>' . print_r( $this->options, 1 ) . '</pre>';
555
- ?>
556
- <div id="pf_settings" class="wrap">
557
- <div class="icon32" id="printfriendly"></div>
558
- <h2><?php _e( 'Print Friendly & PDF Settings', $this->hook ); ?></h2>
559
-
560
- <form action="options.php" method="post">
561
- <?php settings_fields( $this->option_name ); ?>
562
-
563
- <table class="form-table">
564
- <tr>
565
- <th colspan="2">
566
- <h3><?php _e( "Pick a Button and/or Text", $this->hook ); ?></h3>
567
- </th>
568
- </tr>
569
- <tr>
570
- <th scope="row"><?php _e( "Pick Your Button Style", $this->hook ); ?></th>
571
- <td class="defaultavatarpicker">
572
- <fieldset>
573
- <?php $this->radio('pf-button.gif'); ?>
574
- <?php $this->radio('pf-button-both.gif'); ?>
575
- <?php $this->radio('pf-button-big.gif'); ?>
576
- <?php $this->radio('button-print-grnw20.png'); ?>
577
- <?php $this->radio('button-print-blu20.png'); ?>
578
- <?php $this->radio('button-print-gry20.png'); ?>
579
- <?php $this->radio('button-print-whgn20.png'); ?>
580
- <?php $this->radio('pf_button_sq_gry_m.png'); ?>
581
- <?php $this->radio('pf_button_sq_gry_l.png'); ?>
582
- <?php $this->radio('pf_button_sq_grn_m.png'); ?>
583
- <?php $this->radio('pf_button_sq_grn_l.png'); ?>
584
- <span class="button_preview">
585
- <?php $this->radio('pf-icon-small.gif'); ?>
586
- <?php $this->radio('pf-icon-both.gif'); ?>
587
- <?php $this->radio('pf-icon.gif'); ?>
588
- <?php $this->radio('text-only'); ?>
589
- <?php $this->radio('custom-image', false); ?>
590
- </span>
591
- <label for="custom-image"><?php _e( "Custom Image URL", $this->hook ); ?></label>
592
- <input id="custom_image" type="text" class="regular-text" size="40" name="<?php echo $this->option_name; ?>[custom_image]" value="<?php $this->val( 'custom_image' ); ?>" /><br>
593
- <span class="description"><?php _e( ".JPG .GIF or .PNG Absolute (http://www.example.com/...), or Relative (/wp/wp-content/uploads/example.png)", $this->hook ); ?></span>
594
- <br>
595
- </fieldset>
596
- </td>
597
- </tr>
598
- <tr>
599
- <th scope="row"><label for="custom_text"><?php _e( "Button Text", $this->hook ); ?></label></th>
600
- <td><input type="text" class="text" name="<?php echo $this->option_name; ?>[custom_text]" id="custom_text" value="<?php $this->val( 'custom_text' ); ?>"></td>
601
- </tr>
602
- <tr class="css">
603
- <th colspan="2">
604
- <h3><?php _e( "Style the Button and Text", $this->hook ); ?></h3>
605
- </th>
606
- </tr>
607
- <tr class="css">
608
- <th scope="row"><?php _e( "Text Color", $this->hook ); ?></th>
609
- <td>
610
- <div id="colorSelector"><div style="background-color: <?php echo $this->options['text_color']; ?>;"></div></div>
611
- <input type="hidden" name="<?php echo $this->option_name; ?>[text_color]" id="text_color" value="<?php $this->val( 'text_color' ); ?>"/><br>
612
- <span class="description"><?php _e( "Use the color picker, or enter a valid hex color in the color picker input box.", $this->hook ); ?></span>
613
- </td>
614
- </tr>
615
- <tr class="css">
616
- <th scope="row"<label for="text_size"><?php _e( "Text Size", $this->hook ); ?></label></th>
617
- <td>
618
- <input type="number" id="text_size" min="9" max="25" class="small-text" name="<?php echo $this->option_name; ?>[text_size]" value="<?php $this->val( 'text_size' ); ?>"/>
619
- <span class="description"><?php _e( "In pixels (px)", $this->hook ); ?></span>
620
- </td>
621
- </tr>
622
- <tr class="css">
623
- <th scope="row"><?php _e( "Margin", $this->hook ); ?></th>
624
- <td>
625
- <label><input class="small-text" type="number" name="<?php echo $this->option_name; ?>[margin_left]" value="<?php $this->val( 'margin_left' ); ?>" maxlength="3"/> <?php _e( "Left", $this->hook ); ?></label> &nbsp;&nbsp;&nbsp; <span class="description"><?php _e( "In pixels (px)", $this->hook ); ?></span><br>
626
- <label><input class="small-text" type="number" name="<?php echo $this->option_name; ?>[margin_right]" value="<?php $this->val( 'margin_right' ); ?>"/> <?php _e( "Right", $this->hook ); ?></label><br>
627
- <label><input class="small-text" type="number" name="<?php echo $this->option_name; ?>[margin_top]" value="<?php $this->val( 'margin_top' ); ?>" maxlength="3"/> <?php _e( "Top", $this->hook ); ?></label><br>
628
- <label><input class="small-text" type="number" name="<?php echo $this->option_name; ?>[margin_bottom]" value="<?php $this->val( 'margin_bottom' ); ?>" maxlength="3"/> <?php _e( "Bottom", $this->hook ); ?></label><br>
629
- </td>
630
- </tr>
631
- <tr>
632
- <th colspan="2">
633
- <h3><?php _e( "Button Placement", $this->hook ); ?></h3>
634
- </th>
635
- </tr>
636
- <tr>
637
- <th scope="row"><?php _e( "Horizontal Alignment", $this->hook ); ?></th>
638
- <td>
639
- <label><input type="radio" name="<?php echo $this->option_name; ?>[content_position]" value="none" <?php $this->checked( 'content_position', 'none'); ?>/> <?php _e( "None", $this->hook ); ?></label><br>
640
- <label><input type="radio" name="<?php echo $this->option_name; ?>[content_position]" value="left" <?php $this->checked( 'content_position', 'left'); ?>/> <?php _e( "Left", $this->hook ); ?></label><br>
641
- <label><input type="radio" name="<?php echo $this->option_name; ?>[content_position]" value="right" <?php $this->checked( 'content_position', 'right') ?>/> <?php _e( "Right", $this->hook ); ?></label><br>
642
- <label><input type="radio" name="<?php echo $this->option_name; ?>[content_position]" value="center" <?php $this->checked( 'content_position', 'center') ?>/> <?php _e( "Center", $this->hook ); ?></label><br>
643
- </td>
644
- </tr>
645
- <tr class="content_placement">
646
- <th scope="row"><?php _e( "Vertical Position", $this->hook ); ?></th>
647
- <td>
648
- <label><input type="radio" name="<?php echo $this->option_name; ?>[content_placement]" value="before" <?php $this->checked( 'content_placement', 'before'); ?> <?php if( $this->options['show_list']=='manual'){ echo 'disabled="disabled"'; } ?>/> <?php _e( "Before Content", $this->hook ); ?></label><br>
649
- <label><input type="radio" name="<?php echo $this->option_name; ?>[content_placement]" value="after" <?php $this->checked( 'content_placement', 'after'); ?> <?php if( $this->options['show_list']=='manual'){ echo 'disabled="disabled"'; } ?>/> <?php _e( "After Content", $this->hook ); ?></label><br>
650
- </td>
651
- </tr>
652
- <tr>
653
- <th scope="row"><?php _e( "Add PrintFriendly To", $this->hook ); ?></th>
654
- <td>
655
- <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="all" <?php $this->checked( 'show_list', 'all'); ?>/> <?php _e( "Homepage, Archives, Posts, and Pages", $this->hook ); ?></label><br>
656
- <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="single" <?php $this->checked( 'show_list', 'single'); ?>/> <?php _e( "Posts and Pages", $this->hook ); ?></label><br>
657
- <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="posts" <?php $this->checked( 'show_list', 'posts'); ?>/> <?php _e( "Posts", $this->hook ); ?></label><br>
658
- <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="manual" <?php $this->checked( 'show_list', 'manual'); ?> /> <?php _e( "Manual", $this->hook ); ?></label><br>
659
- <div id="addmanual-help">
660
- <p><?php _e( "Copy and paste the code below anywhere in your template pages.", $this->hook ); ?></p>
661
- <code style="display:block;">&lt;?php if(function_exists('pf_show_link')){echo pf_show_link();} ?&gt;</code>
662
- </div>
663
- </td>
664
- </tr>
665
- <tr>
666
- <th colspan="2">
667
- <h3><?php _e( "Other Settings", $this->hook ); ?></h3>
668
- </th>
669
- </tr>
670
- <tr>
671
- <th scope="row"><?php _e( "CSS Stylesheet", $this->hook ); ?></th>
672
- <td>
673
- <label><input type="checkbox" id="disable_css" name="<?php echo $this->option_name; ?>[disable_css]" <?php $this->checked( 'disable_css', 'on' ); ?>/> <?php _e( "Add CSS to pages", $this->hook ); ?></label><br/>
674
- <p class="description">
675
- <?php _e( "If you uncheck this box you have to add the styling for the PrintFriendly button to your theme's stylesheet.", $this->hook ); ?>
676
- </p>
677
- </td>
678
- </tr>
679
- <tr>
680
- <th scope="row"><?php _e( "JavaScript", $this->hook ); ?></th>
681
- <td>
682
- <label><input type="checkbox" name="<?php echo $this->option_name; ?>[javascript_fallback]" <?php $this->checked( 'javascript_fallback', 'on' ); ?>/> <?php _e( "JavaScript Fallback", $this->hook ); ?></label><br/>
683
- <p class="description">
684
- <?php _e( "If you uncheck this box users without JavaScript will be unable to use the PrintFriendly service.", $this->hook ); ?>
685
- </p>
686
- <label><input type="checkbox" name="<?php echo $this->option_name; ?>[javascript_include]" <?php $this->checked( 'javascript_include', 'on' ); ?>/> <?php _e( "Include JavaScript", $this->hook ); ?></label><br/>
687
- <p class="description">
688
- <?php _e( "If you uncheck this box, all buttons will become links to the PrintFriendly webservice and the PrintFriendly JavaScript will not be loaded on your site.", $this->hook ); ?>
689
- </p>
690
- </td>
691
- </tr>
692
- </table>
693
-
694
- <p class="submit">
695
- <input type="submit" class="button-primary" value="<?php esc_attr_e( "Save Options", $this->hook ); ?>"/>
696
- <input type="reset" class="button-secondary" value="<?php esc_attr_e( "Cancel", $this->hook ); ?>"/>
697
- </p>
698
- <p>
699
- <?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>.
700
- </p>
701
- </form>
702
- </div>
703
- <?php
704
- }
705
- }
706
- $printfriendly = new PrintFriendly_WordPress();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
707
  }
708
 
709
  /**
@@ -713,6 +843,6 @@ if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
713
  * @return string returns a button to be printed.
714
  */
715
  function pf_show_link() {
716
- global $printfriendly;
717
- return $printfriendly->show_link();
718
  }
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.0.9
8
  Author: Print Friendly
9
  Author URI: http://www.PrintFriendly.com
10
 
11
  Changelog :
12
+ 3.0.9 - New features: Custom header, disable click-to-delete, https support (beta), PrintFriendly Pro (ad-free).
13
  3.0.8 - Reordered PrintFriendly & PDF buttons. CSS stylesheet option is now checked by default.
14
  3.0.7 - Added additional images for print button.
15
  3.0.6 - Fix bug that would display button on category pages when not wanted.
19
  3.0.2 - Fixed JS bug with Google Chrome not submitting and fixed input validation issues.
20
  3.0.1 - Fixed minor JS bug.
21
  3.0 - Complete overhaul of the plugin by Joost de Valk.
22
+ 2.1.8 - The Print Button was showing up on printed, or PDF, pages. Junk! Print or PDF button no longer displayed on printed out page or PDF.
23
  2.1.7 - Changed button from span to div to support floating.
24
  2.1.6 - Added rel="nofollow" to links. Changed button from <a> to <span> to fix target_new or target_blank issues.
25
  2.1.5 - Fix conflict with link tracking plugins. Custom image support for hosted wordpress sites.
33
  1.4 - Changed Name.
34
  1.3 - Added new buttons, removed redundant code.
35
  1.2 - User can choose to show or not show buttons on the listing page.
36
+ */
37
+
38
  /**
39
  * PrintFriendly WordPress plugin. Allows easy embedding of printfriendly.com buttons.
40
  * @package PrintFriendly_WordPress
41
+ * @author PrintFriendly <support@printfriendly.com>
42
+ * @copyright Copyright (C) 2012, PrintFriendly
43
  */
44
  if ( ! class_exists( 'PrintFriendly_WordPress' ) ) {
45
 
46
+ /**
47
+ * Class containing all the plugins functionality.
48
+ * @package PrintFriendly_WordPress
49
+ */
50
+ class PrintFriendly_WordPress {
51
+ /**
52
+ * The hook, used for text domain as well as hooks on pages and in get requests for admin.
53
+ * @var string
54
+ */
55
+ var $hook = 'printfriendly';
56
+
57
+ /**
58
+ * The option name, used throughout to refer to the plugins option and option group.
59
+ * @var string
60
+ */
61
+ var $option_name = 'printfriendly_option';
62
+
63
+ /**
64
+ * The plugins options, loaded on init containing all the plugins settings.
65
+ * @var array
66
+ */
67
+ var $options = array();
68
+
69
+ /**
70
+ * Database version, used to allow for easy upgrades to / additions in plugin options between plugin versions.
71
+ * @var int
72
+ */
73
+ var $db_version = 2;
74
+
75
+ /**
76
+ * Settings page, used within the plugin to reliably load the plugins admin JS and CSS files only on the admin page.
77
+ * @var string
78
+ */
79
+ var $settings_page = '';
80
+
81
+ /**
82
+ * Constructor
83
+ *
84
+ * @since 3.0
85
+ */
86
+ function __construct() {
87
+ // delete_option( $this->option_name );
88
+
89
+ // Retrieve the plugin options
90
+ $this->options = get_option( $this->option_name );
91
+
92
+ // If the options array is empty, set defaults
93
+ if ( ! is_array( $this->options ) )
94
+ $this->set_defaults();
95
+
96
+ // If the version number doesn't match, upgrade
97
+ if ( $this->db_version > $this->options['db_version'] )
98
+ $this->upgrade();
99
+
100
+ add_action( 'wp_head', array( &$this, 'front_head' ) );
101
+ // automaticaly add the link
102
+ if( 'manual' != $this->options['show_list'] ) {
103
+ add_filter( 'the_content', array( &$this, 'show_link' ) );
104
+ add_filter( 'the_excerpt', array( &$this, 'show_link' ) );
105
+ }
106
+
107
+ if ( !is_admin() )
108
+ return;
109
+
110
+ // Hook into init for registration of the option and the language files
111
+ add_action( 'admin_init', array( &$this, 'init' ) );
112
+
113
+ // Register the settings page
114
+ add_action( 'admin_menu', array( &$this, 'add_config_page' ) );
115
+
116
+ // Register the contextual help
117
+ add_filter( 'contextual_help', array( &$this, 'contextual_help' ), 10, 2 );
118
+
119
+ // Enqueue the needed scripts and styles
120
+ add_action( 'admin_enqueue_scripts',array( &$this, 'admin_enqueue_scripts' ) );
121
+
122
+ // Register a link to the settings page on the plugins overview page
123
+ add_filter( 'plugin_action_links', array( &$this, 'filter_plugin_actions' ), 10, 2 );
124
+ }
125
+
126
+ /**
127
+ * PHP 4 Compatible Constructor
128
+ *
129
+ * @since 3.0
130
+ */
131
+ function PrintFriendly_WordPress() {
132
+ $this->__construct();
133
+ }
134
+
135
+ /**
136
+ * Prints the PrintFriendly button CSS, in the header.
137
+ *
138
+ * @since 3.0
139
+ */
140
+ function front_head() {
141
+
142
+ if ( !isset( $this->options['enable_css'] ) || $this->options['enable_css'] != 'on' )
143
+ return;
144
+
145
+ ?>
146
+ <style type="text/css" media="screen">
147
+ div.printfriendly {
148
+ margin: <?php echo $this->options['margin_top'].'px '.$this->options['margin_right'].'px '.$this->options['margin_bottom'].'px '.$this->options['margin_left'].'px'; ?>;
149
+ }
150
+ .printfriendly a {
151
+ text-decoration: none;
152
+ font-size: <?php echo $this->options['text_size']; ?>px;
153
+ color: <?php echo $this->options['text_color']; ?>;
154
+ vertical-align: bottom;
155
+ }
156
+
157
+ .printfriendly a:hover {
158
+ cursor: pointer;
159
+ }
160
+
161
+ .printfriendly a img {
162
+ border: none;
163
+ padding:0;
164
+ margin-right: 6px;
165
+ }
166
+ .printfriendly a span{
167
+ vertical-align: bottom;
168
+ }
169
+ .alignleft {
170
+ float:left;
171
+ margin: 5px 20px 20px 0;
172
+ }
173
+ .alignright {
174
+ float:right;
175
+ margin: 5px 0 20px 20px;
176
+ }
177
+ .aligncenter {
178
+ text-align: center;
179
+ margin: 5px auto 5px auto;
180
+ }
181
+ </style>
182
+ <style type="text/css" media="print">
183
+ .printfriendly {
184
+ display: none;
185
+ }
186
+ </style>
187
+ <?php
188
+ }
189
+
190
+ /**
191
+ * Prints the PrintFriendly JavaScript, in the footer, and loads it asynchronously.
192
+ *
193
+ * @since 3.0
194
+ */
195
+ function print_script_footer() {
196
+ if (isset($this->options['javascript']) && $this->options['javascript'] == 'no')
197
+ return;
198
+
199
+ else {
200
+ $tagline = $this->options['tagline'];
201
+ $image_url = $this->options['image_url'];
202
+ if( $this->options['logo'] == 'favicon' ) {
203
+ $tagline = '';
204
+ $image_url = '';
205
+ }
206
+
207
+ // Currently we use v3 for both: normal and password protected sites
208
+ $pf_src = '//cdn.printfriendly.com/printfriendly.js';
209
+ if($this->options['website_protocol'] == 'https')
210
+ $pf_src = 'https://pf-cdn.printfriendly.com/ssl/main.js';
211
+
212
+
213
+ ?>
214
+ <script type="text/javascript">
215
+ var pfHeaderImgUrl = "<?php echo $image_url ?>";
216
+ var pfHeaderTagline = "<?php echo $tagline ?>";
217
+ var pfdisableClickToDel = "<?php echo $this->options['click_to_delete'] ?>";
218
+
219
+ // PrintFriendly
220
+ var e = document.createElement('script'); e.type="text/javascript";
221
+ e.async = true;
222
+ e.src = '<?php echo $pf_src ?>';
223
+ document.getElementsByTagName('head')[0].appendChild(e);
224
+ </script>
225
+ <?php
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Primary frontend function, used either as a filter for the_content, or directly using pf_show_link
231
+ *
232
+ * @since 3.0
233
+ * @param string $content the content of the post, when the function is used as a filter
234
+ * @return string $button or $content with the button added to the content when appropriate, just the content when button shouldn't be added or just button when called manually.
235
+ */
236
+ function show_link( $content = false ) {
237
+ if( !$content && 'manual' != $this->options['show_list'] )
238
+ return "";
239
+
240
+ $onclick = 'onclick="window.print(); return false;"';
241
+ $href = 'http://www.printfriendly.com/print/v2?url='.get_permalink();
242
+
243
+ if ( isset( $this->options['javascript'] ) && $this->options['javascript'] == 'no' )
244
+ $onclick = 'target="_blank"';
245
+
246
+ if ( !is_singular() && '' != $onclick ) {
247
+ $onclick = '';
248
+ $href = get_permalink().'?pfstyle=wp';
249
+ }
250
+
251
+ $align = '';
252
+ if ( 'none' != $this->options['content_position'] )
253
+ $align = ' align'.$this->options['content_position'];
254
+
255
+ $button = apply_filters( 'printfriendly_button', '<div class="printfriendly'.$align.'"><a href="'.$href.'" rel="nofollow" '.$onclick.'>'.$this->button().'</a></div>' );
256
+
257
+ if (is_singular())
258
+ {
259
+ // Hook the script call now, so it only get's loaded when needed, and need is determined by the user calling pf_button
260
+ add_action( 'wp_footer', array( &$this, 'print_script_footer' ) );
261
+ }
262
+
263
+ if ( 'manual' == $this->options['show_list'] )
264
+ {
265
+ return $button;
266
+ }
267
+
268
+ else
269
+ {
270
+ if (is_single() || ( is_page() && 'posts' != $this->options['show_list'] ) || ((is_home() || is_category()) && 'all' == $this->options['show_list'] ))
271
+ {
272
+
273
+ if ( $this->options['content_placement'] == 'before' )
274
+ return $button.$content;
275
+ else
276
+ return $content.$button;
277
+ }
278
+
279
+ else
280
+ {
281
+ return $content;
282
+ }
283
+
284
+ }
285
+
286
+ }
287
+
288
+ /**
289
+ * Register the textdomain and the options array along with the validation function
290
+ *
291
+ * @since 3.0
292
+ */
293
+ function init() {
294
+ // Allow for localization
295
+ load_plugin_textdomain( $this->hook, false, basename( dirname( __FILE__ ) ) . '/languages' );
296
+
297
+ // Register our option array
298
+ register_setting( $this->option_name, $this->option_name, array( &$this, 'options_validate' ) );
299
+ }
300
+
301
+ /**
302
+ * Validate the saved options.
303
+ *
304
+ * @since 3.0
305
+ * @param array $input with unvalidated options.
306
+ * @return array $valid_input with validated options.
307
+ */
308
+ function options_validate( $input ) {
309
+ $valid_input = $input;
310
+
311
+ // echo '<pre>'.print_r($input,1).'</pre>';
312
+ // die;
313
+
314
+ 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') ) )
315
+ $valid_input['button_type'] = 'pf-button.gif';
316
+
317
+ if ( !isset( $input['custom_image'] ) )
318
+ $valid_input['custom_image'] = '';
319
+
320
+ if ( !in_array( $input['show_list'], array( 'all', 'single', 'posts', 'manual') ) )
321
+ $valid_input['show_list'] = 'all';
322
+
323
+ if ( !in_array( $input['content_position'], array( 'none', 'left', 'center', 'right' ) ) )
324
+ $valid_input['content_position'] = 'left';
325
+
326
+ if ( !in_array( $input['content_placement'], array( 'before', 'after' ) ) )
327
+ $valid_input['content_placement'] = 'after';
328
+
329
+ foreach ( array( 'margin_top', 'margin_right', 'margin_bottom', 'margin_left' ) as $opt )
330
+ $valid_input[$opt] = (int) $input[$opt];
331
+
332
+ $valid_input['text_size'] = (int) $input['text_size'];
333
+
334
+ if ( !isset($valid_input['text_size']) || 0 == $valid_input['text_size'] ) {
335
+ $valid_input['text_size'] = 14;
336
+ } else if ( 25 < $valid_input['text_size'] || 9 > $valid_input['text_size'] ) {
337
+ $valid_input['text_size'] = 14;
338
+ add_settings_error( $this->option_name, 'invalid_color', __( 'The text size you entered is invalid, please stay between 9px and 25px', $this->hook ) );
339
+ }
340
+
341
+ if ( !isset( $input['text_color'] )) {
342
+ $valid_input['text_color'] = $this->options['text_color'];
343
+ } else if ( ! preg_match('/^#[a-f0-9]{3,6}$/i', $input['text_color'] ) ) {
344
+ // Revert to previous setting and throw error.
345
+ $valid_input['text_color'] = $this->options['text_color'];
346
+ add_settings_error( $this->option_name, 'invalid_color', __( 'The color you entered is not valid, it must be a valid hexadecimal RGB font color.', $this->hook ) );
347
+ }
348
+
349
+ $valid_input['db_version'] = $this->db_version;
350
+
351
+ return $valid_input;
352
+ }
353
+
354
+ /**
355
+ * Register the config page for all users that have the manage_options capability
356
+ *
357
+ * @since 3.0
358
+ */
359
+ function add_config_page() {
360
+ $this->settings_page = add_options_page( __( 'PrintFriendly Options', $this->hook ), __( 'Print Friendly & PDF', $this->hook ), 'manage_options', $this->hook, array( &$this, 'config_page' ) );
361
+ }
362
+
363
+ /**
364
+ * Shows help on the plugin page when clicking on the Help button, top right.
365
+ *
366
+ * @since 3.0
367
+ */
368
+ function contextual_help( $contextual_help, $screen_id ) {
369
+ if ( $this->settings_page == $screen_id ) {
370
+ $contextual_help = '<strong>'.__( "Need Help?", $this->hook ).'</strong><br/>'
371
+ .sprintf( __( "Be sure to check out the %s!"), '<a href="http://wordpress.org/extend/plugins/printfriendly/faq/">'.__( "Frequently Asked Questions", $this->hook ).'</a>' );
372
+ }
373
+ return $contextual_help;
374
+ }
375
+
376
+ /**
377
+ * Enqueue the scripts for the admin settings page
378
+ *
379
+ * @since 3.0
380
+ * @param string $hook_suffix hook to check against whether the current page is the PrintFriendly settings page.
381
+ */
382
+ function admin_enqueue_scripts( $screen_id ) {
383
+ if ( $this->settings_page == $screen_id ) {
384
+ wp_register_script( 'pf-color-picker', plugins_url( 'colorpicker.js', __FILE__ ), array( 'jquery', 'media-upload' ) );
385
+ wp_register_script( 'pf-admin-js', plugins_url( 'admin.js', __FILE__ ), array( 'jquery', 'media-upload' ) );
386
+
387
+ wp_enqueue_script( 'pf-color-picker' );
388
+ wp_enqueue_script( 'pf-admin-js' );
389
+
390
+ wp_enqueue_style( 'printfriendly-admin-css', plugins_url( 'admin.css', __FILE__ ) );
391
+ }
392
+ }
393
+
394
+ /**
395
+ * Register the settings link for the plugins page
396
+ *
397
+ * @since 3.0
398
+ * @param array $links the links for the plugins.
399
+ * @param string $file filename to check against plugins filename.
400
+ * @return array $links the links with the settings link added to it if appropriate.
401
+ */
402
+ function filter_plugin_actions( $links, $file ){
403
+ // Static so we don't call plugin_basename on every plugin row.
404
+ static $this_plugin;
405
+ if ( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ );
406
+
407
+ if ( $file == $this_plugin ){
408
+ $settings_link = '<a href="options-general.php?page='.$this->hook.'">' . __( 'Settings', $this->hook ) . '</a>';
409
+ array_unshift( $links, $settings_link ); // before other links
410
+ }
411
+ return $links;
412
+ }
413
+
414
+ /**
415
+ * Set default values for the plugin. If old, as in pre 1.0, settings are there, use them and then delete them.
416
+ *
417
+ * @since 3.0
418
+ */
419
+ function set_defaults() {
420
+ // Set some defaults
421
+ $this->options = array(
422
+ 'button_type' => 'pf-button.gif',
423
+ 'content_position' => 'left',
424
+ 'content_placement' => 'after',
425
+ 'custom_image' => 'http://cdn.printfriendly.com/pf-icon.gif',
426
+ 'custom_text' => 'Print Friendly',
427
+ 'enable_css' => 'on',
428
+ 'margin_top' => '12',
429
+ 'margin_right' => '12',
430
+ 'margin_bottom' => '12',
431
+ 'margin_left' => '12',
432
+ 'show_list' => 'single',
433
+ 'text_color' => '#6D9F00',
434
+ 'text_size' => 14,
435
+ 'logo' => 'favicon',
436
+ 'image_url' => '',
437
+ 'tagline' => '',
438
+ 'click_to_delete' => '0', // 0 - allow, 1 - do not allow
439
+ 'website_protocol' => 'http',
440
+ 'password_protected' => 'no',
441
+ 'javascript' => 'yes'
442
+ );
443
+
444
+ // Check whether the old badly named singular options are there, if so, use the data and delete them.
445
+ foreach ( array_keys( $this->options ) as $opt ) {
446
+ $old_opt = get_option( 'pf_'.$opt );
447
+ if ( $old_opt !== false ) {
448
+ $this->options[$opt] = $old_opt;
449
+ delete_option( 'pf_'.$opt );
450
+ }
451
+ }
452
+
453
+ // This should always be set to the latest immediately when defaults are pushed in.
454
+ $this->options['db_version'] = $this->db_version;
455
+
456
+ update_option( $this->option_name, $this->options );
457
+ }
458
+
459
+ /**
460
+ * Upgrades the stored options, used to add new defaults if needed etc.
461
+ *
462
+ * @since 3.0
463
+ */
464
+ function upgrade() {
465
+ // Do stuff
466
+
467
+ // update options to version 2
468
+ if($this->options['db_version'] < 2) {
469
+
470
+ $additional_options = array(
471
+ 'enable_css' => 'on',
472
+ 'logo' => 'favicon',
473
+ 'image_url' => '',
474
+ 'tagline' => '',
475
+ 'click_to_delete' => '0',
476
+ 'website_protocol' => 'http',
477
+ 'password_protected' => 'no',
478
+ 'javascript' => 'yes'
479
+ );
480
+
481
+ // use old javascript_include value to initialize javascript
482
+ if(!isset($this->options['javascript_include']))
483
+ $additional_options['javascript'] = 'no';
484
+
485
+ unset($this->options['javascript_include']);
486
+ unset($this->options['javascript_fallback']);
487
+
488
+ // correcting badly named option
489
+ if(isset($this->options['disable_css'])) {
490
+ $additional_options['enable_css'] = $this->options['disable_css'];
491
+ unset($this->options['disable_css']);
492
+ }
493
+
494
+ // check whether image we do not list any more was used
495
+ 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'))) {
496
+ // previous version had a bug with button name
497
+ if(in_array($this->options['button_type'], array('pf_button_sq_qry_m.png', 'pf_button_sq_qry_l.png')))
498
+ $this->options['button_type'] = str_replace('qry', 'gry', $this->options['button_type']);
499
+
500
+ $image_address = '//cdn.printfriendly.com/'.$this->options['button_type'];
501
+ $this->options['button_type'] = 'custom-image';
502
+ $this->options['custom_text'] = '';
503
+ $this->options['custom_image'] = $image_address;
504
+ }
505
+
506
+ $this->options = array_merge($this->options, $additional_options);
507
+ }
508
+
509
+ $this->options['db_version'] = $this->db_version;
510
+ update_option( $this->option_name, $this->options );
511
+ }
512
+
513
+ /**
514
+ * Displays radio button in the admin area
515
+ *
516
+ * @since 3.0
517
+ * @param string $name the name of the radio button to generate.
518
+ * @param boolean $br whether or not to add an HTML <br> tag, defaults to true.
519
+ */
520
+ function radio($name, $br = false){
521
+ $var = '<input id="'.$name.'" class="radio" name="'.$this->option_name.'[button_type]" type="radio" value="'.$name.'" '.$this->checked( 'button_type', $name, false ).'/>';
522
+ $button = $this->button( $name );
523
+ if ( '' != $button )
524
+ echo '<label for="'.$name.'">' . $var . $button . '</label>';
525
+ else
526
+ echo $var;
527
+
528
+ if ( $br )
529
+ echo '<br>';
530
+ }
531
+
532
+ /**
533
+ * Displays button image in the admin area
534
+ *
535
+ * @since 3.0
536
+ * @param string $name the name of the button to generate.
537
+ */
538
+ function button( $name = false ){
539
+ if( !$name )
540
+ $name = $this->options['button_type'];
541
+
542
+ $text = $this->options['custom_text'];
543
+
544
+ switch($name){
545
+ case "custom-image":
546
+ if( '' == $this->options['custom_image'] )
547
+ $return = '';
548
+ else
549
+ $return = '<img src="'.$this->options['custom_image'].'" alt="Print Friendly" />';
550
+
551
+ $return .= $this->options['custom_text'];
552
+
553
+ return $return;
554
+ break;
555
+ case "text-only":
556
+ return '<span class="printfriendly-text2">'.$text.'</span>';
557
+ break;
558
+
559
+ case "pf-icon-both.gif":
560
+ return '<span class="printfriendly-text2 printandpdf"><img style="border:none;margin-right:6px;" src="http://cdn.printfriendly.com/pf-print-icon.gif" width="16" height="15" alt="Print Friendly Version of this page" />Print <img style="border:none;margin:0 6px" src="http://cdn.printfriendly.com/pf-pdf-icon.gif" width="12" height="12" alt="Get a PDF version of this webpage" />PDF</span>';
561
+ break;
562
+
563
+ case "pf-icon-small.gif":
564
+ return '<img style="border:none;margin-right:4px;" src="http://cdn.printfriendly.com/pf-icon-small.gif" alt="PrintFriendly and PDF" width="18" height="18"><span class="printfriendly-text2">'.$text.'</span>';
565
+ break;
566
+ case "pf-icon.gif":
567
+ return '<img style="border:none;margin-right:6px;" src="http://cdn.printfriendly.com/pf-icon.gif" width="23" height="25" alt="PrintFriendly and PDF"><span class="printfriendly-text2">'.$text.'</span>';
568
+ break;
569
+
570
+ default:
571
+ return '<img src="//cdn.printfriendly.com/'.$name.'" alt="Print Friendly" />';
572
+ break;
573
+ }
574
+ }
575
+
576
+
577
+ /**
578
+ * Convenience function to output a value custom button preview elements
579
+ *
580
+ * @since 3.0.9
581
+ */
582
+ function custom_button_preview() {
583
+ if( '' == trim($this->options['custom_image']) )
584
+ $button_preview = '<span id="pf-custom-button-preview"></span>';
585
+ else
586
+ $button_preview = '<span id="pf-custom-button-preview"><img src="'.$this->options['custom_image'].'" alt="Print Friendly" /></span>';
587
+
588
+ $button_preview .= '<span class="printfriendly-text2">'.$this->options['custom_text'].'</span>';
589
+
590
+ echo $button_preview;
591
+ }
592
+
593
+ /**
594
+ * Convenience function to output a value for an input
595
+ *
596
+ * @since 3.0
597
+ * @param string $val value to check.
598
+ */
599
+ function val( $val ) {
600
+ if ( isset( $this->options[$val] ) )
601
+ echo esc_attr( $this->options[$val] );
602
+ }
603
+
604
+ /**
605
+ * Like the WordPress checked() function but it doesn't throw notices when the array key isn't set and uses the plugins options array.
606
+ *
607
+ * @since 3.0
608
+ * @param mixed $val value to check.
609
+ * @param mixed $check_against value to check against.
610
+ * @param boolean $echo whether or not to echo the output.
611
+ * @return string checked, when true, empty, when false.
612
+ */
613
+ function checked( $val, $check_against = true, $echo = true ) {
614
+ if ( !isset( $this->options[$val] ) )
615
+ return;
616
+
617
+ if ( $this->options[$val] == $check_against ) {
618
+ if ( $echo )
619
+ echo ' checked="checked" ';
620
+ else
621
+ return ' checked="checked" ';
622
+ }
623
+ }
624
+
625
+
626
+ /**
627
+ * Like the WordPress selected() function but it doesn't throw notices when the array key isn't set and uses the plugins options array.
628
+ *
629
+ * @since 3.0.9
630
+ * @param mixed $val value to check.
631
+ * @param mixed $check_against value to check against.
632
+ * @return string checked, when true, empty, when false.
633
+ */
634
+ function selected( $val, $check_against = true) {
635
+ if ( !isset( $this->options[$val] ) )
636
+ return;
637
+
638
+ return selected ($this->options[$val], $check_against);
639
+ }
640
+
641
+ /**
642
+ * Output the config page
643
+ *
644
+ * @since 3.0
645
+ */
646
+ function config_page() {
647
+
648
+ // 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.
649
+ global $wp_version;
650
+ if ( version_compare( $wp_version, '3.2', '<' ) )
651
+ settings_errors();
652
+
653
+ // Show the content of the options array when debug is enabled
654
+ if ( WP_DEBUG )
655
+ echo '<pre>Options:<br><br>' . print_r( $this->options, 1 ) . '</pre>';
656
+ ?>
657
+ <div id="pf_settings" class="wrap">
658
+
659
+ <div class="icon32" id="printfriendly"></div>
660
+ <h2><?php _e( 'Print Friendly & PDF Settings', $this->hook ); ?></h2>
661
+
662
+ <form action="options.php" method="post">
663
+ <?php settings_fields( $this->option_name ); ?>
664
+
665
+ <h3><?php _e( "Pick Your Button Style", $this->hook ); ?></h3>
666
+
667
+ <fieldset id="button-style">
668
+ <div id="buttongroup1">
669
+ <?php $this->radio('pf-button.gif'); ?>
670
+ <?php $this->radio('pf-button-both.gif'); ?>
671
+ <?php $this->radio('pf-button-big.gif'); ?>
672
+ </div>
673
+ <div id="buttongroup2">
674
+ <?php $this->radio('button-print-grnw20.png'); ?>
675
+ <?php $this->radio('button-print-blu20.png'); ?>
676
+ <?php $this->radio('button-print-gry20.png'); ?>
677
+ </div>
678
+ <div id="buttongroup3">
679
+ <?php $this->radio('pf-icon-small.gif'); ?>
680
+ <?php $this->radio('pf-icon-both.gif'); ?>
681
+ <?php $this->radio('pf-icon.gif'); ?>
682
+ <?php $this->radio('text-only'); ?>
683
+ </div>
684
+
685
+ <div id="custom">
686
+ <label for="custom-image">
687
+ <?php echo '<input id="custom-image" class="radio" name="'.$this->option_name.'[button_type]" type="radio" value="custom-image" '.$this->checked( 'button_type', 'custom-image', false ).'/>'; ?>
688
+ <?php _e( "Custom Button", $this->hook ); ?>
689
+ </label>
690
+ <div id="custom-img">
691
+ <?php _e( "Enter Image URL", $this->hook ); ?><br>
692
+ <input id="custom_image" type="text" class="clear regular-text" size="30" name="<?php echo $this->option_name; ?>[custom_image]" value="<?php $this->val( 'custom_image' ); ?>" />
693
+ <div class="description"><?php _e( "Ex: http://www.example.com/<br>Ex: /wp/wp-content/uploads/example.png)", $this->hook ); ?>
694
+ </div>
695
+ </div>
696
+ <div id="pf-custom-button-error"></div>
697
+ <div id="custom-txt" >
698
+ <div id="txt-enter">
699
+ <?php _e( "Text", $this->hook ); ?><br>
700
+ <input type="text" size="10" name="<?php echo $this->option_name; ?>[custom_text]" id="custom_text" value="<?php $this->val( 'custom_text' ); ?>">
701
+ </div>
702
+ <div id="txt-color">
703
+ <?php _e( "Text Color", $this->hook ); ?>
704
+ <input type="hidden" name="<?php echo $this->option_name; ?>[text_color]" id="text_color" value="<?php $this->val( 'text_color' ); ?>"/><br>
705
+ <div id="colorSelector">
706
+ <div style="background-color: <?php echo $this->options['text_color']; ?>;"></div>
707
+ </div>
708
+ </div>
709
+ <div id="txt-size">
710
+ <?php _e( "Text Size", $this->hook ); ?><br>
711
+ <input type="number" id="text_size" min="9" max="25" class="small-text" name="<?php echo $this->option_name; ?>[text_size]" value="<?php $this->val( 'text_size' ); ?>"/>
712
+ </div>
713
+ </div>
714
+ <div id="custom-button-preview">
715
+ <?php $this->custom_button_preview(); ?>
716
+ </div>
717
+ </fieldset>
718
+ <br class="clear">
719
+
720
+ <!--Section 2 Button Placement-->
721
+ <div id="button-placement">
722
+ <h3><?php _e( "Button Placement", $this->hook ); ?></h3>
723
+ <input type="hidden" name="<?php echo $this->option_name; ?>[enable_css]" value="<?php $this->val('enable_css');?>"/>
724
+ <div id="button-placement-options">
725
+ <div id="alignment">
726
+ <label>
727
+ <select id="pf_content_position" name="<?php echo $this->option_name; ?>[content_position]" >
728
+ <option value="left" <?php selected( $this->options['content_position'], 'left' ); ?>><?php _e( "Left Align", $this->hook ); ?></option>
729
+ <option value="right" <?php selected( $this->options['content_position'], 'right' ); ?>><?php _e( "Right Align", $this->hook ); ?></option>
730
+ <option value="center" <?php selected( $this->options['content_position'], 'center' ); ?>><?php _e( "Center", $this->hook ); ?></option>
731
+ <option value="none" <?php selected( $this->options['content_position'], 'none' ); ?>><?php _e( "None", $this->hook ); ?></option>
732
+ </select>
733
+ </label>
734
+ </div>
735
+ <div class="content_placement">
736
+ <label>
737
+ <select id="pf_content_placement" name="<?php echo $this->option_name; ?>[content_placement]" >
738
+ <option value="before" <?php selected( $this->options['content_placement'], 'before' ); ?>><?php _e( "Above Content", $this->hook ); ?></option>
739
+ <option value="after" <?php selected( $this->options['content_placement'], 'after' ); ?>><?php _e( "Below Content", $this->hook ); ?></option>
740
+ </select>
741
+ </label>
742
+ </div>
743
+ <div id="margin">
744
+ <label>
745
+ <input type="number" name="<?php echo $this->option_name; ?>[margin_left]" value="<?php $this->val( 'margin_left' ); ?>" maxlength="3"/>
746
+ <?php _e( "Margin Left", $this->hook ); ?>
747
+ </label>
748
+ <label>
749
+ <input type="number" name="<?php echo $this->option_name; ?>[margin_right]" value="<?php $this->val( 'margin_right' ); ?>"/> <?php _e( "Margin Right", $this->hook ); ?>
750
+ </label>
751
+ <label>
752
+ <input type="number" name="<?php echo $this->option_name; ?>[margin_top]" value="<?php $this->val( 'margin_top' ); ?>" maxlength="3"/> <?php _e( "Margin Top", $this->hook ); ?>
753
+ </label>
754
+ <label>
755
+ <input type="number" name="<?php echo $this->option_name; ?>[margin_bottom]" value="<?php $this->val( 'margin_bottom' ); ?>" maxlength="3"/> <?php _e( "Margin Bottom", $this->hook ); ?>
756
+ </label>
757
+ </div>
758
+ </div>
759
+ <div id="pages">
760
+ <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="all" <?php $this->checked( 'show_list', 'all'); ?>/> <?php _e( "Homepage, Posts, and Pages", $this->hook ); ?></label>
761
+ <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="single" <?php $this->checked( 'show_list', 'single'); ?>/> <?php _e( "Posts and Pages", $this->hook ); ?></label>
762
+ <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="posts" <?php $this->checked( 'show_list', 'posts'); ?>/> <?php _e( "Posts", $this->hook ); ?></label>
763
+ <label><input type="radio" class="show_list" name="<?php echo $this->option_name; ?>[show_list]" value="manual" <?php $this->checked( 'show_list', 'manual'); ?> /> <?php _e( "Use shortcode in your template", $this->hook ); ?>
764
+ </label>
765
+ <textarea id="pf-shortcode" class="code" rows="2" cols="40">&lt;?php if(function_exists('pf_show_link')){echo pf_show_link();} ?&gt;</textarea>
766
+ </div>
767
+ </div>
768
+
769
+ <!--Section 3 Button Print Options-->
770
+ <div id="print-options">
771
+ <h3><?php _e( "Print PDF Options", $this->hook ); ?></h3>
772
+ <label id="pf-favicon" for="favicon">
773
+ <?php _e( "Page header", $this->hook ); ?>
774
+ <select id="pf-logo" name="<?php echo $this->option_name; ?>[logo]" >
775
+ <option value="favicon" <?php selected( $this->options['logo'], 'favicon' ); ?>><?php _e( "My Website Icon", $this->hook ); ?></option>
776
+ <option value="upload-an-image" <?php selected( $this->options['logo'], 'upload-an-image' ); ?>><?php _e( "Upload an Image", $this->hook ); ?></option>
777
+ </select>
778
+ </label>
779
+ <div class="custom-logo"><label for="Enter_URL">Enter url</label><input id="upload-an-image" type="text" class="regular-text" name="<?php echo $this->option_name; ?>[image_url]" value="<?php $this->val( 'image_url' ); ?>" /><label for="Text__optional_">Text (optional)</label><input id="image-tagline" type="text" class="regular-text" name="<?php echo $this->option_name; ?>[tagline]" value="<?php $this->val( 'tagline' ); ?>" /></div>
780
+ <div id="pf-image-error"></div>
781
+ <div id="pf-image-preview"></div>
782
+ <label for="click_to_delete">
783
+ <?php _e( "Click-to-delete", $this->hook ); ?>
784
+ <select name="<?php echo $this->option_name; ?>[click_to_delete]" id="click-to-delete">
785
+ <option value="0" <?php selected( $this->options['click_to_delete'], '0' ); ?>><?php _e( "Allow", $this->hook ); ?></option>
786
+ <option value="1" <?php selected( $this->options['click_to_delete'], '1' ); ?>><?php _e( "Not Allow", $this->hook ); ?></option>
787
+ </select>
788
+ </label>
789
+ </div>
790
+
791
+ <!--Section 4 WebMaster-->
792
+ <h3><?php _e( "Webmaster Settings", $this->hook ); ?></h3>
793
+
794
+ <label for="protocol">Website Protocol<br>
795
+ <select id="website_protocol" name="<?php echo $this->option_name; ?>[website_protocol]" >
796
+ <option value="http" <?php selected( $this->options['website_protocol'], 'http' ); ?>><?php _e( "http (common)", $this->hook ); ?></option>
797
+ <option value="https" <?php selected( $this->options['website_protocol'], 'https' ); ?>><?php _e( "https (secure)", $this->hook ); ?></option>
798
+ </select>
799
+ <span id="https-beta-registration" class="description">HTTPS is in Beta. Please <a href="#" onclick="window.open('http://www.printfriendly.com/https-registration.html', 'newwindow', 'width=600, height=550'; return false;">Register for updates</a>.
800
+ </span>
801
+ </label>
802
+ <label for="password-site">Password Protected Content
803
+ <select id="password_protected" name="<?php echo $this->option_name; ?>[password_protected]">
804
+ <option value="no" <?php selected( $this->options['password_protected'], 'no' ); ?>><?php _e( "No", $this->hook ); ?></option>
805
+ <option value="yes" <?php selected( $this->options['password_protected'], 'yes' ); ?>><?php _e( "Yes", $this->hook ); ?></option>
806
+ </select>
807
+ </label>
808
+ <label id="pf-javascript-container">Use JavaScript<br>
809
+ <select id="javascript" name="<?php echo $this->option_name; ?>[javascript]>">
810
+ <option value="yes" <?php $this->selected( 'javascript', 'yes' ); ?>> <?php _e( "Yes", $this->hook ); ?></option>
811
+ <option value="no" <?php $this->selected( 'javascript', 'no' ); ?>> <?php _e( "No", $this->hook ); ?></option>
812
+ </select>
813
+ <span class="description javascript">
814
+ <?php _e( "Display print preview on-page using a JavaScript Lightbox (user never leaves the site/page).", $this->hook ); ?>
815
+ </span>
816
+ <span class="description no-javascript">
817
+ <?php _e( "Display print preview on PrintFriendly.com (No JavaScript)", $this->hook ); ?>
818
+ </span>
819
+ </label>
820
+
821
+ <p class="submit">
822
+ <input type="submit" class="button-primary" value="<?php esc_attr_e( "Save Options", $this->hook ); ?>"/>
823
+ <input type="reset" class="button-secondary" value="<?php esc_attr_e( "Cancel", $this->hook ); ?>"/>
824
+ </p>
825
+ <div id="after-submit">
826
+ <p>Need professional options for your corporate, education, or agency developed website? Check out <a href="http://www.printfriendly.com/pro">PrintFriendly Pro</a>.</p>
827
+ <p>
828
+ <?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>
829
+ </div>
830
+
831
+ </form>
832
+ </div>
833
+ <?php
834
+ }
835
+ }
836
+ $printfriendly = new PrintFriendly_WordPress();
837
  }
838
 
839
  /**
843
  * @return string returns a button to be printed.
844
  */
845
  function pf_show_link() {
846
+ global $printfriendly;
847
+ return $printfriendly->show_link();
848
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: printfriendly,joostdevalk
3
  Tags: print, pdf, printer, printing, printable, widget, plugin
4
  Requires at least: 2.8
5
  Tested up to: 3.2.1
6
- Stable tag: 3.0.8
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
 
@@ -64,6 +64,10 @@ If you have any other issues with the plugin or the PrintFriendly widget, please
64
 
65
  == Changelog ==
66
 
 
 
 
 
67
  = 3.0.8 =
68
 
69
  * Reordered PrintFriendly & PDF buttons. CSS stylesheet option is now checked by default.
3
  Tags: print, pdf, printer, printing, printable, widget, plugin
4
  Requires at least: 2.8
5
  Tested up to: 3.2.1
6
+ Stable tag: 3.0.9
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
 
64
 
65
  == Changelog ==
66
 
67
+ = 3.0.9 =
68
+
69
+ * New features: Custom header, disable click-to-delete, https support (beta), PrintFriendly Pro (ad-free).
70
+
71
  = 3.0.8 =
72
 
73
  * Reordered PrintFriendly & PDF buttons. CSS stylesheet option is now checked by default.