This commit is contained in:
Rachit Bhargava
2024-01-10 11:53:33 -05:00
parent 83d223b0df
commit 054b4fffc9
16481 changed files with 0 additions and 3473867 deletions

View File

@@ -1,466 +0,0 @@
<?php
/**
* Admin Scripts and Styles
*
* Enqueue scripts and styles to be used on the admin pages
*
* @since 3.1.0
*
* @param string $hook Hook suffix for the current admin page
*
* @return void
*/
function wpcf7dtx_enqueue_admin_assets($hook)
{
// Only load on CF7 Form pages (both editing forms and creating new forms)
if ($hook === 'toplevel_page_wpcf7' || $hook === 'contact_page_wpcf7-new') {
$prefix = 'wpcf7dtx-';
$debug = defined('WP_DEBUG_SCRIPTS') && constant('WP_DEBUG_SCRIPTS');
$url = plugin_dir_url(WPCF7DTX_FILE);
$path = plugin_dir_path(WPCF7DTX_FILE);
wp_enqueue_style(
$prefix . 'admin', //Handle
$url . 'assets/styles/tag-generator' . ($debug ? '' : '.min') . '.css', //Source
array('contact-form-7-admin'), //Dependencies
$debug ? @filemtime($path . 'assets/styles/tag-generator.css') : WPCF7DTX_VERSION //Version
);
//Plugin Scripts
wp_enqueue_script(
$prefix . 'taggenerator', //Handle
$url . 'assets/scripts/tag-generator' . ($debug ? '' : '.min') . '.js', //Source
array('jquery', 'wpcf7-admin-taggenerator'), //Dependencies
$debug ? @filemtime($path . 'assets/scripts/tag-generator.js') : WPCF7DTX_VERSION, //Version
array('in_footer' => true, 'strategy' => 'defer') // Defer loading in footer
);
}
}
add_action('admin_enqueue_scripts', 'wpcf7dtx_enqueue_admin_assets'); //Enqueue styles/scripts for admin page
/**
* Create Tag Generators
*
* @return void
*/
function wpcf7dtx_add_tag_generators()
{
if (!class_exists('WPCF7_TagGenerator')) {
return;
}
// Custom dynamic fields to add
global $wpcf7_dynamic_fields_config;
// Loop fields to add them
$tag_generator = WPCF7_TagGenerator::get_instance();
foreach ($wpcf7_dynamic_fields_config as $id => $field) {
$tag_generator->add($id, $field['title'], 'wpcf7dtx_tag_generator', array_merge(array('name-attr', 'dtx_pageload'), $field['options']));
}
}
add_action('wpcf7_admin_init', 'wpcf7dtx_add_tag_generators', 100);
/**
* Echo HTML for Dynamic Tag Generator
*
* @param WPCF7_ContactForm $contact_form
* @param array $options
*
* @return void
*/
function wpcf7dtx_tag_generator($contact_form, $options = '')
{
$options = wp_parse_args($options);
global $wpcf7_dynamic_fields_config;
$type = $options['id'];
$input_type = str_replace('dynamic_', '', $type);
$utm_source = urlencode(home_url());
$description = sprintf(
__('Generate a form-tag for %s with a dynamic default value. For more details, see %s fields in the %s.', 'contact-form-7-dynamic-text-extension'),
esc_html($wpcf7_dynamic_fields_config[$type]['description']), // dynamic description
// Link to specific form-tag documentation
sprintf(
'<a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/%s?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" title="%s" target="_blank" rel="noopener">%s</a>',
esc_attr(str_replace('_', '-', $type)), // URL component
esc_attr($utm_source), //UTM source
esc_attr($type), //UTM content
esc_attr__('View this form-tag on the DTX Documentation website', 'contact-form-7-dynamic-text-extension'), // Link title
esc_html(ucwords(str_replace('_', ' ', $type))) // Link label
),
// Link to general DTX documentation
sprintf(
'<a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" title="%s" target="_blank" rel="noopener">%s</a>',
esc_attr($utm_source), //UTM source
esc_attr($type), //UTM content
esc_attr__('Go to DTX Documentation website', 'contact-form-7-dynamic-text-extension'),
esc_html__('DTX knowledge base', 'contact-form-7-dynamic-text-extension')
)
);
// Open Form-Tag Generator
printf(
'<div class="control-box dtx-taggen"><fieldset><legend>%s</legend><table class="form-table"><tbody>',
wp_kses($description, array('a' => array('href' => array(), 'target' => array(), 'rel' => array(), 'title' => array()))) //Tag generator description
);
// Input field - Required checkbox (not available for some fields)
if (!in_array($input_type, array('hidden', 'quiz', 'submit', 'reset'))) {
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-required'), // field id
esc_html__('Field type', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'required',
'id' => $options['content'] . '-required'
)),
esc_html__('Required field', 'contact-form-7-dynamic-text-extension') // checkbox label
);
}
// Input field - Field Name (not available for some fields)
if (!in_array($input_type, array('submit', 'reset'))) {
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /></td></tr>',
esc_attr($options['content'] . '-name'), // field id
esc_html__('Name', 'contact-form-7-dynamic-text-extension'), // field label
wpcf7_format_atts(array(
'type' => 'text',
'name' => 'name',
'id' => $options['content'] . '-name',
'class' => 'tg-name oneline',
'autocomplete' => 'off'
))
);
}
// Input field - Dynamic value/options
$value_name = __('Dynamic value', 'contact-form-7-dynamic-text-extension');
$value_description = __('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension');
$value_placeholder = "CF7_GET key='foo'";
$value_input_type = '<input %s />';
switch ($input_type) {
case 'textarea':
$value_placeholder = "CF7_get_post_var key='post_excerpt'";
$value_input_type = '<textarea %s></textarea>';
break;
case 'select':
$value_name = __('Dynamic options', 'contact-form-7-dynamic-text-extension');
$value_description .= ' ' . __('If static text, use one option per line. Can define static key/value pairs using pipes.', 'contact-form-7-dynamic-text-extension');
$value_description .= ' ' . __('If shortcode, it must return only option or optgroup HTML and can override the first option and select default settings here.', 'contact-form-7-dynamic-text-extension');
$value_placeholder = "hello-world | Hello World" . PHP_EOL . "Foo";
$value_input_type = '<textarea %s></textarea>';
break;
case 'checkbox':
case 'radio':
$value_name = __('Dynamic options', 'contact-form-7-dynamic-text-extension');
$value_description .= ' ' . __('If static text, use one option per line. Can define static key/value pairs using pipes.', 'contact-form-7-dynamic-text-extension');
$value_description .= ' ' . __('If shortcode, it must return only option or optgroup HTML.', 'contact-form-7-dynamic-text-extension');
$value_placeholder = "hello-world | Hello World" . PHP_EOL . "Foo";
$value_input_type = '<textarea %s></textarea>';
break;
default: // All other text fields
break;
}
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td>' . $value_input_type . '<br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
esc_attr($options['content'] . '-values'), // field id
esc_html($value_name), // field label
wpcf7_format_atts(array(
'name' => 'values',
'id' => $options['content'] . '-values',
'class' => 'multiline',
'placeholder' => $value_placeholder,
'list' => 'dtx-shortcodes'
)),
esc_html($value_description),
esc_attr($utm_source), // UTM source
esc_attr($type), // UTM content
esc_html__('View DTX shortcode syntax documentation', 'contact-form-7-dynamic-text-extension') // Link label
);
if ($input_type == 'select') {
// Input field - Multiple selections checkbox
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-multiple'), // field id
esc_html__('Multiple Options', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'multiple',
'id' => $options['content'] . '-multiple',
'class' => 'option'
)),
esc_html__('Allow user to select multiple options', 'contact-form-7-dynamic-text-extension') // checkbox label
);
// Input field - Include blank checkbox
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-include_blank'), // field id
esc_html__('First Option', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'include_blank',
'id' => $options['content'] . '-include_blank',
'class' => 'include_blankvalue option'
)),
esc_html__('Insert a blank item as the first option', 'contact-form-7-dynamic-text-extension') // checkbox label
);
}
// Input field - Dynamic placeholder (not available for some fields)
if (!in_array($input_type, array('hidden', 'radio', 'checkbox', 'quiz', 'submit', 'reset'))) {
$placeholder_description = '';
if (in_array($input_type, array('select', 'checkbox', 'radio'))) {
$placeholder_label = __('First Option Label', 'contact-form-7-dynamic-text-extension');
$placeholder_description .= __('Optionally define a label for the first option.', 'contact-form-7-dynamic-text-extension') . ' ';
} else {
$placeholder_label = __('Dynamic placeholder', 'contact-form-7-dynamic-text-extension');
}
$placeholder_description .= __('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension');
$placeholder_input_type = $input_type == 'textarea' ? $value_input_type : '<input %s />';
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s />' . $placeholder_input_type . '<br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-placeholder/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
esc_attr($options['content'] . '-placeholder'), // field id
esc_html($placeholder_label), // field label
wpcf7_format_atts(array(
'type' => 'hidden',
'name' => 'placeholder',
'class' => 'option'
)),
wpcf7_format_atts(array(
'name' => 'dtx-placeholder',
'id' => $options['content'] . '-placeholder', // field id
'class' => 'multiline dtx-option',
'placeholder' => "CF7_get_post_var key='post_title'",
'list' => 'dtx-shortcodes'
)),
esc_html($placeholder_description), // Small note below input
esc_attr($utm_source), //UTM source
esc_attr($type), //UTM content
esc_html__('View DTX placeholder documentation', 'contact-form-7-dynamic-text-extension') //Link label
);
}
// Additional fields for select regarding placeholder options
if ($input_type == 'select') {
// Input field - Hide Blank Option
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
esc_attr($options['content'] . '-dtx_hide_blank'), // field id
esc_html__('Hide First Option', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'dtx_hide_blank',
'id' => $options['content'] . '-dtx_hide_blank',
'class' => 'option'
)),
esc_html__('Hide the first blank option from being visible in the drop-down', 'contact-form-7-dynamic-text-extension'), // checkbox label
esc_html__('Optional. Only works if "First Option" is checked.', 'contact-form-7-dynamic-text-extension'), // Small note below input
esc_attr($utm_source), //UTM source
esc_attr($type), //UTM content
esc_html__('View Dynamic Select documentation', 'contact-form-7-dynamic-text-extension') //Link label
);
// Input field - Disable Blank Option
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
esc_attr($options['content'] . '-dtx_disable_blank'), // field id
esc_html__('Disable First Option', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'dtx_disable_blank',
'id' => $options['content'] . '-dtx_disable_blank',
'class' => 'option'
)),
esc_html__('Disable the first blank option from being selectable in the drop-down', 'contact-form-7-dynamic-text-extension'), // checkbox label
esc_html__('Optional. Only works if "First Option" is checked.', 'contact-form-7-dynamic-text-extension'), // Small note below input
esc_attr($utm_source), //UTM source
esc_attr($type), //UTM content
esc_html__('View Dynamic Select documentation', 'contact-form-7-dynamic-text-extension') //Link label
);
} elseif (in_array($input_type, array('checkbox', 'radio'))) {
// Additional fields for checkboxes and radio buttons
// Input field - Checkbox Layout Reverse Option
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-label_first'), // field id
esc_html__('Reverse', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'label_first',
'id' => $options['content'] . '-label_first',
'class' => 'option'
)),
esc_html__('Put a label first, an input last', 'contact-form-7-dynamic-text-extension') // checkbox label
);
// Input field - Label UI
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-use_label_element'), // field id
esc_html__('Label', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'use_label_element',
'id' => $options['content'] . '-use_label_element',
'class' => 'option'
)),
esc_html__('Wrap each item with label element', 'contact-form-7-dynamic-text-extension') // checkbox label
);
// Input field - Exclusive Checkbox
if ($input_type == 'checkbox') {
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-exclusive'), // field id
esc_html__('Exclusive', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'exclusive',
'id' => $options['content'] . '-exclusive',
'class' => 'option'
)),
esc_html__('Make checkboxes exclusive', 'contact-form-7-dynamic-text-extension') // checkbox label
);
}
}
// Input field - Dynamic default value (not available for some fields)
if (in_array($input_type, array('select'))) {
$default_input_type = '<input %s />';
$default_placeholder = '';
if ($input_type == 'checkbox') {
$default_input_type = '<textarea %s></textarea>';
$default_description = __('Optionally define the default on/off status of the checkboxes by putting a 1 (checked) or 0 (not checked) on each line that corresponds with the options.', 'contact-form-7-dynamic-text-extension') . ' ';
$default_placeholder = '0' . PHP_EOL . '1';
} else {
$default_description = __('Optionally define the option that is selected by default. This can be different than the first [blank] option. If options use key/value pairs, only define the key here.', 'contact-form-7-dynamic-text-extension') . ' ';
}
$default_description .= __('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension');
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s />' . $default_input_type . '<br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
esc_attr($options['content'] . '-default'), // field id
esc_html__('Selected Default'), // field label
wpcf7_format_atts(array(
'type' => 'hidden',
'name' => 'default',
'class' => 'option'
)),
wpcf7_format_atts(array(
'name' => 'dtx-default',
'id' => $options['content'] . '-default', // field id
'class' => 'oneline dtx-option',
'placeholder' => $default_placeholder,
'list' => 'dtx-shortcodes'
)),
esc_html($default_description), // Small note below input
esc_attr($utm_source), //UTM source
esc_attr($type), //UTM content
esc_html__('View Dynamic Select documentation', 'contact-form-7-dynamic-text-extension') //Link label
);
}
//Input field - ID attribute
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /></td></tr>',
esc_attr($options['content'] . '-id'), // field id
esc_html__('Id attribute', 'contact-form-7-dynamic-text-extension'), // field label
wpcf7_format_atts(array(
'type' => 'text',
'name' => 'id',
'id' => $options['content'] . '-id', // field id
'class' => 'idvalue oneline option'
))
);
//Input field - Class attribute
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /></td></tr>',
esc_attr($options['content'] . '-class'), // field id
esc_html__('Class attribute', 'contact-form-7-dynamic-text-extension'), // field label
wpcf7_format_atts(array(
'type' => 'text',
'name' => 'class',
'id' => $options['content'] . '-class', // field id
'class' => 'classvalue oneline option'
))
);
//Input field - Readonly attribute (not available for hidden, submit, or quiz fields)
if (!in_array($input_type, array('hidden', 'submit', 'quiz'))) {
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-readonly'), // field id
esc_html__('Read only attribute', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'readonly',
'id' => $options['content'] . '-readonly',
'class' => 'readonlyvalue option'
)),
esc_html__('Do not let users edit this field', 'contact-form-7-dynamic-text-extension') // checkbox label
);
}
// Input field - Page load data attribute (triggers the loading of a frontend script)
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tag-attribute-after-page-load/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
esc_attr($options['content'] . '-dtx_pageload'), // field id
esc_html__('Cache Compatible', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'dtx_pageload',
'id' => $options['content'] . '-dtx_pageload',
'class' => 'option'
)),
esc_html__('Get the dynamic value after the page has loaded', 'contact-form-7-dynamic-text-extension'), // checkbox label
esc_html__('May impact page performance.', 'contact-form-7-dynamic-text-extension'), // Small note below input
esc_attr($utm_source), //UTM source
esc_attr($type), //UTM content
esc_html__('View DTX page load documentation', 'contact-form-7-dynamic-text-extension') //Link label
);
// Input field - Akismet module (only available for text, email, and url fields)
if (in_array($input_type, array('text', 'email', 'url'))) {
switch ($input_type) {
case 'email':
$akismet_name = 'author_email';
$akismet_desc = __("This field requires author's email address", 'contact-form-7-dynamic-text-extension');
break;
case 'url':
$akismet_name = 'author_url';
$akismet_desc = __("This field requires author's URL", 'contact-form-7-dynamic-text-extension');
break;
default:
$akismet_name = 'author';
$akismet_desc = __("This field requires author's name", 'contact-form-7-dynamic-text-extension');
break;
}
printf(
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
esc_attr($options['content'] . '-readonly'), // field id
esc_html__('Akismet', 'contact-form-7-dynamic-text-extension'), // field Label
wpcf7_format_atts(array(
'type' => 'checkbox',
'name' => 'akismet:' . $akismet_name,
'id' => $options['content'] . '-akismet-' . $akismet_name,
'class' => 'akismetvalue option'
)),
esc_html($akismet_desc) // checkbox label
);
}
//Close Form-Tag Generator
printf(
'</tbody></table></fieldset></div><div class="insert-box"><input type="text" name="%s" class="tag code" readonly="readonly" onfocus="this.select()" /><div class="submitbox"><input type="button" class="button button-primary insert-tag" value="%s" /></div><br class="clear" /></div>',
esc_attr($type),
esc_html__('Insert Tag', 'contact-form-7-dynamic-text-extension')
);
}

