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