Version Description
- Added $_POST shortcode
- Added current post/page variable shortcode
- Added current URL shortcode
=
Download this release
Release Info
Developer | sevenspark |
Plugin | Contact Form 7 Dynamic Text Extension |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- readme.txt +57 -6
- wpcf7_dynamic_text.php +47 -3
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Contact Form 7 Dynamic Text Extension ===
|
2 |
Contributors: sevenspark
|
3 |
Donate link: http://bit.ly/bVogDN
|
4 |
-
Tags: Contact Form 7, Contact, Contact Form, dynamic, text, input, GET,
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 3.0.1
|
7 |
-
Stable tag: 1.0.
|
8 |
|
9 |
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.
|
10 |
|
@@ -17,7 +17,7 @@ One thing it doesn't handle, however, is dynamic content. Any default values in
|
|
17 |
with pre-populated fields based on some other value? Some examples might include:
|
18 |
|
19 |
* Auto-filling a URL
|
20 |
-
* Auto-filling a Post ID
|
21 |
* Pre-populating a Product Number
|
22 |
* Referencing other content on the site
|
23 |
|
@@ -42,8 +42,9 @@ familiar to Contact Form 7 users. There are two important fields:
|
|
42 |
|
43 |
This field takes a shortcode, with two important provisions:
|
44 |
|
45 |
-
|
46 |
-
|
|
|
47 |
|
48 |
**Uneditable Option**
|
49 |
|
@@ -62,12 +63,27 @@ http://mysite.com?foo=bar
|
|
62 |
Enter the following into the "Dynamic Value" input
|
63 |
|
64 |
CF7_GET key='foo'
|
|
|
65 |
Your Content Form 7 Tag will look something like this:
|
66 |
|
67 |
[dynamictext dynamicname "CF7_GET key='foo'"]
|
68 |
|
69 |
Your form's dynamicname text input will then be pre-populated with the value of foo, in this case, bar
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
**Blog Info**
|
72 |
|
73 |
Want to grab some information from your blog like the URL or the sitename? Use the CF7_bloginfo shortcode. For example, to get the site's URL:
|
@@ -83,6 +99,33 @@ Your Content Form 7 Tag will look something like this:
|
|
83 |
Your form's dynamicname text input will then be pre-populated with your site's URL
|
84 |
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
== Installation ==
|
88 |
|
@@ -109,7 +152,15 @@ None. Yet.
|
|
109 |
= 1.0.1 =
|
110 |
* Fixed dependency issue.
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
== Upgrade Notice ==
|
114 |
|
115 |
-
|
1 |
=== Contact Form 7 Dynamic Text Extension ===
|
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: 2.9
|
6 |
Tested up to: 3.0.1
|
7 |
+
Stable tag: 1.0.3
|
8 |
|
9 |
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.
|
10 |
|
17 |
with pre-populated fields based on some other value? Some examples might include:
|
18 |
|
19 |
* Auto-filling a URL
|
20 |
+
* Auto-filling a Post ID, title, or slug
|
21 |
* Pre-populating a Product Number
|
22 |
* Referencing other content on the site
|
23 |
|
42 |
|
43 |
This field takes a shortcode, with two important provisions:
|
44 |
|
45 |
+
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' .
|
46 |
+
2. Any parameters in the shortcode must use single quotes. That is: CF7_GET key='value' and not CF7_GET key="value"
|
47 |
+
|
48 |
|
49 |
**Uneditable Option**
|
50 |
|
63 |
Enter the following into the "Dynamic Value" input
|
64 |
|
65 |
CF7_GET key='foo'
|
66 |
+
|
67 |
Your Content Form 7 Tag will look something like this:
|
68 |
|
69 |
[dynamictext dynamicname "CF7_GET key='foo'"]
|
70 |
|
71 |
Your form's dynamicname text input will then be pre-populated with the value of foo, in this case, bar
|
72 |
|
73 |
+
|
74 |
+
**PHP POST Variables**
|
75 |
+
|
76 |
+
New in version 1.0.3!
|
77 |
+
|
78 |
+
Grab variables from the $_POST array. The shortcode is much like the GET shortcode:
|
79 |
+
|
80 |
+
CF7_POST key='foo'
|
81 |
+
|
82 |
+
Your Content Form 7 Tag will look something like this:
|
83 |
+
|
84 |
+
[dynamictext dynamicname "CF7_POST key='foo'"]
|
85 |
+
|
86 |
+
|
87 |
**Blog Info**
|
88 |
|
89 |
Want to grab some information from your blog like the URL or the sitename? Use the CF7_bloginfo shortcode. For example, to get the site's URL:
|
99 |
Your form's dynamicname text input will then be pre-populated with your site's URL
|
100 |
|
101 |
|
102 |
+
**Post Info**
|
103 |
+
|
104 |
+
New in version 1.0.3!
|
105 |
+
|
106 |
+
Retrieve information about the current post/page (that the contact form is displayed on). The shortcode works as follows:
|
107 |
+
|
108 |
+
CF7_get_post_var key='title' <-- retrieves the Post's Title
|
109 |
+
CF7_get_post_var key='slug' <-- retrieves the Post's Slug
|
110 |
+
|
111 |
+
You can also retrieve any parameter from the $post object. Just set that as the key value, for example 'post_date'
|
112 |
+
|
113 |
+
The Contact Form 7 Tag would look like:
|
114 |
+
|
115 |
+
[dynamictext dynamicname "CF7_get_post_var key='title'"]
|
116 |
+
|
117 |
+
**Current URL**
|
118 |
+
|
119 |
+
New in version 1.0.3!
|
120 |
+
|
121 |
+
Retrieve the current URL. The shortcode takes no parameters:
|
122 |
+
|
123 |
+
CF7_URL
|
124 |
+
|
125 |
+
So your Contact Form 7 Tag would look like:
|
126 |
+
|
127 |
+
[dynamictext dynamicname "CF7_URL"]
|
128 |
+
|
129 |
|
130 |
== Installation ==
|
131 |
|
152 |
= 1.0.1 =
|
153 |
* Fixed dependency issue.
|
154 |
|
155 |
+
= 1.0.2 =
|
156 |
+
* Fixed administrative control panel dependency issue
|
157 |
+
|
158 |
+
= 1.0.3 =
|
159 |
+
* Added $_POST shortcode
|
160 |
+
* Added current post/page variable shortcode
|
161 |
+
* Added current URL shortcode
|
162 |
+
|
163 |
|
164 |
== Upgrade Notice ==
|
165 |
|
166 |
+
Upgrading gives you new features and fixes!
|
wpcf7_dynamic_text.php
CHANGED
@@ -4,7 +4,7 @@
|
|
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: 1.0.
|
8 |
Author: Chris Mavricos, SevenSpark
|
9 |
Author URI: http://sevenspark.com
|
10 |
License: GPL2
|
@@ -230,8 +230,8 @@ function cf7_get($atts){
|
|
230 |
extract(shortcode_atts(array(
|
231 |
'key' => 0,
|
232 |
), $atts));
|
233 |
-
$
|
234 |
-
return $
|
235 |
}
|
236 |
add_shortcode('CF7_GET', 'cf7_get');
|
237 |
|
@@ -245,4 +245,48 @@ function cf7_bloginfo($atts){
|
|
245 |
}
|
246 |
add_shortcode('CF7_bloginfo', 'cf7_bloginfo');
|
247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
?>
|
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: 1.0.3
|
8 |
Author: Chris Mavricos, SevenSpark
|
9 |
Author URI: http://sevenspark.com
|
10 |
License: GPL2
|
230 |
extract(shortcode_atts(array(
|
231 |
'key' => 0,
|
232 |
), $atts));
|
233 |
+
$value = urldecode($_GET[$key]);
|
234 |
+
return $value;
|
235 |
}
|
236 |
add_shortcode('CF7_GET', 'cf7_get');
|
237 |
|
245 |
}
|
246 |
add_shortcode('CF7_bloginfo', 'cf7_bloginfo');
|
247 |
|
248 |
+
function cf7_post($atts){
|
249 |
+
extract(shortcode_atts(array(
|
250 |
+
'key' => -1,
|
251 |
+
), $atts));
|
252 |
+
if($key == -1) return '';
|
253 |
+
$val = $_POST[$key];
|
254 |
+
return $val;
|
255 |
+
}
|
256 |
+
add_shortcode('CF7_POST', 'cf7_post');
|
257 |
+
|
258 |
+
function cf7_get_post_var($atts){
|
259 |
+
extract(shortcode_atts(array(
|
260 |
+
'key' => 'post_title',
|
261 |
+
), $atts));
|
262 |
+
|
263 |
+
switch($key){
|
264 |
+
case 'slug':
|
265 |
+
$key = 'post_name';
|
266 |
+
break;
|
267 |
+
case 'title':
|
268 |
+
$key = 'post_title';
|
269 |
+
break;
|
270 |
+
}
|
271 |
+
|
272 |
+
global $post;
|
273 |
+
//echo '<pre>'; print_r($post); echo '</pre>';
|
274 |
+
$val = $post->$key;
|
275 |
+
return $val;
|
276 |
+
}
|
277 |
+
add_shortcode('CF7_get_post_var', 'cf7_get_post_var');
|
278 |
+
|
279 |
+
function cf7_url(){
|
280 |
+
$pageURL = 'http';
|
281 |
+
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
|
282 |
+
$pageURL .= "://";
|
283 |
+
if ($_SERVER["SERVER_PORT"] != "80") {
|
284 |
+
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
285 |
+
} else {
|
286 |
+
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
287 |
+
}
|
288 |
+
return $pageURL;
|
289 |
+
}
|
290 |
+
add_shortcode('CF7_URL', 'cf7_url');
|
291 |
+
|
292 |
?>
|