WP-Print - Version 2.54

Version Description

  • NEW: Finally there is custom post type support. Props nimmolo.
  • NEW: Allow Multisite Network Activate
  • NEW: Uses WordPress uninstall.php file to uninstall the plugin
Download this release

Release Info

Developer GamerZ
Plugin Icon WP-Print
Version 2.54
Comparing to
See all releases

Code changes from version 2.53 to 2.54

print-css-rtl.css CHANGED
@@ -1,16 +1,3 @@
1
- /*
2
- * WordPress Plugin: WP-Print
3
- * Copyright (c) 2012 Lester "GaMerZ" Chan
4
- *
5
- * File Written By:
6
- * - Lester "GaMerZ" Chan
7
- * - http://lesterchan.net
8
- *
9
- * File Information:
10
- * - CSS Style For Printer Friendly Page (RTL)
11
- * - wp-content/plugins/wp-print/print-css-rtl.css
12
- */
13
-
14
  Body {
15
  font-family: Tahoma, Arial, Sans-Serif;
16
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  Body {
2
  font-family: Tahoma, Arial, Sans-Serif;
3
  }
print-css.css CHANGED
@@ -1,22 +1,14 @@
1
- /*
2
- * WordPress Plugin: WP-Print
3
- * Copyright (c) 2012 Lester "GaMerZ" Chan
4
- *
5
- * File Written By:
6
- * - Lester "GaMerZ" Chan
7
- * - http://lesterchan.net
8
- *
9
- * File Information:
10
- * - CSS Style For Printer Friendly Page
11
- * - wp-content/plugins/wp-print/print-css.css
12
- */
13
-
14
-
15
- Body {
16
  font-family: Verdana, Arial, Tahoma;
17
  font-size: 12px;
18
  color: #000000;
19
  }
 
 
 
 
 
 
20
  .Center {
21
  margin: 0px auto 0px auto;
22
  }
1
+ BODY {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  font-family: Verdana, Arial, Tahoma;
3
  font-size: 12px;
4
  color: #000000;
5
  }
6
+ IMG {
7
+ max-width: 100%;
8
+ }
9
+ P {
10
+ word-wrap: break-word;
11
+ }
12
  .Center {
13
  margin: 0px auto 0px auto;
14
  }
print-options.php CHANGED
@@ -1,18 +1,4 @@
1
  <?php
2
- /*
3
- * WordPress Plugin: WP-Print
4
- * Copyright (c) 2013 Lester "GaMerZ" Chan
5
- *
6
- * File Written By:
7
- * - Lester "GaMerZ" Chan
8
- * - http://lesterchan.net
9
- *
10
- * File Information:
11
- * - Print Options Page
12
- * - wp-content/plugins/wp-print/print-options.php
13
- */
14
-
15
-
16
  ### Variables Variables Variables
17
  $base_name = plugin_basename('wp-print/print-options.php');
18
  $base_page = 'admin.php?page='.$base_name;
@@ -51,49 +37,8 @@ if(!empty($_POST['Submit'])) {
51
  $text = '<font color="red">'.__('No Print Option Updated', 'wp-print').'</font>';
52
  }
53
  }
