PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.7.6
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.7.6
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
← All changes | pdf-print.php +1249 -1992 trunk1.7.6 View file →
@@ -1,1331 +1,1052 @@
1 1 <?php
2 -/**
3 -Plugin Name: PDF & Print by BestWebSoft
4 -Plugin URI: https://bestwebsoft.com/products/wordpress/plugins/pdf-print/
5 -Description: Generate PDF files and print WordPress posts/pages. Customize document header/footer styles and appearance.
2 +/*
3 +Plugin Name: PDF & Print
4 +Plugin URI: http://bestwebsoft.com/products/
5 +Description: Plugin adds PDF creation and Print button on your site.
6 6 Author: BestWebSoft
7 -Text Domain: pdf-print
8 -Domain Path: /languages
9 -Version: 2.4.7
10 -Author URI: https://bestwebsoft.com/
7 +Version: 1.7.6
8 +Author URI: http://bestwebsoft.com/
11 9 License: GPLv2 or later
12 - */
10 +*/
13 11
14 -/**
15 -© Copyright 2021 BestWebSoft ( https://support.bestwebsoft.com )
12 +/* © Copyright 2014 BestWebSoft ( http://support.bestwebsoft.com )
16 13
17 -This program is free software; you can redistribute it and/or modify
18 -it under the terms of the GNU General Public License, version 2, as
19 -published by the Free Software Foundation.
14 + This program is free software; you can redistribute it and/or modify
15 + it under the terms of the GNU General Public License, version 2, as
16 + published by the Free Software Foundation.
20 17
21 -This program is distributed in the hope that it will be useful,
22 -but WITHOUT ANY WARRANTY; without even the implied warranty of
23 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 -GNU General Public License for more details.
18 + This program is distributed in the hope that it will be useful,
19 + but WITHOUT ANY WARRANTY; without even the implied warranty of
20 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 + GNU General Public License for more details.
25 22
26 -You should have received a copy of the GNU General Public License
27 -along with this program; if not, write to the Free Software
28 -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 - */
23 + You should have received a copy of the GNU General Public License
24 + along with this program; if not, write to the Free Software
25 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 +*/
30 27
31 -if ( ! defined( 'ABSPATH' ) ) {
32 - exit;
33 -}
28 +/* Add our own menu */
29 +if ( ! function_exists( 'pdfprnt_add_pages' ) ) {
30 + function pdfprnt_add_pages() {
31 + global $bstwbsftwppdtplgns_options, $bstwbsftwppdtplgns_added_menu;
32 + $bws_menu_info = get_plugin_data( plugin_dir_path( __FILE__ ) . "bws_menu/bws_menu.php" );
33 + $bws_menu_version = $bws_menu_info["Version"];
34 + $base = plugin_basename(__FILE__);
34 35
35 -require_once dirname( __FILE__ ) . '/includes/deprecated.php';
36 + if ( ! isset( $bstwbsftwppdtplgns_options ) ) {
37 + if ( ! get_option( 'bstwbsftwppdtplgns_options' ) )
38 + add_option( 'bstwbsftwppdtplgns_options', array(), '', 'yes' );
39 + $bstwbsftwppdtplgns_options = get_option( 'bstwbsftwppdtplgns_options' );
40 + }
36 41
37 -if ( ! function_exists( 'pdfprnt_add_admin_menu' ) ) {
38 - /**
39 - * Add our own menu
40 - */
41 - function pdfprnt_add_admin_menu() {
42 - global $submenu, $pdfprnt_plugin_info, $wp_version, $pdfprnt_options;
43 - if ( ! is_plugin_active( 'pdf-print-pro/pdf-print-pro.php' )/*pls */ && ! is_plugin_active( 'pdf-print-plus/pdf-print-plus.php' )/* pls*/ ) {
44 - $settings = add_menu_page( esc_html__( 'PDF & Print Settings', 'pdf-print' ), 'PDF & Print', 'manage_options', 'pdf-print.php', 'pdfprnt_settings_page' );
45 - add_submenu_page( 'pdf-print.php', esc_html__( 'PDF & Print Settings', 'pdf-print' ), esc_html__( 'Settings', 'pdf-print' ), 'manage_options', 'pdf-print.php', 'pdfprnt_settings_page' );
46 - add_submenu_page( 'pdf-print.php', esc_html__( 'Headers & Footers', 'pdf-print' ), esc_html__( 'Headers & Footers', 'pdf-print' ), 'manage_options', 'pdf-print-templates.php', 'pdfprnt_templates' );
47 - add_submenu_page( 'pdf-print.php', 'BWS Panel', 'BWS Panel', 'manage_options', 'pdfprnt-bws-panel', 'bws_add_menu_render' );
48 - if ( isset( $submenu['pdf-print.php'] ) ) {
49 - $submenu['pdf-print.php'][] = array(
50 - '<span style="color:#d86463"> ' . esc_html__( 'Upgrade to Pro', 'pdf-print' ) . '</span>',
51 - 'manage_options',
52 - 'https://bestwebsoft.com/products/wordpress/plugins/pdf-print/?k=d9da7c9c2046bed8dfa38d005d4bffdb&pn=101&v=' . $pdfprnt_plugin_info['Version'] . '&wp_v=' . $wp_version,
53 - );
42 + if ( isset( $bstwbsftwppdtplgns_options['bws_menu_version'] ) ) {
43 + $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] = $bws_menu_version;
44 + unset( $bstwbsftwppdtplgns_options['bws_menu_version'] );
45 + update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options, '', 'yes' );
46 + require_once( dirname( __FILE__ ) . '/bws_menu/bws_menu.php' );
47 + } else if ( ! isset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] ) || $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] < $bws_menu_version ) {
48 + $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] = $bws_menu_version;
49 + update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options, '', 'yes' );
50 + require_once( dirname( __FILE__ ) . '/bws_menu/bws_menu.php' );
51 + } else if ( ! isset( $bstwbsftwppdtplgns_added_menu ) ) {
52 + $plugin_with_newer_menu = $base;
53 + foreach ( $bstwbsftwppdtplgns_options['bws_menu']['version'] as $key => $value ) {
54 + if ( $bws_menu_version < $value && is_plugin_active( $base ) ) {
55 + $plugin_with_newer_menu = $key;
56 + }
54 57 }
55 -
56 - add_action( "load-{$settings}", 'pdfprnt_add_tabs' );
58 + $plugin_with_newer_menu = explode( '/', $plugin_with_newer_menu );
59 + $wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? basename( WP_CONTENT_DIR ) : 'wp-content';
60 + if ( file_exists( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_menu.php' ) )
61 + require_once( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_menu.php' );
62 + else
63 + require_once( dirname( __FILE__ ) . '/bws_menu/bws_menu.php' );
64 + $bstwbsftwppdtplgns_added_menu = true;
57 65 }
58 - }
59 -}
60 66
61 -if ( ! function_exists( 'pdfprnt_add_tabs' ) ) {
62 - /**
63 - * Add help tab on settings page
64 - *
65 - * @return void
66 - */
67 - function pdfprnt_add_tabs() {
68 - $args = array(
69 - 'id' => 'pdfprnt',
70 - 'section' => '200538669',
71 - );
72 - bws_help_tab( get_current_screen(), $args );
67 + add_menu_page( 'BWS Plugins', 'BWS Plugins', 'manage_options', 'bws_plugins', 'bws_add_menu_render', plugins_url( 'images/px.png', __FILE__ ), 1001 );
68 + add_submenu_page( 'bws_plugins', __( 'PDF & Print Settings', 'pdf-print' ), __( 'PDF & Print', 'pdf-print' ), 'manage_options', "pdf-print.php", 'pdfprnt_settings_page' );
73 69 }
74 70 }
75 71
76 -if ( ! function_exists( 'pdfprnt_plugins_loaded' ) ) {
77 - /**
78 - * Localization
79 - */
80 - function pdfprnt_plugins_loaded() {
81 - /* Internationalization */
72 +/* Init plugin */
73 +if ( ! function_exists ( 'pdfprnt_init' ) ) {
74 + function pdfprnt_init() {
75 + /* Internationalization, first(!) */
82 76 load_plugin_textdomain( 'pdf-print', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
83 - }
84 -}
85 -
86 -if ( ! function_exists( 'pdfprnt_init' ) ) {
87 - /**
88 - * Init plugin
89 - */
90 - function pdfprnt_init() {
91 - global $pdfprnt_plugin_info, $pdfprnt_is_old_php;
92 -
93 - $plugin_basename = plugin_basename( __FILE__ );
94 -
95 - require_once dirname( __FILE__ ) . '/bws_menu/bws_include.php';
96 - bws_include_init( $plugin_basename );
97 -
98 - if ( empty( $pdfprnt_plugin_info ) ) {
99 - if ( ! function_exists( 'get_plugin_data' ) ) {
100 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
101 - }
102 - $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
103 - }
104 -
105 - /* check WordPress version */
106 - bws_wp_min_version_check( $plugin_basename, $pdfprnt_plugin_info, '4.5' );
107 -
108 - /* check PHP version */
109 - $pdfprnt_is_old_php = version_compare( PHP_VERSION, '5.4.0', '<' );
110 -
77 + /* Function check if plugin is compatible with current WP version */
78 + pdfprnt_version_check();
111 79 /* Get/Register and check settings for plugin */
112 - if ( ! is_admin() || ( isset( $_GET['page'] ) && 'pdf-print.php' === $_GET['page'] ) ) {
80 + if ( ! is_admin() || ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] ) )
113 81 pdfprnt_settings();
114 - }
115 -
116 - if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
117 - wp_register_block_types_from_metadata_collection( __DIR__ . '/includes/build', __DIR__ . '/includes/build/blocks-manifest.php' );
118 - return;
119 - }
120 -
121 - if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
122 - wp_register_block_metadata_collection( __DIR__ . '/includes/build', __DIR__ . '/includes/build/blocks-manifest.php' );
123 - }
124 - $manifest_data = require __DIR__ . '/includes/build/blocks-manifest.php';
125 - foreach ( array_keys( $manifest_data ) as $block_type ) {
126 - register_block_type( __DIR__ . "/includes/build/{$block_type}" );
127 - }
128 82 }
129 83 }
130 84
131 85 if ( ! function_exists( 'pdfprnt_admin_init' ) ) {
132 - /**
133 - * Admin init
134 - */
135 86 function pdfprnt_admin_init() {
136 - global $bws_plugin_info, $pdfprnt_plugin_info, $bws_shortcode_list, $pagenow, $pdfprnt_options;
87 + global $bws_plugin_info, $pdfprnt_plugin_info;
137 88
138 - if ( empty( $bws_plugin_info ) ) {
139 - $bws_plugin_info = array(
140 - 'id' => '101',
141 - 'version' => $pdfprnt_plugin_info['Version'],
142 - );
143 - }
144 - /* add PDF&Print to global $bws_shortcode_list */
145 - $bws_shortcode_list['pdfprnt'] = array(
146 - 'name' => 'PDF&Print',
147 - 'js_function' => 'pdfprnt_shortcode_init',
148 - );
149 - if ( 'plugins.php' === $pagenow ) {
150 - /* Install the option defaults */
151 - if ( function_exists( 'bws_plugin_banner_go_pro' ) ) {
152 - pdfprnt_settings();
153 - bws_plugin_banner_go_pro( $pdfprnt_options, $pdfprnt_plugin_info, 'pdfprnt', 'pdf-print', 'e2f2549f4d70bc4cb9b48071169d264e', '101', 'pdf-print' );
154 - }
155 - }
156 - }
157 -}
89 + if ( ! $pdfprnt_plugin_info )
90 + $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
158 91
159 -
160 -if ( ! function_exists( 'pdfprnt_plugin_activate' ) ) {
161 - /**
162 - * Function for activation
163 - */
164 - function pdfprnt_plugin_activate() {
165 - if ( is_multisite() ) {
166 - switch_to_blog( 1 );
167 - register_uninstall_hook( __FILE__, 'pdfprnt_uninstall' );
168 - restore_current_blog();
169 - } else {
170 - register_uninstall_hook( __FILE__, 'pdfprnt_uninstall' );
171 - }
92 + if ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) )
93 + $bws_plugin_info = array( 'id' => '101', 'version' => $pdfprnt_plugin_info["Version"] );
172 94 }
173 95 }
174 96
97 +/* Register settings for plugin */
175 98 if ( ! function_exists( 'pdfprnt_settings' ) ) {
176 - /**
177 - * Register settings for plugin
178 - */
179 99 function pdfprnt_settings() {
180 - global $pdfprnt_options, $pdfprnt_plugin_info;
181 - $options_default = pdfprnt_get_options_default();
182 - if ( ! get_option( 'pdfprnt_options' ) ) {
183 - add_option( 'pdfprnt_options', $options_default );
184 - }
100 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $pdfprnt_plugin_info;
185 101
186 - $pdfprnt_options = get_option( 'pdfprnt_options' );
187 - if ( ! isset( $pdfprnt_options['plugin_option_version'] ) || $pdfprnt_options['plugin_option_version'] !== $pdfprnt_plugin_info['Version'] ) {
188 - if ( isset( $pdfprnt_options['button_post_types'] ) ) {
189 - unset( $options_default['button_post_types'] );
190 - }
191 - if ( function_exists( 'array_replace_recursive' ) ) {
192 - $pdfprnt_options = array_replace_recursive( $options_default, $pdfprnt_options );
193 - } else {
194 - foreach ( $options_default as $key => $value ) {
195 - if (
196 - ! isset( $pdfprnt_options[ $key ] ) ||
197 - ( isset( $pdfprnt_options[ $key ] ) && is_array( $options_default[ $key ] ) && ! is_array( $pdfprnt_options[ $key ] ) )
198 - ) {
199 - $pdfprnt_options[ $key ] = $options_default[ $key ];
200 - } else {
201 - if ( is_array( $options_default[ $key ] ) ) {
202 - foreach ( $options_default[ $key ] as $key2 => $value2 ) {
203 - if ( ! isset( $pdfprnt_options[ $key ][ $key2 ] ) ) {
204 - $pdfprnt_options[ $key ][ $key2 ] = $options_default[ $key ][ $key2 ];
205 - }
206 - }
207 - }
208 - }
209 - }
210 - }
211 - $is_old_pro = false === strpos( 'pro-', $pdfprnt_options['plugin_option_version'] ) ? false : true;
212 - if ( $is_old_pro ) {
213 - foreach ( array( 'pdf', 'print' ) as $button ) {
214 - if ( 'none' !== $pdfprnt_options['button_image'][ $button ]['type'] ) {
215 - $pdfprnt_options['button_image'][ $button ]['type'] = 'default';
216 - $pdfprnt_options['button_image'][ $button ]['image_src'] = plugins_url( "images/{$button}.png", __FILE__ );
217 - }
218 - }
219 - }
220 -
221 - $pdfprnt_options['plugin_option_version'] = $pdfprnt_plugin_info['Version'];
222 - $pdfprnt_options['hide_premium_options'] = array();
223 - update_option( 'pdfprnt_options', $pdfprnt_options );
224 - pdfprnt_plugin_activate();
102 + if ( ! $pdfprnt_plugin_info ) {
103 + if ( ! function_exists( 'get_plugin_data' ) )
104 + require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
105 + $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
225 106 }
226 - }
227 -}
228 -
229 -if ( ! function_exists( 'pdfprnt_get_options_default' ) ) {
230 - /**
231 - * Get plugin default settings
232 - */
233 - function pdfprnt_get_options_default() {
234 - global $pdfprnt_plugin_info, $wp_roles;
235 -
107 +
236 108 /* Variable to verify performance number of once function. */
237 - $default_post_types = array();
109 + $pdfprnt_output_count_buttons = 0;
110 + $pdfprnt_default_post_types = array();
238 111 /* Default post types of WordPress. */
239 - foreach ( get_post_types(
240 - array(
241 - 'public' => 1,
242 - 'show_ui' => 1,
243 - '_builtin' => true,
244 - ),
245 - 'names'
246 - ) as $value ) {
247 - $default_post_types[] = $value;
248 - }
249 - $default_post_types[] = 'pdfprnt_search';
250 - $default_post_types[] = 'pdfprnt_archives';
251 - $default_post_types[] = 'pdfprnt_blog';
112 + foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1, '_builtin' => true ), 'names' ) as $value )
113 + $pdfprnt_default_post_types[] = $value;
252 114
253 - $enabled_roles = array();
254 - $roles = array_keys( $wp_roles->roles );
255 - foreach ( $roles as $key => $role ) {
256 - $enabled_roles[ $role ] = 1;
257 - }
258 - $enabled_roles['unauthorized'] = 1;
259 -
260 - $options_default = array(
261 - 'plugin_option_version' => $pdfprnt_plugin_info['Version'],
262 - 'button_post_types' => array(
263 - 'pdf' => $default_post_types,
264 - 'print' => $default_post_types,
265 - ),
266 - 'buttons_position' => 'top-right',
267 - 'use_default_css' => 0,
268 - 'use_custom_css' => 0,
269 - 'custom_css_code' => '',
270 - 'do_shorcodes' => 1,
271 - 'disable_links' => 0,
272 - 'remove_links' => 0,
273 - 'replace_video' => 0,
274 - 'qr_code_link' => 0,
275 - 'show_print_window' => 0,
276 - 'additional_fonts' => 0,
277 - 'show_title' => 1,
278 - 'show_featured_image' => 0,
279 - 'show_author' => 0,
280 - 'show_date' => 0,
281 - 'show_category' => 0,
282 - 'featured_image_size' => 'thumbnail',
283 - 'button_image' => array(
284 - 'pdf' => array(
285 - 'type' => 'default',
286 - 'image_src' => plugins_url( 'images/pdf.png', __FILE__ ),
287 - ),
288 - 'print' => array(
289 - 'type' => 'default',
290 - 'image_src' => plugins_url( 'images/print.png', __FILE__ ),
291 - ),
292 - ),
293 - 'button_title' => array(
294 - 'pdf' => '',
295 - 'print' => '',
296 - ),
297 - 'pdf_page_size' => 'A4',
298 - 'image_to_pdf' => 0,
299 - 'pdf_margins' => array(
300 - 'left' => 15,
301 - 'right' => 15,
302 - 'top' => 16,
303 - 'bottom' => 16,
304 - ),
305 - 'first_install' => strtotime( 'now' ),
306 - 'suggest_feature_banner' => 1,
307 - 'file_action' => 'open',
308 - 'print_action' => 'plugin_function',
309 - 'enabled_roles' => $enabled_roles,
310 - 'mpdf_library_version' => '8.2.6',
311 - 'hide_classes' => array(),
312 - 'count_generation' => 0,
115 + $pdfprnt_options_array_defaults = array(
116 + 'plugin_option_version' => $pdfprnt_plugin_info["Version"],
117 + 'position' => 'top-right',
118 + 'position_search_archive' => 'left',
119 + 'position_custom' => 'left',
120 + 'show_btn_print' => 1,
121 + 'show_btn_pdf' => 1,
122 + 'show_btn_print_search_archive' => 1,
123 + 'show_btn_pdf_search_archive' => 1,
124 + 'show_btn_print_custom' => 1,
125 + 'show_btn_pdf_custom' => 1,
126 + 'use_theme_stylesheet' => 0,
127 + 'tmpl_post' => 1,
128 + 'tmpl_search' => 1,
129 + 'tmpl_custom' => 1,
130 + 'tmpl_shorcode' => 1,
131 + 'use_types_posts' => $pdfprnt_default_post_types,
132 + 'show_print_window' => 0
313 133 );
134 +
135 + if ( ! get_option( 'pdfprnt_options_array' ) )
136 + add_option( 'pdfprnt_options_array', $pdfprnt_options_array_defaults, '', 'yes' );
314 137
315 - $options_default = apply_filters( 'pdfprnt_get_additional_options_default', $options_default );
138 + $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
316 139
317 - return $options_default;
140 + if ( ! isset( $pdfprnt_options_array['plugin_option_version'] ) || $pdfprnt_options_array['plugin_option_version'] != $pdfprnt_plugin_info["Version"] ) {
141 + $pdfprnt_options_array = array_merge( $pdfprnt_options_array_defaults, $pdfprnt_options_array );
142 + $pdfprnt_options_array['plugin_option_version'] = $pdfprnt_plugin_info["Version"];
143 + update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
144 + }
318 145 }
319 146 }
320 147
321 -if ( ! function_exists( 'pdfprnt_settings_page' ) ) {
322 - /**
323 - * Settings page
324 - */
325 - function pdfprnt_settings_page() {
326 - global $pdfprnt_plugin_info;
327 - require_once dirname( __FILE__ ) . '/includes/pro_banners.php';
328 - if ( ! class_exists( 'Bws_Settings_Tabs' ) ) {
329 - require_once dirname( __FILE__ ) . '/bws_menu/class-bws-settings.php';
330 - }
331 - require_once dirname( __FILE__ ) . '/includes/class-pdfprnt-settings.php';
332 - $page = new Pdfprnt_Settings_Tabs( plugin_basename( __FILE__ ) );
333 - if ( method_exists( $page, 'add_request_feature' ) ) {
334 - $page->add_request_feature();
335 - } ?>
336 - <div class="wrap">
337 - <h1 class="pdfprnt-title"><?php esc_html_e( 'PDF & Print Settings', 'pdf-print' ); ?></h1>
338 - <?php
339 - if ( function_exists( 'bws_plugin_promo_banner' ) ) {
340 - echo bws_plugin_promo_banner( $pdfprnt_plugin_info, 'pdfprnt_options', 'pdf-print', 'https://bestwebsoft.com/products/wordpress/plugins/pdf-print/?utm_source=wordpress&utm_medium=plugin_banner&utm_campaign=upgrade' );
148 +/* Function check if plugin is compatible with current WP version */
149 +if ( ! function_exists ( 'pdfprnt_version_check' ) ) {
150 + function pdfprnt_version_check() {
151 + global $wp_version, $pdfprnt_plugin_info;
152 + $require_wp = "3.0"; /* Wordpress at least requires version */
153 + $plugin = plugin_basename( __FILE__ );
154 + if ( version_compare( $wp_version, $require_wp, "<" ) ) {
155 + include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
156 + if ( is_plugin_active( $plugin ) ) {
157 + deactivate_plugins( $plugin );
158 + if ( ! $pdfprnt_plugin_info )
159 + $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
160 + $admin_url = ( function_exists( 'get_admin_url' ) ) ? get_admin_url( null, 'plugins.php' ) : esc_url( '/wp-admin/plugins.php' );
161 + wp_die( "<strong>" . $pdfprnt_plugin_info['Name'] . " </strong> " . __( 'requires', 'pdf-print' ) . " <strong>WordPress" . $require_wp . " </strong> " . __( 'or higher, that is why it has been deactivated! Please upgrade WordPress and try again.', 'pdf-print') . "<br /><br />" . __( 'Back to the WordPress', 'pdf-print') . " <a href='" . $admin_url . "'>" . __( 'Plugins page', 'pdf-print') . "</a>." );
341 162 }
342 - $page->display_content(); ?>
343 - </div>
344 - <?php
345 - }
346 -}
347 -
348 -
349 -if ( ! function_exists( 'pdfprnt_templates' ) ) {
350 - /**
351 - * Headers & Footers page
352 - */
353 - function pdfprnt_templates() {
354 - global $wp_version, $pdfprnt_plugin_info, $pdfprnt_options, $pdfprnt_links;
355 - require_once dirname( __FILE__ ) . '/includes/pro_banners.php';
356 -
357 - pdfprnt_settings();
358 - $bws_hide_premium = bws_hide_premium_options_check( $pdfprnt_options );
359 -
360 - $tab_action = ( isset( $_GET['pdfprnt_tab_action'] ) && 'new' === $_GET['pdfprnt_tab_action'] );
361 - if ( $tab_action ) {
362 - $page_title = esc_html__( 'Add New', 'pdf-print' );
363 - $page_name = esc_html__( 'Header & Footer Template', 'pdf-print' );
364 - } else {
365 - $page_title = '';
366 - $page_name = esc_html__( 'Headers & Footers', 'pdf-print' );
367 163 }
368 - $display_title = ( ! empty( $page_title ) ) ? "$page_title $page_name" : "$page_name";
369 - if ( ! isset( $_GET['pdfprnt_tab_action'] ) && ! $bws_hide_premium ) {
370 - $display_title .= sprintf(
371 - ' <a class="add-new-h2 pdfprnt_add_new_button" href="%s">%s</a>',
372 - admin_url( 'admin.php?page=pdf-print-templates.php&pdfprnt_tab_action=new' ),
373 - esc_html__( 'Add New', 'pdf-print' )
374 - );
375 - }
376 - ?>
377 - <div class="wrap">
378 - <h1 class="pdfprnt-title"><?php echo wp_kses_post( $display_title ); ?></h1>
379 - <br>
380 - <?php if ( $bws_hide_premium ) { ?>
381 - <p>
382 - <?php
383 - esc_html_e( 'This tab contains Pro options only.', 'pdf-print' );
384 - echo ' ' . sprintf(
385 - esc_html__( '%1$sChange the settings%2$s to view the Pro options.', 'pdf-print' ),
386 - '<a href="admin.php?page=pdf-print.php&bws_active_tab=misc">',
387 - '</a>'
388 - );
389 - ?>
390 - </p>
391 - <?php } else { ?>
392 - <div class="bws_pro_version_bloc pdfprnt-pro-feature pdfprnt-pro-feature-templates">
393 - <div class="bws_pro_version_table_bloc">
394 - <div class="bws_table_bg" style="z-index: 1098;"></div>
395 - <div class="bws_pro_version">
396 - <?php
397 - if ( ! $tab_action ) {
398 - $date_format = get_option( 'date_format' );
399 - pdfprnt_headers_footers_list_block( $date_format );
400 - } else {
401 - pdfprnt_headers_footers_editor_block();
402 - }
403 - ?>
404 - </div>
405 - </div>
406 - <div class="bws_pro_version_tooltip" style="z-index: 1099;">
407 - <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/pdf-print/?k=d9da7c9c2046bed8dfa38d005d4bffdb&pn=101&v=<?php echo esc_attr( $pdfprnt_plugin_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="PDF & Print Pro Plugin"><?php esc_html_e( 'Upgrade to Pro', 'pdf-print' ); ?></a>
408 - <div class="clear"></div>
409 - </div>
410 - </div>
411 - <?php } ?>
412 - </div>
413 - <?php
414 164 }
415 165 }
416 166
417 -if ( ! function_exists( 'pdfprnt_shortcode' ) ) {
418 - /**
419 - * PDF&Print shortcode
420 - * [bws_pdfprint]
421 - *
422 - * @param array $attr Attribute for shortcode.
423 - */
424 - function pdfprnt_shortcode( $attr ) {
425 - global $pdfprnt_options, $pdfprnt_is_old_php;
167 +/* Add admin page */
168 +if ( ! function_exists ( 'pdfprnt_settings_page' ) ) {
169 + function pdfprnt_settings_page () {
170 + global $pdfprnt_options_array, $wp_version, $pdfprnt_plugin_info;
171 + $message = $error = "";
426 172
427 - if ( isset( $_REQUEST['print'] ) || $pdfprnt_is_old_php || ! pdfprnt_is_user_role_enabled() ) {
428 - return;
429 - }
173 + $pdfprnt_positions_values = array(
174 + 'top-left' => __( 'Top Left', 'pdf-print' ),
175 + 'top-right' => __( 'Top Right', 'pdf-print' ),
176 + 'bottom-left' => __( 'Bottom Left', 'pdf-print' ),
177 + 'bottom-right' => __( 'Bottom Right', 'pdf-print' )
178 + );
430 179
431 - $buttons = '';
432 - if ( is_home() ) {
433 - global $post;
434 - $permalink = get_permalink( $post );
435 - } else {
436 - $permalink = isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ? ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
437 - }
438 - $shortcode_atts = shortcode_atts( array( 'display' => 'pdf' ), $attr );
439 - $shortcode_atts = str_word_count( $shortcode_atts['display'], 1 );
180 + if ( ! function_exists( 'get_plugins' ) || ! function_exists( 'is_plugin_active_for_network' ) )
181 + require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
182 + $all_plugins = get_plugins();
183 + $active_plugins = get_option( 'active_plugins' );
440 184
441 - foreach ( $shortcode_atts as $value ) {
442 - if ( 'pdf' === $value ) {
443 - $buttons .= pdfprnt_get_button( 'pdf', $permalink );
444 - }
445 - if ( 'print' === $value ) {
446 - $buttons .= pdfprnt_get_button( 'print', $permalink );
447 - }
185 + if ( isset( $_REQUEST['pdfprnt_position'] ) &&
186 + isset( $_REQUEST['pdfprnt_position_search_archive'] ) &&
187 + isset( $_REQUEST['pdfprnt_position_custom'] ) &&
188 + isset( $_REQUEST['pdfprnt_use_theme_stylesheet'] ) &&
189 + isset( $_REQUEST['pdfprnt_tmpl_post'] ) &&
190 + isset( $_REQUEST['pdfprnt_tmpl_custom'] ) &&
191 + isset( $_REQUEST['pdfprnt_tmpl_search'] ) &&
192 + check_admin_referer( plugin_basename( __FILE__ ), 'pdfprnt_nonce_name' ) ) {
193 + $pdfprnt_options_array['position'] = $_REQUEST['pdfprnt_position'];
194 + $pdfprnt_options_array['position_search_archive'] = $_REQUEST['pdfprnt_position_search_archive'];
195 + $pdfprnt_options_array['position_custom'] = $_REQUEST['pdfprnt_position_custom'];
196 + $pdfprnt_options_array['tmpl_post'] = $_REQUEST['pdfprnt_tmpl_post'];
197 + $pdfprnt_options_array['tmpl_search'] = $_REQUEST['pdfprnt_tmpl_search'];
198 + $pdfprnt_options_array['tmpl_custom'] = $_REQUEST['pdfprnt_tmpl_custom'];
199 + $pdfprnt_options_array['use_theme_stylesheet'] = $_REQUEST['pdfprnt_use_theme_stylesheet'];
200 + $pdfprnt_options_array['show_btn_pdf'] = isset( $_REQUEST['pdfprnt_show_btn_pdf'] ) ? 1 : 0;
201 + $pdfprnt_options_array['show_btn_print'] = isset( $_REQUEST['pdfprnt_show_btn_print'] ) ? 1 : 0;
202 + $pdfprnt_options_array['show_btn_pdf_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_search_archive'] ) ? 1 : 0;
203 + $pdfprnt_options_array['show_btn_print_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_print_search_archive'] ) ? 1 : 0;
204 + $pdfprnt_options_array['show_btn_pdf_custom'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_custom'] ) ? 1 : 0;
205 + $pdfprnt_options_array['show_btn_print_custom'] = isset( $_REQUEST['pdfprnt_show_btn_print_custom'] ) ? 1 : 0;
206 + $pdfprnt_options_array['tmpl_shorcode'] = isset( $_REQUEST['pdfprnt_tmpl_shorcode'] ) ? 1 : 0;
207 + $pdfprnt_options_array['show_print_window'] = isset( $_REQUEST['pdfprnt_show_print_window'] ) ? 1 : 0;
208 + $pdfprnt_options_array['use_types_posts'] = isset( $_REQUEST['pdfprnt_use_types_posts'] ) ? $_REQUEST['pdfprnt_use_types_posts'] : array();
209 + update_option ( 'pdfprnt_options_array', $pdfprnt_options_array );
210 + $message = __( 'Settings saved.', 'pdf-print' );
448 211 }
449 - if ( 1 === $pdfprnt_options['count_generation'] ) {
450 - $post_type = get_post_type();
451 - if ( in_array( $post_type, $pdfprnt_options['button_post_types']['pdf'] ) || in_array( $post_type, $pdfprnt_options['button_post_types']['print'] ) ) {
452 - $count = get_post_meta( get_the_ID(), 'pdfprnt_count_generation', true );
453 - $buttons .= ' <span class="pdfprnt-count-generation">' . $count . '</span>';
454 - }
455 - }
456 - if ( ! empty( $buttons ) ) {
457 - $buttons = sprintf(
458 - '<div class="pdfprnt-buttons">%s</div>',
459 - $buttons
460 - );
461 - add_action( 'wp_footer', 'pdfprnt_add_script' );
462 - }
212 + /* GO PRO */
213 + if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) {
463 214
464 - return $buttons;
465 - }
466 -}
215 + $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? trim( esc_html( $_POST['bws_license_key'] ) ) : "";
216 + $bstwbsftwppdtplgns_options_defaults = array();
467 217
468 -if ( ! function_exists( 'pdfprnt_shortcode_pagebreak' ) ) {
469 - /**
470 - * [pdfprnt_shortcode_pagebreak]
471 - */
472 - function pdfprnt_shortcode_pagebreak() {
473 - if ( isset( $_GET['print'] ) && 'pdf' === $_GET['print'] ) {
474 - return '<div style="page-break-after:always"></div>';
475 - }
476 - return '';
477 - }
478 -}
218 + if ( !get_option( 'bstwbsftwppdtplgns_options' ) )
219 + add_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options_defaults, '', 'yes' );
220 + $bstwbsftwppdtplgns_options = get_option( 'bstwbsftwppdtplgns_options' );
479 221
222 + if ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'bws_license_nonce_name' ) ) {
223 + if ( '' != $bws_license_key ) {
224 + if ( strlen( $bws_license_key ) != 18 ) {
225 + $error = __( "Wrong license key", 'pdf-print' );
226 + } else {
227 + $bws_license_plugin = stripslashes( esc_html( $_POST['bws_license_plugin'] ) );
228 + if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] < ( time() + (24 * 60 * 60) ) ) {
229 + $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1;
230 + } else {
231 + $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1;
232 + $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time();
233 + }
480 234
481 -if ( ! function_exists( 'pdfprnt_qr_code_content' ) ) {
482 - /**
483 - * Add custom fields shortcodes button
484 - *
485 - * @param string $content Post content.
486 - */
487 - function pdfprnt_qr_code_content( $content ) {
488 - global $pdfprnt_options;
489 - if ( 1 === $pdfprnt_options['replace_video'] ) {
490 - $provider_match_masks = array(
491 - 'youtube' => '/http.*(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/)[^\"\'>]+/',
492 - 'vimeo' => '/http.*vimeo\.com\/[^\"\'>]+/',
493 - 'dailymotion' => '/http.*dailymotion.com\/[^\"\'>]+/',
494 - 'videopress' => array(
495 - '/(?:http(?:s)?:\/\/)?videos\.files\.wordpress\.com\/[^\"\'>]+/i',
496 - '/(?:http(?:s)?:\/\/)?(?:www\.)?video(?:\.word)?press\.com\/(?:v|embed)\/[^\"\'>]+/i',
497 - ),
498 - );
499 - $find_replace = array();
500 - foreach ( $provider_match_masks as $provider => $match_mask ) {
501 - if ( ! is_array( $match_mask ) ) {
502 - $match_mask = array( $match_mask );
503 - }
504 - foreach ( $match_mask as $mask ) {
505 - $matches = array();
506 - preg_match_all( $mask, $content, $matches, PREG_OFFSET_CAPTURE );
507 - if ( isset( $matches[0][0] ) ) {
508 - $pos_start = strrpos( substr( $content, 0, $matches[0][0][1] ), '<', 0 );
509 - $pos_end = strpos( substr( $content, $pos_start ), '>', 0 );
510 - preg_match( '/<.*>/', substr( $content, $pos_start + $pos_end, 15 ), $matches2 );
511 - $text = substr( $content, $pos_start, $pos_end + 1 ) . $matches2[0];
512 - $find_replace[] = array( $matches[0][0][0], $matches[0][0][1], $text );
513 - }
514 - }
515 - }
516 - if ( ! empty( $find_replace ) ) {
517 - require_once( dirname( __FILE__ ) . '/includes/qr_code/qr_code.php' );
235 + /* download Pro */
236 + if ( ! array_key_exists( $bws_license_plugin, $all_plugins ) ) {
237 + $current = get_site_transient( 'update_plugins' );
238 + if ( is_array( $all_plugins ) && !empty( $all_plugins ) && isset( $current ) && is_array( $current->response ) ) {
239 + $to_send = array();
240 + $to_send["plugins"][ $bws_license_plugin ] = array();
241 + $to_send["plugins"][ $bws_license_plugin ]["bws_license_key"] = $bws_license_key;
242 + $to_send["plugins"][ $bws_license_plugin ]["bws_illegal_client"] = true;
243 + $options = array(
244 + 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
245 + 'body' => array( 'plugins' => serialize( $to_send ) ),
246 + 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
247 + $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options );
518 248
519 - foreach( $find_replace as $replace ) {
520 - $qr_code = QRCode::getMinimumQRCode( $replace[0], QR_ERROR_CORRECT_LEVEL_L );
249 + if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) {
250 + $error = __( "Something went wrong. Try again later. If the error will appear again, please, contact us <a href=http://support.bestwebsoft.com>BestWebSoft</a>. We are sorry for inconvenience.", 'pdf-print' );
251 + } else {
252 + $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
253 +
254 + if ( is_array( $response ) && !empty( $response ) ) {
255 + foreach ( $response as $key => $value ) {
256 + if ( "wrong_license_key" == $value->package ) {
257 + $error = __( "Wrong license key", 'pdf-print' );
258 + } elseif ( "wrong_domain" == $value->package ) {
259 + $error = __( "This license key is bind to another site", 'pdf-print' );
260 + } elseif ( "you_are_banned" == $value->package ) {
261 + $error = __( "Unfortunately, you have exceeded the number of available tries. Please, upload the plugin manually.", 'pdf-print' );
262 + }
263 + }
264 + if ( '' == $error ) {
265 + $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key;
521 266
522 - $image = $qr_code->createImage( 6, 4 );
523 - ob_start();
524 - imagejpeg( $image );
525 - $contents = ob_get_contents();
526 - ob_end_clean();
527 - $image_data = "data:image/jpeg;base64," . base64_encode( $contents );
267 + $url = 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $bws_license_plugin . '&bws_license_key=' . $bws_license_key . '&download_from=5';
268 + $uploadDir = wp_upload_dir();
269 + $zip_name = explode( '/', $bws_license_plugin );
270 + if ( file_put_contents( $uploadDir["path"] . "/" . $zip_name[0] . ".zip", file_get_contents( $url ) ) ) {
271 + @chmod( $uploadDir["path"] . "/" . $zip_name[0] . ".zip", octdec( 755 ) );
272 + if ( class_exists( 'ZipArchive' ) ) {
273 + $zip = new ZipArchive();
274 + if ( $zip->open( $uploadDir["path"] . "/" . $zip_name[0] . ".zip" ) === TRUE ) {
275 + $zip->extractTo( WP_PLUGIN_DIR );
276 + $zip->close();
277 + } else {
278 + $error = __( "Failed to open the zip archive. Please, upload the plugin manually", 'pdf-print' );
279 + }
280 + } elseif ( class_exists( 'Phar' ) ) {
281 + $phar = new PharData( $uploadDir["path"] . "/" . $zip_name[0] . ".zip" );
282 + $phar->extractTo( WP_PLUGIN_DIR );
283 + } else {
284 + $error = __( "Your server does not support either ZipArchive or Phar. Please, upload the plugin manually", 'pdf-print' );
285 + }
286 + @unlink( $uploadDir["path"] . "/" . $zip_name[0] . ".zip" );
287 + } else {
288 + $error = __( "Failed to download the zip archive. Please, upload the plugin manually", 'pdf-print' );
289 + }
528 290
529 - if ( 1 === $pdfprnt_options['qr_code_link'] ) {
530 - $content = str_replace( $replace[2], '<a href="' . $replace[0] . '"><img src="' . $image_data . '" /></a>', $content );
531 - } else {
532 - $content = str_replace( $replace[2], '<img src="' . $image_data . '" />', $content );
533 - }
534 - }
535 - }
536 - }
537 - return $content;
538 - }
539 -}
540 -if ( ! function_exists( 'pdfprnt_shortcode_button_content' ) ) {
541 - /**
542 - * Add shortcode content
543 - *
544 - * @param string $content Post content.
545 - */
546 - function pdfprnt_shortcode_button_content( $content ) {
547 - ?>
548 - <div id="pdfprnt" style="display:none;">
549 - <fieldset>
550 - <?php esc_html_e( 'Add PDF & Print Buttons to your page or post', 'pdf-print' ); ?>
551 - <br />
552 - <label>
553 - <input type="checkbox" name="pdfprnt_selected_pdf" value="pdf" checked="checked" />
554 - <?php esc_html_e( 'PDF', 'pdf-print' ); ?>
555 - </label>
556 - <br />
557 - <label>
558 - <input type="checkbox" name="pdfprnt_selected_print" value="print" />
559 - <?php esc_html_e( 'Print', 'pdf-print' ); ?>
560 - </label>
561 - <input class="bws_default_shortcode" type="hidden" name="default" value="[bws_pdfprint]" />
562 - <div class="clear"></div>
563 - </fieldset>
291 + /* activate Pro */
292 + if ( file_exists( WP_PLUGIN_DIR . '/' . $zip_name[0] ) ) {
293 + array_push( $active_plugins, $bws_license_plugin );
294 + update_option( 'active_plugins', $active_plugins );
295 + $pro_plugin_is_activated = true;
296 + } elseif ( '' == $error ) {
297 + $error = __( "Failed to download the zip archive. Please, upload the plugin manually", 'pdf-print' );
298 + }
299 + }
300 + } else {
301 + $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvienience.", 'pdf-print' );
302 + }
303 + }
304 + }
305 + } else {
306 + /* activate Pro */
307 + if ( ! ( in_array( $bws_license_plugin, $active_plugins ) || is_plugin_active_for_network( $bws_license_plugin ) ) ) {
308 + array_push( $active_plugins, $bws_license_plugin );
309 + update_option( 'active_plugins', $active_plugins );
310 + $pro_plugin_is_activated = true;
311 + }
312 + }
313 + update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options, '', 'yes' );
314 + }
315 + } else {
316 + $error = __( "Please, enter Your license key", 'pdf-print' );
317 + }
318 + }
319 + } ?>
320 + <div class="wrap">
321 + <div class="icon32 icon32-bws" id="icon-options-general"></div>
322 + <h2><?php _e( 'PDF & Print Settings', 'pdf-print' ); ?></h2>
323 + <h2 class="nav-tab-wrapper">
324 + <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>
325 + <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>
326 + <a class="nav-tab" href="http://bestwebsoft.com/products/pdf-print/faq/" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>
327 + <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>
328 + </h2>
329 + <div class="updated fade" <?php if ( empty( $message ) || "" != $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?></strong></p></div>
330 + <div id="pdfprnt_settings_notice" class="updated fade" style="display:none"><p><strong><?php _e( "Notice:", 'pdf-print' ); ?></strong> <?php _e( "The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'pdf-print' ); ?></p></div>
331 + <div class="error" <?php if ( "" == $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $error; ?></strong></p></div>
332 + <?php if ( ! isset( $_GET['action'] ) ) { ?>
333 + <form method="post" action="admin.php?page=pdf-print.php" id="pdfprnt_settings_form">
334 + <table class="form-table pdfprnt_settings_table">
335 + <tr>
336 + <th scope="row"><?php _e( 'Use of theme stylesheet or plugin default style:', 'pdf-print' ); ?></th>
337 + <td>
338 + <select name="pdfprnt_use_theme_stylesheet">
339 + <option value="0" <?php if ( 0 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Default stylesheet', 'pdf-print' ); ?></option>
340 + <option value="1" <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Current theme stylesheet', 'pdf-print' ); ?></option>
341 + </select>
342 + </td>
343 + </tr>
344 + <tr>
345 + <th scope="row"><?php _e( 'The types of posts that the plugin will use:', 'pdf-print' ); ?></th>
346 + <td>
347 + <select name="pdfprnt_use_types_posts[]" multiple="multiple">
348 + <?php foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1 ), 'objects' ) as $key => $value ) : ?>
349 + <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $pdfprnt_options_array['use_types_posts'] ) ) echo 'selected="selected"'; ?>><?php echo $value->label; ?></option>
350 + <?php endforeach; ?>
351 + </select>
352 + </td>
353 + </tr>
354 + <?php if( 0 < count( preg_grep( '/portfolio\/portfolio.php/', $active_plugins ) ) ) : ?>
355 + <tr>
356 + <th scope="row"></th>
357 + <td>
358 + <span class="pdfprnt_explanation"><?php echo __( 'If you are using a Portfolio plugin (powered by bestwebsoft.com) and you need the output pdf and print buttons next to each post, you just need to insert the strings in loop into the template source code in files portfolio.php and portfolio-post.php', 'pdf-print' ) . ' &#60;?php if ( function_exists( \'pdfprnt_show_buttons_for_bws_portfolio_post\' ) ) echo pdfprnt_show_buttons_for_bws_portfolio_post(); ?&#62;<br/> ' . __( ' In order to use PDF and Print buttons for all posts you need to put the strings below into the template source code in file portfolio.php', 'pdf-print' ) . ' &#60;?php if ( function_exists( \'pdfprnt_show_buttons_for_bws_portfolio\' ) ) echo pdfprnt_show_buttons_for_bws_portfolio(); ?&#62;'; ?></span>
359 + </td>
360 + </tr>
361 + <?php endif; ?>
362 + <tr>
363 + <th scope="row">
364 + <?php _e( 'Position of buttons in content:', 'pdf-print' ); ?>
365 + </th>
366 + <td>
367 + <select name="pdfprnt_position">
368 + <?php foreach ( $pdfprnt_positions_values as $key => $value ) : ?>
369 + <option value="<?php echo $key; ?>" <?php if ( $pdfprnt_options_array['position'] == $key ) echo 'selected="selected"'; ?>><?php echo $value; ?></option>
370 + <?php endforeach; ?>
371 + </select>
372 + </td>
373 + </tr>
374 + <tr>
375 + <th scope="row"><?php _e( 'Show:', 'pdf-print' ); ?></th>
376 + <td>
377 + <label><input type="checkbox" name="pdfprnt_show_btn_pdf" <?php if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'PDF button', 'pdf-print' ); ?></span></label><br />
378 + <label><input type="checkbox" name="pdfprnt_show_btn_print" <?php if ( 1 == $pdfprnt_options_array['show_btn_print'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'Print button', 'pdf-print' ); ?></span></label>
379 + </td>
380 + </tr>
381 + <tr>
382 + <th scope="row">
383 + <?php _e( 'Default template setting for post:', 'pdf-print' ); ?>
384 + </th>
385 + <td>
386 + <div>
387 + <label>
388 + <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
389 + <input type="radio" name="pdfprnt_tmpl_post" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
390 + </label>
391 + </div>
392 + <div>
393 + <label>
394 + <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
395 + <input type="radio" name="pdfprnt_tmpl_post" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
396 + </label>
397 + </div>
398 + <div>
399 + <label>
400 + <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
401 + <input type="radio" name="pdfprnt_tmpl_post" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
402 + </label>
403 + </div>
404 + </td>
405 + </tr>
406 + <tr>
407 + <th scope="row">
408 + <?php _e( 'Position of buttons in content for custom post:', 'pdf-print' ); ?>
409 + </th>
410 + <td>
411 + <select name="pdfprnt_position_custom">
412 + <option value="pdfprnt-left" <?php if ( 'left' == $pdfprnt_options_array['position_custom'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Left', 'pdf-print' ); ?></option>
413 + <option value="pdfprnt-right" <?php if ( 'right' == $pdfprnt_options_array['position_custom'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Right', 'pdf-print' ); ?></option>
414 + </select>
415 + </td>
416 + </tr>
417 + <tr>
418 + <th scope="row"><?php _e( 'Show for custom posts:', 'pdf-print' ); ?></th>
419 + <td>
420 + <label><input type="checkbox" name="pdfprnt_show_btn_pdf_custom" <?php if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'PDF button', 'pdf-print' ); ?></span></label><br />
421 + <label><input type="checkbox" name="pdfprnt_show_btn_print_custom" <?php if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'Print button', 'pdf-print' ); ?></span></label>
422 + </td>
423 + </tr>
424 + <tr>
425 + <th scope="row">
426 + <?php _e( 'Default template setting for custom posts:', 'pdf-print' ); ?>
427 + </th>
428 + <td>
429 + <div>
430 + <label>
431 + <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
432 + <input type="radio" name="pdfprnt_tmpl_custom" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
433 + </label>
434 + </div>
435 + <div>
436 + <label>
437 + <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
438 + <input type="radio" name="pdfprnt_tmpl_custom" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
439 + </label>
440 + </div>
441 + <div>
442 + <label>
443 + <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
444 + <input type="radio" name="pdfprnt_tmpl_custom" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
445 + </label>
446 + </div>
447 + </td>
448 + </tr>
449 + <tr>
450 + <th scope="row"></th>
451 + <td>
452 + <span class="pdfprnt_explanation"><?php echo __( 'In order to use PDF and Print buttons on the custom page you should use the', 'pdf-print' ) . '&#60;?php if ( function_exists( \'pdfprnt_show_buttons_for_custom_post_type\' ) ) echo pdfprnt_show_buttons_for_custom_post_type( $custom_query ); ?&#62;' . __( ' where you have to specify query parameters for your custom post.<br/> For example: ', 'pdf-print' ) . '&#60;?php if ( function_exists( \'pdfprnt_show_buttons_for_custom_post_type\' ) ) echo pdfprnt_show_buttons_for_custom_post_type( \'post_type=gallery&orderby=post_date\' ); ?&#62;' . __(' or ', 'pdf-print') . '&#60;?php if ( function_exists( \'pdfprnt_show_buttons_for_custom_post_type\' ) ) echo pdfprnt_show_buttons_for_custom_post_type( array( \'post_type\' => \'gallery\', \'orderby\' => \'post_date\' ) ); ?&#62;.' . __( ' For more information on the syntax for assigning parameters to function see <a target="_blank" href="http://codex.wordpress.org/Class_Reference/WP_Query#Parameters">here</a>.', 'pdf-print' ); ?></span>
453 + </td>
454 + </tr>
455 + <tr>
456 + <th scope="row">
457 + <?php _e( 'Position of buttons on search or archive page:', 'pdf-print' ); ?>
458 + </th>
459 + <td>
460 + <select name="pdfprnt_position_search_archive">
461 + <option value="pdfprnt-left" <?php if ( 'left' == $pdfprnt_options_array['position_search_archive'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Left', 'pdf-print' ); ?></option>
462 + <option value="pdfprnt-right" <?php if ( 'right' == $pdfprnt_options_array['position_search_archive'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Right', 'pdf-print' ); ?></option>
463 + </select>
464 + </td>
465 + </tr>
466 + <tr>
467 + <th scope="row"><?php _e( 'Show for search or archive page:', 'pdf-print' ); ?></th>
468 + <td>
469 + <label><input type="checkbox" name="pdfprnt_show_btn_pdf_search_archive" <?php if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'PDF button', 'pdf-print' ); ?></span></label><br />
470 + <label><input type="checkbox" name="pdfprnt_show_btn_print_search_archive" <?php if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'Print button', 'pdf-print' ); ?></span></label>
471 + </td>
472 + </tr>
473 + <tr>
474 + <th scope="row">
475 + <?php _e( 'Default template setting for search and archive:', 'pdf-print' ); ?>
476 + </th>
477 + <td>
478 + <div>
479 + <label>
480 + <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
481 + <input type="radio" name="pdfprnt_tmpl_search" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
482 + </label>
483 + </div>
484 + <div>
485 + <label>
486 + <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
487 + <input type="radio" name="pdfprnt_tmpl_search" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
488 + </label>
489 + </div>
490 + <div>
491 + <label>
492 + <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
493 + <input type="radio" name="pdfprnt_tmpl_search" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
494 + </label>
495 + </div>
496 + </td>
497 + </tr>
498 + <tr>
499 + <th scope="row"></th>
500 + <td>
501 + <span class="pdfprnt_explanation"><?php echo __( 'In order to use PDF and Print buttons on the search page or archive page you should put the strings below into the template source code in files search.php or archives.php ', 'pdf-print' ) . ' &#60;?php if ( function_exists( \'pdfprnt_show_buttons_search_archive\' ) ) echo pdfprnt_show_buttons_search_archive(); ?&#62;'; ?></span>
502 + </td>
503 + </tr>
504 + <tr>
505 + <th scope="row">
506 + <?php _e( 'Settings for shorcodes:', 'pdf-print' ); ?>
507 + </th>
508 + <td>
509 + <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>
510 + </td>
511 + </tr>
512 + <tr>
513 + <th scope="row"><?php _e( 'Show the print window', 'pdf-print' ); ?></th>
514 + <td>
515 + <input type="checkbox" name="pdfprnt_show_print_window" <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) echo 'checked="checked"'; ?> />
516 + </td>
517 + </tr>
518 + </table>
519 + <input type="hidden" name="pdfprnt_form_submit" value="1" />
520 + <p class="submit">
521 + <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
522 + </p>
523 + <?php wp_nonce_field( plugin_basename( __FILE__ ), 'pdfprnt_nonce_name' ); ?>
524 + </form>
525 + <div class="bws-plugin-reviews">
526 + <div class="bws-plugin-reviews-rate">
527 + <?php _e( 'If you enjoy our plugin, please give it 5 stars on WordPress', 'pdf-print' ); ?>:
528 + <a href="http://wordpress.org/support/view/plugin-reviews/pdf-print" target="_blank" title="PDF &amp; Print reviews"><?php _e( 'Rate the plugin', 'pdf-print' ); ?></a>
529 + </div>
530 + <div class="bws-plugin-reviews-support">
531 + <?php _e( 'If there is something wrong about it, please contact us', 'pdf-print' ); ?>:
532 + <a href="http://support.bestwebsoft.com">http://support.bestwebsoft.com</a>
533 + </div>
534 + </div>
535 + <?php } elseif ( 'extra' == $_GET['action'] ) { ?>
536 + <div class="bws_pro_version_bloc">
537 + <div class="bws_pro_version_table_bloc">
538 + <div class="bws_table_bg"></div>
539 + <table class="form-table bws_pro_version">
540 + <tr valign="top">
541 + <td colspan="2">
542 + <?php _e( 'Please choose the necessary post types (or single pages) where PDF & Print buttons will be displayed:', 'pdf-print' ); ?>
543 + </td>
544 + </tr>
545 + <tr valign="top">
546 + <td colspan="2">
547 + <label>
548 + <input disabled="disabled" checked="checked" id="twttrpr_jstree_url" type="checkbox" name="twttrpr_jstree_url" value="1" />
549 + <?php _e( "Show URL for pages", 'pdf-print' );?>
550 + </label>
551 + </td>
552 + </tr>
553 + <tr valign="top">
554 + <td colspan="2">
555 + <img src="<?php echo plugins_url( 'images/pro_screen_1.png', __FILE__ ); ?>" alt="<?php _e( "Example of site pages' tree", 'pdf-print' ); ?>" title="<?php _e( "Example of site pages' tree", 'pdf-print' ); ?>" />
556 + </td>
557 + </tr>
558 + <tr valign="top">
559 + <td colspan="2">
560 + <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
561 + </td>
562 + </tr>
563 + <tr valign="top">
564 + <th scope="row" colspan="2">
565 + * <?php _e( 'If you upgrade to Pro version all your settings will be saved.', 'pdf-print' ); ?>
566 + </th>
567 + </tr>
568 + </table>
569 + </div>
570 + <div class="bws_pro_version_tooltip">
571 + <div class="bws_info">
572 + <?php _e( 'Unlock premium options by upgrading to a PRO version.', 'pdf-print' ); ?>
573 + <a href="http://bestwebsoft.com/products/pdf-print/?k=d9da7c9c2046bed8dfa38d005d4bffdb&pn=101&v=<?php echo $pdfprnt_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="PDF & Print Pro"><?php _e( 'Learn More', 'pdf-print' ); ?></a>
574 + </div>
575 + <a class="bws_button" href="http://bestwebsoft.com/products/pdf-print/buy/?k=d9da7c9c2046bed8dfa38d005d4bffdb&pn=101&v=<?php echo $pdfprnt_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="PDF & Print Pro">
576 + <?php _e( 'Go', 'pdf-print' ); ?> <strong>PRO</strong>
577 + </a>
578 + <div class="clear"></div>
579 + </div>
580 + </div>
581 + <?php } elseif ( 'go_pro' == $_GET['action'] ) { ?>
582 + <?php if ( isset( $pro_plugin_is_activated ) && true === $pro_plugin_is_activated ) { ?>
583 + <script type="text/javascript">
584 + window.setTimeout( function() {
585 + window.location.href = 'admin.php?page=pdf-print-pro.php';
586 + }, 5000 );
587 + </script>
588 + <p><?php _e( "Congratulations! The PRO version of the plugin is successfully download and activated.", 'pdf-print' ); ?></p>
589 + <p>
590 + <?php _e( "Please, go to", 'pdf-print' ); ?> <a href="admin.php?page=pdf-print-pro.php"><?php _e( 'the setting page', 'pdf-print' ); ?></a>
591 + (<?php _e( "You will be redirected automatically in 5 seconds.", 'pdf-print' ); ?>)
592 + </p>
593 + <?php } else { ?>
594 + <form method="post" action="admin.php?page=pdf-print.php&amp;action=go_pro">
595 + <p>
596 + <?php _e( 'You can download and activate', 'pdf-print' ); ?>
597 + <a href="http://bestwebsoft.com/products/pdf-print/?k=d9da7c9c2046bed8dfa38d005d4bffdb&pn=101&v=<?php echo $pdfprnt_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="PDF & Print Pro">PRO</a>
598 + <?php _e( 'version of this plugin by entering Your license key.', 'pdf-print' ); ?><br />
599 + <span style="color: #888888;font-size: 10px;">
600 + <?php _e( 'You can find your license key on your personal page Client area, by clicking on the link', 'pdf-print' ); ?>
601 + <a href="http://bestwebsoft.com/wp-login.php">http://bestwebsoft.com/wp-login.php</a>
602 + <?php _e( '(your username is the email you specify when purchasing the product).', 'pdf-print' ); ?>
603 + </span>
604 + </p>
605 + <?php if ( isset( $bstwbsftwppdtplgns_options['go_pro']['pdf-print-pro/pdf-print-pro.php']['count'] ) &&
606 + '5' < $bstwbsftwppdtplgns_options['go_pro']['pdf-print-pro/pdf-print-pro.php']['count'] &&
607 + $bstwbsftwppdtplgns_options['go_pro']['pdf-print-pro/pdf-print-pro.php']['time'] < ( time() + ( 24 * 60 * 60 ) ) ) { ?>
608 + <p>
609 + <input disabled="disabled" type="text" name="bws_license_key" value="<?php echo $bws_license_key; ?>" />
610 + <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Go!', 'pdf-print' ); ?>" />
611 + </p>
612 + <p>
613 + <?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'pdf-print' ); ?>
614 + </p>
615 + <?php } else { ?>
616 + <p>
617 + <input type="text" name="bws_license_key" value="<?php echo $bws_license_key; ?>" />
618 + <input type="hidden" name="bws_license_plugin" value="pdf-print-pro/pdf-print-pro.php" />
619 + <input type="hidden" name="bws_license_submit" value="submit" />
620 + <input type="submit" class="button-primary" value="<?php _e( 'Go!', 'pdf-print' ); ?>" />
621 + <?php wp_nonce_field( plugin_basename(__FILE__), 'bws_license_nonce_name' ); ?>
622 + </p>
623 + <?php } ?>
624 + </form>
625 + <?php }
626 + } ?>
564 627 </div>
565 - <?php
566 - $script = "function pdfprnt_shortcode_init() {
567 - ( function( $ ) {
568 - $( '.mce-reset input[name^=\"pdfprnt_selected\"]' ).change( function() {
569 - var result = '';
570 - $( '.mce-reset input[name^=\"pdfprnt_selected\"]' ).each( function() {
571 - if ( $( this ).is( ':checked' ) ) {
572 - result += $( this ).val() + ',';
573 - }
574 - } );
575 -
576 - if ( '' == result ) {
577 - $( '.mce-reset #bws_shortcode_display' ).text( '' );
578 - } else {
579 - result = result.slice( 0, - 1 );
580 - $( '.mce-reset #bws_shortcode_display' ).text( '[bws_pdfprint display=\"' + result + '\"]' );
581 - }
582 - } );
583 - } ) ( jQuery );
584 - }";
585 -
586 - wp_register_script( 'pdfprnt_bws_shortcode_button', '//', false, null, false );
587 - wp_enqueue_script( 'pdfprnt_bws_shortcode_button' );
588 - wp_add_inline_script( 'pdfprnt_bws_shortcode_button', sprintf( $script ) );
589 - }
628 + <?php }
590 629 }
591 630
592 -if ( ! function_exists( 'pdfprnt_get_button' ) ) {
593 - /**
594 - * Forming button
595 - *
596 - * @param string $button button name: 'pdf' or 'print'.
597 - * @param string $url page url or permalink.
598 - * @param string $custom_query_arg custom query arg to add to query.
599 - * @return string $link formed link with image and button title.
600 - */
601 - function pdfprnt_get_button( $button = 'pdf', $url = '', $custom_query_arg = '' ) {
602 - global $pdfprnt_options;
603 -
604 - if ( empty( $url ) ) {
605 - $url = home_url( '/' );
606 - }
607 - $button = ( 'print' === $button ) ? 'print' : 'pdf';
608 -
609 - if ( 'default' === $pdfprnt_options['button_image'][ $button ]['type'] && ! empty( $pdfprnt_options['button_image'][ $button ]['image_src'] ) ) {
610 - $image = sprintf(
611 - '<img src="%s" alt="image_%s" title="%s" />',
612 - esc_url( $pdfprnt_options['button_image'][ $button ]['image_src'] ),
613 - $button,
614 - ( ( 'print' === $button ) ? esc_html__( 'Print Content', 'pdf-print' ) : ( ( 'open' === $pdfprnt_options['file_action'] ) ? esc_html__( 'View PDF', 'pdf-print' ) : esc_html__( 'Download PDF', 'pdf-print' ) ) )
615 - );
616 - } else {
617 - $image = '';
618 - }
619 -
620 - $custom_query_arg = ( ! empty( $custom_query_arg ) ) ? $custom_query_arg : $button;
621 - $url = esc_url( $url );
622 - $url = add_query_arg( 'print', $custom_query_arg, $url );
623 - $target = '_blank';
624 -
625 - $title = ( ! empty( $pdfprnt_options['button_title'][ $button ] ) ) ?
626 - sprintf(
627 - '<span class="pdfprnt-button-title pdfprnt-button-%s-title">%s</span>',
628 - $button,
629 - $pdfprnt_options['button_title'][ $button ]
630 - )
631 - :
632 - '';
633 - if ( $pdfprnt_options['image_to_pdf'] && 'pdf' === $custom_query_arg ) {
634 - $url = 'javascript: imageToPdf(' . get_the_ID() . ')';
635 - $target = '_self';
636 - }
637 -
638 - if ( 'print' === $button && 'ctrl_p' === $pdfprnt_options['print_action'] ) {
639 - $url = "javascript: window.print()";
640 - $target = '_self';
641 - }
642 -
643 - $link = sprintf(
644 - '<a href="%s" class="pdfprnt-button pdfprnt-button-%s" target="%s" >%s%s</a>',
645 - $url,
646 - $button,
647 - $target,
648 - $image,
649 - $title
650 - );
651 -
652 - $link = apply_filters( 'pdfprnt_add_atribute_rel', $link, $url, $button, $target, $image, $title );
653 -
654 - return $link;
655 - }
656 -}
657 -
658 -if ( ! function_exists( 'pdfprnt_is_user_role_enabled' ) ) {
659 - /**
660 - * Check is enabled for user role
661 - */
662 - function pdfprnt_is_user_role_enabled() {
663 - global $pdfprnt_options, $current_user;
664 - if ( ! is_user_logged_in() || empty( $current_user->roles ) ) {
665 - return ! empty( $pdfprnt_options['enabled_roles']['unauthorized'] );
666 - } else {
667 - $role = $current_user->roles[0];
668 - return ! empty( $pdfprnt_options['enabled_roles'][ $role ] );
669 - }
670 - }
671 -}
672 -
673 -if ( ! function_exists( 'pdfprnt_content' ) ) {
674 - /**
675 - * Positioning buttons in content of standart posts and pages
676 - *
677 - * @param string $content Post content.
678 - * @return string $content
679 - */
631 +/* Positioning buttons in the page */
632 +if( ! function_exists( 'pdfprnt_content' ) ) {
680 633 function pdfprnt_content( $content ) {
681 - global $pdfprnt_options, $post, $pdfprnt_is_old_php;
634 + if ( is_admin() )
635 + return;
682 636
683 - if ( $pdfprnt_is_old_php || is_admin() || is_feed() || is_search() || is_category() || is_tax() || is_tag() || is_author() || ! pdfprnt_is_user_role_enabled() || post_password_required( $post->ID ) ) {
637 + global $pdfprnt_options_array, $post;
638 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) // Check for existence the type of posts.
684 639 return $content;
685 - }
686 -
687 - $show_button_pdf = ! empty( $pdfprnt_options['button_post_types']['pdf'] ) && in_array( $post->post_type, $pdfprnt_options['button_post_types']['pdf'], true );
688 - $show_button_print = ! empty( $pdfprnt_options['button_post_types']['print'] ) && in_array( $post->post_type, $pdfprnt_options['button_post_types']['print'], true );
689 -
690 - if ( $show_button_pdf || $show_button_print ) {
691 -
692 - $str = '<div class="pdfprnt-buttons pdfprnt-buttons-' . $post->post_type . ' pdfprnt-' . $pdfprnt_options['buttons_position'] . '">';
693 - if ( is_home() ) {
694 - $permalink = get_permalink( $post );
695 - } else {
696 - $permalink = isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ? ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( urldecode( $_SERVER['REQUEST_URI'] ) ) ) : '';
640 + if ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) {
641 + $position = ( 'top-left' == $pdfprnt_options_array['position'] || 'top-right' == $pdfprnt_options_array['position'] ) ? true : false;
642 + $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position'] . '">';
643 + if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) {
644 + if ( ! is_front_page () )
645 + $permalink = add_query_arg( 'print' , 'pdf' , get_permalink( $post->ID ) );
646 + else
647 + $permalink = add_query_arg( 'print' , 'pdf' , get_permalink() . '?page-id=' . $post->ID );
648 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="View PDF" /></a>';
697 649 }
698 -
699 - if ( $show_button_pdf ) {
700 - $str .= pdfprnt_get_button( 'pdf', $permalink );
701 - if ( ! is_archive() && ! is_home() ) {
702 - add_action( 'wp_footer', 'pdfprnt_add_script' );
703 - }
650 + if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
651 + if ( ! is_front_page () )
652 + $permalink = add_query_arg( 'print' , 'print' , get_permalink( $post->ID ) );
653 + else
654 + $permalink = add_query_arg( 'print' , 'print' , get_permalink() . '?page-id=' . $post->ID );
655 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
704 656 }
705 - if ( $show_button_print ) {
706 - $str .= pdfprnt_get_button( 'print', $permalink );
707 - }
708 - if ( 1 === $pdfprnt_options['count_generation'] ) {
709 - $post_type = get_post_type();
710 - if ( in_array( $post_type, $pdfprnt_options['button_post_types']['pdf'] ) || in_array( $post_type, $pdfprnt_options['button_post_types']['print'] ) ) {
711 - $count = get_post_meta( get_the_ID(), 'pdfprnt_count_generation', true );
712 - $str .= ' <span class="pdfprnt-count-generation">' . $count . '</span>';
713 - }
714 - }
715 657 $str .= '</div>';
716 -
717 - if ( 'top-left' === $pdfprnt_options['buttons_position'] || 'top-right' === $pdfprnt_options['buttons_position'] ) {
658 + if ( $position )
718 659 $content = $str . $content;
719 - } elseif ( 'bottom-left' === $pdfprnt_options['buttons_position'] || 'bottom-right' === $pdfprnt_options['buttons_position'] ) {
660 + else
720 661 $content = $content . $str;
721 - } else {
722 - $content = $str . $content . $str;
723 - }
662 + unset( $position );
663 + unset( $str );
724 664 }
725 665 return $content;
726 666 }
727 667 }
728 668
729 -if ( ! function_exists( 'pdfprnt_excerpt' ) ) {
730 - /**
731 - * Remove Print word from excerpt
732 - *
733 - * @param string $content Post excerpt.
734 - * @return string $content
735 - */
736 - function pdfprnt_excerpt( $content ) {
737 - global $pdfprnt_options;
738 - $temp = array();
739 - $temp[1] = $content;
740 - $title = isset( $pdfprnt_options['button_title'] ) ? $pdfprnt_options['button_title'] : array( 'pdf' => '', 'print' => '' );
741 - if ( ! empty( $title['pdf'] ) ) {
742 - $temp = explode( $title['pdf'], $content );
669 +/* Output buttons for search or archive pages */
670 +if( ! function_exists( 'pdfprnt_show_buttons_search_archive' ) ) {
671 + function pdfprnt_show_buttons_search_archive() {
672 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wp, $posts;
673 + if ( 0 < $pdfprnt_output_count_buttons )
674 + return;
675 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_search_archive'] && 1 !== $pdfprnt_options_array['show_btn_print_search_archive'] )
676 + return;
677 + if ( ( ! is_search() && ! is_archive() ) || ( is_category() || ! have_posts() ) )
678 + return;
679 + /* Check for existence the type of posts. */
680 + $is_return = true;
681 + foreach ( $posts as $post ) {
682 + if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
683 + $is_return = false;
684 + break;
685 + }
743 686 }
744 - if ( ! empty( $title['print'] ) ) {
745 - $temp = explode( $title['print'], $content );
687 + if ( $is_return )
688 + return;
689 + $pdfprnt_output_count_buttons++;
690 + if ( empty( $wp->request ) )
691 + $current_url = add_query_arg( $wp->query_string, '', home_url() );
692 + else
693 + $current_url = home_url( $wp->request );
694 + $str = '<div class="' . $pdfprnt_options_array['position_search_archive'] . '">';
695 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) {
696 + $permalink = add_query_arg( 'print' , 'pdf-page' , $current_url );
697 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
746 698 }
747 - if ( isset( $temp[1] ) ) {
748 - return $temp[1];
749 - } else {
750 - return $content;
699 + if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) {
700 + $permalink = add_query_arg( 'print' , 'print-page' , $current_url );
701 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
751 702 }
703 + $str .= '</div>';
704 + unset( $current_url );
705 + unset( $permalink );
706 + echo $str;
752 707 }
753 708 }
754 -
755 -if ( ! function_exists( 'pdfprnt_show_buttons_search_archive' ) ) {
756 - /**
757 - * Output buttons for search or archive pages
758 - *
759 - * @param string $content Post content.
760 - */
761 - function pdfprnt_show_buttons_search_archive( $content ) {
762 - global $wp_query;
763 -
764 - /* make sure that we display pdf/print buttons only with main loop */
765 - if ( is_main_query() && $content === $wp_query ) {
766 - global $pdfprnt_options, $wp, $posts, $pdfprnt_show_archive_start, $pdfprnt_show_archive_end;
767 -
768 - $is_search = ( is_search() );
769 - $is_archive = ( is_archive() || is_category() || is_tax() || is_tag() || is_author() );
770 - $is_blog = ( is_home() );
771 -
772 - if ( $is_search ) {
773 - $show_button_pdf = ( in_array( 'pdfprnt_search', $pdfprnt_options['button_post_types']['pdf'], true ) );
774 - $show_button_print = ( in_array( 'pdfprnt_search', $pdfprnt_options['button_post_types']['print'], true ) );
775 - } elseif ( $is_archive ) {
776 - $show_button_pdf = ( in_array( 'pdfprnt_archives', $pdfprnt_options['button_post_types']['pdf'], true ) );
777 - $show_button_print = ( in_array( 'pdfprnt_archives', $pdfprnt_options['button_post_types']['print'], true ) );
778 - } elseif ( $is_blog ) {
779 - $show_button_pdf = ( in_array( 'pdfprnt_blog', $pdfprnt_options['button_post_types']['pdf'], true ) );
780 - $show_button_print = ( in_array( 'pdfprnt_blog', $pdfprnt_options['button_post_types']['print'], true ) );
781 - } else {
782 - $show_button_pdf = false;
783 - $show_button_print = false;
784 - }
785 -
786 - $loop_position = current_filter();
787 - if ( ! ( $show_button_pdf || $show_button_print ) ) {
788 - return;
789 - }
790 -
791 - if ( ( 'loop_start' === $loop_position && intval( $pdfprnt_show_archive_start ) === 1 ) || ( 'loop_end' === $loop_position && intval( $pdfprnt_show_archive_end ) === 1 ) ) {
792 - return;
793 - }
794 -
795 - if ( $show_button_pdf || $show_button_print ) {
796 - global $pdfprnt_is_search_archive;
797 - $current_url = isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ? set_url_scheme( ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( urldecode( $_SERVER['REQUEST_URI'] ) ) ) ) : '';
798 - $pdfprnt_is_search_archive = true;
799 - $str = '<div class="pdfprnt-buttons pdfprnt-buttons-' . ( ( $is_search ) ? 'search' : 'archive' ) . ' pdfprnt-' . $pdfprnt_options['buttons_position'] . '">';
800 - if ( $show_button_pdf ) {
801 - $str .= pdfprnt_get_button( 'pdf', $current_url, 'pdf-search' );
802 - add_action( 'wp_footer', 'pdfprnt_add_script' );
803 - }
804 -
805 - if ( $show_button_print ) {
806 - $str .= pdfprnt_get_button( 'print', $current_url, 'print-search' );
807 - }
808 - $str .= '</div>';
809 - echo wp_kses_post( $str );
810 - if ( 'loop_start' === $loop_position ) {
811 - $pdfprnt_show_archive_start++;
812 - } elseif ( 'loop_end' === $loop_position ) {
813 - $pdfprnt_show_archive_end++;
814 - }
815 - }
816 - }
709 +if ( ! function_exists( 'pdfprnt_auto_show_buttons_search_archive' ) ) {
710 + function pdfprnt_auto_show_buttons_search_archive() {
711 + if ( is_archive() || is_search() )
712 + add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
817 713 }
714 + add_action( 'wp_head', 'pdfprnt_auto_show_buttons_search_archive' );
818 715 }
819 716
820 -if ( ! function_exists( 'pdfprnt_return_buttons_search_archive' ) ) {
821 - /**
822 - * Return buttons for search or archive pages
823 - */
824 - function pdfprnt_return_buttons_search_archive() {
825 - global $wp_query;
826 -
827 - global $pdfprnt_options, $wp, $posts, $pdfprnt_show_archive_start, $pdfprnt_show_archive_end;
828 -
829 - $is_search = ( is_search() );
830 - $is_archive = ( is_archive() || is_category() || is_tax() || is_tag() || is_author() );
831 - $is_blog = ( is_home() );
832 -
833 - if ( $is_search ) {
834 - $show_button_pdf = ( in_array( 'pdfprnt_search', $pdfprnt_options['button_post_types']['pdf'], true ) );
835 - $show_button_print = ( in_array( 'pdfprnt_search', $pdfprnt_options['button_post_types']['print'], true ) );
836 - } elseif ( $is_archive ) {
837 - $show_button_pdf = ( in_array( 'pdfprnt_archives', $pdfprnt_options['button_post_types']['pdf'], true ) );
838 - $show_button_print = ( in_array( 'pdfprnt_archives', $pdfprnt_options['button_post_types']['print'], true ) );
839 - } elseif ( $is_blog ) {
840 - $show_button_pdf = ( in_array( 'pdfprnt_blog', $pdfprnt_options['button_post_types']['pdf'], true ) );
841 - $show_button_print = ( in_array( 'pdfprnt_blog', $pdfprnt_options['button_post_types']['print'], true ) );
842 - } else {
843 - $show_button_pdf = false;
844 - $show_button_print = false;
845 - }
846 -
847 - $loop_position = current_filter();
848 - if ( ! ( $show_button_pdf || $show_button_print ) ) {
717 +/* Output buttons of page for BWS Portfolio plugin */
718 +if( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio' ) ) {
719 + function pdfprnt_show_buttons_for_bws_portfolio() {
720 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wp;
721 + if ( 0 < $pdfprnt_output_count_buttons )
849 722 return;
850 - }
851 -
852 - if ( ( 'loop_start' === $loop_position && intval( $pdfprnt_show_archive_start ) === 1 ) || ( 'loop_end' === $loop_position && intval( $pdfprnt_show_archive_end ) === 1 ) ) {
723 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
853 724 return;
725 + if ( ! in_array( 'portfolio', $pdfprnt_options_array['use_types_posts'] ) )
726 + return;
727 + $pdfprnt_output_count_buttons++;
728 + if ( empty( $wp->request ) )
729 + $current_url = add_query_arg( $wp->query_string, '', home_url() );
730 + else
731 + $current_url = home_url( $wp->request );
732 + $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
733 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
734 + $permalink = add_query_arg( 'print' , 'pdf-portfolio-page' , $current_url );
735 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
854 736 }
855 -
856 - if ( $show_button_pdf || $show_button_print ) {
857 - global $pdfprnt_is_search_archive;
858 - $current_url = isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ? set_url_scheme( ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( urldecode( $_SERVER['REQUEST_URI'] ) ) ) ) : '';
859 - $pdfprnt_is_search_archive = true;
860 - $str = '<div class="pdfprnt-buttons pdfprnt-buttons-' . ( ( $is_search ) ? 'search' : 'archive' ) . ' pdfprnt-' . $pdfprnt_options['buttons_position'] . '">';
861 - if ( $show_button_pdf ) {
862 - $str .= pdfprnt_get_button( 'pdf', $current_url );
863 - add_action( 'wp_footer', 'pdfprnt_add_script' );
864 - }
865 -
866 - if ( $show_button_print ) {
867 - $str .= pdfprnt_get_button( 'print', $current_url, 'print-search' );
868 - }
869 - $str .= '</div>';
870 - if ( 'loop_start' === $loop_position ) {
871 - $pdfprnt_show_archive_start++;
872 - } elseif ( 'loop_end' === $loop_position ) {
873 - $pdfprnt_show_archive_end++;
874 - }
875 - return $str;
737 + if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
738 + $permalink = add_query_arg( 'print' , 'print-portfolio-page' , $current_url );
739 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
876 740 }
741 + $str .= '</div>';
742 + unset( $current_url );
743 + unset( $permalink );
744 + return $str;
877 745 }
878 746 }
879 747
880 -if ( ! function_exists( 'pdfprnt_auto_show_buttons_search_archive' ) ) {
881 - /**
882 - * Add buttons before or after the loop
883 - */
884 - function pdfprnt_auto_show_buttons_search_archive() {
885 - global $pdfprnt_options, $pdfprnt_is_old_php, $pdfprnt_plugin_info;
886 - $check_page = false;
887 - if ( $pdfprnt_is_old_php || apply_filters( 'pdfprnt_prevent_display_buttons', $check_page ) ) {
748 +/* Output buttons of post for BWS Portfolio plugin */
749 +if ( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio_post' ) ) {
750 + function pdfprnt_show_buttons_for_bws_portfolio_post() {
751 + global $pdfprnt_options_array, $post;
752 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
888 753 return;
889 - }
890 -
891 - $display_in_search = ( is_search() && ( in_array( 'pdfprnt_search', $pdfprnt_options['button_post_types']['pdf'], true ) || in_array( 'pdfprnt_search', $pdfprnt_options['button_post_types']['print'], true ) ) );
892 - $display_in_archive = ( ( is_archive() || is_category() || is_tax() || is_tag() || is_author() ) && ( in_array( 'pdfprnt_archives', $pdfprnt_options['button_post_types']['pdf'], true ) || in_array( 'pdfprnt_archives', $pdfprnt_options['button_post_types']['print'], true ) ) );
893 - $display_in_blog = ( ( is_home() ) && ( in_array( 'pdfprnt_blog', $pdfprnt_options['button_post_types']['pdf'], true ) || in_array( 'pdfprnt_blog', $pdfprnt_options['button_post_types']['print'], true ) ) );
894 -
895 - if ( ( $display_in_search || $display_in_archive || $display_in_blog ) && pdfprnt_is_user_role_enabled() ) {
896 - global $pdfprnt_show_archive_start, $pdfprnt_show_archive_end;
897 - $pdfprnt_show_archive_start = 0;
898 - $pdfprnt_show_archive_end = 0;
899 -
900 - $css = wp_remote_get( get_bloginfo( 'stylesheet_url' ) );
901 -
902 - if ( is_array( $css ) && ! empty( $css['body'] ) && ( ! empty( mb_stristr( $css['body'], 'Twenty Twenty-Two', true ) ) || ! empty( mb_stristr( $css['body'], 'Twenty Twenty-Three', true ) ) ) ) {
903 - $out1 = pdfprnt_return_buttons_search_archive();
904 - if ( ! empty( $out1 ) ) {
905 - wp_enqueue_script( 'pdfprnt_custom_script', plugins_url( 'js/custom_script.js', __FILE__ ), array( 'jquery' ), $pdfprnt_plugin_info['Version'], true );
906 - }
907 - }
908 - if ( in_array( $pdfprnt_options['buttons_position'], array( 'top-left', 'top-right' ), true ) ) {
909 - add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
910 - if ( isset( $out1 ) && ! empty( $out1 ) ) {
911 - wp_localize_script(
912 - 'pdfprnt_custom_script',
913 - 'pdfprnt_display_buttons',
914 - array(
915 - 'top' => $out1,
916 - )
917 - );
918 - }
919 - } elseif ( in_array( $pdfprnt_options['buttons_position'], array( 'bottom-left', 'bottom-right' ), true ) ) {
920 - add_action( 'loop_end', 'pdfprnt_show_buttons_search_archive' );
921 - if ( isset( $out1 ) && ! empty( $out1 ) ) {
922 - wp_localize_script(
923 - 'pdfprnt_custom_script',
924 - 'pdfprnt_display_buttons',
925 - array(
926 - 'bottom' => $out1,
927 - )
928 - );
929 - }
930 - } else {
931 - if ( isset( $out1 ) && ! empty( $out1 ) ) {
932 - wp_localize_script(
933 - 'pdfprnt_custom_script',
934 - 'pdfprnt_display_buttons',
935 - array(
936 - 'top' => $out1,
937 - 'bottom' => $out1,
938 - )
939 - );
940 - }
941 - add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
942 - add_action( 'loop_end', 'pdfprnt_show_buttons_search_archive' );
943 - }
944 - }
945 - }
946 -}
947 -
948 -if ( ! function_exists( 'pdfprnt_display_plugin_buttons' ) ) {
949 - /**
950 - * Display plugin buttons via action call
951 - *
952 - * @param string $where where to display.
953 - * @param mixed $user_query WP_Query parameters.
954 - */
955 - function pdfprnt_display_plugin_buttons( $where = 'top', $user_query = '' ) {
956 - global $pdfprnt_options, $pdfprnt_is_old_php;
957 -
958 - if ( $pdfprnt_is_old_php ) {
754 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
959 755 return;
756 + $current_url = get_permalink();
757 + $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
758 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
759 + $permalink = add_query_arg( 'print' , 'pdf-portfolio' , $current_url );
760 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
960 761 }
961 -
962 - if ( preg_match( '|' . $where . '|', $pdfprnt_options['buttons_position'] ) || empty( $where ) ) {
963 - echo wp_kses_post( pdfprnt_show_buttons_for_custom_post_type( $user_query ) );
762 + if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
763 + $permalink = add_query_arg( 'print' , 'print-portfolio' , $current_url );
764 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
964 765 }
766 + $str .= '</div>';
767 + unset( $current_url );
768 + unset( $permalink );
769 + return $str;
965 770 }
966 771 }
967 772
773 +/* Output buttons of page for custom post type */
968 774 if ( ! function_exists( 'pdfprnt_show_buttons_for_custom_post_type' ) ) {
969 - /**
970 - * Output buttons of page for custom post type
971 - *
972 - * @param string $user_query (Optional) User query.
973 - * @return string $str
974 - */
975 - function pdfprnt_show_buttons_for_custom_post_type( $user_query = '' ) {
976 - global $pdfprnt_options, $post, $posts;
977 -
978 - $show_button_pdf = in_array( $post->post_type, $pdfprnt_options['button_post_types']['pdf'], true );
979 - $show_button_print = in_array( $post->post_type, $pdfprnt_options['button_post_types']['print'], true );
980 -
981 - $show_button_pdf = apply_filters( 'pdfprnt_show_buttons_for_custom_post_type', 'pdf', $show_button_pdf );
982 - $show_button_print = apply_filters( 'pdfprnt_show_buttons_for_custom_post_type', 'print', $show_button_print );
983 -
984 - if (
985 - /* not display anything if displaying buttons for post and pages is disabled */
986 - ( ! ( $show_button_pdf || $show_button_print ) ) ||
987 - /* not display anything if we have wrong $user_query */
988 - ( ! ( is_array( $user_query ) || is_string( $user_query ) ) )
989 - ) {
775 + function pdfprnt_show_buttons_for_custom_post_type( $custom_query ) {
776 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons;
777 + if ( 0 < $pdfprnt_output_count_buttons )
990 778 return;
991 - }
992 - $current_url = isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ? set_url_scheme( ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( urldecode( $_SERVER['REQUEST_URI'] ) ) ) ) : '';
993 - $current_url = esc_url( $current_url );
994 - $is_return = true;
995 -
996 - if ( empty( $user_query ) ) { /* set necessary values of parameters for pdf/print buttons */
997 - $nothing_else = false;
998 - if ( is_search() || is_archive() || is_category() || is_tax() || is_tag() || is_author() || ! pdfprnt_is_user_role_enabled() ) { /* search, cattegories, archives */
999 - foreach ( $posts as $value ) {
1000 - if ( in_array( $value->post_type, $pdfprnt_options['button_post_types']['pdf'], true ) || in_array( 'page', $pdfprnt_options['button_post_types']['print'], true ) ) {
1001 - $is_return = false;
1002 - break;
1003 - }
1004 - }
1005 - if ( $is_return ) {
1006 - return;
1007 - }
1008 - $pdf_query_parameter = 'pdf-search';
1009 - $print_query_parameter = 'print-search';
1010 - } elseif ( is_page() ) { /* pages */
1011 - if ( in_array( 'page', $pdfprnt_options['button_post_types']['pdf'], true ) || in_array( 'page', $pdfprnt_options['button_post_types']['print'], true ) ) {
1012 - $nothing_else = true;
1013 - } else {
1014 - return;
1015 - }
1016 - } elseif ( is_single() ) { /* posts */
1017 - $post_type = get_post_type( $post->ID );
1018 - if ( in_array( $post_type, $pdfprnt_options['button_post_types']['pdf'], true ) || in_array( $post_type, $pdfprnt_options['button_post_types']['print'], true ) ) {
1019 - $nothing_else = true;
1020 - } else {
1021 - return;
1022 - }
1023 - } else {
1024 - $nothing_else = true;
779 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
780 + return;
781 + if ( ! is_array( $custom_query ) && ! is_string( $custom_query ) )
782 + return;
783 + $custom_query = new WP_Query( $custom_query );
784 + /* Check for existence the type of posts. */
785 + $is_return = true;
786 + foreach ( $custom_query->posts as $post ) {
787 + if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
788 + $is_return = false;
789 + break;
1025 790 }
1026 - if ( $nothing_else ) {
1027 - $pdf_query_parameter = 'pdf';
1028 - $print_query_parameter = 'print';
1029 - }
1030 - } else {
1031 - $custom_query = new WP_Query( $user_query );
1032 - $current_url = add_query_arg( $custom_query->query, '', $current_url );
1033 - /* Check for existence the type of posts. */
1034 - if ( ! empty( $custom_query->posts ) ) {
1035 - foreach ( $custom_query->posts as $post ) {
1036 - if ( in_array( get_post_type( $post ), $pdfprnt_options['button_post_types']['pdf'], true ) || in_array( get_post_type( $post ), $pdfprnt_options['button_post_types']['print'], true ) ) {
1037 - $is_return = false;
1038 - break;
1039 - }
1040 - }
1041 - }
1042 - if ( $is_return ) {
1043 - return;
1044 - }
1045 - global $pdfprnt_is_custom_post_type;
1046 - $pdfprnt_is_custom_post_type = true;
1047 - $pdf_query_parameter = 'pdf-custom';
1048 - $print_query_parameter = 'print-custom';
1049 791 }
1050 -
1051 - $str = '<div class="pdfprnt-buttons pdfprnt-buttons-custom pdfprnt-buttons-' . $post->post_type . ' pdfprnt-' . $pdfprnt_options['buttons_position'] . '">';
1052 - $current_url = apply_filters( 'pdfprnt_current_url_filter', $current_url );
1053 - if ( $show_button_pdf ) {
1054 - $str .= pdfprnt_get_button( 'pdf', $current_url, $pdf_query_parameter );
1055 - add_action( 'wp_footer', 'pdfprnt_add_script' );
792 + if ( $is_return )
793 + return;
794 + $pdfprnt_output_count_buttons++;
795 + $current_url = add_query_arg( $custom_query->query, '', home_url() );
796 + $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
797 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
798 + $permalink = add_query_arg( 'print' , 'pdf-custom-page' , $current_url );
799 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
1056 800 }
1057 - if ( $show_button_print ) {
1058 - $str .= pdfprnt_get_button( 'print', $current_url, $print_query_parameter );
801 + if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
802 + $permalink = add_query_arg( 'print' , 'print-custom-page' , $current_url );
803 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
1059 804 }
1060 - if ( 1 === $pdfprnt_options['count_generation'] && ( $show_button_pdf || $show_button_print ) ) {
1061 - $count = get_post_meta( get_the_ID(), 'pdfprnt_count_generation', true );
1062 - $str .= ' <span class="pdfprnt-count-generation">' . $count . '</span>';
1063 - }
1064 805 $str .= '</div>';
806 + unset( $current_url );
807 + unset( $permalink );
808 + unset( $is_return );
809 + unset( $custom_query );
1065 810 return $str;
1066 811 }
1067 812 }
1068 813
814 +/* Add links */
1069 815 if ( ! function_exists( 'pdfprnt_action_links' ) ) {
1070 - /**
1071 - * Add action links
1072 - *
1073 - * @param array $links Links array.
1074 - * @param string $file Plugin file.
1075 - * @return array $links
1076 - */
1077 816 function pdfprnt_action_links( $links, $file ) {
1078 - if ( ! is_network_admin() && is_plugin_inactive( 'pdf-print-pro/pdf-print-pro.php' ) ) {
1079 - $base = plugin_basename( __FILE__ );
1080 - if ( $file === $base ) {
1081 - $settings_link = '<a href="admin.php?page=pdf-print.php">' . esc_html__( 'Settings', 'pdf-print' ) . '</a>';
1082 - array_unshift( $links, $settings_link );
1083 - }
817 + $base = plugin_basename( __FILE__ );
818 + if ( $file == $base ) {
819 + $settings_link = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
820 + array_unshift( $links, $settings_link );
1084 821 }
1085 822 return $links;
1086 823 }
1087 824 }
1088 825
826 +/* Add links */
1089 827 if ( ! function_exists( 'pdfprnt_links' ) ) {
1090 - /**
1091 - * Add Settings, FAQ and Support links
1092 - *
1093 - * @param array $links Links array.
1094 - * @param string $file Plugin file.
1095 - * @return array $links
1096 - */
1097 828 function pdfprnt_links( $links, $file ) {
1098 829 $base = plugin_basename( __FILE__ );
1099 - if ( $file === $base ) {
1100 - if ( ! is_network_admin() && is_plugin_inactive( 'pdf-print-pro/pdf-print-pro.php' ) ) {
1101 - $links[] = '<a href="admin.php?page=pdf-print.php">' . esc_html__( 'Settings', 'pdf-print' ) . '</a>';
1102 - }
1103 - $links[] = '<a href="https://support.bestwebsoft.com/hc/en-us/sections/200538669" target="_blank">' . esc_html__( 'FAQ', 'pdf-print' ) . '</a>';
1104 - $links[] = '<a href="https://support.bestwebsoft.com">' . esc_html__( 'Support', 'pdf-print' ) . '</a>';
830 + if ( $file == $base ) {
831 + $links[] = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
832 + $links[] = '<a href="http://wordpress.org/plugins/pdf-print/faq/" target="_blank">' . __( 'FAQ', 'pdf-print' ) . '</a>';
833 + $links[] = '<a href="http://support.bestwebsoft.com">' . __( 'Support', 'pdf-print' ) . '</a>';
1105 834 }
1106 835 return $links;
1107 836 }
1108 837 }
1109 838
1110 -if ( ! function_exists( 'pdfprnt_admin_head' ) ) {
1111 - /**
1112 - * Add stylesheets
1113 - */
839 +/* Add stylesheets */
840 +if ( ! function_exists ( 'pdfprnt_admin_head' ) ) {
1114 841 function pdfprnt_admin_head() {
1115 - global $pdfprnt_plugin_info, $pdfprnt_options, $post;
842 + global $wp_version;
843 + if ( $wp_version < 3.8 )
844 + wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style_wp_before_3.8.css', __FILE__ ) );
845 + else
846 + wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
1116 847
1117 - if ( is_admin() ) {
1118 - wp_enqueue_style( 'pdfprnt_general', plugins_url( 'css/style-general.css', __FILE__ ), false, $pdfprnt_plugin_info['Version'] );
1119 -
1120 - if ( isset( $_GET['page'] ) && 'pdf-print.php' === $_GET['page'] ) {
1121 - wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style.css', __FILE__ ), false, $pdfprnt_plugin_info['Version'] );
1122 - bws_enqueue_settings_scripts();
1123 - bws_plugins_include_codemirror();
1124 - wp_enqueue_script( 'pdfprnt_script', plugins_url( 'js/script.js', __FILE__ ), array( 'jquery', 'jquery-ui-accordion', 'jquery-ui-slider' ), $pdfprnt_plugin_info['Version'], false );
1125 - wp_localize_script(
1126 - 'pdfprnt_script',
1127 - 'pdfprnt_var',
1128 - array(
1129 - 'loading_fonts' => esc_html__( 'Loading of fonts. It might take a several minutes.', 'pdf-print' ),
1130 - 'loading_mpdf' => esc_html__( 'Loading the mPDF library. It will take few minutes.', 'pdf-print' ),
1131 - 'ajax_nonce' => wp_create_nonce( 'pdfprnt_ajax_nonce' ),
1132 - 'need_reload' => '&nbsp;' . sprintf(
1133 - esc_html__( 'It is necessary to reload fonts. For more info, please see %s.', 'pdf-print' ),
1134 - '<a href="https://support.bestwebsoft.com/hc/en-us/articles/206693223" target="_blank">' . esc_html__( 'FAQ', 'pdf-print' ) . '</a>'
1135 - ),
1136 - )
1137 - );
1138 - }
1139 - if ( isset( $_GET['page'] ) && 'pdf-print-templates.php' === $_GET['page'] ) {
1140 - wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/templates.css', __FILE__ ), false, $pdfprnt_plugin_info['Version'] );
1141 - }
1142 - } elseif ( isset( $post->post_title ) ) {
1143 - wp_enqueue_style( 'pdfprnt_frontend', plugins_url( 'css/frontend.css', __FILE__ ), false, $pdfprnt_plugin_info['Version'] );
1144 - }
848 + if ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] )
849 + wp_enqueue_script( 'pdfprnt_script', plugins_url( 'js/script.js', __FILE__ ) );
1145 850 }
1146 851 }
1147 852
1148 -if ( ! function_exists( 'pdfprnt_add_script' ) ) {
1149 - /**
1150 - * Sending data for front js
1151 - */
1152 - function pdfprnt_add_script() {
1153 - global $pdfprnt_plugin_info , $post, $pdfprnt_options;
1154 - if ( 1 === intval( $pdfprnt_options['image_to_pdf'] ) ) {
1155 - $file_name = $post->post_title;
1156 - wp_enqueue_script( 'html2canvas.js', plugins_url( 'js/html2canvas.js', __FILE__ ), array(), $pdfprnt_plugin_info['Version'], false );
1157 - wp_enqueue_script( 'jspdf.js', plugins_url( 'js/jspdf.js', __FILE__ ), array(), $pdfprnt_plugin_info['Version'], false );
1158 - wp_enqueue_script( 'pdfprnt_front_script', plugins_url( 'js/front-script.js', __FILE__ ), array( 'jquery', 'html2canvas.js', 'jspdf.js' ), $pdfprnt_plugin_info['Version'] . '.7', false );
1159 - wp_localize_script(
1160 - 'pdfprnt_front_script',
1161 - 'pdfprnt_file_settings',
1162 - array(
1163 - 'margin_left' => $pdfprnt_options['pdf_margins']['left'],
1164 - 'margin_right' => $pdfprnt_options['pdf_margins']['right'],
1165 - 'margin_top' => $pdfprnt_options['pdf_margins']['top'],
1166 - 'margin_bottom' => $pdfprnt_options['pdf_margins']['bottom'],
1167 - 'page_size' => $pdfprnt_options['pdf_page_size'],
1168 - 'file_action' => $pdfprnt_options['file_action'],
1169 - 'file_name' => $file_name,
1170 - 'hide_classes' => implode( ', ', $pdfprnt_options['hide_classes'] ),
1171 - 'ajax_nonce' => wp_create_nonce( 'pdfprnt_ajax_nonce' ),
1172 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1173 - 'count_generation' => $pdfprnt_options['count_generation']
1174 - )
1175 - );
1176 - }
1177 - }
1178 -}
1179 -
1180 -if ( ! function_exists( 'pdfprnt_preg_replace' ) ) {
1181 - /**
1182 - * Remove inline 'font-family' and 'font' styles from content
1183 - *
1184 - * @param array $patterns Patterns array.
1185 - * @param string $content Post content.
1186 - * @return string $content
1187 - */
1188 - function pdfprnt_preg_replace( $patterns, $content ) {
1189 - foreach ( $patterns as $pattern ) {
1190 - $content = preg_replace( '/' . $pattern . '(.*?);/', '', $content );
1191 - preg_match_all( "~style=(\"\'?)~", $content, $quotes );/* get array with quotes */
1192 - if ( isset( $quotes[1] ) && ! empty( $quotes[1] ) ) {
1193 - foreach ( $quotes[1] as $quote ) {
1194 - preg_match_all( '~style=' . $quote . '(.*?)' . $quote . '~', $content, $styles );
1195 - if ( ! empty( $styles[1] ) ) {
1196 - foreach ( $styles[1] as $style ) {
1197 - if ( preg_match( '/' . $pattern . '/', $style ) ) {
1198 - $content = preg_replace( '/' . $style . '/', '', $content );
853 +/* Generate templates for pdf file or print */
854 +if ( ! function_exists( 'pdfprnt_generate_template' ) ) {
855 + function pdfprnt_generate_template( $content, $template = false, $isprint = false ) {
856 + global $pdfprnt_options_array;
857 + $tmpl = isset( $_GET['tmpl'] ) ? $_GET['tmpl'] : "";
858 + ob_start(); /* Starting output buffering */ ?>
859 + <html>
860 + <head>
861 + <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) : ?>
862 + <link type="text/css" rel="stylesheet" href="<?php echo get_bloginfo( 'stylesheet_url' ); ?>" media="all" />
863 + <?php else: ?>
864 + <link type="text/css" rel="stylesheet" href="<?php echo plugins_url( 'css/default.css', __FILE__ ); ?>" media="all" />
865 + <?php endif;
866 + if ( ! $template )
867 + $template = $pdfprnt_options_array['tmpl_post'];
868 + switch ( $template ) { /* Using template choosed on settings page */
869 + case 1: /* Allign left template */ ?>
870 + <style type="text/css">
871 + h1, h2, h3, h4, h5, h6 {
872 + text-align: left;
1199 873 }
1200 - }
1201 - }
874 + img {
875 + float: right;
876 + }
877 + </style>
878 + <?php break;
879 + case 2: /* Allign center template */ ?>
880 + <style type="text/css">
881 + h1, h2, h3, h4, h5, h6 {
882 + text-align: center;
883 + }
884 + img {
885 + float: left;
886 + }
887 + </style>
888 + <?php break;
889 + case 3: /* Allign right template */ ?>
890 + <style type="text/css">
891 + h1, h2, h3, h4, h5, h6 {
892 + text-align: right;
893 + }
894 + img {
895 + float: left;
896 + }
897 + </style>
898 + <?php break;
1202 899 }
1203 - }
1204 - }
1205 - return $content;
900 + switch ( $tmpl ) { /* If got something by GET (from admin bar) */
901 + case 1: /* Allign left template */ ?>
902 + <style type="text/css">
903 + h1, h2, h3, h4, h5, h6 {
904 + text-align: left;
905 + }
906 + img {
907 + float: right;
908 + }
909 + </style>
910 + <?php break;
911 + case 2: /* Allign center template */ ?>
912 + <style type="text/css">
913 + h1, h2, h3, h4, h5, h6 {
914 + text-align: center;
915 + }
916 + img {
917 + float: left;
918 + }
919 + </style>
920 + <?php break;
921 + case 3: /* Allign right template */ ?>
922 + <style type="text/css">
923 + h1, h2, h3, h4, h5, h6 {
924 + text-align: right;
925 + }
926 + img {
927 + float: left;
928 + }
929 + </style>
930 + <?php break;
931 + }
932 + if ( $isprint && 1 == $pdfprnt_options_array['show_print_window'] ) {
933 + echo '<script>window.onload = function(){ window.print(); };</script>';
934 + } ?>
935 + </head>
936 + <body>
937 + <?php echo $content; ?>
938 + </body>
939 + </html>
940 + <?php $html = ob_get_contents(); /* Getting output buffering */
941 + ob_end_clean(); /* Closing output buffering */
942 + return $html; /* Now we done with template */
1206 943 }
1207 944 }
1208 945
1209 -if ( ! function_exists( 'pdfprnt_generate_template' ) ) {
1210 - /**
1211 - * Generate templates for pdf file or print
1212 - *
1213 - * @param string $content Post content.
1214 - * @param bool $is_print (Optional) Flag for print version.
1215 - * @return string $html
1216 - */
1217 - function pdfprnt_generate_template( $content, $is_print = false ) {
1218 - global $pdfprnt_options, $wp_locale, $post;
1219 - $html =
1220 - '<html>
1221 - <head>';
1222 - $html .= apply_filters( 'pdfprnt_add_meta_tag_robots', $html );
1223 - if ( $is_print && $post instanceof WP_Post ) {
1224 - if ( is_archive() || is_category() || is_tax() || is_tag() || is_author() || ! pdfprnt_is_user_role_enabled() ) {
1225 - $title = ( function_exists( 'get_the_archive_title' ) ) ? get_the_archive_title() : wp_title( '', false );
1226 - } elseif ( is_search() ) {
1227 - $title = sprintf( esc_html__( 'Search Results for: %s', 'pdf-print' ), get_search_query() );
1228 - } else {
1229 - $title = get_the_title();
1230 - }
1231 - $html .= sprintf(
1232 - '<title>%s - %s</title>',
1233 - wp_strip_all_tags( $title ),
1234 - get_bloginfo( 'name' )
946 +if ( ! function_exists( 'pdfprnt_generate_template_for_bws_portfolio' ) ) {
947 + function pdfprnt_generate_template_for_bws_portfolio() {
948 + global $post;
949 + ob_start(); /* Starting output buffering */
950 + $portfolio_options = get_option( 'prtfl_options' );
951 + $meta_values = get_post_custom( $post->ID );
952 + $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
953 + if ( empty ( $post_thumbnail_id ) ) {
954 + $args = array(
955 + 'post_parent' => $post->ID,
956 + 'post_type' => 'attachment',
957 + 'post_mime_type' => 'image',
958 + 'numberposts' => 1
1235 959 );
960 + $attachments = get_children( $args );
961 + $post_thumbnail_id = key( $attachments );
1236 962 }
1237 - if ( ! empty( $pdfprnt_options['use_default_css'] ) && 1 === intval( $pdfprnt_options['use_default_css'] ) ) {
1238 - /* remove 'font-family' and 'font' styles from theme css-file if additional fonts not loaded */
1239 - if ( 0 === intval( $pdfprnt_options['additional_fonts'] ) ) {
1240 - $css = wp_remote_get( get_bloginfo( 'stylesheet_url' ) );
1241 - if ( is_array( $css ) && ! empty( $css['body'] ) ) {
1242 - $html .= '<style type="text/css">' . preg_replace( '/(font:(.*?);)|(font-family(.*?);)/', '', $css['body'] ) . '</style>';
1243 - }
1244 - } else {
1245 - $html .= '<link type="text/css" rel="stylesheet" href="' . get_bloginfo( 'stylesheet_url' ) . '" media="all" />';
963 + $image = wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
964 + $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
965 + $image_desc = get_post( $post_thumbnail_id );
966 + $image_desc = $image_desc->post_content;
967 + if ( '1' == get_option( 'prtfl_postmeta_update' ) ) {
968 + $post_meta = get_post_meta( $post->ID, 'prtfl_information', true );
969 + $date_compl = $post_meta['_prtfl_date_compl'];
970 + if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
971 + $date_compl = explode( '/', $date_compl );
972 + $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
1246 973 }
974 + $link = $post_meta['_prtfl_link'];
975 + $short_descr = $post_meta['_prtfl_short_descr'];
1247 976 } else {
1248 - $html .= '<link type="text/css" rel="stylesheet" href="' . plugins_url( 'css/default.css', __FILE__ ) . '" media="all" />';
1249 - }
1250 - $html .= pdfprnt_additional_styles( $is_print );
1251 - if ( 1 === intval( $pdfprnt_options['use_custom_css'] ) && ! empty( $pdfprnt_options['custom_css_code'] ) ) {
1252 - $html .= '<style type="text/css">' . $pdfprnt_options['custom_css_code'] . '</style>';
1253 - }
1254 - if ( $is_print && 1 === intval( $pdfprnt_options['show_print_window'] ) ) {
1255 - $html .= '<script>window.onload = function(){ window.print(); };</script>';
1256 - }
1257 - if ( ! empty( $pdfprnt_options['hide_classes'] ) ) {
1258 - $html .= '<style>' . implode( ',', $pdfprnt_options['hide_classes'] ) . '{ display: none; }</style>';
1259 - }
1260 - $html .= apply_filters( 'pdfprnt_woocommerce_layout', $html, $is_print );
1261 - $html .=
1262 - '</head>
1263 - <body class="' . ( $is_print ? 'pdfprnt_print ' : '' ) . $wp_locale->text_direction . '">';
1264 - /* Remove inline 'font-family' and 'font' styles from content */
1265 - if ( 0 === intval( $pdfprnt_options['additional_fonts'] ) ) {
1266 - $content = pdfprnt_preg_replace( array( 'font-family', 'font:' ), $content );
1267 - }
1268 - if ( function_exists( 'has_blocks' ) && has_blocks( $content ) ) {
1269 - $content = preg_replace( '/\s?<!--.*-->\s?/', '', $content );
1270 - $content = preg_replace( '~<p></p>~', '', $content );
1271 - }
1272 - $html .= $content .
1273 - '</body>
1274 - </html>';
1275 - return $html;
977 + $date_compl = get_post_meta( $post->ID, '_prtfl_date_compl', true );
978 + if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
979 + $date_compl = explode( '/', $date_compl );
980 + $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
981 + }
982 + $link = get_post_meta( $post->ID, '_prtfl_link', true);
983 + $short_descr = $post_meta['_prtfl_short_descr'];
984 + } ?>
985 + <img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" alt="<?php echo $image_alt; ?>" />
986 + <div>
987 + <p>
988 + <strong><?php _e( 'Date of completion', 'pdf-print' ); ?>:</strong> <?php echo $date_compl; ?><br/>
989 + <strong><?php _e( 'Link', 'pdf-print' ); ?>:</strong> <a href="<?php echo $link; ?>"><?php echo $link; ?></a><br/>
990 + <strong><?php _e( 'Description', 'pdf-print' ); ?>:</strong> <?php echo $short_descr; ?><br/>
991 + </p>
992 + </div>
993 + <?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' );
994 + if ( is_array( $terms ) && count( $terms ) > 0 ) { ?>
995 + <div style="clear:both;">
996 + <strong><?php _e( 'Technologies', 'pdf-print' ); ?>: </strong>
997 + <?php $count = 0;
998 + foreach ( $terms as $term ) {
999 + if( 0 < $count )
1000 + echo ', ';
1001 + echo '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>';
1002 + $count++;
1003 + } ?>
1004 + </div>
1005 + <?php }
1006 + $content = ob_get_contents(); /* Getting output buffering */
1007 + ob_end_clean(); /* Closing output buffering */
1008 + return $content; /* Now we done with template */
1276 1009 }
1277 1010 }
1278 1011
1279 -if ( ! function_exists( 'pdfprnt_additional_styles' ) ) {
1280 - /**
1281 - * Additinal styles for plugin
1282 - *
1283 - * @param bool $is_print Flag for print version.
1284 - * @return string $html
1285 - */
1286 - function pdfprnt_additional_styles( $is_print ) {
1287 - $styles = apply_filters( 'bwsplgns_add_pdf_print_styles', array() );
1288 - $html = '';
1289 - if ( ! empty( $styles ) && is_array( $styles ) ) {
1290 - $url = get_bloginfo( 'url' );
1291 - require_once ABSPATH . 'wp-admin/includes/file.php';
1292 - $path = get_home_path();
1293 - foreach ( $styles as $style ) {
1294 - if ( ! empty( $style[0] ) && file_exists( $path . $style[0] ) ) {
1295 - /* if "get print" */
1296 - if ( $is_print ) {
1297 - if ( ( isset( $style[1] ) && 'print' === $style[1] ) || ! isset( $style[1] ) ) {
1298 - $html .= '<link type="text/css" rel="stylesheet" href="' . $url . '/' . $style[0] . '" media="all" />';
1299 - }
1300 - /* if "get pdf" */
1301 - } else {
1302 - if ( ( isset( $style[1] ) && 'pdf' === $style[1] ) || ! isset( $style[1] ) ) {
1303 - $html .= '<link type="text/css" rel="stylesheet" href="' . $url . '/' . $style[0] . '" media="all" />';
1304 - }
1305 - }
1306 - }
1307 - }
1012 +/* Generate query posts for Portfolio plugin */
1013 +if ( ! function_exists( 'generate_query_posts_for_portfolio' ) ) {
1014 + function generate_query_posts_for_portfolio() {
1015 + global $wp_query;
1016 + $paged = isset( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1;
1017 + $technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : "";
1018 + if ( "" != $technologies ) {
1019 + $args = array(
1020 + 'post_type' => 'portfolio',
1021 + 'post_status' => 'publish',
1022 + 'posts_per_page' => get_option('posts_per_page'),
1023 + 'paged' => $paged,
1024 + 'tax_query' => array(
1025 + array(
1026 + 'taxonomy' => 'portfolio_technologies',
1027 + 'field' => 'slug',
1028 + 'terms' => $technologies
1029 + )
1030 + )
1031 + );
1032 + } else {
1033 + $args = array(
1034 + 'post_type' => 'portfolio',
1035 + 'post_status' => 'publish',
1036 + 'posts_per_page' => get_option('posts_per_page'),
1037 + 'paged' => $paged
1038 + );
1308 1039 }
1309 - return $html;
1040 + query_posts( $args );
1310 1041 }
1311 1042 }
1312 1043
1044 +/* Output print page or pdf document and include plugin script */
1313 1045 if ( ! function_exists( 'pdfprnt_print' ) ) {
1314 - /**
1315 - * Output print page or pdf document and include plugin script
1316 - *
1317 - * @param string $query Query for post.
1318 - */
1319 1046 function pdfprnt_print( $query ) {
1320 - global $pdfprnt_options, $posts, $post, $pdfprnt_is_old_php, $pdfprnt_links;
1321 - $print = get_query_var( 'print' );
1322 -
1323 - if ( $pdfprnt_is_old_php || empty( $print ) || ! pdfprnt_is_user_role_enabled() || post_password_required() ) {
1324 - return;
1325 - }
1326 -
1327 - if ( apply_filters( 'bwsplgns_remove_content_filters', true ) ) {
1047 + global $pdfprnt_options_array, $posts, $post;
1048 + if ( $print = get_query_var( 'print' ) ) {
1328 1049 remove_all_filters( 'the_content' );
1329 1050 add_filter( 'the_content', 'capital_P_dangit', 11 );
1330 1051 add_filter( 'the_content', 'wptexturize' );
1331 1052 add_filter( 'the_content', 'convert_smilies' );
@@ -1330,830 +1051,383 @@
1330 1051 add_filter( 'the_content', 'wptexturize' );
1331 1052 add_filter( 'the_content', 'convert_smilies' );
1332 1053 add_filter( 'the_content', 'convert_chars' );
1333 1054 add_filter( 'the_content', 'wpautop' );
1334 -
1335 - if ( ! class_exists( 'WP_Embed' ) ) {
1336 - require_once ABSPATH . WPINC . '/class-wp-embed.php';
1055 + if ( 1 == $pdfprnt_options_array['tmpl_shorcode'] ) {
1056 + add_filter( 'the_content', 'do_shortcode' ); /* executing shorcodes on the page */
1057 + } else {
1058 + $pattern = get_shortcode_regex();
1059 + if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) ) { /* getting all shortcodes we are using */
1060 + foreach ( array_unique( $matches[0] ) as $value) {
1061 + $post->post_content = str_replace( $value, "", $post->post_content ); /* replacing shorcodes to an empty string */
1062 + }
1063 + }
1337 1064 }
1338 - new WP_Embed();
1339 - }
1340 - do_action( 'bwsplgns_pdf_print_the_content' );
1341 - if ( 1 === intval( $pdfprnt_options['do_shorcodes'] ) ) {
1342 - add_filter( 'the_content', 'do_shortcode' );
1343 - $pattern = false;
1344 - } else {
1345 - $pattern = get_shortcode_regex();
1346 - }
1347 -
1348 - $doc_type = explode( '-', $print );
1349 -
1350 - if ( ! is_array( $doc_type ) ) {
1351 - return;
1352 - }
1353 -
1354 - /* for search or archives */
1355 - if ( isset( $doc_type[1] ) ) {
1356 - switch ( $doc_type[1] ) {
1357 - case 'custom':
1358 - $url_data = isset( $_SERVER['REQUEST_URI'] ) ? wp_parse_url( sanitize_text_field( wp_unslash( urldecode( $_SERVER['REQUEST_URI'] ) ) ) ) : array();
1359 - parse_str( $url_data['query'], $args );
1360 - unset( $args['print'] );
1361 - if ( ! empty( $args ) ) {
1362 - $posts = query_posts( $args );
1065 + switch ( $print ) {
1066 + case 'pdf': /* Content for PDF from post */
1067 + include ( 'mpdf/mpdf.php' );
1068 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1069 + $mpdf = new mPDF('+aCJK');
1070 + $user_info = get_userdata( $post->post_author );
1071 + $mpdf->SetAutoFont(AUTOFONT_ALL);
1072 + $mpdf->SetAuthor( $user_info->display_name );
1073 + $mpdf->SetTitle( $post->post_title );
1074 + $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1075 + $html = '<div class="container">
1076 + <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
1077 + <div class="content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
1078 + </div>';
1079 + $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
1080 + $mpdf->Output();
1081 + unset( $user_info );
1082 + unset( $html );
1083 + unset( $mpdf );
1084 + die();
1085 + break;
1086 + case 'print': /* Content for printing from post */
1087 + $html = '<div class="container">
1088 + <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1089 + <div class="content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
1090 + </div>';
1091 + echo pdfprnt_generate_template( $html, false, true );
1092 + unset( $html );
1093 + die();
1094 + break;
1095 + case 'pdf-page': /* Content for PDF from archive or searching page */
1096 + $html = '';
1097 + $titles = array();
1098 + $authors = array();
1099 + include ( 'mpdf/mpdf.php' );
1100 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1101 + $mpdf = new mPDF('+aCJK');
1102 + foreach ( $posts as $p ) {
1103 + if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1104 + continue;
1105 + $titles[] = $p->post_title;
1106 + $user_info = get_userdata( $p->post_author );
1107 + $authors[] = $user_info->display_name;
1108 + $html .= '<div class="container">
1109 + <div class="title"><h1><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>
1110 + <div class="content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
1111 + </div><br/><hr/><br/>';
1112 + unset( $user_info );
1363 1113 }
1114 + $titles = array_unique( $titles );
1115 + $authors = array_unique( $authors );
1116 + $mpdf->SetAutoFont(AUTOFONT_ALL);
1117 + $mpdf->SetTitle( implode( ',', $titles ) );
1118 + $mpdf->SetAuthor( implode( ',', $authors ) );
1119 + $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1120 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_search'] ) );
1121 + $mpdf->Output();
1122 + unset( $authors );
1123 + unset( $titles );
1124 + unset( $html );
1125 + unset( $mpdf );
1126 + die();
1364 1127 break;
1365 - case 'search':
1366 - do_action( 'pdfprnt_rewrite_posts_woocommerce' );
1128 + case 'print-page': /* Content for printing from archive or searching page */
1129 + $html = '';
1130 + foreach ( $posts as $p ) {
1131 + if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1132 + continue;
1133 + $html .= '<div class="container">
1134 + <div class="title"><h1>' . $p->post_title . '</h1></div><br/>
1135 + <div class="content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
1136 + </div><br/><hr/><br/>';
1137 + }
1138 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_search'], true );
1139 + unset( $html );
1140 + die();
1367 1141 break;
1368 - default:
1142 + case 'pdf-portfolio': /* Content for PDF from portfolio post */
1143 + include ( 'mpdf/mpdf.php' );
1144 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1145 + $mpdf = new mPDF( '+aCJK' );
1146 + $user_info = get_userdata( $post->post_author );
1147 + $mpdf->SetAutoFont( AUTOFONT_ALL );
1148 + $mpdf->SetAuthor( $user_info->display_name );
1149 + $mpdf->SetTitle( $post->post_title );
1150 + $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1151 + $html = '<div class="container">
1152 + <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
1153 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1154 + </div>';
1155 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
1156 + $mpdf->Output();
1157 + unset( $html );
1158 + unset( $user_info );
1159 + unset( $mpdf );
1160 + die();
1369 1161 break;
1370 - }
1371 - /* for single posts or pages */
1372 - } elseif (
1373 - ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( urldecode( $_SERVER['REQUEST_URI'] ) ) ) === get_home_url() . '/?print=' . $doc_type[0]
1374 - &&
1375 - 'page' === get_option( 'show_on_front' )
1376 - ) {
1377 - $post_id = get_option( 'page_on_front' );
1378 - $posts = query_posts( array( 'page_id' => $post_id ) );
1379 - } else {
1380 - if ( ! is_home() ) {
1381 - $posts = array( $post );
1382 - $count_generation = get_post_meta( $post->ID, 'pdfprnt_count_generation', true );
1383 - update_post_meta( $post->ID, 'pdfprnt_count_generation', (int) ++$count_generation );
1384 - }
1385 - }
1386 -
1387 - switch ( $doc_type[0] ) {
1388 - case 'pdf':
1389 - /* set path to directory with fonts */
1390 - if ( ! ( 0 === intval( $pdfprnt_options['additional_fonts'] ) && defined( '_MPDF_SYSTEM_TTFONTS' ) ) ) {
1391 - if ( is_multisite() ) {
1392 - switch_to_blog( 1 );
1393 - $upload_dir = wp_upload_dir();
1394 - restore_current_blog();
1395 - } else {
1396 - $upload_dir = wp_upload_dir();
1162 + case 'print-portfolio': /* Content for printing from porfolio post */
1163 + $html = '<div class="container">
1164 + <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1165 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1166 + </div>';
1167 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1168 + unset( $html );
1169 + die();
1170 + break;
1171 + case 'pdf-portfolio-page': /* Content for PDF from portfolio page */
1172 + $html = '';
1173 + $titles = array();
1174 + $authors = array();
1175 + generate_query_posts_for_portfolio();
1176 + while ( have_posts() ) {
1177 + the_post();
1178 + global $post;
1179 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
1180 + continue;
1181 + $titles[] = $post->post_title;
1182 + $user_info = get_userdata( $post->post_author );
1183 + $authors[] = $user_info->display_name;
1184 + $html .= '<div class="container">
1185 + <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
1186 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1187 + </div><br/><hr/><br/>';
1188 + unset( $user_info );
1397 1189 }
1398 - @define( '_MPDF_SYSTEM_TTFONTS', $upload_dir['basedir'] . '/pdf-print-fonts/' );
1399 - }
1400 -
1401 - /* prepare data */
1402 - $titles = array();
1403 - $authors = array();
1404 - $default_font = 0 === intval( $pdfprnt_options['additional_fonts'] ) ? 'dejavusansmono' : '';
1405 - $last = count( $posts );
1406 - $i = 1;
1407 - $html = '<div id="content">';
1408 - foreach ( $posts as $p ) {
1409 - if ( function_exists( 'et_theme_builder_get_template_layouts' ) && function_exists( 'et_theme_builder_frontend_render_header' ) ) {
1410 - $layouts = et_theme_builder_get_template_layouts();
1411 - ob_start();
1412 - et_theme_builder_frontend_render_header(
1413 - $layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['id'],
1414 - $layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['enabled'],
1415 - $layouts[ ET_THEME_BUILDER_TEMPLATE_POST_TYPE ]
1416 - );
1417 - $html .= ob_get_clean();
1190 + include ( 'mpdf/mpdf.php' );
1191 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1192 + $mpdf = new mPDF( '+aCJK' );
1193 + $titles = array_unique( $titles );
1194 + $authors = array_unique( $authors );
1195 + $mpdf->SetAutoFont( AUTOFONT_ALL );
1196 + $mpdf->SetTitle( implode( ',', $titles ) );
1197 + $mpdf->SetAuthor( implode( ',', $authors ) );
1198 + $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1199 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
1200 + $mpdf->Output();
1201 + unset( $authors );
1202 + unset( $titles );
1203 + unset( $html );
1204 + unset( $mpdf );
1205 + die();
1206 + break;
1207 + case 'print-portfolio-page': /* Content for printing from portfolio page */
1208 + generate_query_posts_for_portfolio();
1209 + $html = '';
1210 + while ( have_posts() ) {
1211 + the_post();
1212 + global $post;
1213 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
1214 + continue;
1215 + $html .= '<div class="container">
1216 + <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1217 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1218 + </div><br/><hr/><br/>';
1418 1219 }
1419 - $title_filter = apply_filters( 'bwsplgns_get_pdf_print_title', apply_filters( 'the_title', $p->post_title, $p->ID ), $p );
1420 - $titles[] = $title_filter;
1421 - $user_info = get_userdata( $p->post_author );
1422 - $authors[] = $user_info->display_name;
1423 - $title = 1 === intval( $pdfprnt_options['show_title'] ) ? '<div class="entry-header"><h1 class="entry-title"><a href="' . get_permalink( $p ) . '">' . $title_filter . '</a></h1></div>' : '';
1424 - $image = 1 === intval( $pdfprnt_options['show_featured_image'] ) && has_post_thumbnail( $p->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $p->ID, $pdfprnt_options['featured_image_size'] ) . '</div>' : '';
1425 - $date = 1 === intval( $pdfprnt_options['show_date'] ) ? '<span class="entry-date">' . get_the_date( get_option( 'date_format' ) ) . '</span>' : '';
1426 - $author = 1 === intval( $pdfprnt_options['show_author'] ) ? '<span class="entry-author">' . esc_html__( 'written by', 'pdf-print' ) . ' ' . get_the_author_meta( 'display_name', $p->post_author ) . '</span>' : '';
1427 - $category = 1 === intval( $pdfprnt_options['show_category'] ) && has_category( '', $p->ID ) ? '<div class="entry-category">' . __( 'Category', 'pdf-print-pro' ) . ': ' . implode( ',', wp_get_post_categories( $p->ID, array( 'fields' => 'names' ) ) ) . '</div>' : '';
1428 - /* replacing shortcodes to an empty string which were added to the content */
1429 - if ( $pattern && preg_match_all( '/' . $pattern . '/s', $p->post_content, $matches ) ) {
1430 - foreach ( array_unique( $matches[0] ) as $value ) {
1431 - $p->post_content = str_replace( $value, '', $p->post_content );
1432 - }
1220 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1221 + unset( $html );
1222 + die();
1223 + break;
1224 + case 'pdf-custom-page': /* Content for PDF from custom post */
1225 + $html = '';
1226 + $titles = $authors = array();
1227 + foreach ( $posts as $p ) {
1228 + if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1229 + continue;
1230 + $titles[] = $p->post_title;
1231 + $user_info = get_userdata( $p->post_author );
1232 + $authors[] = $user_info->display_name;
1233 + $html .= '<div class="container">';
1234 + $html .= '<div class="title"><h1><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>';
1235 + $html .= '<div class="content">';
1236 + if ( has_post_thumbnail( $p->ID ) )
1237 + $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );
1238 + $html .= apply_filters( 'the_content', $p->post_content ) . '</div></div><br/><hr/><br/>';
1239 + unset( $user_info );
1433 1240 }
1434 - if ( 1 === intval( $pdfprnt_options['remove_links'] ) ) {
1435 - $p->post_content = preg_replace( '~<a\b[^>]*+>|</a\b[^>]*+>~', '$2', $p->post_content );
1436 - $p->post_content = preg_replace( '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@', '', $p->post_content );
1437 - }
1438 - if ( 1 === intval( $pdfprnt_options['disable_links'] ) ) {
1439 - $html .= '<style> a {text-decoration: none; color:#000000 !important; } </style>';
1440 - }
1441 -
1442 - $post_visible = ( ! empty( $p->post_excerpt ) && ! is_singular() ) ? $p->post_excerpt : $p->post_content;
1443 - $post_content = apply_filters( 'bwsplgns_get_pdf_print_content', $post_visible, $p );
1444 - $shortcodes = implode( '|', apply_filters( 'bwsplgns_pdf_print_remove_shortcodes', array( 'vc_', 'az_', 'multilanguage_switcher' ) ) );
1445 - $post_content = preg_replace( "/\[\/?({$shortcodes})[^\]]*?\]/", '', $post_content );
1446 - $post_content = apply_filters( 'the_content', $post_content );
1447 - $post_content = apply_filters( 'bwsplgns_pdf_customize_content', $post_content );
1448 - $post_content = apply_filters( 'bwsplgns_pdf_replace_content', $post_content );
1449 - $separator = '';
1450 - if ( ! empty( $author ) && ! empty( $date ) ) {
1451 - $separator = ' | ';
1452 - }
1453 - $html .=
1454 - '<div class="post">' .
1455 - $title .
1456 - $category .
1457 - '<div class="postmetadata">' . $author . $separator . $date . '</div>' .
1458 - $image .
1459 - '<div class="entry-content">' . $post_content . '</div>
1460 - </div>';
1461 - if ( $i !== $last ) {
1462 - $html .= '<br/><hr/><br/>';
1463 - $i ++;
1464 - }
1465 - }
1466 - if ( function_exists( 'et_theme_builder_get_template_layouts' ) && function_exists( 'et_theme_builder_frontend_render_footer' ) ) {
1467 - ob_start();
1468 - et_theme_builder_frontend_render_footer(
1469 - $layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['id'],
1470 - $layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['enabled'],
1471 - $layouts[ ET_THEME_BUILDER_TEMPLATE_POST_TYPE ]
1472 - );
1473 - $html .= ob_get_clean();
1474 - }
1475 - $html .= '</div>';
1476 - $titles = array_unique( $titles );
1477 - $authors = array_unique( $authors );
1478 -
1479 - $pdfprnt_links = $pdfprnt_options['disable_links'];
1480 -
1481 - /* generate PDF-document */
1482 - $path = $upload_dir['basedir'] . '/vendor/mpdf';
1483 - $is_installed = file_exists( $path );
1484 - if ( $is_installed ) {
1485 - /* Implement mPDF v7.1.5 */
1486 - if ( ! class_exists( '\Mpdf\Mpdf' ) ) {
1487 - include $upload_dir['basedir'] . '/vendor/autoload.php';
1488 - }
1489 - $mpdf_config = array(
1490 - 'mode' => '+aCJK',
1491 - 'format' => $pdfprnt_options['pdf_page_size'],
1492 - 'default_font_size' => 0,
1493 - 'default_font' => $default_font,
1494 - 'margin_left' => $pdfprnt_options['pdf_margins']['left'],
1495 - 'margin_right' => $pdfprnt_options['pdf_margins']['right'],
1496 - 'margin_top' => $pdfprnt_options['pdf_margins']['top'],
1497 - 'margin_bottom' => $pdfprnt_options['pdf_margins']['bottom'],
1498 - );
1499 - $mpdf = new \Mpdf\Mpdf( $mpdf_config );
1500 -
1501 - } else {
1502 - include dirname( __FILE__ ) . '/mpdf/mpdf.php';
1503 - $mpdf = new mPDF(
1504 - '+aCJK',
1505 - $pdfprnt_options['pdf_page_size'],
1506 - 0,
1507 - $default_font,
1508 - $pdfprnt_options['pdf_margins']['left'],
1509 - $pdfprnt_options['pdf_margins']['right'],
1510 - $pdfprnt_options['pdf_margins']['top'],
1511 - $pdfprnt_options['pdf_margins']['bottom']
1512 - );
1513 - }
1514 - $mpdf->allow_charset_conversion = true;
1515 - $mpdf->charset_in = get_bloginfo( 'charset' );
1516 - if ( 0 !== intval( $pdfprnt_options['additional_fonts'] ) ) {
1517 - $mpdf->autoScriptToLang = true;
1518 - $mpdf->autoLangToFont = true;
1519 - $mpdf->baseScript = 1;
1520 - $mpdf->autoVietnamese = true;
1521 - $mpdf->autoArabic = true;
1522 - }
1523 - if ( is_rtl() ) {
1524 - $mpdf->SetDirectionality( 'rtl' );
1525 - }
1526 - $mpdf->SetTitle( htmlspecialchars_decode( implode( ',', $titles ) ) );
1527 - $mpdf->SetAuthor( implode( ',', $authors ) );
1528 - $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1529 - $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
1530 - do_action_ref_array( 'bwsplgns_mpdf', array( &$mpdf ) );
1531 - if ( 'download' === $pdfprnt_options['file_action'] ) {
1532 - $mpdf->Output( '', 'D' );
1533 - } else {
1241 + include ( 'mpdf/mpdf.php' );
1242 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1243 + $mpdf = new mPDF( '+aCJK' );
1244 + $titles = array_unique( $titles );
1245 + $authors = array_unique( $authors );
1246 + $mpdf->SetAutoFont( AUTOFONT_ALL );
1247 + $mpdf->SetTitle( implode( ',', $titles ) );
1248 + $mpdf->SetAuthor( implode( ',', $authors ) );
1249 + $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1250 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
1534 1251 $mpdf->Output();
1535 - }
1536 - die();
1537 - break;
1538 - case 'print':
1539 - $last = count( $posts );
1540 - $i = 1;
1541 - $html = '<div id="content">';
1542 - foreach ( $posts as $p ) {
1543 - if ( function_exists( 'et_theme_builder_get_template_layouts' ) && function_exists( 'et_theme_builder_frontend_render_header' ) ) {
1544 - $layouts = et_theme_builder_get_template_layouts();
1545 - ob_start();
1546 - et_theme_builder_frontend_render_header(
1547 - $layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['id'],
1548 - $layouts[ ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE ]['enabled'],
1549 - $layouts[ ET_THEME_BUILDER_TEMPLATE_POST_TYPE ]
1550 - );
1551 - $html .= ob_get_clean();
1252 + unset( $authors );
1253 + unset( $titles );
1254 + unset( $html );
1255 + unset( $mpdf );
1256 + die();
1257 + break;
1258 + case 'print-custom-page': /* Content for printing from custom post */
1259 + $html = '';
1260 + foreach ( $posts as $p ) {
1261 + if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1262 + continue;
1263 + $html .= '<div class="container">';
1264 + $html .= '<div class="title"><h1>' . $p->post_title . '</h1></div><br/>';
1265 + $html .= '<div class="content">';
1266 + if ( has_post_thumbnail( $p->ID ) )
1267 + $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );
1268 + $html .= apply_filters( 'the_content', $p->post_content ) . '</div>
1269 + </div><br/><hr/><br/>';
1552 1270 }
1553 -
1554 - $title = 1 === intval( $pdfprnt_options['show_title'] ) ? '<div class="entry-header"><h1 class="entry-title">' . apply_filters( 'bwsplgns_get_pdf_print_title', apply_filters( 'the_title', $p->post_title, $p->ID ), $p ) . '</h1></div>' : '';
1555 - $image = 1 === intval( $pdfprnt_options['show_featured_image'] ) && has_post_thumbnail( $p->ID ) ? '<div class="entry-thumbnail">' . get_the_post_thumbnail( $p->ID, $pdfprnt_options['featured_image_size'] ) . '</div>' : '';
1556 - $date = 1 === intval( $pdfprnt_options['show_date'] ) ? '<span class="entry-date">' . get_the_date( get_option( 'date_format' ) ) . '</span>' : '';
1557 - $author = 1 === intval( $pdfprnt_options['show_author'] ) ? '<span class="entry-author">' . esc_html__( 'written by', 'pdf-print' ) . ' ' . get_the_author_meta( 'display_name', $p->post_author ) . '</span>' : '';
1558 - $category = 1 === intval( $pdfprnt_options['show_category'] ) && has_category( '', $p->ID ) ? '<div class="entry-category">' . __( 'Category', 'pdf-print-pro' ) . ': ' . implode( ',', wp_get_post_categories( $p->ID, array( 'fields' => 'names' ) ) ) . '</div>' : '';
1559 - /* replacing shortcodes to an empty string which were added to the content */
1560 - if ( $pattern && preg_match_all( '/' . $pattern . '/s', $p->post_content, $matches ) ) {
1561 - foreach ( array_unique( $matches[0] ) as $value ) {
1562 - $p->post_content = str_replace( $value, '', $p->post_content );
1563 - }
1564 - }
1565 - if ( 1 === intval( $pdfprnt_options['remove_links'] ) ) {
1566 - $p->post_content = preg_replace( '~<a\b[^>]*+>|</a\b[^>]*+>~', '$2', $p->post_content );
1567 - $p->post_content = preg_replace( '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@', '', $p->post_content );
1568 - }
1569 - if ( 1 === intval( $pdfprnt_options['disable_links'] ) ) {
1570 - $html .= '<style> a {text-decoration: none; color:#000000 !important; } </style>';
1571 - }
1572 -
1573 - $post_content = apply_filters( 'bwsplgns_get_pdf_print_content', $p->post_content, $p );
1574 - $shortcodes = implode( '|', apply_filters( 'bwsplgns_pdf_print_remove_shortcodes', array( 'vc_', 'az_', 'multilanguage_switcher' ) ) );
1575 - $post_content = preg_replace( "/\[\/?({$shortcodes})[^\]]*?\]/", '', $post_content );
1576 - $post_content = apply_filters( 'the_content', $post_content );
1577 - $separator = '';
1578 -
1579 - if ( ! empty( $author ) && ! empty( $date ) ) {
1580 - $separator = ' | ';
1581 - }
1582 -
1583 - ob_start();
1584 - ?>
1585 - <div class="post">
1586 - <?php
1587 - echo wp_kses_post( $title ) .
1588 - wp_kses_post( $category ) .
1589 - '<div class="postmetadata">' . wp_kses_post( $author . $separator . $date ) . '</div>' .
1590 - wp_kses_post( $image );
1591 - ?>
1592 - <div class="entry-content"><?php echo $post_content; ?></div>
1593 - </div>
1594 - <?php
1595 - $html .= ob_get_clean();
1596 - if ( $i !== $last ) {
1597 - $html .= '<br/><hr/><br/>';
1598 - $i ++;
1599 - }
1600 - }
1601 - if ( function_exists( 'et_theme_builder_get_template_layouts' ) && function_exists( 'et_theme_builder_frontend_render_footer' ) ) {
1602 - ob_start();
1603 - et_theme_builder_frontend_render_footer(
1604 - $layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['id'],
1605 - $layouts[ ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE ]['enabled'],
1606 - $layouts[ ET_THEME_BUILDER_TEMPLATE_POST_TYPE ]
1607 - );
1608 - $html .= ob_get_clean();
1609 - }
1610 - $html .= '</div>';
1611 - echo pdfprnt_generate_template( $html, true );
1612 - die();
1613 - default:
1614 - break;
1271 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1272 + unset( $html );
1273 + die();
1274 + break;
1275 + }
1615 1276 }
1616 1277 }
1617 1278 }
1618 1279
1619 -if ( ! function_exists( 'pdfprnt_print_vars_callback' ) ) {
1620 - /**
1621 - * Add query vars
1622 - *
1623 - * @param array $query_vars Query vars array.
1624 - */
1625 - function pdfprnt_print_vars_callback( $query_vars ) {
1626 - $query_vars[] = 'print';
1280 +/* Add query vars */
1281 +if ( ! function_exists( 'print_vars_callback' ) ) {
1282 + function print_vars_callback( $query_vars ) {
1283 + $query_vars[] = 'print';
1284 + $query_vars[] = 'tmpl';
1627 1285 return $query_vars;
1628 1286 }
1629 1287 }
1630 1288
1631 -if ( class_exists( 'ZipArchive' ) && ! class_exists( 'Pdfprnt_ZipArchive' ) ) {
1632 - /**
1633 - * Class Pdfprnt_ZipArchive for extracting
1634 - * necessary folder from zip-archive
1635 - */
1636 - class Pdfprnt_ZipArchive extends ZipArchive {
1637 - /**
1638 - * Constructor of class
1639 - *
1640 - * @param string $destination Directory for zip.
1641 - * @param string $subdir Subdirectory for zip.
1642 - */
1643 - public function extractSubdirTo( $destination, $subdir ) {
1644 - $errors = array();
1645 - $charset = get_bloginfo( 'charset' );
1646 - /* Prepare dirs */
1647 - $destination = str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $destination );
1648 - $subdir = str_replace( array( '/', '\\' ), '/', $subdir );
1649 -
1650 - if ( substr( $destination, mb_strlen( DIRECTORY_SEPARATOR, $charset ) * -1 ) !== DIRECTORY_SEPARATOR ) {
1651 - $destination .= DIRECTORY_SEPARATOR;
1289 +/* Add custom admin bar menu */
1290 +if ( ! function_exists( 'pdfprnt_admin_bar_menu' ) ) {
1291 + function pdfprnt_admin_bar_menu() {
1292 + global $pdfprnt_options_array, $wp_admin_bar, $wp, $posts;
1293 + if ( ! is_super_admin() || ! is_admin_bar_showing() || is_admin() ) /* Checking user */
1294 + return;
1295 + if ( ( ! is_search() && ! is_archive() ) || ( is_category() || ! have_posts() ) )
1296 + return;
1297 + $is_return = true;
1298 + foreach ( $posts as $post ) {
1299 + if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
1300 + $is_return = false;
1301 + break;
1652 1302 }
1653 -
1654 - if ( substr( $subdir, -1 ) !== '/' ) {
1655 - $subdir .= '/';
1656 - }
1657 - /* Extract files */
1658 - for ( $i = 0; $i < $this->numFiles; $i++ ) {
1659 - $filename = $this->getNameIndex( $i );
1660 -
1661 - if ( substr( $filename, 0, mb_strlen( $subdir, $charset ) ) === $subdir ) {
1662 - $relative_path = substr( $filename, mb_strlen( $subdir, $charset ) );
1663 - $relative_path = str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $relative_path );
1664 -
1665 - if ( mb_strlen( $relative_path, $charset ) > 0 ) {
1666 - if ( substr( $filename, -1 ) === '/' ) {
1667 - if ( ! is_dir( $destination . $relative_path ) ) {
1668 - if ( ! @mkdir( $destination . $relative_path, 0755, true ) ) {
1669 - $errors[ $i ] = $filename;
1670 - }
1671 - }
1672 - } else {
1673 - if ( dirname( $relative_path ) !== '.' ) {
1674 - if ( ! is_dir( $destination . dirname( $relative_path ) ) ) {
1675 - /* New dir (for file) */
1676 - @mkdir( $destination . dirname( $relative_path ), 0755, true );
1677 - }
1678 - }
1679 - /* New file */
1680 - if ( @file_put_contents( $destination . $relative_path, $this->getFromIndex( $i ) ) === false ) {
1681 - $errors[ $i ] = $filename;
1682 - }
1683 - }
1684 - }
1685 - }
1686 - }
1687 - return $errors;
1688 1303 }
1304 + if ( $is_return )
1305 + return;
1306 + if ( empty( $wp->request ) )
1307 + $current_url = add_query_arg( $wp->query_string, '', home_url() );
1308 + else
1309 + $current_url = home_url( $wp->request );
1310 + $permalink = add_query_arg( 'print', 'pdf-page', $current_url );
1311 + $wp_admin_bar->add_menu( array(
1312 + 'id' => 'pdfprnt-bar-menu',
1313 + 'title' => '<span class="admin-bar-menu-bws-icon"></span>PDF',
1314 + 'href' => $permalink
1315 + ) );
1316 + $template_url = add_query_arg( 'tmpl', '1', $permalink ); /* Adding parametrs to link */
1317 + $wp_admin_bar->add_menu( array(
1318 + 'parent' => 'pdfprnt-bar-menu',
1319 + 'id' => 'pdfprnt-template-1',
1320 + 'title' => '<img src="' . plugins_url( 'images/template_left.jpg', __FILE__ ) . '" alt="template_left" />',
1321 + 'href' => $template_url
1322 + ) );
1323 + $template_url = add_query_arg( 'tmpl', '2', $permalink ); /* Adding parametrs to link */
1324 + $wp_admin_bar->add_menu( array(
1325 + 'parent' => 'pdfprnt-bar-menu',
1326 + 'id' => 'pdfprnt-template-2',
1327 + 'title' => '<img src="' . plugins_url( 'images/template_center.jpg', __FILE__ ) . '" alt="template_center" />',
1328 + 'href' => $template_url
1329 + ) );
1330 + $template_url = add_query_arg( 'tmpl', '3', $permalink ); /* Adding parametrs to link */
1331 + $wp_admin_bar->add_menu( array(
1332 + 'parent' => 'pdfprnt-bar-menu',
1333 + 'id' => 'pdfprnt-template-3',
1334 + 'title' => '<img src="' . plugins_url( 'images/template_right.jpg', __FILE__ ) . '" alt="template_right" />',
1335 + 'href' => $template_url
1336 + ) );
1337 + unset( $current_url );
1338 + unset( $permalink );
1339 + unset( $template_url );
1689 1340 }
1690 1341 }
1691 1342
1692 -if ( ! function_exists( 'pdfprnt_download_zip' ) ) {
1693 - /**
1694 - * Download Zip
1695 - *
1696 - * @param array $zip_file Zip file name.
1697 - * @param array $upload_dir Path for upload directory.
1698 - * @param array $url Url for Curl.
1699 - * @return array $result
1700 - */
1701 - function pdfprnt_download_zip( $zip_file, $upload_dir, $url ) {
1702 - /* Check permissions */
1703 - if ( is_writable( $upload_dir ) ) {
1704 - /* Load ZIP-archive */
1705 - $result = array();
1706 - $fp = fopen( $zip_file, 'w+' );
1707 - /* File size is too big to use wp_remote_get function */
1708 - $curl = curl_init();
1709 - $curl_parametres = array(
1710 - CURLOPT_URL => $url,
1711 - CURLOPT_FILE => $fp,
1712 - CURLOPT_USERAGENT => ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0' ),
1343 +if ( ! function_exists ( 'pdfprnt_plugin_banner' ) ) {
1344 + function pdfprnt_plugin_banner() {
1345 + global $hook_suffix, $pdfprnt_plugin_info;
1346 + if ( 'plugins.php' == $hook_suffix ) {
1347 + $banner_array = array(
1348 + array( 'lmtttmpts_hide_banner_on_plugin_page', 'limit-attempts/limit-attempts.php', '1.0.2' ),
1349 + array( 'sndr_hide_banner_on_plugin_page', 'sender/sender.php', '0.5' ),
1350 + array( 'srrl_hide_banner_on_plugin_page', 'user-role/user-role.php', '1.4' ),
1351 + array( 'pdtr_hide_banner_on_plugin_page', 'updater/updater.php', '1.12' ),
1352 + array( 'cntctfrmtdb_hide_banner_on_plugin_page', 'contact-form-to-db/contact_form_to_db.php', '1.2' ),
1353 + array( 'cntctfrmmlt_hide_banner_on_plugin_page', 'contact-form-multi/contact-form-multi.php', '1.0.7' ),
1354 + array( 'gglmps_hide_banner_on_plugin_page', 'bws-google-maps/bws-google-maps.php', '1.2' ),
1355 + array( 'fcbkbttn_hide_banner_on_plugin_page', 'facebook-button-plugin/facebook-button-plugin.php', '2.29' ),
1356 + array( 'twttr_hide_banner_on_plugin_page', 'twitter-plugin/twitter.php', '2.34' ),
1357 + array( 'pdfprnt_hide_banner_on_plugin_page', 'pdf-print/pdf-print.php', '1.7.1' ),
1358 + array( 'gglplsn_hide_banner_on_plugin_page', 'google-one/google-plus-one.php', '1.1.4' ),
1359 + array( 'gglstmp_hide_banner_on_plugin_page', 'google-sitemap-plugin/google-sitemap-plugin.php', '2.8.4' ),
1360 + array( 'cntctfrmpr_for_ctfrmtdb_hide_banner_on_plugin_page', 'contact-form-pro/contact_form_pro.php', '1.14' ),
1361 + array( 'cntctfrm_for_ctfrmtdb_hide_banner_on_plugin_page', 'contact-form-plugin/contact_form.php', '3.62' ),
1362 + array( 'cntctfrm_hide_banner_on_plugin_page', 'contact-form-plugin/contact_form.php', '3.47' ),
1363 + array( 'cptch_hide_banner_on_plugin_page', 'captcha/captcha.php', '3.8.4' ),
1364 + array( 'gllr_hide_banner_on_plugin_page', 'gallery-plugin/gallery-plugin.php', '3.9.1' )
1713 1365 );
1714 - curl_setopt_array( $curl, $curl_parametres );
1715 - if ( curl_exec( $curl ) ) {
1716 - $result['done'] = 'ok';
1717 - } else {
1718 - $result['error'] = curl_error( $curl ) . '<br />' . esc_html__( 'Check your internet connection', 'pdf-print' );
1719 - }
1720 - curl_close( $curl );
1721 - fclose( $fp );
1722 - } else {
1723 - $result['error'] = esc_html__( 'Cannot load files in to "uploads" folder. Check your permissions', 'pdf-print' );
1724 - }
1725 - return $result;
1726 - }
1727 -}
1728 -
1729 -if ( ! function_exists( 'pdfprnt_copy_fonts' ) ) {
1730 - /**
1731 - * Extract additional fonts to uploads/pdf-print-fonts
1732 - *
1733 - * @param string $zip_file Path to zip archive.
1734 - * @param string $upload_dir Name for zip archive.
1735 - */
1736 - function pdfprnt_copy_fonts( $zip_file, $upload_dir ) {
1737 - global $pdfprnt_options;
1738 - if ( empty( $pdfprnt_options ) ) {
1739 - $pdfprnt_options = get_option( 'pdfprnt_options' );
1740 - }
1741 - $destination = $upload_dir . '/pdf-print-fonts';
1742 - if ( ! file_exists( $destination ) ) {
1743 - mkdir( $destination, 0755, true );
1744 - }
1745 - $result = array();
1746 - /* check permissions */
1747 - if ( is_writable( $destination ) ) {
1748 - $zip = new Pdfprnt_ZipArchive();
1749 - /* open zip-archive */
1750 - if ( true === $zip->open( $zip_file ) ) {
1751 - /* extract folder with fonts */
1752 - $errors = $zip->extractSubdirTo( $destination, 'mpdf-master/ttfonts' );
1753 - $zip->close();
1754 - if ( empty( $errors ) ) {
1755 - $result['done'] = esc_html__( 'Additional fonts were loaded successfully.', 'pdf-print' );
1756 - unlink( $zip_file );
1757 - } else {
1758 - $result['error'] = esc_html__( 'Some errors occurred during loading files.', 'pdf-print' );
1366 + if ( ! $pdfprnt_plugin_info )
1367 + $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
1368 + if ( ! function_exists( 'is_plugin_active_for_network' ) )
1369 + require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
1370 + $active_plugins = get_option( 'active_plugins' );
1371 + $all_plugins = get_plugins();
1372 + $this_banner = 'pdfprnt_hide_banner_on_plugin_page';
1373 + foreach ( $banner_array as $key => $value ) {
1374 + if ( $this_banner == $value[0] ) {
1375 + global $wp_version, $bstwbsftwppdtplgns_cookie_add;
1376 + if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) {
1377 + echo '<script type="text/javascript" src="' . plugins_url( 'js/c_o_o_k_i_e.js', __FILE__ ) . '"></script>';
1378 + $bstwbsftwppdtplgns_cookie_add = true;
1379 + } ?>
1380 + <script type="text/javascript">
1381 + (function($) {
1382 + $(document).ready( function() {
1383 + var hide_message = $.cookie( "pdfprnt_hide_banner_on_plugin_page" );
1384 + if ( hide_message == "true") {
1385 + $( ".pdfprnt_message" ).css( "display", "none" );
1386 + } else {
1387 + $( ".pdfprnt_message" ).css( "display", "block" );
1388 + };
1389 + $( ".pdfprnt_close_icon" ).click( function() {
1390 + $( ".pdfprnt_message" ).css( "display", "none" );
1391 + $.cookie( "pdfprnt_hide_banner_on_plugin_page", "true", { expires: 32 } );
1392 + });
1393 + });
1394 + })(jQuery);
1395 + </script>
1396 + <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
1397 + <div class="pdfprnt_message bws_banner_on_plugin_page" style="display: none;">
1398 + <img class="pdfprnt_close_icon close_icon" title="" src="<?php echo plugins_url( 'images/close_banner.png', __FILE__ ); ?>" alt=""/>
1399 + <div class="button_div">
1400 + <a class="button" target="_blank" href="http://bestwebsoft.com/products/pdf-print/?k=e2f2549f4d70bc4cb9b48071169d264e&pn=101&v=<?php echo $pdfprnt_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>"><?php _e( "Learn More", 'pdf-print' ); ?></a>
1401 + </div>
1402 + <div class="text">
1403 + <?php _e( "It's time to upgrade your <strong>PDF & Print</strong> to <strong>PRO</strong> version", 'pdf-print' ); ?>!<br />
1404 + <span><?php _e( 'Extend standard plugin functionality with new great options', 'pdf-print' ); ?>.</span>
1405 + </div>
1406 + <div class="icon">
1407 + <img title="" src="<?php echo plugins_url( 'images/banner.png', __FILE__ ); ?>" alt=""/>
1408 + </div>
1409 + </div>
1410 + </div>
1411 + <?php break;
1759 1412 }
1760 - } else {
1761 - $result['error'] = esc_html__( 'Can not extract files from zip-archive.', 'pdf-print' );
1762 - unlink( $zip_file );
1763 - }
1764 - } else {
1765 - $result['error'] = sprintf( esc_html__( 'Cannot create %s folder. Check your permissions.', 'pdf-print' ), '"uploads/pdf-print-fonts"' );
1766 - }
1767 - $files = scandir( $destination );
1768 - $value = isset( $result['error'] ) ? -1 : count( $files );
1769 - $opt = 'additional_fonts';
1770 - pdfprnt_update_option( $opt, $value, true );
1771 - return $result;
1772 - }
1773 -}
1774 -
1775 -
1776 -if ( ! function_exists( 'pdfprnt_extract_mpdf_library' ) ) {
1777 - /**
1778 - * Extract mPDF library ( verson 7.1.5 ) from zip-archive
1779 - *
1780 - * @param string $zip_file Path to zip-archive.
1781 - * @param string $upload_dir Path to "Upload" folder.
1782 - * @return string $result Result message.
1783 - */
1784 - function pdfprnt_extract_mpdf_library( $zip_file, $upload_dir ) {
1785 - global $wpdb;
1786 -
1787 - $result = array();
1788 - /* check permissions */
1789 - if ( is_writable( $upload_dir ) ) {
1790 - $zip = new Pdfprnt_ZipArchive();
1791 - /* open zip-archive */
1792 - if ( true === $zip->open( $zip_file ) ) {
1793 - /* extract folder with fonts */
1794 - $errors = $zip->extractSubdirTo( $upload_dir, 'mpdf' );
1795 - $zip->close();
1796 - if ( empty( $errors ) ) {
1797 - $options_default = pdfprnt_get_options_default();
1798 - $value = $options_default['mpdf_library_version'];
1799 - $result['done'] = esc_html__( 'The mPDF library has been loaded successfully.', 'pdf-print' );
1800 - unlink( $zip_file );
1801 - } else {
1802 - $result['error'] = esc_html__( 'Some errors occurred during loading files.', 'pdf-print' );
1413 + if ( isset( $all_plugins[ $value[1] ] ) && $all_plugins[ $value[1] ]["Version"] >= $value[2] && ( 0 < count( preg_grep( '/' . str_replace( '/', '\/', $value[1] ) . '/', $active_plugins ) ) || is_plugin_active_for_network( $value[1] ) ) && ! isset( $_COOKIE[ $value[0] ] ) ) {
1414 + break;
1803 1415 }
1804 - } else {
1805 - $result['error'] = esc_html__( 'Can not extract files from zip-archive.', 'pdf-print' );
1806 - unlink( $zip_file );
1807 - }
1808 - } else {
1809 - $result['error'] = sprintf( esc_html__( 'Cannot extract files into %s folder. Check your permissions.', 'pdf-print' ), $upload_dir );
1416 + }
1810 1417 }
1811 - if ( ! isset( $value ) ) {
1812 - $value = '6.1';
1813 - }
1814 -
1815 - $opt = 'mpdf_library_version';
1816 - pdfprnt_update_option( $opt, $value, true );
1817 - return $result;
1818 1418 }
1819 1419 }
1820 1420
1821 -if ( ! function_exists( 'pdfprnt_load_and_copy' ) ) {
1822 - /**
1823 - * Download ZIP-archive with MPDF library,
1824 - * copy fonts to folder 'pdf-print-fons'
1825 - *
1826 - * @param string $zip_file path to zip-archive.
1827 - * @param string $upload_dir path to "Upload" folder.
1828 - * @param boolean $url url for archive.
1829 - * @param boolean $old_dir old dir for archive.
1830 - * @return string $result result message.
1831 - */
1832 - function pdfprnt_load_and_copy( $zip_file, $upload_dir, $url, $old_dir = '' ) {
1833 - $result = file_exists( $zip_file ) ? array( 'done' => 'ok' ) : pdfprnt_download_zip( $zip_file, $upload_dir, $url );
1834 - if ( is_multisite() ) {
1835 - switch_to_blog( 1 );
1836 - $dir = wp_upload_dir();
1837 - restore_current_blog();
1838 - } else {
1839 - $dir = wp_upload_dir();
1840 - }
1841 - if ( ! empty( $old_dir ) && plugin_dir_path( __FILE__ ) . 'mpdf' === $old_dir && isset( $result['done'] ) ) {
1842 - $result = pdfprnt_extract_mpdf_library( $zip_file, $upload_dir );
1843 - } elseif ( isset( $result['done'] ) ) {
1844 - $result = pdfprnt_copy_fonts( $zip_file, $upload_dir );
1845 - }
1846 - return $result;
1847 - }
1848 -}
1849 -
1850 -
1851 -if ( ! function_exists( 'pdfprnt_load_fonts' ) ) {
1852 - /**
1853 - * Function to load fonts for MPDF library
1854 - */
1855 - function pdfprnt_load_fonts() {
1856 - global $pdfprnt_options;
1857 - if ( empty( $pdfprnt_options ) ) {
1858 - $pdfprnt_options = get_option( 'pdfprnt_options' );
1859 - }
1860 - $ajax_request = isset( $_REQUEST['action'] ) && 'pdfprnt_load_fonts' === sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) ? true : false;
1861 - $php_request = isset( $_REQUEST['pdfprnt_action'] ) && 'pdfprnt_load_fonts' === sanitize_text_field( wp_unslash( $_REQUEST['pdfprnt_action'] ) ) ? true : false;
1862 - $verified = isset( $_REQUEST['pdfprnt_ajax_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['pdfprnt_ajax_nonce'] ) ), 'pdfprnt_ajax_nonce' ) ? true : false;
1863 - /* Sourse of the fonts */
1864 - $url = 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/fontdownloads/?action=loading_fonts';
1865 - if ( ( $ajax_request || $php_request ) && $verified ) {
1866 - $result = array();
1867 - $flag = false;
1868 - /* get path to directory for ZIP-archive uploading */
1869 - if ( is_multisite() ) {
1870 - switch_to_blog( 1 );
1871 - $upload_dir = wp_upload_dir();
1872 - restore_current_blog();
1873 - } else {
1874 - $upload_dir = wp_upload_dir();
1875 - }
1876 - $zip_file = $upload_dir['basedir'] . '/mpdf-master.zip';
1877 - $destination = $upload_dir['basedir'] . '/pdf-print-fonts';
1878 - if ( file_exists( $destination ) ) { /* if folder with fonts already exists */
1879 - if ( is_multisite() ) {
1880 - $network_options = get_site_option( 'pdfprnt_options' ); /* get network options */
1881 - $files = scandir( $destination );
1882 - if ( intval( $network_options['additional_fonts'] ) === count( $files ) ) { /* if all fonts was loaded successfully */
1883 - $result['done'] = esc_html__( 'Additional fonts were loaded successfully.', 'pdf-print' );
1884 - $opt = 'additional_fonts';
1885 - pdfprnt_update_option( $opt, $network_options['additional_fonts'], true );
1886 - } else { /* if something wrong */
1887 - $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'], $url ); /* load fonts */
1888 - }
1889 - } else {
1890 - $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'], $url ); /* load fonts */
1891 - }
1892 - } else {
1893 - mkdir( $destination, 0755, true );
1894 - $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'], $url );
1895 - }
1896 - if ( $ajax_request ) {
1897 - echo wp_json_encode( $result );
1898 - } else {
1899 - return $result;
1900 - }
1901 - }
1902 - if ( $ajax_request ) {
1903 - die();
1904 - }
1905 - }
1906 -}
1907 -
1908 -if ( ! function_exists( 'pdfprnt_upgrade_library' ) ) {
1909 - /**
1910 - * Function to upgrade the MPDF library from version 6.1 to verson 7.1.5
1911 - *
1912 - * @return string $result result message
1913 - */
1914 - function pdfprnt_upgrade_library() {
1915 - global $pdfprnt_options, $wpdb;
1916 -
1917 - $ajax_request = isset( $_REQUEST['action'] ) && 'pdfprnt_upgrade_library' === $_REQUEST['action'] ? true : false;
1918 -
1919 - $php_request = isset( $_REQUEST['pdfprnt_action'] ) && 'pdfprnt_upgrade_library' === sanitize_text_field( wp_unslash( $_REQUEST['pdfprnt_action'] ) ) ? true : false;
1920 - $verified = isset( $_REQUEST['pdfprnt_ajax_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['pdfprnt_ajax_nonce'] ) ), 'pdfprnt_ajax_nonce' ) ? true : false;
1921 - $old_dir = plugin_dir_path( __FILE__ ) . 'mpdf';
1922 - $result = array();
1923 - if ( ( $ajax_request || $php_request ) && true === $verified ) {
1924 - /* get path to directory for ZIP-archive uploading */
1925 - if ( is_multisite() ) {
1926 - switch_to_blog( 1 );
1927 - $upload_dir = wp_upload_dir();
1928 - restore_current_blog();
1929 - } else {
1930 - $upload_dir = wp_upload_dir();
1931 - }
1932 - $zip_file = $upload_dir['basedir'] . '/mpdf.zip';
1933 -
1934 - /* Sourse of the MPDF library */
1935 - $url = 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pdf-print-mpdf/?action=loading_library';
1936 - $new_dir = $upload_dir['basedir'] . '/vendor';
1937 -
1938 - if ( ! file_exists( $new_dir ) ) {
1939 - $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'], $url, $old_dir ); /* load library */
1940 - }
1941 - if ( ! isset( $result['error'] ) ) {
1942 - pdfprnt_delete_old_library( $old_dir );
1943 - }
1944 - }
1945 - if ( true === $ajax_request ) {
1946 - echo wp_json_encode( $result );
1947 - wp_die();
1948 - } else {
1949 - return $result;
1950 - }
1951 - }
1952 -}
1953 -
1954 -if ( ! function_exists( 'pdfprnt_pdf_count' ) ) {
1955 - /**
1956 - * Function to update pdf count generation
1957 - */
1958 - function pdfprnt_pdf_count() {
1959 - global $pdfprnt_options;
1960 - if ( empty( $pdfprnt_options ) ) {
1961 - $pdfprnt_options = get_option( 'pdfprnt_options' );
1962 - }
1963 - if ( 1 === $pdfprnt_options['count_generation'] ) {
1964 - $verified = isset( $_REQUEST['pdfprnt_ajax_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['pdfprnt_ajax_nonce'] ) ), 'pdfprnt_ajax_nonce' ) ? true : false;
1965 - if ( true === $verified && isset( $_REQUEST['id'] ) ) {
1966 - $count_generation = get_post_meta( intval( $_REQUEST['id'] ), 'pdfprnt_count_generation', true );
1967 - update_post_meta( intval( $_REQUEST['id'] ), 'pdfprnt_count_generation', (int) ++$count_generation );
1968 - }
1969 - }
1970 - wp_die();
1971 - }
1972 -}
1973 -
1974 -if ( ! function_exists( 'pdfprnt_delete_old_library' ) ) {
1975 - /**
1976 - * Delete old library
1977 - *
1978 - * @param string $dir path to library dir.
1979 - * @return bool resullt removing dir.
1980 - */
1981 - function pdfprnt_delete_old_library( $dir ) {
1982 - $files = scandir( $dir );
1983 - $files = array_diff( $files, array( '.', '..' ) );
1984 - foreach ( $files as $file ) {
1985 - ( is_dir( "$dir/$file" ) ) ? pdfprnt_delete_old_library( "$dir/$file" ) : unlink( "$dir/$file" );
1986 - }
1987 - return rmdir( $dir );
1988 - }
1989 -}
1990 -
1991 -if ( ! function_exists( 'pdfprnt_update_option' ) ) {
1992 - /**
1993 - * Update options
1994 - *
1995 - * @param string $opt option slug.
1996 - * @param string $value new value.
1997 - * @param bool $update_network (Optional) flag for update network.
1998 - */
1999 - function pdfprnt_update_option( $opt, $value, $update_network = false ) {
2000 - global $pdfprnt_options;
2001 - if ( empty( $pdfprnt_options ) ) {
2002 - $pdfprnt_options = get_option( 'pdfprnt_options' );
2003 - }
2004 - $pdfprnt_options[ $opt ] = $value;
2005 - update_option( 'pdfprnt_options', $pdfprnt_options );
2006 - if ( $update_network ) {
2007 - $network_options = get_site_option( 'pdfprnt_options' );
2008 - $network_options[ $opt ] = $value;
2009 - update_site_option( 'pdfprnt_options', $network_options );
2010 - }
2011 - }
2012 -}
2013 -
2014 -if ( ! function_exists( 'pdfprnt_get_pdf_page_sizes' ) ) {
2015 - /**
2016 - * Pafe sizes array
2017 - */
2018 - function pdfprnt_get_pdf_page_sizes() {
2019 - $page_sizes = array(
2020 - 'A0',
2021 - 'A1',
2022 - 'A2',
2023 - 'A3',
2024 - 'A4',
2025 - 'A5',
2026 - 'A6',
2027 - 'A7',
2028 - 'A8',
2029 - 'A9',
2030 - 'A10',
2031 - 'B0',
2032 - 'B1',
2033 - 'B2',
2034 - 'B3',
2035 - 'B4',
2036 - 'B5',
2037 - 'B6',
2038 - 'B7',
2039 - 'B8',
2040 - 'B9',
2041 - 'B10',
2042 - 'C0',
2043 - 'C1',
2044 - 'C2',
2045 - 'C3',
2046 - 'C4',
2047 - 'C5',
2048 - 'C6',
2049 - 'C7',
2050 - 'C8',
2051 - 'C9',
2052 - 'C10',
2053 - '4A0',
2054 - '2A0',
2055 - 'RA0',
2056 - 'RA1',
2057 - 'RA2',
2058 - 'RA3',
2059 - 'RA4',
2060 - 'SRA0',
2061 - 'SRA1',
2062 - 'SRA2',
2063 - 'SRA3',
2064 - 'SRA4',
2065 - 'Letter',
2066 - 'Legal',
2067 - 'Executive',
2068 - 'Folio',
2069 - 'Demy',
2070 - 'Royal',
2071 - 'A',
2072 - 'B',
2073 - );
2074 - $page_sizes = apply_filters( 'pdfprnt_get_pdf_page_sizes', $page_sizes );
2075 - return $page_sizes;
2076 - }
2077 -}
2078 -
2079 -if ( ! function_exists( 'pdfprnt_plugin_banner' ) ) {
2080 - /**
2081 - * Display plugn banner
2082 - */
2083 - function pdfprnt_plugin_banner() {
2084 - global $hook_suffix, $pdfprnt_plugin_info;
2085 - if ( 'plugins.php' === $hook_suffix ) {
2086 - bws_plugin_banner_to_settings( $pdfprnt_plugin_info, 'pdfprnt_options', 'pdf-print', 'admin.php?page=pdf-print.php' );
2087 - if ( function_exists( 'bws_plugin_banner_to_promo' ) ) {
2088 - bws_plugin_banner_to_promo( $pdfprnt_plugin_info, 'pdfprnt_options', 'pdf-print', 'admin.php?page=pdf-print.php', array( __( 'Test your PDF Generation Settings', 'bestwebsoft' ), __( "Ensure your PDF & Print plugin is correctly configured. Check your settings now!", 'bestwebsoft' ) ) );
2089 - }
2090 -
2091 - if ( isset( $_REQUEST['page'] ) && 'pdf-print.php' === $_REQUEST['page'] ) {
2092 - bws_plugin_suggest_feature_banner( $pdfprnt_plugin_info, 'pdfprnt_options', 'pdf-print' );
2093 - }
2094 - }
2095 - }
2096 -}
2097 -
2098 -if ( ! function_exists( 'pdfprnt_register_buttons_widget' ) ) {
2099 - /**
2100 - * Register buttons Widget
2101 - */
2102 - function pdfprnt_register_buttons_widget() {
2103 - global $pdfprnt_is_old_php;
2104 - if ( ! $pdfprnt_is_old_php ) {
2105 - if ( ! class_exists( 'Pdfprnt_Buttons_Widget' ) ) {
2106 - require_once dirname( __FILE__ ) . '/includes/class-pdfprnt-buttons-widget.php';
2107 - }
2108 - register_widget( 'Pdfprnt_Buttons_Widget' );
2109 - }
2110 - }
2111 -}
2112 -
2113 -
1421 +/* Deleting plugin options on uninstalling */
2114 1422 if ( ! function_exists( 'pdfprnt_uninstall' ) ) {
2115 - /**
2116 - * Deleting plugin options on uninstalling
2117 - */
2118 1423 function pdfprnt_uninstall() {
2119 - if ( ! function_exists( 'get_plugins' ) ) {
2120 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
2121 - }
2122 - $all_plugins = get_plugins();
2123 -
2124 - if ( ! array_key_exists( 'pdf-print-pro/pdf-print-pro.php' /*pls */ && ! array_key_exists( 'pdf-print-plus/pdf-print-plus.php', $all_plugins )/* pls*/, $all_plugins ) ) {
2125 - global $wpdb;
2126 - if ( is_multisite() ) {
2127 - /* Get all blog ids */
2128 - $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" );
2129 - $tables = '';
2130 - $old_blog = $wpdb->blogid;
2131 - foreach ( $blogids as $blog_id ) {
2132 - switch_to_blog( $blog_id );
2133 - delete_option( 'pdfprnt_options' );
2134 - delete_option( 'widget_pdfprint_buttons' );
2135 - }
2136 - switch_to_blog( $old_blog );
2137 - delete_site_option( 'pdfprnt_options' );
2138 - delete_option( 'widget_pdfprnt_buttons' );
2139 - } else {
2140 - delete_option( 'pdfprnt_options' );
2141 - delete_option( 'widget_pdfprnt_buttons' );
2142 - }
2143 - }
2144 -
2145 - require_once dirname( __FILE__ ) . '/bws_menu/bws_include.php';
2146 - bws_include_init( plugin_basename( __FILE__ ) );
2147 - bws_delete_plugin( plugin_basename( __FILE__ ) );
1424 + delete_option( 'pdfprnt_options_array' );
2148 1425 }
2149 1426 }
2150 1427
2151 1428 /* Adding function to output PDF document or pirnt page */
2152 -register_activation_hook( __FILE__, 'pdfprnt_plugin_activate' );
2153 -add_action( 'wp', 'pdfprnt_print', 20, 1 );
2154 -add_action( 'wp_head', 'pdfprnt_auto_show_buttons_search_archive' );
2155 -add_action( 'plugins_loaded', 'pdfprnt_plugins_loaded' );
1429 +add_action( 'wp', 'pdfprnt_print' );
2156 1430 /* Initialization */
2157 1431 add_action( 'init', 'pdfprnt_init' );
2158 1432 add_action( 'admin_init', 'pdfprnt_admin_init' );
2159 1433 /* Adding stylesheets */
@@ -2159,36 +1433,19 @@
2159 1433 /* Adding stylesheets */
2160 1434 add_action( 'admin_enqueue_scripts', 'pdfprnt_admin_head' );
2161 1435 add_action( 'wp_enqueue_scripts', 'pdfprnt_admin_head' );
2162 1436 /* Adding 'BWS Plugins' admin menu */
2163 -add_action( 'admin_menu', 'pdfprnt_add_admin_menu' );
1437 +add_action( 'admin_menu', 'pdfprnt_add_pages' );
1438 +/* Add menu to bar menu WordPress */
1439 +add_action( 'admin_bar_menu', 'pdfprnt_admin_bar_menu', 1000 );
2164 1440 /* Add query vars */
2165 -add_filter( 'query_vars', 'pdfprnt_print_vars_callback' );
2166 -
2167 -add_shortcode( 'bws_pdfprint', 'pdfprnt_shortcode' );
2168 -add_shortcode( 'bws_pdfprint_pagebreak', 'pdfprnt_shortcode_pagebreak' );
2169 -
2170 -add_filter( 'bwsplgns_pdf_replace_content', 'pdfprnt_qr_code_content', 10, 1 );
2171 -
2172 -/* custom filter for bws button in tinyMCE */
2173 -add_filter( 'bws_shortcode_button_content', 'pdfprnt_shortcode_button_content' );
2174 -
1441 +add_filter( 'query_vars', 'print_vars_callback' );
2175 1442 /* Additional links on the plugin page */
2176 1443 add_filter( 'plugin_action_links', 'pdfprnt_action_links', 10, 2 );
2177 1444 add_filter( 'plugin_row_meta', 'pdfprnt_links', 10, 2 );
2178 1445 /* Adding buttons plugin to content */
2179 1446 add_filter( 'the_content', 'pdfprnt_content' );
2180 -/* Remove Print word from excerpt */
2181 -add_filter( 'get_the_excerpt', 'pdfprnt_excerpt' );
2182 -/* load additional fonts */
2183 -add_action( 'wp_ajax_pdfprnt_load_fonts', 'pdfprnt_load_fonts' );
2184 -/* load mPDF library */
2185 -add_action( 'wp_ajax_pdfprnt_upgrade_library', 'pdfprnt_upgrade_library' );
2186 -add_action( 'wp_ajax_pdfprnt_pdf_count', 'pdfprnt_pdf_count' );
2187 -add_action( 'wp_ajax_nopriv_pdfprnt_pdf_count', 'pdfprnt_pdf_count' );
2188 1447 /* Adding banner */
2189 1448 add_action( 'admin_notices', 'pdfprnt_plugin_banner' );
2190 -
2191 -/* Register widget */
2192 -add_action( 'widgets_init', 'pdfprnt_register_buttons_widget' );
2193 -
2194 -add_action( 'bwsplgns_display_pdf_print_buttons', 'pdfprnt_display_plugin_buttons', 10, 2 );
1449 +/* Plugin uninstall function */
1450 +register_uninstall_hook( __FILE__, 'pdfprnt_uninstall' );
1451 +?>