PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.8.5
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.8.5
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
pdf-print / pdf-print.php

pdf-print.php in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 1.8.5, at pdf-print.php

1,306 lines 59.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: PDF & Print by BestWebSoft
4 Plugin URI: http://bestwebsoft.com/products/
5 Description: Plugin adds PDF creation and Print button on your site.
6 Author: BestWebSoft
7 Text Domain: pdf-print
8 Domain Path: /languages
9 Version: 1.8.5
10 Author URI: http://bestwebsoft.com/
11 License: GPLv2 or later
12 */
13
14 /* © Copyright 2015 BestWebSoft ( http://support.bestwebsoft.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, version 2, as
18 published by the Free Software Foundation.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30 /* Add our own menu */
31 if ( ! function_exists( 'pdfprnt_add_pages' ) ) {
32 function pdfprnt_add_pages() {
33 bws_add_general_menu( plugin_basename( __FILE__ ) );
34 $settings = add_submenu_page( 'bws_plugins', __( 'PDF & Print Settings', 'pdf-print' ), 'PDF & Print', 'manage_options', 'pdf-print.php', 'pdfprnt_settings_page' );
35 add_action( "load-{$settings}", 'pdfprnt_add_tabs' );
36 }
37 }
38
39 /**
40 * Add help tab on settings page
41 * @return void
42 */
43 if ( ! function_exists( 'pdfprnt_add_tabs' ) ) {
44 function pdfprnt_add_tabs() {
45 $args = array(
46 'id' => 'pdfprnt',
47 'section' => '200538669'
48 );
49 bws_help_tab( get_current_screen(), $args );
50 }
51 }
52
53 if ( ! function_exists( 'pdfprnt_plugins_loaded' ) ) {
54 function pdfprnt_plugins_loaded() {
55 /* Internationalization, first(!) */
56 load_plugin_textdomain( 'pdf-print', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
57 }
58 }
59
60 /* Init plugin */
61 if ( ! function_exists ( 'pdfprnt_init' ) ) {
62 function pdfprnt_init() {
63 global $pdfprnt_plugin_info;
64 $plugin_basename = plugin_basename( __FILE__ );
65
66 require_once( dirname( __FILE__ ) . '/bws_menu/bws_include.php' );
67 bws_include_init( $plugin_basename );
68
69 if ( empty( $pdfprnt_plugin_info ) ) {
70 if ( ! function_exists( 'get_plugin_data' ) ) {
71 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
72 }
73 $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
74 }
75
76 /* check WordPress version */
77 bws_wp_min_version_check( $plugin_basename, $pdfprnt_plugin_info, '3.8', "3.3" );
78
79 /* Get/Register and check settings for plugin */
80 if ( ! is_admin() || ( isset( $_GET['page'] ) && 'pdf-print.php' == $_GET['page'] ) )
81 pdfprnt_settings();
82 }
83 }
84
85 if ( ! function_exists( 'pdfprnt_admin_init' ) ) {
86 function pdfprnt_admin_init() {
87 global $bws_plugin_info, $pdfprnt_plugin_info;
88
89 if ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) )
90 $bws_plugin_info = array( 'id' => '101', 'version' => $pdfprnt_plugin_info["Version"] );
91 }
92 }
93
94 /* Register settings for plugin */
95 if ( ! function_exists( 'pdfprnt_settings' ) ) {
96 function pdfprnt_settings() {
97 global $pdfprnt_options_array, $pdfprnt_plugin_info, $pdfprnt_options_defaults;
98
99 if ( ! $pdfprnt_plugin_info ) {
100 if ( ! function_exists( 'get_plugin_data' ) )
101 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
102 $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
103 }
104
105 /* Variable to verify performance number of once function. */
106 $pdfprnt_default_post_types = array();
107 /* Default post types of WordPress. */
108 foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1, '_builtin' => true ), 'names' ) as $value )
109 $pdfprnt_default_post_types[] = $value;
110
111 $pdfprnt_options_defaults = array(
112 'plugin_option_version' => $pdfprnt_plugin_info["Version"],
113 'position' => 'top-right',
114 'position_search_archive' => 'top-right',
115 'position_custom' => 'right',
116 'show_btn_print' => 1,
117 'show_btn_pdf' => 1,
118 'show_btn_print_search_archive' => 1,
119 'show_btn_pdf_search_archive' => 1,
120 'use_theme_stylesheet' => 0,
121 'use_custom_styles' => 0,
122 'custom_styles' => "",
123 'tmpl_shorcode' => 1,
124 'use_types_posts' => $pdfprnt_default_post_types,
125 'show_print_window' => 0,
126 'additional_fonts' => 0,
127 'show_title' => 1,
128 'show_featured_image' => 0,
129 'first_install' => strtotime( "now" )
130 );
131
132 if ( ! get_option( 'pdfprnt_options_array' ) )
133 add_option( 'pdfprnt_options_array', $pdfprnt_options_defaults );
134
135 $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
136
137 if ( ! isset( $pdfprnt_options_array['plugin_option_version'] ) || $pdfprnt_options_array['plugin_option_version'] != $pdfprnt_plugin_info["Version"] ) {
138 if ( in_array( $pdfprnt_options_array['position_search_archive'], array( 'pdfprnt-right', 'pdfprnt-left' ) ) )
139 $pdfprnt_options_array['position_search_archive'] = 'pdfprnt-left' == $pdfprnt_options_array['position_search_archive'] ? 'top-left' : 'top-right';
140 if ( in_array( $pdfprnt_options_array['position_custom'], array( 'pdfprnt-right', 'pdfprnt-left' ) ) )
141 $pdfprnt_options_array['position_custom'] = 'pdfprnt-left' == $pdfprnt_options_array['position_custom'] ? 'left' : 'right';
142 $pdfprnt_options_array['hide_premium_options'] = 0;
143 $pdfprnt_options_array = array_merge( $pdfprnt_options_defaults, $pdfprnt_options_array );
144 $pdfprnt_options_array['plugin_option_version'] = $pdfprnt_plugin_info["Version"];
145 update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
146 }
147 }
148 }
149
150 /**
151 * Display <input type="radio"> on settings page
152 **/
153 if ( ! function_exists( 'pdfprnt_display_radio' ) ) {
154 function pdfprnt_display_radio( $name, $selected ) {
155 $positions_values = array(
156 'top-left' => __( 'Top Left', 'pdf-print' ),
157 'top-right' => __( 'Top Right', 'pdf-print' ),
158 'bottom-left' => __( 'Bottom Left', 'pdf-print' ),
159 'bottom-right' => __( 'Bottom Right', 'pdf-print' ),
160 'top-bottom-left' => __( 'Top & Bottom Left', 'pdf-print' ),
161 'top-bottom-right' => __( 'Top & Bottom Right', 'pdf-print' )
162 );
163 foreach ( $positions_values as $key => $value ) { ?>
164 <label><input type="radio" name="<?php echo $name; ?>" value="<?php echo $key ?>"<?php echo $key == $selected ? ' checked="checked"' : ''; ?> />&nbsp;<?php echo $value; ?></label><br/>
165 <?php }
166 }
167 }
168 /* Add admin page */
169 if ( ! function_exists ( 'pdfprnt_settings_page' ) ) {
170 function pdfprnt_settings_page () {
171 global $pdfprnt_options_array, $pdfprnt_plugin_info, $pdfprnt_options_defaults;
172 $message = $error = "";
173 $plugin_basename = plugin_basename( __FILE__ );
174 if ( is_multisite() ) {
175 switch_to_blog( 1 );
176 $upload_dir = wp_upload_dir();
177 restore_current_blog();
178 } else {
179 $upload_dir = wp_upload_dir();
180 }
181 $need_fonts_reload = false;
182 $fonts_path = $upload_dir['basedir'] .'/pdf-print-fonts';
183 if ( ! function_exists( 'get_plugins' ) )
184 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
185 require_once( dirname( __FILE__ ) . '/includes/pro_banners.php' );
186 $all_plugins = get_plugins();
187 if ( isset( $_REQUEST['pdfprnt_form_submit'] ) && check_admin_referer( $plugin_basename, 'pdfprnt_nonce_name' ) ) {
188 $pdfprnt_options_array['position'] = isset( $_REQUEST['pdfprnt_position'] ) ? $_REQUEST['pdfprnt_position'] : 'top-right';
189 $pdfprnt_options_array['position_search_archive'] = isset( $_REQUEST['pdfprnt_position_search_archive'] ) ? $_REQUEST['pdfprnt_position_search_archive'] : 'top-right';
190 $pdfprnt_options_array['position_custom'] = isset( $_REQUEST['pdfprnt_position_custom'] ) ? $_REQUEST['pdfprnt_position_custom'] : 'right';
191 $pdfprnt_options_array['use_theme_stylesheet'] = isset( $_REQUEST['pdfprnt_use_theme_stylesheet'] ) ? $_REQUEST['pdfprnt_use_theme_stylesheet'] : 0;
192 $pdfprnt_options_array['show_btn_pdf'] = isset( $_REQUEST['pdfprnt_show_btn_pdf'] ) ? 1 : 0;
193 $pdfprnt_options_array['show_btn_print'] = isset( $_REQUEST['pdfprnt_show_btn_print'] ) ? 1 : 0;
194 $pdfprnt_options_array['show_btn_pdf_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_search_archive'] ) ? 1 : 0;
195 $pdfprnt_options_array['show_btn_print_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_print_search_archive'] ) ? 1 : 0;
196 $pdfprnt_options_array['tmpl_shorcode'] = isset( $_REQUEST['pdfprnt_tmpl_shorcode'] ) ? 1 : 0;
197 $pdfprnt_options_array['show_print_window'] = isset( $_REQUEST['pdfprnt_show_print_window'] ) ? 1 : 0;
198 $pdfprnt_options_array['use_types_posts'] = isset( $_REQUEST['pdfprnt_use_types_posts'] ) ? $_REQUEST['pdfprnt_use_types_posts'] : array();
199 $pdfprnt_options_array['use_custom_styles'] = isset( $_REQUEST['pdfprnt_use_custom_styles'] ) ? 1 : 0;
200 $pdfprnt_options_array['show_title'] = isset( $_REQUEST['pdfprnt_show_title'] ) ? 1 : 0;
201 $pdfprnt_options_array['show_featured_image'] = isset( $_REQUEST['pdfprnt_show_featured_image'] ) ? 1 : 0;
202 if ( isset( $_REQUEST['pdfprnt_custom_styles'] ) ) {
203 $custom_styles = stripslashes( esc_html( trim( $_REQUEST['pdfprnt_custom_styles'] ) ) );
204 if ( 10000 < strlen( $custom_styles ) )
205 $error .= __( 'You have entered too much text in the "edit styles" field.', 'pdf-print' );
206 else
207 $pdfprnt_options_array['custom_styles'] = $custom_styles;
208 }
209 update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
210 $message = __( 'Settings saved.', 'pdf-print' );
211 }
212 if ( ! is_dir( $fonts_path ) && $pdfprnt_options_array['additional_fonts'] != 0 ) { /* if "pdf-print-fonts" folder was removed somehow */
213 $error = __( 'The folder "uploads/pdf-print-fonts" was removed', 'pdf-print' );
214 $need_fonts_reload = true;
215 } elseif (
216 is_dir( $fonts_path ) &&
217 $pdfprnt_options_array['additional_fonts'] != count( scandir( $fonts_path ) ) &&
218 0 < $pdfprnt_options_array['additional_fonts']
219 ) { /* if some fonts was removed somehow from "pdf-print-fonts" folder */
220 $error = __( 'Some fonts were removed from the folder "uploads/pdf-print-fonts"', 'pdf-print' );
221 $need_fonts_reload = true;
222 }
223 if ( $need_fonts_reload ) {
224 $error .= '.&nbsp;' . sprintf(
225 __( 'You may need to reload fonts. For more info see %s', 'pdf-print' ),
226 '<a href="http://bestwebsoft.com/products/pdf-print/faq" target="_blank">' . __( 'FAQ', 'pdf-print' ) . '</a>'
227 );
228 pdfprnt_update_option( -1, true );
229 }
230 if ( isset( $_REQUEST['pdfprnt_load_fonts'] ) ) {
231 /* load additional fonts if javascript is disabled */
232 $result = pdfprnt_load_fonts();
233 if ( isset( $result['error'] ) ) {
234 $error .= '&nbsp;' . $result['error'] . '.&nbsp;' .
235 sprintf(
236 __( 'You may need to reload fonts. For more info see %s', 'pdf-print' ),
237 '<a href="http://bestwebsoft.com/products/pdf-print/faq" target="_blank">' . __( 'FAQ', 'pdf-print' ) . '</a>'
238 );
239 $need_fonts_reload = true;
240 }
241 if ( isset( $result['done'] ) )
242 $message .= '&nbsp;' . $result['done'];
243 }
244 if ( isset( $_REQUEST['bws_restore_confirm'] ) && check_admin_referer( $plugin_basename, 'pdfprnt_nonce_name' ) ) {
245 $pdfprnt_options_array = $pdfprnt_options_defaults;
246 update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
247 $message = __( 'All plugin settings were restored.', 'pdf-print' );
248 }
249
250 /* hide pro blocks */
251 if ( isset( $_POST['bws_hide_premium_options'] ) && check_admin_referer( $plugin_basename, 'pdfprnt_nonce_name' ) ) {
252 $hide_result = bws_hide_premium_options( $pdfprnt_options_array );
253 $pdfprnt_options_array = $hide_result['options'];
254 $message = $hide_result['message'];
255 update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
256 }
257 /* GO PRO */
258 if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) {
259 $go_pro_result = bws_go_pro_tab_check( $plugin_basename, 'pdfprnt_options_array' );
260 if ( ! empty( $go_pro_result['error'] ) )
261 $error = $go_pro_result['error'];
262 elseif ( ! empty( $go_pro_result['message'] ) )
263 $message = $go_pro_result['message'];
264 }
265 ?>
266 <div class="wrap">
267 <div class="icon32 icon32-bws" id="icon-options-general"></div>
268 <h2>PDF & Print<?php if ( isset( $_GET['action'] ) && 'templates' == $_GET['action'] ) { ?> <a href="admin.php?page=pdf-print.php&amp;action=templates&amp;pdfprnt_tab_action=new" class="add-new-h2 pdfprnt_add_new_button"><?php _e( 'Add New Template', 'pdf-print' ); ?></a><?php } ?></h2>
269 <h2 class="nav-tab-wrapper">
270 <a class="nav-tab<?php if ( !isset( $_GET['action'] ) ) echo ' nav-tab-active'; ?>" href="admin.php?page=pdf-print.php"><?php _e( 'Settings', 'pdf-print' ); ?></a>
271 <a class="nav-tab<?php if ( isset( $_GET['action'] ) && 'extra' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=pdf-print.php&amp;action=extra"><?php _e( 'Extra settings', 'pdf-print' ); ?></a>
272 <a class="nav-tab<?php if ( isset( $_GET['action'] ) && 'templates' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=pdf-print.php&amp;action=templates"><?php _e( 'Templates', 'pdf-print' ); ?></a>
273 <a class="nav-tab bws_go_pro_tab<?php if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=pdf-print.php&amp;action=go_pro"><?php _e( 'Go PRO', 'pdf-print' ); ?></a>
274 </h2>
275 <div class="updated fade" <?php if ( empty( $message ) || "" != $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?></strong></p></div>
276 <div class="error" <?php if ( "" == $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $error; ?></strong></p></div>
277 <?php $ttfontdata = plugin_dir_path( __FILE__ ) . 'mpdf/ttfontdata';
278 if ( ! is_writable( $ttfontdata ) ) {
279 if ( ! @chmod( $ttfontdata, 0755 ) ) { ?>
280 <div class="error">
281 <p>
282 <strong>
283 <?php _e( "Warning: Not enough rights for folder", 'pdf-print' ); ?>&nbsp;<i><?php echo $ttfontdata; ?></i>.<br />
284 <?php _e( 'Please check and change permissions for your plugins` folder ( for folders - 755, for files - 644 ). For more info see', 'pdf-print' ); ?>&nbsp;
285 <a href="https://codex.wordpress.org/Changing_File_Permissions" target="_blank"><?php _e( 'Changing File Permissions', 'pdf-print' ); ?></a>
286 &nbsp;<?php _e( 'and', 'pdf-print' ); ?>&nbsp;
287 <a href="http://bestwebsoft.com/products/pdf-print/faq" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>.
288 </strong>
289 </p>
290 </div>
291 <?php }
292 }
293 if ( ! isset( $_GET['action'] ) ) {
294 if ( isset( $_REQUEST['bws_restore_default'] ) && check_admin_referer( $plugin_basename, 'bws_settings_nonce_name' ) ) {
295 bws_form_restore_default_confirm( $plugin_basename );
296 } else {
297 bws_show_settings_notice(); ?>
298 <form method="post" action="admin.php?page=pdf-print.php" id="pdfprnt_settings_form" class="bws_form">
299 <table class="form-table pdfprnt_settings_table">
300 <tr>
301 <th scope="row"><?php _e( 'Types of posts that will be used in the plugin', 'pdf-print' ); ?></th>
302 <td>
303 <select name="pdfprnt_use_types_posts[]" multiple="multiple">
304 <?php foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1 ), 'objects' ) as $key => $value ) {
305 if ( 'attachment' != $key ) { ?>
306 <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $pdfprnt_options_array['use_types_posts'] ) ) echo 'selected="selected"'; ?>><?php echo $value->label; ?></option>
307 <?php }
308 } ?>
309 </select>
310 </td>
311 </tr>
312 </table>
313 <table class="form-table pdfprnt_settings_table pdfprnt_buttons" style="width: auto !important;">
314 <tr class="pdfprnt_table_head">
315 <th scope="row"></th>
316 <th><?php _e( 'Posts and pages', 'pdf-print' ); ?></th>
317 <th><?php _e( 'Search and archive pages', 'pdf-print' ); ?></th>
318 </tr>
319 <tr class="pdfprnt_pdf_buttton">
320 <th scope="row"><?php _e( 'Show PDF button', 'pdf-print' ); ?></th>
321 <td>
322 <input type="checkbox" name="pdfprnt_show_btn_pdf" <?php if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) echo 'checked="checked"'; ?> />
323 </td>
324 <td>
325 <input type="checkbox" name="pdfprnt_show_btn_pdf_search_archive" <?php if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) echo 'checked="checked"'; ?> />
326 </td>
327 </tr>
328 <tr class="pdfprnt_print_buttton">
329 <th scope="row"><?php _e( 'Show Print button', 'pdf-print' ); ?></th>
330 <td>
331 <input type="checkbox" name="pdfprnt_show_btn_print" <?php if ( 1 == $pdfprnt_options_array['show_btn_print'] ) echo 'checked="checked"'; ?> />
332 </td>
333 <td>
334 <input type="checkbox" name="pdfprnt_show_btn_print_search_archive" <?php if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) echo 'checked="checked"'; ?> />
335 </td>
336 </tr>
337 <tr class="pdfprnt_position_buttton">
338 <th scope="row"><?php _e( 'Position of buttons in the content', 'pdf-print' ); ?></th>
339 <td>
340 <fieldset><?php pdfprnt_display_radio( 'pdfprnt_position', $pdfprnt_options_array['position'] ); ?></fieldset>
341 </td>
342 <td>
343 <fieldset><?php pdfprnt_display_radio( 'pdfprnt_position_search_archive', $pdfprnt_options_array['position_search_archive'] ); ?></fieldset>
344 </td>
345 </tr>
346 </table>
347 <div>
348 <p>
349 <?php _e( 'In order to use PDF and Print buttons in the custom post or page template, see', 'pdf-print' ); ?>&nbsp;<a href="http://bestwebsoft.com/products/pdf-print/faq/" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>
350 </p>
351 </div>
352 <?php pdfprnt_pro_block( 'pdfprnt_image_block' ); ?>
353 <table class="form-table pdfprnt_settings_table">
354 <tr id="pdfprnt_load_fonts_button">
355 <th scope="row"><?php _e( 'Load additional fonts', 'pdf-print' ); ?></th>
356 <td style="position: relative;">
357 <?php if ( class_exists( 'ZipArchive' ) ) {
358 $fonts_button_title =
359 0 < $pdfprnt_options_array['additional_fonts'] || /* loading not called yet */
360 $need_fonts_reload /* loading occurred with errors or neccessary files lacks */
361 ?
362 __( 'Reload Fonts', 'pdf-print' )
363 :
364 __( 'Load Fonts', 'pdf-print' ); ?>
365 <input type="submit" class="button bws_no_bind_notice" value="<?php echo $fonts_button_title; ?>" name="pdfprnt_load_fonts" />&nbsp;<span id="pdfprnt_font_loader" class="pdfprnt_loader"><img src="<?php echo plugins_url( 'images/ajax-loader.gif', __FILE__ ); ?>" alt="loader" /></span><br />
366 <input type="hidden" name="pdfprnt_action" value="pdfprnt_load_fonts" />
367 <input type="hidden" name="pdfprnt_ajax_nonce" value="<?php echo wp_create_nonce( 'pdfprnt_ajax_nonce' ); ?>" />
368 <?php if ( 0 < $pdfprnt_options_array['additional_fonts'] ) { ?>
369 <span><?php _e( 'Additional fonts were loaded successfully', 'pdf-print' ); ?>.</span>
370 <?php } else {
371 if ( -1 == $pdfprnt_options_array['additional_fonts'] ) { ?>
372 <span><?php _e( 'If you have some problems with your internet connection, please, try to load additional fonts manually. For more info see', 'pdf-print' ); ?>&nbsp;<a href="http://bestwebsoft.com/products/pdf-print/faq" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>.</span><br />
373 <?php } ?>
374 <span class="bws_info"><?php _e( 'You can load additional fonts, needed for the PDF creation. When creating the PDF-doc, this will allow automatic selection of fonts necessary for text, according to languages used in the content.', 'pdf-print' ); ?></span>
375 <?php }
376 } else { ?>
377 <span style="color: red"><strong><?php _e( 'WARNING', 'pdf-print' ); ?>:&nbsp;</strong><?php _e( 'Class ZipArchive is not installed on your server. It is impossible to load additional fonts.', 'pdf-print' ); ?></span>
378 <?php } ?>
379 </td>
380 </tr>
381 <tr>
382 <th scope="row"><?php _e( 'Use the theme stylesheet or plugin default style', 'pdf-print' ); ?></th>
383 <td>
384 <select name="pdfprnt_use_theme_stylesheet">
385 <option value="0" <?php if ( 0 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Default stylesheet', 'pdf-print' ); ?></option>
386 <option value="1" <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Current theme stylesheet', 'pdf-print' ); ?></option>
387 </select>
388 </td>
389 </tr>
390 <tr>
391 <th scope="row"><?php _e( 'Add custom styles', 'pdf-print' ); ?></th>
392 <td>
393 <input value="1" type="checkbox" name="pdfprnt_use_custom_styles" <?php if ( 1 == $pdfprnt_options_array['use_custom_styles'] ) echo 'checked="checked"'; ?> />
394 <div class="bws_help_box dashicons dashicons-editor-help">
395 <div class="bws_hidden_help_text" style="min-width: 200px;">
396 <p>
397 <?php _e( 'Additional CSS-styles will be applied to your PDF/Print document', 'pdf-print' ); ?>.<br/>
398 <?php _e( 'Learn more about', 'pdf-print' ); ?>&nbsp;<a href="http://www.w3schools.com/css/" target="_blank">CSS</a>.
399 </p>
400 </div>
401 </div>
402 </td>
403 </tr>
404 <tr class="pdfprnt_custom_styles"<?php if ( 1 != $pdfprnt_options_array['use_custom_styles'] ) echo ' style="display: none;"'; ?>>
405 <th scope="row"></th>
406 <td>
407 <textarea id="pdfprnt_custom_styles" name="pdfprnt_custom_styles" maxlength="10000" cols="50" rows="5"><?php echo $pdfprnt_options_array['custom_styles']; ?></textarea><br />
408 <span class="bws_info"><?php _e( 'You can enter up to 10,000 characters', 'pdf-print' ); ?>.</span>
409
410 </td>
411 </tr>
412 <tr>
413 <th scope="row"><?php _e( 'Display additional elements', 'pdf-print' ); ?></th>
414 <td>
415 <label><input type="checkbox" name="pdfprnt_show_title" <?php if ( 1 == $pdfprnt_options_array['show_title'] ) echo 'checked="checked"'; ?> />&nbsp;<?php _e( 'Title', 'pdf-print' ); ?></label><br/>
416 <label><input type="checkbox" name="pdfprnt_show_featured_image" <?php if ( 1 == $pdfprnt_options_array['show_featured_image'] ) echo 'checked="checked"'; ?> />&nbsp;<?php _e( 'Featured image', 'pdf-print' ); ?></label>
417 </td>
418 </tr>
419 <tr>
420 <th scope="row">
421 <?php _e( 'Settings for shortcodes', 'pdf-print' ); ?>
422 </th>
423 <td>
424 <label><input type="checkbox" name="pdfprnt_tmpl_shorcode" <?php if ( 1 == $pdfprnt_options_array['tmpl_shorcode'] ) echo 'checked="checked"'; ?> /> <span><?php _e( 'Do!', 'pdf-print' ); ?></span></label>
425 </td>
426 </tr>
427 <tr>
428 <th scope="row"><?php _e( 'Show the print window', 'pdf-print' ); ?></th>
429 <td>
430 <input type="checkbox" name="pdfprnt_show_print_window" <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) echo 'checked="checked"'; ?> />
431 </td>
432 </tr>
433 </table>
434 <input type="hidden" name="pdfprnt_form_submit" value="1" />
435 <p class="submit">
436 <input type="submit" id="bws-submit-button" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
437 </p>
438 <?php wp_nonce_field( $plugin_basename, 'pdfprnt_nonce_name' ); ?>
439 </form>
440 <?php bws_form_restore_default_settings( $plugin_basename );
441 }
442 } else {
443 switch ( $_GET['action'] ) {
444 case 'extra':
445 case 'templates':
446 $new = isset( $_GET['pdfprnt_tab_action'] ) && 'new' == $_GET['pdfprnt_tab_action'] ? '_new' : '';
447 pdfprnt_pro_block( "pdfprnt_{$_GET['action']}{$new}_block", false );
448 break;
449 case 'go_pro':
450 $show = bws_hide_premium_options_check( $pdfprnt_options_array ) ? true : false;
451 bws_go_pro_tab_show(
452 $show,
453 $pdfprnt_plugin_info,
454 $plugin_basename,
455 'pdf-print.php',
456 'pdf-print-pro.php',
457 'pdf-print-pro/pdf-print-pro.php',
458 'pdf-print',
459 'd9da7c9c2046bed8dfa38d005d4bffdb',
460 '101',
461 isset( $go_pro_result['pro_plugin_is_activated'] )
462 );
463 break;
464 default:
465 break;
466 }
467
468 }
469 bws_plugin_reviews_block( $pdfprnt_plugin_info['Name'], 'pdf-print' ); ?>
470 </div>
471 <?php }
472 }
473
474 /* Positioning buttons in the page */
475 if ( ! function_exists( 'pdfprnt_content' ) ) {
476 function pdfprnt_content( $content ) {
477 if ( is_admin() )
478 return;
479 global $pdfprnt_options_array, $post;
480 if ( is_search() || is_archive() || is_category() || is_tax() || is_tag() || is_author() || ! in_array( $post->post_type, $pdfprnt_options_array['use_types_posts'] ) ) // Check for existence the type of posts.
481 return $content;
482 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) {
483 $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position'] . '">';
484 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) {
485 if ( ! is_front_page () )
486 $permalink = add_query_arg( 'print' , 'pdf' , get_permalink( $post->ID ) );
487 else
488 $permalink = add_query_arg( 'print' , 'pdf' , get_permalink() . '?page_id=' . $post->ID );
489 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="View PDF" /></a>';
490 }
491 if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
492 if ( ! is_front_page () )
493 $permalink = add_query_arg( 'print' , 'print' , get_permalink( $post->ID ) );
494 else
495 $permalink = add_query_arg( 'print' , 'print' , get_permalink() . '?page_id=' . $post->ID );
496 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
497 }
498 $str .= '</div>';
499
500 if ( 'top-left' == $pdfprnt_options_array['position'] || 'top-right' == $pdfprnt_options_array['position'] )
501 $content = $str . $content;
502 elseif ( 'bottom-left' == $pdfprnt_options_array['position'] || 'bottom-right' == $pdfprnt_options_array['position'] )
503 $content = $content . $str;
504 else
505 $content = $str . $content . $str;
506 }
507 return $content;
508 }
509 }
510
511 /* Output buttons for search or archive pages */
512 if ( ! function_exists( 'pdfprnt_show_buttons_search_archive' ) ) {
513 function pdfprnt_show_buttons_search_archive( $content ) {
514 global $wp_query;
515 /* make sure that we display pdf/print buttons only with main loop */
516 if ( is_main_query() && $content === $wp_query ) {
517 global $pdfprnt_options_array, $wp, $posts, $pdfprnt_show_archive_start, $pdfprnt_show_archive_end;
518 $loop_position = current_filter();
519 if ( ! ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] || 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) )
520 return;
521 /* Check for existence the type of posts. */
522 $is_return = true;
523 foreach ( $posts as $post ) {
524 if ( in_array( $post->post_type, $pdfprnt_options_array['use_types_posts'] ) ) {
525 $is_return = false;
526 break;
527 }
528 }
529 if ( $is_return )
530 return;
531
532 if ( ( 'loop_start' == $loop_position && $pdfprnt_show_archive_start == 1 ) || ( 'loop_end' == $loop_position && $pdfprnt_show_archive_end == 1 ) )
533 return;
534
535 $current_url = ( empty( $wp->request ) ) ? add_query_arg( $wp->query_string, '', home_url() ) : home_url( $wp->request );
536
537 $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position_search_archive'] . '">';
538 if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) {
539 $permalink = add_query_arg( 'print' , 'pdf-search' , $current_url );
540 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
541 }
542 if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) {
543 $permalink = add_query_arg( 'print' , 'print-search' , $current_url );
544 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
545 }
546 $str .= '</div>';
547 echo $str;
548 if ( 'loop_start' == $loop_position )
549 $pdfprnt_show_archive_start++;
550 elseif ( 'loop_end' == $loop_position )
551 $pdfprnt_show_archive_end++;
552 }
553 }
554 }
555
556 /**
557 * Add buttons before or after the loop
558 */
559 if ( ! function_exists( 'pdfprnt_auto_show_buttons_search_archive' ) ) {
560 function pdfprnt_auto_show_buttons_search_archive() {
561 if ( is_search() || is_archive() || is_category() || is_tax() || is_tag() || is_author() ) {
562 global $pdfprnt_options_array, $pdfprnt_show_archive_start, $pdfprnt_show_archive_end;
563 $pdfprnt_show_archive_start = $pdfprnt_show_archive_end = 0;
564 if ( in_array( $pdfprnt_options_array['position_search_archive'], array( 'top-left', 'top-right' ) ) ) {
565 add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
566 } elseif ( in_array( $pdfprnt_options_array['position_search_archive'], array( 'bottom-left', 'bottom-right' ) ) ) {
567 add_action( 'loop_end', 'pdfprnt_show_buttons_search_archive' );
568 } else {
569 add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
570 add_action( 'loop_end', 'pdfprnt_show_buttons_search_archive' );
571 }
572 }
573 }
574 }
575
576 /**
577 * Output buttons of page for BWS Portfolio plugin
578 * @deprecated since 1.8.4
579 */
580 if( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio' ) ) {
581 function pdfprnt_show_buttons_for_bws_portfolio() {
582 return pdfprnt_show_buttons_for_custom_post_type();
583 }
584 }
585
586 /**
587 * Output buttons of post for BWS Portfolio plugin
588 * @deprecated since 1.8.4
589 */
590 if ( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio_post' ) ) {
591 function pdfprnt_show_buttons_for_bws_portfolio_post() {
592 return pdfprnt_show_buttons_for_custom_post_type();
593 }
594 }
595
596
597 /**
598 * Display plugin buttons via action call
599 * @param string $where where to display
600 * @param mixed $user_query WP_Query parameters
601 */
602 if ( ! function_exists( 'pdfprnt_display_plugin_butttons' ) ) {
603 function pdfprnt_display_plugin_butttons( $where = 'top', $user_query = '' ) {
604 global $pdfprnt_options_array;
605 if ( preg_match( "|" . $where . "|", $pdfprnt_options_array['position'] ) || empty( $where ) )
606 echo pdfprnt_show_buttons_for_custom_post_type( $user_query );
607 }
608 }
609
610 /* Output buttons of page for custom post type */
611 if ( ! function_exists( 'pdfprnt_show_buttons_for_custom_post_type' ) ) {
612 function pdfprnt_show_buttons_for_custom_post_type( $user_query = '' ) {
613 global $pdfprnt_options_array, $post, $wp, $posts;
614 if (
615 /* not display anything if displaying buttons for post and pages is disabled */
616 ( ! ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) ) ||
617 /* not display anything if we have wrong $user_query */
618 ( ! ( is_array( $user_query ) || is_string( $user_query ) ) )
619 )
620 return;
621
622 $is_return = true;
623 if ( empty( $user_query ) ) { /* set necessary values of parameters for pdf/print buttons */
624 $current_url = empty( $wp->request ) ? add_query_arg( $wp->query_string, '', home_url() ) : home_url( $wp->request );
625 $nothing_else = false;
626 if ( is_search() || is_archive() || is_category() || is_tax() || is_tag() || is_author() ) { /* search, cattegories, archives */
627 foreach ( $posts as $value ) {
628 if ( in_array( $value->post_type, $pdfprnt_options_array['use_types_posts'] ) ) {
629 $is_return = false;
630 break;
631 }
632 }
633 if ( $is_return )
634 return;
635 $pdf_query_parameter = 'pdf-search';
636 $print_query_parameter = 'print-search';
637 } elseif ( is_page() ) { /* pages */
638 if ( in_array( 'page', $pdfprnt_options_array['use_types_posts'] ) ) {
639 $nothing_else = true;
640 } else {
641 return;
642 }
643 } elseif ( is_single() ) { /* posts */
644 $post_type = get_post_type( $post->ID );
645 if ( in_array( $post_type, $pdfprnt_options_array['use_types_posts'] ) ) {
646 $nothing_else = true;
647 } else {
648 return;
649 }
650 } else {
651 $nothing_else = true;
652 }
653 if ( $nothing_else ) {
654 $pdf_query_parameter = 'pdf';
655 $print_query_parameter = 'print';
656 }
657 } else {
658 $custom_query = new WP_Query( $user_query );
659 $current_url = add_query_arg( $custom_query->query, '', home_url() );
660 /* Check for existence the type of posts. */
661 if ( ! empty( $custom_query->posts) ) {
662 foreach ( $custom_query->posts as $post ) {
663 if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
664 $is_return = false;
665 break;
666 }
667 }
668 }
669 if ( $is_return )
670 return;
671 $pdf_query_parameter = 'pdf-custom';
672 $print_query_parameter = 'print-custom';
673 }
674
675 $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position'] . '">';
676 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) {
677 $permalink = add_query_arg( 'print' , $pdf_query_parameter , $current_url );
678 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
679 }
680 if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
681 $permalink = add_query_arg( 'print' , $print_query_parameter , $current_url );
682 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
683 }
684 $str .= '</div>';
685 return $str;
686 }
687 }
688
689 /* Add links */
690 if ( ! function_exists( 'pdfprnt_action_links' ) ) {
691 function pdfprnt_action_links( $links, $file ) {
692 if ( ! is_network_admin() ) {
693 $base = plugin_basename( __FILE__ );
694 if ( $file == $base ) {
695 $settings_link = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
696 array_unshift( $links, $settings_link );
697 }
698 }
699 return $links;
700 }
701 }
702
703 /* Add links */
704 if ( ! function_exists( 'pdfprnt_links' ) ) {
705 function pdfprnt_links( $links, $file ) {
706 $base = plugin_basename( __FILE__ );
707 if ( $file == $base ) {
708 if ( ! is_network_admin() )
709 $links[] = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
710 $links[] = '<a href="http://wordpress.org/plugins/pdf-print/faq/" target="_blank">' . __( 'FAQ', 'pdf-print' ) . '</a>';
711 $links[] = '<a href="http://support.bestwebsoft.com">' . __( 'Support', 'pdf-print' ) . '</a>';
712 }
713 return $links;
714 }
715 }
716
717 /* Add stylesheets */
718 if ( ! function_exists ( 'pdfprnt_admin_head' ) ) {
719 function pdfprnt_admin_head() {
720
721 wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
722
723 if ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] ) {
724 wp_enqueue_style( 'pdfprnt_codemirror', plugins_url( 'css/codemirror.css', __FILE__ ) );
725 wp_enqueue_script( 'pdfprnt_codemirror', plugins_url( 'js/codemirror.js' , __FILE__ ) );
726 wp_enqueue_script( 'pdfprnt_codemirror_css', plugins_url( 'js/css.js' , __FILE__ ) );
727 wp_enqueue_script( 'pdfprnt_script', plugins_url( 'js/script.js', __FILE__ ) );
728 wp_localize_script( 'pdfprnt_script', 'pdfprnt_var', array(
729 'loading_fonts' => __( 'Loading of fonts. It might take a several minutes', 'pdf-print' ),
730 'ajax_nonce' => wp_create_nonce( 'pdfprnt_ajax_nonce' ),
731 'need_reload' => '.&nbsp;' . sprintf(
732 __( 'You may need to reload fonts. For more info see %s', 'pdf-print' ),
733 '<a href="http://bestwebsoft.com/products/pdf-print/faq" target="_blank">' . __( 'FAQ', 'pdf-print' ) . '</a>'
734 )
735 )
736 );
737 }
738 }
739 }
740 /* Remove inline 'font-family' and 'font' styles from content */
741 if ( ! function_exists( 'pdfprnt_preg_replace' ) ) {
742 function pdfprnt_preg_replace( $patterns, $content ) {
743 foreach( $patterns as $pattern ) {
744 $content = preg_replace( "/" . $pattern . "(.*?);/", "", $content );
745 preg_match_all( "~style=(\"\'?)~", $content, $quotes );/* get array with quotes */
746 if ( isset( $quotes[1] ) && ! empty( $quotes[1] ) ) {
747 foreach ( $quotes[1] as $quote ) {
748 preg_match_all( "~style=" . $quote . "(.*?)" . $quote . "~", $content, $styles );
749 if ( ! empty( $styles[1] ) ) {
750 foreach ( $styles[1] as $style ) {
751 if ( preg_match( "/" . $pattern . "/", $style ) )
752 $content = preg_replace( "/" . $style . "/", "", $content );
753 }
754
755 }
756 }
757 }
758 }
759 return $content;
760 }
761 }
762
763 /* Generate templates for pdf file or print */
764 if ( ! function_exists( 'pdfprnt_generate_template' ) ) {
765 function pdfprnt_generate_template( $content, $isprint = false ) {
766 global $pdfprnt_options_array;
767 $html =
768 '<html>
769 <head>';
770 if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) {
771 /* remove 'font-family' and 'font' styles from theme css-file if additional fonts not loaded */
772 if ( 0 == $pdfprnt_options_array['additional_fonts'] ) {
773 $css = file_get_contents( get_bloginfo( 'stylesheet_url' ) );
774 if ( ( ! empty( $css ) ) )
775 $html .= '<style type="text/css">' . preg_replace( "/(font:(.*?);)|(font-family(.*?);)/", "", $css ) . '</style>';
776 } else {
777 $html .= '<link type="text/css" rel="stylesheet" href="' . get_bloginfo( 'stylesheet_url' ) . '" media="all" />';
778 }
779 } else {
780 $html .= '<link type="text/css" rel="stylesheet" href="' . plugins_url( 'css/default.css', __FILE__ ) . '" media="all" />';
781 }
782 $html .= pdfprnt_additional_styles( $isprint );
783 if ( 1 == $pdfprnt_options_array['use_custom_styles'] && ! empty( $pdfprnt_options_array['custom_styles'] ) )
784 $html .= '<style type="text/css">' . $pdfprnt_options_array['custom_styles'] . '</style>';
785 if ( $isprint && 1 == $pdfprnt_options_array['show_print_window'] )
786 $html .= '<script>window.onload = function(){ window.print(); };</script>';
787 $html .=
788 '</head>
789 <body' . ( $isprint ? ' class="pdfprnt_print"' : '' ) . '>';
790 /* Remove inline 'font-family' and 'font' styles from content */
791 if ( 0 == $pdfprnt_options_array['additional_fonts'] )
792 $content = pdfprnt_preg_replace( array( "font-family", "font:" ), $content );
793 $html .= $content .
794 '</body>
795 </html>';
796 return $html;
797 }
798 }
799
800 if ( ! function_exists( 'pdfprnt_additional_styles' ) ) {
801 function pdfprnt_additional_styles( $isprint ) {
802 $styles = apply_filters( 'bwsplgns_add_pdf_print_styles', array() );
803 $html = '';
804 if( ! empty( $styles ) && is_array( $styles ) ) {
805 $url = get_bloginfo( 'url' );
806 require_once( ABSPATH . 'wp-admin/includes/file.php' );
807 $path = get_home_path();
808 foreach ( $styles as $style ) {
809 if( ! empty( $style[0] ) && file_exists( $path . $style[0] ) ) {
810 /* if "get print" */
811 if ( $isprint ) {
812 if( ( isset( $style[1] ) && 'print' == $style[1] ) || ! isset( $style[1] ) )
813 $html .= '<link type="text/css" rel="stylesheet" href="' . $url . '/' . $style[0] . '" media="all" />';
814 /* if "get pdf" */
815 } else {
816 if( ( isset( $style[1] ) && 'pdf' == $style[1] ) || ! isset( $style[1] ) )
817 $html .= '<link type="text/css" rel="stylesheet" href="' . $url . '/' . $style[0] . '" media="all" />';
818 }
819 }
820 }
821 }
822 return $html;
823 }
824 }
825 /* Output print page or pdf document and include plugin script */
826 if ( ! function_exists( 'pdfprnt_print' ) ) {
827 function pdfprnt_print( $query ) {
828 global $pdfprnt_options_array, $posts, $post;
829 if ( $print = get_query_var( 'print' ) ) {
830 remove_all_filters( 'the_content' );
831 add_filter( 'the_content', 'capital_P_dangit', 11 );
832 add_filter( 'the_content', 'wptexturize' );
833 add_filter( 'the_content', 'convert_smilies' );
834 add_filter( 'the_content', 'convert_chars' );
835 add_filter( 'the_content', 'wpautop' );
836 if ( ! 0 == $pdfprnt_options_array['tmpl_shorcode'] ) {
837 add_filter( 'the_content', 'do_shortcode' ); /* executing shortcodes on the page */
838 } else {
839 $pattern = get_shortcode_regex();
840 if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) ) { /* getting all shortcodes we are using */
841 foreach ( array_unique( $matches[0] ) as $value) {
842 $post->post_content = str_replace( $value, "", $post->post_content ); /* replacing shortcodes to an empty string */
843 }
844 }
845 }
846 /* set path to directory with fonts for PDF document */
847 if ( ! ( 0 == $pdfprnt_options_array['additional_fonts'] && defined( "_MPDF_SYSTEM_TTFONTS" ) ) ) {
848 if ( is_multisite() ) {
849 switch_to_blog( 1 );
850 $upload_dir = wp_upload_dir();
851 restore_current_blog();
852 } else {
853 $upload_dir = wp_upload_dir();
854 }
855 define( '_MPDF_SYSTEM_TTFONTS', $upload_dir['basedir'] .'/pdf-print-fonts/' );
856 }
857 switch ( $print ) {
858 case 'pdf': /* Content for PDF from post */
859 include ( 'mpdf/mpdf.php' );
860 $user_info = get_userdata( $post->post_author );
861 $default_font = 0 == $pdfprnt_options_array['additional_fonts'] ? 'dejavusansmono' : '';
862 $mpdf = new mPDF( '+aCJK', 'A4', 0, $default_font );
863 $mpdf->allow_charset_conversion = true;
864 $mpdf->charset_in = get_bloginfo( 'charset' );
865 if ( ! 0 == $pdfprnt_options_array['additional_fonts'] ) {
866 $mpdf->autoScriptToLang = true;
867 $mpdf->autoLangToFont = true;
868 $mpdf->baseScript = 1;
869 $mpdf->autoVietnamese = true;
870 $mpdf->autoArabic = true;
871 }
872 if ( is_rtl() )
873 $mpdf->SetDirectionality( 'rtl' );
874 $mpdf->SetAuthor( $user_info->display_name );
875 $mpdf->SetTitle( $post->post_title );
876 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
877 $title = 1 == $pdfprnt_options_array['show_title'] ? '<div class="entry-header"><h1 class="entry-title"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div>' : '';
878 $featured_image = 1 == $pdfprnt_options_array['show_featured_image'] && has_post_thumbnail( $post->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $post->ID ) . '</div>' : '';
879 $html = '<div id="content">
880 <div class="post">' .
881 $featured_image .
882 $title .
883 '<div class="entry-content">' . apply_filters( 'bwsplgns_get_pdf_print_content', apply_filters( 'the_content', $post->post_content ) ) . '</div>
884 </div>
885 </div>';
886 $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
887 $mpdf->Output();
888 break;
889 case 'print': /* Content for printing from post */
890 $title = 1 == $pdfprnt_options_array['show_title'] ? '<div class="entry-header"><h1 class="entry-title">' . $post->post_title . '</h1></div>' : '';
891 $featured_image = 1 == $pdfprnt_options_array['show_featured_image'] && has_post_thumbnail( $post->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $post->ID ) . '</div>' : '';
892 $html = '<div id="content">
893 <div class="post">' .
894 $featured_image .
895 $title .
896 '<div class="entry-content">' . apply_filters( 'bwsplgns_get_pdf_print_content', apply_filters( 'the_content', $post->post_content ) ) . '</div>
897 </div>
898 </div>';
899 echo pdfprnt_generate_template( $html, true );
900 die();
901 break;
902 case 'pdf-search': /* Content for PDF from archive or searching page */
903 $titles = array();
904 $authors = array();
905 include ( 'mpdf/mpdf.php' );
906 $user_info = get_userdata( $post->post_author );
907 $default_font = 0 == $pdfprnt_options_array['additional_fonts'] ? 'dejavusansmono' : '';
908 $mpdf = new mPDF( '+aCJK', 'A4', 0, $default_font );
909 $mpdf->allow_charset_conversion = true;
910 $mpdf->charset_in = get_bloginfo( 'charset' );
911 if ( ! 0 == $pdfprnt_options_array['additional_fonts'] ) {
912 $mpdf->autoScriptToLang = true;
913 $mpdf->autoLangToFont = true;
914 $mpdf->baseScript = 1;
915 $mpdf->autoVietnamese = true;
916 $mpdf->autoArabic = true;
917 }
918 if ( is_rtl() )
919 $mpdf->SetDirectionality( 'rtl' );
920 $html = '<div id="content">';
921 foreach ( $posts as $p ) {
922 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
923 continue;
924 $titles[] = $p->post_title;
925 $user_info = get_userdata( $p->post_author );
926 $authors[] = $user_info->display_name;
927 $title = 1 == $pdfprnt_options_array['show_title'] ? '<div class="entry-header"><h1 class="entry-title"><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div>' : '';
928 $featured_image = 1 == $pdfprnt_options_array['show_featured_image'] && has_post_thumbnail( $p->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $p->ID ) . '</div>' : '';
929 $html .= '<div class="post">' .
930 $featured_image .
931 $title .
932 '<div class="entry-content">' . apply_filters( 'bwsplgns_get_pdf_print_content', apply_filters( 'the_content', $p->post_content ) ) . '</div>
933 </div><br/><hr/><br/>';
934 }
935 $html .= '</div>';
936 $titles = array_unique( $titles );
937 $authors = array_unique( $authors );
938 $mpdf->SetTitle( implode( ',', $titles ) );
939 $mpdf->SetAuthor( implode( ',', $authors ) );
940 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
941 $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
942 $mpdf->Output();
943 break;
944 case 'print-search': /* Content for printing from archive or searching page */
945 $html = '<div id="content">';
946 foreach ( $posts as $p ) {
947 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
948 continue;
949 $title = 1 == $pdfprnt_options_array['show_title'] ? '<div class="entry-header"><h1 class="entry-title">' . $p->post_title . '</h1></div>' : '';
950 $featured_image = 1 == $pdfprnt_options_array['show_featured_image'] && has_post_thumbnail( $p->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $p->ID ) . '</div>' : '';
951 $html .= '<div class="post">' .
952 $featured_image .
953 $title .
954 '<div class="entry-content">' . apply_filters( 'bwsplgns_get_pdf_print_content', apply_filters( 'the_content', $p->post_content ) ) . '</div>
955 </div><br/><hr/><br/>';
956 }
957 $html .= '</div>';
958 echo pdfprnt_generate_template( $html, true );
959 die();
960 break;
961 case 'pdf-custom': /* Content for PDF from custom post */
962 $url_data = parse_url( $_SERVER['REQUEST_URI'] );
963 parse_str( $url_data['query'], $args );
964 unset( $args['print'] );
965 if ( ! empty( $args ) ) {
966 $posts = get_posts( $args );
967 }
968 $html = '<div id="content">';
969 $titles = $authors = array();
970 foreach ( $posts as $p ) {
971 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
972 continue;
973 $titles[] = $p->post_title;
974 $user_info = get_userdata( $p->post_author );
975 $authors[] = $user_info->display_name;
976 $title = 1 == $pdfprnt_options_array['show_title'] ? '<div class="entry-header"><h1 class="entry-title"><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div>' : '';
977 $featured_image = 1 == $pdfprnt_options_array['show_featured_image'] && has_post_thumbnail( $p->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $p->ID ) . '</div>' : '';
978 $html .=
979 '<div class="post">' .
980 $featured_image .
981 $title .
982 '<div class="entry-content">' . apply_filters( 'bwsplgns_get_pdf_print_content', apply_filters( 'the_content', $p->post_content ) ) . '</div>
983 </div><br/><hr/><br/>';
984 }
985 $html .= '</div>';
986 include ( 'mpdf/mpdf.php' );
987 $default_font = 0 == $pdfprnt_options_array['additional_fonts'] ? 'dejavusansmono' : '';
988 $mpdf = new mPDF( '+aCJK', 'A4', 0, $default_font );
989 $mpdf->allow_charset_conversion = true;
990 $mpdf->charset_in = get_bloginfo( 'charset' );
991 if ( ! 0 == $pdfprnt_options_array['additional_fonts'] ) {
992 $mpdf->autoScriptToLang = true;
993 $mpdf->autoLangToFont = true;
994 $mpdf->baseScript = 1;
995 $mpdf->autoVietnamese = true;
996 $mpdf->autoArabic = true;
997 }
998 if ( is_rtl() )
999 $mpdf->SetDirectionality( 'rtl' );
1000 $titles = array_unique( $titles );
1001 $authors = array_unique( $authors );
1002 $mpdf->SetTitle( implode( ',', $titles ) );
1003 $mpdf->SetAuthor( implode( ',', $authors ) );
1004 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1005 $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
1006 $mpdf->Output();
1007 break;
1008 case 'print-custom': /* Content for printing from custom post */
1009 $url_data = parse_url( $_SERVER['REQUEST_URI'] );
1010 parse_str( $url_data['query'], $args );
1011 unset( $args['print'] );
1012 if ( ! empty( $args ) ) {
1013 $posts = get_posts( $args );
1014 }
1015 $html = '<div id="content">';
1016 foreach ( $posts as $p ) {
1017 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1018 continue;
1019 $title = 1 == $pdfprnt_options_array['show_title'] ? '<div class="entry-header"><h1 class="entry-title">' . $p->post_title . '</h1></div>' : '';
1020 $featured_image = 1 == $pdfprnt_options_array['show_featured_image'] && has_post_thumbnail( $p->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $p->ID ) . '</div>' : '';
1021 $html .=
1022 '<div class="post">' .
1023 $featured_image .
1024 $title .
1025 '<div class="entry-content">' . apply_filters( 'bwsplgns_get_pdf_print_content', apply_filters( 'the_content', $p->post_content ) ) . '</div>
1026 </div><br/><hr/><br/>';
1027 }
1028 $html .= '</div>';
1029 echo pdfprnt_generate_template( $html, true );
1030 die();
1031 break;
1032 }
1033 }
1034 }
1035 }
1036
1037 /* Add query vars */
1038 if ( ! function_exists( 'print_vars_callback' ) ) {
1039 function print_vars_callback( $query_vars ) {
1040 $query_vars[] = 'print';
1041 return $query_vars;
1042 }
1043 }
1044
1045 /**
1046 * Class Pdfprnt_ZipArchive for extracting
1047 * necessary folder from zip-archive
1048 */
1049 if ( class_exists( 'ZipArchive' ) && ! class_exists( 'Pdfprnt_ZipArchive' ) ) {
1050 class Pdfprnt_ZipArchive extends ZipArchive {
1051 /**
1052 * constructor of class
1053 */
1054 public function extractSubdirTo( $destination, $subdir ) {
1055 $errors = array();
1056 $charset = get_bloginfo( 'charset' );
1057 // Prepare dirs
1058 $destination = str_replace( array("/", "\\"), DIRECTORY_SEPARATOR, $destination );
1059 $subdir = str_replace( array("/", "\\"), "/", $subdir);
1060
1061 if ( substr( $destination, mb_strlen( DIRECTORY_SEPARATOR, $charset ) * -1 ) != DIRECTORY_SEPARATOR )
1062 $destination .= DIRECTORY_SEPARATOR;
1063
1064 if ( substr( $subdir, -1 ) != "/" )
1065 $subdir .= "/";
1066 // Extract files
1067 for ( $i = 0; $i < $this->numFiles; $i++ ) {
1068 $filename = $this->getNameIndex( $i );
1069
1070 if ( substr( $filename, 0, mb_strlen( $subdir, $charset ) ) == $subdir ) {
1071 $relativePath = substr( $filename, mb_strlen( $subdir, $charset ) );
1072 $relativePath = str_replace( array( "/", "\\" ), DIRECTORY_SEPARATOR, $relativePath );
1073
1074 if ( mb_strlen( $relativePath, $charset ) > 0 ) {
1075 if ( substr( $filename, -1 ) == "/" ) {
1076 if ( ! is_dir( $destination . $relativePath ) )
1077 if ( ! @mkdir( $destination . $relativePath, 0755, true ) )
1078 $errors[$i] = $filename;
1079 } else {
1080 if ( dirname( $relativePath) != "." ) {
1081 if ( ! is_dir( $destination . dirname( $relativePath ) ) ) {
1082 // New dir (for file)
1083 @mkdir( $destination . dirname( $relativePath ), 0755, true );
1084 }
1085 }
1086 // New file
1087 if ( @file_put_contents( $destination . $relativePath, $this->getFromIndex( $i ) ) === false )
1088 $errors[$i] = $filename;
1089 }
1090 }
1091 }
1092 }
1093 return $errors;
1094 }
1095 }
1096 }
1097
1098 /**
1099 * Download Zip
1100 */
1101 if ( ! function_exists( 'pdfprnt_download_zip' ) ) {
1102 function pdfprnt_download_zip( $zip_file, $upload_dir ) {
1103 /* check permissions */
1104 if ( is_writable( $upload_dir ) ) {
1105 /* load ZIP-archive */
1106 $result = array();
1107 $fp = fopen( $zip_file, 'w+');
1108 $curl = curl_init();
1109 $curl_parametres = array(
1110 CURLOPT_URL => 'http://mpdf1.com/repos/MPDF60.zip',
1111 CURLOPT_FILE => $fp,
1112 CURLOPT_USERAGENT => ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0" )
1113 );
1114 curl_setopt_array( $curl, $curl_parametres );
1115 if ( curl_exec( $curl ) ) {
1116 $result['done'] = 'ok';
1117 } else {
1118 $result['error'] = curl_error( $curl ) . '<br />' . __( 'Check your internet connection', 'pdf-print' );
1119 }
1120 curl_close( $curl );
1121 fclose( $fp );
1122 } else {
1123 $result['error'] = __( 'Cannot load files in to "uploads" folder. Check your permissions', 'pdf-print' );
1124 }
1125 return $result;
1126 }
1127 }
1128
1129 /**
1130 * Copy neccesary fonts to mpdf/ttfonts
1131 * @param string $zip_file path to zip archive
1132 */
1133 if ( ! function_exists( 'pdfprnt_copy_fonts' ) ) {
1134 function pdfprnt_copy_fonts( $zip_file, $upload_dir ) {
1135 global $pdfprnt_options_array;
1136 if ( empty( $pdfprnt_options_array ) )
1137 $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
1138 $destination = $upload_dir .'/pdf-print-fonts';
1139 if ( ! file_exists( $destination ) ) {
1140 mkdir( $destination, 0755, true );
1141 }
1142 $result = array();
1143 /* check permissions */
1144 if ( is_writable( $destination ) ) {
1145 $zip = new Pdfprnt_ZipArchive();
1146 /* open zip-archive */
1147 if ( true === $zip->open( $zip_file ) ) {
1148 /* extract folder with fonts */
1149 $errors = $zip->extractSubdirTo( $destination, "mpdf60/ttfonts" );
1150 $zip->close();
1151 if ( empty( $errors ) ) {
1152 $result['done'] = __( 'Additional fonts were successfully loaded', 'pdf-print' );
1153 unlink( $zip_file );
1154 } else {
1155 $result['error'] = __( 'Some errors occur during loading files', 'pdf-print' );
1156 }
1157 } else {
1158 $result['error'] = __( 'Can not extract files from zip-archive', 'pdf-print' );
1159 unlink( $zip_file );
1160 }
1161 } else {
1162 $result['error'] = __( 'Cannot create "uploads/pdf-print-fonts" folder. Check your permissions', 'pdf-print' );
1163 }
1164 $value = isset( $result['error'] ) ? -1 : count( scandir( $destination ) );
1165 pdfprnt_update_option( $value, true );
1166 return $result;
1167 }
1168 }
1169
1170 /**
1171 * Download ZIP-archive with MPDF library,
1172 * copy fonts to folder 'pdf-print-fons'
1173 */
1174 if ( ! function_exists( 'pdfprnt_load_and_copy' ) ) {
1175 function pdfprnt_load_and_copy( $zip_file, $upload_dir ) {
1176 $result = file_exists( $zip_file ) ? array( 'done' => 'ok' ) : pdfprnt_download_zip( $zip_file, $upload_dir );
1177 if ( isset( $result['done'] ) )
1178 $result = pdfprnt_copy_fonts( $zip_file, $upload_dir );
1179 return $result;
1180 }
1181 }
1182 /**
1183 * Function to load fonts for MPDF library
1184 */
1185 if ( ! function_exists( 'pdfprnt_load_fonts' ) ) {
1186 function pdfprnt_load_fonts() {
1187 global $pdfprnt_options_array;
1188 if ( empty( $pdfprnt_options_array ) )
1189 $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
1190 $ajax_request = isset( $_REQUEST['action'] ) && 'pdfprnt_load_fonts' == $_REQUEST['action'] ? true : false;
1191 $php_request = isset( $_REQUEST['pdfprnt_action'] ) && 'pdfprnt_load_fonts' == $_REQUEST['pdfprnt_action'] ? true : false;
1192 $verified = isset( $_REQUEST['pdfprnt_ajax_nonce'] ) && wp_verify_nonce( $_REQUEST['pdfprnt_ajax_nonce'], 'pdfprnt_ajax_nonce' ) ? true : false;
1193 if ( ( $ajax_request || $php_request ) && $verified ) {
1194 $result = array();
1195 $flag = false;
1196 /* get path to directory for ZIP-archive uploading */
1197 if ( is_multisite() ) {
1198 switch_to_blog( 1 );
1199 $upload_dir = wp_upload_dir();
1200 restore_current_blog();
1201 } else {
1202 $upload_dir = wp_upload_dir();
1203 }
1204 $zip_file = $upload_dir['basedir'] . '/MPDF60.zip';
1205 $destination = $upload_dir['basedir'] .'/pdf-print-fonts';
1206 if ( file_exists( $destination ) ) { /* if folder with fonts already exists */
1207 if ( is_multisite() ) {
1208 $network_options = get_site_option( 'pdfprnt_options_array' ); /* get network options */
1209 if ( $network_options['additional_fonts'] == count( scandir( $destination ) ) ) { /* if all fonts was loaded successfully */
1210 $result['done'] = __( 'Additional fonts was successfully loaded', 'pdf-print' );
1211 pdfprnt_update_option( $network_options['additional_fonts'] );
1212 } else { /* if something wrong */
1213 $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'] ); /* load fonts */
1214 }
1215 } else {
1216 $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'] ); /* load fonts */
1217 }
1218 } else {
1219 mkdir( $destination, 0755, true );
1220 $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'] );
1221 }
1222 if ( $ajax_request )
1223 echo json_encode( $result );
1224 else
1225 return $result;
1226 }
1227 if ( $ajax_request )
1228 die();
1229 }
1230 }
1231
1232 if ( ! function_exists( 'pdfprnt_update_option' ) ) {
1233 function pdfprnt_update_option( $value, $update_network = false ) {
1234 global $pdfprnt_options_array;
1235 if ( empty( $pdfprnt_options_array ) )
1236 $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
1237 $pdfprnt_options_array['additional_fonts'] = $value;
1238 update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
1239 if ( $update_network ) {
1240 $network_options = get_site_option( 'pdfprnt_options_array' );
1241 $network_options['additional_fonts'] = $value;
1242 update_site_option( 'pdfprnt_options_array', $network_options );
1243 }
1244 }
1245 }
1246
1247 if ( ! function_exists ( 'pdfprnt_plugin_banner' ) ) {
1248 function pdfprnt_plugin_banner() {
1249 global $hook_suffix, $pdfprnt_plugin_info, $pdfprnt_options_array;
1250 if ( empty( $pdfprnt_options_array ) )
1251 $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
1252 if ( 'plugins.php' == $hook_suffix ) {
1253 if ( isset( $pdfprnt_options_array['first_install'] ) && strtotime( '-1 week' ) > $pdfprnt_options_array['first_install'] )
1254 bws_plugin_banner( $pdfprnt_plugin_info, 'pdfprnt', 'pdf-print', 'e2f2549f4d70bc4cb9b48071169d264e', '101', '//ps.w.org/pdf-print/assets/icon-128x128.png' );
1255 bws_plugin_banner_to_settings( $pdfprnt_plugin_info, 'pdfprnt_options_array', 'pdf-print', 'admin.php?page=pdf-print.php' );
1256 }
1257 }
1258 }
1259
1260 /* Deleting plugin options on uninstalling */
1261 if ( ! function_exists( 'pdfprnt_uninstall' ) ) {
1262 function pdfprnt_uninstall() {
1263 global $wpdb;
1264 if ( is_multisite() ) {
1265 /* Get all blog ids */
1266 $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" );
1267 $tables = '';
1268 foreach ( $blogids as $blog_id ) {
1269 switch_to_blog( $blog_id );
1270 delete_option( 'pdfprnt_options_array' );
1271 }
1272 restore_current_blog();
1273 delete_site_option( 'pdfprnt_options_array' );
1274 } else {
1275 delete_option( 'pdfprnt_options_array' );
1276 }
1277 }
1278 }
1279
1280 /* Adding function to output PDF document or pirnt page */
1281 add_action( 'wp', 'pdfprnt_print' );
1282 add_action( 'wp_head', 'pdfprnt_auto_show_buttons_search_archive' );
1283 add_action( 'plugins_loaded', 'pdfprnt_plugins_loaded' );
1284 /* Initialization */
1285 add_action( 'init', 'pdfprnt_init' );
1286 add_action( 'admin_init', 'pdfprnt_admin_init' );
1287 /* Adding stylesheets */
1288 add_action( 'admin_enqueue_scripts', 'pdfprnt_admin_head' );
1289 add_action( 'wp_enqueue_scripts', 'pdfprnt_admin_head' );
1290 /* Adding 'BWS Plugins' admin menu */
1291 add_action( 'admin_menu', 'pdfprnt_add_pages' );
1292 /* Add query vars */
1293 add_filter( 'query_vars', 'print_vars_callback' );
1294 /* Additional links on the plugin page */
1295 add_filter( 'plugin_action_links', 'pdfprnt_action_links', 10, 2 );
1296 add_filter( 'plugin_row_meta', 'pdfprnt_links', 10, 2 );
1297 /* Adding buttons plugin to content */
1298 add_filter( 'the_content', 'pdfprnt_content' );
1299 /* load additional fonts */
1300 add_action( 'wp_ajax_pdfprnt_load_fonts', 'pdfprnt_load_fonts' );
1301 /* Adding banner */
1302 add_action( 'admin_notices', 'pdfprnt_plugin_banner' );
1303 /* Plugin uninstall function */
1304
1305 add_action( 'bwsplgns_display_pdf_print_buttons', 'pdfprnt_display_plugin_butttons', 10, 2 );
1306 register_uninstall_hook( __FILE__, 'pdfprnt_uninstall' );