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

1,226 lines 55.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: PDF & Print by BestWebSoft
4 Plugin URI: http://bestwebsoft.com/products/
5 Description: Plugin adds PDF creation and Print button on your site.
6 Author: BestWebSoft
7 Version: 1.7.9
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 bws_add_general_menu( plugin_basename( __FILE__ ) );
32 add_submenu_page( 'bws_plugins', 'PDF & Print ' . __( 'Settings', 'pdf-print' ), 'PDF & Print', 'manage_options', "pdf-print.php", 'pdfprnt_settings_page' );
33 }
34 }
35
36 /* Init plugin */
37 if ( ! function_exists ( 'pdfprnt_init' ) ) {
38 function pdfprnt_init() {
39 global $pdfprnt_plugin_info;
40 /* Internationalization, first(!) */
41 load_plugin_textdomain( 'pdf-print', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
42
43 require_once( dirname( __FILE__ ) . '/bws_menu/bws_functions.php' );
44
45 if ( empty( $pdfprnt_plugin_info ) ) {
46 if ( ! function_exists( 'get_plugin_data' ) ) {
47 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
48 }
49 $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
50 }
51
52 /* check WordPress version */
53 bws_wp_version_check( plugin_basename( __FILE__ ), $pdfprnt_plugin_info, "3.0" );
54
55 /* Get/Register and check settings for plugin */
56 if ( ! is_admin() || ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] ) )
57 pdfprnt_settings();
58 }
59 }
60
61 if ( ! function_exists( 'pdfprnt_admin_init' ) ) {
62 function pdfprnt_admin_init() {
63 global $bws_plugin_info, $pdfprnt_plugin_info;
64
65 if ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) )
66 $bws_plugin_info = array( 'id' => '101', 'version' => $pdfprnt_plugin_info["Version"] );
67 }
68 }
69
70 /* Register settings for plugin */
71 if ( ! function_exists( 'pdfprnt_settings' ) ) {
72 function pdfprnt_settings() {
73 global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $pdfprnt_plugin_info;
74
75 if ( ! $pdfprnt_plugin_info ) {
76 if ( ! function_exists( 'get_plugin_data' ) )
77 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
78 $pdfprnt_plugin_info = get_plugin_data( __FILE__ );
79 }
80
81 /* Variable to verify performance number of once function. */
82 $pdfprnt_output_count_buttons = 0;
83 $pdfprnt_default_post_types = array();
84 /* Default post types of WordPress. */
85 foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1, '_builtin' => true ), 'names' ) as $value )
86 $pdfprnt_default_post_types[] = $value;
87
88 $pdfprnt_options_array_defaults = array(
89 'plugin_option_version' => $pdfprnt_plugin_info["Version"],
90 'position' => 'top-right',
91 'position_search_archive' => 'pdfprnt-left',
92 'position_custom' => 'pdfprnt-left',
93 'show_btn_print' => 1,
94 'show_btn_pdf' => 1,
95 'show_btn_print_search_archive' => 1,
96 'show_btn_pdf_search_archive' => 1,
97 'show_btn_print_custom' => 1,
98 'show_btn_pdf_custom' => 1,
99 'use_theme_stylesheet' => 0,
100 'tmpl_post' => 1,
101 'tmpl_search' => 1,
102 'tmpl_custom' => 1,
103 'tmpl_shorcode' => 1,
104 'use_types_posts' => $pdfprnt_default_post_types,
105 'show_print_window' => 0
106 );
107
108 if ( ! get_option( 'pdfprnt_options_array' ) )
109 add_option( 'pdfprnt_options_array', $pdfprnt_options_array_defaults );
110
111 $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
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 /* Add admin page */
122 if ( ! function_exists ( 'pdfprnt_settings_page' ) ) {
123 function pdfprnt_settings_page () {
124 global $pdfprnt_options_array, $wp_version, $pdfprnt_plugin_info, $bstwbsftwppdtplgns_options;
125 $message = $error = "";
126 $plugin_basename = plugin_basename( __FILE__ );
127 $pdfprnt_positions_values = array(
128 'top-left' => __( 'Top Left', 'pdf-print' ),
129 'top-right' => __( 'Top Right', 'pdf-print' ),
130 'bottom-left' => __( 'Bottom Left', 'pdf-print' ),
131 'bottom-right' => __( 'Bottom Right', 'pdf-print' )
132 );
133
134 if ( ! function_exists( 'get_plugins' ) )
135 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
136 $all_plugins = get_plugins();
137
138 if ( isset( $_REQUEST['pdfprnt_position'] ) &&
139 isset( $_REQUEST['pdfprnt_position_search_archive'] ) &&
140 isset( $_REQUEST['pdfprnt_position_custom'] ) &&
141 isset( $_REQUEST['pdfprnt_use_theme_stylesheet'] ) &&
142 isset( $_REQUEST['pdfprnt_tmpl_post'] ) &&
143 isset( $_REQUEST['pdfprnt_tmpl_custom'] ) &&
144 isset( $_REQUEST['pdfprnt_tmpl_search'] ) &&
145 check_admin_referer( $plugin_basename, 'pdfprnt_nonce_name' ) ) {
146 $pdfprnt_options_array['position'] = $_REQUEST['pdfprnt_position'];
147 $pdfprnt_options_array['position_search_archive'] = $_REQUEST['pdfprnt_position_search_archive'];
148 $pdfprnt_options_array['position_custom'] = $_REQUEST['pdfprnt_position_custom'];
149 $pdfprnt_options_array['tmpl_post'] = $_REQUEST['pdfprnt_tmpl_post'];
150 $pdfprnt_options_array['tmpl_search'] = $_REQUEST['pdfprnt_tmpl_search'];
151 $pdfprnt_options_array['tmpl_custom'] = $_REQUEST['pdfprnt_tmpl_custom'];
152 $pdfprnt_options_array['use_theme_stylesheet'] = $_REQUEST['pdfprnt_use_theme_stylesheet'];
153 $pdfprnt_options_array['show_btn_pdf'] = isset( $_REQUEST['pdfprnt_show_btn_pdf'] ) ? 1 : 0;
154 $pdfprnt_options_array['show_btn_print'] = isset( $_REQUEST['pdfprnt_show_btn_print'] ) ? 1 : 0;
155 $pdfprnt_options_array['show_btn_pdf_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_search_archive'] ) ? 1 : 0;
156 $pdfprnt_options_array['show_btn_print_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_print_search_archive'] ) ? 1 : 0;
157 $pdfprnt_options_array['show_btn_pdf_custom'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_custom'] ) ? 1 : 0;
158 $pdfprnt_options_array['show_btn_print_custom'] = isset( $_REQUEST['pdfprnt_show_btn_print_custom'] ) ? 1 : 0;
159 $pdfprnt_options_array['tmpl_shorcode'] = isset( $_REQUEST['pdfprnt_tmpl_shorcode'] ) ? 1 : 0;
160 $pdfprnt_options_array['show_print_window'] = isset( $_REQUEST['pdfprnt_show_print_window'] ) ? 1 : 0;
161 $pdfprnt_options_array['use_types_posts'] = isset( $_REQUEST['pdfprnt_use_types_posts'] ) ? $_REQUEST['pdfprnt_use_types_posts'] : array();
162 update_option ( 'pdfprnt_options_array', $pdfprnt_options_array );
163 $message = __( 'Settings saved.', 'pdf-print' );
164 }
165 /* GO PRO */
166 if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) {
167 $go_pro_result = bws_go_pro_tab_check( $plugin_basename );
168 if ( ! empty( $go_pro_result['error'] ) )
169 $error = $go_pro_result['error'];
170 } ?>
171 <div class="wrap">
172 <div class="icon32 icon32-bws" id="icon-options-general"></div>
173 <h2><?php _e( 'PDF & Print Settings', 'pdf-print' ); ?></h2>
174 <h2 class="nav-tab-wrapper">
175 <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>
176 <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>
177 <a class="nav-tab" href="http://bestwebsoft.com/products/pdf-print/faq/" target="_blank"><?php _e( 'FAQ', 'pdf-print' ); ?></a>
178 <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>
179 </h2>
180 <div class="updated fade" <?php if ( empty( $message ) || "" != $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?></strong></p></div>
181 <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>
182 <div class="error" <?php if ( "" == $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $error; ?></strong></p></div>
183 <?php if ( ! isset( $_GET['action'] ) ) { ?>
184 <form method="post" action="admin.php?page=pdf-print.php" id="pdfprnt_settings_form">
185 <table class="form-table pdfprnt_settings_table">
186 <tr>
187 <th scope="row"><?php _e( 'Use of theme stylesheet or plugin default style:', 'pdf-print' ); ?></th>
188 <td>
189 <select name="pdfprnt_use_theme_stylesheet">
190 <option value="0" <?php if ( 0 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Default stylesheet', 'pdf-print' ); ?></option>
191 <option value="1" <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) echo 'selected="selected"'; ?>><?php echo __( 'Current theme stylesheet', 'pdf-print' ); ?></option>
192 </select>
193 </td>
194 </tr>
195 <tr>
196 <th scope="row"><?php _e( 'The types of posts that the plugin will use:', 'pdf-print' ); ?></th>
197 <td>
198 <select name="pdfprnt_use_types_posts[]" multiple="multiple">
199 <?php foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1 ), 'objects' ) as $key => $value ) : ?>
200 <option value="<?php echo $key; ?>" <?php if ( in_array( $key, $pdfprnt_options_array['use_types_posts'] ) ) echo 'selected="selected"'; ?>><?php echo $value->label; ?></option>
201 <?php endforeach; ?>
202 </select>
203 </td>
204 </tr>
205 <?php if ( is_plugin_active( 'portfolio/portfolio.php' ) || is_plugin_active( 'portfolio-pro/portfolio-pro.php' ) ) { ?>
206 <tr>
207 <th scope="row"></th>
208 <td>
209 <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>
210 </td>
211 </tr>
212 <?php } ?>
213 <tr>
214 <th scope="row">
215 <?php _e( 'Position of buttons in content:', 'pdf-print' ); ?>
216 </th>
217 <td>
218 <select name="pdfprnt_position">
219 <?php foreach ( $pdfprnt_positions_values as $key => $value ) : ?>
220 <option value="<?php echo $key; ?>" <?php if ( $pdfprnt_options_array['position'] == $key ) echo 'selected="selected"'; ?>><?php echo $value; ?></option>
221 <?php endforeach; ?>
222 </select>
223 </td>
224 </tr>
225 <tr>
226 <th scope="row"><?php _e( 'Show:', 'pdf-print' ); ?></th>
227 <td>
228 <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 />
229 <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>
230 </td>
231 </tr>
232 <tr>
233 <th scope="row">
234 <?php _e( 'Default template setting for post:', 'pdf-print' ); ?>
235 </th>
236 <td>
237 <div>
238 <label>
239 <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
240 <input type="radio" name="pdfprnt_tmpl_post" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
241 </label>
242 </div>
243 <div>
244 <label>
245 <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
246 <input type="radio" name="pdfprnt_tmpl_post" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
247 </label>
248 </div>
249 <div>
250 <label>
251 <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
252 <input type="radio" name="pdfprnt_tmpl_post" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_post'] ) echo 'checked="checked"'; ?> />
253 </label>
254 </div>
255 </td>
256 </tr>
257 <tr>
258 <th scope="row">
259 <?php _e( 'Position of buttons in content for custom post:', 'pdf-print' ); ?>
260 </th>
261 <td>
262 <select name="pdfprnt_position_custom">
263 <option value="pdfprnt-left" <?php if ( 'pdfprnt-left' == $pdfprnt_options_array['position_custom'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Left', 'pdf-print' ); ?></option>
264 <option value="pdfprnt-right" <?php if ( 'pdfprnt-right' == $pdfprnt_options_array['position_custom'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Right', 'pdf-print' ); ?></option>
265 </select>
266 </td>
267 </tr>
268 <tr>
269 <th scope="row"><?php _e( 'Show for custom posts:', 'pdf-print' ); ?></th>
270 <td>
271 <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 />
272 <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>
273 </td>
274 </tr>
275 <tr>
276 <th scope="row">
277 <?php _e( 'Default template setting for custom posts:', 'pdf-print' ); ?>
278 </th>
279 <td>
280 <div>
281 <label>
282 <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
283 <input type="radio" name="pdfprnt_tmpl_custom" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
284 </label>
285 </div>
286 <div>
287 <label>
288 <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
289 <input type="radio" name="pdfprnt_tmpl_custom" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
290 </label>
291 </div>
292 <div>
293 <label>
294 <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
295 <input type="radio" name="pdfprnt_tmpl_custom" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_custom'] ) echo 'checked="checked"'; ?> />
296 </label>
297 </div>
298 </td>
299 </tr>
300 <tr>
301 <th scope="row"></th>
302 <td>
303 <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>
304 </td>
305 </tr>
306 <tr>
307 <th scope="row">
308 <?php _e( 'Position of buttons on search or archive page:', 'pdf-print' ); ?>
309 </th>
310 <td>
311 <select name="pdfprnt_position_search_archive">
312 <option value="pdfprnt-left" <?php if ( 'pdfprnt-left' == $pdfprnt_options_array['position_search_archive'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Left', 'pdf-print' ); ?></option>
313 <option value="pdfprnt-right" <?php if ( 'pdfprnt-right' == $pdfprnt_options_array['position_search_archive'] ) echo 'selected="selected"'; ?>><?php echo __( 'Align Right', 'pdf-print' ); ?></option>
314 </select>
315 </td>
316 </tr>
317 <tr>
318 <th scope="row"><?php _e( 'Show for search or archive page:', 'pdf-print' ); ?></th>
319 <td>
320 <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 />
321 <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>
322 </td>
323 </tr>
324 <tr>
325 <th scope="row">
326 <?php _e( 'Default template setting for search and archive:', 'pdf-print' ); ?>
327 </th>
328 <td>
329 <div>
330 <label>
331 <img src="<?php echo plugins_url( 'images/template_left.jpg', __FILE__ ); ?>" alt="template_left" />
332 <input type="radio" name="pdfprnt_tmpl_search" value="1" <?php if ( 1 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
333 </label>
334 </div>
335 <div>
336 <label>
337 <img src="<?php echo plugins_url( 'images/template_center.jpg', __FILE__ ); ?>" alt="template_center" />
338 <input type="radio" name="pdfprnt_tmpl_search" value="2" <?php if ( 2 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
339 </label>
340 </div>
341 <div>
342 <label>
343 <img src="<?php echo plugins_url( 'images/template_right.jpg', __FILE__ ); ?>" alt="template_right" />
344 <input type="radio" name="pdfprnt_tmpl_search" value="3" <?php if ( 3 == $pdfprnt_options_array['tmpl_search'] ) echo 'checked="checked"'; ?> />
345 </label>
346 </div>
347 </td>
348 </tr>
349 <tr>
350 <th scope="row"></th>
351 <td>
352 <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>
353 </td>
354 </tr>
355 <tr>
356 <th scope="row">
357 <?php _e( 'Settings for shorcodes:', 'pdf-print' ); ?>
358 </th>
359 <td>
360 <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>
361 </td>
362 </tr>
363 <tr>
364 <th scope="row"><?php _e( 'Show the print window', 'pdf-print' ); ?></th>
365 <td>
366 <input type="checkbox" name="pdfprnt_show_print_window" <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) echo 'checked="checked"'; ?> />
367 </td>
368 </tr>
369 </table>
370 <div class="bws_pro_version_bloc">
371 <div class="bws_pro_version_table_bloc">
372 <div class="bws_table_bg"></div>
373 <table class="form-table bws_pro_version">
374 <tr>
375 <th scope="row"><?php _e( 'PDF files name', 'pdf-print' ); ?></th>
376 <td>
377 <label><input disabled type="radio" name="pdfprntpr_select_file_name" value="1" /> <?php _e( 'use post or page slug', 'pdf-print' ); ?></label><br />
378 <input type="radio" disabled name="pdfprntpr_select_file_name" value="0" /><input disabled type="text" name='pdfprntpr_file_name' value="mpdf" /><br />
379 <span class="pdfprnt_explanation">
380 <?php _e( 'File name cannot contain more than 195 symbols. The file name can include Latin letters, numbers and symbols "-" , "_" only.', 'pdf-print' ) ?>
381 </span>
382 </td>
383 </tr>
384 <tr>
385 <th scope="row"><?php _e( 'Do not index pdf and print pages', 'pdf-print' ); ?></th>
386 <td>
387 <input type="checkbox" name="pdfprntpr_noindex_page" />
388 </td>
389 </tr>
390 <tr valign="top">
391 <th scope="row" colspan="2">
392 * <?php _e( 'If you upgrade to Pro version all your settings will be saved.', 'pdf-print' ); ?>
393 </th>
394 </tr>
395 </table>
396 </div>
397 <div class="bws_pro_version_tooltip">
398 <div class="bws_info">
399 <?php _e( 'Unlock premium options by upgrading to a PRO version.', 'pdf-print' ); ?>
400 <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>
401 </div>
402 <div class="bws_pro_links">
403 <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">
404 <?php _e( 'Go', 'pdf-print' ); ?> <strong>PRO</strong>
405 </a>
406 </div>
407 <div class="clear"></div>
408 </div>
409 </div>
410 <input type="hidden" name="pdfprnt_form_submit" value="1" />
411 <p class="submit">
412 <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
413 </p>
414 <?php wp_nonce_field( $plugin_basename, 'pdfprnt_nonce_name' ); ?>
415 </form>
416 <?php bws_plugin_reviews_block( $pdfprnt_plugin_info['Name'], 'pdf-print' ); ?>
417 <?php } elseif ( 'extra' == $_GET['action'] ) { ?>
418 <div class="bws_pro_version_bloc">
419 <div class="bws_pro_version_table_bloc">
420 <div class="bws_table_bg"></div>
421 <table class="form-table bws_pro_version">
422 <tr valign="top">
423 <td colspan="2">
424 <?php _e( 'Please choose the necessary post types (or single pages) where PDF & Print buttons will be displayed:', 'pdf-print' ); ?>
425 </td>
426 </tr>
427 <tr valign="top">
428 <td colspan="2">
429 <label>
430 <input disabled="disabled" checked="checked" id="twttrpr_jstree_url" type="checkbox" name="twttrpr_jstree_url" value="1" />
431 <?php _e( "Show URL for pages", 'pdf-print' );?>
432 </label>
433 </td>
434 </tr>
435 <tr valign="top">
436 <td colspan="2">
437 <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' ); ?>" />
438 </td>
439 </tr>
440 <tr valign="top">
441 <td colspan="2">
442 <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
443 </td>
444 </tr>
445 <tr valign="top">
446 <th scope="row" colspan="2">
447 * <?php _e( 'If you upgrade to Pro version all your settings will be saved.', 'pdf-print' ); ?>
448 </th>
449 </tr>
450 </table>
451 </div>
452 <div class="bws_pro_version_tooltip">
453 <div class="bws_info">
454 <?php _e( 'Unlock premium options by upgrading to a PRO version.', 'pdf-print' ); ?>
455 <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>
456 </div>
457 <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">
458 <?php _e( 'Go', 'pdf-print' ); ?> <strong>PRO</strong>
459 </a>
460 <div class="clear"></div>
461 </div>
462 </div>
463 <?php bws_plugin_reviews_block( $pdfprnt_plugin_info['Name'], 'pdf-print' ); ?>
464 <?php } elseif ( 'go_pro' == $_GET['action'] ) {
465 bws_go_pro_tab( $pdfprnt_plugin_info, $plugin_basename, 'pdf-print.php', 'pdf-print-pro.php', 'pdf-print-pro/pdf-print-pro.php', 'pdf-print', 'd9da7c9c2046bed8dfa38d005d4bffdb', '101', isset( $go_pro_result['pro_plugin_is_activated'] ) );
466 } ?>
467 </div>
468 <?php }
469 }
470
471 /* Positioning buttons in the page */
472 if( ! function_exists( 'pdfprnt_content' ) ) {
473 function pdfprnt_content( $content ) {
474 if ( is_admin() )
475 return;
476
477 global $pdfprnt_options_array, $post;
478 if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) // Check for existence the type of posts.
479 return $content;
480 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) {
481 $position = ( 'top-left' == $pdfprnt_options_array['position'] || 'top-right' == $pdfprnt_options_array['position'] ) ? true : false;
482 $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position'] . '">';
483 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) {
484 if ( ! is_front_page () )
485 $permalink = add_query_arg( 'print' , 'pdf' , get_permalink( $post->ID ) );
486 else
487 $permalink = add_query_arg( 'print' , 'pdf' , get_permalink() . '?page_id=' . $post->ID );
488 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="View PDF" /></a>';
489 }
490 if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
491 if ( ! is_front_page () )
492 $permalink = add_query_arg( 'print' , 'print' , get_permalink( $post->ID ) );
493 else
494 $permalink = add_query_arg( 'print' , 'print' , get_permalink() . '?page_id=' . $post->ID );
495 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
496 }
497 $str .= '</div>';
498 if ( $position )
499 $content = $str . $content;
500 else
501 $content = $content . $str;
502 unset( $position );
503 unset( $str );
504 }
505 return $content;
506 }
507 }
508
509 /* Output buttons for search or archive pages */
510 if( ! function_exists( 'pdfprnt_show_buttons_search_archive' ) ) {
511 function pdfprnt_show_buttons_search_archive() {
512 global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wp, $posts;
513 if ( 0 < $pdfprnt_output_count_buttons )
514 return;
515 if ( 1 !== $pdfprnt_options_array['show_btn_pdf_search_archive'] && 1 !== $pdfprnt_options_array['show_btn_print_search_archive'] )
516 return;
517 if ( ( ! is_search() && ! is_archive() ) || ( is_category() || ! have_posts() ) )
518 return;
519 /* Check for existence the type of posts. */
520 $is_return = true;
521 foreach ( $posts as $post ) {
522 if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
523 $is_return = false;
524 break;
525 }
526 }
527 if ( $is_return )
528 return;
529 $pdfprnt_output_count_buttons++;
530 if ( empty( $wp->request ) )
531 $current_url = add_query_arg( $wp->query_string, '', home_url() );
532 else
533 $current_url = home_url( $wp->request );
534 $str = '<div class="' . $pdfprnt_options_array['position_search_archive'] . '">';
535 if ( 1 == $pdfprnt_options_array['show_btn_pdf_search_archive'] ) {
536 $permalink = add_query_arg( 'print' , 'pdf-page' , $current_url );
537 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
538 }
539 if ( 1 == $pdfprnt_options_array['show_btn_print_search_archive'] ) {
540 $permalink = add_query_arg( 'print' , 'print-page' , $current_url );
541 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
542 }
543 $str .= '</div>';
544 unset( $current_url );
545 unset( $permalink );
546 echo $str;
547 }
548 }
549 if ( ! function_exists( 'pdfprnt_auto_show_buttons_search_archive' ) ) {
550 function pdfprnt_auto_show_buttons_search_archive() {
551 if ( is_archive() || is_search() )
552 add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
553 }
554 add_action( 'wp_head', 'pdfprnt_auto_show_buttons_search_archive' );
555 }
556
557 /* Output buttons of page for BWS Portfolio plugin */
558 if( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio' ) ) {
559 function pdfprnt_show_buttons_for_bws_portfolio() {
560 global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wp;
561 if ( 0 < $pdfprnt_output_count_buttons )
562 return;
563 if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
564 return;
565 if ( ! in_array( 'portfolio', $pdfprnt_options_array['use_types_posts'] ) )
566 return;
567 $pdfprnt_output_count_buttons++;
568 if ( empty( $wp->request ) )
569 $current_url = add_query_arg( $wp->query_string, '', home_url() );
570 else
571 $current_url = home_url( $wp->request );
572 $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
573 if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
574 $permalink = add_query_arg( 'print' , 'pdf-portfolio-page' , $current_url );
575 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
576 }
577 if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
578 $permalink = add_query_arg( 'print' , 'print-portfolio-page' , $current_url );
579 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
580 }
581 $str .= '</div>';
582 unset( $current_url );
583 unset( $permalink );
584 return $str;
585 }
586 }
587
588 /* Output buttons of post for BWS Portfolio plugin */
589 if ( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio_post' ) ) {
590 function pdfprnt_show_buttons_for_bws_portfolio_post() {
591 global $pdfprnt_options_array, $post;
592 if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
593 return;
594 if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
595 return;
596 $current_url = get_permalink();
597 $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
598 if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
599 $permalink = add_query_arg( 'print' , 'pdf-portfolio' , $current_url );
600 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
601 }
602 if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
603 $permalink = add_query_arg( 'print' , 'print-portfolio' , $current_url );
604 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
605 }
606 $str .= '</div>';
607 unset( $current_url );
608 unset( $permalink );
609 return $str;
610 }
611 }
612
613 /* Output buttons of page for custom post type */
614 if ( ! function_exists( 'pdfprnt_show_buttons_for_custom_post_type' ) ) {
615 function pdfprnt_show_buttons_for_custom_post_type( $custom_query ) {
616 global $pdfprnt_options_array, $pdfprnt_output_count_buttons;
617 if ( 0 < $pdfprnt_output_count_buttons )
618 return;
619 if ( 1 !== $pdfprnt_options_array['show_btn_pdf_custom'] && 1 !== $pdfprnt_options_array['show_btn_print_custom'] )
620 return;
621 if ( ! is_array( $custom_query ) && ! is_string( $custom_query ) )
622 return;
623 $custom_query = new WP_Query( $custom_query );
624 /* Check for existence the type of posts. */
625 $is_return = true;
626 foreach ( $custom_query->posts as $post ) {
627 if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
628 $is_return = false;
629 break;
630 }
631 }
632 if ( $is_return )
633 return;
634 $pdfprnt_output_count_buttons++;
635 $current_url = add_query_arg( $custom_query->query, '', home_url() );
636 $str = '<div class="' . $pdfprnt_options_array['position_custom'] . '">';
637 if ( 1 == $pdfprnt_options_array['show_btn_pdf_custom'] ) {
638 $permalink = add_query_arg( 'print' , 'pdf-custom-page' , $current_url );
639 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="Print PDF" /></a>';
640 }
641 if ( 1 == $pdfprnt_options_array['show_btn_print_custom'] ) {
642 $permalink = add_query_arg( 'print' , 'print-custom-page' , $current_url );
643 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
644 }
645 $str .= '</div>';
646 unset( $current_url );
647 unset( $permalink );
648 unset( $is_return );
649 unset( $custom_query );
650 return $str;
651 }
652 }
653
654 /* Add links */
655 if ( ! function_exists( 'pdfprnt_action_links' ) ) {
656 function pdfprnt_action_links( $links, $file ) {
657 if ( ! is_network_admin() ) {
658 $base = plugin_basename( __FILE__ );
659 if ( $file == $base ) {
660 $settings_link = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
661 array_unshift( $links, $settings_link );
662 }
663 }
664 return $links;
665 }
666 }
667
668 /* Add links */
669 if ( ! function_exists( 'pdfprnt_links' ) ) {
670 function pdfprnt_links( $links, $file ) {
671 $base = plugin_basename( __FILE__ );
672 if ( $file == $base ) {
673 if ( ! is_network_admin() )
674 $links[] = '<a href="admin.php?page=pdf-print.php">' . __( 'Settings', 'pdf-print' ) . '</a>';
675 $links[] = '<a href="http://wordpress.org/plugins/pdf-print/faq/" target="_blank">' . __( 'FAQ', 'pdf-print' ) . '</a>';
676 $links[] = '<a href="http://support.bestwebsoft.com">' . __( 'Support', 'pdf-print' ) . '</a>';
677 }
678 return $links;
679 }
680 }
681
682 /* Add stylesheets */
683 if ( ! function_exists ( 'pdfprnt_admin_head' ) ) {
684 function pdfprnt_admin_head() {
685 global $wp_version;
686 if ( $wp_version < 3.8 )
687 wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style_wp_before_3.8.css', __FILE__ ) );
688 else
689 wp_enqueue_style( 'pdfprnt_stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
690
691 if ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] )
692 wp_enqueue_script( 'pdfprnt_script', plugins_url( 'js/script.js', __FILE__ ) );
693 }
694 }
695
696 /* Generate templates for pdf file or print */
697 if ( ! function_exists( 'pdfprnt_generate_template' ) ) {
698 function pdfprnt_generate_template( $content, $template = false, $isprint = false ) {
699 global $pdfprnt_options_array;
700 $tmpl = isset( $_GET['tmpl'] ) ? $_GET['tmpl'] : "";
701 ob_start(); /* Starting output buffering */ ?>
702 <html>
703 <head>
704 <?php if ( 1 == $pdfprnt_options_array['use_theme_stylesheet'] ) : ?>
705 <link type="text/css" rel="stylesheet" href="<?php echo get_bloginfo( 'stylesheet_url' ); ?>" media="all" />
706 <?php else: ?>
707 <link type="text/css" rel="stylesheet" href="<?php echo plugins_url( 'css/default.css', __FILE__ ); ?>" media="all" />
708 <?php endif;
709 if ( ! $template )
710 $template = $pdfprnt_options_array['tmpl_post'];
711 switch ( $template ) { /* Using template choosed on settings page */
712 case 1: /* Allign left template */ ?>
713 <style type="text/css">
714 h1, h2, h3, h4, h5, h6 {
715 text-align: left;
716 }
717 img {
718 float: right;
719 }
720 </style>
721 <?php break;
722 case 2: /* Allign center template */ ?>
723 <style type="text/css">
724 h1, h2, h3, h4, h5, h6 {
725 text-align: center;
726 }
727 img {
728 float: left;
729 }
730 </style>
731 <?php break;
732 case 3: /* Allign right template */ ?>
733 <style type="text/css">
734 h1, h2, h3, h4, h5, h6 {
735 text-align: right;
736 }
737 img {
738 float: left;
739 }
740 </style>
741 <?php break;
742 }
743 switch ( $tmpl ) { /* If got something by GET (from admin bar) */
744 case 1: /* Allign left template */ ?>
745 <style type="text/css">
746 h1, h2, h3, h4, h5, h6 {
747 text-align: left;
748 }
749 img {
750 float: right;
751 }
752 </style>
753 <?php break;
754 case 2: /* Allign center template */ ?>
755 <style type="text/css">
756 h1, h2, h3, h4, h5, h6 {
757 text-align: center;
758 }
759 img {
760 float: left;
761 }
762 </style>
763 <?php break;
764 case 3: /* Allign right template */ ?>
765 <style type="text/css">
766 h1, h2, h3, h4, h5, h6 {
767 text-align: right;
768 }
769 img {
770 float: left;
771 }
772 </style>
773 <?php break;
774 }
775 if ( $isprint && 1 == $pdfprnt_options_array['show_print_window'] ) {
776 echo '<script>window.onload = function(){ window.print(); };</script>';
777 } ?>
778 </head>
779 <body>
780 <?php echo $content; ?>
781 </body>
782 </html>
783 <?php $html = ob_get_contents(); /* Getting output buffering */
784 ob_end_clean(); /* Closing output buffering */
785 return $html; /* Now we done with template */
786 }
787 }
788
789 if ( ! function_exists( 'pdfprnt_generate_template_for_bws_portfolio' ) ) {
790 function pdfprnt_generate_template_for_bws_portfolio() {
791 global $post;
792 ob_start(); /* Starting output buffering */
793 $portfolio_options = get_option( 'prtfl_options' );
794 $meta_values = get_post_custom( $post->ID );
795 $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
796 if ( empty ( $post_thumbnail_id ) ) {
797 $args = array(
798 'post_parent' => $post->ID,
799 'post_type' => 'attachment',
800 'post_mime_type' => 'image',
801 'numberposts' => 1
802 );
803 $attachments = get_children( $args );
804 $post_thumbnail_id = key( $attachments );
805 }
806 $image = wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
807 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
808 $image_desc = get_post( $post_thumbnail_id );
809 $image_desc = $image_desc->post_content;
810 if ( '1' == get_option( 'prtfl_postmeta_update' ) ) {
811 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true );
812 $date_compl = $post_meta['_prtfl_date_compl'];
813 if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
814 $date_compl = explode( '/', $date_compl );
815 $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
816 }
817 $link = $post_meta['_prtfl_link'];
818 $short_descr = $post_meta['_prtfl_short_descr'];
819 } else {
820 $date_compl = get_post_meta( $post->ID, '_prtfl_date_compl', true );
821 if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
822 $date_compl = explode( '/', $date_compl );
823 $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
824 }
825 $link = get_post_meta( $post->ID, '_prtfl_link', true);
826 $short_descr = $post_meta['_prtfl_short_descr'];
827 } ?>
828 <img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" alt="<?php echo $image_alt; ?>" />
829 <div>
830 <p>
831 <strong><?php _e( 'Date of completion', 'pdf-print' ); ?>:</strong> <?php echo $date_compl; ?><br/>
832 <strong><?php _e( 'Link', 'pdf-print' ); ?>:</strong> <a href="<?php echo $link; ?>"><?php echo $link; ?></a><br/>
833 <strong><?php _e( 'Description', 'pdf-print' ); ?>:</strong> <?php echo $short_descr; ?><br/>
834 </p>
835 </div>
836 <?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' );
837 if ( is_array( $terms ) && count( $terms ) > 0 ) { ?>
838 <div style="clear:both;">
839 <strong><?php _e( 'Technologies', 'pdf-print' ); ?>: </strong>
840 <?php $count = 0;
841 foreach ( $terms as $term ) {
842 if( 0 < $count )
843 echo ', ';
844 echo '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>';
845 $count++;
846 } ?>
847 </div>
848 <?php }
849 $content = ob_get_contents(); /* Getting output buffering */
850 ob_end_clean(); /* Closing output buffering */
851 return $content; /* Now we done with template */
852 }
853 }
854
855 /* Generate query posts for Portfolio plugin */
856 if ( ! function_exists( 'generate_query_posts_for_portfolio' ) ) {
857 function generate_query_posts_for_portfolio() {
858 global $wp_query;
859 $paged = isset( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1;
860 $technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : "";
861 if ( "" != $technologies ) {
862 $args = array(
863 'post_type' => 'portfolio',
864 'post_status' => 'publish',
865 'posts_per_page' => get_option('posts_per_page'),
866 'paged' => $paged,
867 'tax_query' => array(
868 array(
869 'taxonomy' => 'portfolio_technologies',
870 'field' => 'slug',
871 'terms' => $technologies
872 )
873 )
874 );
875 } else {
876 $args = array(
877 'post_type' => 'portfolio',
878 'post_status' => 'publish',
879 'posts_per_page' => get_option('posts_per_page'),
880 'paged' => $paged
881 );
882 }
883 query_posts( $args );
884 }
885 }
886
887 /* Output print page or pdf document and include plugin script */
888 if ( ! function_exists( 'pdfprnt_print' ) ) {
889 function pdfprnt_print( $query ) {
890 global $pdfprnt_options_array, $posts, $post;
891 if ( $print = get_query_var( 'print' ) ) {
892 remove_all_filters( 'the_content' );
893 add_filter( 'the_content', 'capital_P_dangit', 11 );
894 add_filter( 'the_content', 'wptexturize' );
895 add_filter( 'the_content', 'convert_smilies' );
896 add_filter( 'the_content', 'convert_chars' );
897 add_filter( 'the_content', 'wpautop' );
898 if ( 1 == $pdfprnt_options_array['tmpl_shorcode'] ) {
899 add_filter( 'the_content', 'do_shortcode' ); /* executing shorcodes on the page */
900 } else {
901 $pattern = get_shortcode_regex();
902 if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) ) { /* getting all shortcodes we are using */
903 foreach ( array_unique( $matches[0] ) as $value) {
904 $post->post_content = str_replace( $value, "", $post->post_content ); /* replacing shorcodes to an empty string */
905 }
906 }
907 }
908 switch ( $print ) {
909 case 'pdf': /* Content for PDF from post */
910 include ( 'mpdf/mpdf.php' );
911 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
912 $mpdf = new mPDF('+aCJK');
913 $user_info = get_userdata( $post->post_author );
914 $mpdf->SetAutoFont(AUTOFONT_ALL);
915 $mpdf->SetAuthor( $user_info->display_name );
916 $mpdf->SetTitle( $post->post_title );
917 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
918 $html = '<div class="container">
919 <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
920 <div class="content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
921 </div>';
922 $mpdf->WriteHTML( pdfprnt_generate_template( $html ) );
923 $mpdf->Output();
924 unset( $user_info );
925 unset( $html );
926 unset( $mpdf );
927 die();
928 break;
929 case 'print': /* Content for printing from post */
930 $html = '<div class="container">
931 <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
932 <div class="content">' . apply_filters( 'the_content', $post->post_content ) . '</div>
933 </div>';
934 echo pdfprnt_generate_template( $html, false, true );
935 unset( $html );
936 die();
937 break;
938 case 'pdf-page': /* Content for PDF from archive or searching page */
939 $html = '';
940 $titles = array();
941 $authors = array();
942 include ( 'mpdf/mpdf.php' );
943 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
944 $mpdf = new mPDF('+aCJK');
945 foreach ( $posts as $p ) {
946 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
947 continue;
948 $titles[] = $p->post_title;
949 $user_info = get_userdata( $p->post_author );
950 $authors[] = $user_info->display_name;
951 $html .= '<div class="container">
952 <div class="title"><h1><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>
953 <div class="content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
954 </div><br/><hr/><br/>';
955 unset( $user_info );
956 }
957 $titles = array_unique( $titles );
958 $authors = array_unique( $authors );
959 $mpdf->SetAutoFont(AUTOFONT_ALL);
960 $mpdf->SetTitle( implode( ',', $titles ) );
961 $mpdf->SetAuthor( implode( ',', $authors ) );
962 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
963 $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_search'] ) );
964 $mpdf->Output();
965 unset( $authors );
966 unset( $titles );
967 unset( $html );
968 unset( $mpdf );
969 die();
970 break;
971 case 'print-page': /* Content for printing from archive or searching page */
972 $html = '';
973 foreach ( $posts as $p ) {
974 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
975 continue;
976 $html .= '<div class="container">
977 <div class="title"><h1>' . $p->post_title . '</h1></div><br/>
978 <div class="content">' . apply_filters( 'the_content', $p->post_content ) . '</div>
979 </div><br/><hr/><br/>';
980 }
981 echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_search'], true );
982 unset( $html );
983 die();
984 break;
985 case 'pdf-portfolio': /* Content for PDF from portfolio post */
986 include ( 'mpdf/mpdf.php' );
987 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
988 $mpdf = new mPDF( '+aCJK' );
989 $user_info = get_userdata( $post->post_author );
990 $mpdf->SetAutoFont( AUTOFONT_ALL );
991 $mpdf->SetAuthor( $user_info->display_name );
992 $mpdf->SetTitle( $post->post_title );
993 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
994 $html = '<div class="container">
995 <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
996 <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
997 </div>';
998 $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
999 $mpdf->Output();
1000 unset( $html );
1001 unset( $user_info );
1002 unset( $mpdf );
1003 die();
1004 break;
1005 case 'print-portfolio': /* Content for printing from porfolio post */
1006 $html = '<div class="container">
1007 <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1008 <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1009 </div>';
1010 echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1011 unset( $html );
1012 die();
1013 break;
1014 case 'pdf-portfolio-page': /* Content for PDF from portfolio page */
1015 $html = '';
1016 $titles = array();
1017 $authors = array();
1018 generate_query_posts_for_portfolio();
1019 while ( have_posts() ) {
1020 the_post();
1021 global $post;
1022 if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
1023 continue;
1024 $titles[] = $post->post_title;
1025 $user_info = get_userdata( $post->post_author );
1026 $authors[] = $user_info->display_name;
1027 $html .= '<div class="container">
1028 <div class="title"><h1><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h1></div><br/>
1029 <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1030 </div><br/><hr/><br/>';
1031 unset( $user_info );
1032 }
1033 include ( 'mpdf/mpdf.php' );
1034 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1035 $mpdf = new mPDF( '+aCJK' );
1036 $titles = array_unique( $titles );
1037 $authors = array_unique( $authors );
1038 $mpdf->SetAutoFont( AUTOFONT_ALL );
1039 $mpdf->SetTitle( implode( ',', $titles ) );
1040 $mpdf->SetAuthor( implode( ',', $authors ) );
1041 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1042 $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
1043 $mpdf->Output();
1044 unset( $authors );
1045 unset( $titles );
1046 unset( $html );
1047 unset( $mpdf );
1048 die();
1049 break;
1050 case 'print-portfolio-page': /* Content for printing from portfolio page */
1051 generate_query_posts_for_portfolio();
1052 $html = '';
1053 while ( have_posts() ) {
1054 the_post();
1055 global $post;
1056 if ( ! in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) )
1057 continue;
1058 $html .= '<div class="container">
1059 <div class="title"><h1>' . $post->post_title . '</h1></div><br/>
1060 <div class="content">' . pdfprnt_generate_template_for_bws_portfolio() . '</div>
1061 </div><br/><hr/><br/>';
1062 }
1063 echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1064 unset( $html );
1065 die();
1066 break;
1067 case 'pdf-custom-page': /* Content for PDF from custom post */
1068 $html = '';
1069 $titles = $authors = array();
1070 foreach ( $posts as $p ) {
1071 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1072 continue;
1073 $titles[] = $p->post_title;
1074 $user_info = get_userdata( $p->post_author );
1075 $authors[] = $user_info->display_name;
1076 $html .= '<div class="container">';
1077 $html .= '<div class="title"><h1><a href="' . get_permalink( $p->ID ) . '">' . $p->post_title . '</a></h1></div><br/>';
1078 $html .= '<div class="content">';
1079 if ( has_post_thumbnail( $p->ID ) )
1080 $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );
1081 $html .= apply_filters( 'the_content', $p->post_content ) . '</div></div><br/><hr/><br/>';
1082 unset( $user_info );
1083 }
1084 include ( 'mpdf/mpdf.php' );
1085 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
1086 $mpdf = new mPDF( '+aCJK' );
1087 $titles = array_unique( $titles );
1088 $authors = array_unique( $authors );
1089 $mpdf->SetAutoFont( AUTOFONT_ALL );
1090 $mpdf->SetTitle( implode( ',', $titles ) );
1091 $mpdf->SetAuthor( implode( ',', $authors ) );
1092 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
1093 $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
1094 $mpdf->Output();
1095 unset( $authors );
1096 unset( $titles );
1097 unset( $html );
1098 unset( $mpdf );
1099 die();
1100 break;
1101 case 'print-custom-page': /* Content for printing from custom post */
1102 $html = '';
1103 foreach ( $posts as $p ) {
1104 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
1105 continue;
1106 $html .= '<div class="container">';
1107 $html .= '<div class="title"><h1>' . $p->post_title . '</h1></div><br/>';
1108 $html .= '<div class="content">';
1109 if ( has_post_thumbnail( $p->ID ) )
1110 $html .= get_the_post_thumbnail( $p->ID, 'thumbnail' );
1111 $html .= apply_filters( 'the_content', $p->post_content ) . '</div>
1112 </div><br/><hr/><br/>';
1113 }
1114 echo pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'], true );
1115 unset( $html );
1116 die();
1117 break;
1118 }
1119 }
1120 }
1121 }
1122
1123 /* Add query vars */
1124 if ( ! function_exists( 'print_vars_callback' ) ) {
1125 function print_vars_callback( $query_vars ) {
1126 $query_vars[] = 'print';
1127 $query_vars[] = 'tmpl';
1128 return $query_vars;
1129 }
1130 }
1131
1132 /* Add custom admin bar menu */
1133 if ( ! function_exists( 'pdfprnt_admin_bar_menu' ) ) {
1134 function pdfprnt_admin_bar_menu() {
1135 global $pdfprnt_options_array, $wp_admin_bar, $wp, $posts;
1136 if ( ! is_super_admin() || ! is_admin_bar_showing() || is_admin() ) /* Checking user */
1137 return;
1138 if ( ( ! is_search() && ! is_archive() ) || ( is_category() || ! have_posts() ) )
1139 return;
1140 $is_return = true;
1141 foreach ( $posts as $post ) {
1142 if ( in_array( get_post_type( $post ), $pdfprnt_options_array['use_types_posts'] ) ) {
1143 $is_return = false;
1144 break;
1145 }
1146 }
1147 if ( $is_return )
1148 return;
1149 if ( empty( $wp->request ) )
1150 $current_url = add_query_arg( $wp->query_string, '', home_url() );
1151 else
1152 $current_url = home_url( $wp->request );
1153 $permalink = add_query_arg( 'print', 'pdf-page', $current_url );
1154 $wp_admin_bar->add_menu( array(
1155 'id' => 'pdfprnt-bar-menu',
1156 'title' => '<span class="admin-bar-menu-bws-icon"></span>PDF',
1157 'href' => $permalink
1158 ) );
1159 $template_url = add_query_arg( 'tmpl', '1', $permalink ); /* Adding parametrs to link */
1160 $wp_admin_bar->add_menu( array(
1161 'parent' => 'pdfprnt-bar-menu',
1162 'id' => 'pdfprnt-template-1',
1163 'title' => '<img src="' . plugins_url( 'images/template_left.jpg', __FILE__ ) . '" alt="template_left" />',
1164 'href' => $template_url
1165 ) );
1166 $template_url = add_query_arg( 'tmpl', '2', $permalink ); /* Adding parametrs to link */
1167 $wp_admin_bar->add_menu( array(
1168 'parent' => 'pdfprnt-bar-menu',
1169 'id' => 'pdfprnt-template-2',
1170 'title' => '<img src="' . plugins_url( 'images/template_center.jpg', __FILE__ ) . '" alt="template_center" />',
1171 'href' => $template_url
1172 ) );
1173 $template_url = add_query_arg( 'tmpl', '3', $permalink ); /* Adding parametrs to link */
1174 $wp_admin_bar->add_menu( array(
1175 'parent' => 'pdfprnt-bar-menu',
1176 'id' => 'pdfprnt-template-3',
1177 'title' => '<img src="' . plugins_url( 'images/template_right.jpg', __FILE__ ) . '" alt="template_right" />',
1178 'href' => $template_url
1179 ) );
1180 unset( $current_url );
1181 unset( $permalink );
1182 unset( $template_url );
1183 }
1184 }
1185
1186 if ( ! function_exists ( 'pdfprnt_plugin_banner' ) ) {
1187 function pdfprnt_plugin_banner() {
1188 global $hook_suffix, $pdfprnt_plugin_info;
1189 if ( 'plugins.php' == $hook_suffix ) {
1190 bws_plugin_banner( $pdfprnt_plugin_info, 'pdfprnt', 'pdf-print', 'e2f2549f4d70bc4cb9b48071169d264e', '101', 'http://ps.w.org/pdf-print/assets/icon-128x128.png' );
1191 }
1192 }
1193 }
1194
1195 /* Deleting plugin options on uninstalling */
1196 if ( ! function_exists( 'pdfprnt_uninstall' ) ) {
1197 function pdfprnt_uninstall() {
1198 delete_option( 'pdfprnt_options_array' );
1199 }
1200 }
1201
1202 /* Adding function to output PDF document or pirnt page */
1203 add_action( 'wp', 'pdfprnt_print' );
1204 /* Initialization */
1205 add_action( 'init', 'pdfprnt_init' );
1206 add_action( 'admin_init', 'pdfprnt_admin_init' );
1207 /* Adding stylesheets */
1208 add_action( 'admin_enqueue_scripts', 'pdfprnt_admin_head' );
1209 add_action( 'wp_enqueue_scripts', 'pdfprnt_admin_head' );
1210 /* Adding 'BWS Plugins' admin menu */
1211 add_action( 'admin_menu', 'pdfprnt_add_pages' );
1212 /* Add menu to bar menu WordPress */
1213 add_action( 'admin_bar_menu', 'pdfprnt_admin_bar_menu', 1000 );
1214 /* Add query vars */
1215 add_filter( 'query_vars', 'print_vars_callback' );
1216 /* Additional links on the plugin page */
1217 add_filter( 'plugin_action_links', 'pdfprnt_action_links', 10, 2 );
1218 add_filter( 'plugin_row_meta', 'pdfprnt_links', 10, 2 );
1219 /* Adding buttons plugin to content */
1220 add_filter( 'the_content', 'pdfprnt_content' );
1221 /* Adding banner */
1222 add_action( 'admin_notices', 'pdfprnt_plugin_banner' );
1223 /* Plugin uninstall function */
1224 register_uninstall_hook( __FILE__, 'pdfprnt_uninstall' );
1225 ?>
1226