Version Description
- Fixed $wpdb->prepare error
Download this release
Release Info
Developer | Blue Liquid Designs |
Plugin | Gravity PDF |
Version | 1.2.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.2 to 1.2.3
- README.txt +5 -2
- pdf.php +177 -177
README.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: blueliquiddesigns
|
|
3 |
Donate link: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
|
4 |
Tags: gravity, forms, pdf, automation, attachment
|
5 |
Requires at least: 3.4.1
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -66,6 +66,9 @@ By deleting the .htaccess file in the 'output' folder you'll be able to access t
|
|
66 |
|
67 |
Remember to always make a backup of your plugin before upgrading otherwise you'll loose your custom PDF template file.
|
68 |
|
|
|
|
|
|
|
69 |
= 1.2.2 =
|
70 |
* Fixed bug with tempalte shipping method MERGETAGS
|
71 |
* Fixed bug where attachment wasn't being sent
|
3 |
Donate link: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
|
4 |
Tags: gravity, forms, pdf, automation, attachment
|
5 |
Requires at least: 3.4.1
|
6 |
+
Tested up to: 3.5
|
7 |
+
Stable tag: 1.2.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
66 |
|
67 |
Remember to always make a backup of your plugin before upgrading otherwise you'll loose your custom PDF template file.
|
68 |
|
69 |
+
= 1.2.3 =
|
70 |
+
* Fixed $wpdb->prepare error
|
71 |
+
|
72 |
= 1.2.2 =
|
73 |
* Fixed bug with tempalte shipping method MERGETAGS
|
74 |
* Fixed bug where attachment wasn't being sent
|
pdf.php
CHANGED
@@ -1,178 +1,178 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
Plugin Name: Gravity Forms PDF Extended
|
5 |
-
Plugin URI: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
|
6 |
-
Description: Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Note: If you're upgrading, backup your plugin files beforehand as your custom template will be overridden.
|
7 |
-
Version: 1.2.
|
8 |
-
Author: Blue Liquid Designs
|
9 |
-
Author URI: http://www.blueliquiddesigns.com.au
|
10 |
-
|
11 |
-
------------------------------------------------------------------------
|
12 |
-
|
13 |
-
This program is free software; you can redistribute it and/or modify
|
14 |
-
it under the terms of the GNU General Public License as published by
|
15 |
-
the Free Software Foundation; either version 2 of the License, or
|
16 |
-
(at your option) any later version.
|
17 |
-
|
18 |
-
This program is distributed in the hope that it will be useful,
|
19 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
-
GNU General Public License for more details.
|
22 |
-
|
23 |
-
*/
|
24 |
-
|
25 |
-
/*
|
26 |
-
* Handles the admin area routing
|
27 |
-
* See render_to_pdf.php for PDF Output Functions
|
28 |
-
*/
|
29 |
-
|
30 |
-
add_action('gform_entries_first_column_actions', 'pdf_link', 10, 4);
|
31 |
-
add_action("gform_entry_info", "detail_pdf_link", 10, 2);
|
32 |
-
add_action('wp', 'process_exterior_pages');
|
33 |
-
register_activation_hook( __FILE__, 'pdf_extended_activate' );
|
34 |
-
|
35 |
-
|
36 |
-
add_action('admin_init', 'gfe_admin_init', 9);
|
37 |
-
add_action("gform_entry_created", "gform_pdf_example_create", 10, 2);
|
38 |
-
add_filter("gform_admin_notification_attachments", 'gform_add_example_attachment', 10, 3);
|
39 |
-
|
40 |
-
|
41 |
-
/*
|
42 |
-
* Generate our Sample PDF for our Sample Form
|
43 |
-
*/
|
44 |
-
function gform_pdf_example_create($entry, $form)
|
45 |
-
{
|
46 |
-
$user_id = $entry['id'];
|
47 |
-
$form_id = $entry['form_id'];
|
48 |
-
|
49 |
-
if($form['title'] == 'Gravity Forms PDF Extended Custom Template Sample')
|
50 |
-
{
|
51 |
-
/* include the pdf processing file */
|
52 |
-
require ABSPATH. 'wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf.php';
|
53 |
-
/* generate and save the PDF file*/
|
54 |
-
$filename = PDF_Generator($form_id, $user_id, 'save', true, 'example-template.php');
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
/* Emails our sample PDF to the site administrator */
|
59 |
-
function gform_add_example_attachment($attachments, $lead, $form){
|
60 |
-
|
61 |
-
$form_id = $lead['form_id'];
|
62 |
-
$user_id = $lead['id'];
|
63 |
-
$attachments = array();
|
64 |
-
|
65 |
-
if($form['title'] == 'Gravity Forms PDF Extended Custom Template Sample')
|
66 |
-
{
|
67 |
-
/* include PDF converter plugin */
|
68 |
-
include ABSPATH. 'wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf.php';
|
69 |
-
$attachment_file = PDF_SAVE_LOCATION. get_pdf_filename($form_id, $user_id);
|
70 |
-
$attachments[] = $attachment_file;
|
71 |
-
return $attachments;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Check to see if Gravity Forms is actually installed
|
77 |
-
*/
|
78 |
-
function gfe_admin_init()
|
79 |
-
{
|
80 |
-
if(!class_exists("RGForms"))
|
81 |
-
{
|
82 |
-
/* throw error to the admin notice bar */
|
83 |
-
add_action('admin_notices', 'gf_not_installed');
|
84 |
-
}
|
85 |
-
|
86 |
-
if(get_option('gf_pdf_extended_sample') != 'installed')
|
87 |
-
{
|
88 |
-
pdf_extended_activate();
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Install an example form to show off the new template system
|
94 |
-
*/
|
95 |
-
function pdf_extended_activate()
|
96 |
-
{
|
97 |
-
GFExport::import_file(ABSPATH .'/wp-content/plugins/gravity-forms-pdf-extended/example-form.xml');
|
98 |
-
update_option('gf_pdf_extended_sample', 'installed');
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Gravity Forms hasn't been installed so throw error.
|
103 |
-
* We make sure the user hasn't already dismissed the error
|
104 |
-
*/
|
105 |
-
function gf_not_installed()
|
106 |
-
{
|
107 |
-
global $current_user;
|
108 |
-
$user_id = $current_user->ID;
|
109 |
-
|
110 |
-
/* Check that the user hasn't already clicked to ignore the message */
|
111 |
-
if ( ! get_user_meta($user_id, 'gfpdfe_ignore_notice') ) {
|
112 |
-
// Shows as an error message. You could add a link to the right page if you wanted.
|
113 |
-
echo '<div id="message" class="error"><p>';
|
114 |
-
printf(__('You need to install <a href="http://www.gravityforms.com/">Gravity Forms</a> to use the Gravity Forms PDF Extended Plugin. | <a href="%1$s">Hide Notice</a>'), '?gfpdfe_nag_ignore=1');
|
115 |
-
echo '</p></div>';
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Gravity Forms hasn't been installed and user is dismissing the error thrown
|
121 |
-
*/
|
122 |
-
add_action('admin_init', 'gfpdfe_nag_ignore');
|
123 |
-
function gfpdfe_nag_ignore() {
|
124 |
-
global $current_user;
|
125 |
-
$user_id = $current_user->ID;
|
126 |
-
/* If user clicks to ignore the notice, add that to their user meta */
|
127 |
-
if ( isset($_GET['gfpdfe_nag_ignore']) && $_GET['gfpdfe_nag_ignore'] == 1 ) {
|
128 |
-
add_user_meta($user_id, 'gfpdfe_ignore_notice', 'true', true);
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
//Link for Entry Detail View (Provide both View Link and Download)
|
133 |
-
function detail_pdf_link($form_id, $lead) {
|
134 |
-
$lead_id = $lead['id'];
|
135 |
-
echo "PDF: ";
|
136 |
-
echo "<a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '¬es=1' : ''; var url='".home_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> View</a>";
|
137 |
-
echo " <a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '¬es=1' : ''; var url='".home_url()."/?gf_pdf=print-entry&download=1&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> Download</a>";
|
138 |
-
}
|
139 |
-
|
140 |
-
// Made this first... figured i would leave it in. View link on the Entry list view.
|
141 |
-
function pdf_link($form_id, $field_id, $value, $lead) {
|
142 |
-
$lead_id = $lead['id'];
|
143 |
-
echo "| <a href=\"javascript:;\" onclick=\"var notes_qs = '¬es=1'; var url='".home_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\"> View PDF</a>";
|
144 |
-
}
|
145 |
-
|
146 |
-
//Handle Incoming route. Look for GF_PDF namespace
|
147 |
-
function process_exterior_pages(){
|
148 |
-
global $wpdb;
|
149 |
-
|
150 |
-
if(rgempty("gf_pdf", $_GET))
|
151 |
-
return;
|
152 |
-
|
153 |
-
$form_id = $_GET['fid'];
|
154 |
-
$lead_id = $_GET['lid'];
|
155 |
-
$ip = $_GET['ip'];
|
156 |
-
$template = (rgempty('template', $_GET)) ? 'pdf-print-entry.php' : rgget('template');
|
157 |
-
|
158 |
-
/* check the lead is in the database and the IP address matches (little security booster) */
|
159 |
-
$form_entries = $wpdb->get_var( $wpdb->prepare("SELECT count(*) FROM `".$wpdb->prefix."rg_lead` WHERE form_id = ".$form_id." AND status = 'active' AND id = ".$lead_id." AND ip = '".$ip."'", array() ) ) ;
|
160 |
-
|
161 |
-
//ensure users are logged in
|
162 |
-
if(!is_user_logged_in() && !rgempty('template', $_GET) && $form_entries == 0)
|
163 |
-
auth_redirect();
|
164 |
-
|
165 |
-
switch(rgget("gf_pdf")){
|
166 |
-
case "print-entry" :
|
167 |
-
require_once("render_to_pdf.php");
|
168 |
-
/* call the creation class */
|
169 |
-
$output = ($_GET['download'] == 1) ? 'download' : 'view';
|
170 |
-
PDF_Generator((int) $_GET['fid'], (int) $_GET['lid'], $output, false, $template);
|
171 |
-
break;
|
172 |
-
}
|
173 |
-
exit();
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
Plugin Name: Gravity Forms PDF Extended
|
5 |
+
Plugin URI: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
|
6 |
+
Description: Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Note: If you're upgrading, backup your plugin files beforehand as your custom template will be overridden.
|
7 |
+
Version: 1.2.3
|
8 |
+
Author: Blue Liquid Designs
|
9 |
+
Author URI: http://www.blueliquiddesigns.com.au
|
10 |
+
|
11 |
+
------------------------------------------------------------------------
|
12 |
+
|
13 |
+
This program is free software; you can redistribute it and/or modify
|
14 |
+
it under the terms of the GNU General Public License as published by
|
15 |
+
the Free Software Foundation; either version 2 of the License, or
|
16 |
+
(at your option) any later version.
|
17 |
+
|
18 |
+
This program is distributed in the hope that it will be useful,
|
19 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
GNU General Public License for more details.
|
22 |
+
|
23 |
+
*/
|
24 |
+
|
25 |
+
/*
|
26 |
+
* Handles the admin area routing
|
27 |
+
* See render_to_pdf.php for PDF Output Functions
|
28 |
+
*/
|
29 |
+
|
30 |
+
add_action('gform_entries_first_column_actions', 'pdf_link', 10, 4);
|
31 |
+
add_action("gform_entry_info", "detail_pdf_link", 10, 2);
|
32 |
+
add_action('wp', 'process_exterior_pages');
|
33 |
+
register_activation_hook( __FILE__, 'pdf_extended_activate' );
|
34 |
+
|
35 |
+
|
36 |
+
add_action('admin_init', 'gfe_admin_init', 9);
|
37 |
+
add_action("gform_entry_created", "gform_pdf_example_create", 10, 2);
|
38 |
+
add_filter("gform_admin_notification_attachments", 'gform_add_example_attachment', 10, 3);
|
39 |
+
|
40 |
+
|
41 |
+
/*
|
42 |
+
* Generate our Sample PDF for our Sample Form
|
43 |
+
*/
|
44 |
+
function gform_pdf_example_create($entry, $form)
|
45 |
+
{
|
46 |
+
$user_id = $entry['id'];
|
47 |
+
$form_id = $entry['form_id'];
|
48 |
+
|
49 |
+
if($form['title'] == 'Gravity Forms PDF Extended Custom Template Sample')
|
50 |
+
{
|
51 |
+
/* include the pdf processing file */
|
52 |
+
require ABSPATH. 'wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf.php';
|
53 |
+
/* generate and save the PDF file*/
|
54 |
+
$filename = PDF_Generator($form_id, $user_id, 'save', true, 'example-template.php');
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/* Emails our sample PDF to the site administrator */
|
59 |
+
function gform_add_example_attachment($attachments, $lead, $form){
|
60 |
+
|
61 |
+
$form_id = $lead['form_id'];
|
62 |
+
$user_id = $lead['id'];
|
63 |
+
$attachments = array();
|
64 |
+
|
65 |
+
if($form['title'] == 'Gravity Forms PDF Extended Custom Template Sample')
|
66 |
+
{
|
67 |
+
/* include PDF converter plugin */
|
68 |
+
include ABSPATH. 'wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf.php';
|
69 |
+
$attachment_file = PDF_SAVE_LOCATION. get_pdf_filename($form_id, $user_id);
|
70 |
+
$attachments[] = $attachment_file;
|
71 |
+
return $attachments;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Check to see if Gravity Forms is actually installed
|
77 |
+
*/
|
78 |
+
function gfe_admin_init()
|
79 |
+
{
|
80 |
+
if(!class_exists("RGForms"))
|
81 |
+
{
|
82 |
+
/* throw error to the admin notice bar */
|
83 |
+
add_action('admin_notices', 'gf_not_installed');
|
84 |
+
}
|
85 |
+
|
86 |
+
if(get_option('gf_pdf_extended_sample') != 'installed')
|
87 |
+
{
|
88 |
+
pdf_extended_activate();
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Install an example form to show off the new template system
|
94 |
+
*/
|
95 |
+
function pdf_extended_activate()
|
96 |
+
{
|
97 |
+
GFExport::import_file(ABSPATH .'/wp-content/plugins/gravity-forms-pdf-extended/example-form.xml');
|
98 |
+
update_option('gf_pdf_extended_sample', 'installed');
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Gravity Forms hasn't been installed so throw error.
|
103 |
+
* We make sure the user hasn't already dismissed the error
|
104 |
+
*/
|
105 |
+
function gf_not_installed()
|
106 |
+
{
|
107 |
+
global $current_user;
|
108 |
+
$user_id = $current_user->ID;
|
109 |
+
|
110 |
+
/* Check that the user hasn't already clicked to ignore the message */
|
111 |
+
if ( ! get_user_meta($user_id, 'gfpdfe_ignore_notice') ) {
|
112 |
+
// Shows as an error message. You could add a link to the right page if you wanted.
|
113 |
+
echo '<div id="message" class="error"><p>';
|
114 |
+
printf(__('You need to install <a href="http://www.gravityforms.com/">Gravity Forms</a> to use the Gravity Forms PDF Extended Plugin. | <a href="%1$s">Hide Notice</a>'), '?gfpdfe_nag_ignore=1');
|
115 |
+
echo '</p></div>';
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Gravity Forms hasn't been installed and user is dismissing the error thrown
|
121 |
+
*/
|
122 |
+
add_action('admin_init', 'gfpdfe_nag_ignore');
|
123 |
+
function gfpdfe_nag_ignore() {
|
124 |
+
global $current_user;
|
125 |
+
$user_id = $current_user->ID;
|
126 |
+
/* If user clicks to ignore the notice, add that to their user meta */
|
127 |
+
if ( isset($_GET['gfpdfe_nag_ignore']) && $_GET['gfpdfe_nag_ignore'] == 1 ) {
|
128 |
+
add_user_meta($user_id, 'gfpdfe_ignore_notice', 'true', true);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
//Link for Entry Detail View (Provide both View Link and Download)
|
133 |
+
function detail_pdf_link($form_id, $lead) {
|
134 |
+
$lead_id = $lead['id'];
|
135 |
+
echo "PDF: ";
|
136 |
+
echo "<a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '¬es=1' : ''; var url='".home_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> View</a>";
|
137 |
+
echo " <a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '¬es=1' : ''; var url='".home_url()."/?gf_pdf=print-entry&download=1&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> Download</a>";
|
138 |
+
}
|
139 |
+
|
140 |
+
// Made this first... figured i would leave it in. View link on the Entry list view.
|
141 |
+
function pdf_link($form_id, $field_id, $value, $lead) {
|
142 |
+
$lead_id = $lead['id'];
|
143 |
+
echo "| <a href=\"javascript:;\" onclick=\"var notes_qs = '¬es=1'; var url='".home_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\"> View PDF</a>";
|
144 |
+
}
|
145 |
+
|
146 |
+
//Handle Incoming route. Look for GF_PDF namespace
|
147 |
+
function process_exterior_pages(){
|
148 |
+
global $wpdb;
|
149 |
+
|
150 |
+
if(rgempty("gf_pdf", $_GET))
|
151 |
+
return;
|
152 |
+
|
153 |
+
$form_id = $_GET['fid'];
|
154 |
+
$lead_id = $_GET['lid'];
|
155 |
+
$ip = $_GET['ip'];
|
156 |
+
$template = (rgempty('template', $_GET)) ? 'pdf-print-entry.php' : rgget('template');
|
157 |
+
|
158 |
+
/* check the lead is in the database and the IP address matches (little security booster) */
|
159 |
+
$form_entries = $wpdb->get_var( $wpdb->prepare("SELECT count(*) FROM `".$wpdb->prefix."rg_lead` WHERE form_id = ".$form_id." AND status = 'active' AND id = ".$lead_id." AND ip = '".$ip."'", array() ) ) ;
|
160 |
+
|
161 |
+
//ensure users are logged in
|
162 |
+
if(!is_user_logged_in() && !rgempty('template', $_GET) && $form_entries == 0)
|
163 |
+
auth_redirect();
|
164 |
+
|
165 |
+
switch(rgget("gf_pdf")){
|
166 |
+
case "print-entry" :
|
167 |
+
require_once("render_to_pdf.php");
|
168 |
+
/* call the creation class */
|
169 |
+
$output = ($_GET['download'] == 1) ? 'download' : 'view';
|
170 |
+
PDF_Generator((int) $_GET['fid'], (int) $_GET['lid'], $output, false, $template);
|
171 |
+
break;
|
172 |
+
}
|
173 |
+
exit();
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
|
178 |
?>
|