Version Description
- Please update!
- Security: Fix Reflected XSS - more: https://sevenspark.com/docs/cf7-dtx-security-2019-07-24
Download this release
Release Info
Developer | sevenspark |
Plugin | Contact Form 7 Dynamic Text Extension |
Version | 2.0.3 |
Comparing to | |
See all releases |
Code changes from version 2.0.2.1 to 2.0.3
- contact-form-7-dynamic-text-extension.php +28 -38
- readme.txt +23 -18
contact-form-7-dynamic-text-extension.php
CHANGED
@@ -4,16 +4,16 @@
|
|
4 |
Plugin Name: Contact Form 7 - Dynamic Text Extension
|
5 |
Plugin URI: http://sevenspark.com/wordpress-plugins/contact-form-7-dynamic-text-extension
|
6 |
Description: Provides a dynamic text field that accepts any shortcode to generate the content. Requires Contact Form 7
|
7 |
-
Version: 2.0.
|
8 |
Author: Chris Mavricos, SevenSpark
|
9 |
Author URI: http://sevenspark.com
|
10 |
License: GPL2
|
11 |
*/
|
12 |
|
13 |
-
/* Copyright 2010-
|
14 |
|
15 |
This program is free software; you can redistribute it and/or modify
|
16 |
-
it under the terms of the GNU General Public License, version 2, as
|
17 |
published by the Free Software Foundation.
|
18 |
|
19 |
This program is distributed in the hope that it will be useful,
|
@@ -21,7 +21,7 @@ License: GPL2
|
|
21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
GNU General Public License for more details.
|
23 |
|
24 |
-
|
25 |
along with this program; if not, write to the Free Software
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
@@ -93,8 +93,8 @@ function wpcf7dtx_dynamictext_shortcode_handler( $tag ) {
|
|
93 |
}
|
94 |
|
95 |
$atts['value'] = $value;
|
96 |
-
|
97 |
-
|
98 |
switch( $tag->basetype ){
|
99 |
case 'dynamictext':
|
100 |
$atts['type'] = 'text';
|
@@ -197,9 +197,9 @@ function wpcf7dtx_tag_generator_dynamictext( $contact_form , $args = '' ){
|
|
197 |
//$type = 'text';
|
198 |
break;
|
199 |
}
|
200 |
-
|
201 |
|
202 |
-
|
|
|
203 |
|
204 |
|
205 |
?>
|
@@ -265,13 +265,13 @@ function wpcf7dtx_tag_generator_dynamictext( $contact_form , $args = '' ){
|
|
265 |
|
266 |
/*****************************************************
|
267 |
* CF7 DTX Included Shortcodes
|
268 |
-
*
|
269 |
* Used like this:
|
270 |
-
*
|
271 |
* CF7_GET val='value'
|
272 |
-
*
|
273 |
* No [] and single quotes ' rather than double "
|
274 |
-
*
|
275 |
*****************************************************/
|
276 |
|
277 |
/* Insert a $_GET variable */
|
@@ -281,7 +281,7 @@ function cf7_get($atts){
|
|
281 |
), $atts));
|
282 |
$value = '';
|
283 |
if( isset( $_GET[$key] ) ){
|
284 |
-
$value =
|
285 |
}
|
286 |
return $value;
|
287 |
}
|
@@ -292,7 +292,7 @@ function cf7_bloginfo($atts){
|
|
292 |
extract(shortcode_atts(array(
|
293 |
'show' => 'name'
|
294 |
), $atts));
|
295 |
-
|
296 |
return get_bloginfo($show);
|
297 |
}
|
298 |
add_shortcode('CF7_bloginfo', 'cf7_bloginfo');
|
@@ -305,7 +305,7 @@ function cf7_post($atts){
|
|
305 |
if($key == -1) return '';
|
306 |
$val = '';
|
307 |
if( isset( $_POST[$key] ) ){
|
308 |
-
$val = $_POST[$key];
|
309 |
}
|
310 |
return $val;
|
311 |
}
|
@@ -316,7 +316,7 @@ function cf7_get_post_var($atts){
|
|
316 |
extract(shortcode_atts(array(
|
317 |
'key' => 'post_title',
|
318 |
), $atts));
|
319 |
-
|
320 |
switch($key){
|
321 |
case 'slug':
|
322 |
$key = 'post_name';
|
@@ -325,9 +325,8 @@ function cf7_get_post_var($atts){
|
|
325 |
$key = 'post_title';
|
326 |
break;
|
327 |
}
|
328 |
-
|
329 |
global $post;
|
330 |
-
//echo '<pre>'; print_r($post); echo '</pre>';
|
331 |
$val = $post->$key;
|
332 |
return $val;
|
333 |
}
|
@@ -337,9 +336,9 @@ add_shortcode('CF7_get_post_var', 'cf7_get_post_var');
|
|
337 |
function cf7_url(){
|
338 |
$pageURL = 'http';
|
339 |
if( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on"){ $pageURL .= "s"; }
|
340 |
-
|
341 |
$pageURL .= "://";
|
342 |
-
|
343 |
if( isset( $_SERVER["SERVER_PORT"] ) && $_SERVER["SERVER_PORT"] != "80" ){
|
344 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
345 |
} else {
|
@@ -350,7 +349,7 @@ function cf7_url(){
|
|
350 |
add_shortcode('CF7_URL', 'cf7_url');
|
351 |
|
352 |
/* Insert a Custom Post Field
|
353 |
-
* New in 1.0.4
|
354 |
*/
|
355 |
function cf7_get_custom_field($atts){
|
356 |
extract(shortcode_atts(array(
|
@@ -358,28 +357,28 @@ function cf7_get_custom_field($atts){
|
|
358 |
'post_id' => -1,
|
359 |
'obfuscate' => 'off'
|
360 |
), $atts));
|
361 |
-
|
362 |
if($post_id < 0){
|
363 |
global $post;
|
364 |
if(isset($post)) $post_id = $post->ID;
|
365 |
}
|
366 |
-
|
367 |
if($post_id < 0 || empty($key)) return '';
|
368 |
-
|
369 |
$val = get_post_meta($post_id, $key, true);
|
370 |
-
|
371 |
if($obfuscate == 'on'){
|
372 |
$val = cf7dtx_obfuscate($val);
|
373 |
}
|
374 |
-
|
375 |
return $val;
|
376 |
-
|
377 |
}
|
378 |
add_shortcode('CF7_get_custom_field', 'cf7_get_custom_field');
|
379 |
|
380 |
/* Insert information about the current user
|
381 |
-
* New in 1.0.4
|
382 |
-
* See https://codex.wordpress.org/Function_Reference/wp_get_current_user
|
383 |
*/
|
384 |
function cf7_get_current_user($atts){
|
385 |
extract(shortcode_atts(array(
|
@@ -427,12 +426,3 @@ function cf7dtx_cf7com_links() {
|
|
427 |
return $links;
|
428 |
}
|
429 |
add_filter('wpcf7_cf7com_links', 'cf7dtx_cf7com_links');
|
430 |
-
|
431 |
-
/*function obf($atts){
|
432 |
-
extract(shortcode_atts(array(
|
433 |
-
'val' => ''
|
434 |
-
), $atts));
|
435 |
-
return $val.' : '. cf7dtx_obfuscate($val);
|
436 |
-
}
|
437 |
-
add_shortcode('obf', 'obf');*/
|
438 |
-
|
4 |
Plugin Name: Contact Form 7 - Dynamic Text Extension
|
5 |
Plugin URI: http://sevenspark.com/wordpress-plugins/contact-form-7-dynamic-text-extension
|
6 |
Description: Provides a dynamic text field that accepts any shortcode to generate the content. Requires Contact Form 7
|
7 |
+
Version: 2.0.3
|
8 |
Author: Chris Mavricos, SevenSpark
|
9 |
Author URI: http://sevenspark.com
|
10 |
License: GPL2
|
11 |
*/
|
12 |
|
13 |
+
/* Copyright 2010-2019 Chris Mavricos, SevenSpark http://sevenspark.com
|
14 |
|
15 |
This program is free software; you can redistribute it and/or modify
|
16 |
+
it under the terms of the GNU General Public License, version 2, as
|
17 |
published by the Free Software Foundation.
|
18 |
|
19 |
This program is distributed in the hope that it will be useful,
|
21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
GNU General Public License for more details.
|
23 |
|
24 |
+
License
|
25 |
along with this program; if not, write to the Free Software
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
93 |
}
|
94 |
|
95 |
$atts['value'] = $value;
|
96 |
+
|
97 |
+
|
98 |
switch( $tag->basetype ){
|
99 |
case 'dynamictext':
|
100 |
$atts['type'] = 'text';
|
197 |
//$type = 'text';
|
198 |
break;
|
199 |
}
|
|
|
200 |
|
201 |
+
|
202 |
+
|
203 |
|
204 |
|
205 |
?>
|
265 |
|
266 |
/*****************************************************
|
267 |
* CF7 DTX Included Shortcodes
|
268 |
+
*
|
269 |
* Used like this:
|
270 |
+
*
|
271 |
* CF7_GET val='value'
|
272 |
+
*
|
273 |
* No [] and single quotes ' rather than double "
|
274 |
+
*
|
275 |
*****************************************************/
|
276 |
|
277 |
/* Insert a $_GET variable */
|
281 |
), $atts));
|
282 |
$value = '';
|
283 |
if( isset( $_GET[$key] ) ){
|
284 |
+
$value = sanitize_text_field($_GET[$key]);
|
285 |
}
|
286 |
return $value;
|
287 |
}
|
292 |
extract(shortcode_atts(array(
|
293 |
'show' => 'name'
|
294 |
), $atts));
|
295 |
+
|
296 |
return get_bloginfo($show);
|
297 |
}
|
298 |
add_shortcode('CF7_bloginfo', 'cf7_bloginfo');
|
305 |
if($key == -1) return '';
|
306 |
$val = '';
|
307 |
if( isset( $_POST[$key] ) ){
|
308 |
+
$val = sanitize_text_field( $_POST[$key] );
|
309 |
}
|
310 |
return $val;
|
311 |
}
|
316 |
extract(shortcode_atts(array(
|
317 |
'key' => 'post_title',
|
318 |
), $atts));
|
319 |
+
|
320 |
switch($key){
|
321 |
case 'slug':
|
322 |
$key = 'post_name';
|
325 |
$key = 'post_title';
|
326 |
break;
|
327 |
}
|
328 |
+
|
329 |
global $post;
|
|
|
330 |
$val = $post->$key;
|
331 |
return $val;
|
332 |
}
|
336 |
function cf7_url(){
|
337 |
$pageURL = 'http';
|
338 |
if( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on"){ $pageURL .= "s"; }
|
339 |
+
|
340 |
$pageURL .= "://";
|
341 |
+
|
342 |
if( isset( $_SERVER["SERVER_PORT"] ) && $_SERVER["SERVER_PORT"] != "80" ){
|
343 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
344 |
} else {
|
349 |
add_shortcode('CF7_URL', 'cf7_url');
|
350 |
|
351 |
/* Insert a Custom Post Field
|
352 |
+
* New in 1.0.4
|
353 |
*/
|
354 |
function cf7_get_custom_field($atts){
|
355 |
extract(shortcode_atts(array(
|
357 |
'post_id' => -1,
|
358 |
'obfuscate' => 'off'
|
359 |
), $atts));
|
360 |
+
|
361 |
if($post_id < 0){
|
362 |
global $post;
|
363 |
if(isset($post)) $post_id = $post->ID;
|
364 |
}
|
365 |
+
|
366 |
if($post_id < 0 || empty($key)) return '';
|
367 |
+
|
368 |
$val = get_post_meta($post_id, $key, true);
|
369 |
+
|
370 |
if($obfuscate == 'on'){
|
371 |
$val = cf7dtx_obfuscate($val);
|
372 |
}
|
373 |
+
|
374 |
return $val;
|
375 |
+
|
376 |
}
|
377 |
add_shortcode('CF7_get_custom_field', 'cf7_get_custom_field');
|
378 |
|
379 |
/* Insert information about the current user
|
380 |
+
* New in 1.0.4
|
381 |
+
* See https://codex.wordpress.org/Function_Reference/wp_get_current_user
|
382 |
*/
|
383 |
function cf7_get_current_user($atts){
|
384 |
extract(shortcode_atts(array(
|
426 |
return $links;
|
427 |
}
|
428 |
add_filter('wpcf7_cf7com_links', 'cf7dtx_cf7com_links');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,12 +2,12 @@
|
|
2 |
Contributors: sevenspark
|
3 |
Donate link: http://bit.ly/bVogDN
|
4 |
Tags: Contact Form 7, Contact, Contact Form, dynamic, text, input, GET, POST, title, slug
|
5 |
-
Requires at least:
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 2.0.
|
8 |
|
9 |
This plugin provides 2 new tag types for the Contact Form 7 Plugin. It allows the dynamic generation of content for a text input box via any shortcode.
|
10 |
-
It also offers dynamic hidden field functionality, which can be utilized to dynamically set the Email Recipient (To:) address.
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -18,30 +18,30 @@ While default values in Contact Form 7 are static. CF7 DTX lets you create pre-p
|
|
18 |
* Auto-filling a Post ID, title, or slug
|
19 |
* Pre-populating a Product Number
|
20 |
* Referencing other content on the site
|
21 |
-
* Populating with post info
|
22 |
* Populating with user info
|
23 |
* Populating with custom fields
|
24 |
* Any value you can write a shortcode for
|
25 |
|
26 |
-
There are many more case-specific examples. I searched for a solution, and there are some decent hacks out there. Many of them are
|
27 |
-
explored in this forum topic:
|
28 |
-
[Contact Form 7 Input Fields Values as PHP Get-Variables](http://wordpress.org/support/topic/contact-form-7-input-fields-values-as-php-get-viarables).
|
29 |
-
However, they all involved hacking the current Contact Form 7 code, which means next time the plugin is updated their edits will be
|
30 |
overwritten. That's bad.
|
31 |
|
32 |
This Dynamic Text Extension plugin provides a more elegant solution that leaves the Contact Form 7 Plugin intact.
|
33 |
|
34 |
= WHAT DOES IT DO? =
|
35 |
|
36 |
-
This plugin provides a new tag type for the Contact Form 7 Plugin. It allows the dynamic generation of content for a text input box via any shortcode.
|
37 |
-
For example, it comes with several built-in shortcodes that will allow the Contact Form to be populated from any $_GET PHP variable or any info from the
|
38 |
get_bloginfo() function, among others. See below for included shortcodes.
|
39 |
|
40 |
Don't see the shortcode you need on the list? You can write a custom one! Any shortcode that returns a string value can be used here. The included shortcodes just cover the most common scenarios, but the plugin provides the flexibility for you to grab any value you have access to programmatically.
|
41 |
|
42 |
= HOW TO USE IT =
|
43 |
|
44 |
-
After installing and activating the plugin, the Contact Form 7 tag generator will have 2 new tag types: Dynamic Text Field and Dynamic Hidden Field. Most of the options will be
|
45 |
familiar to Contact Form 7 users. There are two important fields:
|
46 |
|
47 |
**Dynamic Value**
|
@@ -50,8 +50,8 @@ This field takes a shortcode, with two important provisions:
|
|
50 |
|
51 |
1. The shortcode should NOT include the normal square brackets ([ and ]). So, instead of [CF7_GET key='value'] you would use CF7_GET key='value' .
|
52 |
2. Any parameters in the shortcode must use single quotes. That is: CF7_GET key='value' and not CF7_GET key="value"
|
53 |
-
|
54 |
-
|
55 |
**Uneditable Option**
|
56 |
|
57 |
As these types of fields should often remain uneditable by the user, there is a checkbox to turn this option on (Not applicable for hidden fields).
|
@@ -63,7 +63,7 @@ The plugin includes 2 basic shortcodes for use with the Dynamic Text extension.
|
|
63 |
|
64 |
**PHP GET Variables**
|
65 |
|
66 |
-
Want to use a variable from the PHP GET array? Just use the CF7_GET shortcode. For example, if you want to get the foo parameter from the url
|
67 |
http://mysite.com?foo=bar
|
68 |
|
69 |
Enter the following into the "Dynamic Value" input
|
@@ -150,8 +150,8 @@ For the purposes of including an email address, you can obfuscate the custom fie
|
|
150 |
|
151 |
**Current User Info**
|
152 |
|
153 |
-
Get data about the current user - assuming they are logged in. Defaults to user name, but you can set the key to any valid value in
|
154 |
-
http://codex.wordpress.org/Function_Reference/get_currentuserinfo
|
155 |
|
156 |
CF7_get_current_user
|
157 |
|
@@ -191,6 +191,11 @@ None. Yet.
|
|
191 |
|
192 |
== Changelog ==
|
193 |
|
|
|
|
|
|
|
|
|
|
|
194 |
= 2.0.2.1 =
|
195 |
|
196 |
* Update changelog properly for 2.0.2 changes:
|
@@ -246,4 +251,4 @@ None. Yet.
|
|
246 |
|
247 |
== Upgrade Notice ==
|
248 |
|
249 |
-
2.0 complete rewrite for compatibility with latest Contact Form 7
|
2 |
Contributors: sevenspark
|
3 |
Donate link: http://bit.ly/bVogDN
|
4 |
Tags: Contact Form 7, Contact, Contact Form, dynamic, text, input, GET, POST, title, slug
|
5 |
+
Requires at least: 5.0
|
6 |
+
Tested up to: 5.2.2
|
7 |
+
Stable tag: 2.0.3
|
8 |
|
9 |
This plugin provides 2 new tag types for the Contact Form 7 Plugin. It allows the dynamic generation of content for a text input box via any shortcode.
|
10 |
+
It also offers dynamic hidden field functionality, which can be utilized to dynamically set the Email Recipient (To:) address.
|
11 |
|
12 |
== Description ==
|
13 |
|
18 |
* Auto-filling a Post ID, title, or slug
|
19 |
* Pre-populating a Product Number
|
20 |
* Referencing other content on the site
|
21 |
+
* Populating with post info
|
22 |
* Populating with user info
|
23 |
* Populating with custom fields
|
24 |
* Any value you can write a shortcode for
|
25 |
|
26 |
+
There are many more case-specific examples. I searched for a solution, and there are some decent hacks out there. Many of them are
|
27 |
+
explored in this forum topic:
|
28 |
+
[Contact Form 7 Input Fields Values as PHP Get-Variables](http://wordpress.org/support/topic/contact-form-7-input-fields-values-as-php-get-viarables).
|
29 |
+
However, they all involved hacking the current Contact Form 7 code, which means next time the plugin is updated their edits will be
|
30 |
overwritten. That's bad.
|
31 |
|
32 |
This Dynamic Text Extension plugin provides a more elegant solution that leaves the Contact Form 7 Plugin intact.
|
33 |
|
34 |
= WHAT DOES IT DO? =
|
35 |
|
36 |
+
This plugin provides a new tag type for the Contact Form 7 Plugin. It allows the dynamic generation of content for a text input box via any shortcode.
|
37 |
+
For example, it comes with several built-in shortcodes that will allow the Contact Form to be populated from any $_GET PHP variable or any info from the
|
38 |
get_bloginfo() function, among others. See below for included shortcodes.
|
39 |
|
40 |
Don't see the shortcode you need on the list? You can write a custom one! Any shortcode that returns a string value can be used here. The included shortcodes just cover the most common scenarios, but the plugin provides the flexibility for you to grab any value you have access to programmatically.
|
41 |
|
42 |
= HOW TO USE IT =
|
43 |
|
44 |
+
After installing and activating the plugin, the Contact Form 7 tag generator will have 2 new tag types: Dynamic Text Field and Dynamic Hidden Field. Most of the options will be
|
45 |
familiar to Contact Form 7 users. There are two important fields:
|
46 |
|
47 |
**Dynamic Value**
|
50 |
|
51 |
1. The shortcode should NOT include the normal square brackets ([ and ]). So, instead of [CF7_GET key='value'] you would use CF7_GET key='value' .
|
52 |
2. Any parameters in the shortcode must use single quotes. That is: CF7_GET key='value' and not CF7_GET key="value"
|
53 |
+
|
54 |
+
|
55 |
**Uneditable Option**
|
56 |
|
57 |
As these types of fields should often remain uneditable by the user, there is a checkbox to turn this option on (Not applicable for hidden fields).
|
63 |
|
64 |
**PHP GET Variables**
|
65 |
|
66 |
+
Want to use a variable from the PHP GET array? Just use the CF7_GET shortcode. For example, if you want to get the foo parameter from the url
|
67 |
http://mysite.com?foo=bar
|
68 |
|
69 |
Enter the following into the "Dynamic Value" input
|
150 |
|
151 |
**Current User Info**
|
152 |
|
153 |
+
Get data about the current user - assuming they are logged in. Defaults to user name, but you can set the key to any valid value in
|
154 |
+
http://codex.wordpress.org/Function_Reference/get_currentuserinfo
|
155 |
|
156 |
CF7_get_current_user
|
157 |
|
191 |
|
192 |
== Changelog ==
|
193 |
|
194 |
+
= 2.0.3 =
|
195 |
+
|
196 |
+
* Please update!
|
197 |
+
* Security: Fix Reflected XSS - more: https://sevenspark.com/docs/cf7-dtx-security-2019-07-24
|
198 |
+
|
199 |
= 2.0.2.1 =
|
200 |
|
201 |
* Update changelog properly for 2.0.2 changes:
|
251 |
|
252 |
== Upgrade Notice ==
|
253 |
|
254 |
+
2.0 complete rewrite for compatibility with latest Contact Form 7
|