Version Description
- Added Current User Info shortcode
- Added Post Custom Field shortcode (with obfuscation support)
- Added Hidden Field capability
Download this release
Release Info
Developer | sevenspark |
Plugin | Contact Form 7 Dynamic Text Extension |
Version | 1.0.4 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 1.0.4
- readme.txt +61 -22
- wpcf7_dynamic_text.php +203 -4
readme.txt
CHANGED
@@ -3,39 +3,43 @@ 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.
|
7 |
-
Stable tag: 1.0.
|
8 |
|
9 |
-
This plugin provides
|
|
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Contact Form 7 is an excellent WordPress plugin
|
14 |
-
|
15 |
-
|
16 |
-
One thing it doesn't handle, however, is dynamic content. Any default values in Contact Form 7 are static. But what if I wanted a Contact Form
|
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 |
|
24 |
-
There are many more case-specific examples. I searched for a solution, and there are some decent hacks out there. Many of them are
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
|
28 |
This Dynamic Text Extension plugin provides a more elegant solution that leaves the Contact Form 7 Plugin intact.
|
29 |
|
30 |
= WHAT DOES IT DO? =
|
31 |
|
32 |
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.
|
33 |
-
For example, it comes with
|
34 |
-
get_bloginfo() function.
|
35 |
|
36 |
= HOW TO USE IT =
|
37 |
|
38 |
-
After installing and activating the plugin, the Contact Form 7 tag generator will have
|
39 |
familiar to Contact Form 7 users. There are two important fields:
|
40 |
|
41 |
**Dynamic Value**
|
@@ -48,7 +52,7 @@ This field takes a shortcode, with two important provisions:
|
|
48 |
|
49 |
**Uneditable Option**
|
50 |
|
51 |
-
As these types of fields should often remain uneditable by the user, there is a checkbox to turn this option on.
|
52 |
|
53 |
|
54 |
= INCLUDED SHORTCODES =
|
@@ -126,13 +130,43 @@ So your Contact Form 7 Tag would look like:
|
|
126 |
|
127 |
[dynamictext dynamicname "CF7_URL"]
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
== Installation ==
|
131 |
|
132 |
This section describes how to install the plugin and get it working.
|
133 |
|
134 |
1. Download and install the Contact Form 7 Plugin located at http://wordpress.org/extend/plugins/contact-form-7/
|
135 |
-
1. Upload the plugin folder to the
|
136 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
137 |
1. You will now have a "Dynamic Text" tag option in the Contact Form 7 tag generator
|
138 |
|
@@ -149,18 +183,23 @@ None. Yet.
|
|
149 |
|
150 |
== Changelog ==
|
151 |
|
152 |
-
= 1.0.
|
153 |
-
*
|
154 |
-
|
155 |
-
|
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 |
-
|
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.4
|
7 |
+
Stable tag: 1.0.4
|
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 |
|
14 |
+
Contact Form 7 is an excellent WordPress plugin, and the CF7 DTX Plugin makes it even more awesome by adding dynamic content capabilities.
|
15 |
+
While default values in Contact Form 7 are static. CF7 DTX lets you create pre-populated fields based on other values. Some examples might include:
|
|
|
|
|
|
|
16 |
|
17 |
* Auto-filling a URL
|
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-Viarables](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 |
= HOW TO USE IT =
|
41 |
|
42 |
+
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
|
43 |
familiar to Contact Form 7 users. There are two important fields:
|
44 |
|
45 |
**Dynamic Value**
|
52 |
|
53 |
**Uneditable Option**
|
54 |
|
55 |
+
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).
|
56 |
|
57 |
|
58 |
= INCLUDED SHORTCODES =
|
130 |
|
131 |
[dynamictext dynamicname "CF7_URL"]
|
132 |
|
133 |
+
**Custom Fields**
|
134 |
+
|
135 |
+
New in version 1.0.4!
|
136 |
+
|
137 |
+
Retrieve custom fields from the current post/page. Just set the custom field as the key in the shortcode.
|
138 |
+
|
139 |
+
The dynamic value input becomes:
|
140 |
+
|
141 |
+
CF7_get_custom_field key='my_custom_field'
|
142 |
+
|
143 |
+
And the tag looks like this:
|
144 |
+
|
145 |
+
[dynamictext dynamicname "CF7_get_custom_field key='my_custom_field'"]
|
146 |
+
|
147 |
+
For the purposes of including an email address, you can obfuscate the custom field value by setting obfuscate='on' in the shortcode.
|
148 |
+
|
149 |
+
**Current User Info**
|
150 |
+
|
151 |
+
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
|
152 |
+
http://codex.wordpress.org/Function_Reference/get_currentuserinfo
|
153 |
+
|
154 |
+
CF7_get_current_user
|
155 |
+
|
156 |
+
[dynamictext dynamicname "CF7_get_current_user"]
|
157 |
+
|
158 |
+
|
159 |
+
Like the Dynamic Text Extension? Please consider supporting its development by [Donating](http://bit.ly/bVogDN).
|
160 |
+
|
161 |
+
Or check out my upcoming premium plugin, [UberMenu - WordPress Mega Menu Plugin](http://wpmegamenu.com)
|
162 |
+
|
163 |
|
164 |
== Installation ==
|
165 |
|
166 |
This section describes how to install the plugin and get it working.
|
167 |
|
168 |
1. Download and install the Contact Form 7 Plugin located at http://wordpress.org/extend/plugins/contact-form-7/
|
169 |
+
1. Upload the plugin folder to the '/wp-content/plugins/' directory
|
170 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
171 |
1. You will now have a "Dynamic Text" tag option in the Contact Form 7 tag generator
|
172 |
|
183 |
|
184 |
== Changelog ==
|
185 |
|
186 |
+
= 1.0.4 =
|
187 |
+
* Added Current User Info shortcode
|
188 |
+
* Added Post Custom Field shortcode (with obfuscation support)
|
189 |
+
* Added Hidden Field capability
|
|
|
190 |
|
191 |
= 1.0.3 =
|
192 |
* Added $_POST shortcode
|
193 |
* Added current post/page variable shortcode
|
194 |
* Added current URL shortcode
|
195 |
|
196 |
+
= 1.0.2 =
|
197 |
+
* Fixed administrative control panel dependency issue
|
198 |
+
|
199 |
+
= 1.0.1 =
|
200 |
+
* Fixed dependency issue.
|
201 |
+
|
202 |
|
203 |
== Upgrade Notice ==
|
204 |
|
205 |
+
The newest upgrade includes hidden field capability and two new shortcodes - current user info and custom post fields.
|
wpcf7_dynamic_text.php
CHANGED
@@ -4,13 +4,13 @@
|
|
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
|
11 |
*/
|
12 |
|
13 |
-
/* Copyright 2010 Chris Mavricos, SevenSpark (email : chris@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
|
@@ -37,6 +37,7 @@ function wpcf7_dynamictext_init(){
|
|
37 |
/* Shortcode handler */
|
38 |
wpcf7_add_shortcode( 'dynamictext', 'wpcf7_dynamictext_shortcode_handler', true );
|
39 |
wpcf7_add_shortcode( 'dynamictext*', 'wpcf7_dynamictext_shortcode_handler', true );
|
|
|
40 |
|
41 |
}
|
42 |
|
@@ -44,10 +45,15 @@ function wpcf7_dynamictext_init(){
|
|
44 |
add_filter( 'wpcf7_validate_dynamictext*', 'wpcf7_dynamictext_validation_filter', 10, 2 );
|
45 |
|
46 |
add_action( 'admin_init', 'wpcf7_add_tag_generator_dynamictext', 15 );
|
|
|
47 |
|
48 |
}
|
49 |
add_action( 'plugins_loaded', 'wpcf7_dynamictext_init');
|
50 |
|
|
|
|
|
|
|
|
|
51 |
function wpcf7_dynamictext_shortcode_handler( $tag ) {
|
52 |
global $wpcf7_contact_form;
|
53 |
|
@@ -217,15 +223,125 @@ function wpcf7_tg_pane_dynamictext( $type = 'dynamictext' ) {
|
|
217 |
}
|
218 |
|
219 |
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
* Used like this:
|
223 |
*
|
224 |
* CF7_GET val='value'
|
225 |
*
|
226 |
* No [] and single quotes ' rather than double "
|
227 |
*
|
228 |
-
|
|
|
|
|
229 |
function cf7_get($atts){
|
230 |
extract(shortcode_atts(array(
|
231 |
'key' => 0,
|
@@ -245,6 +361,7 @@ function cf7_bloginfo($atts){
|
|
245 |
}
|
246 |
add_shortcode('CF7_bloginfo', 'cf7_bloginfo');
|
247 |
|
|
|
248 |
function cf7_post($atts){
|
249 |
extract(shortcode_atts(array(
|
250 |
'key' => -1,
|
@@ -255,6 +372,7 @@ function cf7_post($atts){
|
|
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',
|
@@ -276,6 +394,7 @@ function cf7_get_post_var($atts){
|
|
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";}
|
@@ -289,4 +408,84 @@ function cf7_url(){
|
|
289 |
}
|
290 |
add_shortcode('CF7_URL', 'cf7_url');
|
291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
?>
|
|
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.4
|
8 |
Author: Chris Mavricos, SevenSpark
|
9 |
Author URI: http://sevenspark.com
|
10 |
License: GPL2
|
11 |
*/
|
12 |
|
13 |
+
/* Copyright 2010-2011 Chris Mavricos, SevenSpark (email : chris@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
|
37 |
/* Shortcode handler */
|
38 |
wpcf7_add_shortcode( 'dynamictext', 'wpcf7_dynamictext_shortcode_handler', true );
|
39 |
wpcf7_add_shortcode( 'dynamictext*', 'wpcf7_dynamictext_shortcode_handler', true );
|
40 |
+
wpcf7_add_shortcode( 'dynamichidden', 'wpcf7_dynamichidden_shortcode_handler', true );
|
41 |
|
42 |
}
|
43 |
|
45 |
add_filter( 'wpcf7_validate_dynamictext*', 'wpcf7_dynamictext_validation_filter', 10, 2 );
|
46 |
|
47 |
add_action( 'admin_init', 'wpcf7_add_tag_generator_dynamictext', 15 );
|
48 |
+
add_action( 'admin_init', 'wpcf7_add_tag_generator_dynamichidden', 16 );
|
49 |
|
50 |
}
|
51 |
add_action( 'plugins_loaded', 'wpcf7_dynamictext_init');
|
52 |
|
53 |
+
/*************************************************************
|
54 |
+
* DynamicText Shortcode
|
55 |
+
*************************************************************/
|
56 |
+
|
57 |
function wpcf7_dynamictext_shortcode_handler( $tag ) {
|
58 |
global $wpcf7_contact_form;
|
59 |
|
223 |
}
|
224 |
|
225 |
|
226 |
+
/*************************************************************
|
227 |
+
* DynamicHidden Shortcode
|
228 |
+
*************************************************************/
|
229 |
+
function wpcf7_dynamichidden_shortcode_handler( $tag ) {
|
230 |
+
global $wpcf7_contact_form;
|
231 |
|
232 |
+
if ( ! is_array( $tag ) )
|
233 |
+
return '';
|
234 |
+
|
235 |
+
$type = $tag['type'];
|
236 |
+
$name = $tag['name'];
|
237 |
+
$options = (array) $tag['options'];
|
238 |
+
$values = (array) $tag['values'];
|
239 |
+
|
240 |
+
if ( empty( $name ) )
|
241 |
+
return '';
|
242 |
+
|
243 |
+
$atts = '';
|
244 |
+
$id_att = '';
|
245 |
+
$class_att = '';
|
246 |
+
$size_att = '';
|
247 |
+
$maxlength_att = '';
|
248 |
+
$tabindex_att = '';
|
249 |
+
|
250 |
+
$class_att .= ' wpcf7-text';
|
251 |
+
|
252 |
+
foreach ( $options as $option ) {
|
253 |
+
if ( preg_match( '%^id:([-0-9a-zA-Z_]+)$%', $option, $matches ) ) {
|
254 |
+
$id_att = $matches[1];
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
if ( $id_att )
|
259 |
+
$atts .= ' id="' . trim( $id_att ) . '"';
|
260 |
+
|
261 |
+
// Value
|
262 |
+
if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) && $wpcf7_contact_form->is_posted() ) {
|
263 |
+
if ( isset( $_POST['_wpcf7_mail_sent'] ) && $_POST['_wpcf7_mail_sent']['ok'] )
|
264 |
+
$value = '';
|
265 |
+
else
|
266 |
+
$value = stripslashes_deep( $_POST[$name] );
|
267 |
+
} else {
|
268 |
+
$value = isset( $values[0] ) ? $values[0] : '';
|
269 |
+
}
|
270 |
+
|
271 |
+
$value = do_shortcode('['.$value.']');
|
272 |
+
//echo '<pre>'; print_r($options);echo '</pre>';
|
273 |
+
|
274 |
+
$html = '<input type="hidden" name="' . $name . '" value="' . esc_attr( $value ) . '"' . $atts . ' />';
|
275 |
+
|
276 |
+
//No need to validate, it's a hidden field - we could validate by checking the value hasn't changed, but that seems overkill I think
|
277 |
+
//$validation_error = '';
|
278 |
+
//if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) )
|
279 |
+
// $validation_error = $wpcf7_contact_form->validation_error( $name );
|
280 |
+
|
281 |
+
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . $validation_error . '</span>';
|
282 |
+
|
283 |
+
return $html;
|
284 |
+
}
|
285 |
+
|
286 |
+
|
287 |
+
/* Tag generator */
|
288 |
+
|
289 |
+
function wpcf7_add_tag_generator_dynamichidden() {
|
290 |
+
if(function_exists('wpcf7_add_tag_generator')){
|
291 |
+
wpcf7_add_tag_generator( 'dynamichidden', __( 'Dynamic Hidden field', 'wpcf7' ),
|
292 |
+
'wpcf7-tg-pane-dynamichidden', 'wpcf7_tg_pane_dynamichidden_' );
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
function wpcf7_tg_pane_dynamichidden_( &$contact_form ) {
|
297 |
+
wpcf7_tg_pane_dynamichidden( 'dynamichidden' );
|
298 |
+
}
|
299 |
+
|
300 |
+
function wpcf7_tg_pane_dynamichidden( $type = 'dynamichidden' ) {
|
301 |
+
?>
|
302 |
+
<div id="wpcf7-tg-pane-<?php echo $type; ?>" class="hidden">
|
303 |
+
<form action="">
|
304 |
+
<table>
|
305 |
+
<tr><td><?php echo esc_html( __( 'Name', 'wpcf7' ) ); ?><br /><input type="text" name="name" class="tg-name oneline" /></td><td></td></tr>
|
306 |
+
</table>
|
307 |
+
|
308 |
+
<table>
|
309 |
+
<tr>
|
310 |
+
<td><code>id</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br />
|
311 |
+
<input type="text" name="id" class="idvalue oneline option" /></td>
|
312 |
+
</tr>
|
313 |
+
|
314 |
+
<tr>
|
315 |
+
|
316 |
+
<td><?php echo esc_html( __( 'Dynamic value', 'wpcf7' ) ); ?> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /><input type="text" name="values" class="oneline" />
|
317 |
+
<?php echo esc_html( __( 'You can enter any short code. Just leave out the square brackets ([]) and only use single quotes (\' not ")', 'wpcf7' )); ?>
|
318 |
+
</td>
|
319 |
+
</tr>
|
320 |
+
</table>
|
321 |
+
|
322 |
+
<div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'wpcf7' ) ); ?><br /><input type="text" name="<?php echo $type; ?>" class="tag" readonly="readonly" onfocus="this.select()" /></div>
|
323 |
+
|
324 |
+
<div class="tg-mail-tag"><?php echo esc_html( __( "And, put this code into the Mail fields below.", 'wpcf7' ) ); ?><br /><span class="arrow">⬇</span> <input type="text" class="mail-tag" readonly="readonly" onfocus="this.select()" /></div>
|
325 |
+
</form>
|
326 |
+
</div>
|
327 |
+
<?php
|
328 |
+
}
|
329 |
+
|
330 |
+
|
331 |
+
|
332 |
+
|
333 |
+
/*****************************************************
|
334 |
+
* CF7 DTX Included Shortcodes
|
335 |
+
*
|
336 |
* Used like this:
|
337 |
*
|
338 |
* CF7_GET val='value'
|
339 |
*
|
340 |
* No [] and single quotes ' rather than double "
|
341 |
*
|
342 |
+
*****************************************************/
|
343 |
+
|
344 |
+
/* Insert a $_GET variable */
|
345 |
function cf7_get($atts){
|
346 |
extract(shortcode_atts(array(
|
347 |
'key' => 0,
|
361 |
}
|
362 |
add_shortcode('CF7_bloginfo', 'cf7_bloginfo');
|
363 |
|
364 |
+
/* Insert a $_POST variable (submitted form value)*/
|
365 |
function cf7_post($atts){
|
366 |
extract(shortcode_atts(array(
|
367 |
'key' => -1,
|
372 |
}
|
373 |
add_shortcode('CF7_POST', 'cf7_post');
|
374 |
|
375 |
+
/* Insert a $post (Blog Post) Variable */
|
376 |
function cf7_get_post_var($atts){
|
377 |
extract(shortcode_atts(array(
|
378 |
'key' => 'post_title',
|
394 |
}
|
395 |
add_shortcode('CF7_get_post_var', 'cf7_get_post_var');
|
396 |
|
397 |
+
/* Insert the current URL */
|
398 |
function cf7_url(){
|
399 |
$pageURL = 'http';
|
400 |
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
|
408 |
}
|
409 |
add_shortcode('CF7_URL', 'cf7_url');
|
410 |
|
411 |
+
/* Insert a Custom Post Field
|
412 |
+
* New in 1.0.4
|
413 |
+
*/
|
414 |
+
function cf7_get_custom_field($atts){
|
415 |
+
extract(shortcode_atts(array(
|
416 |
+
'key' => '',
|
417 |
+
'post_id' => -1,
|
418 |
+
'obfuscate' => 'off'
|
419 |
+
), $atts));
|
420 |
+
|
421 |
+
if($post_id < 0){
|
422 |
+
global $post;
|
423 |
+
if(isset($post)) $post_id = $post->ID;
|
424 |
+
}
|
425 |
+
|
426 |
+
if($post_id < 0 || empty($key)) return '';
|
427 |
+
|
428 |
+
$val = get_post_meta($post_id, $key, true);
|
429 |
+
|
430 |
+
if($obfuscate == 'on'){
|
431 |
+
$val = cf7dtx_obfuscate($val);
|
432 |
+
}
|
433 |
+
|
434 |
+
return $val;
|
435 |
+
|
436 |
+
}
|
437 |
+
add_shortcode('CF7_get_custom_field', 'cf7_get_custom_field');
|
438 |
+
|
439 |
+
/* Insert information about the current user
|
440 |
+
* New in 1.0.4
|
441 |
+
* See http://codex.wordpress.org/Function_Reference/get_currentuserinfo
|
442 |
+
*/
|
443 |
+
function cf7_get_current_user($atts){
|
444 |
+
extract(shortcode_atts(array(
|
445 |
+
'key' => 'user_login',
|
446 |
+
), $atts));
|
447 |
+
|
448 |
+
global $current_user;
|
449 |
+
get_currentuserinfo();
|
450 |
+
|
451 |
+
$val = $current_user->$key;
|
452 |
+
return $val;
|
453 |
+
}
|
454 |
+
add_shortcode('CF7_get_current_user', 'cf7_get_current_user');
|
455 |
+
|
456 |
+
function cf7dtx_obfuscate($val){
|
457 |
+
$link = '';
|
458 |
+
foreach(str_split($val) as $letter)
|
459 |
+
$link .= '&#'.ord($letter).';';
|
460 |
+
return $link;
|
461 |
+
}
|
462 |
+
|
463 |
+
function cf7dtx_cf7com_links() {
|
464 |
+
$links = '<div class="cf7com-links">'
|
465 |
+
. '<a href="' . esc_url_raw( __( 'http://contactform7.com/', 'wpcf7' ) ) . '" target="_blank">'
|
466 |
+
. esc_html( __( 'Contactform7.com', 'wpcf7' ) ) . '</a> '
|
467 |
+
. '<a href="' . esc_url_raw( __( 'http://contactform7.com/docs/', 'wpcf7' ) ) . '" target="_blank">'
|
468 |
+
. esc_html( __( 'Docs', 'wpcf7' ) ) . '</a> - '
|
469 |
+
. '<a href="' . esc_url_raw( __( 'http://contactform7.com/faq/', 'wpcf7' ) ) . '" target="_blank">'
|
470 |
+
. esc_html( __( 'FAQ', 'wpcf7' ) ) . '</a> - '
|
471 |
+
. '<a href="' . esc_url_raw( __( 'http://contactform7.com/support/', 'wpcf7' ) ) . '" target="_blank">'
|
472 |
+
. esc_html( __( 'Support', 'wpcf7' ) ) . '</a>'
|
473 |
+
. ' - <a href="'. esc_url_raw( __( 'http://sevenspark.com/wordpress-plugins/contact-form-7-dynamic-text-extension', 'wpcf7') )
|
474 |
+
. '" target="_blank">'.__( 'Dynamic Text Extension' , 'wpcf7').'</a> by <a href="' . esc_url_raw( __( 'http://sevenspark.com', 'wpcf7') ).'" target="_blank">'
|
475 |
+
. esc_html( __( 'SevenSpark', 'wpcf7' ) ). '</a> <a href="'.esc_url_raw( __('http://bit.ly/bVogDN')).'" target="_blank">'
|
476 |
+
. esc_html( __( '[Donate]')).'</a>'
|
477 |
+
. '</div>';
|
478 |
+
return $links;
|
479 |
+
}
|
480 |
+
add_filter('wpcf7_cf7com_links', 'cf7dtx_cf7com_links');
|
481 |
+
|
482 |
+
/*function obf($atts){
|
483 |
+
extract(shortcode_atts(array(
|
484 |
+
'val' => ''
|
485 |
+
), $atts));
|
486 |
+
return $val.' : '. cf7dtx_obfuscate($val);
|
487 |
+
}
|
488 |
+
add_shortcode('obf', 'obf');*/
|
489 |
+
|
490 |
?>
|
491 |
+
|