View File

@@ -1,504 +0,0 @@
<?php
/*****************************************************
* Included Shortcodes
*
* See documentation for usage:
* https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/
*
*****************************************************/
/**
* Initialise DTX included shortcodes
*
* Hooked to `init`
*
* @return void
*/
function wpcf7dtx_init_shortcodes()
{
add_shortcode('CF7_GET', 'wpcf7dtx_get', 10, 1);
add_shortcode('CF7_POST', 'wpcf7dtx_post', 10, 1);
add_shortcode('CF7_URL', 'wpcf7dtx_url', 10, 1);
add_shortcode('CF7_referrer', 'wpcf7dtx_referrer', 10, 1);
add_shortcode('CF7_bloginfo', 'wpcf7dtx_bloginfo', 10, 1);
add_shortcode('CF7_get_post_var', 'wpcf7dtx_get_post_var', 10, 1);
add_shortcode('CF7_get_custom_field', 'wpcf7dtx_get_custom_field', 10, 1);
add_shortcode('CF7_get_current_var', 'wpcf7dtx_get_current_var', 10, 1);
add_shortcode('CF7_get_current_user', 'wpcf7dtx_get_current_user', 10, 1);
add_shortcode('CF7_get_attachment', 'wpcf7dtx_get_attachment', 10, 1);
add_shortcode('CF7_get_cookie', 'wpcf7dtx_get_cookie', 10, 1);
add_shortcode('CF7_get_taxonomy', 'wpcf7dtx_get_taxonomy', 10, 1);
add_shortcode('CF7_get_theme_option', 'wpcf7dtx_get_theme_option', 10, 1);
add_shortcode('CF7_guid', 'wpcf7dtx_guid', 10, 0);
}
add_action('init', 'wpcf7dtx_init_shortcodes'); //Add init hook to add shortcodes
/**
* Get Variable from $_GET Array
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-php-get-variables/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get($atts = array())
{
extract(shortcode_atts(array(
'key' => 0,
'default' => '',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
$value = apply_filters('wpcf7dtx_sanitize', wpcf7dtx_array_has_key($key, $_GET, $default));
return apply_filters('wpcf7dtx_escape', $value, $obfuscate);
}
/**
* Get Variable from $_POST Array
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-php-post-variables/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_post($atts = array())
{
extract(shortcode_atts(array(
'key' => '',
'default' => '',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
$value = apply_filters('wpcf7dtx_sanitize', wpcf7dtx_array_has_key($key, $_POST, $default));
return apply_filters('wpcf7dtx_escape', $value, $obfuscate);
}
/**
* Get Current URL or Part
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-current-url/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_url($atts = array())
{
extract(shortcode_atts(array(
'allowed_protocols' => '',
'part' => '',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
$allowed_protocols = explode(',', sanitize_text_field($allowed_protocols));
// Get the absolute URL
if (is_multisite() && !is_subdomain_install()) {
// Network installs not using subdomains
$url = apply_filters('wpcf7dtx_sanitize', network_home_url($_SERVER['REQUEST_URI']), 'url', $allowed_protocols);
} else {
// Single installs and network installs using subdomains
$url = apply_filters('wpcf7dtx_sanitize', home_url($_SERVER['REQUEST_URI']), 'url', $allowed_protocols);
}
if ($url && !empty($part = sanitize_key(strtolower($part)))) {
// If an individual part is requested, get that specific value using parse_url()
$part_constant_map = [
'scheme' => PHP_URL_SCHEME, // e.g. `http`
'host' => PHP_URL_HOST, // the domain (or subdomain) of the current website
'path' => PHP_URL_PATH, // e.g. `/path/to/current/page/`
'query' => PHP_URL_QUERY // after the question mark ?
];
$value = '';
if (array_key_exists($part, $part_constant_map)) {
$value = apply_filters('wpcf7dtx_sanitize', strval(wp_parse_url($url, $part_constant_map[$part])), 'text');
}
return apply_filters('wpcf7dtx_escape', $value, $obfuscate, 'text');
}
// No part requested, return the absolute URL
return apply_filters('wpcf7dtx_escape', $url, $obfuscate, 'url', $allowed_protocols);
}
/**
* Get Referrering URL
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-referrer-url/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_referrer($atts = array())
{
extract(shortcode_atts(array(
'allowed_protocols' => '',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
if ($value = wpcf7dtx_array_has_key('HTTP_REFERER', $_SERVER)) {
$value = apply_filters('wpcf7dtx_sanitize', $value, 'url', $allowed_protocols);
return apply_filters('wpcf7dtx_escape', $value, $obfuscate, 'url');
}
return '';
}
/**
* Get Variable from Bloginfo
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-post-page-variables/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_bloginfo($atts = array())
{
extract(shortcode_atts(array(
'show' => 'name', //Backwards compatibility
'key' => 'name',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
$key = $show != $key && $show != 'name' ? $show : $key; // Use old value of "show" if not set to default value
return apply_filters('wpcf7dtx_escape', get_bloginfo($key), $obfuscate);
}
/**
* Get Variable from a Post Object
*
* @link https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-post-page-variables/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_post_var($atts = array())
{
extract(shortcode_atts(array(
'key' => 'post_title',
'post_id' => '',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
$key = strtolower(apply_filters('wpcf7dtx_sanitize', $key));
switch ($key) {
case 'acf_id': // If requesting the handle for ACF, return the post ID
case 'id':
$key = 'ID';
break;
case 'slug': // Alias
$key = 'post_name';
break;
case 'title': // Alias
$key = 'post_title';
break;
default:
break;
}
$post_id = wpcf7dtx_get_post_id($post_id);
if ($post_id) {
return apply_filters('wpcf7dtx_escape', get_post_field($key, $post_id), $obfuscate);
}
return '';
}
/**
* Get Value from Post Meta Field
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-post-meta-custom-fields/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_custom_field($atts = array())
{
extract(shortcode_atts(array(
'key' => '',
'post_id' => '',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
$post_id = wpcf7dtx_get_post_id($post_id);
$key = apply_filters('wpcf7dtx_sanitize', $key, 'text');
if ($post_id && $key) {
return apply_filters('wpcf7dtx_escape', get_post_meta($post_id, $key, true), $obfuscate);
}
return '';
}
/**
* Get Variable from the Current Object
*
* @since 3.4.0
*
* @link https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-current-variables/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_current_var($atts = array())
{
extract(shortcode_atts(array(
'key' => 'title',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
$key = apply_filters('wpcf7dtx_sanitize', $key);
$temp_key = str_replace('-', '_', sanitize_key($key));
if ($temp_key === 'url') {
return wpcf7dtx_url($atts); // Getting the current URL is the same for all WordPress pages
} elseif (!empty($key)) {
$type = '';
$obj = null;
if (!wp_doing_ajax()) {
$obj = get_queried_object(); // Get the current WordPress queried object
if (!is_null($obj)) {
if ($obj instanceof WP_User) {
$type = 'user';
} elseif (property_exists($obj, 'ID')) {
$type = 'post';
} elseif (property_exists($obj, 'term_id')) {
$type = 'term';
}
} elseif (is_archive()) {
$type = 'archive';
}
}
switch ($type) {
case 'user': // This is an author page
switch ($temp_key) {
case 'acf_id': // Get handle for Advanced Custom Fields
return apply_filters('wpcf7dtx_escape', 'user_' . $obj->ID, $obfuscate);
case 'image':
case 'featured_image': // Get the profile picture of the user being displayed on the page
return apply_filters('wpcf7dtx_escape', get_avatar_url($obj->ID), $obfuscate, 'url');
case 'title': // Get author's display name
return apply_filters('wpcf7dtx_escape', $obj->display_name, $obfuscate);
case 'slug': // Not all author pages use the `user_login` variable for security reasons, so get what is currently displayed as slug
return apply_filters('wpcf7dtx_escape', basename(wpcf7dtx_url(array('part' => 'path'))), $obfuscate);
default: // Get user value by key should it exist
return apply_filters('wpcf7dtx_escape', $obj->get($key), $obfuscate);
}
case 'post': // This is a post object
switch ($temp_key) {
case 'image':
case 'featured_image': // Get the current post's featured image
return wpcf7dtx_get_attachment(array_merge($atts, array('post_id' => $obj->ID)));
case 'terms': // Get the current post's assigned terms
return wpcf7dtx_get_taxonomy(array_merge($atts, array('post_id' => $obj->ID)));
default:
// Use the post object shortcode should it exist as a post variable
$value = wpcf7dtx_get_post_var(array_merge($atts, array('post_id' => $obj->ID)));
if (empty($value)) {
// Try post meta if post object variable failed
$value = wpcf7dtx_get_custom_field(array_merge($atts, array('post_id' => $obj->ID)));
}
return $value;
}
case 'term': // This is a taxonomy with a term ID
switch ($key) {
case 'id': // Get term ID
return apply_filters('wpcf7dtx_escape', $obj->term_id, $obfuscate);
case 'acf_id': // Get handle for Advanced Custom Fields
return apply_filters('wpcf7dtx_escape', $obj->taxonomy . '_' . $obj->term_id, $obfuscate);
case 'title': // Get term name
return apply_filters('wpcf7dtx_escape', $obj->name, $obfuscate);
default:
if (property_exists($obj, $key)) {
// Get any property if it exists
return apply_filters('wpcf7dtx_escape', $obj->{$key}, $obfuscate);
}
// Otherwise, try meta data if the property doesn't exist
return apply_filters('wpcf7dtx_escape', get_metadata('term', $obj->ID, $key, true), $obfuscate);
}
case 'archive': // Possibly a date or formats archive
switch ($temp_key) {
case 'title': // Get archive title
return apply_filters('wpcf7dtx_escape', get_the_archive_title(), $obfuscate);
default:
break;
}
default: // Possibly a search or 404 page at this point
if ($temp_key == 'slug') {
// no idea what else to get except the slug maybe
return apply_filters('wpcf7dtx_escape', basename(wpcf7dtx_url(array('part' => 'path'))), $obfuscate);
}
break;
}
}
return '';
}
/**
* Get Value from Current User
*
* Retreives data from the `users` and `usermeta` tables.
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-current-user-user-meta/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_current_user($atts = array())
{
extract(shortcode_atts(array(
'key' => 'user_login',
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
if (is_user_logged_in()) {
$user = wp_get_current_user();
return apply_filters('wpcf7dtx_escape', $user->get($key), $obfuscate);
}
return '';
}
/**
* Get Attachment
*
* Retreives an attachment ID or absolute URL depending on attributes
*
* @since 3.1.0
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-media-attachment/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_attachment($atts = array())
{
extract(shortcode_atts(array(
'id' => '', //Get attachment by ID
'size' => 'full', //Define attachment size
'post_id' => '', //If attachment ID is empty but post ID is not, get the featured image
'return' => 'url', //Options are `id` or `url`
'obfuscate' => ''
), array_change_key_case((array)$atts, CASE_LOWER)));
//No attachment ID was provided, check for post ID to get it's featured image
if (empty($id)) {
if ($post_id = wpcf7dtx_get_post_id($post_id)) {
//If a post ID was provided, get it's featured image
$id = get_post_thumbnail_id($post_id);
}
}
//Get the value
if ($id) {
$id = intval(sanitize_text_field(strval($id)));
switch ($return) {
case 'id': //Return the attachment ID
return apply_filters('wpcf7dtx_escape', $id, $obfuscate);
default: //Return attachment URL
$url = wp_get_attachment_image_url(intval($id), sanitize_text_field(strval($size)));
return apply_filters('wpcf7dtx_escape', $url, $obfuscate, 'url');
}
}
return '';
}
/**
* Get Cookie Value
*
* Retreives the value of a cookie
*
* @since 3.3.0
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-cookie/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_cookie($atts = array())
{
extract(shortcode_atts(array(
'key' => '',
'default' => '',
'obfuscate' => '' // Optionally obfuscate returned value
), array_change_key_case((array)$atts, CASE_LOWER)));
$key = apply_filters('wpcf7dtx_sanitize', $key);
$value = wpcf7dtx_array_has_key($key, $_COOKIE, $default);
return apply_filters('wpcf7dtx_escape', $value, $obfuscate);
}
/**
* Get Taxonomy
*
* Retreives a list of taxonomy values
*
* @since 3.3.0
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-taxonomy/
* @see https://developer.wordpress.org/reference/classes/wp_term_query/get_terms/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_taxonomy($atts = array())
{
extract(shortcode_atts(array(
'post_id' => '',
'taxonomy' => 'category', // Default taxonomy is `category`
'fields' => 'names', // Return an array of term names
'obfuscate' => '' // Optionally obfuscate returned value
), array_change_key_case((array)$atts, CASE_LOWER)));
$post_id = wpcf7dtx_get_post_id($post_id);
$fields = apply_filters('wpcf7dtx_sanitize', $fields, 'key');
if ($post_id && in_array($fields, array('names', 'slugs', 'ids'))) {
$terms = wp_get_object_terms(
$post_id, // Get only the ones assigned to this post
apply_filters('wpcf7dtx_sanitize', $taxonomy, 'slug'),
array('fields' => $fields)
);
if (is_array($terms) && count($values = array_values($terms)) && (is_string($values[0]) || is_numeric($values[0]))) {
return apply_filters('wpcf7dtx_escape', implode(', ', $values), $obfuscate, 'text');
}
}
return '';
}
/**
* Get Theme Customization Option
*
* Retreives theme modification value for the active theme
*
* @since 3.3.0
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-theme-option/
* @see https://developer.wordpress.org/reference/functions/get_theme_mod/
*
* @param array $atts Optional. An associative array of shortcode attributes. Default is an empty array.
*
* @return string Output of the shortcode
*/
function wpcf7dtx_get_theme_option($atts = array())
{
extract(shortcode_atts(array(
'key' => '',
'default' => '', // Optional default value
'obfuscate' => '' // Optionally obfuscate returned value
), array_change_key_case((array)$atts, CASE_LOWER)));
if ($key = apply_filters('wpcf7dtx_sanitize', $key, 'text')) {
$default = apply_filters('wpcf7dtx_sanitize', $default);
return apply_filters('wpcf7dtx_escape', get_theme_mod($key, $default), $obfuscate);
}
return '';
}
/**
* GUID Field
*
* Generate a random GUID (globally unique identifier)
*
* @since 3.1.0
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-guid/
*
* @return string a randomly generated 128-bit text string.
*/
function wpcf7dtx_guid()
{
if (function_exists('com_create_guid') === true) {
return esc_attr(trim(com_create_guid(), '{}'));
}
return esc_attr(sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)));
}

