Print, PDF, Email by PrintFriendly - Version 5.2.1

Version Description

  • Fix: Allow HTML in button custom text
Download this release

Release Info

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

Code changes from version 5.2.0 to 5.2.1

Files changed (3) hide show
  1. assets/js/admin.js +1 -1
  2. pf.php +45 -16
  3. readme.txt +4 -1
assets/js/admin.js CHANGED
@@ -236,7 +236,7 @@
236
  function custom_text_change(){
237
  $('#buttongroup3 span:not(.printandpdf)').text( $('#custom_text').val() );
238
  var newText = $('#custom-text-no').prop('checked') ? '' : $('#custom_text').val();
239
- $('#printfriendly-text2').text( newText );
240
  $('#printfriendly-text2').css('color','#' + $('#text_color').val());
241
  }
242
 
236
  function custom_text_change(){
237
  $('#buttongroup3 span:not(.printandpdf)').text( $('#custom_text').val() );
238
  var newText = $('#custom-text-no').prop('checked') ? '' : $('#custom_text').val();
239
+ $('#printfriendly-text2').html( newText );
240
  $('#printfriendly-text2').css('color','#' + $('#text_color').val());
241
  }
242
 
pf.php CHANGED
@@ -5,7 +5,7 @@
5
  Plugin URI: http://www.printfriendly.com
6
  Description: PrintFriendly & PDF button for your website. Optimizes your pages and brand for print, pdf, and email.
7
  Name and URL are included to ensure repeat visitors and new visitors when printed versions are shared.
8
- Version: 5.2.0
9
  Author: Print, PDF, & Email by PrintFriendly
10
  Author URI: http://www.printfriendly.com
11
  Domain Path: /languages
@@ -41,7 +41,7 @@ if (! class_exists('PrintFriendly_WordPress')) {
41
  *
42
  * @var string
43
  */
44
- var $plugin_version = '5.2.0';
45
  /**
46
  * The hook, used for text domain as well as hooks on pages and in get requests for admin.
47
  *
@@ -131,6 +131,18 @@ if (! class_exists('PrintFriendly_WordPress')) {
131
  $this->upgrade();
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  add_action('wp_head', array(&$this, 'front_head'));
135
 
136
  // automaticaly add the link
@@ -138,9 +150,14 @@ if (! class_exists('PrintFriendly_WordPress')) {
138
  add_filter('the_excerpt', array(&$this, 'show_link_on_excerpt'));
139
 
140
  add_action('the_content', array(&$this, 'add_pf_content_class_around_content_hook'));
141
- if (is_admin()) {
142
- $this->admin_hooks();
143
- }
 
 
 
 
 
144
  }
145
 
146
  /**
@@ -298,10 +315,6 @@ if (! class_exists('PrintFriendly_WordPress')) {
298
  }
299
  }
300
 
301
- .pf-button.pf-button-excerpt {
302
- display: none;
303
- }
304
-
305
  .pf-button-img {
306
  border: none;
307
  -webkit-box-shadow: none;
@@ -317,6 +330,12 @@ if (! class_exists('PrintFriendly_WordPress')) {
317
  margin-left: 6px;
318
  }
319
  </style>
 
 
 
 
 
 
320
  <?php
321
  }
322
  }
@@ -353,6 +372,14 @@ if (! class_exists('PrintFriendly_WordPress')) {
353
  var pfDisablePrint = '<?php echo esc_js($this->options['print']); ?>';
354
  var pfCustomCSS = '<?php echo esc_js(esc_url($this->get_custom_css())); ?>';
355
  var pfPlatform = 'WordPress';
 
 
 
 
 
 
 
 
356
  </script>
357
  <script async src='https://cdn.printfriendly.com/printfriendly.js'></script>
358
  <?php
@@ -1278,9 +1305,9 @@ if (! class_exists('PrintFriendly_WordPress')) {
1278
  $return = '<img src="' . esc_url($this->options['custom_button_icon']) . '" alt="Print Friendly, PDF & Email" class="pf-button-img" style="' . $imgStyle . '" />';
1279
  }
1280
 
1281
- /* esc_html was removerd to support custom html, CSRF prevents from attack by using this field */
1282
  if ($this->options['custom_button_text'] === 'custom-text') {
1283
- $return .= sprintf('<span id="printfriendly-text2" class="pf-button-text">%s</span>', esc_html($this->options['custom_text']));
1284
  }
1285
 
1286
  return $return;
@@ -1342,7 +1369,8 @@ if (! class_exists('PrintFriendly_WordPress')) {
1342
  $style .= 'color: ' . $this->options['text_color'] . ';';
1343
  }
1344
 
1345
- $button_preview = sprintf('<span><span id="pf-custom-button-preview" class="pf-button-img">%s</span><span id="printfriendly-text2" class="pf-button-text" style="%s">%s</span></span>', $img, $style, esc_html($button_text));
 
1346
 
1347
  echo $button_preview;
1348
  }
