first commit
This commit is contained in:
367
wp/wp-content/plugins/contact-form-7-modules/hidden.php
Normal file
367
wp/wp-content/plugins/contact-form-7-modules/hidden.php
Normal file
@@ -0,0 +1,367 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Contact Form 7 Modules: Hidden Fields
|
||||
Plugin URI: https://katz.co/contact-form-7-hidden-fields/
|
||||
Description: Add hidden fields to the popular Contact Form 7 plugin.
|
||||
Author: Katz Web Services, Inc.
|
||||
Author URI: http://www.katz.co
|
||||
Version: 2.0.2
|
||||
Text Domain: cf7_modules
|
||||
Domain Path: languages
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
add_action('plugins_loaded', 'contact_form_7_hidden_fields', 11);
|
||||
|
||||
function contact_form_7_hidden_fields() {
|
||||
global $pagenow;
|
||||
if ( class_exists( 'WPCF7_Shortcode' ) || class_exists('WPCF7_FormTag') ) {
|
||||
if ( function_exists( 'wpcf7_add_form_tag' ) ) {
|
||||
wpcf7_add_form_tag( array( 'hidden', 'hidden*' ), 'wpcf7_hidden_shortcode_handler', true );
|
||||
} else {
|
||||
wpcf7_add_shortcode( array( 'hidden', 'hidden*' ), 'wpcf7_hidden_shortcode_handler', true );
|
||||
}
|
||||
} else {
|
||||
if ( $pagenow != 'plugins.php' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'admin_notices', 'contact_form_7_hidden_fields_error' );
|
||||
add_action( 'admin_enqueue_scripts', 'contact_form_7_hidden_fields_scripts' );
|
||||
}
|
||||
}
|
||||
|
||||
function contact_form_7_hidden_fields_error() {
|
||||
$out = '<div class="error" id="messages"><p>';
|
||||
if ( @ file_exists( WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php' ) ) {
|
||||
$out .= esc_html__( 'The Contact Form 7 is installed, but you must activate Contact Form 7 below for the Hidden Fields Module to work.', 'cf7_modules' );
|
||||
} else {
|
||||
$out .= esc_html__( 'The Contact Form 7 plugin must be installed for the Hidden Fields Module to work.', 'cf7_modules' );
|
||||
$install_url = esc_url_raw( admin_url( 'plugin-install.php?tab=plugin-information&plugin=contact-form-7&from=plugins&TB_iframe=true&width=600&height=550' ) );
|
||||
$out .= sprintf( ' <a href="%s" class="thickbox" title="Contact Form 7">%s</a>', $install_url, esc_html__( 'Install Now.', 'cf7_modules' ) );
|
||||
}
|
||||
$out .= '</p></div>';
|
||||
echo $out;
|
||||
}
|
||||
|
||||
function contact_form_7_hidden_fields_scripts() {
|
||||
wp_enqueue_script('thickbox');
|
||||
}
|
||||
|
||||
/**
|
||||
** A base module for [hidden] and [hidden*]
|
||||
**/
|
||||
|
||||
/* Shortcode handler */
|
||||
|
||||
add_filter('wpcf7_form_elements', 'wpcf7_form_elements_strip_paragraphs_and_brs');
|
||||
|
||||
/**
|
||||
* Strip paragraph tags being wrapped around the field
|
||||
* @param $form
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function wpcf7_form_elements_strip_paragraphs_and_brs($form) {
|
||||
return preg_replace_callback( '/<p>(<input\stype="hidden"(?:.*?))<\/p>/ism', 'wpcf7_form_elements_strip_paragraphs_and_brs_callback', $form );
|
||||
}
|
||||
|
||||
function wpcf7_form_elements_strip_paragraphs_and_brs_callback($matches = array()) {
|
||||
return "\n" . '<!-- CF7 Modules -->' . "\n" . '<div style=\'display:none;\'>' . str_replace( '<br>', '', str_replace( '<br />', '', stripslashes_deep( $matches[1] ) ) ) . '</div>' . "\n" . '<!-- End CF7 Modules -->' . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
** A base module for [hidden], [hidden*]
|
||||
**/
|
||||
|
||||
/* Shortcode handler */
|
||||
|
||||
function wpcf7_hidden_shortcode_handler( $tag ) {
|
||||
|
||||
if ( class_exists( 'WPCF7_FormTag' ) ) {
|
||||
$tag = new WPCF7_FormTag( $tag );
|
||||
} else {
|
||||
$tag = new WPCF7_Shortcode( $tag );
|
||||
}
|
||||
|
||||
if ( empty( $tag->name ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$validation_error = wpcf7_get_validation_error( $tag->name );
|
||||
|
||||
$class = wpcf7_form_controls_class( $tag->type, 'wpcf7-hidden' );
|
||||
|
||||
if ( $validation_error ) {
|
||||
$class .= ' wpcf7-not-valid';
|
||||
}
|
||||
|
||||
$class .= ' wpcf7-hidden';
|
||||
|
||||
if ( 'hidden*' === $tag->type ) {
|
||||
$class .= ' wpcf7-validates-as-required';
|
||||
}
|
||||
|
||||
$value = (string) reset( $tag->values );
|
||||
|
||||
$placeholder = '';
|
||||
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
||||
$placeholder = $value;
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$default_value = $tag->get_default_option( $value );
|
||||
|
||||
$value = contact_form_7_hidden_fields_fill_post_data( $value, $tag );
|
||||
|
||||
// Post data hasn't filled yet. No arrays.
|
||||
if ( $default_value === $value ) {
|
||||
$value = contact_form_7_hidden_fields_fill_user_data( $value );
|
||||
}
|
||||
|
||||
// Arrays get imploded.
|
||||
$value = is_array( $value ) ? implode( apply_filters( 'wpcf7_hidden_field_implode_glue', ', ' ), $value ) : $value;
|
||||
|
||||
// Make sure we're using a string. Objects get JSON-encoded.
|
||||
if ( ! is_string( $value ) ) {
|
||||
$value = json_encode( $value );
|
||||
}
|
||||
|
||||
$value = apply_filters( 'wpcf7_hidden_field_value', apply_filters( 'wpcf7_hidden_field_value_' . $tag->get_id_option(), $value ) );
|
||||
|
||||
$value = wpcf7_get_hangover( $tag->name, $value );
|
||||
|
||||
$atts = array(
|
||||
'type' => 'hidden',
|
||||
'class' => $tag->get_class_option( $class ),
|
||||
'id' => $tag->get_id_option(),
|
||||
'name' => $tag->name,
|
||||
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
||||
'placeholder' => $placeholder,
|
||||
'value' => $value,
|
||||
);
|
||||
|
||||
$atts = wpcf7_format_atts( $atts );
|
||||
|
||||
$html = sprintf( '<input %1$s />%2$s', $atts, $validation_error );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill data based on user information.
|
||||
*
|
||||
* @param string $value Existing value, if any
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function contact_form_7_hidden_fields_fill_user_data( $value ) {
|
||||
|
||||
$return = $value;
|
||||
|
||||
// Process user stuff
|
||||
if ( preg_match( '/user/ism', strtolower( trim( $value ) ) ) && is_user_logged_in() ) {
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
switch ( $value ) {
|
||||
case 'user_name':
|
||||
$return = $current_user->user_login;
|
||||
break;
|
||||
case 'user_id':
|
||||
$return = $current_user->ID;
|
||||
break;
|
||||
case 'caps':
|
||||
$return = $current_user->caps;
|
||||
break;
|
||||
case 'allcaps':
|
||||
$return = $current_user->allcaps;
|
||||
break;
|
||||
case 'user_roles':
|
||||
$return = $current_user->roles;
|
||||
break;
|
||||
default:
|
||||
// Gets the values for `user_email`, others that have `user_` prefix.
|
||||
if ( $current_user->has_prop( $value ) ) {
|
||||
$return = $current_user->get( $value );
|
||||
} else {
|
||||
// Define some other item in the WP_User object using the `user_[what you want to get]` format
|
||||
// This works for the `user_display_name` setting
|
||||
$user_key = preg_replace( '/user[_-](.+)/ism', '$1', $value );
|
||||
if ( $current_user->has_prop( $user_key ) ) {
|
||||
$return = $current_user->get( $user_key );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill data based on user information.
|
||||
*
|
||||
* @param string $value Existing value, if any
|
||||
* @param WPCF7_Shortcode $tag Tag
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function contact_form_7_hidden_fields_fill_post_data( $value = '', $tag ) {
|
||||
global $post;
|
||||
|
||||
$return = $value;
|
||||
|
||||
if ( is_object( $post ) ) {
|
||||
|
||||
switch ( strtolower( trim( $value ) ) ) {
|
||||
case 'post_title':
|
||||
case 'post-title':
|
||||
$return = $post->post_title;
|
||||
break;
|
||||
case 'page_url':
|
||||
case 'post_url':
|
||||
$return = get_permalink( $post->ID );
|
||||
if ( empty( $return ) && isset( $post->guid ) ) {
|
||||
$return = $post->guid;
|
||||
}
|
||||
$return = esc_url( $return );
|
||||
break;
|
||||
case 'post_category':
|
||||
$categories = get_the_category( $post->ID );
|
||||
$catnames = array();
|
||||
// Get the category names
|
||||
foreach ( $categories as $cat ) {
|
||||
$catnames[] = $cat->cat_name;
|
||||
}
|
||||
|
||||
$return = implode( ', ', $catnames );
|
||||
break;
|
||||
case 'post_author_id':
|
||||
$return = $post->post_author;
|
||||
break;
|
||||
case 'post_author':
|
||||
$user = get_userdata( $post->post_author );
|
||||
$return = $user->display_name;
|
||||
break;
|
||||
default:
|
||||
// You want post_modified? just use [hidden hidden-123 "post_modified"]
|
||||
if ( isset( $post->{ $value } ) ) {
|
||||
$return = $post->{ $value };
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ( preg_match( '/^custom_field\-(.*?)$/ism', $value ) ) {
|
||||
$custom_field = preg_replace( '/custom_field\-(.*?)/ism', '$1', $value );
|
||||
$return = get_post_meta( $post->ID, $custom_field, false ) ? get_post_meta( $post->ID, $custom_field, false ) : '';
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/* Tag generator */
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_init', 'wpcf7_add_tag_generator_hidden', 30 );
|
||||
}
|
||||
|
||||
function wpcf7_add_tag_generator_hidden() {
|
||||
|
||||
if ( class_exists( 'WPCF7_TagGenerator' ) ) {
|
||||
|
||||
$tag_generator = WPCF7_TagGenerator::get_instance();
|
||||
$tag_generator->add( 'hidden', _x( 'hidden', 'the name of the field button in CF7', 'cf7_modules' ), 'wpcf7_tg_pane_hidden' );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function wpcf7_tg_pane_hidden( $contact_form, $args = '' ) {
|
||||
|
||||
$args = wp_parse_args( $args, array() );
|
||||
|
||||
$description = __( "Generate a form tag for a hidden field. For more details, see %s.", 'contact-form-7' );
|
||||
$desc_link = wpcf7_link( 'https://wordpress.org/plugins/contact-form-7-modules/', __( 'the plugin page on WordPress.org', 'contact-form-7' ), array( 'target' => '_blank' ) );
|
||||
?>
|
||||
<div class="control-box">
|
||||
<fieldset>
|
||||
<legend><?php printf( esc_html( $description ), $desc_link ); ?></legend>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row"><label
|
||||
for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label>
|
||||
</th>
|
||||
<td><input type="text" name="name" class="tg-name oneline"
|
||||
id="<?php echo esc_attr( $args['content'] . '-name' ); ?>"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label
|
||||
for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'ID attribute', 'contact-form-7' ) ); ?>
|
||||
(<?php echo esc_html( __( 'optional', 'cf7_modules' ) ); ?>)</label></th>
|
||||
<td><input type="text" name="id" class="idvalue oneline option"
|
||||
id="<?php echo esc_attr( $args['content'] . '-id' ); ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php _e( 'Value', 'cf7_modules' ); ?>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="values" class="oneline"/>
|
||||
<div>
|
||||
<input type="checkbox" name="watermark"
|
||||
class="option"/> <?php echo esc_html( __( 'Use this text as watermark?', 'cf7_modules' ) ); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php _e( 'Dynamic Values', 'cf7_modules' ); ?>
|
||||
</th>
|
||||
<td>
|
||||
<span class="howto"
|
||||
style="font-size:1em;"><?php _e( 'To use dynamic data from the post or page the form is embedded on, you can use the following values:', 'cf7_modules' ); ?></span>
|
||||
|
||||
<ul>
|
||||
<li><?php _e( '<code>post_title</code>: The title of the post/page', 'cf7_modules' ); ?></li>
|
||||
<li><?php _e( '<code>post_url</code>: The URL of the post/page', 'cf7_modules' ); ?></li>
|
||||
<li><?php _e( '<code>post_category</code>: The categories the post is in, comma-separated', 'cf7_modules' ); ?></li>
|
||||
<li><?php _e( '<code>post_date</code>: The date the post/page was created', 'cf7_modules' ); ?></li>
|
||||
<li><?php _e( '<code>post_author</code>: The name of the author of the post/page', 'cf7_modules' ); ?></li>
|
||||
</ul>
|
||||
<span class="howto"><?php _e( 'The following values will be replaced if an user is logged in:', 'cf7_modules' ); ?></span>
|
||||
<ul>
|
||||
<li><?php _e( '<code>user_name</code>: User Login', 'cf7_modules' ); ?></li>
|
||||
<li><?php _e( '<code>user_id</code>: User ID', 'cf7_modules' ); ?></li>
|
||||
<li><?php _e( '<code>user_email</code>: User Email Address', 'cf7_modules' ); ?></li>
|
||||
<li><?php _e( '<code>user_display_name</code>: Display Name (Generally the first and last name of the user)', 'cf7_modules' ); ?></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="insert-box">
|
||||
<input type="text" name="hidden" class="tag code" readonly="readonly" onfocus="this.select()"/>
|
||||
|
||||
<div class="submitbox">
|
||||
<input type="button" class="button button-primary insert-tag"
|
||||
value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>"/>
|
||||
</div>
|
||||
|
||||
<br class="clear"/>
|
||||
|
||||
<p class="description mail-tag"><label
|
||||
for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'contact-form-7' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?>
|
||||
<input type="text" class="mail-tag code hidden" readonly="readonly"
|
||||
id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"/></label></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
BIN
wp/wp-content/plugins/contact-form-7-modules/languages/en_US.mo
Normal file
BIN
wp/wp-content/plugins/contact-form-7-modules/languages/en_US.mo
Normal file
Binary file not shown.
133
wp/wp-content/plugins/contact-form-7-modules/languages/en_US.po
Normal file
133
wp/wp-content/plugins/contact-form-7-modules/languages/en_US.po
Normal file
@@ -0,0 +1,133 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Contact Form 7 Modules: Send All Fields\n"
|
||||
"POT-Creation-Date: 2017-02-01 18:49-0700\n"
|
||||
"PO-Revision-Date: 2017-02-01 18:49-0700\n"
|
||||
"Last-Translator: Katz Web Services, Inc. <support@katz.co>\n"
|
||||
"Language-Team: Zack Katz <support@katz.co>\n"
|
||||
"Language: en_US\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.5\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
|
||||
"_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: hidden.php:38
|
||||
msgid ""
|
||||
"The Contact Form 7 is installed, but you must activate Contact Form 7 below "
|
||||
"for the Hidden Fields Module to work."
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:40
|
||||
msgid ""
|
||||
"The Contact Form 7 plugin must be installed for the Hidden Fields Module to "
|
||||
"work."
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:42
|
||||
msgid "Install Now."
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:277
|
||||
msgctxt "the name of the field button in CF7"
|
||||
msgid "hidden"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:286
|
||||
#, php-format
|
||||
msgid "Generate a form tag for a hidden field. For more details, see %s."
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:287
|
||||
msgid "the plugin page on WordPress.org"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:297
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:305
|
||||
msgid "ID attribute"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:306
|
||||
msgid "optional"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:312
|
||||
msgid "Value"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:318
|
||||
msgid "Use this text as watermark?"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:324
|
||||
msgid "Dynamic Values"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:328
|
||||
msgid ""
|
||||
"To use dynamic data from the post or page the form is embedded on, you can "
|
||||
"use the following values:"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:331
|
||||
msgid "<code>post_title</code>: The title of the post/page"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:332
|
||||
msgid "<code>post_url</code>: The URL of the post/page"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:333
|
||||
msgid ""
|
||||
"<code>post_category</code>: The categories the post is in, comma-separated"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:334
|
||||
msgid "<code>post_date</code>: The date the post/page was created"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:335
|
||||
msgid "<code>post_author</code>: The name of the author of the post/page"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:337
|
||||
msgid "The following values will be replaced if an user is logged in:"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:339
|
||||
msgid "<code>user_name</code>: User Login"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:340
|
||||
msgid "<code>user_id</code>: User ID"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:341
|
||||
msgid "<code>user_email</code>: User Email Address"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:342
|
||||
msgid ""
|
||||
"<code>user_display_name</code>: Display Name (Generally the first and last "
|
||||
"name of the user)"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:356
|
||||
msgid "Insert Tag"
|
||||
msgstr ""
|
||||
|
||||
#: hidden.php:362
|
||||
#, php-format
|
||||
msgid ""
|
||||
"To use the value input through this field in a mail field, you need to "
|
||||
"insert the corresponding mail-tag (%s) into the field on the Mail tab."
|
||||
msgstr ""
|
||||
256
wp/wp-content/plugins/contact-form-7-modules/readme.txt
Normal file
256
wp/wp-content/plugins/contact-form-7-modules/readme.txt
Normal file
@@ -0,0 +1,256 @@
|
||||
=== Contact Form 7 Modules ===
|
||||
Tags: Contact Form 7, cf7, Contact Forms 7, hidden fields, all fields
|
||||
Requires at least: 2.8
|
||||
Tested up to: 4.7.2
|
||||
Stable tag: trunk
|
||||
Contributors: katzwebdesign, katzwebservices
|
||||
Donate link: https://katz.co/contact-form-7-hidden-fields/
|
||||
License: GPLv2 or later
|
||||
|
||||
Contact Form 7 - Add useful modules such as hidden fields and "send all fields" to the Contact Form 7 plugin
|
||||
|
||||
== Description ==
|
||||
|
||||
### Add Hidden Fields to Contact Form 7
|
||||
|
||||
The Contact Form 7 plugin has over <em>1 million</em> active installations, yet the great plugin still lacks a simple feature: <strong>hidden fields</strong>. This plugin adds hidden fields to Contact Form 7 once and for all.
|
||||
|
||||
#### Inserting dynamic values
|
||||
|
||||
You can also choose to have the value of the hidden field dynamically populated in your form when you are contacted. To do so, choose the "Default value" to be:
|
||||
|
||||
* `post_title` - Inserts the title of the post/page
|
||||
* `post_category` - The categories of the post or page
|
||||
* `post_url` - The URL of the post or page
|
||||
* `post_author` - The author of the post or page
|
||||
* `custom_field-[Name]` - The value of a post or page's custom field. If you had a custom field "Foo", you would use the following as the hidden field value: `custom_field-Foo`
|
||||
|
||||
The following values will be replaced if an user is logged in:
|
||||
|
||||
* `user_name`: User Login
|
||||
* `user_id`: User ID
|
||||
* `user_email`: User Email Address
|
||||
* `user_display_name`: Display Name (Generally the first and last name of the user)
|
||||
* `user_url`: User Website
|
||||
|
||||
And you can also use it for user custom meta data using the format of `user-{field}`:
|
||||
|
||||
* `user-aim`: AIM
|
||||
* `user-jabber`: Jabber / Google Talk
|
||||
* `user-description`: User Bio
|
||||
|
||||
<strong>You can also use a filter:</strong> hook into the `wpcf7_hidden_field_value` filter to modify the value of the hidden field using <a href="http://codex.wordpress.org/Function_Reference/add_filter" rel="nofollow"><code>add_filter()</code></a>. If you know the ID of the input, you can also use the `wpcf7_hidden_field_value_[#ID]` filter.
|
||||
|
||||
Now, when someone contacts you using your Contact Form 7 contact form, you can have lots more information about their visit - and you'll see it when you receive the email that tells you you've been contacted.
|
||||
|
||||
### Easily Send All Submitted Fields At Once
|
||||
|
||||
####Save time setting up your form emails...and never miss a field!
|
||||
|
||||
One of the limitations of Contact Form 7 is that you need to manually add each field to generated emails. This means that if you update the form with a new field and forget to add it to your email message, you won't receive it in your email. <strong>No longer.</strong>.
|
||||
|
||||
Using the <strong>Send All Fields</strong> module, you simply need to add `[all-fields]` to your message, and you will receive every field submitted. If you use HTML formatting, the formatting even looks nice.
|
||||
|
||||
<h4>Visit the official <a href="https://katz.co/contact-form-7-hidden-fields/">Contact Form 7 Modules plugin page</a> for more support & additional information</h4>
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. The Hidden fields tag generator
|
||||
2. The `[all-fields]` Mail tag
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Upload plugin files to your plugins folder, or install using WordPress' built-in Add New Plugin installer
|
||||
1. Activate the plugin
|
||||
1. Edit a form in Contact Form 7
|
||||
1. Choose "Hidden field" from the Generate Tag dropdown
|
||||
1. Follow the instructions on the page
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= How do I turn off formatting the key in the `[all-fields]` output? =
|
||||
Add the following to your theme's `functions.php` file:
|
||||
|
||||
`
|
||||
add_filter('wpcf7_send_all_fields_format_key', '__return_false');
|
||||
`
|
||||
|
||||
= How do I set non-standard user data as hidden field values? =
|
||||
|
||||
Starting with Version 1.4, you can access user data, including meta data.
|
||||
|
||||
You need to set the default value as: `user-{meta_key}` where `{meta_key}` is the key of the meta field you want the value of.
|
||||
|
||||
To get the values of WordPress default profile fields, for example, you would use:
|
||||
|
||||
* `user-aim` - AOL
|
||||
* `user-jabber` - Jabber / Google Talk
|
||||
* `user-description` - Biographical description
|
||||
|
||||
= What is the plugin license? =
|
||||
|
||||
* This plugin is released under a GPL license.
|
||||
|
||||
= How do I send empty values with the `[all-fields]` shortcode? =
|
||||
|
||||
Add this to your `functions.php` file: `add_filter('wpcf7_send_all_fields_send_empty_fields', '__return_true');`
|
||||
|
||||
= How do I modify the output of the `[all-fields]` shortcode? =
|
||||
|
||||
* `wpcf7_send_all_fields_format_before` - Before the loop of fields (`<dl>` for HTML output)
|
||||
* `$value` _string_ Previous output
|
||||
* `$format` _string_ Either "html" or "text"
|
||||
* `wpcf7_send_all_fields_format_item` - Change each item output. Passes four arguments:
|
||||
* `$value` _string_ Previous output
|
||||
* `$k` _string_ Field label
|
||||
* `$v` _string_ Value of the field
|
||||
* `$format` _string_ Either "html" or "text"
|
||||
* `wpcf7_send_all_fields_format_after` - After the loop of fields (`</dl>` for HTML output). Passes two arguments:
|
||||
* `$value` _string_ Previous output
|
||||
* `$format` _string_ Either "html" or "text"
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 2.0.1 & 2.0.2 on February 1, 2017 =
|
||||
|
||||
* Confirmed compatibility with WordPress 4.7.2
|
||||
* Updated to work with Contact Form 7 4.6
|
||||
* Fixed: `[hidden]` shortcodes not being replaced in emails
|
||||
* Fixed: PHP warning related to deprecated function
|
||||
* Fixed: Removed use of deprecated `get_currentuserinfo()` function
|
||||
* Updated translations
|
||||
|
||||
= 2.0 on June 28, 2015 =
|
||||
* **Requires Contact Form 7 4.2 or higher**
|
||||
* Updated to work with latest Contact Form 7
|
||||
* Removed Contact Form 7 Newsletter plugin promotion
|
||||
|
||||
= 1.4.2 on March 25, 2014 =
|
||||
* Added: `[all-fields]` shortcode now skips sending data for empty fields
|
||||
* Added `wpcf7_send_all_fields_send_empty_fields` filter to override the setting. See the FAQ.
|
||||
* Added: `[all-fields]` shortcode output filters (see the FAQ item "How do I modify the output...")
|
||||
* `wpcf7_send_all_fields_format_before`
|
||||
* `wpcf7_send_all_fields_format_item`
|
||||
* `wpcf7_send_all_fields_format_after`
|
||||
|
||||
= 1.4 & 1.4.1 on March 15, 2014 =
|
||||
* Added: Internationalization support. [Help translate the plugin!](https://www.transifex.com/projects/p/contact-form-7-modules/)
|
||||
|
||||
__The below updates apply only to the Hidden Fields module.__
|
||||
|
||||
* Added: Support for retrieving other user data by using the field name `user_{data you want}`. See the FAQ "How do I set non-standard user data as hidden field values?"
|
||||
* Added: `wpcf7_hidden_field_implode_glue` filter. If you want to modify how arrays of data get combined into a string (default is CSV), use this filter.
|
||||
* Fixed: `$post` global no longer needs to be defined for user data to be successfully passed.
|
||||
* Fixed: Now supports multiple post `custom_field` data values, instead of only fetching one
|
||||
* Modified: Added callback function to format the hidden field instead of relying on depricated PHP
|
||||
* Modified: Improved include path for `functions.php` file
|
||||
* Modified: Added text to support additional localization
|
||||
|
||||
= 1.3.3 =
|
||||
* Hidden Fields: Fixed issue that broke the plugin with WordPress 3.8.
|
||||
|
||||
= 1.3.2 =
|
||||
* Hidden Fields: Fixed PHP notice caused by improper adding of script in administration
|
||||
* Hidden Fields: Fixed double inputs that were the exact same (<a href="http://wordpress.org/support/topic/render-the-fields-twice">as reported here</a>)
|
||||
|
||||
= 1.3.1 =
|
||||
* Fixed: issue in Hidden Fields where the `[hidden-###]` shortcode no longer worked and only `[post_title]` format worked.
|
||||
* Added: Hidden fields now support both formats: `[hidden-123]` and `[post_title]` as long as they're in the form itself.
|
||||
* Fixed: issue in Send All Fields where the <a href="http://wordpress.org/support/topic/post_title-hidden-field-no-longer-working#post-3708463">HTML was showing as text</a>.
|
||||
* Added `wpcf7_send_all_fields_format_key` filter to Send All Fields plugin to turn on or off formatting of the key (replacing `example-key` with `Example Key` in output). See "How do I turn off formatting the key in the `[all-fields]` output?" in the FAQ.
|
||||
|
||||
= 1.3 =
|
||||
* Fixed: Hidden field now supports new Contact Form 7 format; post fields will work again.
|
||||
* Fixed: Send All Fields no longer causes spinning form submission in WordPress 3.5
|
||||
* Added: access any of the <a href="http://www.rlmseo.com/blog/wordpress-post-variable-quick-reference/" rel='nofollow'>data in `$post` object</a> by using the variable name. Example: You want `post_modified`? Use `[hidden hidden-123 "post_modified"]`
|
||||
* Added: If an user is logged in, you can now use `user_name`, `user_id`, `user_email`, `user_display_name` replacement values
|
||||
* Added/Improved: `post_author` will now return the author's Display Name. Use `post_author_id` for the post author's ID.
|
||||
* Added: Inline instructions on the Hidden field module
|
||||
* Improved: In Send All Fields, the name of the field now has dashes replaced with spaces. This will show "your name", rather than "your-name". Thanks, <a href="http://wordpress.org/support/topic/sending-all-fields-with-content-code-provided">@hitolonen</a>
|
||||
|
||||
= 1.2.2 =
|
||||
* Removed `_wpnonce` field from `[all-fields]` output
|
||||
* Fixed a conflict when using "Send All Fields" module alongside "Hidden Fields" module (<a href="http://wordpress.org/support/topic/plugin-contact-form-7-modules-all-fields-doesn´t-work-wit-wordpress-33">as reported here</a>)
|
||||
|
||||
= 1.2.1 =
|
||||
* Added support for checkboxes with Send All Fields (`[all-fields]`)
|
||||
|
||||
= 1.2 =
|
||||
* Hidden fields are now displayed inside a hidden `<div>` instead of Contact Form 7's default `<p>`. This makes hidden fields more hidden :-)
|
||||
* Added brand-new module: Send All Fields. Allows you to add a `[all-fields]` tag to your email message that includes every submitted field in one tag.
|
||||
|
||||
= 1.1.1 =
|
||||
* Fixed `Parameter 1 to wpcf7_add_tag_generator_hidden() expected to be a reference, value given` error, <a href="http://www.seodenver.com/contact-form-7-hidden-fields/#comment-116384456"> as reported by BDN Online</a>
|
||||
|
||||
= 1.1 =
|
||||
* Added support for using post titles as hidden fields
|
||||
* Added support for using custom field values as hidden fields
|
||||
* Added `wpcf7_hidden_field_value` filter to hook into using <a href="http://codex.wordpress.org/Function_Reference/add_filter" rel="nofollow"><code>add_filter()</code></a>
|
||||
|
||||
= 1.0 =
|
||||
* Initial plugin release.
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 1.4.2 on March 25, 2014 =
|
||||
* Added: `[all-fields]` shortcode now skips sending data for empty fields
|
||||
* Added `wpcf7_send_all_fields_send_empty_fields` filter to override the setting. See the FAQ.
|
||||
* Added: `[all-fields]` shortcode output filters (see the FAQ item "How do I modify the output...")
|
||||
* `wpcf7_send_all_fields_format_before`
|
||||
* `wpcf7_send_all_fields_format_item`
|
||||
* `wpcf7_send_all_fields_format_after`
|
||||
|
||||
= 1.4 & 1.4.1 on March 15, 2014 =
|
||||
* Added: Internationalization support. [Help translate the plugin!](https://www.transifex.com/projects/p/contact-form-7-modules/)
|
||||
|
||||
__The below updates apply only to the Hidden Fields module.__
|
||||
|
||||
* Added: Support for retrieving other user data by using the field name `user_{data you want}`. See the FAQ "How do I set non-standard user data as hidden field values?"
|
||||
* Added: `wpcf7_hidden_field_implode_glue` filter. If you want to modify how arrays of data get combined into a string (default is CSV), use this filter.
|
||||
* Fixed: `$post` global no longer needs to be defined for user data to be successfully passed.
|
||||
* Fixed: Now supports multiple post `custom_field` data values, instead of only fetching one
|
||||
* Modified: Added callback function to format the hidden field instead of relying on depricated PHP
|
||||
* Modified: Improved include path for `functions.php` file
|
||||
* Modified: Added text to support additional localization
|
||||
|
||||
= 1.3.3 =
|
||||
* Hidden Fields: Fixed issue that broke the plugin with the WordPress 3.8
|
||||
|
||||
= 1.3.2 =
|
||||
* Hidden Fields: Fixed PHP notice caused by improper adding of script in administration
|
||||
* Hidden Fields: Fixed double inputs that were the exact same (<a href="http://wordpress.org/support/topic/render-the-fields-twice">as reported here</a>)
|
||||
|
||||
= 1.3.1 =
|
||||
* Fixed: issue in Hidden Fields where the `[hidden-###]` shortcode no longer worked and only `[post_title]` format worked.
|
||||
* Fixed: issue in Send All Fields where the <a href="http://wordpress.org/support/topic/post_title-hidden-field-no-longer-working#post-3708463">HTML was showing as text</a>.
|
||||
|
||||
= 1.3 =
|
||||
* Fixed: Hidden field now supports new Contact Form 7 format; post fields will work again.
|
||||
* Fixed: Send All Fields no longer causes spinning form submission in WordPress 3.5
|
||||
* Added: access any of the <a href="http://www.rlmseo.com/blog/wordpress-post-variable-quick-reference/" rel='nofollow'>data in `$post` object</a> by using the variable name. Example: You want `post_modified`? Use `[hidden hidden-123 "post_modified"]`
|
||||
* Added: If an user is logged in, you can now use `user_name`, `user_id`, `user_email`, `user_display_name` replacement values
|
||||
* Added/Improved: `post_author` will now return the author's Display Name. Use `post_author_id` for the post author's ID.
|
||||
* Added: Inline instructions on the Hidden field module
|
||||
* Improved: In Send All Fields, the name of the field now has dashes replaced with spaces. This will show "your name", rather than "your-name". Thanks, <a href="http://wordpress.org/support/topic/sending-all-fields-with-content-code-provided">@hitolonen</a>
|
||||
|
||||
= 1.2.2 =
|
||||
* Removed `_wpnonce` field from `[all-fields]` output
|
||||
* Fixed a conflict when using "Send All Fields" module alongside "Hidden Fields" module (<a href="http://wordpress.org/support/topic/plugin-contact-form-7-modules-all-fields-doesn´t-work-wit-wordpress-33">as reported here</a>)
|
||||
|
||||
= 1.2.1 =
|
||||
* Added support for checkboxes with Send All Fields (`[all-fields]`)
|
||||
|
||||
= 1.2 =
|
||||
* Hidden fields are now displayed inside a hidden `<div>` instead of Contact Form 7's default `<p>`. This makes hidden fields more hidden :-)
|
||||
* Added brand-new module: Send All Fields. Allows you to add a `[all-fields]` tag to your email message that includes every submitted field in one tag.
|
||||
|
||||
= 1.1.1 =
|
||||
* Fixed `Parameter 1 to wpcf7_add_tag_generator_hidden() expected to be a reference, value given` error, <a href="http://www.seodenver.com/contact-form-7-hidden-fields/#comment-116384456"> as reported by BDN Online</a>
|
||||
|
||||
= 1.1 =
|
||||
* Added support for using post titles as hidden fields
|
||||
* Added support for using custom field values as hidden fields
|
||||
* Added `wpcf7_hidden_field_value` filter to hook into using <a href="http://codex.wordpress.org/Function_Reference/add_filter" rel="nofollow"><code>add_filter()</code></a>
|
||||
|
||||
= 1.0 =
|
||||
* Woot!
|
||||
BIN
wp/wp-content/plugins/contact-form-7-modules/screenshot-1.jpg
Normal file
BIN
wp/wp-content/plugins/contact-form-7-modules/screenshot-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 186 KiB |
BIN
wp/wp-content/plugins/contact-form-7-modules/screenshot-2.jpg
Normal file
BIN
wp/wp-content/plugins/contact-form-7-modules/screenshot-2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
111
wp/wp-content/plugins/contact-form-7-modules/send-all-fields.php
Normal file
111
wp/wp-content/plugins/contact-form-7-modules/send-all-fields.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Contact Form 7 Modules: Send All Fields
|
||||
Plugin URI: https://katz.co/contact-form-7-hidden-fields/
|
||||
Description: Send all submitted fields in the message body using one simple tag: <code>[all-fields]</code>
|
||||
Author: Katz Web Services, Inc.
|
||||
Author URI: http://www.katz.co
|
||||
Version: 2.0.2
|
||||
Text Domain: cf7_modules
|
||||
Domain Path: languages
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
add_filter('wpcf7_mail_components', 'all_fields_wpcf7_before_send_mail');
|
||||
|
||||
function all_fields_wpcf7_before_send_mail($array) {
|
||||
$debug = false;
|
||||
|
||||
if ( $debug ) {
|
||||
print_r( $array );
|
||||
}
|
||||
if ( $debug ) {
|
||||
print_r( $_POST );
|
||||
}
|
||||
|
||||
$post = $_POST;
|
||||
|
||||
$html = false;
|
||||
if ( wpautop( $array['body'] ) == $array['body'] ) {
|
||||
$html = true;
|
||||
}
|
||||
|
||||
foreach ( $post as $k => $v ) {
|
||||
if ( substr( $k, 0, 6 ) == '_wpcf7' || strpos( $k, 'all-fields' ) || $k === '_wpnonce' ) {
|
||||
unset( $post["{$k}"] );
|
||||
}
|
||||
}
|
||||
if ( $debug ) {
|
||||
print_r( $post );
|
||||
}
|
||||
|
||||
$postbody = '';
|
||||
|
||||
if ( $html ) {
|
||||
$postbody = apply_filters( 'wpcf7_send_all_fields_format_before', '<dl>', 'html' );
|
||||
} else {
|
||||
$postbody = apply_filters( 'wpcf7_send_all_fields_format_before', '', 'text' );
|
||||
}
|
||||
|
||||
foreach ( $post as $k => $v ) {
|
||||
|
||||
// Remove dupe content. The Hidden and Values are both sent.
|
||||
if ( preg_match( '/hidden\-/', $k ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there's no value for the field, don't send it.
|
||||
if ( empty( $v ) && false === apply_filters( 'wpcf7_send_all_fields_send_empty_fields', false ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_array( $v ) ) {
|
||||
$v = implode( ', ', $v );
|
||||
}
|
||||
|
||||
// Make the fields easier to read. Thanks, @hitolonen
|
||||
$k = apply_filters( 'wpcf7_send_all_fields_format_key', true ) ? ucwords( str_replace( "-", " ", str_replace( "_", " ", $k ) ) ) : $k;
|
||||
|
||||
// Sanitize!
|
||||
$k = esc_attr( $k );
|
||||
$v = esc_attr( $v );
|
||||
|
||||
if ( $html ) {
|
||||
$postbody .= apply_filters( 'wpcf7_send_all_fields_format_item', "<dt style='font-size:1.2em;'><font size='3'><strong style='font-weight:bold;'>{$k}</strong>:</font></dt><dd style='padding:0 0 .5em 1.5em; margin:0;'>{$v}</dd>", $k, $v, 'html' );
|
||||
} else {
|
||||
$postbody .= apply_filters( 'wpcf7_send_all_fields_format_item', "{$k}: {$v}\n", $k, $v, 'text' );
|
||||
}
|
||||
}
|
||||
if ( $html ) {
|
||||
$postbody .= apply_filters( 'wpcf7_send_all_fields_format_after', '</dl>', 'html' );
|
||||
} else {
|
||||
$postbody .= apply_filters( 'wpcf7_send_all_fields_format_after', '', 'text' );
|
||||
}
|
||||
|
||||
if ( $debug ) {
|
||||
print_r( $postbody );
|
||||
}
|
||||
|
||||
$array['body'] = str_replace( '<p>[all-fields]</p>', $postbody, str_replace( '[all-fields]', $postbody, $array['body'] ) );
|
||||
|
||||
if ( $debug ) {
|
||||
die();
|
||||
} else {
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
add_filter('wpcf7_collect_mail_tags', 'wpcf7_collect_mail_tags_add_all_fields_tag');
|
||||
|
||||
/**
|
||||
* Add a all-fields option to the Mail tab's merge tags
|
||||
* @since 2.0
|
||||
* @param array $mailtags
|
||||
*/
|
||||
function wpcf7_collect_mail_tags_add_all_fields_tag( $mailtags = array() ) {
|
||||
|
||||
$mailtags[] = 'all-fields';
|
||||
|
||||
return $mailtags;
|
||||
}
|
||||
Reference in New Issue
Block a user