PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.7.3
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.7.3
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 +1125 -918 1.8.41.7.3 View file →
@@ -1,16 +1,16 @@
1 1 <?php
2 2 /*
3 -Plugin Name: PDF & Print by BestWebSoft
4 -Plugin URI: http://bestwebsoft.com/products/
3 +Plugin Name: PDF & Print
4 +Plugin URI: http://bestwebsoft.com/plugin/
5 5 Description: Plugin adds PDF creation and Print button on your site.
6 6 Author: BestWebSoft
7 -Version: 1.8.4
7 +Version: 1.7.3
8 8 Author URI: http://bestwebsoft.com/
9 9 License: GPLv2 or later
10 10 */
11 11
12 -/* © Copyright 2015 BestWebSoft ( http://support.bestwebsoft.com )
12 +/* © Copyright 2014 BestWebSoft ( http://support.bestwebsoft.com )
13 13
14 14 This program is free software; you can redistribute it and/or modify
15 15 it under the terms of the GNU General Public License, version 2, as
16 16 published by the Free Software Foundation.
@@ -27,10 +27,52 @@
27 27
28 28 /* Add our own menu */
29 29 if ( ! function_exists( 'pdfprnt_add_pages' ) ) {
30 30 function pdfprnt_add_pages() {
31 - bws_add_general_menu( plugin_basename( __FILE__ ) );
32 - add_submenu_page( 'bws_plugins', __( 'PDF & Print Settings', 'pdf-print' ), 'PDF & Print', 'manage_options', 'pdf-print.php', 'pdfprnt_settings_page' );
31 + global $bstwbsftwppdtplgns_options, $wpmu, $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__);
35 +
36 + if ( ! isset( $bstwbsftwppdtplgns_options ) ) {
37 + if ( 1 == $wpmu ) {
38 + if ( ! get_site_option( 'bstwbsftwppdtplgns_options' ) )
39 + add_site_option( 'bstwbsftwppdtplgns_options', array(), '', 'yes' );
40 + $bstwbsftwppdtplgns_options = get_site_option( 'bstwbsftwppdtplgns_options' );
41 + } else {
42 + if ( ! get_option( 'bstwbsftwppdtplgns_options' ) )
43 + add_option( 'bstwbsftwppdtplgns_options', array(), '', 'yes' );
44 + $bstwbsftwppdtplgns_options = get_option( 'bstwbsftwppdtplgns_options' );
45 + }
46 + }
47 +
48 + if ( isset( $bstwbsftwppdtplgns_options['bws_menu_version'] ) ) {
49 + $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] = $bws_menu_version;
50 + unset( $bstwbsftwppdtplgns_options['bws_menu_version'] );
51 + update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options, '', 'yes' );
52 + require_once( dirname( __FILE__ ) . '/bws_menu/bws_menu.php' );
53 + } else if ( ! isset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] ) || $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] < $bws_menu_version ) {
54 + $bstwbsftwppdtplgns_options['bws_menu']['version'][ $base ] = $bws_menu_version;
55 + update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options, '', 'yes' );
56 + require_once( dirname( __FILE__ ) . '/bws_menu/bws_menu.php' );
57 + } else if ( ! isset( $bstwbsftwppdtplgns_added_menu ) ) {
58 + $plugin_with_newer_menu = $base;
59 + foreach ( $bstwbsftwppdtplgns_options['bws_menu']['version'] as $key => $value ) {
60 + if ( $bws_menu_version < $value && is_plugin_active( $base ) ) {
61 + $plugin_with_newer_menu = $key;
62 + }
63 + }
64 + $plugin_with_newer_menu = explode( '/', $plugin_with_newer_menu );
65 + $wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? basename( WP_CONTENT_DIR ) : 'wp-content';
66 + if ( file_exists( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_menu.php' ) )
67 + require_once( ABSPATH . $wp_content_dir . '/plugins/' . $plugin_with_newer_menu[0] . '/bws_menu/bws_menu.php' );
68 + else
69 + require_once( dirname( __FILE__ ) . '/bws_menu/bws_menu.php' );
70 + $bstwbsftwppdtplgns_added_menu = true;
71 + }
72 +
73 + add_menu_page( 'BWS Plugins', 'BWS Plugins', 'manage_options', 'bws_plugins', 'bws_add_menu_render', plugins_url( 'images/px.png', __FILE__ ), 1001 );
74 + add_submenu_page( 'bws_plugins', __( 'PDF & Print Settings', 'pdf-print' ), __( 'PDF & Print', 'pdf-print' ), 'manage_options', "pdf-print.php", 'pdfprnt_settings_page' );
33 75 }
34 76 }
35 77
36 78 /* Init plugin */
@@ -35,26 +77,12 @@
35 77
36 78 /* Init plugin */
37 79 if ( ! function_exists ( 'pdfprnt_init' ) ) {
38 80 function pdfprnt_init() {
39 - global $pdfprnt_plugin_info;
40 81 /* Internationalization, first(!) */
41 82 load_plugin_textdomain( 'pdf-print', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
42 -
43 - require_once( dirname( __FILE__ ) . '/bws_menu/bws_functions.php' );
44 -
45 - if ( empty( $pdfprnt_plugin_info ) ) {
46 - if ( ! function_exists( 'get_plugin_data' ) ) {
47 - require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
48 - }
49 - $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
50 - }
51 -
52 - /* check WordPress version */
53 - bws_wp_version_check( plugin_basename( __FILE__ ), $pdfprnt_plugin_info, '3.3' );
54 -
55 83 /* Get/Register and check settings for plugin */
56 - if ( ! is_admin() || ( isset( $_GET['page'] ) && 'pdf-print.php' == $_GET['page'] ) )
84 + if ( ! is_admin() || ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] ) )
57 85 pdfprnt_settings();
58 86 }
59 87 }
60 88
@@ -61,10 +89,15 @@
61 89 if ( ! function_exists( 'pdfprnt_admin_init' ) ) {
62 90 function pdfprnt_admin_init() {
63 91 global $bws_plugin_info, $pdfprnt_plugin_info;
64 92
65 - if ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) )
93 + if ( ! $pdfprnt_plugin_info )
94 + $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
95 +
96 + if ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) )
66 97 $bws_plugin_info = array( 'id' => '101', 'version' => $pdfprnt_plugin_info["Version"] );
98 + /* Function check if plugin is compatible with current WP version */
99 + pdfprnt_version_check();
67 100 }
68 101 }
69 102
70 103 /* Register settings for plugin */
@@ -69,9 +102,9 @@
69 102
70 103 /* Register settings for plugin */
71 104 if ( ! function_exists( 'pdfprnt_settings' ) ) {
72 105 function pdfprnt_settings() {
73 - global $pdfprnt_options_array, $pdfprnt_plugin_info, $pdfprnt_options_defaults;
106 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wpmu, $pdfprnt_plugin_info;
74 107
75 108 if ( ! $pdfprnt_plugin_info ) {
76 109 if ( ! function_exists( 'get_plugin_data' ) )
77 110 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
@@ -78,40 +111,48 @@
78 111 $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
79 112 }
80 113
81 114 /* Variable to verify performance number of once function. */
115 + $pdfprnt_output_count_buttons = 0;
82 116 $pdfprnt_default_post_types = array();
83 117 /* Default post types of WordPress. */
84 118 foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1, '_builtin' => true ), 'names' ) as $value )
85 119 $pdfprnt_default_post_types[] = $value;
86 120
87 - $pdfprnt_options_defaults = array(
121 + $pdfprnt_options_array_defaults = array(
88 122 'plugin_option_version' => $pdfprnt_plugin_info["Version"],
89 123 'position' => 'top-right',
90 - 'position_search_archive' => 'top-right',
91 - 'position_custom' => 'right',
124 + 'position_search_archive' => 'left',
125 + 'position_custom' => 'left',
92 126 'show_btn_print' => 1,
93 127 'show_btn_pdf' => 1,
94 128 'show_btn_print_search_archive' => 1,
95 129 'show_btn_pdf_search_archive' => 1,
130 + 'show_btn_print_custom' => 1,
131 + 'show_btn_pdf_custom' => 1,
96 132 'use_theme_stylesheet' => 0,
133 + 'tmpl_post' => 1,
134 + 'tmpl_search' => 1,
135 + 'tmpl_custom' => 1,
97 136 'tmpl_shorcode' => 1,
98 137 'use_types_posts' => $pdfprnt_default_post_types,
99 - 'show_print_window' => 0,
100 - 'additional_fonts' => 0
138 + 'show_print_window' => 0
101 139 );
102 140
103 - if ( ! get_option( 'pdfprnt_options_array' ) )
104 - add_option( 'pdfprnt_options_array', $pdfprnt_options_defaults );
141 + if ( 1 == $wpmu ) {
142 + if ( ! get_site_option( 'pdfprnt_options_array' ) )
143 + add_site_option( 'pdfprnt_options_array', $pdfprnt_options_array_defaults, '', 'yes' );
105 144
106 - $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
145 + $pdfprnt_options_array = get_site_option( 'pdfprnt_options_array' );
146 + } else {
147 + if ( ! get_option( 'pdfprnt_options_array' ) )
148 + add_option( 'pdfprnt_options_array', $pdfprnt_options_array_defaults, '', 'yes' );
107 149
150 + $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
151 + }
152 +
108 153 if ( ! isset( $pdfprnt_options_array['plugin_option_version'] ) || $pdfprnt_options_array['plugin_option_version'] != $pdfprnt_plugin_info["Version"] ) {
109 - if ( in_array( $pdfprnt_options_array['position_search_archive'], array( 'pdfprnt-right', 'pdfprnt-left' ) ) )
110 - $pdfprnt_options_array['position_search_archive'] = 'pdfprnt-left' == $pdfprnt_options_array['position_search_archive'] ? 'top-left' : 'top-right';
111 - if ( in_array( $pdfprnt_options_array['position_custom'], array( 'pdfprnt-right', 'pdfprnt-left' ) ) )
112 - $pdfprnt_options_array['position_custom'] = 'pdfprnt-left' == $pdfprnt_options_array['position_custom'] ? 'left' : 'right';
113 - $pdfprnt_options_array = array_merge( $pdfprnt_options_defaults, $pdfprnt_options_array );
154 + $pdfprnt_options_array = array_merge( $pdfprnt_options_array_defaults, $pdfprnt_options_array );
114 155 $pdfprnt_options_array['plugin_option_version'] = $pdfprnt_plugin_info["Version"];
115 156 update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
116 157 }
117 158 }
@@ -116,408 +157,515 @@
116 157 }
117 158 }
118 159 }
119 160
120 -/**
121 - * Display <input type="radio"> on settings page
122 - **/
123 -if ( ! function_exists( 'pdfprnt_display_radio' ) ) {
124 - function pdfprnt_display_radio( $name, $selected ) {
125 - $positions_values = array(
126 - 'top-left' => __( 'Top Left', 'pdf-print' ),
127 - 'top-right' => __( 'Top Right', 'pdf-print' ),
128 - 'bottom-left' => __( 'Bottom Left', 'pdf-print' ),
129 - 'bottom-right' => __( 'Bottom Right', 'pdf-print' ),
130 - 'top-bottom-left' => __( 'Top & Bottom Left', 'pdf-print' ),
131 - 'top-bottom-right' => __( 'Top & Bottom Right', 'pdf-print' )
132 - );
133 - foreach ( $positions_values as $key => $value ) { ?>
134 - <label><input type="radio" name="<?php echo $name; ?>" value="<?php echo $key ?>"<?php echo $key == $selected ? ' checked="checked"' : ''; ?> />&nbsp;<?php echo $value; ?></label><br/>
135 - <?php }
161 +/* Function check if plugin is compatible with current WP version */
162 +if ( ! function_exists ( 'pdfprnt_version_check' ) ) {
163 + function pdfprnt_version_check() {
164 + global $wp_version, $pdfprnt_plugin_info;
165 + if ( ! $pdfprnt_plugin_info )
166 + $pdfprnt_plugin_info = get_plugin_data( __FILE__, false );
167 + $require_wp = "3.0"; /* Wordpress at least requires version */
168 + $plugin = plugin_basename( __FILE__ );
169 + if ( version_compare( $wp_version, $require_wp, "<" ) ) {
170 + if ( is_plugin_active( $plugin ) ) {
171 + deactivate_plugins( $plugin );
172 + 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='" . get_admin_url( null, 'plugins.php' ) . "'>" . __( 'Plugins page', 'pdf-print') . "</a>." );
173 + }
174 + }
136 175 }
137 176 }
177 +
138 178 /* Add admin page */
139 179 if ( ! function_exists ( 'pdfprnt_settings_page' ) ) {
140 180 function pdfprnt_settings_page () {
141 - global $pdfprnt_options_array, $wp_version, $pdfprnt_plugin_info, $pdfprnt_options_defaults;
142 - $message = $error = "";
143 - $plugin_basename = plugin_basename( __FILE__ );
144 - if ( is_multisite() ) {
145 - switch_to_blog( 1 );
146 - $upload_dir = wp_upload_dir();
147 - restore_current_blog();
148 - } else {
149 - $upload_dir = wp_upload_dir();
150 - }
151 - $need_fonts_reload = false;
152 - $fonts_path = $upload_dir['basedir'] .'/pdf-print-fonts';
153 - if ( ! function_exists( 'get_plugins' ) )
154 - require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
155 - $all_plugins = get_plugins();
156 - if ( isset( $_REQUEST['pdfprnt_form_submit'] ) && check_admin_referer( $plugin_basename, 'pdfprnt_nonce_name' ) ) {
157 - $pdfprnt_options_array['position'] = isset( $_REQUEST['pdfprnt_position'] ) ? $_REQUEST['pdfprnt_position'] : 'top-right';
158 - $pdfprnt_options_array['position_search_archive'] = isset( $_REQUEST['pdfprnt_position_search_archive'] ) ? $_REQUEST['pdfprnt_position_search_archive'] : 'top-right';
159 - $pdfprnt_options_array['position_custom'] = isset( $_REQUEST['pdfprnt_position_custom'] ) ? $_REQUEST['pdfprnt_position_custom'] : 'right';
160 - $pdfprnt_options_array['use_theme_stylesheet'] = isset( $_REQUEST['pdfprnt_use_theme_stylesheet'] ) ? $_REQUEST['pdfprnt_use_theme_stylesheet'] : 0;
181 + global $pdfprnt_options_array, $wp_version, $pdfprnt_plugin_info;
182 + $message = $error = "";
183 +
184 + $pdfprnt_positions_values = array(
185 + 'top-left' => __( 'Top Left', 'pdf-print' ),
186 + 'top-right' => __( 'Top Right', 'pdf-print' ),
187 + 'bottom-left' => __( 'Bottom Left', 'pdf-print' ),
188 + 'bottom-right' => __( 'Bottom Right', 'pdf-print' )
189 + );
190 +
191 + if ( isset( $_REQUEST['pdfprnt_position'] ) &&
192 + isset( $_REQUEST['pdfprnt_position_search_archive'] ) &&
193 + isset( $_REQUEST['pdfprnt_position_custom'] ) &&
194 + isset( $_REQUEST['pdfprnt_use_theme_stylesheet'] ) &&
195 + isset( $_REQUEST['pdfprnt_tmpl_post'] ) &&
196 + isset( $_REQUEST['pdfprnt_tmpl_custom'] ) &&
197 + isset( $_REQUEST['pdfprnt_tmpl_search'] ) &&
198 + check_admin_referer( plugin_basename( __FILE__ ), 'pdfprnt_nonce_name' ) ) {
199 + $pdfprnt_options_array['position'] = $_REQUEST['pdfprnt_position'];
200 + $pdfprnt_options_array['position_search_archive'] = $_REQUEST['pdfprnt_position_search_archive'];
201 + $pdfprnt_options_array['position_custom'] = $_REQUEST['pdfprnt_position_custom'];
202 + $pdfprnt_options_array['tmpl_post'] = $_REQUEST['pdfprnt_tmpl_post'];
203 + $pdfprnt_options_array['tmpl_search'] = $_REQUEST['pdfprnt_tmpl_search'];
204 + $pdfprnt_options_array['tmpl_custom'] = $_REQUEST['pdfprnt_tmpl_custom'];
205 + $pdfprnt_options_array['use_theme_stylesheet'] = $_REQUEST['pdfprnt_use_theme_stylesheet'];
161 206 $pdfprnt_options_array['show_btn_pdf'] = isset( $_REQUEST['pdfprnt_show_btn_pdf'] ) ? 1 : 0;
162 207 $pdfprnt_options_array['show_btn_print'] = isset( $_REQUEST['pdfprnt_show_btn_print'] ) ? 1 : 0;
163 208 $pdfprnt_options_array['show_btn_pdf_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_search_archive'] ) ? 1 : 0;
164 209 $pdfprnt_options_array['show_btn_print_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_print_search_archive'] ) ? 1 : 0;
210 + $pdfprnt_options_array['show_btn_pdf_custom'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_custom'] ) ? 1 : 0;
211 + $pdfprnt_options_array['show_btn_print_custom'] = isset( $_REQUEST['pdfprnt_show_btn_print_custom'] ) ? 1 : 0;
165 212 $pdfprnt_options_array['tmpl_shorcode'] = isset( $_REQUEST['pdfprnt_tmpl_shorcode'] ) ? 1 : 0;
166 213 $pdfprnt_options_array['show_print_window'] = isset( $_REQUEST['pdfprnt_show_print_window'] ) ? 1 : 0;
167 214 $pdfprnt_options_array['use_types_posts'] = isset( $_REQUEST['pdfprnt_use_types_posts'] ) ? $_REQUEST['pdfprnt_use_types_posts'] : array();
168 - update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
215 + update_option ( 'pdfprnt_options_array', $pdfprnt_options_array );
169 216 $message = __( 'Settings saved.', 'pdf-print' );
170 217 }
171 - if ( ( ! is_dir( $fonts_path ) ) && 0 != $pdfprnt_options_array['additional_fonts'] ) { /* if "pdf-print-fonts" folder was removed somehow */
172 - $error = __( 'The folder "uploads/pdf-print-fonts" was removed.', 'pdf-print' );
173 - $need_fonts_reload = true;
174 - } elseif (
175 - is_dir( $fonts_path ) &&
176 - $pdfprnt_options_array['additional_fonts'] != count( scandir( $fonts_path ) ) &&
177 - 0 < $pdfprnt_options_array['additional_fonts']
178 - ) { /* if some fonts was removed somehow from "pdf-print-fonts" folder */
179 - $error = __( 'Some fonts were removed from the folder "uploads/pdf-print-fonts".', 'pdf-print' );
180 - $need_fonts_reload = true;
218 + /* GO PRO */
219 + if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) {
220 + global $wpmu;
221 +
222 + $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? trim( $_POST['bws_license_key'] ) : "";
223 + $bstwbsftwppdtplgns_options_defaults = array();
224 + if ( 1 == $wpmu ) {
225 + if ( !get_site_option( 'bstwbsftwppdtplgns_options' ) )
226 + add_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options_defaults, '', 'yes' );
227 + $bstwbsftwppdtplgns_options = get_site_option( 'bstwbsftwppdtplgns_options' );
228 + } else {
229 + if ( !get_option( 'bstwbsftwppdtplgns_options' ) )
230 + add_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options_defaults, '', 'yes' );
231 + $bstwbsftwppdtplgns_options = get_option( 'bstwbsftwppdtplgns_options' );
232 + }
233 +
234 + if ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'bws_license_nonce_name' ) ) {
235 + if ( '' != $bws_license_key ) {
236 + if ( strlen( $bws_license_key ) != 18 ) {
237 + $error = __( "Wrong license key", 'pdf-print' );
238 + } else {
239 + $bws_license_plugin = trim( $_POST['bws_license_plugin'] );
240 + if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] < ( time() + (24 * 60 * 60) ) ) {
241 + $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1;
242 + } else {
243 + $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1;
244 + $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time();
245 + }
246 +
247 + /* download Pro */
248 + if ( !function_exists( 'get_plugins' ) )
249 + require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
250 + if ( ! function_exists( 'is_plugin_active_for_network' ) )
251 + require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
252 + $all_plugins = get_plugins();
253 + $active_plugins = get_option( 'active_plugins' );
254 +
255 + if ( ! array_key_exists( $bws_license_plugin, $all_plugins ) ) {
256 + $current = get_site_transient( 'update_plugins' );
257 + if ( is_array( $all_plugins ) && !empty( $all_plugins ) && isset( $current ) && is_array( $current->response ) ) {
258 + $to_send = array();
259 + $to_send["plugins"][ $bws_license_plugin ] = array();
260 + $to_send["plugins"][ $bws_license_plugin ]["bws_license_key"] = $bws_license_key;
261 + $to_send["plugins"][ $bws_license_plugin ]["bws_illegal_client"] = true;
262 + $options = array(
263 + 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
264 + 'body' => array( 'plugins' => serialize( $to_send ) ),
265 + 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
266 + $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options );
267 +
268 + if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) {
269 + $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' );
270 + } else {
271 + $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
272 +
273 + if ( is_array( $response ) && !empty( $response ) ) {
274 + foreach ( $response as $key => $value ) {
275 + if ( "wrong_license_key" == $value->package ) {
276 + $error = __( "Wrong license key", 'pdf-print' );
277 + } elseif ( "wrong_domain" == $value->package ) {
278 + $error = __( "This license key is bind to another site", 'pdf-print' );
279 + } elseif ( "you_are_banned" == $value->package ) {
280 + $error = __( "Unfortunately, you have exceeded the number of available tries. Please, upload the plugin manually.", 'pdf-print' );
281 + }
282 + }
283 + if ( '' == $error ) {
284 + global $wpmu;
285 + $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key;
286 +
287 + $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';
288 + $uploadDir = wp_upload_dir();
289 + $zip_name = explode( '/', $bws_license_plugin );
290 + if ( file_put_contents( $uploadDir["path"] . "/" . $zip_name[0] . ".zip", file_get_contents( $url ) ) ) {
291 + @chmod( $uploadDir["path"] . "/" . $zip_name[0] . ".zip", octdec( 755 ) );
292 + if ( class_exists( 'ZipArchive' ) ) {
293 + $zip = new ZipArchive();
294 + if ( $zip->open( $uploadDir["path"] . "/" . $zip_name[0] . ".zip" ) === TRUE ) {
295 + $zip->extractTo( WP_PLUGIN_DIR );
296 + $zip->close();
297 + } else {
298 + $error = __( "Failed to open the zip archive. Please, upload the plugin manually", 'pdf-print' );
299 + }
300 + } elseif ( class_exists( 'Phar' ) ) {
301 + $phar = new PharData( $uploadDir["path"] . "/" . $zip_name[0] . ".zip" );
302 + $phar->extractTo( WP_PLUGIN_DIR );
303 + } else {
304 + $error = __( "Your server does not support either ZipArchive or Phar. Please, upload the plugin manually", 'pdf-print' );
305 + }
306 + @unlink( $uploadDir["path"] . "/" . $zip_name[0] . ".zip" );
307 + } else {
308 + $error = __( "Failed to download the zip archive. Please, upload the plugin manually", 'pdf-print' );
309 + }
310 +
311 + /* activate Pro */
312 + if ( file_exists( WP_PLUGIN_DIR . '/' . $zip_name[0] ) ) {
313 + array_push( $active_plugins, $bws_license_plugin );
314 + update_option( 'active_plugins', $active_plugins );
315 + $pro_plugin_is_activated = true;
316 + } elseif ( '' == $error ) {
317 + $error = __( "Failed to download the zip archive. Please, upload the plugin manually", 'pdf-print' );
318 + }
319 + }
320 + } else {
321 + $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvienience.", 'pdf-print' );
322 + }
323 + }
324 + }
325 + } else {
326 + /* activate Pro */
327 + if ( ! ( in_array( $bws_license_plugin, $active_plugins ) || is_plugin_active_for_network( $bws_license_plugin ) ) ) {
328 + array_push( $active_plugins, $bws_license_plugin );
329 + update_option( 'active_plugins', $active_plugins );
330 + $pro_plugin_is_activated = true;
331 + }
332 + }
333 + update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options, '', 'yes' );
334 + }
335 + } else {
336 + $error = __( "Please, enter Your license key", 'pdf-print' );
337 + }
338 + }
181 339 }
182 - if ( $need_fonts_reload ) {
183 - $error .= __( ' You may need to reload fonts.', 'pdf-print' );
184 - $pdfprnt_options_array['additional_fonts'] = 0;
185 - }
186 - if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) {
187 - /* GO PRO */
188 - $go_pro_result = bws_go_pro_tab_check( $plugin_basename );
189 - if ( ! empty( $go_pro_result['error'] ) )
190 - $error = $go_pro_result['error'];
191 - }
192 - if ( isset( $_REQUEST['pdfprnt_load_fonts'] ) ) {
193 - /* load additional fonts if javascript is disabled */
194 - $result = pdfprnt_load_fonts();
195 - if ( isset( $result['error'] ) )
196 - $error .= '&nbsp;' . $result['error'];
197 - if ( isset( $result['done'] ) )
198 - $message .= '&nbsp;' . $result['done'];
199 - }
200 - if ( isset( $_REQUEST['bws_restore_confirm'] ) && check_admin_referer( $plugin_basename, 'bws_settings_nonce_name' ) ) {
201 - $pdfprnt_options_array = $pdfprnt_options_defaults;
202 - update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
203 - $message = __( 'All plugin settings were restored.', 'pdf-print' );
204 - }
205 340 ?>
206 341 <div class="wrap">
207 342 <div class="icon32 icon32-bws" id="icon-options-general"></div>
208 - <h2>PDF & Print<?php if ( isset( $_GET['action'] ) && 'templates' == $_GET['action'] ) { ?> <a href="admin.php?page=pdf-print.php&amp;action=templates&amp;pdfprnt_tab_action=new" class="<?php if ( 3.8 > $wp_version ) echo 'button '; ?>add-new-h2"><?php _e( 'Add New Template', 'pdf-print' ); ?></a><?php } ?></h2>
343 + <h2><?php echo __( 'PDF & Print Settings', 'pdf-print' ); ?></h2>
209 344 <h2 class="nav-tab-wrapper">
210 345 <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>
211 346 <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>
212 - <a class="nav-tab<?php if ( isset( $_GET['action'] ) && 'templates' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=pdf-print.php&amp;action=templates"><?php _e( 'Templates', 'pdf-print' ); ?></a>
213 - <a class="nav-tab" href="http://bestwebsoft.com/products/pdf-print/faq/" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>
347 + <a class="nav-tab" href="http://bestwebsoft.com/plugin/pdf-print/#faq" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>
214 348 <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>
215 349 </h2>
216 350 <div class="updated fade" <?php if ( empty( $message ) || "" != $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?></strong></p></div>
217 351 <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>
218 352 <div class="error" <?php if ( "" == $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $error; ?></strong></p></div>
219 - <?php if ( ! isset( $_GET['action'] ) ) {
220 - if ( isset( $_REQUEST['bws_restore_default'] ) && check_admin_referer( $plugin_basename, 'bws_settings_nonce_name' ) ) {
221 - bws_form_restore_default_confirm( $plugin_basename );
222 - } else { ?>
223 - <form method="post" action="admin.php?page=pdf-print.php" id="pdfprnt_settings_form">
224 - <table class="form-table pdfprnt_settings_table">
225 - <tr id="pdfprnt_load_fonts_button">
226 - <th scope="row"><?php _e( 'Load additional fonts', 'pdf-print' ); ?></th>
227 - <td style="position: relative;">
228 - <?php if ( 0 == $pdfprnt_options_array['additional_fonts'] && class_exists( 'ZipArchive' ) ) {
229 - $ajax_nonce = wp_create_nonce( 'pdfprnt_ajax_nonce' ); ?>
230 - <input type="submit" class="button" value="<?php _e( 'Load Fonts', 'pdf-print' ); ?>" name="pdfprnt_load_fonts" />&nbsp;<span id="pdfprnt_font_loader" class="pdfprnt_loader"><img src="<?php echo plugins_url( 'images/ajax-loader.gif', __FILE__ ); ?>" alt="loader" /></span><br />
231 - <span class="pdfprnt_info"><?php _e( 'You can load additional fonts, needed for the PDF creation. When creating the PDF-doc, this will allow automatic selection of fonts necessary for text, according to languages used in the content.', 'pdf-print' ); ?></span>
232 - <input type="hidden" name="pdfprnt_action" value="pdfprnt_load_fonts" />
233 - <input type="hidden" name="pdfprnt_ajax_nonce" value="<?php echo $ajax_nonce; ?>" />
234 - <?php } elseif ( 0 == $pdfprnt_options_array['additional_fonts'] && ! class_exists( 'ZipArchive' ) ) { ?>
235 - <span style="color: red"><strong><?php _e( 'WARNING', 'pdf-print' ); ?>:&nbsp;</strong><?php _e( 'Class ZipArchive is not installed on your server. It is impossible to load additional fonts.', 'pdf-print' ); ?></span>
236 - <?php } elseif ( 0 < $pdfprnt_options_array['additional_fonts'] ) { ?>
237 - <span><?php _e( 'Additional fonts were loaded successfully', 'pdf-print' ); ?>.</span>
238 - <?php } ?>
353 + <?php if ( ! isset( $_GET['action'] ) ) { ?>
354 + <form method="post" action="admin.php?page=pdf-print.php" id="pdfprnt_settings_form">
355 + <table class="form-table pdfprnt_settings_table">
356 + <tr>
357 + <th scope="row"><?php echo __( 'Use of theme stylesheet or plugin default style:', 'pdf-print' ); ?></th>
358 + <td>
359 + <select name="pdfprnt_use_theme_stylesheet">
360 + <option value="0" <?php if ( 0 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Default stylesheet', 'pdf-print' ); ?></option>
361 + <option value="1" <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Current theme stylesheet', 'pdf-print' ); ?></option>
362 + </select>
363 + </td>
364 + </tr>
365 + <tr>
366 + <th scope="row"><?php echo __( 'The types of posts that the plugin will use:', 'pdf-print' ); ?></th>
367 + <td>
368 + <select name="pdfprnt_use_types_posts[]" multiple="multiple">
369 + <?php foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1 ), 'objects' ) as $key => $value ) : ?>
370 + <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $pdfprnt_options_array['use_types_posts'] ) ) echo 'selected="selected"'; ?>><?php echo $value->label; ?></option>
371 + <?php endforeach; ?>
372 + </select>
373 + </td>
374 + </tr>
375 + <?php
376 + $active_plugins = get_option( 'active_plugins' );
377 + if( 0 < count( preg_grep( '/portfolio\/portfolio.php/', $active_plugins ) ) ) : ?>
378 + <tr>
379 + <th scope="row"></th>
380 + <td>
381 + <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>
382 + </td>
383 + </tr>
384 + <?php endif; ?>
385 + <tr>
386 + <th scope="row">
387 + <?php echo __( 'Position of buttons in content:', 'pdf-print' ); ?>
388 + </th>
389 + <td>
390 + <select name="pdfprnt_position">
391 + <?php foreach ( $pdfprnt_positions_values as $key => $value ) : ?>
392 + <option value="<?php echo $key; ?>" <?php if ( $pdfprnt_options_array['position'] == $key ) echo 'selected="selected"'; ?>><?php echo $value; ?></option>
393 + <?php endforeach; ?>
394 + </select>
395 + </td>
396 + </tr>
397 + <tr>
398 + <th scope="row"><?php echo __( 'Show:', 'pdf-print' ); ?></th>
399 + <td>
400 + <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 />
401 + <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>
402 + </td>
403 + </tr>
404 + <tr>
405 + <th scope="row">
406 + <?php echo __( 'Default template setting for post:', 'pdf-print' ); ?>
407 + </th>
408 + <td>
409 + <div>
410 + <label>
411 + <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
412 + <input type="radio" name="pdfprnt_tmpl_post" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
413 + </label>
414 + </div>
415 + <div>
416 + <label>
417 + <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
418 + <input type="radio" name="pdfprnt_tmpl_post" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
419 + </label>
420 + </div>
421 + <div>
422 + <label>
423 + <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
424 + <input type="radio" name="pdfprnt_tmpl_post" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
425 + </label>
426 + </div>
427 + </td>
428 + </tr>
429 + <tr>
430 + <th scope="row">
431 + <?php echo __( 'Position of buttons in content for custom post:', 'pdf-print' ); ?>
432 + </th>
433 + <td>
434 + <select name="pdfprnt_position_custom">
435 + <option value="pdfprnt-left" <?php if ( 'left' == $pdfprnt_options_array['position_custom'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Left', 'pdf-print' ); ?></option>
436 + <option value="pdfprnt-right" <?php if ( 'right' == $pdfprnt_options_array['position_custom'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Right', 'pdf-print' ); ?></option>
437 + </select>
438 + </td>
439 + </tr>
440 + <tr>
441 + <th scope="row"><?php echo __( 'Show for custom posts:', 'pdf-print' ); ?></th>
442 + <td>
443 + <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 />
444 + <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>
445 + </td>
446 + </tr>
447 + <tr>
448 + <th scope="row">
449 + <?php echo __( 'Default template setting for custom posts:', 'pdf-print' ); ?>
450 + </th>
451 + <td>
452 + <div>
453 + <label>
454 + <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
455 + <input type="radio" name="pdfprnt_tmpl_custom" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
456 + </label>
457 + </div>
458 + <div>
459 + <label>
460 + <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
461 + <input type="radio" name="pdfprnt_tmpl_custom" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
462 + </label>
463 + </div>
464 + <div>
465 + <label>
466 + <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
467 + <input type="radio" name="pdfprnt_tmpl_custom" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
468 + </label>
469 + </div>
470 + </td>
471 + </tr>
472 + <tr>
473 + <th scope="row"></th>
474 + <td>
475 + <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>
476 + </td>
477 + </tr>
478 + <tr>
479 + <th scope="row">
480 + <?php echo __( 'Position of buttons on search or archive page:', 'pdf-print' ); ?>
481 + </th>
482 + <td>
483 + <select name="pdfprnt_position_search_archive">
484 + <option value="pdfprnt-left" <?php if ( 'left' == $pdfprnt_options_array['position_search_archive'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Left', 'pdf-print' ); ?></option>
485 + <option value="pdfprnt-right" <?php if ( 'right' == $pdfprnt_options_array['position_search_archive'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Right', 'pdf-print' ); ?></option>
486 + </select>
487 + </td>
488 + </tr>
489 + <tr>
490 + <th scope="row"><?php echo __( 'Show for search or archive page:', 'pdf-print' ); ?></th>
491 + <td>
492 + <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 />
493 + <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>
494 + </td>
495 + </tr>
496 + <tr>
497 + <th scope="row">
498 + <?php echo __( 'Default template setting for search and archive:', 'pdf-print' ); ?>
499 + </th>
500 + <td>
501 + <div>
502 + <label>
503 + <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
504 + <input type="radio" name="pdfprnt_tmpl_search" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
505 + </label>
506 + </div>
507 + <div>
508 + <label>
509 + <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
510 + <input type="radio" name="pdfprnt_tmpl_search" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
511 + </label>
512 + </div>
513 + <div>
514 + <label>
515 + <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
516 + <input type="radio" name="pdfprnt_tmpl_search" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
517 + </label>
518 + </div>
519 + </td>
520 + </tr>
521 + <tr>
522 + <th scope="row"></th>
523 + <td>
524 + <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>
525 + </td>
526 + </tr>
527 + <tr>
528 + <th scope="row">
529 + <?php echo __( 'Settings for shorcodes:', 'pdf-print' ); ?>
530 + </th>
531 + <td>
532 + <label><input type="checkbox" name="pdfprnt_tmpl_shorcode" <?php if ( 1 == $pdfprnt_options_array['tmpl_shorcode'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'Do!', 'pdf-print' ); ?></span></label>
533 + </td>
534 + </tr>
535 + <tr>
536 + <th scope="row"><?php echo __( 'Show the print window', 'pdf-print' ); ?></th>
537 + <td>
538 + <label><input type="checkbox" name="pdfprnt_show_print_window" <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'Mark the checkbox to show it', 'pdf-print' ); ?></span></label><br />
539 + </td>
540 + </tr>
541 + </table>
542 + <input type="hidden" name="pdfprnt_form_submit" value="1" />
543 + <p class="submit">
544 + <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
545 + </p>
546 + <?php wp_nonce_field( plugin_basename( __FILE__ ), 'pdfprnt_nonce_name' ); ?>
547 + </form>
548 + <div class="bws-plugin-reviews">
549 + <div class="bws-plugin-reviews-rate">
550 + <?php _e( 'If you enjoy our plugin, please give it 5 stars on WordPress', 'pdf-print' ); ?>:
551 + <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>
552 + </div>
553 + <div class="bws-plugin-reviews-support">
554 + <?php _e( 'If there is something wrong about it, please contact us', 'pdf-print' ); ?>:
555 + <a href="http://support.bestwebsoft.com">http://support.bestwebsoft.com</a>
556 + </div>
557 + </div>
558 + <?php } elseif ( 'extra' == $_GET['action'] ) { ?>
559 + <div class="bws_pro_version_bloc">
560 + <div class="bws_pro_version_table_bloc">
561 + <div class="bws_table_bg"></div>
562 + <table class="form-table bws_pro_version">
563 + <tr valign="top">
564 + <td colspan="2">
565 + <?php _e( 'Please choose the necessary post types (or single pages) where PDF & Print buttons will be displayed:', 'pdf-print' ); ?>
239 566 </td>
240 567 </tr>
241 - <tr>
242 - <th scope="row"><?php _e( 'Use the theme stylesheet or plugin default style', 'pdf-print' ); ?></th>
243 - <td>
244 - <select name="pdfprnt_use_theme_stylesheet">
245 - <option value="0" <?php if ( 0 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Default stylesheet', 'pdf-print' ); ?></option>
246 - <option value="1" <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Current theme stylesheet', 'pdf-print' ); ?></option>
247 - </select>
568 + <tr valign="top">
569 + <td colspan="2">
570 + <label>
571 + <input disabled="disabled" checked="checked" id="twttrpr_jstree_url" type="checkbox" name="twttrpr_jstree_url" value="1" />
572 + <?php _e( "Show URL for pages", 'pdf-print' );?>
573 + </label>
248 574 </td>
249 575 </tr>
250 - <tr>
251 - <th scope="row"><?php _e( 'Types of posts that will be used in the plugin', 'pdf-print' ); ?></th>
252 - <td>
253 - <select name="pdfprnt_use_types_posts[]" multiple="multiple">
254 - <?php foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1 ), 'objects' ) as $key => $value ) {
255 - if ( 'attachment' != $key ) { ?>
256 - <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $pdfprnt_options_array['use_types_posts'] ) ) echo 'selected="selected"'; ?>><?php echo $value->label; ?></option>
257 - <?php }
258 - } ?>
259 - </select>
576 + <tr valign="top">
577 + <td colspan="2">
578 + <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' ); ?>" />
260 579 </td>
261 580 </tr>
262 - </table>
263 - <table class="form-table pdfprnt_settings_table pdfprnt_buttons" style="width: auto !important;">
264 - <tr class="pdfprnt_table_head">
265 - <th scope="row"></th>
266 - <th><?php _e( 'Posts and pages', 'pdf-print' ); ?></th>
267 - <th><?php _e( 'Search and archive pages', 'pdf-print' ); ?></th>
268 - </tr>
269 - <tr class="pdfprnt_pdf_buttton">
270 - <th scope="row"><?php _e( 'Show PDF button', 'pdf-print' ); ?></th>
271 - <td>
272 - <input type="checkbox" name="pdfprnt_show_btn_pdf" <?php if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) echo 'checked="checked"'; ?> />
581 + <tr valign="top">
582 + <td colspan="2">
583 + <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
273 584 </td>
274 - <td>
275 - <input type="checkbox" name="pdfprnt_show_btn_pdf_search_archive" <?php if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) echo 'checked="checked"'; ?> />
276 - </td>
277 585 </tr>
278 - <tr class="pdfprnt_print_buttton">
279 - <th scope="row"><?php _e( 'Show Print button', 'pdf-print' ); ?></th>
280 - <td>
281 - <input type="checkbox" name="pdfprnt_show_btn_print" <?php if ( 1 == $pdfprnt_options_array['show_btn_print'] ) echo 'checked="checked"'; ?> />
282 - </td>
283 - <td>
284 - <input type="checkbox" name="pdfprnt_show_btn_print_search_archive" <?php if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) echo 'checked="checked"'; ?> />
285 - </td>
286 - </tr>
287 - <tr class="pdfprnt_position_buttton">
288 - <th scope="row"><?php _e( 'Position of buttons in the content', 'pdf-print' ); ?></th>
289 - <td>
290 - <fieldset><?php pdfprnt_display_radio( 'pdfprnt_position', $pdfprnt_options_array['position'] ); ?></fieldset>
291 - </td>
292 - <td>
293 - <fieldset><?php pdfprnt_display_radio( 'pdfprnt_position_search_archive', $pdfprnt_options_array['position_search_archive'] ); ?></fieldset>
294 - </td>
295 - </tr>
296 - </table>
297 - <div>
298 - <p>
299 - <?php _e( 'In order to use PDF and Print buttons in the custom post or page template, see', 'pdf-print' ); ?>&nbsp;<a href="http://bestwebsoft.com/products/pdf-print/faq/" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>
300 - </p>
301 - </div>
302 - <table class="form-table pdfprnt_settings_table">
303 - <tr>
304 - <th scope="row">
305 - <?php _e( 'Settings for shortcodes', 'pdf-print' ); ?>
586 + <tr valign="top">
587 + <th scope="row" colspan="2">
588 + * <?php _e( 'If you upgrade to Pro version all your settings will be saved.', 'pdf-print' ); ?>
306 589 </th>
307 - <td>
308 - <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>
309 - </td>
310 - </tr>
311 - <tr>
312 - <th scope="row"><?php _e( 'Show the print window', 'pdf-print' ); ?></th>
313 - <td>
314 - <input type="checkbox" name="pdfprnt_show_print_window" <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) echo 'checked="checked"'; ?> />
315 - </td>
316 - </tr>
317 - </table>
318 - <div class="bws_pro_version_bloc">
319 - <div class="bws_pro_version_table_bloc">
320 - <div class="bws_table_bg"></div>
321 - <table class="form-table bws_pro_version">
322 - <tr>
323 - <th scope="row"><?php _e( 'PDF files name', 'pdf-print' ); ?></th>
324 - <td>
325 - <fieldset>
326 - <label><input disabled="disabled" type="radio" name="pdfprntpr_select_file_name" value="1" /> <?php _e( 'use post or page slug', 'pdf-print' ); ?></label><br />
327 - <input type="radio" disabled="disabled" name="pdfprntpr_select_file_name" value="0" /><input disabled="disabled" type="text" name='pdfprntpr_file_name' value="mpdf" /><br />
328 - <span class="pdfprnt_info">
329 - <?php _e( 'File name cannot contain more than 195 symbols. The file name can include Latin letters, numbers and symbols "-" , "_" only.', 'pdf-print' ) ?>
330 - </span>
331 - </fieldset>
332 - </td>
333 - </tr>
334 - <tr>
335 - <th scope="row"><?php _e( 'Do not index pdf and print pages', 'pdf-print' ); ?></th>
336 - <td>
337 - <input type="checkbox" name="pdfprntpr_noindex_page" disabled="disabled" />
338 - </td>
339 - </tr>
340 - <tr valign="top">
341 - <th scope="row" colspan="2">
342 - * <?php _e( 'If you upgrade to Pro version, all your settings will be saved.', 'pdf-print' ); ?>
343 - </th>
344 - </tr>
345 - </table>
346 - </div>
347 - <div class="bws_pro_version_tooltip">
348 - <div class="bws_info">
349 - <?php _e( 'Unlock premium options by upgrading to Pro version', 'pdf-print' ); ?>
350 - </div>
351 - <a class="bws_button" 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>
352 - <div class="clear"></div>
353 - </div>
354 - </div>
355 - <input type="hidden" name="pdfprnt_form_submit" value="1" />
356 - <p class="submit">
357 - <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
358 - </p>
359 - <?php wp_nonce_field( $plugin_basename, 'pdfprnt_nonce_name' ); ?>
360 - </form>
361 - <?php bws_form_restore_default_settings( $plugin_basename );
362 - } ?>
363 - <?php } elseif ( 'extra' == $_GET['action'] ) { ?>
364 - <div class="bws_pro_version_bloc">
365 - <div class="bws_pro_version_table_bloc">
366 - <div class="bws_table_bg"></div>
367 - <div class="bws_pro_version">
368 - <p><?php _e( 'Please choose the necessary post types (or single pages), where PDF & Print buttons should be displayed:', 'pdf-print' ); ?></p>
369 - <p><label>
370 - <input disabled="disabled" checked="checked" id="twttrpr_jstree_url" type="checkbox" name="twttrpr_jstree_url" value="1" />
371 - <?php _e( "Show URL for pages", 'pdf-print' );?>
372 - </label></p>
373 - <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' ); ?>" />
374 - <p class="submit">
375 - <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
376 - </p>
377 - <p><strong>* <?php _e( 'If you upgrade to Pro version all your settings will be saved.', 'pdf-print' ); ?></strong></p>
378 - </div>
590 + </tr>
591 + </table>
379 592 </div>
380 593 <div class="bws_pro_version_tooltip">
381 594 <div class="bws_info">
382 - <?php _e( 'Unlock premium options by upgrading to Pro version', 'pdf-print' ); ?>
595 + <?php _e( 'Unlock premium options by upgrading to a PRO version.', 'pdf-print' ); ?>
596 + <a href="http://bestwebsoft.com/plugin/pdf-print-pro/?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>
383 597 </div>
384 - <a class="bws_button" 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>
598 + <a class="bws_button" href="http://bestwebsoft.com/plugin/pdf-print-pro/?k=d9da7c9c2046bed8dfa38d005d4bffdb&pn=101&v=<?php echo $pdfprnt_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>#purchase" target="_blank" title="PDF & Print Pro">
599 + <?php _e( 'Go', 'pdf-print' ); ?> <strong>PRO</strong>
600 + </a>
385 601 <div class="clear"></div>
386 602 </div>
387 603 </div>
388 - <?php } elseif ( 'templates' == $_GET['action'] ) { ?>
389 - <div class="bws_pro_version_bloc">
390 - <div class="bws_pro_version_table_bloc">
391 - <div class="bws_table_bg"></div>
392 - <?php if ( isset( $_GET['pdfprnt_tab_action'] ) && 'new' == $_GET['pdfprnt_tab_action'] ) { ?>
393 - <h2><?php _e( 'Add New template', 'pdf-print' ); ?></h2>
394 - <p class="hide-if-no-js desription"><i><?php _e( 'For more info click "Help" tab at the top of the page.', 'pdf-print' ); ?></i></p>
395 - <div id="pdfprntpr_template_page">
396 - <div id="titlediv"><div id="titlewrap"><input disabled type="text" name="pdfprntpr_template_title" size="30" value="" id="title" placeholder="<?php _e( 'Enter Template Title', 'pdf-print' ); ?>" /></div></div>
397 - <h3><span><?php _e( 'Top running title', 'pdf-print' ); ?></span></h3>
398 - <div class="postarea wp-editor-expand">
399 - <div id="wp-pdfprntpr_top-wrap" class="wp-core-ui wp-editor-wrap tmce-active">
400 - <div id="wp-pdfprntpr_top-editor-tools" class="wp-editor-tools hide-if-no-js">
401 - <div id="wp-pdfprntpr_top-media-buttons" class="wp-media-buttons">
402 - <link rel='stylesheet' id='editor-buttons-css' href='#' type='text/css' media='all' />
403 - <a disabled href="#" id="insert-media-button" class="button insert-media add_media" data-editor="pdfprntpr_top" title="<?php _e( 'Add Media', 'pdf-print' ); ?>"><span class="wp-media-buttons-icon"></span> <?php _e( 'Add Media', 'pdf-print' ); ?></a>
404 - </div>
405 - </div>
406 - <div id="wp-pdfprntpr_top-editor-container" class="wp-editor-container"><textarea disabled style="width: 100%;" class="pdfprntpr_top wp-editor-area" rows="5" autocomplete="off" name="pdfprntpr_top" id="pdfprntpr_top"></textarea></div>
407 - </div>
408 - </div>
409 - <h3><span><?php _e( 'Bottom running title', 'pdf-print' ); ?></span></h3>
410 - <div class="postarea wp-editor-expand">
411 - <div id="wp-pdfprntpr_bottom-wrap" class="wp-core-ui wp-editor-wrap tmce-active">
412 - <div id="wp-pdfprntpr_bottom-editor-tools" class="wp-editor-tools hide-if-no-js">
413 - <div id="wp-pdfprntpr_bottom-media-buttons" class="wp-media-buttons"><a disabled href="#" class="button insert-media add_media" data-editor="pdfprntpr_bottom" title="<?php _e( 'Add Media', 'pdf-print' ); ?>"><span class="wp-media-buttons-icon"></span> <?php _e( 'Add Media', 'pdf-print' ); ?></a></div>
414 - </div>
415 - <div id="wp-pdfprntpr_bottom-editor-container" class="wp-editor-container"><textarea disabled style="width: 100%;" class="pdfprntpr_bottom wp-editor-area" rows="5" autocomplete="off" name="pdfprntpr_bottom" id="pdfprntpr_bottom"></textarea></div>
416 - </div>
417 - </div>
418 - </div>
419 - <p><input disabled name="pdfprntpr_template_submit" type="submit" class="button-primary" value="<?php _e( 'Save template', 'pdf-print' ); ?>" /></p>
604 + <?php } elseif ( 'go_pro' == $_GET['action'] ) { ?>
605 + <?php if ( isset( $pro_plugin_is_activated ) && true === $pro_plugin_is_activated ) { ?>
606 + <script type="text/javascript">
607 + window.setTimeout( function() {
608 + window.location.href = 'admin.php?page=pdf-print-pro.php';
609 + }, 5000 );
610 + </script>
611 + <p><?php _e( "Congratulations! The PRO version of the plugin is successfully download and activated.", 'pdf-print' ); ?></p>
612 + <p>
613 + <?php _e( "Please, go to", 'pdf-print' ); ?> <a href="admin.php?page=pdf-print-pro.php"><?php _e( 'the setting page', 'pdf-print' ); ?></a>
614 + (<?php _e( "You will be redirected automatically in 5 seconds.", 'pdf-print' ); ?>)
615 + </p>
420 616 <?php } else { ?>
421 - <ul class='subsubsub'>
422 - <li class='all'><a class="current" href="#"><?php _e( 'All', 'pdf-print' ); ?><span class="count"> ( 2 )</span></a> |</li>
423 - <li class='trash'><a href="#"><?php _e( 'Trash', 'pdf-print' ); ?><span class="count"> ( 0 )</span></a></li>
424 - </ul>
425 - <p class="search-box">
426 - <label class="screen-reader-text" for="pdfprntpr-search-input"><?php _e( 'search', 'pdf-print' ); ?>:</label>
427 - <input disabled type="search" id="pdfprntpr-search-input" name="s" value="" />
428 - <input disabled type="submit" id="search-submit" class="button" value="<?php _e( 'search', 'pdf-print' ); ?>" />
429 - </p>
430 - <div class="tablenav top">
431 - <div class="alignleft actions bulkactions">
432 - <label for='bulk-action-selector-top' class='screen-reader-text'><?php _e( 'Select bulk action', 'pdf-print' ); ?></label>
433 - <select disabled name='action' id='bulk-action-selector-top'>
434 - <option value='-1' selected='selected'><?php _e( 'Bulk Actions', 'pdf-print' ); ?></option>
435 - <option value='trash'><?php _e( 'Trash', 'pdf-print' ); ?></option>
436 - </select>
437 - <input disabled type="submit" id="doaction" class="button action" value="<?php _e( 'Apply', 'pdf-print' ); ?>" />
438 - </div>
439 - <div class='tablenav-pages one-page'>
440 - <span class="displaying-num">2 <?php _e( 'items', 'pdf-print' ); ?></span>
441 - <span class='pagination-links'><a class='first-page disabled' title='<?php _e( 'Go to the first page', 'pdf-print' ); ?>' href='#'>&laquo;</a>
442 - <a class='prev-page disabled' title='<?php _e( 'Go to the previous page', 'pdf-print' ); ?>' href='#'>&lsaquo;</a>
443 - <span class="paging-input">
444 - <label for="current-page-selector" class="screen-reader-text"><?php _e( 'Select Page', 'pdf-print' ); ?></label>
445 - <input disabled class='current-page' id='current-page-selector' title='<?php _e( 'Current page', 'pdf-print' ); ?>' type='text' name='paged' value='1' size='1' /> <?php _e( 'of', 'pdf-print' ); ?> <span class='total-pages'>1</span>
446 - </span>
447 - <a class='next-page disabled' title='<?php _e( 'Go to the next page', 'pdf-print' ); ?>' href='#'>&rsaquo;</a>
448 - <a class='last-page disabled' title='<?php _e( 'Go to the last page', 'pdf-print' ); ?>' href='#'>&raquo;</a>
617 + <form method="post" action="admin.php?page=pdf-print.php&amp;action=go_pro">
618 + <p>
619 + <?php _e( 'You can download and activate', 'pdf-print' ); ?>
620 + <a href="http://bestwebsoft.com/plugin/pdf-print-pro/?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>
621 + <?php _e( 'version of this plugin by entering Your license key.', 'pdf-print' ); ?><br />
622 + <span style="color: #888888;font-size: 10px;">
623 + <?php _e( 'You can find your license key on your personal page Client area, by clicking on the link', 'pdf-print' ); ?>
624 + <a href="http://bestwebsoft.com/wp-login.php">http://bestwebsoft.com/wp-login.php</a>
625 + <?php _e( '(your username is the email you specify when purchasing the product).', 'pdf-print' ); ?>
449 626 </span>
450 - </div>
451 - <br class="clear" />
452 - </div>
453 - <table class="wp-list-table widefat striped templates">
454 - <thead>
455 - <tr><th scope='col' id='cb' class='manage-column column-cb check-column' style=""><label class="screen-reader-text" for="cb-select-all-1"><?php _e( 'Select All', 'pdf-print' ); ?></label><input disabled id="cb-select-all-1" type="checkbox" /></th><th scope='col' id='title' class='manage-column column-title sortable desc' style=""><a href="#"><span><?php _e( 'Title', 'pdf-print' ); ?></span><span class="sorting-indicator"></span></a></th><th scope='col' id='pdf' class='manage-column column-pdf' style="">PDF</th><th scope='col' id='print' class='manage-column column-print' style="">Print</th><th scope='col' id='date' class='manage-column column-date sortable desc' style=""><a href="#"><span><?php _e( 'Date', 'pdf-print' ); ?></span><span class="sorting-indicator"></span></a></th></tr>
456 - </thead>
457 - <tbody id="the-list" data-wp-lists='list:template'>
458 - <tr><th scope="row" class="check-column"><input disabled id="cb_2" type="checkbox" name="pdfprntpr_template_id[]" value=" 2" /></th><td class='title column-title'><strong><a href="#">Custom template</a></strong> <div class="row-actions"><span class='edit'><a href="#"><?php _e( 'Edit', 'pdf-print' ); ?></a> | </span><span class='trash'><a class="submitdelete" href="#"><?php _e( 'Trash', 'pdf-print' ); ?></a></span></div></td><td class='pdf column-pdf'><input disabled type="radio" name="pdfprntpr_template_for_pdf" value="2" /></td><td class='print column-print'><input disabled type="radio" name="pdfprntpr_template_for_print" value="2" checked="checked" /></td><td class='date column-date'>June 26, 2015</td></tr><tr><th scope="row" class="check-column"><input disabled id="cb_1" type="checkbox" name="pdfprntpr_template_id[]" value=" 1" /></th><td class='title column-title'><strong><a href="#">New template</a></strong> <div class="row-actions"><span class='edit'><a href="#"><?php _e( 'Edit', 'pdf-print' ); ?></a> | </span><span class='trash'><a class="submitdelete" href="#"><?php _e( 'Trash', 'pdf-print' ); ?></a></span></div></td><td class='pdf column-pdf'><input disabled type="radio" name="pdfprntpr_template_for_pdf" value="1" checked="checked" /></td><td class='print column-print'><input disabled type="radio" name="pdfprntpr_template_for_print" value="1" /></td><td class='date column-date'>June 25, 2015</td></tr>
459 - </tbody>
460 - <tfoot>
461 - <tr><th scope='col' class='manage-column column-cb check-column' style=""><label class="screen-reader-text" for="cb-select-all-2"><?php _e( 'Select All', 'pdf-print' ); ?></label><input disabled id="cb-select-all-2" type="checkbox" /></th><th scope='col' class='manage-column column-title sortable desc' style=""><a href="#"><span><?php _e( 'Title', 'pdf-print' ); ?></span><span class="sorting-indicator"></span></a></th><th scope='col' class='manage-column column-pdf' style="">PDF</th><th scope='col' class='manage-column column-print' style="">Print</th><th scope='col' class='manage-column column-date sortable desc' style=""><a href="#"><span><?php _e( 'Date', 'pdf-print' ); ?></span><span class="sorting-indicator"></span></a></th></tr>
462 - </tfoot>
463 - </table>
464 - <div class="tablenav bottom">
465 - <div class="alignleft actions bulkactions">
466 - <label for='bulk-action-selector-top' class='screen-reader-text'><?php _e( 'Select bulk action', 'pdf-print' ); ?></label>
467 - <select disabled name='action' id='bulk-action-selector-top'>
468 - <option value='-1' selected='selected'><?php _e( 'Bulk Actions', 'pdf-print' ); ?></option>
469 - <option value='trash'><?php _e( 'Trash', 'pdf-print' ); ?></option>
470 - </select>
471 - <input disabled type="submit" id="doaction" class="button action" value="<?php _e( 'Apply', 'pdf-print' ); ?>" />
472 - </div>
473 - <div class='tablenav-pages one-page'>
474 - <span class="displaying-num">2 <?php _e( 'items', 'pdf-print' ); ?></span>
475 - <span class='pagination-links'><a class='first-page disabled' title='<?php _e( 'Go to the first page', 'pdf-print' ); ?>' href='#'>&laquo;</a>
476 - <a class='prev-page disabled' title='<?php _e( 'Go to the previous page', 'pdf-print' ); ?>' href='#'>&lsaquo;</a>
477 - <span class="paging-input">
478 - <label for="current-page-selector" class="screen-reader-text"><?php _e( 'Select Page', 'pdf-print' ); ?></label>
479 - <input disabled class='current-page' id='current-page-selector' title='<?php _e( 'Current page', 'pdf-print' ); ?>' type='text' name='paged' value='1' size='1' /> <?php _e( 'of', 'pdf-print' ); ?> <span class='total-pages'>1</span>
480 - </span>
481 - <a class='next-page disabled' title='<?php _e( 'Go to the next page', 'pdf-print' ); ?>' href='#'>&rsaquo;</a>
482 - <a class='last-page disabled' title='<?php _e( 'Go to the last page', 'pdf-print' ); ?>' href='#'>&raquo;</a>
483 - </span>
484 - </div>
485 - <br class="clear" />
486 - </div>
487 - <?php } ?>
488 - </div>
489 - <div class="bws_pro_version_tooltip">
490 - <div class="bws_info">
491 - <?php _e( 'Unlock premium options by upgrading to PRO version.', 'pdf-print' ); ?>
492 - </div>
493 - <a class="bws_button" 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>
494 - <div class="clear"></div>
495 - </div>
496 - </div>
497 - <?php } elseif ( 'go_pro' == $_GET['action'] ) {
498 - bws_go_pro_tab( $pdfprnt_plugin_info, $plugin_basename, 'pdf-print.php', 'pdf-print-pro.php', 'pdf-print-pro/pdf-print-pro.php', 'pdf-print', 'd9da7c9c2046bed8dfa38d005d4bffdb', '101', isset( $go_pro_result['pro_plugin_is_activated'] ) );
499 - }
500 - bws_plugin_reviews_block( $pdfprnt_plugin_info['Name'], 'pdf-print' ); ?>
627 + </p>
628 + <?php if ( isset( $bstwbsftwppdtplgns_options['go_pro']['pdf-print-pro/pdf-print-pro.php']['count'] ) &&
629 + '5' < $bstwbsftwppdtplgns_options['go_pro']['pdf-print-pro/pdf-print-pro.php']['count'] &&
630 + $bstwbsftwppdtplgns_options['go_pro']['pdf-print-pro/pdf-print-pro.php']['time'] < ( time() + ( 24 * 60 * 60 ) ) ) { ?>
631 + <p>
632 + <input disabled="disabled" type="text" name="bws_license_key" value="<?php echo $bws_license_key; ?>" />
633 + <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Go!', 'pdf-print' ); ?>" />
634 + </p>
635 + <p>
636 + <?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'pdf-print' ); ?>
637 + </p>
638 + <?php } else { ?>
639 + <p>
640 + <input type="text" name="bws_license_key" value="<?php echo $bws_license_key; ?>" />
641 + <input type="hidden" name="bws_license_plugin" value="pdf-print-pro/pdf-print-pro.php" />
642 + <input type="hidden" name="bws_license_submit" value="submit" />
643 + <input type="submit" class="button-primary" value="<?php _e( 'Go!', 'pdf-print' ); ?>" />
644 + <?php wp_nonce_field( plugin_basename(__FILE__), 'bws_license_nonce_name' ); ?>
645 + </p>
646 + <?php } ?>
647 + </form>
648 + <?php }
649 + } ?>
501 650 </div>
502 651 <?php }
503 652 }
504 653
505 654 /* Positioning buttons in the page */
506 -if ( ! function_exists( 'pdfprnt_content' ) ) {
655 +if( ! function_exists( 'pdfprnt_content' ) ) {
507 656 function pdfprnt_content( $content ) {
508 - if ( is_admin() )
509 - return;
510 657 global $pdfprnt_options_array, $post;
511 - if ( is_search() || is_archive() || is_category() || is_tax() || is_tag() || is_author() || ! in_array( $post->post_type, $pdfprnt_options_array['use_types_posts'] ) ) // Check for existence the type of posts.
658 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) // Check for existence the type of posts.
512 659 return $content;
513 - if ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) {
660 + if ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) {
661 + $position = ( 'top-left' == $pdfprnt_options_array['position'] || 'top-right' == $pdfprnt_options_array['position'] ) ? true : false;
514 662 $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position'] . '">';
515 663 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) {
516 664 if ( ! is_front_page () )
517 665 $permalink = add_query_arg( 'print' , 'pdf' , get_permalink( $post->ID ) );
518 666 else
519 - $permalink = add_query_arg( 'print' , 'pdf' , get_permalink() . '?page_id=' . $post->ID );
667 + $permalink = add_query_arg( 'print' , 'pdf' , get_permalink() . '?page-id=' . $post->ID );
520 668 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="View PDF" /></a>';
521 669 }
522 670 if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
523 671 if ( ! is_front_page () )
@@ -522,19 +670,18 @@
522 670 if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
523 671 if ( ! is_front_page () )
524 672 $permalink = add_query_arg( 'print' , 'print' , get_permalink( $post->ID ) );
525 673 else
526 - $permalink = add_query_arg( 'print' , 'print' , get_permalink() . '?page_id=' . $post->ID );
674 + $permalink = add_query_arg( 'print' , 'print' , get_permalink() . '?page-id=' . $post->ID );
527 675 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
528 676 }
529 677 $str .= '</div>';
530 -
531 - if ( 'top-left' == $pdfprnt_options_array['position'] || 'top-right' == $pdfprnt_options_array['position'] )
678 + if ( $position )
532 679 $content = $str . $content;
533 - elseif ( 'bottom-left' == $pdfprnt_options_array['position'] || 'bottom-right' == $pdfprnt_options_array['position'] )
680 + else
534 681 $content = $content . $str;
535 - else
536 - $content = $str . $content . $str;
682 + unset( $position );
683 + unset( $str );
537 684 }
538 685 return $content;
539 686 }
540 687 }
@@ -539,181 +686,148 @@
539 686 }
540 687 }
541 688
542 689 /* Output buttons for search or archive pages */
543 -if ( ! function_exists( 'pdfprnt_show_buttons_search_archive' ) ) {
544 - function pdfprnt_show_buttons_search_archive( $content ) {
545 - global $wp_query;
546 - /* make sure that we display pdf/print buttons only with main loop */
547 - if ( is_main_query() && $content === $wp_query ) {
548 - global $pdfprnt_options_array, $wp, $posts, $pdfprnt_show_archive_start, $pdfprnt_show_archive_end;
549 - $loop_position = current_filter();
550 - if ( ! ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] || 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) )
551 - return;
552 - /* Check for existence the type of posts. */
553 - $is_return = true;
554 - foreach ( $posts as $post ) {
555 - if ( in_array( $post->post_type, $pdfprnt_options_array['use_types_posts'] ) ) {
556 - $is_return = false;
557 - break;
558 - }
690 +if( ! function_exists( 'pdfprnt_show_buttons_search_archive' ) ) {
691 + function pdfprnt_show_buttons_search_archive() {
692 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wp, $posts;
693 + if ( 0 < $pdfprnt_output_count_buttons )
694 + return;
695 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_search_archive'] && 1 !== $pdfprnt_options_array['show_btn_print_search_archive'] )
696 + return;
697 + if ( ( ! is_search() && ! is_archive() ) || ( is_category() || ! have_posts() ) )
698 + return;
699 + /* Check for existence the type of posts. */
700 + $is_return = true;
701 + foreach ( $posts as $post ) {
702 + if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
703 + $is_return = false;
704 + break;
559 705 }
560 - if ( $is_return )
561 - return;
562 -
563 - if ( ( 'loop_start' == $loop_position && $pdfprnt_show_archive_start == 1 ) || ( 'loop_end' == $loop_position && $pdfprnt_show_archive_end == 1 ) )
564 - return;
565 -
566 - $current_url = ( empty( $wp->request ) ) ? add_query_arg( $wp->query_string, '', home_url() ) : home_url( $wp->request );
567 -
568 - $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position_search_archive'] . '">';
569 - if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) {
570 - $permalink = add_query_arg( 'print' , 'pdf-search' , $current_url );
571 - $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
572 - }
573 - if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) {
574 - $permalink = add_query_arg( 'print' , 'print-search' , $current_url );
575 - $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
576 - }
577 - $str .= '</div>';
578 - echo $str;
579 - if ( 'loop_start' == $loop_position )
580 - $pdfprnt_show_archive_start++;
581 - elseif ( 'loop_end' == $loop_position )
582 - $pdfprnt_show_archive_end++;
583 706 }
707 + if ( $is_return )
708 + return;
709 + $pdfprnt_output_count_buttons++;
710 + if ( empty( $wp->request ) )
711 + $current_url = add_query_arg( $wp->query_string, '', home_url() );
712 + else
713 + $current_url = home_url( $wp->request );
714 + $str = '<div class="' . $pdfprnt_options_array['position_search_archive'] . '">';
715 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) {
716 + $permalink = add_query_arg( 'print' , 'pdf-page' , $current_url );
717 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
718 + }
719 + if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) {
720 + $permalink = add_query_arg( 'print' , 'print-page' , $current_url );
721 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
722 + }
723 + $str .= '</div>';
724 + unset( $current_url );
725 + unset( $permalink );
726 + echo $str;
584 727 }
585 728 }
586 -
587 -/**
588 - * Add buttons before or after the loop
589 - */
590 729 if ( ! function_exists( 'pdfprnt_auto_show_buttons_search_archive' ) ) {
591 730 function pdfprnt_auto_show_buttons_search_archive() {
592 - if ( is_search() || is_archive() || is_category() || is_tax() || is_tag() || is_author() ) {
593 - global $pdfprnt_options_array, $pdfprnt_show_archive_start, $pdfprnt_show_archive_end;
594 - $pdfprnt_show_archive_start = $pdfprnt_show_archive_end = 0;
595 - if ( in_array( $pdfprnt_options_array['position_search_archive'], array( 'top-left', 'top-right' ) ) ) {
596 - add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
597 - } elseif ( in_array( $pdfprnt_options_array['position_search_archive'], array( 'bottom-left', 'bottom-right' ) ) ) {
598 - add_action( 'loop_end', 'pdfprnt_show_buttons_search_archive' );
599 - } else {
600 - add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
601 - add_action( 'loop_end', 'pdfprnt_show_buttons_search_archive' );
602 - }
603 - }
731 + if ( is_archive() || is_search() )
732 + add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
604 733 }
734 + add_action( 'wp_head', 'pdfprnt_auto_show_buttons_search_archive' );
605 735 }
606 736
607 -/**
608 - * Output buttons of page for BWS Portfolio plugin
609 - * @deprecated since 1.8.4
610 - */
737 +/* Output buttons of page for BWS Portfolio plugin */
611 738 if( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio' ) ) {
612 739 function pdfprnt_show_buttons_for_bws_portfolio() {
613 - return pdfprnt_show_buttons_for_custom_post_type();
740 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wp;
741 + if ( 0 < $pdfprnt_output_count_buttons )
742 + return;
743 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
744 + return;
745 + if ( ! in_array( 'portfolio', $pdfprnt_options_array['use_types_posts'] ) )
746 + return;
747 + $pdfprnt_output_count_buttons++;
748 + if ( empty( $wp->request ) )
749 + $current_url = add_query_arg( $wp->query_string, '', home_url() );
750 + else
751 + $current_url = home_url( $wp->request );
752 + $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
753 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
754 + $permalink = add_query_arg( 'print' , 'pdf-portfolio-page' , $current_url );
755 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
756 + }
757 + if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
758 + $permalink = add_query_arg( 'print' , 'print-portfolio-page' , $current_url );
759 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
760 + }
761 + $str .= '</div>';
762 + unset( $current_url );
763 + unset( $permalink );
764 + return $str;
614 765 }
615 766 }
616 767
617 -/**
618 - * Output buttons of post for BWS Portfolio plugin
619 - * @deprecated since 1.8.4
620 - */
768 +/* Output buttons of post for BWS Portfolio plugin */
621 769 if ( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio_post' ) ) {
622 770 function pdfprnt_show_buttons_for_bws_portfolio_post() {
623 - return pdfprnt_show_buttons_for_custom_post_type();
771 + global $pdfprnt_options_array, $post;
772 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
773 + return;
774 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
775 + return;
776 + $current_url = get_permalink();
777 + $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
778 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
779 + $permalink = add_query_arg( 'print' , 'pdf-portfolio' , $current_url );
780 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
781 + }
782 + if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
783 + $permalink = add_query_arg( 'print' , 'print-portfolio' , $current_url );
784 + $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
785 + }
786 + $str .= '</div>';
787 + unset( $current_url );
788 + unset( $permalink );
789 + return $str;
624 790 }
625 791 }
626 792
627 -
628 -/**
629 - * Display plugin buttons via action call
630 - * @param string $where where to display
631 - * @param mixed $user_query WP_Query parameters
632 - */
633 -if ( ! function_exists( 'pdfprnt_display_plugin_butttons' ) ) {
634 - function pdfprnt_display_plugin_butttons( $where = 'top', $user_query = '' ) {
635 - global $pdfprnt_options_array;
636 - if ( preg_match( "|" . $where . "|", $pdfprnt_options_array['position'] ) || empty( $where ) )
637 - echo pdfprnt_show_buttons_for_custom_post_type( $user_query );
638 - }
639 -}
640 -
641 793 /* Output buttons of page for custom post type */
642 794 if ( ! function_exists( 'pdfprnt_show_buttons_for_custom_post_type' ) ) {
643 - function pdfprnt_show_buttons_for_custom_post_type( $user_query = '' ) {
644 - global $pdfprnt_options_array, $post, $wp, $posts;
645 - if (
646 - /* not display anything if displaying buttons for post and pages is disabled */
647 - ( ! ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) ) ||
648 - /* not display anything if we have wrong $user_query */
649 - ( ! ( is_array( $user_query ) || is_string( $user_query ) ) )
650 - )
795 + function pdfprnt_show_buttons_for_custom_post_type( $custom_query ) {
796 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons;
797 + if ( 0 < $pdfprnt_output_count_buttons )
651 798 return;
652 -
799 + if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
800 + return;
801 + if ( ! is_array( $custom_query ) && ! is_string( $custom_query ) )
802 + return;
803 + $custom_query = new WP_Query( $custom_query );
804 + /* Check for existence the type of posts. */
653 805 $is_return = true;
654 - if ( empty( $user_query ) ) { /* set necessary values of parameters for pdf/print buttons */
655 - $current_url = empty( $wp->request ) ? add_query_arg( $wp->query_string, '', home_url() ) : home_url( $wp->request );
656 - $nothing_else = false;
657 - if ( is_search() || is_archive() || is_category() || is_tax() || is_tag() || is_author() ) { /* search, cattegories, archives */
658 - foreach ( $posts as $value ) {
659 - if ( in_array( $value->post_type, $pdfprnt_options_array['use_types_posts'] ) ) {
660 - $is_return = false;
661 - break;
662 - }
663 - }
664 - if ( $is_return )
665 - return;
666 - $pdf_query_parameter = 'pdf-search';
667 - $print_query_parameter = 'print-search';
668 - } elseif ( is_page() ) { /* pages */
669 - if ( in_array( 'page', $pdfprnt_options_array['use_types_posts'] ) ) {
670 - $nothing_else = true;
671 - } else {
672 - return;
673 - }
674 - } elseif ( is_single() ) { /* posts */
675 - $post_type = get_post_type( $post->ID );
676 - if ( in_array( $post_type, $pdfprnt_options_array['use_types_posts'] ) ) {
677 - $nothing_else = true;
678 - } else {
679 - return;
680 - }
681 - } else {
682 - $nothing_else = true;
683 - }
684 - if ( $nothing_else ) {
685 - $pdf_query_parameter = 'pdf';
686 - $print_query_parameter = 'print';
806 + foreach ( $custom_query->posts as $post ) {
807 + if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
808 + $is_return = false;
809 + break;
687 810 }
688 - } else {
689 - $custom_query = new WP_Query( $user_query );
690 - $current_url = add_query_arg( $custom_query->query, '', home_url() );
691 - /* Check for existence the type of posts. */
692 - if ( ! empty( $custom_query->posts) ) {
693 - foreach ( $custom_query->posts as $post ) {
694 - if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
695 - $is_return = false;
696 - break;
697 - }
698 - }
699 - }
700 - if ( $is_return )
701 - return;
702 - $pdf_query_parameter = 'pdf-custom';
703 - $print_query_parameter = 'print-custom';
704 811 }
705 -
706 - $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position'] . '">';
707 - if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) {
708 - $permalink = add_query_arg( 'print' , $pdf_query_parameter , $current_url );
812 + if ( $is_return )
813 + return;
814 + $pdfprnt_output_count_buttons++;
815 + $current_url = add_query_arg( $custom_query->query, '', home_url() );
816 + $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
817 + if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
818 + $permalink = add_query_arg( 'print' , 'pdf-custom-page' , $current_url );
709 819 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
710 820 }
711 - if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
712 - $permalink = add_query_arg( 'print' , $print_query_parameter , $current_url );
821 + if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
822 + $permalink = add_query_arg( 'print' , 'print-custom-page' , $current_url );
713 823 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
714 824 }
715 825 $str .= '</div>';
826 + unset( $current_url );
827 + unset( $permalink );
828 + unset( $is_return );
829 + unset( $custom_query );
716 830 return $str;
717 831 }
718 832 }
719 833
@@ -719,14 +833,12 @@
719 833
720 834 /* Add links */
721 835 if ( ! function_exists( 'pdfprnt_action_links' ) ) {
722 836 function pdfprnt_action_links( $links, $file ) {
723 - if ( ! is_network_admin() ) {
724 - $base = plugin_basename( __FILE__ );
725 - if ( $file == $base ) {
726 - $settings_link = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
727 - array_unshift( $links, $settings_link );
728 - }
837 + $base = plugin_basename( __FILE__ );
838 + if ( $file == $base ) {
839 + $settings_link = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
840 + array_unshift( $links, $settings_link );
729 841 }
730 842 return $links;
731 843 }
732 844 }
@@ -735,10 +847,9 @@
735 847 if ( ! function_exists( 'pdfprnt_links' ) ) {
736 848 function pdfprnt_links( $links, $file ) {
737 849 $base = plugin_basename( __FILE__ );
738 850 if ( $file == $base ) {
739 - if ( ! is_network_admin() )
740 - $links[] = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
851 + $links[] = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
741 852 $links[] = '<a href="http://wordpress.org/plugins/pdf-print/faq/" target="_blank">' . __( 'FAQ', 'pdf-print' ) . '</a>';
742 853 $links[] = '<a href="http://support.bestwebsoft.com">' . __( 'Support', 'pdf-print' ) . '</a>';
743 854 }
744 855 return $links;
@@ -753,72 +864,216 @@
753 864 wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style_wp_before_3.8.css', __FILE__ ) );
754 865 else
755 866 wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
756 867
757 - if ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] ) {
868 + if ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] )
758 869 wp_enqueue_script( 'pdfprnt_script', plugins_url( 'js/script.js', __FILE__ ) );
759 - wp_localize_script( 'pdfprnt_script', 'pdfprnt_var', array(
760 - 'loading_fonts' => __( 'Loading of fonts. It might take a several minutes', 'pdf-print' ),
761 - 'ajax_nonce' => wp_create_nonce( 'pdfprnt_ajax_nonce' ),
762 - )
763 - );
764 - }
765 870 }
766 871 }
767 -/* Remove inline 'font-family' and 'font' styles from content */
768 -if ( ! function_exists( 'pdfprnt_preg_replace' ) ) {
769 - function pdfprnt_preg_replace( $patterns, $content ) {
770 - foreach( $patterns as $pattern ) {
771 - $content = preg_replace( "/" . $pattern . "(.*?);/", "", $content );
772 - preg_match_all( "~style=(\"\'?)~", $content, $quotes );/* get array with quotes */
773 - if ( isset( $quotes[1] ) && ! empty( $quotes[1] ) ) {
774 - foreach ( $quotes[1] as $quote ) {
775 - preg_match_all( "~style=" . $quote . "(.*?)" . $quote . "~", $content, $styles );
776 - if ( ! empty( $styles[1] ) ) {
777 - foreach ( $styles[1] as $style ) {
778 - if ( preg_match( "/" . $pattern . "/", $style ) )
779 - $content = preg_replace( "/" . $style . "/", "", $content );
872 +
873 +/* Generate templates for pdf file or print */
874 +if ( ! function_exists( 'pdfprnt_generate_template' ) ) {
875 + function pdfprnt_generate_template( $content, $template = false, $isprint = false ) {
876 + global $pdfprnt_options_array;
877 + $tmpl = isset( $_GET['tmpl'] ) ? $_GET['tmpl'] : "";
878 + ob_start(); /* Starting output buffering */
879 + ?>
880 + <html>
881 + <head>
882 + <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) : ?>
883 + <link type="text/css" rel="stylesheet" href="<?php echo get_bloginfo( 'stylesheet_url' ); ?>" media="all" />
884 + <?php else: ?>
885 + <link type="text/css" rel="stylesheet" href="<?php echo plugins_url( 'css/default.css', __FILE__ ); ?>" media="all" />
886 + <?php endif;
887 + if ( ! $template )
888 + $template = $pdfprnt_options_array['tmpl_post'];
889 + switch ( $template ) { /* Using template choosed on settings page */
890 + case 1: /* Allign left template */
891 + ?>
892 + <style type="text/css">
893 + h1, h2, h3, h4, h5, h6 {
894 + text-align: left;
895 + }
896 + img {
897 + float: right;
898 + }
899 + </style>
900 + <?php
901 + break;
902 + case 2: /* Allign center template */
903 + ?>
904 + <style type="text/css">
905 + h1, h2, h3, h4, h5, h6 {
906 + text-align: center;
907 + }
908 + img {
909 + float: left;
910 + }
911 + </style>
912 + <?php
913 + break;
914 + case 3: /* Allign right template */
915 + ?>
916 + <style type="text/css">
917 + h1, h2, h3, h4, h5, h6 {
918 + text-align: right;
919 + }
920 + img {
921 + float: left;
922 + }
923 + </style>
924 + <?php
925 + break;
780 926 }
781 -
782 - }
783 - }
927 + switch ( $tmpl ) { /* If got something by GET (from admin bar) */
928 + case 1: /* Allign left template */
929 + ?>
930 + <style type="text/css">
931 + h1, h2, h3, h4, h5, h6 {
932 + text-align: left;
933 + }
934 + img {
935 + float: right;
936 + }
937 + </style>
938 + <?php
939 + break;
940 + case 2: /* Allign center template */
941 + ?>
942 + <style type="text/css">
943 + h1, h2, h3, h4, h5, h6 {
944 + text-align: center;
945 + }
946 + img {
947 + float: left;
948 + }
949 + </style>
950 + <?php
951 + break;
952 + case 3: /* Allign right template */
953 + ?>
954 + <style type="text/css">
955 + h1, h2, h3, h4, h5, h6 {
956 + text-align: right;
957 + }
958 + img {
959 + float: left;
960 + }
961 + </style>
962 + <?php break;
963 + }
964 + if ( $isprint ) : ?>
965 + <script type="text/javascript" src="<?php echo plugins_url( 'js/pdfprnt.print.js', __FILE__ ); ?>"></script>
966 + <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) {
967 + echo '<script>window.onload = function(){ window.print(); };</script>'; } ?>
968 + <?php endif; ?>
969 + </head>
970 + <body>
971 + <?php echo $content; ?>
972 + </body>
973 + </html>
974 + <?php
975 + $html = ob_get_contents(); /* Getting output buffering */
976 + ob_end_clean(); /* Closing output buffering */
977 + return $html; /* Now we done with template */
978 + }
979 +}
980 +
981 +if ( ! function_exists( 'pdfprnt_generate_template_for_bws_portfolio' ) ) {
982 + function pdfprnt_generate_template_for_bws_portfolio() {
983 + global $post;
984 + ob_start(); /* Starting output buffering */
985 + $portfolio_options = get_option( 'prtfl_options' );
986 + $meta_values = get_post_custom( $post->ID );
987 + $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
988 + if( empty ( $post_thumbnail_id ) ) {
989 + $args = array(
990 + 'post_parent' => $post->ID,
991 + 'post_type' => 'attachment',
992 + 'post_mime_type' => 'image',
993 + 'numberposts' => 1
994 + );
995 + $attachments = get_children( $args );
996 + $post_thumbnail_id = key( $attachments );
997 + }
998 + $image = wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
999 + $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
1000 + $image_desc = get_post( $post_thumbnail_id );
1001 + $image_desc = $image_desc->post_content;
1002 + if ( '1' == get_option( 'prtfl_postmeta_update' ) ) {
1003 + $post_meta = get_post_meta( $post->ID, 'prtfl_information', true );
1004 + $date_compl = $post_meta['_prtfl_date_compl'];
1005 + if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
1006 + $date_compl = explode( '/', $date_compl );
1007 + $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
784 1008 }
785 - }
786 - return $content;
1009 + $link = $post_meta['_prtfl_link'];
1010 + $short_descr = $post_meta['_prtfl_short_descr'];
1011 + } else {
1012 + $date_compl = get_post_meta( $post->ID, '_prtfl_date_compl', true );
1013 + if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
1014 + $date_compl = explode( '/', $date_compl );
1015 + $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
1016 + }
1017 + $link = get_post_meta( $post->ID, '_prtfl_link', true);
1018 + $short_descr = $post_meta['_prtfl_short_descr'];
1019 + } ?>
1020 + <img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" alt="<?php echo $image_alt; ?>" />
1021 + <div>
1022 + <p>
1023 + <strong><?php _e( 'Date of completion', 'pdf-print' ); ?>:</strong> <?php echo $date_compl; ?><br/>
1024 + <strong><?php _e( 'Link', 'pdf-print' ); ?>:</strong> <a href="<?php echo $link; ?>"><?php echo $link; ?></a><br/>
1025 + <strong><?php _e( 'Description', 'pdf-print' ); ?>:</strong> <?php echo $short_descr; ?><br/>
1026 + </p>
1027 + </div>
1028 + <?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' );
1029 + if ( is_array( $terms ) && count( $terms ) > 0 ) { ?>
1030 + <div style="clear:both;">
1031 + <strong><?php _e( 'Technologies', 'pdf-print' ); ?>: </strong>
1032 + <?php $count = 0;
1033 + foreach ( $terms as $term ) {
1034 + if( 0 < $count )
1035 + echo ', ';
1036 + echo '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>';
1037 + $count++;
1038 + } ?>
1039 + </div>
1040 + <?php }
1041 + $content = ob_get_contents(); /* Getting output buffering */
1042 + ob_end_clean(); /* Closing output buffering */
1043 + return $content; /* Now we done with template */
787 1044 }
788 1045 }
789 1046
790 -/* Generate templates for pdf file or print */
791 -if ( ! function_exists( 'pdfprnt_generate_template' ) ) {
792 - function pdfprnt_generate_template( $content, $isprint = false ) {
793 - global $pdfprnt_options_array;
794 - $html =
795 - '<html>
796 - <head>';
797 - if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) {
798 - /* remove 'font-family' and 'font' styles from theme css-file if additional fonts not loaded */
799 - if ( 0 == $pdfprnt_options_array['additional_fonts'] ) {
800 - $css = file_get_contents( get_bloginfo( 'stylesheet_url' ) );
801 - if ( ( ! empty( $css ) ) )
802 - $html .= '<style type="text/css">' . preg_replace( "/(font:(.*?);)|(font-family(.*?);)/", "", $css ) . '</style>';
803 - } else {
804 - $html .= '<link type="text/css" rel="stylesheet" href="' . get_bloginfo( 'stylesheet_url' ) . '" media="all" />';
805 - }
806 - } else {
807 - $html .= '<link type="text/css" rel="stylesheet" href="' . plugins_url( 'css/default.css', __FILE__ ) . '" media="all" />';
808 - }
809 - if ( $isprint && 1 == $pdfprnt_options_array['show_print_window'] )
810 - $html .= '<script>window.onload = function(){ window.print(); };</script>';
811 - $html .=
812 - '</head>
813 - <body>';
814 - /* Remove inline 'font-family' and 'font' styles from content */
815 - if ( 0 == $pdfprnt_options_array['additional_fonts'] )
816 - $content = pdfprnt_preg_replace( array( "font-family", "font:" ), $content );
817 - $html .= apply_filters( 'bwsplgns_get_pdf_print_content', $content ) .
818 - '</body>
819 - </html>';
820 - return $html;
1047 +/* Generate query posts for Portfolio plugin */
1048 +if ( ! function_exists( 'generate_query_posts_for_portfolio' ) ) {
1049 + function generate_query_posts_for_portfolio() {
1050 + global $wp_query;
1051 + $paged = isset( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1;
1052 + $technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : "";
1053 + if ( "" != $technologies ) {
1054 + $args = array(
1055 + 'post_type' => 'portfolio',
1056 + 'post_status' => 'publish',
1057 + 'posts_per_page' => get_option('posts_per_page'),
1058 + 'paged' => $paged,
1059 + 'tax_query' => array(
1060 + array(
1061 + 'taxonomy' => 'portfolio_technologies',
1062 + 'field' => 'slug',
1063 + 'terms' => $technologies
1064 + )
1065 + )
1066 + );
1067 + } else {
1068 + $args = array(
1069 + 'post_type' => 'portfolio',
1070 + 'post_status' => 'publish',
1071 + 'posts_per_page' => get_option('posts_per_page'),
1072 + 'paged' => $paged
1073 + );
1074 + }
1075 + query_posts( $args );
821 1076 }
822 1077 }
823 1078
824 1079 /* Output print page or pdf document and include plugin script */
@@ -831,87 +1086,55 @@
831 1086 add_filter( 'the_content', 'wptexturize' );
832 1087 add_filter( 'the_content', 'convert_smilies' );
833 1088 add_filter( 'the_content', 'convert_chars' );
834 1089 add_filter( 'the_content', 'wpautop' );
835 - if ( ! 0 == $pdfprnt_options_array['tmpl_shorcode'] ) {
836 - add_filter( 'the_content', 'do_shortcode' ); /* executing shortcodes on the page */
1090 + if ( 1 == $pdfprnt_options_array['tmpl_shorcode'] ) {
1091 + add_filter( 'the_content', 'do_shortcode' ); /* executing shorcodes on the page */
837 1092 } else {
838 1093 $pattern = get_shortcode_regex();
839 1094 if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) ) { /* getting all shortcodes we are using */
840 1095 foreach ( array_unique( $matches[0] ) as $value) {
841 - $post->post_content = str_replace( $value, "", $post->post_content ); /* replacing shortcodes to an empty string */
1096 + $post->post_content = str_replace( $value, "", $post->post_content ); /* replacing shorcodes to an empty string */
842 1097 }
843 1098 }
844 1099 }
845 - /* set path to directory with fonts for PDF document */
846 - if ( ! ( 0 == $pdfprnt_options_array['additional_fonts'] && defined( "_MPDF_SYSTEM_TTFONTS" ) ) ) {
847 - if ( is_multisite() ) {
848 - switch_to_blog( 1 );
849 - $upload_dir = wp_upload_dir();
850 - restore_current_blog();
851 - } else {
852 - $upload_dir = wp_upload_dir();
853 - }
854 - define( '_MPDF_SYSTEM_TTFONTS', $upload_dir['basedir'] .'/pdf-print-fonts/' );
855 - }
856 1100 switch ( $print ) {
857 1101 case 'pdf': /* Content for PDF from post */
858 1102 include ( 'mpdf/mpdf.php' );
859 - $user_info = get_userdata( $post->post_author );
860 - $default_font = 0 == $pdfprnt_options_array['additional_fonts'] ? 'dejavusansmono' : '';
861 - $mpdf = new mPDF( '+aCJK', 'A4', 0, $default_font );
862 - $mpdf->allow_charset_conversion = true;
863 - $mpdf->charset_in = get_bloginfo( 'charset' );
864 - if ( ! 0 == $pdfprnt_options_array['additional_fonts'] ) {
865 - $mpdf->autoScriptToLang = true;
866 - $mpdf->autoLangToFont = true;
867 - $mpdf->baseScript = 1;
868 - $mpdf->autoVietnamese = true;
869 - $mpdf->autoArabic = true;
870 - }
871 - if ( is_rtl() )
872 - $mpdf->SetDirectionality( 'rtl' );
1103 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1104 + $mpdf = new mPDF('+aCJK');
1105 + $user_info = get_userdata( $post->post_author );
1106 + $mpdf->SetAutoFont(AUTOFONT_ALL);
873 1107 $mpdf->SetAuthor( $user_info->display_name );
874 1108 $mpdf->SetTitle( $post->post_title );
875 1109 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
876 - $html = '<div id="content">
877 - <div class="post">
878 - <div class="entry-header"><h1 class="entry-title"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
879 - <div class="entry-content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
880 - </div>
1110 + $html = '<div class="container">
1111 + <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
1112 + <div class="content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
881 1113 </div>';
882 1114 $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
883 1115 $mpdf->Output();
1116 + unset( $user_info );
1117 + unset( $html );
1118 + unset( $mpdf );
1119 + die();
884 1120 break;
885 1121 case 'print': /* Content for printing from post */
886 - $html = '<div id="content">
887 - <div class="post">
888 - <div class="entry-header"><h1 class="entry-title">' . $post->post_title . '</h1></div><br/>
889 - <div class="entry-content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
890 - </div>
1122 + $html = '<div class="container">
1123 + <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1124 + <div class="content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
891 1125 </div>';
892 - echo pdfprnt_generate_template( $html, true );
1126 + echo pdfprnt_generate_template( $html, false, true );
1127 + unset( $html );
893 1128 die();
894 1129 break;
895 - case 'pdf-search': /* Content for PDF from archive or searching page */
1130 + case 'pdf-page': /* Content for PDF from archive or searching page */
1131 + $html = '';
896 1132 $titles = array();
897 1133 $authors = array();
898 1134 include ( 'mpdf/mpdf.php' );
899 - $user_info = get_userdata( $post->post_author );
900 - $default_font = 0 == $pdfprnt_options_array['additional_fonts'] ? 'dejavusansmono' : '';
901 - $mpdf = new mPDF( '+aCJK', 'A4', 0, $default_font );
902 - $mpdf->allow_charset_conversion = true;
903 - $mpdf->charset_in = get_bloginfo( 'charset' );
904 - if ( ! 0 == $pdfprnt_options_array['additional_fonts'] ) {
905 - $mpdf->autoScriptToLang = true;
906 - $mpdf->autoLangToFont = true;
907 - $mpdf->baseScript = 1;
908 - $mpdf->autoVietnamese = true;
909 - $mpdf->autoArabic = true;
910 - }
911 - if ( is_rtl() )
912 - $mpdf->SetDirectionality( 'rtl' );
913 - $html = '<div id="content">';
1135 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1136 + $mpdf = new mPDF('+aCJK');
914 1137 foreach ( $posts as $p ) {
915 1138 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
916 1139 continue;
917 1140 $titles[] = $p->post_title;
@@ -916,44 +1139,126 @@
916 1139 continue;
917 1140 $titles[] = $p->post_title;
918 1141 $user_info = get_userdata( $p->post_author );
919 1142 $authors[] = $user_info->display_name;
920 - $html .= '<div class="post">
921 - <div class="entry-title"><h1 class="entry-header"><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>
922 - <div class="entry-content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
923 - </div><br/><hr/><br/>';
1143 + $html .= '<div class="container">
1144 + <div class="title"><h1><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>
1145 + <div class="content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
1146 + </div><br/><hr/><br/>';
1147 + unset( $user_info );
924 1148 }
925 - $html .= '</div>';
926 1149 $titles = array_unique( $titles );
927 1150 $authors = array_unique( $authors );
1151 + $mpdf->SetAutoFont(AUTOFONT_ALL);
928 1152 $mpdf->SetTitle( implode( ',', $titles ) );
929 1153 $mpdf->SetAuthor( implode( ',', $authors ) );
930 1154 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
931 - $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
1155 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_search'] ) );
932 1156 $mpdf->Output();
1157 + unset( $authors );
1158 + unset( $titles );
1159 + unset( $html );
1160 + unset( $mpdf );
1161 + die();
933 1162 break;
934 - case 'print-search': /* Content for printing from archive or searching page */
935 - $html = '<div id="content">';
1163 + case 'print-page': /* Content for printing from archive or searching page */
1164 + $html = '';
936 1165 foreach ( $posts as $p ) {
937 1166 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
938 1167 continue;
939 - $html .= '<div class="post">
940 - <div class="entry-header"><h1 class="entry-title">' . $p->post_title . '</h1></div><br/>
941 - <div class="entry-content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
1168 + $html .= '<div class="container">
1169 + <div class="title"><h1>' . $p->post_title . '</h1></div><br/>
1170 + <div class="content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
942 1171 </div><br/><hr/><br/>';
943 1172 }
944 - $html .= '</div>';
945 - echo pdfprnt_generate_template( $html, true );
1173 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_search'], true );
1174 + unset( $html );
946 1175 die();
947 1176 break;
948 - case 'pdf-custom': /* Content for PDF from custom post */
949 - $url_data = parse_url( $_SERVER['REQUEST_URI'] );
950 - parse_str( $url_data['query'], $args );
951 - unset( $args['print'] );
952 - if ( ! empty( $args ) ) {
953 - $posts = get_posts( $args );
1177 + case 'pdf-portfolio': /* Content for PDF from portfolio post */
1178 + include ( 'mpdf/mpdf.php' );
1179 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1180 + $mpdf = new mPDF( '+aCJK' );
1181 + $user_info = get_userdata( $post->post_author );
1182 + $mpdf->SetAutoFont( AUTOFONT_ALL );
1183 + $mpdf->SetAuthor( $user_info->display_name );
1184 + $mpdf->SetTitle( $post->post_title );
1185 + $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1186 + $html = '<div class="container">
1187 + <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
1188 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1189 + </div>';
1190 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
1191 + $mpdf->Output();
1192 + unset( $html );
1193 + unset( $user_info );
1194 + unset( $mpdf );
1195 + die();
1196 + break;
1197 + case 'print-portfolio': /* Content for printing from porfolio post */
1198 + $html = '<div class="container">
1199 + <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1200 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1201 + </div>';
1202 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1203 + unset( $html );
1204 + die();
1205 + break;
1206 + case 'pdf-portfolio-page': /* Content for PDF from portfolio page */
1207 + $html = '';
1208 + $titles = array();
1209 + $authors = array();
1210 + generate_query_posts_for_portfolio();
1211 + while ( have_posts() ) {
1212 + the_post();
1213 + global $post;
1214 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
1215 + continue;
1216 + $titles[] = $post->post_title;
1217 + $user_info = get_userdata( $post->post_author );
1218 + $authors[] = $user_info->display_name;
1219 + $html .= '<div class="container">
1220 + <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
1221 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1222 + </div><br/><hr/><br/>';
1223 + unset( $user_info );
954 1224 }
955 - $html = '<div id="content">';
1225 + include ( 'mpdf/mpdf.php' );
1226 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1227 + $mpdf = new mPDF( '+aCJK' );
1228 + $titles = array_unique( $titles );
1229 + $authors = array_unique( $authors );
1230 + $mpdf->SetAutoFont( AUTOFONT_ALL );
1231 + $mpdf->SetTitle( implode( ',', $titles ) );
1232 + $mpdf->SetAuthor( implode( ',', $authors ) );
1233 + $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1234 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
1235 + $mpdf->Output();
1236 + unset( $authors );
1237 + unset( $titles );
1238 + unset( $html );
1239 + unset( $mpdf );
1240 + die();
1241 + break;
1242 + case 'print-portfolio-page': /* Content for printing from portfolio page */
1243 + generate_query_posts_for_portfolio();
1244 + $html = '';
1245 + while ( have_posts() ) {
1246 + the_post();
1247 + global $post;
1248 + if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
1249 + continue;
1250 + $html .= '<div class="container">
1251 + <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1252 + <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1253 + </div><br/><hr/><br/>';
1254 + }
1255 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1256 + unset( $html );
1257 + die();
1258 + break;
1259 + case 'pdf-custom-page': /* Content for PDF from custom post */
1260 + $html = '';
956 1261 $titles = $authors = array();
957 1262 foreach ( $posts as $p ) {
958 1263 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
959 1264 continue;
@@ -959,58 +1264,48 @@
959 1264 continue;
960 1265 $titles[] = $p->post_title;
961 1266 $user_info = get_userdata( $p->post_author );
962 1267 $authors[] = $user_info->display_name;
963 - $html .= '<div class="post">
964 - <div class="entry-header"><h1 class="entry-title"><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>
965 - <div class="entry-content">';
966 - /*if ( has_post_thumbnail( $p->ID ) )
967 - $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );*/
1268 + $html .= '<div class="container">';
1269 + $html .= '<div class="title"><h1><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>';
1270 + $html .= '<div class="content">';
1271 + if ( has_post_thumbnail( $p->ID ) )
1272 + $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );
968 1273 $html .= apply_filters( 'the_content', $p->post_content ) . '</div></div><br/><hr/><br/>';
1274 + unset( $user_info );
969 1275 }
970 - $html .= '</div>';
971 1276 include ( 'mpdf/mpdf.php' );
972 - $default_font = 0 == $pdfprnt_options_array['additional_fonts'] ? 'dejavusansmono' : '';
973 - $mpdf = new mPDF( '+aCJK', 'A4', 0, $default_font );
974 - $mpdf->allow_charset_conversion = true;
975 - $mpdf->charset_in = get_bloginfo( 'charset' );
976 - if ( ! 0 == $pdfprnt_options_array['additional_fonts'] ) {
977 - $mpdf->autoScriptToLang = true;
978 - $mpdf->autoLangToFont = true;
979 - $mpdf->baseScript = 1;
980 - $mpdf->autoVietnamese = true;
981 - $mpdf->autoArabic = true;
982 - }
983 - if ( is_rtl() )
984 - $mpdf->SetDirectionality( 'rtl' );
1277 + $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1278 + $mpdf = new mPDF( '+aCJK' );
985 1279 $titles = array_unique( $titles );
986 1280 $authors = array_unique( $authors );
1281 + $mpdf->SetAutoFont( AUTOFONT_ALL );
987 1282 $mpdf->SetTitle( implode( ',', $titles ) );
988 1283 $mpdf->SetAuthor( implode( ',', $authors ) );
989 1284 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
990 - $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
1285 + $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
991 1286 $mpdf->Output();
1287 + unset( $authors );
1288 + unset( $titles );
1289 + unset( $html );
1290 + unset( $mpdf );
1291 + die();
992 1292 break;
993 - case 'print-custom': /* Content for printing from custom post */
994 - $url_data = parse_url( $_SERVER['REQUEST_URI'] );
995 - parse_str( $url_data['query'], $args );
996 - unset( $args['print'] );
997 - if ( ! empty( $args ) ) {
998 - $posts = get_posts( $args );
999 - }
1000 - $html = '<div id="content">';
1293 + case 'print-custom-page': /* Content for printing from custom post */
1294 + $html = '';
1001 1295 foreach ( $posts as $p ) {
1002 1296 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1003 1297 continue;
1004 - $html .= '<div class="post">
1005 - <div class="entry-header"><h1 class="entry-title">' . $p->post_title . '</h1></div><br/>
1006 - <div class="entry-content">';
1007 - /*if ( has_post_thumbnail( $p->ID ) )
1008 - $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );*/
1009 - $html .= apply_filters( 'the_content', $p->post_content ) . '</div></div><br/><hr/><br/>';
1298 + $html .= '<div class="container">';
1299 + $html .= '<div class="title"><h1>' . $p->post_title . '</h1></div><br/>';
1300 + $html .= '<div class="content">';
1301 + if ( has_post_thumbnail( $p->ID ) )
1302 + $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );
1303 + $html .= apply_filters( 'the_content', $p->post_content ) . '</div>
1304 + </div><br/><hr/><br/>';
1010 1305 }
1011 - $html .= '</div>';
1012 - echo pdfprnt_generate_template( $html, true );
1306 + echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1307 + unset( $html );
1013 1308 die();
1014 1309 break;
1015 1310 }
1016 1311 }
@@ -1019,242 +1314,155 @@
1019 1314
1020 1315 /* Add query vars */
1021 1316 if ( ! function_exists( 'print_vars_callback' ) ) {
1022 1317 function print_vars_callback( $query_vars ) {
1023 - $query_vars[] = 'print';
1318 + $query_vars[] = 'print';
1319 + $query_vars[] = 'tmpl';
1024 1320 return $query_vars;
1025 1321 }
1026 1322 }
1027 1323
1028 -/**
1029 - * Class Pdfprnt_ZipArchive for extracting
1030 - * necessary folder from zip-archive
1031 - */
1032 -if ( class_exists( 'ZipArchive' ) && ! class_exists( 'Pdfprnt_ZipArchive' ) ) {
1033 - class Pdfprnt_ZipArchive extends ZipArchive {
1034 - /**
1035 - * constructor of class
1036 - */
1037 - public function extractSubdirTo( $destination, $subdir ) {
1038 - $errors = array();
1039 - $charset = get_bloginfo( 'charset' );
1040 - // Prepare dirs
1041 - $destination = str_replace( array("/", "\\"), DIRECTORY_SEPARATOR, $destination );
1042 - $subdir = str_replace( array("/", "\\"), "/", $subdir);
1043 -
1044 - if ( substr( $destination, mb_strlen( DIRECTORY_SEPARATOR, $charset ) * -1 ) != DIRECTORY_SEPARATOR )
1045 - $destination .= DIRECTORY_SEPARATOR;
1046 -
1047 - if ( substr( $subdir, -1 ) != "/" )
1048 - $subdir .= "/";
1049 - // Extract files
1050 - for ( $i = 0; $i < $this->numFiles; $i++ ) {
1051 - $filename = $this->getNameIndex( $i );
1052 -
1053 - if ( substr( $filename, 0, mb_strlen( $subdir, $charset ) ) == $subdir ) {
1054 - $relativePath = substr( $filename, mb_strlen( $subdir, $charset ) );
1055 - $relativePath = str_replace( array( "/", "\\" ), DIRECTORY_SEPARATOR, $relativePath );
1056 -
1057 - if ( mb_strlen( $relativePath, $charset ) > 0 ) {
1058 - if ( substr( $filename, -1 ) == "/" ) {
1059 - if ( ! is_dir( $destination . $relativePath ) )
1060 - if ( ! @mkdir( $destination . $relativePath, 0755, true ) )
1061 - $errors[$i] = $filename;
1062 - } else {
1063 - if ( dirname( $relativePath) != "." ) {
1064 - if ( ! is_dir( $destination . dirname( $relativePath ) ) ) {
1065 - // New dir (for file)
1066 - @mkdir( $destination . dirname( $relativePath ), 0755, true );
1067 - }
1068 - }
1069 - // New file
1070 - if ( @file_put_contents( $destination . $relativePath, $this->getFromIndex( $i ) ) === false )
1071 - $errors[$i] = $filename;
1072 - }
1073 - }
1074 - }
1324 +/* Add custom admin bar menu */
1325 +if ( ! function_exists( 'pdfprnt_admin_bar_menu' ) ) {
1326 + function pdfprnt_admin_bar_menu() {
1327 + global $pdfprnt_options_array, $wp_admin_bar, $wp, $posts;
1328 + if ( ! is_super_admin() || ! is_admin_bar_showing() || is_admin() ) /* Checking user */
1329 + return;
1330 + if ( ( ! is_search() && ! is_archive() ) || ( is_category() || ! have_posts() ) )
1331 + return;
1332 + $is_return = true;
1333 + foreach ( $posts as $post ) {
1334 + if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
1335 + $is_return = false;
1336 + break;
1075 1337 }
1076 - return $errors;
1077 1338 }
1339 + if ( $is_return )
1340 + return;
1341 + if ( empty( $wp->request ) )
1342 + $current_url = add_query_arg( $wp->query_string, '', home_url() );
1343 + else
1344 + $current_url = home_url( $wp->request );
1345 + $permalink = add_query_arg( 'print', 'pdf-page', $current_url );
1346 + $wp_admin_bar->add_menu( array(
1347 + 'id' => 'pdfprnt-bar-menu',
1348 + 'title' => '<span class="admin-bar-menu-bws-icon"></span>PDF',
1349 + 'href' => $permalink
1350 + ) );
1351 + $template_url = add_query_arg( 'tmpl', '1', $permalink ); /* Adding parametrs to link */
1352 + $wp_admin_bar->add_menu( array(
1353 + 'parent' => 'pdfprnt-bar-menu',
1354 + 'id' => 'pdfprnt-template-1',
1355 + 'title' => '<img src="' . plugins_url( 'images/template_left.jpg', __FILE__ ) . '" alt="template_left" />',
1356 + 'href' => $template_url
1357 + ) );
1358 + $template_url = add_query_arg( 'tmpl', '2', $permalink ); /* Adding parametrs to link */
1359 + $wp_admin_bar->add_menu( array(
1360 + 'parent' => 'pdfprnt-bar-menu',
1361 + 'id' => 'pdfprnt-template-2',
1362 + 'title' => '<img src="' . plugins_url( 'images/template_center.jpg', __FILE__ ) . '" alt="template_center" />',
1363 + 'href' => $template_url
1364 + ) );
1365 + $template_url = add_query_arg( 'tmpl', '3', $permalink ); /* Adding parametrs to link */
1366 + $wp_admin_bar->add_menu( array(
1367 + 'parent' => 'pdfprnt-bar-menu',
1368 + 'id' => 'pdfprnt-template-3',
1369 + 'title' => '<img src="' . plugins_url( 'images/template_right.jpg', __FILE__ ) . '" alt="template_right" />',
1370 + 'href' => $template_url
1371 + ) );
1372 + unset( $current_url );
1373 + unset( $permalink );
1374 + unset( $template_url );
1078 1375 }
1079 1376 }
1080 1377
1081 -/**
1082 - * Download Zip
1083 - */
1084 -if ( ! function_exists( 'pdfprnt_download_zip' ) ) {
1085 - function pdfprnt_download_zip( $zip_file, $upload_dir ) {
1086 - /* check permissions */
1087 - if ( is_writable( $upload_dir ) ) {
1088 - /* load ZIP-archive */
1089 - $result = array();
1090 - $fp = fopen( $zip_file, 'w+');
1091 - $curl = curl_init();
1092 - $curl_parametres = array(
1093 - CURLOPT_URL => 'http://mpdf1.com/repos/MPDF60.zip',
1094 - CURLOPT_FILE => $fp,
1095 - CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0"
1378 +if ( ! function_exists ( 'pdfprnt_plugin_banner' ) ) {
1379 + function pdfprnt_plugin_banner() {
1380 + global $hook_suffix, $pdfprnt_plugin_info;
1381 + if ( 'plugins.php' == $hook_suffix ) {
1382 + $banner_array = array(
1383 + array( 'sndr_hide_banner_on_plugin_page', 'sender/sender.php', '0.5' ),
1384 + array( 'srrl_hide_banner_on_plugin_page', 'user-role/user-role.php', '1.4' ),
1385 + array( 'pdtr_hide_banner_on_plugin_page', 'updater/updater.php', '1.12' ),
1386 + array( 'cntctfrmtdb_hide_banner_on_plugin_page', 'contact-form-to-db/contact_form_to_db.php', '1.2' ),
1387 + array( 'cntctfrmmlt_hide_banner_on_plugin_page', 'contact-form-multi/contact-form-multi.php', '1.0.7' ),
1388 + array( 'gglmps_hide_banner_on_plugin_page', 'bws-google-maps/bws-google-maps.php', '1.2' ),
1389 + array( 'fcbkbttn_hide_banner_on_plugin_page', 'facebook-button-plugin/facebook-button-plugin.php', '2.29' ),
1390 + array( 'twttr_hide_banner_on_plugin_page', 'twitter-plugin/twitter.php', '2.34' ),
1391 + array( 'pdfprnt_hide_banner_on_plugin_page', 'pdf-print/pdf-print.php', '1.7.1' ),
1392 + array( 'gglplsn_hide_banner_on_plugin_page', 'google-one/google-plus-one.php', '1.1.4' ),
1393 + array( 'gglstmp_hide_banner_on_plugin_page', 'google-sitemap-plugin/google-sitemap-plugin.php', '2.8.4' ),
1394 + array( 'cntctfrmpr_for_ctfrmtdb_hide_banner_on_plugin_page', 'contact-form-pro/contact_form_pro.php', '1.14' ),
1395 + array( 'cntctfrm_for_ctfrmtdb_hide_banner_on_plugin_page', 'contact-form-plugin/contact_form.php', '3.62' ),
1396 + array( 'cntctfrm_hide_banner_on_plugin_page', 'contact-form-plugin/contact_form.php', '3.47' ),
1397 + array( 'cptch_hide_banner_on_plugin_page', 'captcha/captcha.php', '3.8.4' ),
1398 + array( 'gllr_hide_banner_on_plugin_page', 'gallery-plugin/gallery-plugin.php', '3.9.1' )
1096 1399 );
1097 - curl_setopt_array( $curl, $curl_parametres );
1098 - if ( curl_exec( $curl ) ) {
1099 - $result['done'] = 'ok';
1100 - } else {
1101 - $result['error'] = curl_error( $curl ) . '<br />' . __( 'Check your internet connection', 'pdf-print' );
1102 - }
1103 - curl_close( $curl );
1104 - fclose( $fp );
1105 - } else {
1106 - $result['error'] = __( 'Cannot load files in to "uploads" folder. Check your permissions', 'pdf-print' );
1107 - }
1108 - return $result;
1109 - }
1110 -}
1111 -
1112 -/**
1113 - * Copy neccesary fonts to mpdf/ttfonts
1114 - * @param string $zip_file path to zip archive
1115 - */
1116 -if ( ! function_exists( 'pdfprnt_copy_fonts' ) ) {
1117 - function pdfprnt_copy_fonts( $zip_file, $upload_dir ) {
1118 - global $pdfprnt_options_array;
1119 - if ( empty( $pdfprnt_options_array ) )
1120 - $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
1121 - if ( is_multisite() )
1122 - $network_options = get_site_option( 'pdfprnt_options_array' );
1123 - $destination = $upload_dir .'/pdf-print-fonts';
1124 - if ( ! file_exists( $destination ) ) {
1125 - mkdir( $destination, 0755, true );
1126 - }
1127 - $result = array();
1128 - /* check permissions */
1129 - if ( is_writable( $destination ) ) {
1130 - $zip = new Pdfprnt_ZipArchive();
1131 - /* open zip-archive */
1132 - if ( true === $zip->open( $zip_file ) ) {
1133 - /* extract folder with fonts */
1134 - $errors = $zip->extractSubdirTo( $destination, "mpdf60/ttfonts" );
1135 - $zip->close();
1136 - /* delete zip-archive */
1137 - unlink( $zip_file );
1138 - if ( empty( $errors ) ) {
1139 - $result['done'] = __( 'Additional fonts were successfully loaded', 'pdf-print' );
1140 - $pdfprnt_options_array['additional_fonts'] = count( scandir( $destination ) );
1141 - update_option( 'pdfprnt_options_array', $pdfprnt_options_array );
1142 - if ( is_multisite() ) {
1143 - $network_options['additional_fonts'] = $pdfprnt_options_array['additional_fonts'];
1144 - update_site_option( 'pdfprnt_options_array', $network_options );
1145 - }
1146 - } else {
1147 - $result['error'] = __( 'Some errors occur during loading files', 'pdf-print' );
1400 + if ( ! $pdfprnt_plugin_info )
1401 + $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
1402 + if ( ! function_exists( 'is_plugin_active_for_network' ) )
1403 + require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
1404 + $active_plugins = get_option( 'active_plugins' );
1405 + $all_plugins = get_plugins();
1406 + $this_banner = 'pdfprnt_hide_banner_on_plugin_page';
1407 + foreach ( $banner_array as $key => $value ) {
1408 + if ( $this_banner == $value[0] ) {
1409 + global $wp_version, $bstwbsftwppdtplgns_cookie_add;
1410 + if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) {
1411 + echo '<script type="text/javascript" src="' . plugins_url( 'js/c_o_o_k_i_e.js', __FILE__ ) . '"></script>';
1412 + $bstwbsftwppdtplgns_cookie_add = true;
1413 + } ?>
1414 + <script type="text/javascript">
1415 + (function($) {
1416 + $(document).ready( function() {
1417 + var hide_message = $.cookie( "pdfprnt_hide_banner_on_plugin_page" );
1418 + if ( hide_message == "true") {
1419 + $( ".pdfprnt_message" ).css( "display", "none" );
1420 + } else {
1421 + $( ".pdfprnt_message" ).css( "display", "block" );
1422 + };
1423 + $( ".pdfprnt_close_icon" ).click( function() {
1424 + $( ".pdfprnt_message" ).css( "display", "none" );
1425 + $.cookie( "pdfprnt_hide_banner_on_plugin_page", "true", { expires: 32 } );
1426 + });
1427 + });
1428 + })(jQuery);
1429 + </script>
1430 + <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
1431 + <div class="pdfprnt_message bws_banner_on_plugin_page" style="display: none;">
1432 + <img class="pdfprnt_close_icon close_icon" title="" src="<?php echo plugins_url( 'images/close_banner.png', __FILE__ ); ?>" alt=""/>
1433 + <div class="button_div">
1434 + <a class="button" target="_blank" href="http://bestwebsoft.com/plugin/pdf-print-pro/?k=e2f2549f4d70bc4cb9b48071169d264e&pn=101&v=<?php echo $pdfprnt_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>"><?php _e( "Learn More", 'pdf-print' ); ?></a>
1435 + </div>
1436 + <div class="text">
1437 + <?php _e( "It's time to upgrade your <strong>PDF & Print</strong> to <strong>PRO</strong> version", 'pdf-print' ); ?>!<br />
1438 + <span><?php _e( 'Extend standard plugin functionality with new great options', 'pdf-print' ); ?>.</span>
1439 + </div>
1440 + <div class="icon">
1441 + <img title="" src="<?php echo plugins_url( 'images/banner.png', __FILE__ ); ?>" alt=""/>
1442 + </div>
1443 + </div>
1444 + </div>
1445 + <?php break;
1148 1446 }
1149 - } else {
1150 - $result['error'] = __( 'Some errors occur during loading files', 'pdf-print' );
1151 - }
1152 - } else {
1153 - $result['error'] = __( 'Cannot create "uploads/pdf-print-fonts" folder. Check your permissions', 'pdf-print' );
1154 - }
1155 - return $result;
1156 - }
1157 -}
1158 -
1159 -/**
1160 - * Download ZIP-archive with MPDF library,
1161 - * copy fonts to folder 'pdf-print-fons'
1162 - */
1163 -if ( ! function_exists( 'pdfprnt_load_and_copy' ) ) {
1164 - function pdfprnt_load_and_copy( $zip_file, $upload_dir ) {
1165 - if ( file_exists( $zip_file ) )
1166 - unlink( $zip_file );
1167 - /* load ZIP-archive */
1168 - $result = pdfprnt_download_zip( $zip_file, $upload_dir );
1169 - /* if ZIP-archive was download successfully */
1170 - if ( isset( $result['done'] ) )
1171 - $result = pdfprnt_copy_fonts( $zip_file, $upload_dir );
1172 - return $result;
1173 - }
1174 -}
1175 -/**
1176 - * Function to load fonts for MPDF library
1177 - */
1178 -if ( ! function_exists( 'pdfprnt_load_fonts' ) ) {
1179 - function pdfprnt_load_fonts() {
1180 - global $pdfprnt_options_array;
1181 - if ( empty( $pdfprnt_options_array ) )
1182 - $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
1183 - $ajax_request = isset( $_REQUEST['action'] ) && 'pdfprnt_load_fonts' == $_REQUEST['action'] ? true : false;
1184 - $php_request = isset( $_REQUEST['pdfprnt_action'] ) && 'pdfprnt_load_fonts' == $_REQUEST['pdfprnt_action'] ? true : false;
1185 - $verified = isset( $_REQUEST['pdfprnt_ajax_nonce'] ) && wp_verify_nonce( $_REQUEST['pdfprnt_ajax_nonce'], 'pdfprnt_ajax_nonce' ) ? true : false;
1186 - if ( ( $ajax_request || $php_request ) && $verified ) {
1187 - $result = array();
1188 - $flag = false;
1189 - /* get path to directory for ZIP-archive uploading */
1190 - if ( is_multisite() ) {
1191 - switch_to_blog( 1 );
1192 - $upload_dir = wp_upload_dir();
1193 - restore_current_blog();
1194 - } else {
1195 - $upload_dir = wp_upload_dir();
1196 - }
1197 - $zip_file = $upload_dir['basedir'] . '/MPDF60.zip';
1198 - $destination = $upload_dir['basedir'] .'/pdf-print-fonts';
1199 - if ( file_exists( $destination ) ) { /* if folder with fonts already exists */
1200 - if ( is_multisite() ) {
1201 - $network_options = get_site_option( 'pdfprnt_options_array' ); /* get network options */
1202 - if ( $network_options['additional_fonts'] == count( scandir( $destination ) ) ) { /* if all fonts was loaded successfully */
1203 - $pdfprnt_options_array['additional_fonts'] = $network_options['additional_fonts'];
1204 - update_option( 'pdfprnt_options_array', $pdfprnt_options_array ); /* update only option of current blog */
1205 - $result['done'] = __( 'Additional fonts was successfully loaded', 'pdf-print' );
1206 - } else { /* if something wrong */
1207 - $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'] ); /* load fonts */
1208 - }
1209 - } else {
1210 - $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'] ); /* load fonts */
1447 + 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] ] ) ) {
1448 + break;
1211 1449 }
1212 - } else {
1213 - mkdir( $destination, 0755, true );
1214 - $result = pdfprnt_load_and_copy( $zip_file, $upload_dir['basedir'] );
1215 - }
1216 - if ( $ajax_request )
1217 - echo json_encode( $result );
1218 - else
1219 - return $result;
1450 + }
1220 1451 }
1221 - if ( $ajax_request )
1222 - die();
1223 1452 }
1224 1453 }
1225 1454
1226 -if ( ! function_exists ( 'pdfprnt_plugin_banner' ) ) {
1227 - function pdfprnt_plugin_banner() {
1228 - global $hook_suffix, $pdfprnt_plugin_info;
1229 - if ( 'plugins.php' == $hook_suffix ) {
1230 - bws_plugin_banner( $pdfprnt_plugin_info, 'pdfprnt', 'pdf-print', 'e2f2549f4d70bc4cb9b48071169d264e', '101', '//ps.w.org/pdf-print/assets/icon-128x128.png' );
1231 - }
1232 - }
1233 -}
1234 -
1235 1455 /* Deleting plugin options on uninstalling */
1236 1456 if ( ! function_exists( 'pdfprnt_uninstall' ) ) {
1237 1457 function pdfprnt_uninstall() {
1238 - global $wpdb;
1239 - if ( is_multisite() ) {
1240 - /* Get all blog ids */
1241 - $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" );
1242 - $tables = '';
1243 - foreach ( $blogids as $blog_id ) {
1244 - switch_to_blog( $blog_id );
1245 - delete_option( 'pdfprnt_options_array' );
1246 - }
1247 - restore_current_blog();
1248 - } else {
1249 - delete_option( 'pdfprnt_options_array' );
1250 - }
1458 + delete_option( 'pdfprnt_options_array' );
1459 + delete_site_option( 'pdfprnt_options_array' );
1251 1460 }
1252 1461 }
1253 1462
1254 1463 /* Adding function to output PDF document or pirnt page */
1255 1464 add_action( 'wp', 'pdfprnt_print' );
1256 -add_action( 'wp_head', 'pdfprnt_auto_show_buttons_search_archive' );
1257 1465 /* Initialization */
1258 1466 add_action( 'init', 'pdfprnt_init' );
1259 1467 add_action( 'admin_init', 'pdfprnt_admin_init' );
1260 1468 /* Adding stylesheets */
@@ -1261,8 +1469,10 @@
1261 1469 add_action( 'admin_enqueue_scripts', 'pdfprnt_admin_head' );
1262 1470 add_action( 'wp_enqueue_scripts', 'pdfprnt_admin_head' );
1263 1471 /* Adding 'BWS Plugins' admin menu */
1264 1472 add_action( 'admin_menu', 'pdfprnt_add_pages' );
1473 +/* Add menu to bar menu WordPress */
1474 +add_action( 'admin_bar_menu', 'pdfprnt_admin_bar_menu', 1000 );
1265 1475 /* Add query vars */
1266 1476 add_filter( 'query_vars', 'print_vars_callback' );
1267 1477 /* Additional links on the plugin page */
1268 1478 add_filter( 'plugin_action_links', 'pdfprnt_action_links', 10, 2 );
@@ -1268,12 +1478,9 @@
1268 1478 add_filter( 'plugin_action_links', 'pdfprnt_action_links', 10, 2 );
1269 1479 add_filter( 'plugin_row_meta', 'pdfprnt_links', 10, 2 );
1270 1480 /* Adding buttons plugin to content */
1271 1481 add_filter( 'the_content', 'pdfprnt_content' );
1272 -/* load additional fonts */
1273 -add_action( 'wp_ajax_pdfprnt_load_fonts', 'pdfprnt_load_fonts' );
1274 1482 /* Adding banner */
1275 1483 add_action( 'admin_notices', 'pdfprnt_plugin_banner' );
1276 1484 /* Plugin uninstall function */
1277 -
1278 -add_action( 'bwsplgns_display_pdf_print_buttons', 'pdfprnt_display_plugin_butttons', 10, 2 );
1279 -register_uninstall_hook( __FILE__, 'pdfprnt_uninstall' );
1485 +register_uninstall_hook( __FILE__, 'pdfprnt_uninstall' );
1486 +?>