View File

@@ -1,663 +0,0 @@
<?php
/**
* Custom DTX Allowed Protocols Filter
*
* @since 3.3.0
*
* @param array|string $protocols Optional. Specify protocols to allow either as an array of string values or a string value of comma separated protocols.
* @param bool $replace Optional. If true, this function will only return the specified values. If false, will merge specified values with default values. Default is false.
*
* @return array An array of string values, default only includes `http` and `https` protocols.
*/
function wpcf7dtx_allow_protocols($protocols = false, $replace = false)
{
// Get user-inputted protocols
$user_protocols = false;
if (is_string($protocols) && !empty($protocols)) {
$user_protocols = explode(',', sanitize_text_field($protocols));
} elseif (is_array($protocols) && count($protocols)) {
$user_protocols = array_filter(array_values($protocols));
}
$default = array('http', 'https');
if (is_array($user_protocols) && count($user_protocols)) {
// Sanitize each value before adding
$allowed_protocols = array();
foreach ($user_protocols as $protocol) {
$allowed_protocols[] = sanitize_text_field($protocol);
}
if ($replace) {
return array_unique($allowed_protocols);
}
return array_unique(array_merge(array('http', 'https'), $allowed_protocols)); // Return merged values
} elseif ($replace) {
return array(); // None allowed, apparently
}
return $default; // Return only default values
}
add_filter('wpcf7dtx_allow_protocols', 'wpcf7dtx_allow_protocols', 10, 2);
/**
* Custom DTX Sanitize Filter
*
* @since 3.3.0
*
* @param string $value value to be sanitized
* @param string $type Optional. The type of sanitation to return. Default is `auto` where automatic identification will be used to attempt to identify URLs and email addresses vs text.
* @param array|string $protocols Optional. Specify protocols to allow either as an array of string values or a string value of comma separated protocols.
*
* @return string the sanitized value
*/
function wpcf7dtx_sanitize($value = '', $type = 'auto', $protocols = false)
{
if ($type == 'none') {
return $value;
}
$value = is_string($value) ? $value : strval($value); // Force string value
if (!empty($value)) {
$type = $type == 'auto' ? wpcf7dtx_detect_value_type($value) : sanitize_text_field($type);
switch ($type) {
case 'email':
return sanitize_email($value);
case 'url':
return sanitize_url($value, apply_filters('wpcf7dtx_allow_protocols', $protocols));
case 'key':
return sanitize_key($value);
case 'slug':
return sanitize_title($value);
case 'textarea':
return sanitize_textarea_field($value);
}
}
return sanitize_text_field($value);
}
add_filter('wpcf7dtx_sanitize', 'wpcf7dtx_sanitize', 10, 3);
/**
* Custom DTX Escape Filter
*
* @since 3.3.0
*
* @param string $value value to be escaped
* @param bool $obfuscate Optional. If true, returned value will be obfuscated. Default is false.
* @param string $type Optional. The type of escape to return. Default is `auto` where automatic identification will be used to attempt to identify the type of text.
* @param array|string $protocols Optional. Specify protocols to allow either as an array of string values or a string value of comma separated protocols.
*
* @return string the escaped value
*/
function wpcf7dtx_escape($value = '', $obfuscate = false, $type = 'auto', $protocols = false)
{
if ($type == 'none') {
return $value;
}
$value = apply_filters('wpcf7dtx_sanitize', $value, $type); // Sanitize value
if (!empty($value)) {
if ($obfuscate) {
return apply_filters('wpcf7dtx_obfuscate', $value); // Return obfuscated value
}
$type = $type == 'auto' ? wpcf7dtx_detect_value_type($value) : sanitize_text_field($type);
switch ($type) {
case 'url':
return esc_url($value, apply_filters('wpcf7dtx_allow_protocols', $protocols));
case 'textarea':
return esc_textarea($value);
}
}
return esc_attr($value); // Return attribute value
}
add_filter('wpcf7dtx_escape', 'wpcf7dtx_escape', 10, 4);
/**
* Detect Value Type
*
* @since 3.3.0
*
* @access private
*
* @param string $value the value to be identified
*
* @return string Potentially identifies string values as `url`, `email`, or `text`.
*/
function wpcf7dtx_detect_value_type($value)
{
// Try to detect the value type
$value = trim($value);
$is_https_url = stripos($value, 'https') === 0 && strlen($value) > 5;
$is_http_url = stripos($value, 'http') === 0 && strlen($value) > 4 && sanitize_key($value) != 'https';
if ($is_https_url || $is_http_url) {
return 'url';
} elseif (preg_match('/^[^\s@]+@[^\s@]+\.[^\s@]+$/', $value)) {
return 'email';
}
return 'text';
}
/**
* Obfuscate a value
*
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-obfuscate/
*
* @param mixed $value the value to be obfuscated
*
* @return string obfuscated value
*/
function wpcf7dtx_obfuscate($value = '')
{
$o = '';
if (!is_string($value)) {
$value = sanitize_text_field(strval($value)); // Force value to be string and sanitize it
}
if (!empty($value)) {
$value = htmlentities($value, ENT_QUOTES);
foreach (str_split($value) as $letter) {
$o .= '&#' . ord($letter) . ';';
}
return $o; // Return obfuscated value
}
return esc_attr($value); // Return default attribute escape
}
add_filter('wpcf7dtx_obfuscate', 'wpcf7dtx_obfuscate', 10, 1);
/**
* Get Post ID
*
* @access private
*
* @param mixed $post_id
*
* @return int An integer value of the passed post ID or the post ID of the current `$post` global object. 0 on Failure.
*/
function wpcf7dtx_get_post_id($post_id, $context = 'dtx')
{
$post_id = $post_id ? intval(sanitize_text_field(strval($post_id))) : '';
if (!$post_id || !is_numeric($post_id)) {
if ($context == 'dtx') {
if (wp_doing_ajax()) {
// If we're doing an AJAX call, just fail quietly
return 0;
} else {
global $post;
if (isset($post)) {
$post_id = $post->ID; // If the global $post object is set, get its ID
} else {
$post_id = get_the_ID(); // Otherwise get it from "the loop"
}
}
} elseif ($context == 'acf') {
// When a post ID is not specified for ACF keys, it accepts the boolean `false`
$post_id = false;
}
}
return $post_id;
}
/**
* Get Dynamic Value
*
* @since 3.2.2
*
* @param string $value The form tag value.
* @param WPCF7_FormTag|false $tag Optional. Use to look up default value.
* @param string $sanitize Optional. Specify type of sanitization. Default is `auto`.
*
* @return string The dynamic output or the original value, not escaped or sanitized.
*/
function wpcf7dtx_get_dynamic($value, $tag = false, $sanitize = 'auto')
{
if ($tag !== false) {
$default = $tag->get_option('defaultvalue', '', true);
if (!$default) {
$default = $tag->get_default_option(strval(reset($tag->values)));
}
$value = wpcf7_get_hangover($tag->name, $default);
}
$value = apply_filters('wpcf7dtx_sanitize', $value, $sanitize);
if (is_string($value) && !empty($value)) {
// If a shortcode was passed as the value, evaluate it and use the result
$shortcode_tag = '[' . $value . ']';
$shortcode_output = do_shortcode($shortcode_tag); //Shortcode value
if (is_string($shortcode_output) && $shortcode_output != $shortcode_tag) {
return apply_filters('wpcf7dtx_sanitize', $shortcode_output, $sanitize);
}
}
return $value;
}
/**
* Get Allowed HTML for Form Field Properties
*
* @since 4.0.0
*
* @param string $type Optional. The type of input for unique properties. Default is `text`.
* @param array $extra Optional. A sequential array of properties to additionally include.
*
* @return array An associative array of allowed properties appropriate for use in `wp_kses()`
*/
function wpcf7dtx_get_allowed_field_properties($type = 'text', $extra = array())
{
if (in_array($type, array('option', 'optgroup'))) {
return array(
'optgroup' => array(
'label' => array(),
'disabled' => array(),
'hidden' => array()
),
'option' => array(
'value' => array(),
'selected' => array(),
'disabled' => array(),
'hidden' => array()
)
);
}
$allowed_properties = array(
// Global properties
'type' => array(),
'id' => array(),
'name' => array(),
'value' => array(),
'required' => array(),
'class' => array(),
'disabled' => array(),
'readonly' => array(),
'tabindex' => array(),
'size' => array(),
'title' => array(),
'autofocus' => array(),
// ARIA properties
'aria-invalid' => array(),
'aria-describedby' => array(),
// DTX properties
'data-dtx-value' => array(),
);
if (in_array($type, array('checkbox', 'radio', 'acceptance'))) {
// Properties exclusive to checkboxes and radio buttons
$allowed_properties['checked'] = array();
$allowed_properties['dtx-default'] = array();
} elseif (in_array($type, array('number', 'range'))) {
// Properties exclusive to number inputs
$allowed_properties['step'] = array();
} elseif ($type == 'select') {
// Properties exclusive to select fields
$allowed_properties['multiple'] = array();
$allowed_properties['dtx-default'] = array();
unset($allowed_properties['type'], $allowed_properties['value'], $allowed_properties['placeholder'], $allowed_properties['size']); // Remove invalid select attributes
}
if (!in_array($type, array('checkbox', 'radio', 'select', 'acceptance'))) {
// Allowed properties for all text-based inputs
$allowed_properties['placeholder'] = array();
$allowed_properties['autocomplete'] = array();
$allowed_properties['minlength'] = array();
$allowed_properties['maxlength'] = array();
if (in_array($type, array('number', 'range', 'date', 'datetime-local', 'time'))) {
// Additional properties for number and date inputs
$allowed_properties['min'] = array();
$allowed_properties['max'] = array();
}
if ($type == 'textarea') {
// Additional properties exclusive to textarea fields
$allowed_properties['cols'] = array();
$allowed_properties['rows'] = array();
unset($allowed_properties['type'], $allowed_properties['value']); // Remove invalid textarea attributes
} elseif (in_array($type, array('text', 'date', 'url', 'tel', 'email', 'password'))) {
// Additional properties exclusive to specific text fields
$allowed_properties['pattern'] = array();
}
}
if (is_array($extra) && count($extra)) {
foreach ($extra as $property) {
$allowed_properties[sanitize_title($property)] = array();
}
}
return $allowed_properties;
}
/**
* Returns a formatted string of HTML attributes
*
* @since 4.0.0
*
* @param array $atts Associative array of attribute name and value pairs
*
* @return string Formatted HTML attributes with keys and values both escaped
*/
function wpcf7dtx_format_atts($atts)
{
if (is_array($atts) && count($atts)) {
$sanitized_atts = array();
static $boolean_attributes = array(
'checked', 'disabled', 'multiple', 'readonly', 'required', 'selected'
);
foreach ($atts as $key => $value) {
$key = sanitize_key(strval($key));
if ($key) {
if (in_array($key, $boolean_attributes) || is_bool($value)) {
if ($value) {
$sanitized_atts[$key] = $key;
}
} elseif ($value && (is_string($value) || is_numeric($value))) {
$sanitized_atts[$key] = $value;
}
}
}
if (count($sanitized_atts)) {
$output = array();
foreach ($sanitized_atts as $key => $value) {
$output[] = sprintf('%s="%s"', esc_attr($key), esc_attr($value));
}
return implode(' ', $output);
}
}
return '';
}
/**
* Create Input Field HTML
*
* @since 4.0.0
*
* @param array $atts An associative array of input attributes.
*
* @return string HTML output of input field
*/
function wpcf7dtx_input_html($atts)
{
return sprintf('<input %s />', wpcf7dtx_format_atts($atts));
}
/**
* Create Checkbox Field HTML
*
* @since 4.0.0
*
* @param array $atts An associative array of select input attributes.
* @param string $label_text Optional. The text to display next to the checkbox or radio button.
* @param bool $label_ui Optional. If true, will place input and label text inside a `<label>` element. Default is true.
* @param bool $reverse Optional. If true, will reverse the order to display the text label first then the button. Has no effect if label text is empty. Default is false.
*
* @return string HTML output of the checkbox or radio button or empty string on failure.
*/
function wpcf7dtx_checkbox_html($atts, $label_text = '', $label_ui = true, $reverse = false)
{
// Default field attributes
$atts = array_merge(array('value' => '', 'dtx-default' => ''), array_change_key_case((array)$atts, CASE_LOWER));
if ($atts['value'] && $atts['dtx-default'] && $atts['value'] == $atts['dtx-default']) {
$atts['checked'] = 'checked';
}
$input = wpcf7dtx_input_html($atts);
if (!empty(trim($label_text))) {
$label_el = $label_ui ? 'span' : 'label'; // If not wrapping with a label element, display it next to it
$label_text = sprintf(
'<%1$s%2$s class="wpcf7-list-item-label">%3$s</%1$s>',
$label_el,
// If not wrapping with a label element and the element has an ID attribute, add a `for` attribute
$label_ui ? '' : (wpcf7dtx_array_has_key('id', $atts) ? ' for="' . esc_attr($atts['id']) . '"' : ''),
esc_html($label_text)
);
if ($reverse) {
$html = $label_text . $input;
} else {
$html = $input . $label_text;
}
} else {
$html = $input;
}
if ($label_ui) {
$html = '<label>' . $html . '</label>';
}
return $html;
}
/**
* Create Checkbox Group HTML
*
* @since 4.0.3
*
* @param array $atts An associative array of select input attributes.
* @param array|string $options Accepts an associative array of key/value pairs to use as the
* select option's value/label pairs. It also accepts an associative array of associative
* arrays with the keys being used as option group labels and the array values used as that
* group's options. It also accepts a string value of HTML already formatted as options or
* option groups. It also accepts a string value of a self-closing shortcode that is
* evaluated and its output is either options or option groups.
* @param bool $label_ui Optional. If true, will place input and label text inside a `<label>` element. Default is true.
* @param bool $reverse Optional. If true, will reverse the order to display the text label first then the button. Has no effect if label text is empty. Default is false.
*
* @return string HTML output of the checkbox or radio button or empty string on failure.
*/
function wpcf7dtx_checkbox_group_html($atts, $options, $label_ui = false, $reverse = false, $exclusive = false)
{
$group_html = '';
if ($count = count($options)) {
// Attributes specific to HTML creation
$atts = array_merge(array(
'type' => 'checkbox',
'id' => '',
'name' => '',
'value' => '',
'dtx-default' => ''
), array_change_key_case((array)$atts, CASE_LOWER));
// Loop all the options
$group_html = array();
$id_prefix = ($atts['id'] ? $atts['id'] : uniqid($atts['name'] . '_')) . '_'; // Create prefix from passed ID or Name
$i = 1;
foreach ($options as $value => $label) {
$my_atts = array_merge($atts, array(
'id' => sanitize_html_class($id_prefix . $i) // Always have unique IDs for group items
));
$dynamic_value = '';
$dynamic_label = $label;
if ($value && $label && $value === $label) {
// These are identical, just handle it as one, could also be a raw shortcode
$dynamic_option = trim(wpcf7dtx_get_dynamic($value, false, 'none')); // Do not sanitize yet, it may have HTML
if (is_string($dynamic_option) && !empty($dynamic_option) && strpos($dynamic_option, '{') === 0 && strpos($dynamic_option, '}') === strlen($dynamic_option) - 1) {
// If it outputs JSON, try parsing it
try {
$dynamic_option = json_decode($dynamic_option, true);
if (is_array($dynamic_option) && count($dynamic_option)) {
$group_html[] = wpcf7dtx_checkbox_group_html(
$my_atts,
$dynamic_option,
$label_ui,
$reverse,
$exclusive
);
}
} catch (Exception $e) {
// Fail quietly
if (WP_DEBUG && WP_DEBUG_LOG) {
error_log('[Contact Form 7 - Dynamic Text Extension] Error parsing JSON value');
error_log($e->getMessage());
}
}
$i++;
continue; // Continue with next iteration
} elseif (is_string($dynamic_option) && !empty($dynamic_option) && esc_html($dynamic_option) != $dynamic_option) {
$group_html[] = force_balance_tags($dynamic_option); // If it outputs HTML, escape and use them as-is
$i++;
continue; // Continue with next iteration
} else {
$dynamic_value = $dynamic_option;
$dynamic_label = $dynamic_option;
}
} else {
// These are different, could be raw shortcodes
$dynamic_value = wpcf7dtx_get_dynamic($value, false);
$dynamic_label = wpcf7dtx_get_dynamic($label, false);
}
// This could be a single??
$class = array('wpcf7-list-item');
$class[] = sanitize_html_class('wpcf7-list-item-' . $i);
if ($i === 1) {
$class[] = 'first';
}
if ($i === $count) {
$class[] = 'last';
}
if ($exclusive) {
$class[] = 'wpcf7-exclusive-checkbox';
}
if ($dynamic_value && $atts['dtx-default'] && $dynamic_value == $atts['dtx-default']) {
$my_atts['checked'] = 'checked';
}
$group_html[] = sprintf(
'<span class="%s">%s</span>',
esc_attr(implode(' ', $class)),
wpcf7dtx_checkbox_html(
// Overwrite name attribute
array_merge($my_atts, array(
'name' => $atts['type'] == 'radio' || $exclusive || $count === 1 ? $atts['name'] : $atts['name'] . '[]', // if there are multiple checkboxes and they aren't exclusive, names are an array
'value' => $dynamic_value
)),
$dynamic_label,
$label_ui,
$reverse
)
);
$i++;
}
$group_html = implode('', $group_html);
}
return $group_html;
}
/**
* Create Textarea Field HTML
*
* @since 4.0.0
*
* @param array $atts An associative array of textarea field attributes.
*
* @return string HTML output of textarea field
*/
function wpcf7dtx_textarea_html($atts)
{
// Attributes specific to HTML creation
$atts = array_merge(array('value' => ''), array_change_key_case((array)$atts, CASE_LOWER));
return sprintf(
'<textarea %s>%s</textarea>',
wpcf7dtx_format_atts($atts),
apply_filters('wpcf7dtx_escape', $atts['value'], false, 'textarea')
);
}
/**
* Create Select Field HTML
*
* @since 4.0.0
*
* @param array $atts An associative array of select input attributes.
* @param array|string $options Accepts an associative array of key/value pairs to use as the
* select option's value/label pairs. It also accepts an associative array of associative
* arrays with the keys being used as option group labels and the array values used as that
* group's options. It also accepts a string value of HTML already formatted as options or
* option groups. It also accepts a string value of a self-closing shortcode that is
* evaluated and its output is either options or option groups.
* @param bool $hide_blank Optional. If true, the first blank placeholder option will have the `hidden` attribute added to it. Default is false.
* @param bool $disable_blank Optional. If true, the first blank placeholder option will have the `disabled` attribute added to it. Default is false.
*
* @return string HTML output of select field
*/
function wpcf7dtx_select_html($atts, $options, $hide_blank = false, $disable_blank = false)
{
// Attributes specific to HTML creation
$atts = array_merge(array('placeholder' => '', 'dtx-default' => ''), array_change_key_case((array)$atts, CASE_LOWER));
$options_html = ''; // Open options HTML
// If using a placeholder, use it as the text of the first option
if ($atts['placeholder']) {
$options_html .= sprintf(
'<option value=""%s%s%s>%s</option>',
empty($atts['dtx-default']) ? ' selected' : '',
$hide_blank ? ' hidden' : '',
$disable_blank ? ' disabled' : '',
apply_filters('wpcf7dtx_escape', $atts['placeholder'])
);
}
if (is_array($options) && count($options)) {
//Check if using option groups
if (is_array(array_values($options)[0])) {
foreach ($options as $group_name => $opt_group) {
$options_html .= sprintf('<optgroup label="%s">', esc_attr(apply_filters('wpcf7dtx_escape', wpcf7dtx_get_dynamic($group_name)))); // Open option group
foreach ($opt_group as $option_value => $option_label) {
// Check if option values and groups are dynamic
$dynamic_option_value = wpcf7dtx_get_dynamic($option_value);
$options_html .= sprintf(
'<option value="%1$s"%3$s>%2$s</option>',
esc_attr(apply_filters('wpcf7dtx_escape', $dynamic_option_value)),
esc_html(apply_filters('wpcf7dtx_escape', wpcf7dtx_get_dynamic($option_label))),
$atts['dtx-default'] == $dynamic_option_value ? ' selected' : ''
);
}
$options_html .= '</optgroup>'; // Close option group
}
} else {
$allowed_html = wpcf7dtx_get_allowed_field_properties('option');
foreach ($options as $option_value => $option_label) {
if ($option_value === $option_label) {
// These are identical, just handle it as one, could also be a raw shortcode
$dynamic_option = trim(wpcf7dtx_get_dynamic($option_value, false, 'none')); // Do not sanitize yet, it may have HTML
if (is_string($dynamic_option) && !empty($dynamic_option) && (strpos($dynamic_option, '<option') === 0 || stripos($dynamic_option, '<optgroup') === 0)) {
$options_html .= wp_kses($dynamic_option, $allowed_html); // If it outputs HTML, escape and use them as-is
} elseif ($dynamic_option) {
// Just output the option
$dynamic_option = apply_filters('wpcf7dtx_escape', $dynamic_option);
$options_html .= sprintf(
'<option value="%1$s"%3$s>%2$s</option>',
esc_attr($dynamic_option),
esc_html($dynamic_option),
$atts['dtx-default'] == $dynamic_option ? ' selected' : ''
);
}
} else {
$dynamic_option_value = wpcf7dtx_get_dynamic($option_value, false);
$options_html .= sprintf(
'<option value="%1$s"%3$s>%2$s</option>',
esc_attr(apply_filters('wpcf7dtx_escape', $dynamic_option_value)),
esc_html(apply_filters('wpcf7dtx_escape', wpcf7dtx_get_dynamic($option_label))),
$atts['dtx-default'] == $dynamic_option_value ? ' selected' : ''
);
}
}
}
} elseif (is_string($options) && !empty($options = trim($options))) {
$allowed_html = wpcf7dtx_get_allowed_field_properties('option');
// If options were passed as a string, go ahead and use them
if (strpos($options, '<option') === 0 || stripos($options, '<optgroup') === 0) {
$options_html .= wp_kses($options, $allowed_html);
} else {
// If a shortcode was passed as the options, evaluate it and use the result
$shortcode_output = wpcf7dtx_get_dynamic($options);
if (is_string($shortcode_output) && !empty($shortcode_output) && (strpos($shortcode_output, '<option') === 0) || strpos($shortcode_output, '<optgroup') === 0) {
$options_html .= wp_kses($shortcode_output, $allowed_html);
}
}
}
return sprintf('<select %s>%s</select>', wpcf7dtx_format_atts($atts), $options_html);
}
/**
* Array Key Exists and Has Value
*
* @since 3.1.0
*
* @param string|int $key The key to search for in the array.
* @param array $array The array to search.
* @param mixed $default The default value to return if not found or is empty. Default is an empty string.
*
* @return mixed The value of the key found in the array if it exists or the value of `$default` if not found or is empty.
*/
function wpcf7dtx_array_has_key($key, $array = array(), $default = '')
{
//Check if this key exists in the array
$valid_key = (is_string($key) && !empty($key)) || is_numeric($key);
$valid_array = is_array($array) && count($array);
if ($valid_key && $valid_array && array_key_exists($key, $array)) {
//Always return if it's a boolean or number, otherwise only return it if it has any value
if ($array[$key] || is_bool($array[$key]) || is_numeric($array[$key])) {
return $array[$key];
}
}
return $default;
}

