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

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

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