@@ -1382,18 +1410,19 @@ if (! class_exists('PrintFriendly_WordPress')) {
1382
  */
1383
  function checked($val, $check_against = true, $echo = true)
1384
  {
 
1385
  if (! isset($this->options[ $val ])) {
1386
- return;
1387
  }
1388
 
1389
  // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1390
  if ($this->options[ $val ] == $check_against) {
 
1391
  if ($echo) {
1392
- echo ' checked="checked" ';
1393
- } else {
1394
- return ' checked="checked" ';
1395
  }
1396
  }
 
1397
  }
1398
 
1399
  /**
5
  Plugin URI: http://www.printfriendly.com
6
  Description: PrintFriendly & PDF button for your website. Optimizes your pages and brand for print, pdf, and email.
7
  Name and URL are included to ensure repeat visitors and new visitors when printed versions are shared.
8
+ Version: 5.2.1
9
  Author: Print, PDF, & Email by PrintFriendly
10
  Author URI: http://www.printfriendly.com
11
  Domain Path: /languages
41
  *
42
  * @var string
43
  */
44
+ var $plugin_version = '5.2.1';
45
  /**
46
  * The hook, used for text domain as well as hooks on pages and in get requests for admin.
47
  *
131
  $this->upgrade();
132
  }
133
 
134
+ $this->public_hooks();
135
+ if (is_admin()) {
136
+ $this->admin_hooks();
137
+ }
138
+ }
139
+
140
+ /**
141
+ * All public hooks.
142
+ */
143
+ function public_hooks()
144
+ {
145
+ add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ));
146
  add_action('wp_head', array(&$this, 'front_head'));
147
 
148
  // automaticaly add the link
150
  add_filter('the_excerpt', array(&$this, 'show_link_on_excerpt'));
151
 
152
  add_action('the_content', array(&$this, 'add_pf_content_class_around_content_hook'));
153
+ }
154
+
155
+ /**
156
+ * Load front end dependencies.
157
+ */
158
+ function wp_enqueue_scripts()
159
+ {
160
+ wp_enqueue_script('jquery');
161
  }
162
 
163
  /**
315
  }
316
  }
317
 
 
 
 
 
318
  .pf-button-img {
319
  border: none;
320
  -webkit-box-shadow: none;
330
  margin-left: 6px;
331
  }
332
  </style>
333
+
334
+ <style type="text/css" id="pf-excerpt-styles">
335
+ .pf-button.pf-button-excerpt {
336
+ display: none;
337
+ }
338
+ </style>
339
  <?php
340
  }
341
  }
372
  var pfDisablePrint = '<?php echo esc_js($this->options['print']); ?>';
373
  var pfCustomCSS = '<?php echo esc_js(esc_url($this->get_custom_css())); ?>';
374
  var pfPlatform = 'WordPress';
375
+
376
+ (function($){
377
+ $(document).ready(function(){
378
+ if($('.pf-button-content').length === 0){
379
+ $('style#pf-excerpt-styles').remove();
380
+ }
381
+ });
382
+ })(jQuery);
383
  </script>
384
  <script async src='https://cdn.printfriendly.com/printfriendly.js'></script>
385
  <?php
1305
  $return = '<img src="' . esc_url($this->options['custom_button_icon']) . '" alt="Print Friendly, PDF & Email" class="pf-button-img" style="' . $imgStyle . '" />';
1306
  }
1307
 
1308
+ // esc_html is deliberately not used here
1309
  if ($this->options['custom_button_text'] === 'custom-text') {
1310
+ $return .= sprintf('<span id="printfriendly-text2" class="pf-button-text">%s</span>', $this->options['custom_text']);
1311
  }
1312
 
1313
  return $return;
1369
  $style .= 'color: ' . $this->options['text_color'] . ';';
1370
  }
1371
 
1372
+ // esc_html is deliberately not used here
1373
+ $button_preview = sprintf('<span><span id="pf-custom-button-preview" class="pf-button-img">%s</span><span id="printfriendly-text2" class="pf-button-text" style="%s">%s</span></span>', $img, $style, $button_text);
1374
 
1375
  echo $button_preview;
1376
  }
1410
  */
1411
  function checked($val, $check_against = true, $echo = true)
1412
  {
1413
+ $result = '';
1414
  if (! isset($this->options[ $val ])) {
1415
+ return $result;
1416
  }
1417
 
1418
  // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1419
  if ($this->options[ $val ] == $check_against) {
1420
+ $result = ' checked="checked" ';
1421
  if ($echo) {
1422
+ echo $result;
 
 
1423
  }
1424
  }
1425
+ return $result;
1426
  }
1427
 
1428
  /**
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: printfriendly, joostdevalk, jrf, rozroz
3
  Tags: print, pdf, email, woocommerce print, woocommerce pdf, print plugin, print button, pdf plugin, pdf button
4
  Requires at least: 4.9
5
  Tested up to: 5.8
6
- Stable tag: 5.2.0
7
 
8
 
9
  The #1 Print, PDF, Email button. Stylish, full featured, customizable. Add custom header, footer, and more.
@@ -144,6 +144,9 @@ You can [hide the Print, PDF, and Email button](https://support.printfriendly.co
144
 
145
  == Changelog ==
146
 
 
 
 
147
  = 5.2.0 =
148
  * Fix PHP Notice
149
 
3
  Tags: print, pdf, email, woocommerce print, woocommerce pdf, print plugin, print button, pdf plugin, pdf button
4
  Requires at least: 4.9
5
  Tested up to: 5.8
6
+ Stable tag: 5.2.1
7
 
8
 
9
  The #1 Print, PDF, Email button. Stylish, full featured, customizable. Add custom header, footer, and more.
144
 
145
  == Changelog ==
146
 
147
+ = 5.2.1 =
148
+ * Fix: Allow HTML in button custom text
149
+
150
  = 5.2.0 =
151
  * Fix PHP Notice
152