This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetparam.php
55 lines (43 loc) · 1.86 KB
/
getparam.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Plugin Name: Contact Form 7 Get and Show Parameter from URL
* Plugin URI: http://elementdesignllc.com/2011/11/contact-form-7-get-parameter-from-url-into-form-plugin/
* Description: Get and Show Parameter from URL Contact Form 7 Plugin
* Version: 0.9.7
* Author: Chad Huntley
* Author URI: http://URI_Of_The_Plugin_Author
* License: GPL2
*/
/* Copyright 2013 Chad Huntley (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
add_action( 'wpcf7_init', 'wpcf7_add_shortcode_getparam' );
function wpcf7_add_shortcode_getparam() {
if ( function_exists( 'wpcf7_add_shortcode' ) ) {
wpcf7_add_shortcode( 'getparam', 'wpcf7_getparam_shortcode_handler', true );
wpcf7_add_shortcode( 'showparam', 'wpcf7_showparam_shortcode_handler', true );
}
}
function wpcf7_getparam_shortcode_handler($tag) {
if (!is_array($tag)) return '';
$name = $tag['name'];
if (empty($name)) return '';
$html = '<input type="hidden" name="' . $name . '" value="'. esc_attr( $_GET[$name] ) . '" />';
return $html;
}
function wpcf7_showparam_shortcode_handler($tag) {
if (!is_array($tag)) return '';
$name = $tag['name'];
if (empty($name)) return '';
$html = esc_html( $_GET[$name] );
return $html;
}