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 +19 -99 1.71.5 View file →
@@ -3,14 +3,14 @@
3 3 Plugin Name: PDF & Print
4 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.7
7 +Version: 1.5
8 8 Author URI: http://bestwebsoft.com/
9 9 License: GPLv2 or later
10 10 */
11 11
12 -/* © Copyright 2014 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.
@@ -29,9 +29,9 @@
29 29
30 30 /* Add our own menu */
31 31 if ( ! function_exists( 'pdfprnt_add_pages' ) ) {
32 32 function pdfprnt_add_pages() {
33 - add_menu_page( 'BWS Plugins', 'BWS Plugins', 'manage_options', 'bws_plugins', 'bws_add_menu_render', plugins_url( 'images/px.png', __FILE__ ), 1001 );
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 34 add_submenu_page( 'bws_plugins', __( 'PDF & Print Settings', 'pdf-print' ), __( 'PDF & Print', 'pdf-print' ), 'manage_options', "pdf-print.php", 'pdfprnt_settings_page' );
35 35 }
36 36 }
37 37
@@ -37,15 +37,9 @@
37 37
38 38 /* Register settings for plugin */
39 39 if ( ! function_exists( 'pdfprnt_settings' ) ) {
40 40 function pdfprnt_settings() {
41 - global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wpmu, $bws_plugin_info;
42 -
43 - if ( function_exists( 'get_plugin_data' ) && ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) ) ) {
44 - $plugin_info = get_plugin_data( __FILE__ );
45 - $bws_plugin_info = array( 'id' => '101', 'version' => $plugin_info["Version"] );
46 - }
47 -
41 + global $pdfprnt_options_array, $pdfprnt_output_count_buttons, $wpmu;
48 42 $pdfprnt_output_count_buttons = 0; /* Variable to verify performance number of once function. */
49 43 $pdfprnt_default_post_types = array();
50 44 foreach ( get_post_types( array( 'public' => 1, 'show_ui' => 1, '_builtin' => true ), 'names' ) as $value )
51 45 $pdfprnt_default_post_types[] = $value; /* Default post types of WordPress. */
@@ -63,10 +57,9 @@
63 57 'tmpl_post' => 1,
64 58 'tmpl_search' => 1,
65 59 'tmpl_custom' => 1,
66 60 'tmpl_shorcode' => 1,
67 - 'use_types_posts' => $pdfprnt_default_post_types,
68 - 'show_print-window' => 0
61 + 'use_types_posts' => $pdfprnt_default_post_types
69 62 );
70 63 if ( 1 == $wpmu ) {
71 64 if ( ! get_site_option( 'pdfprnt_options_array' ) ) {
72 65 add_site_option( 'pdfprnt_options_array', $cptch_option_defaults, '', 'yes' );
@@ -78,10 +71,8 @@
78 71 if ( 1 == $wpmu )
79 72 $pdfprnt_options_array = get_site_option( 'pdfprnt_options_array' );
80 73 else
81 74 $pdfprnt_options_array = get_option( 'pdfprnt_options_array' );
82 - if ( ! isset( $pdfprnt_options_array['show_print_window'] ) )
83 - $pdfprnt_options_array['show_print_window'] = 0;
84 75 $pdfprnt_options_array = array_merge( $pdfprnt_options_array_defaults, $pdfprnt_options_array );
85 76 }
86 77 }
87 78
@@ -88,9 +79,8 @@
88 79 /* Function check if plugin is compatible with current WP version */
89 80 if ( ! function_exists ( 'pdfprnt_version_check' ) ) {
90 81 function pdfprnt_version_check() {
91 82 global $wp_version;
92 -
93 83 $plugin_data = get_plugin_data( __FILE__, false );
94 84 $require_wp = "3.0"; /* Wordpress at least requires version */
95 85 $plugin = plugin_basename( __FILE__ );
96 86 if ( version_compare( $wp_version, $require_wp, "<" ) ) {
@@ -133,9 +123,8 @@
133 123 $pdfprnt_options_array['show_btn_print_search_archive'] = isset( $_REQUEST['pdfprnt_show_btn_print_search_archive'] ) ? 1 : 0;
134 124 $pdfprnt_options_array['show_btn_pdf_custom'] = isset( $_REQUEST['pdfprnt_show_btn_pdf_custom'] ) ? 1 : 0;
135 125 $pdfprnt_options_array['show_btn_print_custom'] = isset( $_REQUEST['pdfprnt_show_btn_print_custom'] ) ? 1 : 0;
136 126 $pdfprnt_options_array['tmpl_shorcode'] = isset( $_REQUEST['pdfprnt_tmpl_shorcode'] ) ? 1 : 0;
137 - $pdfprnt_options_array['show_print_window'] = isset( $_REQUEST['pdfprnt_show_print_window'] ) ? 1 : 0;
138 127 $pdfprnt_options_array['use_types_posts'] = isset( $_REQUEST['pdfprnt_use_types_posts'] ) ? $_REQUEST['pdfprnt_use_types_posts'] : array();
139 128 update_option ( 'pdfprnt_options_array', $pdfprnt_options_array );
140 129 $message = __( 'Settings saved.', 'pdf-print' );
141 130 } ?>
@@ -142,11 +131,10 @@
142 131 <div class="wrap">
143 132 <div class="icon32 icon32-bws" id="icon-options-general"></div>
144 133 <h2><?php echo __( 'PDF & Print Settings', 'pdf-print' ); ?></h2>
145 134 <div class="updated fade" <?php if( empty( $message ) ) echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?></strong></p></div>
146 - <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>
147 135 <div>
148 - <form method="post" action="admin.php?page=pdf-print.php" id="pdfprnt_settings_form">
136 + <form method="post" action="admin.php?page=pdf-print.php">
149 137 <table class="form-table pdfprnt_settings_table">
150 138 <tr>
151 139 <th scope="row"><?php echo __( 'Use of theme stylesheet or plugin default style:', 'pdf-print' ); ?></th>
152 140 <td>
@@ -326,14 +314,8 @@
326 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>
327 315 </td>
328 316 </tr>
329 317 <tr>
330 - <th scope="row"><?php echo __( 'Show the print window', 'pdf-print' ); ?></th>
331 - <td>
332 - <label><input type="checkbox" name="pdfprnt_show_print_window" <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) echo 'checked="checked"'; ?> /> <span><?php echo __( 'Mark the checkbox to show it', 'pdf-print' ); ?></span></label><br />
333 - </td>
334 - </tr>
335 - <tr>
336 318 <td colspan="2">
337 319 <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'pdf-print' ); ?>" />
338 320 </td>
339 321 </tr>
@@ -339,19 +321,8 @@
339 321 </tr>
340 322 </table>
341 323 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'pdfprnt_nonce_name' ); ?>
342 324 </form>
343 - <br />
344 - <div class="bws-plugin-reviews">
345 - <div class="bws-plugin-reviews-rate">
346 - <?php _e( 'If you enjoy our plugin, please give it 5 stars on WordPress', 'pdf-print' ); ?>:
347 - <a href="http://wordpress.org/support/view/plugin-reviews/pdf-print" target="_blank" title="PDF &amp; Print reviews"><?php _e( 'Rate the plugin', 'pdf-print' ); ?></a><br/>
348 - </div>
349 - <div class="bws-plugin-reviews-support">
350 - <?php _e( 'If there is something wrong about it, please contact us', 'pdf-print' ); ?>:
351 - <a href="http://support.bestwebsoft.com">http://support.bestwebsoft.com</a>
352 - </div>
353 - </div>
354 325 </div>
355 326 </div>
356 327 <?php }
357 328 }
@@ -365,19 +336,13 @@
365 336 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] || 1 == $pdfprnt_options_array['show_btn_print'] ) {
366 337 $position = ( 'top-left' == $pdfprnt_options_array['position'] || 'top-right' == $pdfprnt_options_array['position'] ) ? true : false;
367 338 $str = '<div class="pdfprnt-' . $pdfprnt_options_array['position'] . '">';
368 339 if ( 1 == $pdfprnt_options_array['show_btn_pdf'] ) {
369 - if ( ! is_front_page () )
370 - $permalink = add_query_arg( 'print' , 'pdf' , get_permalink( $post->ID ) );
371 - else
372 - $permalink = add_query_arg( 'print' , 'pdf' , get_permalink() . '?page_id=' . $post->ID );
340 + $permalink = add_query_arg( 'print' , 'pdf' , get_permalink( $post->ID ) );
373 341 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/pdf.png', __FILE__ ) . '" alt="image_pdf" title="View PDF" /></a>';
374 342 }
375 343 if ( 1 == $pdfprnt_options_array['show_btn_print'] ) {
376 - if ( ! is_front_page () )
377 - $permalink = add_query_arg( 'print' , 'print' , get_permalink( $post->ID ) );
378 - else
379 - $permalink = add_query_arg( 'print' , 'print' , get_permalink() . '?page_id=' . $post->ID );
344 + $permalink = add_query_arg( 'print' , 'print' , get_permalink( $post->ID ) );
380 345 $str .= '<a href="' . $permalink . '" target="_blank"><img src="' . plugins_url( 'images/print.gif', __FILE__ ) . '" alt="image_print" title="Print Content" /></a>';
381 346 }
382 347 $str .= '</div>';
383 348 if ( $position )
@@ -427,18 +392,11 @@
427 392 }
428 393 $str .= '</div>';
429 394 unset( $current_url );
430 395 unset( $permalink );
431 - echo $str;
396 + return $str;
432 397 }
433 398 }
434 -if( ! function_exists( 'pdfprnt_auto_show_buttons_search_archive' ) ) {
435 - function pdfprnt_auto_show_buttons_search_archive() {
436 - if ( is_archive() || is_search() )
437 - add_action( 'loop_start', 'pdfprnt_show_buttons_search_archive' );
438 - }
439 - add_action( 'wp_head', 'pdfprnt_auto_show_buttons_search_archive' );
440 -}
441 399
442 400 /* Output buttons of page for BWS Portfolio plugin */
443 401 if( ! function_exists( 'pdfprnt_show_buttons_for_bws_portfolio' ) ) {
444 402 function pdfprnt_show_buttons_for_bws_portfolio() {
@@ -564,8 +522,9 @@
564 522 /* Init plugin */
565 523 if ( ! function_exists ( 'pdfprnt_plugin_init' ) ) {
566 524 function pdfprnt_plugin_init() {
567 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/' );
568 527 }
569 528 }
570 529
571 530 /* Add stylesheets */
@@ -570,13 +529,12 @@
570 529
571 530 /* Add stylesheets */
572 531 if ( ! function_exists ( 'pdfprnt_admin_head' ) ) {
573 532 function pdfprnt_admin_head() {
574 - global $wp_version;
575 - if ( $wp_version < 3.8 )
576 - wp_enqueue_style( 'pdfprnt-stylesheet', plugins_url( 'css/style_wp_before_3.8.css', __FILE__ ) );
577 - else
578 - wp_enqueue_style( 'pdfprnt-stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
533 + wp_enqueue_style( 'pdfprnt-stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
534 +
535 + if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_plugins" )
536 + wp_enqueue_script( 'bws_menu_script', plugins_url( 'js/bws_menu.js', __FILE__ ) );
579 537 }
580 538 }
581 539
582 540 /* Generate templates for pdf file or print */
@@ -671,10 +629,8 @@
671 629 <?php break;
672 630 }
673 631 if ( $isprint ) : ?>
674 632 <script type="text/javascript" src="<?php echo plugins_url( 'js/pdfprnt.print.js', __FILE__ ); ?>"></script>
675 - <?php if ( 1 == $pdfprnt_options_array['show_print_window'] ) {
676 - echo '<script>window.onload = function(){ window.print(); };</script>'; } ?>
677 633 <?php endif; ?>
678 634 </head>
679 635 <body>
680 636 <?php echo $content; ?>
@@ -700,9 +656,9 @@
700 656 'post_type' => 'attachment',
701 657 'post_mime_type' => 'image',
702 658 'numberposts' => 1
703 659 );
704 - $attachments = get_children( $args );
660 + $attachments = get_children( $args );
705 661 $post_thumbnail_id = key( $attachments );
706 662 }
707 663 $image = wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
708 664 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
@@ -707,12 +663,12 @@
707 663 $image = wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' );
708 664 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true );
709 665 $image_desc = get_post( $post_thumbnail_id );
710 666 $image_desc = $image_desc->post_content;
711 - if ( '1' == get_option( 'prtfl_postmeta_update' ) ) {
667 + if( get_option( 'prtfl_postmeta_update' ) == '1' ) {
712 668 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true );
713 669 $date_compl = $post_meta['_prtfl_date_compl'];
714 - if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
670 + if( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
715 671 $date_compl = explode( '/', $date_compl );
716 672 $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
717 673 }
718 674 $link = $post_meta['_prtfl_link'];
@@ -718,9 +674,9 @@
718 674 $link = $post_meta['_prtfl_link'];
719 675 $short_descr = $post_meta['_prtfl_short_descr'];
720 676 } else {
721 677 $date_compl = get_post_meta( $post->ID, '_prtfl_date_compl', true );
722 - if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
678 + if( ! empty( $date_compl ) && 'in progress' != $date_compl ) {
723 679 $date_compl = explode( '/', $date_compl );
724 680 $date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . '-' . $date_compl[0] . '-' . $date_compl[2] ) );
725 681 }
726 682 $link = get_post_meta( $post->ID, '_prtfl_link', true);
@@ -758,9 +714,9 @@
758 714 function generate_query_posts_for_portfolio() {
759 715 global $wp_query;
760 716 $paged = isset( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1;
761 717 $technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : "";
762 - if ( "" != $technologies ) {
718 + if( $technologies != "" ) {
763 719 $args = array(
764 720 'post_type' => 'portfolio',
765 721 'post_status' => 'publish',
766 722 'posts_per_page' => get_option('posts_per_page'),
@@ -809,11 +765,9 @@
809 765 switch ( $print ) {
810 766 case 'pdf': /* Content for PDF from post */
811 767 include ( 'mpdf/mpdf.php' );
812 768 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
813 - $mpdf = new mPDF('+aCJK');
814 769 $user_info = get_userdata( $post->post_author );
815 - $mpdf->SetAutoFont(AUTOFONT_ALL);
816 770 $mpdf->SetAuthor( $user_info->display_name );
817 771 $mpdf->SetTitle( $post->post_title );
818 772 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
819 773 $html = '<div class="container">
@@ -841,9 +795,8 @@
841 795 $titles = array();
842 796 $authors = array();
843 797 include ( 'mpdf/mpdf.php' );
844 798 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
845 - $mpdf = new mPDF('+aCJK');
846 799 foreach ( $posts as $p ) {
847 800 if ( ! in_array( get_post_type( $p ), $pdfprnt_options_array['use_types_posts'] ) )
848 801 continue;
849 802 $titles[] = $p->post_title;
@@ -856,9 +809,8 @@
856 809 unset( $user_info );
857 810 }
858 811 $titles = array_unique( $titles );
859 812 $authors = array_unique( $authors );
860 - $mpdf->SetAutoFont(AUTOFONT_ALL);
861 813 $mpdf->SetTitle( implode( ',', $titles ) );
862 814 $mpdf->SetAuthor( implode( ',', $authors ) );
863 815 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
864 816 $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_search'] ) );
@@ -885,11 +837,9 @@
885 837 break;
886 838 case 'pdf-portfolio': /* Content for PDF from portfolio post */
887 839 include ( 'mpdf/mpdf.php' );
888 840 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
889 - $mpdf = new mPDF( '+aCJK' );
890 841 $user_info = get_userdata( $post->post_author );
891 - $mpdf->SetAutoFont( AUTOFONT_ALL );
892 842 $mpdf->SetAuthor( $user_info->display_name );
893 843 $mpdf->SetTitle( $post->post_title );
894 844 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
895 845 $html = '<div class="container">
@@ -932,12 +882,10 @@
932 882 unset( $user_info );
933 883 }
934 884 include ( 'mpdf/mpdf.php' );
935 885 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
936 - $mpdf = new mPDF( '+aCJK' );
937 886 $titles = array_unique( $titles );
938 887 $authors = array_unique( $authors );
939 - $mpdf->SetAutoFont( AUTOFONT_ALL );
940 888 $mpdf->SetTitle( implode( ',', $titles ) );
941 889 $mpdf->SetAuthor( implode( ',', $authors ) );
942 890 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
943 891 $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
@@ -983,12 +931,10 @@
983 931 unset( $user_info );
984 932 }
985 933 include ( 'mpdf/mpdf.php' );
986 934 $mpdf = new mPDF( get_bloginfo( 'charset' ) );
987 - $mpdf = new mPDF( '+aCJK' );
988 935 $titles = array_unique( $titles );
989 936 $authors = array_unique( $authors );
990 - $mpdf->SetAutoFont( AUTOFONT_ALL );
991 937 $mpdf->SetTitle( implode( ',', $titles ) );
992 938 $mpdf->SetAuthor( implode( ',', $authors ) );
993 939 $mpdf->SetSubject( get_bloginfo( 'blogdescription' ) );
994 940 $mpdf->WriteHTML( pdfprnt_generate_template( $html, $pdfprnt_options_array['tmpl_custom'] ) );
@@ -1083,33 +1029,8 @@
1083 1029 unset( $template_url );
1084 1030 }
1085 1031 }
1086 1032
1087 -if ( ! function_exists('pdfprnt_admin_js') ) {
1088 - function pdfprnt_admin_js() {
1089 - if ( isset( $_GET['page'] ) && "pdf-print.php" == $_GET['page'] ) {
1090 - /* Add notice about changing in the settings page */
1091 - ?>
1092 - <script type="text/javascript">
1093 - (function($) {
1094 - $(document).ready( function() {
1095 - $( '#pdfprnt_settings_form input' ).bind( "change click select", function() {
1096 - if ( $( this ).attr( 'type' ) != 'submit' ) {
1097 - $( '.updated.fade' ).css( 'display', 'none' );
1098 - $( '#pdfprnt_settings_notice' ).css( 'display', 'block' );
1099 - };
1100 - });
1101 - $( '#pdfprnt_settings_form select' ).bind( "change", function() {
1102 - $( '.updated.fade' ).css( 'display', 'none' );
1103 - $( '#pdfprnt_settings_notice' ).css( 'display', 'block' );
1104 - });
1105 - });
1106 - })(jQuery);
1107 - </script>
1108 - <?php }
1109 - }
1110 -}
1111 -
1112 1033 /* Deleting plugin options on uninstalling */
1113 1034 if( ! function_exists( 'pdfprnt_uninstall' ) ) {
1114 1035 function pdfprnt_uninstall() {
1115 1036 delete_option( 'pdfprnt_options_array' );
@@ -1130,9 +1051,8 @@
1130 1051 /* Adding 'BWS Plugins' admin menu */
1131 1052 add_action( 'admin_menu', 'pdfprnt_add_pages' );
1132 1053 /* Add menu to bar menu WordPress */
1133 1054 add_action( 'admin_bar_menu', 'pdfprnt_admin_bar_menu', 1000 );
1134 -add_action( 'admin_head', 'pdfprnt_admin_js' );
1135 1055
1136 1056 /* Add query vars */
1137 1057 add_filter( 'query_vars', 'print_vars_callback' );
1138 1058 /* Adds "Settings" link to the plugin action page */