PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.7.1
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.7.1
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.1, at pdf-print.php

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