View File

@@ -1,233 +0,0 @@
<?php
/**
* Add Frontend Validation Messages
*
* @since 4.0.0
*
* @param array An associative array of messages
*
* @return array A modified associative array of messages
*/
function wpcf7dtx_messages($messages)
{
return array_merge($messages, array(
'dtx_invalid_email' => array(
'description' => __('There is a field with an invalid email address', 'contact-form-7-dynamic-text-extension'),
'default' => __('Please enter a valid email address.', 'contact-form-7-dynamic-text-extension')
),
'dtx_invalid_tel' => array(
'description' => __('There is a field with an invalid phone number', 'contact-form-7-dynamic-text-extension'),
'default' => __('Please enter a valid phone number.', 'contact-form-7-dynamic-text-extension')
),
'dtx_invalid_number' => array(
'description' => __('There is a field with an invalid number', 'contact-form-7-dynamic-text-extension'),
'default' => __('Please enter a valid number.', 'contact-form-7-dynamic-text-extension')
),
'dtx_invalid_date' => array(
'description' => __('There is a field with an invalid date', 'contact-form-7-dynamic-text-extension'),
'default' => __('Please enter a valid date.', 'contact-form-7-dynamic-text-extension')
),
));
}
add_filter('wpcf7_messages', 'wpcf7dtx_messages');
/**
* Validate DTX Form Fields
*
* Frontend validation for DTX form tags
*
* @param WPCF7_Validation $result the current validation result object
* @param WPCF7_FormTag $tag the current form tag being filtered for validation
*
* @return WPCF7_Validation a possibly modified validation result object
*/
function wpcf7dtx_validation_filter($result, $tag)
{
$type = str_replace(array('dynamic_', 'dynamic'), '', $tag->basetype);
if (empty($tag->name) || in_array($type, array('hidden', 'submit', 'reset'))) {
return $result; // Bail early for tags without names or if a specific type
}
// Get the value
$user_value = wpcf7dtx_array_has_key($tag->name, $_POST);
if (is_array($user_value)) {
$selection_count = count($user_value);
if (!wpcf7_form_tag_supports($tag->type, 'selectable-values')) {
// Field passed selectable values when it's doesn't support them
$result->invalidate($tag, wpcf7_get_message('validation_error'));
return $result;
} elseif ($selection_count > 1) {
if (!wpcf7_form_tag_supports($tag->type, 'multiple-controls-container')) {
// Field passed multiple values when it's doesn't support them
$result->invalidate($tag, wpcf7_get_message('validation_error'));
return $result;
}
foreach ($user_value as $selection) {
// Validate each selected choice
$result = wpcf7dtx_validate_value($result, sanitize_textarea_field(strval($selection)), $tag, $type);
if (!$result->is_valid($tag->name)) {
return $result; // Return early if any are invalid
}
}
return $result;
}
$user_value = sanitize_text_field(strval(implode(' ', $user_value)));
} elseif ($type == 'textarea') {
$user_value = sanitize_textarea_field(strval($user_value));
} else {
$user_value = sanitize_text_field(strval($user_value));
}
// Validate and return
return wpcf7dtx_validate_value($result, $user_value, $tag, $type);
}
/**
* Validate Single Value
*
* @param WPCF7_Validation $result the current validation result object
* @param string $value the current value being validated, sanitized
* @param WPCF7_FormTag $tag the current form tag being filtered for validation
* @param string $type Optional. The type of the current form tag. Default is blank for lookup.
*
* @return WPCF7_Validation a possibly modified validation result object
*/
function wpcf7dtx_validate_value($result, $value, $tag, $type = '')
{
$type = $type ? $type : str_replace(array('dynamic_', 'dynamic'), '', $tag->basetype);
// Validate required fields for value
if ($tag->is_required() && empty($value)) {
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
return $result;
}
// Validate value by type
if (!empty($value)) {
switch ($type) {
case 'email':
if (!wpcf7_is_email($value)) {
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_email'));
return $result;
}
break;
case 'tel':
if (!wpcf7_is_tel($value)) {
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_tel'));
return $result;
}
break;
case 'number':
case 'range':
if (!wpcf7_is_number($value)) {
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_number'));
return $result;
}
break;
case 'date':
if (!wpcf7_is_date($value)) {
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_date'));
return $result;
}
break;
}
// Finish validating text-based inputs
$maxlength = $tag->get_maxlength_option();
$minlength = $tag->get_minlength_option();
if ($maxlength && $minlength && $maxlength < $minlength) {
$maxlength = $minlength = null;
}
$code_units = wpcf7_count_code_units($value);
if (false !== $code_units) {
if ($maxlength && $maxlength < $code_units) {
$result->invalidate($tag, wpcf7_get_message('invalid_too_long'));
return $result;
} elseif ($minlength && $code_units < $minlength) {
$result->invalidate($tag, wpcf7_get_message('invalid_too_short'));
return $result;
}
}
}
return $result;
}
/**
* Backend Mail Configuration Validation
*
* Validate dynamic form tags used in mail configuration.
*
* @since 4.0.0
*
* @param WPCF7_ConfigValidator
*
* @return void
*/
function wpcf7dtx_validate($validator)
{
if (!$validator->is_valid()) {
$contact_form = null;
$form_tags = null;
foreach ($validator->collect_error_messages() as $component => $errors) {
$components = explode('.', $component);
if (count($components) === 2 && strpos($components[0], 'mail') === 0 && in_array($components[1], array('sender', 'recipient', 'additional_headers'))) {
foreach ($errors as $error) {
// Focus on email fields that flag the invalid mailbox syntax warning, have to test link because code isn't sent and message could be in any language
if (strpos(wpcf7dtx_array_has_key('link', $error), 'invalid-mailbox-syntax') !== false) {
if (is_null($contact_form)) {
$contact_form = $validator->contact_form();
}
if (is_null($form_tags)) {
$form_tags = wpcf7_scan_form_tags();
}
$raw_value = $contact_form->prop($components[0])[$components[1]];
foreach ($form_tags as $tag) {
if (!empty($tag->name)) {
// Check if this form tag is in the raw value
$form_tag = '[' . $tag->name . ']';
if (strpos($raw_value, $form_tag) !== false && in_array($tag->basetype, array_keys(wpcf7dtx_config()))) {
$validator->remove_error($component, 'invalid_mailbox_syntax'); // Remove error, this is ours to handle now
$utm_source = urlencode(home_url());
if (!in_array($tag->basetype, array('dynamic_hidden', 'dynamic_email'))) {
$validator->add_error($component, 'invalid_mailbox_syntax', array(
'message' => __('Only email, dynamic email, hidden, or dynamic hidden form tags can be used for email addresses.', 'contact-form-7-dynamic-text-extension'),
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-invalid_mailbox_syntax#valid-form-tags', $utm_source))
));
} else {
$dynamic_value = wpcf7dtx_get_dynamic(false, $tag); // Get the dynamic value of this tag
if (empty($dynamic_value) && $tag->basetype == 'dynamic_hidden') {
$validator->add_error($component, 'maybe_empty', array(
'message' => __('The dynamic hidden form tag must have a default value.', 'contact-form-7-dynamic-text-extension'),
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-maybe_empty#maybe-empty', $utm_source))
));
} elseif (empty($dynamic_value) && !$tag->is_required()) {
$validator->add_error($component, 'maybe_empty', array(
'message' => __('The dynamic form tag must be required or have a default value.', 'contact-form-7-dynamic-text-extension'),
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-maybe_empty#maybe-empty', $utm_source))
));
} elseif (!empty($dynamic_value)) {
if (!wpcf7_is_email($dynamic_value)) {
$validator->add_error($component, 'invalid_mailbox_syntax', array(
'message' => __('The default dynamic value does not result in a valid email address.', 'contact-form-7-dynamic-text-extension'),
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-invalid_mailbox_syntax#invalid-email-address', $utm_source))
));
} elseif ($component[1] == 'sender' && !wpcf7_is_email_in_site_domain($dynamic_value)) {
$validator->add_error($component, 'email_not_in_site_domain', array(
'message' => __('The dynamic email address for the sender does not belong to the site domain.', 'contact-form-7-dynamic-text-extension'),
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-email_not_in_site_domain#invalid-site-domain', $utm_source))
));
}
}
}
}
}
}
}
}
}
}
}
}
add_action('wpcf7_config_validator_validate', 'wpcf7dtx_validate');