PluginProbe
Print, PDF & Email by PrintFriendly / 3.0.9
Print, PDF & Email by PrintFriendly v3.0.9
5.5.13 5.5.12 5.5.11 trunk 0.2 0.9 1.0 2.0 2.1.8 3.0 3.0.9 3.1.6 3.10.0 3.11.0 3.11.1 3.11.2 3.12.0 3.12.1 3.12.2 3.12.3 3.12.4 3.12.5 3.13.0 3.14.0 3.14.1 All 95 releases
printfriendly / pf.php

pf.php in Print, PDF & Email by PrintFriendly 3.0.9, at pf.php

849 lines 35.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.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.
16 3.0.5 - Include button on category pages if user has selected "All pages".
17 3.0.4 - Align-right and align-center support for themes that remove WordPress core css.
18 3.0.3 - Support for bad themes that alter template tags and prevent JavaScript from loading in footer.
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.
26 2.1.4 - wp head fix.
27 2.1.3 - Manual option for button placement. Security updates for multi-author sites.
28 2.1.2 - Improvements to Setting page layout and PrintFriendly button launching from post pages.
29 2.1.1 - Fixed admin settings bug.
30 2.1 - Update for mult-author websites. Improvements to Settings page.
31 2.0 - Customize the style, placement, and pages your printfriendly button appears.
32 1.5 - Added developer ability to disable hook and use the pf_show_link() function to better be used in a custom theme & Uninstall cleanup.
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 /**
840 * Convenience function for use in templates.
841 *
842 * @since 3.0
843 * @return string returns a button to be printed.
844 */
845 function pf_show_link() {
846 global $printfriendly;
847 return $printfriendly->show_link();
848 }
849