54
- // Uninstall WP-Print
55
- if(!empty($_POST['do'])) {
56
- switch($_POST['do']) {
57
- case __('UNINSTALL WP-Print', 'wp-print') :
58
- if(trim($_POST['uninstall_print_yes']) == 'yes') {
59
- echo '<div id="message" class="updated fade">';
60
- echo '<p>';
61
- foreach($print_settings as $setting) {
62
- $delete_setting = delete_option($setting);
63
- if($delete_setting) {
64
- echo '<font color="green">';
65
- printf(__('Setting Key \'%s\' has been deleted.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
66
- echo '</font><br />';
67
- } else {
68
- echo '<font color="red">';
69
- printf(__('Error deleting Setting Key \'%s\'.', 'wp-print'), "<strong><em>{$setting}</em></strong>");
70
- echo '</font><br />';
71
- }
72
- }
73
- echo '</p>';
74
- echo '</div>';
75
- $mode = 'end-UNINSTALL';
76
- }
77
- break;
78
- }
79
- }
80
 
81
- ### Determines Which Mode It Is
82
- switch($mode) {
83
- // Deactivating WP-Print
84
- case 'end-UNINSTALL':
85
- $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-print/wp-print.php';
86
- if(function_exists('wp_nonce_url')) {
87
- $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-print/wp-print.php');
88
- }
89
- echo '<div class="wrap">';
90
- echo '<h2>'.__('Uninstall WP-Print', 'wp-print').'</h2>';
91
- echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-Print Will Be Deactivated Automatically.', 'wp-print'), $deactivate_url).'</strong></p>';
92
- echo '</div>';
93
- break;
94
- // Main Page
95
- default:
96
- $print_options = get_option('print_options');
97
  ?>
98
  <script type="text/javascript">
99
  /* <![CDATA[*/
@@ -242,47 +187,4 @@ switch($mode) {
242
  <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
243
  </p>
244
  </div>
245
- </form>
246
- <p>&nbsp;</p>
247
-
248
- <!-- Uninstall WP-Print -->
249
- <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
250
- <div class="wrap">
251
- <h3><?php _e('Uninstall WP-Print', 'wp-print'); ?></h3>
252
- <p>
253
- <?php _e('Deactivating WP-Print plugin does not remove any data that may have been created, such as the print options. To completely remove this plugin, you can uninstall it here.', 'wp-print'); ?>
254
- </p>
255
- <p style="color: red">
256
- <strong><?php _e('WARNING:', 'wp-print'); ?></strong><br />
257
- <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', 'wp-print'); ?>
258
- </p>
259
- <p style="color: red">
260
- <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-print'); ?></strong><br />
261
- </p>
262
- <table class="widefat">
263
- <thead>
264
- <tr>
265
- <th><?php _e('WordPress Options', 'wp-print'); ?></th>
266
- </tr>
267
- </thead>
268
- <tr>
269
- <td valign="top">
270
- <ol>
271
- <?php
272
- foreach($print_settings as $settings) {
273
- echo '<li>'.$settings.'</li>'."\n";
274
- }
275
- ?>
276
- </ol>
277
- </td>
278
- </tr>
279
- </table>
280
- <p>&nbsp;</p>
281
- <p style="text-align: center;">
282
- <input type="checkbox" name="uninstall_print_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-print'); ?><br /><br />
283
- <input type="submit" name="do" value="<?php _e('UNINSTALL WP-Print', 'wp-print'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-Print From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-print'); ?>')" />
284
- </p>
285
- </div>
286
- </form>
287
- <?php
288
- } // End switch($mode)
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  ### Variables Variables Variables
3
  $base_name = plugin_basename('wp-print/print-options.php');
4
  $base_page = 'admin.php?page='.$base_name;
37
  $text = '<font color="red">'.__('No Print Option Updated', 'wp-print').'</font>';
38
  }
39
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ $print_options = get_option('print_options');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ?>
43
  <script type="text/javascript">
44
  /* <![CDATA[*/
187
  <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-print'); ?>" />
188
  </p>
189
  </div>
190
+ </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,26 +3,25 @@ Contributors: GamerZ
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: print, printer, wp-print
5
  Requires at least: 2.8
6
- Tested up to: 3.9
7
- Stable tag: 2.53
8
 
9
  Displays a printable version of your WordPress blog's post/page.
10
 
11
  == Description ==
12
 
13
- Displays a printable version of your WordPress blog's post/page.
 
14
 
15
  = Development =
16
- * [https://github.com/lesterchan/wp-print](https://github.com/lesterchan/wp-print "https://github.com/lesterchan/wp-print")
17
 
18
  = Translations =
19
- * [http://dev.wp-plugins.org/browser/wp-print/i18n/](http://dev.wp-plugins.org/browser/wp-print/i18n/ "http://dev.wp-plugins.org/browser/wp-print/i18n/")
20
 
21
  = Credits =
 
22
  * Icons courtesy of [FamFamFam](http://www.famfamfam.com/)
23
- * __ngetext() by [Anna Ozeritskaya](http://hweia.ru/)
24
- * Right-to-left language support by [Kambiz R. Khojasteh](http://persian-programming.com/)
25
- * Do Not Print idea by [Robert "Nilpo" Dunham](http://www.nilpo.com/)
26
 
27
  = Donations =
28
  I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks as my school allowance, I will really appreciate it. If not feel free to use it without any obligations. Thank You. My Paypal account is lesterchan@gmail.com.
@@ -58,8 +57,7 @@ Once installed take the following steps to set it up:
58
 
59
  1. Admin Print Options
60
  2. Print Post Link
61
- 3. Print Page link
62
- 4. Print Page
63
 
64
  == Frequently Asked Questions ==
65
 
@@ -93,6 +91,11 @@ if(function_exists('wp_print')) {
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
96
  = 2.53 =
97
  * FIXED: Use get_stylesheet_directory() instead of TEMPLATEPATH
98
 
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: print, printer, wp-print
5
  Requires at least: 2.8
6
+ Tested up to: 4.0
7
+ Stable tag: 2.54
8
 
9
  Displays a printable version of your WordPress blog's post/page.
10
 
11
  == Description ==
12
 
13
+ = Build Status =
14
+ [![Build Status](https://travis-ci.org/lesterchan/wp-print.svg?branch=master)](https://travis-ci.org/lesterchan/wp-print)
15
 
16
  = Development =
17
+ [https://github.com/lesterchan/wp-print](https://github.com/lesterchan/wp-print "https://github.com/lesterchan/wp-print")
18
 
19
  = Translations =
20
+ [http://dev.wp-plugins.org/browser/wp-print/i18n/](http://dev.wp-plugins.org/browser/wp-print/i18n/ "http://dev.wp-plugins.org/browser/wp-print/i18n/")
21
 
22
  = Credits =
23
+ * Plugin icon by [SimpleIcon](http://www.simpleicon.com) from [Flaticon](http://www.flaticon.com)
24
  * Icons courtesy of [FamFamFam](http://www.famfamfam.com/)
 
 
 
25
 
26
  = Donations =
27
  I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks as my school allowance, I will really appreciate it. If not feel free to use it without any obligations. Thank You. My Paypal account is lesterchan@gmail.com.
57
 
58
  1. Admin Print Options
59
  2. Print Post Link
60
+ 3. Print Page
 
61
 
62
  == Frequently Asked Questions ==
63
 
91
 
92
  == Changelog ==
93
 
94
+ = 2.54 =
95
+ * NEW: Finally there is custom post type support. Props [nimmolo](http://andrewnimmo.org/ "nimmolo").
96
+ * NEW: Allow Multisite Network Activate
97
+ * NEW: Uses WordPress uninstall.php file to uninstall the plugin
98
+
99
  = 2.53 =
100
  * FIXED: Use get_stylesheet_directory() instead of TEMPLATEPATH
101
 
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
uninstall.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Uninstall plugin
4
+ */
5
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
6
+ exit ();
7
+
8
+ $option_name = 'print_options';
9
+
10
+ if ( is_multisite() ) {
11
+ $ms_sites = wp_get_sites();
12
+
13
+ if( 0 < sizeof( $ms_sites ) ) {
14
+ foreach ( $ms_sites as $ms_site ) {
15
+ switch_to_blog( $ms_site['blog_id'] );
16
+ delete_option( $option_name );
17
+ }
18
+ }
19
+
20
+ restore_current_blog();
21
+ } else {
22
+ delete_option( $option_name );
23
+ }
wp-print.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Print
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Displays a printable version of your WordPress blog's post/page.
6
- Version: 2.53
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-print
@@ -11,7 +11,7 @@ Text Domain: wp-print
11
 
12
 
13
  /*
14
- Copyright 2013 Lester Chan (email : lesterchan@gmail.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
@@ -30,61 +30,23 @@ Text Domain: wp-print
30
 
31
 
32
  ### Create Text Domain For Translations
33
- add_action('init', 'print_textdomain');
34
  function print_textdomain() {
35
- load_plugin_textdomain('wp-print', false, 'wp-print');
36
  }
37
 
38
 
39
  ### Function: Print Option Menu
40
  add_action('admin_menu', 'print_menu');
41
  function print_menu() {
42
- if (function_exists('add_options_page')) {
43
- add_options_page(__('Print', 'wp-print'), __('Print', 'wp-print'), 'manage_options', 'wp-print/print-options.php') ;
44
- }
45
  }
46
 
47
 
48
- ### Function: Print htaccess ReWrite Rules
49
- add_filter('generate_rewrite_rules', 'print_rewrite');
50
- function print_rewrite($wp_rewrite) {
51
- // Print Rules For Posts
52
- $r_rule = '';
53
- $r_link = '';
54
- $print_link = get_permalink();
55
- if(substr($print_link, -1, 1) != '/' && substr($wp_rewrite->permalink_structure, -1, 1) != '/') {
56
- $print_link_text = '/print';
57
- } else {
58
- $print_link_text = 'print';
59
- }
60
- $rewrite_rules = $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.$print_link_text, EP_PERMALINK);
61
- $rewrite_rules = array_slice($rewrite_rules, 5, 1);
62
- $r_rule = array_keys($rewrite_rules);
63
- $r_rule = array_shift($r_rule);
64
- $r_rule = str_replace('/trackback', '',$r_rule);
65
- $r_link = array_values($rewrite_rules);
66
- $r_link = array_shift($r_link);
67
- $r_link = str_replace('tb=1', 'print=1', $r_link);
68
- $wp_rewrite->rules = array_merge(array($r_rule => $r_link), $wp_rewrite->rules);
69
- // Print Rules For Pages
70
- $page_uris = $wp_rewrite->page_uri_index();
71
- $uris = $page_uris[0];
72
- if(is_array($uris)) {
73
- $print_page_rules = array();
74
- foreach ($uris as $uri => $pagename) {
75
- $wp_rewrite->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
76
- $rewrite_rules = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_page_permastruct().'/printpage', EP_PAGES);
77
- $rewrite_rules = array_slice($rewrite_rules, 5, 1);
78
- $r_rule = array_keys($rewrite_rules);
79
- $r_rule = array_shift($r_rule);
80
- $r_rule = str_replace('/trackback', '',$r_rule);
81
- $r_link = array_values($rewrite_rules);
82
- $r_link = array_shift($r_link);
83
- $r_link = str_replace('tb=1', 'print=1', $r_link);
84
- $print_page_rules = array_merge($print_page_rules, array($r_rule => $r_link));
85
- }
86
- $wp_rewrite->rules = array_merge($print_page_rules, $wp_rewrite->rules);
87
- }
88
  }
89
 
90
 
@@ -92,7 +54,6 @@ function print_rewrite($wp_rewrite) {
92
  add_filter('query_vars', 'print_variables');
93
  function print_variables($public_query_vars) {
94
  $public_query_vars[] = 'print';
95
- $public_query_vars[] = 'printpage';
96
  return $public_query_vars;
97
  }
98
 
@@ -132,10 +93,8 @@ function print_link($print_post_text = '', $print_page_text = '', $echo = true)
132
  } else {
133
  $print_text = $print_page_text;
134
  }
135
- $print_link = $print_link.'printpage/'.$polyglot_append;
136
- } else {
137
- $print_link = $print_link.'print/'.$polyglot_append;
138
  }
 
139
  } else {
140
  if(is_page()) {
141
  if(empty($print_page_text)) {
@@ -378,7 +337,8 @@ function print_links($text_links = '') {
378
  ### Function: Load WP-Print
379
  add_action('template_redirect', 'wp_print', 5);
380
  function wp_print() {
381
- if(intval(get_query_var('print')) == 1 || intval(get_query_var('printpage')) == 1) {
 
382
  include(WP_PLUGIN_DIR.'/wp-print/print.php');
383
  exit();
384
  }
@@ -435,21 +395,48 @@ function str_replace_one($search, $replace, $content){
435
  }
436
 
437
 
438
- ### Function: Print Options
439
- add_action('activate_wp-print/wp-print.php', 'print_init');
440
- function print_init() {
441
- print_textdomain();
442
  // Add Options
443
- $print_options = array();
444
- $print_options['post_text'] = __('Print This Post', 'wp-print');
445
- $print_options['page_text'] = __('Print This Page', 'wp-print');
446
- $print_options['print_icon'] = 'print.gif';
447
- $print_options['print_style'] = 1;
448
- $print_options['print_html'] = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
449
- $print_options['comments'] = 0;
450
- $print_options['links'] = 1;
451
- $print_options['images'] = 1;
452
- $print_options['videos'] = 0;
453
- $print_options['disclaimer'] = sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'));
454
- add_option('print_options', $print_options, 'Print Options');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
  }
 
 
 
 
3
  Plugin Name: WP-Print
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Displays a printable version of your WordPress blog's post/page.
6
+ Version: 2.54
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-print
11
 
12
 
13
  /*
14
+ Copyright 2014 Lester Chan (email : lesterchan@gmail.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
30
 
31
 
32
  ### Create Text Domain For Translations
33
+ add_action( 'plugins_loaded', 'print_textdomain' );
34
  function print_textdomain() {
35
+ load_plugin_textdomain( 'wp-print', false, dirname( plugin_basename( __FILE__ ) ) );
36
  }
37
 
38
 
39
  ### Function: Print Option Menu
40
  add_action('admin_menu', 'print_menu');
41
  function print_menu() {
42
+ add_options_page(__('Print', 'wp-print'), __('Print', 'wp-print'), 'manage_options', 'wp-print/print-options.php') ;
 
 
43
  }
44
 
45
 
46
+ ### Function: Add htaccess Rewrite Endpoint - this handles all the rules
47
+ add_action( 'init', 'wp_print_endpoint' );
48
+ function wp_print_endpoint() {
49
+ add_rewrite_endpoint( 'print', EP_PERMALINK | EP_PAGES );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
 
54
  add_filter('query_vars', 'print_variables');
55
  function print_variables($public_query_vars) {
56
  $public_query_vars[] = 'print';
 
57
  return $public_query_vars;
58
  }
59
 
93
  } else {
94
  $print_text = $print_page_text;
95
  }
 
 
 
96
  }
97
+ $print_link = $print_link.'print/'.$polyglot_append;
98
  } else {
99
  if(is_page()) {
100
  if(empty($print_page_text)) {
337
  ### Function: Load WP-Print
338
  add_action('template_redirect', 'wp_print', 5);
339
  function wp_print() {
340
+ global $wp_query;
341
+ if( array_key_exists( 'print' , $wp_query->query_vars ) ) {
342
  include(WP_PLUGIN_DIR.'/wp-print/print.php');
343
  exit();
344
  }
395
  }
396
 
397
 
398
+ ### Function: Activate Plugin
399
+ register_activation_hook( __FILE__, 'print_activation' );
400
+ function print_activation( $network_wide )
401
+ {
402
  // Add Options
403
+ $option_name = 'print_options';
404
+ $option = array(
405
+ 'post_text' => __('Print This Post', 'wp-print')
406
+ , 'page_text' => __('Print This Page', 'wp-print')
407
+ , 'print_icon' => 'print.gif'
408
+ , 'print_style' => 1
409
+ , 'print_html' => '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>'
410
+ , 'comments' => 0
411
+ , 'links' => 1
412
+ , 'images' => 1
413
+ , 'videos' => 0
414
+ , 'disclaimer' => sprintf(__('Copyright &copy; %s %s. All rights reserved.', 'wp-print'), date('Y'), get_option('blogname'))
415
+ );
416
+
417
+ if ( is_multisite() && $network_wide )
418
+ {
419
+ $ms_sites = wp_get_sites();
420
+
421
+ if( 0 < sizeof( $ms_sites ) )
422
+ {
423
+ foreach ( $ms_sites as $ms_site )
424
+ {
425
+ switch_to_blog( $ms_site['blog_id'] );
426
+ add_option( $option_name, $option );
427
+ print_activate();
428
+ }
429
+ }
430
+
431
+ restore_current_blog();
432
+ }
433
+ else
434
+ {
435
+ add_option( $option_name, $option );
436
+ print_activate();
437
+ }
438
  }
439
+
440
+ function print_activate() {
441
+ flush_rewrite_rules();
442
+ }