plugin updates
This commit is contained in:
@@ -1,226 +1,229 @@
|
||||
var $ = jQuery.noConflict(),
|
||||
dtx = {
|
||||
queue: [],
|
||||
init: function() {
|
||||
var $inputs = $('input.dtx-pageload[data-dtx-value]');
|
||||
if ($inputs.length) {
|
||||
// If this is any of our built-in shortcodes, see if there's any that can be duplicated via client side
|
||||
$inputs.each(function(i, el) {
|
||||
var $input = $(el),
|
||||
raw_value = $input.attr('data-dtx-value'),
|
||||
v = decodeURIComponent(raw_value).split(' ');
|
||||
if (v.length) {
|
||||
var tag = v[0],
|
||||
atts = {};
|
||||
if (v.length > 1) {
|
||||
for (var x = 1; x < v.length; x++) {
|
||||
var att = v[x].split('=');
|
||||
if (att.length === 2) {
|
||||
var key = att[0];
|
||||
atts[key] = att[1].split("'").join('');
|
||||
}
|
||||
}
|
||||
}
|
||||
var value = '';
|
||||
switch (tag) {
|
||||
case 'CF7_GET':
|
||||
value = dtx.get(atts);
|
||||
break;
|
||||
case 'CF7_referrer':
|
||||
value = dtx.referrer(atts);
|
||||
break;
|
||||
case 'CF7_URL':
|
||||
value = dtx.current_url(atts);
|
||||
break;
|
||||
case 'CF7_get_cookie':
|
||||
value = dtx.get_cookie(atts);
|
||||
break;
|
||||
case 'CF7_guid':
|
||||
value = dtx.guid();
|
||||
break;
|
||||
case 'CF7_get_current_var':
|
||||
if (dtx.validKey(atts, 'key') && atts.key == 'url') {
|
||||
value = dtx.current_url(atts);
|
||||
} else {
|
||||
return; // Do nothing, current page variables are safe to cache, just use the value that was calculated by server
|
||||
}
|
||||
break;
|
||||
case 'CF7_get_post_var': // Current post variables are safe to cache
|
||||
case 'CF7_get_custom_field': // Meta data is safe to cache
|
||||
case 'CF7_get_taxonomy': // Terms are safe to cache
|
||||
case 'CF7_get_attachment': // Media attachment info is safe to cache
|
||||
case 'CF7_bloginfo': // Site info is safe to cache
|
||||
case 'CF7_get_theme_option': // Theme options are safe to cache
|
||||
return; // Do nothing, just use the value that was calculated by server
|
||||
default:
|
||||
if (tag) {
|
||||
// Queue the requests for an AJAX call at the end of init
|
||||
dtx.queue.push({ 'value': raw_value, 'multiline': $input.is('textarea') });
|
||||
}
|
||||
return; // Don't continue after queuing it for AJAX
|
||||
}
|
||||
dtx.set($input, value);
|
||||
}
|
||||
});
|
||||
if (dtx.queue.length) {
|
||||
setTimeout(function() { // Set timeout to force it async
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: dtx_obj.ajax_url,
|
||||
dataType: 'json', // only accept strict JSON objects
|
||||
data: {
|
||||
'action': 'wpcf7dtx',
|
||||
'shortcodes': dtx.queue
|
||||
},
|
||||
cache: false,
|
||||
error: function(xhr, status, error) {
|
||||
console.error('[CF7 DTX AJAX ERROR]', error, status, xhr);
|
||||
},
|
||||
success: function(data, status, xhr) {
|
||||
if (typeof(data) == 'object' && data.length) {
|
||||
$.each(data, function(i, obj) {
|
||||
var $inputs = $('.wpcf7 form input.dtx-pageload[data-dtx-value="' + obj.raw_value + '"]');
|
||||
if ($inputs.length) {
|
||||
dtx.set($inputs, obj.value);
|
||||
$inputs.addClass('dtx-ajax-loaded');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Check if Key Exists in Object
|
||||
*/
|
||||
validKey: function(obj, key) {
|
||||
return obj.hasOwnProperty(key) && typeof(obj[key]) == 'string' && obj[key].trim();
|
||||
},
|
||||
/**
|
||||
* Maybe Obfuscate Value
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-obfuscate/
|
||||
*/
|
||||
obfuscate: function(value, atts) {
|
||||
value = value.trim();
|
||||
if (dtx.validKey(atts, 'obfuscate') && atts.obfuscate) {
|
||||
var o = '';
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
o += '&#' + value.codePointAt(i) + ';';
|
||||
}
|
||||
return o;
|
||||
}
|
||||
return value;
|
||||
},
|
||||
/**
|
||||
* Set Value for Form Field
|
||||
*/
|
||||
set: function($input, value) {
|
||||
$input.attr('value', value).addClass('dtx-loaded');
|
||||
},
|
||||
/**
|
||||
* Get Value form URL Query by Key
|
||||
*
|
||||
* @see @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-php-get-variables/
|
||||
*/
|
||||
get: function(atts) {
|
||||
if (dtx.validKey(atts, 'key')) {
|
||||
var query = window.location.search;
|
||||
if (query) {
|
||||
query = new URLSearchParams(query);
|
||||
return dtx.obfuscate(query.get(atts.key).trim(), atts);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Get Referrering URL
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-referrer-url/
|
||||
*/
|
||||
referrer: function(atts) {
|
||||
return dtx.obfuscate(document.referrer, atts);
|
||||
},
|
||||
/**
|
||||
* Get Current URL or Part
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-current-url/
|
||||
*/
|
||||
current_url: function(atts) {
|
||||
if (atts.hasOwnProperty('part')) {
|
||||
var parts = [
|
||||
'scheme', // e.g. `http`
|
||||
'host',
|
||||
'port',
|
||||
'path',
|
||||
'query', // after the question mark ?
|
||||
'fragment' // after the pound sign #
|
||||
];
|
||||
if (parts.includes(atts.part)) {
|
||||
// return part of the url
|
||||
switch (atts.part) {
|
||||
case 'scheme':
|
||||
return dtx.obfuscate(window.location.protocol.replace(':', ''), atts);
|
||||
case 'host':
|
||||
return dtx.obfuscate(window.location.host, atts);
|
||||
case 'port':
|
||||
return dtx.obfuscate(window.location.port, atts);
|
||||
case 'path':
|
||||
return dtx.obfuscate(window.location.pathname, atts);
|
||||
case 'query':
|
||||
return dtx.obfuscate(window.location.search.replace('?', ''), atts);
|
||||
case 'fragment':
|
||||
return dtx.obfuscate(window.location.hash.replace('#', ''), atts);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return dtx.obfuscate(window.location.href, atts); // Return the full url
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Get Cookie Value
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-cookie/
|
||||
*/
|
||||
get_cookie: function(atts) {
|
||||
if (atts.hasOwnProperty('key') && typeof(atts.key) == 'string' && atts.key.trim() != '') {
|
||||
var keyValue = document.cookie.match('(^|;) ?' + atts.key.trim() + '=([^;]*)(;|$)');
|
||||
return keyValue ? dtx.obfuscate(keyValue[2], atts) : '';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Generate a random GUID (globally unique identifier)
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-guid/
|
||||
*/
|
||||
guid: function() {
|
||||
if (typeof(window.crypto) != 'undefined' && typeof(window.crypto.getRandomValues) != 'undefined') {
|
||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
||||
).toUpperCase();
|
||||
}
|
||||
console.warn('[CF7 DTX] Cryptographically secure PRNG is not available for generating GUID value');
|
||||
var d = new Date().getTime(), //Timestamp
|
||||
d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now() * 1000)) || 0; //Time in microseconds since page-load or 0 if unsupported
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = Math.random() * 16; //random number between 0 and 16
|
||||
if (d > 0) { //Use timestamp until depleted
|
||||
r = (d + r) % 16 | 0;
|
||||
d = Math.floor(d / 16);
|
||||
} else { //Use microseconds since page-load if supported
|
||||
r = (d2 + r) % 16 | 0;
|
||||
d2 = Math.floor(d2 / 16);
|
||||
}
|
||||
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16).toUpperCase();
|
||||
}).toUpperCase();;
|
||||
}
|
||||
};
|
||||
window['$'] = window['$'] || jQuery.noConflict();
|
||||
var dtx = {
|
||||
queue: [],
|
||||
init: function() {
|
||||
var $inputs = $('input.dtx-pageload[data-dtx-value]');
|
||||
if ($inputs.length) {
|
||||
// If this is any of our built-in shortcodes, see if there's any that can be duplicated via client side
|
||||
$inputs.each(function(i, el) {
|
||||
var $input = $(el),
|
||||
raw_value = $input.attr('data-dtx-value'),
|
||||
v = decodeURIComponent(raw_value).split(' ');
|
||||
if (v.length) {
|
||||
var tag = v[0],
|
||||
atts = {};
|
||||
if (v.length > 1) {
|
||||
for (var x = 1; x < v.length; x++) {
|
||||
var att = v[x].split('=');
|
||||
if (att.length === 2) {
|
||||
var key = att[0];
|
||||
atts[key] = att[1].split("'").join('');
|
||||
}
|
||||
}
|
||||
}
|
||||
var value = '';
|
||||
switch (tag) {
|
||||
case 'CF7_GET':
|
||||
value = dtx.get(atts);
|
||||
break;
|
||||
case 'CF7_referrer':
|
||||
value = dtx.referrer(atts);
|
||||
break;
|
||||
case 'CF7_URL':
|
||||
value = dtx.current_url(atts);
|
||||
break;
|
||||
case 'CF7_get_cookie':
|
||||
value = dtx.get_cookie(atts);
|
||||
break;
|
||||
case 'CF7_guid':
|
||||
value = dtx.guid();
|
||||
break;
|
||||
case 'CF7_get_current_var':
|
||||
if (dtx.validKey(atts, 'key') && atts.key == 'url') {
|
||||
value = dtx.current_url(atts);
|
||||
} else {
|
||||
return; // Do nothing, current page variables are safe to cache, just use the value that was calculated by server
|
||||
}
|
||||
break;
|
||||
case 'CF7_get_post_var': // Current post variables are safe to cache
|
||||
case 'CF7_get_custom_field': // Meta data is safe to cache
|
||||
case 'CF7_get_taxonomy': // Terms are safe to cache
|
||||
case 'CF7_get_attachment': // Media attachment info is safe to cache
|
||||
case 'CF7_bloginfo': // Site info is safe to cache
|
||||
case 'CF7_get_theme_option': // Theme options are safe to cache
|
||||
return; // Do nothing, just use the value that was calculated by server
|
||||
default:
|
||||
if (tag) {
|
||||
// Queue the requests for an AJAX call at the end of init
|
||||
dtx.queue.push({ 'value': raw_value, 'multiline': $input.is('textarea') });
|
||||
}
|
||||
return; // Don't continue after queuing it for AJAX
|
||||
}
|
||||
dtx.set($input, value);
|
||||
}
|
||||
});
|
||||
if (dtx.queue.length) {
|
||||
setTimeout(function() { // Set timeout to force it async
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: dtx_obj.ajax_url,
|
||||
dataType: 'json', // only accept strict JSON objects
|
||||
data: {
|
||||
'action': 'wpcf7dtx',
|
||||
'shortcodes': dtx.queue
|
||||
},
|
||||
cache: false,
|
||||
error: function(xhr, status, error) {
|
||||
console.error('[CF7 DTX AJAX ERROR]', error, status, xhr);
|
||||
},
|
||||
success: function(data, status, xhr) {
|
||||
if (typeof(data) == 'object' && data.length) {
|
||||
$.each(data, function(i, obj) {
|
||||
var $inputs = $('.wpcf7 form input.dtx-pageload[data-dtx-value="' + obj.raw_value + '"]');
|
||||
if ($inputs.length) {
|
||||
$inputs.addClass('dtx-ajax-loaded');
|
||||
dtx.set($inputs, obj.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Check if Key Exists in Object
|
||||
*/
|
||||
validKey: function(obj, key) {
|
||||
return obj.hasOwnProperty(key) && typeof(obj[key]) == 'string' && obj[key].trim();
|
||||
},
|
||||
/**
|
||||
* Maybe Obfuscate Value
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-obfuscate/
|
||||
*/
|
||||
obfuscate: function(value, atts) {
|
||||
value = value.trim();
|
||||
if (dtx.validKey(atts, 'obfuscate') && atts.obfuscate) {
|
||||
var o = '';
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
o += '&#' + value.codePointAt(i) + ';';
|
||||
}
|
||||
return o;
|
||||
}
|
||||
return value;
|
||||
},
|
||||
/**
|
||||
* Set Value for Form Field
|
||||
*/
|
||||
set: function($input, value) {
|
||||
$input
|
||||
.attr('value', value)
|
||||
.addClass('dtx-loaded')
|
||||
.trigger('dtx_init');
|
||||
},
|
||||
/**
|
||||
* Get Value form URL Query by Key
|
||||
*
|
||||
* @see @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-php-get-variables/
|
||||
*/
|
||||
get: function(atts) {
|
||||
if (dtx.validKey(atts, 'key')) {
|
||||
var query = window.location.search;
|
||||
if (query) {
|
||||
query = new URLSearchParams(query);
|
||||
return dtx.obfuscate(query.get(atts.key).trim(), atts);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Get Referrering URL
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-referrer-url/
|
||||
*/
|
||||
referrer: function(atts) {
|
||||
return dtx.obfuscate(document.referrer, atts);
|
||||
},
|
||||
/**
|
||||
* Get Current URL or Part
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-current-url/
|
||||
*/
|
||||
current_url: function(atts) {
|
||||
if (atts.hasOwnProperty('part')) {
|
||||
var parts = [
|
||||
'scheme', // e.g. `http`
|
||||
'host',
|
||||
'port',
|
||||
'path',
|
||||
'query', // after the question mark ?
|
||||
'fragment' // after the pound sign #
|
||||
];
|
||||
if (parts.includes(atts.part)) {
|
||||
// return part of the url
|
||||
switch (atts.part) {
|
||||
case 'scheme':
|
||||
return dtx.obfuscate(window.location.protocol.replace(':', ''), atts);
|
||||
case 'host':
|
||||
return dtx.obfuscate(window.location.host, atts);
|
||||
case 'port':
|
||||
return dtx.obfuscate(window.location.port, atts);
|
||||
case 'path':
|
||||
return dtx.obfuscate(window.location.pathname, atts);
|
||||
case 'query':
|
||||
return dtx.obfuscate(window.location.search.replace('?', ''), atts);
|
||||
case 'fragment':
|
||||
return dtx.obfuscate(window.location.hash.replace('#', ''), atts);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return dtx.obfuscate(window.location.href, atts); // Return the full url
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Get Cookie Value
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-cookie/
|
||||
*/
|
||||
get_cookie: function(atts) {
|
||||
if (atts.hasOwnProperty('key') && typeof(atts.key) == 'string' && atts.key.trim() != '') {
|
||||
var keyValue = document.cookie.match('(^|;) ?' + atts.key.trim() + '=([^;]*)(;|$)');
|
||||
return keyValue ? dtx.obfuscate(keyValue[2], atts) : '';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Generate a random GUID (globally unique identifier)
|
||||
*
|
||||
* @see https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-guid/
|
||||
*/
|
||||
guid: function() {
|
||||
if (typeof(window.crypto) != 'undefined' && typeof(window.crypto.getRandomValues) != 'undefined') {
|
||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
||||
).toUpperCase();
|
||||
}
|
||||
console.warn('[CF7 DTX] Cryptographically secure PRNG is not available for generating GUID value');
|
||||
var d = new Date().getTime(), //Timestamp
|
||||
d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now() * 1000)) || 0; //Time in microseconds since page-load or 0 if unsupported
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = Math.random() * 16; //random number between 0 and 16
|
||||
if (d > 0) { //Use timestamp until depleted
|
||||
r = (d + r) % 16 | 0;
|
||||
d = Math.floor(d / 16);
|
||||
} else { //Use microseconds since page-load if supported
|
||||
r = (d2 + r) % 16 | 0;
|
||||
d2 = Math.floor(d2 / 16);
|
||||
}
|
||||
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16).toUpperCase();
|
||||
}).toUpperCase();;
|
||||
}
|
||||
};
|
||||
$(document).ready(dtx.init);
|
||||
@@ -1,2 +1,2 @@
|
||||
/*! Do not edit, this file is generated automatically - 2024-01-09 15:01:30 MST */
|
||||
var $=jQuery.noConflict(),dtx={queue:[],init:function(){var e=$("input.dtx-pageload[data-dtx-value]");e.length&&(e.each(function(e,t){var r=$(t),a=r.attr("data-dtx-value"),o=decodeURIComponent(a).split(" ");if(o.length){var n=o[0],c={};if(1<o.length)for(var u=1;u<o.length;u++){var i=o[u].split("="),d;2===i.length&&(c[i[0]]=i[1].split("'").join(""))}var s="";switch(n){case"CF7_GET":s=dtx.get(c);break;case"CF7_referrer":s=dtx.referrer(c);break;case"CF7_URL":s=dtx.current_url(c);break;case"CF7_get_cookie":s=dtx.get_cookie(c);break;case"CF7_guid":s=dtx.guid();break;case"CF7_get_current_var":if(!dtx.validKey(c,"key")||"url"!=c.key)return;s=dtx.current_url(c);break;case"CF7_get_post_var":case"CF7_get_custom_field":case"CF7_get_taxonomy":case"CF7_get_attachment":case"CF7_bloginfo":case"CF7_get_theme_option":return;default:return void(n&&dtx.queue.push({value:a,multiline:r.is("textarea")}))}dtx.set(r,s)}}),dtx.queue.length)&&setTimeout(function(){$.ajax({type:"POST",url:dtx_obj.ajax_url,dataType:"json",data:{action:"wpcf7dtx",shortcodes:dtx.queue},cache:!1,error:function(e,t,r){},success:function(e,t,r){"object"==typeof e&&e.length&&$.each(e,function(e,t){var r=$('.wpcf7 form input.dtx-pageload[data-dtx-value="'+t.raw_value+'"]');r.length&&(dtx.set(r,t.value),r.addClass("dtx-ajax-loaded"))})}})},10)},validKey:function(e,t){return e.hasOwnProperty(t)&&"string"==typeof e[t]&&e[t].trim()},obfuscate:function(e,t){if(e=e.trim(),dtx.validKey(t,"obfuscate")&&t.obfuscate){for(var r="",a=0;a<e.length;a++)r+="&#"+e.codePointAt(a)+";";return r}return e},set:function(e,t){e.attr("value",t).addClass("dtx-loaded")},get:function(e){if(dtx.validKey(e,"key")){var t=window.location.search;if(t)return t=new URLSearchParams(t),dtx.obfuscate(t.get(e.key).trim(),e)}return""},referrer:function(e){return dtx.obfuscate(document.referrer,e)},current_url:function(e){if(!e.hasOwnProperty("part"))return dtx.obfuscate(window.location.href,e);var t;if(["scheme","host","port","path","query","fragment"].includes(e.part))switch(e.part){case"scheme":return dtx.obfuscate(window.location.protocol.replace(":",""),e);case"host":return dtx.obfuscate(window.location.host,e);case"port":return dtx.obfuscate(window.location.port,e);case"path":return dtx.obfuscate(window.location.pathname,e);case"query":return dtx.obfuscate(window.location.search.replace("?",""),e);case"fragment":return dtx.obfuscate(window.location.hash.replace("#",""),e)}return""},get_cookie:function(e){var t;return e.hasOwnProperty("key")&&"string"==typeof e.key&&""!=e.key.trim()&&(t=document.cookie.match("(^|;) ?"+e.key.trim()+"=([^;]*)(;|$)"))?dtx.obfuscate(t[2],e):""},guid:function(){var r,a;return(void 0!==window.crypto&&void 0!==window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)):(r=(new Date).getTime(),a="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0,"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random();return 0<r?(t=(r+t)%16|0,r=Math.floor(r/16)):(t=(a+t)%16|0,a=Math.floor(a/16)),("x"===e?t:3&t|8).toString(16).toUpperCase()}))).toUpperCase()}};$(document).ready(dtx.init);
|
||||
/*! Do not edit, this file is generated automatically - 2024-02-13 23:02:47 EST */
|
||||
window.$=window.$||jQuery.noConflict();var dtx={queue:[],init:function(){var e=$("input.dtx-pageload[data-dtx-value]");e.length&&(e.each(function(e,t){var r=$(t),a=r.attr("data-dtx-value"),o=decodeURIComponent(a).split(" ");if(o.length){var n=o[0],c={};if(1<o.length)for(var i=1;i<o.length;i++){var u=o[i].split("="),d;2===u.length&&(c[u[0]]=u[1].split("'").join(""))}var s="";switch(n){case"CF7_GET":s=dtx.get(c);break;case"CF7_referrer":s=dtx.referrer(c);break;case"CF7_URL":s=dtx.current_url(c);break;case"CF7_get_cookie":s=dtx.get_cookie(c);break;case"CF7_guid":s=dtx.guid();break;case"CF7_get_current_var":if(!dtx.validKey(c,"key")||"url"!=c.key)return;s=dtx.current_url(c);break;case"CF7_get_post_var":case"CF7_get_custom_field":case"CF7_get_taxonomy":case"CF7_get_attachment":case"CF7_bloginfo":case"CF7_get_theme_option":return;default:return void(n&&dtx.queue.push({value:a,multiline:r.is("textarea")}))}dtx.set(r,s)}}),dtx.queue.length)&&setTimeout(function(){$.ajax({type:"POST",url:dtx_obj.ajax_url,dataType:"json",data:{action:"wpcf7dtx",shortcodes:dtx.queue},cache:!1,error:function(e,t,r){},success:function(e,t,r){"object"==typeof e&&e.length&&$.each(e,function(e,t){var r=$('.wpcf7 form input.dtx-pageload[data-dtx-value="'+t.raw_value+'"]');r.length&&(r.addClass("dtx-ajax-loaded"),dtx.set(r,t.value))})}})},10)},validKey:function(e,t){return e.hasOwnProperty(t)&&"string"==typeof e[t]&&e[t].trim()},obfuscate:function(e,t){if(e=e.trim(),dtx.validKey(t,"obfuscate")&&t.obfuscate){for(var r="",a=0;a<e.length;a++)r+="&#"+e.codePointAt(a)+";";return r}return e},set:function(e,t){e.attr("value",t).addClass("dtx-loaded").trigger("dtx_init")},get:function(e){if(dtx.validKey(e,"key")){var t=window.location.search;if(t)return t=new URLSearchParams(t),dtx.obfuscate(t.get(e.key).trim(),e)}return""},referrer:function(e){return dtx.obfuscate(document.referrer,e)},current_url:function(e){if(!e.hasOwnProperty("part"))return dtx.obfuscate(window.location.href,e);var t;if(["scheme","host","port","path","query","fragment"].includes(e.part))switch(e.part){case"scheme":return dtx.obfuscate(window.location.protocol.replace(":",""),e);case"host":return dtx.obfuscate(window.location.host,e);case"port":return dtx.obfuscate(window.location.port,e);case"path":return dtx.obfuscate(window.location.pathname,e);case"query":return dtx.obfuscate(window.location.search.replace("?",""),e);case"fragment":return dtx.obfuscate(window.location.hash.replace("#",""),e)}return""},get_cookie:function(e){var t;return e.hasOwnProperty("key")&&"string"==typeof e.key&&""!=e.key.trim()&&(t=document.cookie.match("(^|;) ?"+e.key.trim()+"=([^;]*)(;|$)"))?dtx.obfuscate(t[2],e):""},guid:function(){var r,a;return(void 0!==window.crypto&&void 0!==window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)):(r=(new Date).getTime(),a="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0,"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random();return 0<r?(t=(r+t)%16|0,r=Math.floor(r/16)):(t=(a+t)%16|0,a=Math.floor(a/16)),("x"===e?t:3&t|8).toString(16).toUpperCase()}))).toUpperCase()}};$(document).ready(dtx.init);
|
||||
@@ -1,2 +1,2 @@
|
||||
/*! Do not edit, this file is generated automatically - 2024-01-09 15:01:30 MST */
|
||||
/*! Do not edit, this file is generated automatically - 2024-02-13 23:02:47 EST */
|
||||
!function(n){"use strict";"undefined"!=typeof wpcf7&&null!==wpcf7&&(window.wpcf7dtx=window.wpcf7dtx||{},wpcf7dtx.taggen={},wpcf7dtx.taggen.escapeRegExp=function(e){return e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")},wpcf7dtx.taggen.replaceAll=function(e,t,n,a){var c;return null!=e&&"string"==typeof e&&""!==e.trim()&&-1<e.indexOf(t)?(c=new RegExp(wpcf7dtx.taggen.escapeRegExp(t),"g"),a&&(c=new RegExp(t,"g")),e.replace(c,n)):e},wpcf7dtx.taggen.updateOption=function(e){var e=n(e.currentTarget),t=encodeURIComponent(wpcf7dtx.taggen.replaceAll(e.val(),"'","'"));e.siblings('input[type="hidden"].option').val(t)},n(function(){n("form.tag-generator-panel .dtx-option").on("change keyup click",wpcf7dtx.taggen.updateOption),n('.contact-form-editor-panel #tag-generator-list a.thickbox.button[href*="inlineId=tag-generator-panel-dynamic_"]').each(function(){var e=n(this),t=e.text();e.addClass("dtx-form-tag"),"dynamic drop-down menu"!=t&&"dynamic checkboxes"!=t&&"dynamic radio buttons"!=t||e.attr("href",e.attr("href").replace("height=500","height=750"))})}))}(jQuery);
|
||||
@@ -1,218 +1,237 @@
|
||||
== Changelog ==
|
||||
|
||||
= 4.2.0 =
|
||||
|
||||
* Security Update: ** Please be sure to review this doc, as you may need to adjust the settings: https://sevenspark.com/docs/contact-form-7-dynamic-text-extension/allow-data-access **
|
||||
* Feature: Added Settings Screen with Allow Lists
|
||||
* Feature: Added Form Scanner
|
||||
* Feature: Added Allow List key validation in CF7 Form Validator
|
||||
|
||||
= 4.1.0 =
|
||||
|
||||
* Feature: Looks for a `dtx.php` file in the `wp_content` directory to maybe load custom shortcodes, [see support thread](https://wordpress.org/support/topic/how-to-avoid-custom-shortcodes-being-overwritten-on-updates/)
|
||||
* Feature: Looks for a `dtx.php` file in the current active theme's directory to maybe load custom shortcodes, [see support thread](https://wordpress.org/support/topic/how-to-avoid-custom-shortcodes-being-overwritten-on-updates/)
|
||||
* Feature: Looks for a `dtx.php` file in the current active theme's parent directory to maybe load custom shortcodes, [see support thread](https://wordpress.org/support/topic/how-to-avoid-custom-shortcodes-being-overwritten-on-updates/)
|
||||
* Fix: addressed user reported bug, [see support thread](https://wordpress.org/support/topic/fatal-error-v4-0-3/)
|
||||
|
||||
= 4.0.3 =
|
||||
|
||||
* Feature: Added `exclusive` option to checkbox tag generator
|
||||
* Fix: addressed bug that put all dynamic checkbox/radio options into one
|
||||
* Fix: addressed bug in frontend validator for multiple selected values
|
||||
|
||||
= 4.0.2 =
|
||||
|
||||
* Fix: addressed bug that put all dynamic select options into one, [see support thread](https://wordpress.org/support/topic/dynamic-select-get-option-values-from-shortcode/)
|
||||
* Update: sanitizing and escaping filters now accept `none` as value for `$type` to bypass. Use with caution.
|
||||
|
||||
= 4.0.1 =
|
||||
|
||||
* Fix: addressed bug that prevented translation for cache compatibility description
|
||||
|
||||
= 4.0.0 =
|
||||
|
||||
* Major: modified function names
|
||||
* Major: deprecated `dynamictext` and `dynamichidden` form tags in favor of `dynamic_text` and `dynamic_hidden`. For more information, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_email` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-email/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_url` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-url/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_tel` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-tel/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_number` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-number/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_range` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-range/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_textarea` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-textarea/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_select` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_radio` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-radio/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_date` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-date/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_submit` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-submit/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dtx_hide_blank` form tag attribute for `dynamic_select`. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dtx_disable_blank` form tag attribute for `dynamic_select`. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: added mail validation for `dynamic_email` and `dynamic_hidden` for backend configuration. For more information, see the [FAQ](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/frequently-asked-questions/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: added the Akismet feature to DTX text, email, and URL form tags.
|
||||
* Update: adjusted how queued values were sent for cache compatibility mode to allow for multiline values in textareas
|
||||
* Removed unused utility functions
|
||||
|
||||
= 3.5.4 =
|
||||
|
||||
* Fix: Updated JavaScript to prevent cacheable fields from making unnecessary AJAX requests
|
||||
|
||||
= 3.5.3 =
|
||||
|
||||
* Update: removed the use of sessions, [see support thread](https://wordpress.org/support/topic/add-option-to-disable-session-data/)
|
||||
|
||||
= 3.5.2 =
|
||||
|
||||
* Fix: Updated the `CF7_URL` shortcode to only use `network_home_url()` for multisite installs that do not use subdomains, and use `home_url()` for all others to [maybe address this support thread](https://wordpress.org/support/topic/cf7_url-return-only-domain-and-not-subdomain/)
|
||||
* Fix: Removed a lingering debug call
|
||||
|
||||
= 3.5.1 =
|
||||
|
||||
* Fix: fixed bug so tag generator for dynamic fields work on "Add New Contact Form" page of Contact Form 7
|
||||
* Updated: Updated text in tag generator for cache compatible checkbox and added link to documentation
|
||||
|
||||
= 3.5.0 =
|
||||
|
||||
* Feature: Added the `dtx_pageload` form tag attribute for cache compatibility. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tag-attribute-after-page-load/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Fix: Updated to be compatible with WordPress version 6.3
|
||||
* Fix: Addressed a bug where `scheme` in `CF7_URL part='scheme'` was incorrectly sanitizing as URL instead of text
|
||||
* Fix: Fixed `wp_kses()` in tag generator that stripped out link opening in new tab
|
||||
* Update: `CF7_get_current_var` utilizes PHP session variables where appropriate
|
||||
* Update: All JavaScript assets will load with the `defer` strategy in the footer in [WordPress 6.3](https://make.wordpress.org/core/2023/07/14/registering-scripts-with-async-and-defer-attributes-in-wordpress-6-3/)
|
||||
|
||||
= 3.4.0 =
|
||||
|
||||
* Feature: Feature: Added the `CF7_get_current_var` shortcode, [see support thread for user request](https://wordpress.org/support/topic/wrong-page-title-7/). For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-current-variables/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Fix: Updated the `CF7_URL` shortcode to no longer check for ports since that's handled in `network_home_url()` function, [see support thread](https://wordpress.org/support/topic/version-3-3-0-breaking/)
|
||||
|
||||
= 3.3.0 =
|
||||
|
||||
* Feature: Added the `CF7_get_cookie` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-cookie/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added the `CF7_get_taxonomy` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-taxonomy/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added the `CF7_get_theme_option` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-theme-option/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added `wpcf7dtx_sanitize` filter that sanitizes attribute values in built-in shortcodes
|
||||
* Feature: Added `wpcf7dtx_escape` filter that escapes values in built-in shortcodes
|
||||
* Feature: Added `wpcf7dtx_allow_protocols` filter to customize allowed protocols in escaping URLs in built-in shortcodes
|
||||
* Fix: Updated how plugin gets dynamic value in form tags, now uses `wpcf7dtx_get_dynamic()` function
|
||||
* Fix: Added case-insensitive ID in `CF7_get_post_var`
|
||||
* Fix: Sanitizes post variable keys as keys in `wpcf7dtx_get_post_var()`
|
||||
* Fix: Updated `wpcf7dtx_get_post_id()` to pull from "the loop" if `$post` is unavailable and now used consistently across built-in shortcodes
|
||||
* Fix: Updated tag markup to be compatible with Contact Form 7 version 5.6 Beta for successful form validation, [see support thread](https://wordpress.org/support/topic/required-field-no-error-is-output-when-validating-when-field-is-empty/)
|
||||
* Fix: Updated the `CF7_URL` shortcode to use `network_home_url()`, [see support thread](https://wordpress.org/support/topic/current-url-not-working/)
|
||||
* Fix: Updated GUID function to return appropriately escaped values
|
||||
* Fix: Updated all existing built-in shortcodes to use the the sanitizing, escaping, and obfuscating shortcodes, [see support thread](https://wordpress.org/support/topic/cant-get-obfuscate-to-work/)
|
||||
* Fix: Marked compatible with WordPress core version 6.2.
|
||||
|
||||
= 3.2 =
|
||||
|
||||
* Feature: Add optional 'part' parameter to CF7_URL shortcode to retrieve Host, Query, or Path from current URL
|
||||
* Updated minimum PHP requirement to 7.4 moving forward
|
||||
* Update branding assets
|
||||
* Update Tested Up To to 6.1.1
|
||||
* Plugin will now be jointly maintained by [SevenSpark](https://sevenspark.com/) and [AuRise Creative](https://aurisecreative.com)
|
||||
|
||||
= 3.1.3 =
|
||||
|
||||
* Fix: Fixed the syntax error that reappeared in 3.1.2.
|
||||
|
||||
= 3.1.2 =
|
||||
|
||||
**Release Date: January 27, 2023**
|
||||
|
||||
* Fix: updated the text domain to match the plugin slug
|
||||
* Fix: updated all of the translated strings to match
|
||||
|
||||
= 3.1.1 =
|
||||
|
||||
**Release Date: January 26, 2023**
|
||||
|
||||
* Fix: Fixed the syntax error: Parse error: syntax error, unexpected `)` in /wp-content/plugins/contact-form-7-dynamic-text extension/includes/admin.php on line 212
|
||||
|
||||
= 3.1.0 =
|
||||
|
||||
**Release Date: January 25, 2023**
|
||||
|
||||
* Feature: Added the `CF7_get_attachment` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-media-attachment/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added the `CF7_guid` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-guid/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme).
|
||||
* Feature: Added the dynamic placeholder option to the dynamic form tags that allows you to specify dynamic or static placeholder content while also setting dynamic values. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-placeholder/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added a "required" dynamic hidden tag (e.g., `[dynamichidden* ...]`). It is identical to the original dynamic hidden tag (as in the field is not actually validated as required because it is hidden); it just doesn't break your website if you use it. This feature was requested by a user.
|
||||
* Feature: Added the `obfuscate` attribute to all included shortcodes
|
||||
|
||||
= 3.0.0 =
|
||||
|
||||
**Release Date: January 17, 2023**
|
||||
|
||||
* Major: Plugin was adopted by AuRise Creative
|
||||
* Major: All functions use the `wpcf7dtx_` prefix
|
||||
* Feature: Added a `post_id` key for the `CF7_get_post_var` shortcode so you can specify a different post
|
||||
* Feature: Updated the `CF7_get_current_user` shortcode to be able to pull data from user metadata too
|
||||
* Feature: Added the "obfuscate" option to `CF7_get_custom_field` shortcode
|
||||
* Feature: Added the "placeholder" checkbox option to the `dynamictext` tag
|
||||
* Fix: Added additional validation for post ID input
|
||||
* Fix: Added additional validation for the `key` attribute in the `CF7_GET` and `CF7_POST` shortcodes
|
||||
* Fix: Shortcode keys are normalized into lowercase before processing
|
||||
* Security: Sanitizing URLs for the `CF7_URL` and `CF7_referrer` shortcode outputs
|
||||
* Feature/Security: Added a `allowed_protocols` attribute to the `CF7_URL` and `CF7_referrer` shortcodes that defaults to `http,https`
|
||||
|
||||
= 2.0.3 =
|
||||
|
||||
* Security: [Fix Reflected XSS](https://web.archive.org/web/20230121180428/https://sevenspark.com/docs/cf7-dtx-security-2019-07-24)
|
||||
|
||||
= 2.0.2.1 =
|
||||
|
||||
* Update changelog properly for 2.0.2 changes:
|
||||
|
||||
= 2.0.2 =
|
||||
|
||||
* Update deprecated `get_currentuserinfo()` function to `wp_get_current_user()`
|
||||
* Update deprecated functions from `WPCF7_add_shortcode` to `WPCF7_add_formtag` and class from `WPCF7_Shortcode` to `WPCF7_FormTag` to comply with CF7 4.6 changes
|
||||
|
||||
= 2.0.1 =
|
||||
|
||||
* Hook change to guarantee the plugin only runs when Contact Form 7 is present in the admin (avoids errors if Contact Form 7 is disabled, or if there is a plugin sequencing issue)
|
||||
|
||||
= 2.0 =
|
||||
|
||||
* Complete rewrite for Compatibility with Contact Form 7 v4
|
||||
|
||||
= 1.2 =
|
||||
|
||||
* Compatibility update for Contact Form 7 v3.9
|
||||
|
||||
= 1.1.0.2 =
|
||||
|
||||
* Updated to work with Contact Form 7 v3.7.x
|
||||
|
||||
= 1.1.0.1 =
|
||||
|
||||
* Removed undefined variable warning
|
||||
|
||||
= 1.1 =
|
||||
|
||||
* Updated for compatibility with Contact Form 7 v3.6
|
||||
* Added Referrer shortcode
|
||||
|
||||
= 1.0.4.2 =
|
||||
|
||||
* Fixed a bug that created repeating square brackets around dynamic text values in cases where the form doesn't validate and JavaScript is deactivated.
|
||||
|
||||
= 1.0.4.1 =
|
||||
|
||||
* Removed trailing whitespace to fix "Headers already sent" errors
|
||||
|
||||
= 1.0.4 =
|
||||
|
||||
* Added Current User Info shortcode
|
||||
* Added Post Custom Field shortcode (with obfuscation support)
|
||||
* Added Hidden Field capability
|
||||
|
||||
= 1.0.3 =
|
||||
|
||||
* Added $_POST shortcode
|
||||
* Added current post/page variable shortcode
|
||||
* Added current URL shortcode
|
||||
|
||||
= 1.0.2 =
|
||||
|
||||
* Fixed administrative control panel dependency issue
|
||||
|
||||
= 1.0.1 =
|
||||
|
||||
* Fixed dependency issue.
|
||||
== Changelog ==
|
||||
|
||||
= 4.2.3 =
|
||||
|
||||
* Fix: Resolved a bug where the `dynamic_select` displayed with a default size of 40 instead of 1.
|
||||
|
||||
= 4.2.2 =
|
||||
|
||||
* Feature: Cache compatibility JavaScript triggers the custom `dtx_init` event on enabled input fields, [see support thread](https://wordpress.org/support/topic/dynamic_text-cf7_url-dont-fire-onchange-event/).
|
||||
|
||||
= 4.2.1 =
|
||||
|
||||
* Feature: Allows text-based fields to use `autocapitalize` attribute
|
||||
* Feature: Allows text-based fields to use `autofocus` attribute
|
||||
* Feature: Allows text-based fields to use `list` attribute
|
||||
* Feature: Allows text-based fields to use `pattern` attribute
|
||||
* Feature: Allows textareas to use `wrap` attribute
|
||||
* Fix: Resolved the bug that prevented the `dynamic_date` shortcode from using `min`, `max`, and `step` attributes, [see support thread](https://wordpress.org/support/topic/dynamic_date-min-max-step-options-ignored/).
|
||||
* Fix: Added minimum version check for Contact Form 7, [see support thread](https://wordpress.org/support/topic/str_contains-is-php-8-0-only-broken-compatibility/).
|
||||
* Fix: Resolved an issue that used a function introduced in PHP 8 while plugin compatibility setting is currently still set to 7.4+, [see support thread](https://wordpress.org/support/topic/str_contains-is-php-8-0-only-broken-compatibility/).
|
||||
|
||||
= 4.2.0 =
|
||||
|
||||
* Security Update: ** Please be sure to review this doc, as you may need to adjust the settings: https://sevenspark.com/docs/contact-form-7-dynamic-text-extension/allow-data-access **
|
||||
* Feature: Added Settings Screen with Allow Lists
|
||||
* Feature: Added Form Scanner
|
||||
* Feature: Added Allow List key validation in CF7 Form Validator
|
||||
|
||||
= 4.1.0 =
|
||||
|
||||
* Feature: Looks for a `dtx.php` file in the `wp_content` directory to maybe load custom shortcodes, [see support thread](https://wordpress.org/support/topic/how-to-avoid-custom-shortcodes-being-overwritten-on-updates/)
|
||||
* Feature: Looks for a `dtx.php` file in the current active theme's directory to maybe load custom shortcodes, [see support thread](https://wordpress.org/support/topic/how-to-avoid-custom-shortcodes-being-overwritten-on-updates/)
|
||||
* Feature: Looks for a `dtx.php` file in the current active theme's parent directory to maybe load custom shortcodes, [see support thread](https://wordpress.org/support/topic/how-to-avoid-custom-shortcodes-being-overwritten-on-updates/)
|
||||
* Fix: addressed user reported bug, [see support thread](https://wordpress.org/support/topic/fatal-error-v4-0-3/)
|
||||
|
||||
= 4.0.3 =
|
||||
|
||||
* Feature: Added `exclusive` option to checkbox tag generator
|
||||
* Fix: addressed bug that put all dynamic checkbox/radio options into one
|
||||
* Fix: addressed bug in frontend validator for multiple selected values
|
||||
|
||||
= 4.0.2 =
|
||||
|
||||
* Fix: addressed bug that put all dynamic select options into one, [see support thread](https://wordpress.org/support/topic/dynamic-select-get-option-values-from-shortcode/)
|
||||
* Update: sanitizing and escaping filters now accept `none` as value for `$type` to bypass. Use with caution.
|
||||
|
||||
= 4.0.1 =
|
||||
|
||||
* Fix: addressed bug that prevented translation for cache compatibility description
|
||||
|
||||
= 4.0.0 =
|
||||
|
||||
* Major: modified function names
|
||||
* Major: deprecated `dynamictext` and `dynamichidden` form tags in favor of `dynamic_text` and `dynamic_hidden`. For more information, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_email` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-email/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_url` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-url/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_tel` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-tel/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_number` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-number/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_range` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-range/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_textarea` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-textarea/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_select` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_radio` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-radio/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_date` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-date/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dynamic_submit` form tag. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-submit/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dtx_hide_blank` form tag attribute for `dynamic_select`. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: introduced `dtx_disable_blank` form tag attribute for `dynamic_select`. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: added mail validation for `dynamic_email` and `dynamic_hidden` for backend configuration. For more information, see the [FAQ](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/frequently-asked-questions/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: added the Akismet feature to DTX text, email, and URL form tags.
|
||||
* Update: adjusted how queued values were sent for cache compatibility mode to allow for multiline values in textareas
|
||||
* Removed unused utility functions
|
||||
|
||||
= 3.5.4 =
|
||||
|
||||
* Fix: Updated JavaScript to prevent cacheable fields from making unnecessary AJAX requests
|
||||
|
||||
= 3.5.3 =
|
||||
|
||||
* Update: removed the use of sessions, [see support thread](https://wordpress.org/support/topic/add-option-to-disable-session-data/)
|
||||
|
||||
= 3.5.2 =
|
||||
|
||||
* Fix: Updated the `CF7_URL` shortcode to only use `network_home_url()` for multisite installs that do not use subdomains, and use `home_url()` for all others to [maybe address this support thread](https://wordpress.org/support/topic/cf7_url-return-only-domain-and-not-subdomain/)
|
||||
* Fix: Removed a lingering debug call
|
||||
|
||||
= 3.5.1 =
|
||||
|
||||
* Fix: fixed bug so tag generator for dynamic fields work on "Add New Contact Form" page of Contact Form 7
|
||||
* Updated: Updated text in tag generator for cache compatible checkbox and added link to documentation
|
||||
|
||||
= 3.5.0 =
|
||||
|
||||
* Feature: Added the `dtx_pageload` form tag attribute for cache compatibility. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tag-attribute-after-page-load/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Fix: Updated to be compatible with WordPress version 6.3
|
||||
* Fix: Addressed a bug where `scheme` in `CF7_URL part='scheme'` was incorrectly sanitizing as URL instead of text
|
||||
* Fix: Fixed `wp_kses()` in tag generator that stripped out link opening in new tab
|
||||
* Update: `CF7_get_current_var` utilizes PHP session variables where appropriate
|
||||
* Update: All JavaScript assets will load with the `defer` strategy in the footer in [WordPress 6.3](https://make.wordpress.org/core/2023/07/14/registering-scripts-with-async-and-defer-attributes-in-wordpress-6-3/)
|
||||
|
||||
= 3.4.0 =
|
||||
|
||||
* Feature: Feature: Added the `CF7_get_current_var` shortcode, [see support thread for user request](https://wordpress.org/support/topic/wrong-page-title-7/). For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-current-variables/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Fix: Updated the `CF7_URL` shortcode to no longer check for ports since that's handled in `network_home_url()` function, [see support thread](https://wordpress.org/support/topic/version-3-3-0-breaking/)
|
||||
|
||||
= 3.3.0 =
|
||||
|
||||
* Feature: Added the `CF7_get_cookie` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-cookie/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added the `CF7_get_taxonomy` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-taxonomy/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added the `CF7_get_theme_option` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-theme-option/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added `wpcf7dtx_sanitize` filter that sanitizes attribute values in built-in shortcodes
|
||||
* Feature: Added `wpcf7dtx_escape` filter that escapes values in built-in shortcodes
|
||||
* Feature: Added `wpcf7dtx_allow_protocols` filter to customize allowed protocols in escaping URLs in built-in shortcodes
|
||||
* Fix: Updated how plugin gets dynamic value in form tags, now uses `wpcf7dtx_get_dynamic()` function
|
||||
* Fix: Added case-insensitive ID in `CF7_get_post_var`
|
||||
* Fix: Sanitizes post variable keys as keys in `wpcf7dtx_get_post_var()`
|
||||
* Fix: Updated `wpcf7dtx_get_post_id()` to pull from "the loop" if `$post` is unavailable and now used consistently across built-in shortcodes
|
||||
* Fix: Updated tag markup to be compatible with Contact Form 7 version 5.6 Beta for successful form validation, [see support thread](https://wordpress.org/support/topic/required-field-no-error-is-output-when-validating-when-field-is-empty/)
|
||||
* Fix: Updated the `CF7_URL` shortcode to use `network_home_url()`, [see support thread](https://wordpress.org/support/topic/current-url-not-working/)
|
||||
* Fix: Updated GUID function to return appropriately escaped values
|
||||
* Fix: Updated all existing built-in shortcodes to use the the sanitizing, escaping, and obfuscating shortcodes, [see support thread](https://wordpress.org/support/topic/cant-get-obfuscate-to-work/)
|
||||
* Fix: Marked compatible with WordPress core version 6.2.
|
||||
|
||||
= 3.2 =
|
||||
|
||||
* Feature: Add optional 'part' parameter to CF7_URL shortcode to retrieve Host, Query, or Path from current URL
|
||||
* Updated minimum PHP requirement to 7.4 moving forward
|
||||
* Update branding assets
|
||||
* Update Tested Up To to 6.1.1
|
||||
* Plugin will now be jointly maintained by [SevenSpark](https://sevenspark.com/) and [AuRise Creative](https://aurisecreative.com)
|
||||
|
||||
= 3.1.3 =
|
||||
|
||||
* Fix: Fixed the syntax error that reappeared in 3.1.2.
|
||||
|
||||
= 3.1.2 =
|
||||
|
||||
**Release Date: January 27, 2023**
|
||||
|
||||
* Fix: updated the text domain to match the plugin slug
|
||||
* Fix: updated all of the translated strings to match
|
||||
|
||||
= 3.1.1 =
|
||||
|
||||
**Release Date: January 26, 2023**
|
||||
|
||||
* Fix: Fixed the syntax error: Parse error: syntax error, unexpected `)` in /wp-content/plugins/contact-form-7-dynamic-text extension/includes/admin.php on line 212
|
||||
|
||||
= 3.1.0 =
|
||||
|
||||
**Release Date: January 25, 2023**
|
||||
|
||||
* Feature: Added the `CF7_get_attachment` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-media-attachment/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added the `CF7_guid` shortcode. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-shortcode-guid/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme).
|
||||
* Feature: Added the dynamic placeholder option to the dynamic form tags that allows you to specify dynamic or static placeholder content while also setting dynamic values. For usage details, see the [knowledge base](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-placeholder/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)
|
||||
* Feature: Added a "required" dynamic hidden tag (e.g., `[dynamichidden* ...]`). It is identical to the original dynamic hidden tag (as in the field is not actually validated as required because it is hidden); it just doesn't break your website if you use it. This feature was requested by a user.
|
||||
* Feature: Added the `obfuscate` attribute to all included shortcodes
|
||||
|
||||
= 3.0.0 =
|
||||
|
||||
**Release Date: January 17, 2023**
|
||||
|
||||
* Major: Plugin was adopted by AuRise Creative
|
||||
* Major: All functions use the `wpcf7dtx_` prefix
|
||||
* Feature: Added a `post_id` key for the `CF7_get_post_var` shortcode so you can specify a different post
|
||||
* Feature: Updated the `CF7_get_current_user` shortcode to be able to pull data from user metadata too
|
||||
* Feature: Added the "obfuscate" option to `CF7_get_custom_field` shortcode
|
||||
* Feature: Added the "placeholder" checkbox option to the `dynamictext` tag
|
||||
* Fix: Added additional validation for post ID input
|
||||
* Fix: Added additional validation for the `key` attribute in the `CF7_GET` and `CF7_POST` shortcodes
|
||||
* Fix: Shortcode keys are normalized into lowercase before processing
|
||||
* Security: Sanitizing URLs for the `CF7_URL` and `CF7_referrer` shortcode outputs
|
||||
* Feature/Security: Added a `allowed_protocols` attribute to the `CF7_URL` and `CF7_referrer` shortcodes that defaults to `http,https`
|
||||
|
||||
= 2.0.3 =
|
||||
|
||||
* Security: [Fix Reflected XSS](https://web.archive.org/web/20230121180428/https://sevenspark.com/docs/cf7-dtx-security-2019-07-24)
|
||||
|
||||
= 2.0.2.1 =
|
||||
|
||||
* Update changelog properly for 2.0.2 changes:
|
||||
|
||||
= 2.0.2 =
|
||||
|
||||
* Update deprecated `get_currentuserinfo()` function to `wp_get_current_user()`
|
||||
* Update deprecated functions from `WPCF7_add_shortcode` to `WPCF7_add_formtag` and class from `WPCF7_Shortcode` to `WPCF7_FormTag` to comply with CF7 4.6 changes
|
||||
|
||||
= 2.0.1 =
|
||||
|
||||
* Hook change to guarantee the plugin only runs when Contact Form 7 is present in the admin (avoids errors if Contact Form 7 is disabled, or if there is a plugin sequencing issue)
|
||||
|
||||
= 2.0 =
|
||||
|
||||
* Complete rewrite for Compatibility with Contact Form 7 v4
|
||||
|
||||
= 1.2 =
|
||||
|
||||
* Compatibility update for Contact Form 7 v3.9
|
||||
|
||||
= 1.1.0.2 =
|
||||
|
||||
* Updated to work with Contact Form 7 v3.7.x
|
||||
|
||||
= 1.1.0.1 =
|
||||
|
||||
* Removed undefined variable warning
|
||||
|
||||
= 1.1 =
|
||||
|
||||
* Updated for compatibility with Contact Form 7 v3.6
|
||||
* Added Referrer shortcode
|
||||
|
||||
= 1.0.4.2 =
|
||||
|
||||
* Fixed a bug that created repeating square brackets around dynamic text values in cases where the form doesn't validate and JavaScript is deactivated.
|
||||
|
||||
= 1.0.4.1 =
|
||||
|
||||
* Removed trailing whitespace to fix "Headers already sent" errors
|
||||
|
||||
= 1.0.4 =
|
||||
|
||||
* Added Current User Info shortcode
|
||||
* Added Post Custom Field shortcode (with obfuscation support)
|
||||
* Added Hidden Field capability
|
||||
|
||||
= 1.0.3 =
|
||||
|
||||
* Added $_POST shortcode
|
||||
* Added current post/page variable shortcode
|
||||
* Added current URL shortcode
|
||||
|
||||
= 1.0.2 =
|
||||
|
||||
* Fixed administrative control panel dependency issue
|
||||
|
||||
= 1.0.1 =
|
||||
|
||||
* Fixed dependency issue.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Plugin Name: Contact Form 7 - Dynamic Text Extension
|
||||
* Plugin URI: https://sevenspark.com/goods/contact-form-7-dynamic-text-extension
|
||||
* Description: This plugin extends Contact Form 7 by adding dynamic form fields that accept any shortcode to generate default values and placeholder text. Requires Contact Form 7.
|
||||
* Version: 4.2.0
|
||||
* Version: 4.2.3
|
||||
* Author: SevenSpark, AuRise Creative
|
||||
* Author URI: https://sevenspark.com
|
||||
* License: GPL2
|
||||
@@ -31,16 +31,24 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// Define current version
|
||||
define('WPCF7DTX_VERSION', '4.2.0');
|
||||
define('WPCF7DTX_VERSION', '4.2.3'); // Define current version of DTX
|
||||
define('WPCF7DTX_MINVERSION', '5.7'); // The minimum version of CF7 required to use all features
|
||||
defined('WPCF7DTX_DIR') || define('WPCF7DTX_DIR', __DIR__); // Define root directory
|
||||
defined('WPCF7DTX_FILE') || define('WPCF7DTX_FILE', __FILE__); // Define root file
|
||||
|
||||
// Define root directory
|
||||
defined('WPCF7DTX_DIR') || define('WPCF7DTX_DIR', __DIR__);
|
||||
define('WPCF7DTX_DATA_ACCESS_KB_URL', 'https://sevenspark.com/docs/contact-form-7-dynamic-text-extension/allow-data-access');
|
||||
|
||||
// Define root file
|
||||
defined('WPCF7DTX_FILE') || define('WPCF7DTX_FILE', __FILE__);
|
||||
|
||||
define( 'WPCF7DTX_DATA_ACCESS_KB_URL', 'https://sevenspark.com/docs/contact-form-7-dynamic-text-extension/allow-data-access' );
|
||||
/**
|
||||
* Determine Dependencies are Met
|
||||
*
|
||||
* @since 4.2.1
|
||||
*
|
||||
* @return bool True if minimum version of Contact Form 7 is met. False otherwise.
|
||||
*/
|
||||
function wpcf7dtx_dependencies()
|
||||
{
|
||||
return defined('WPCF7_VERSION') && version_compare(constant('WPCF7_VERSION'), WPCF7DTX_MINVERSION, '>=');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise Plugin
|
||||
@@ -49,6 +57,18 @@ define( 'WPCF7DTX_DATA_ACCESS_KB_URL', 'https://sevenspark.com/docs/contact-form
|
||||
*/
|
||||
function wpcf7dtx_init()
|
||||
{
|
||||
if (!wpcf7dtx_dependencies()) {
|
||||
add_action('admin_notices', function () {
|
||||
echo (wp_kses_post(sprintf(
|
||||
'<div class="notice notice-error is-dismissible"><p><strong>%s</strong> %s</p></div>',
|
||||
__('Form validation for dynamic fields created with <em>Contact Form 7 - Dynamic Text Extension</em> is not available!', 'contact-form-7-dynamic-text-extension'),
|
||||
sprintf(
|
||||
__('<em>Contact Form 7</em> version %s or higher is required.', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html(WPCF7DTX_MINVERSION)
|
||||
)
|
||||
)));
|
||||
});
|
||||
}
|
||||
add_action('wpcf7_init', 'wpcf7dtx_add_shortcodes'); // Add custom form tags to CF7
|
||||
}
|
||||
add_action('plugins_loaded', 'wpcf7dtx_init', 20);
|
||||
@@ -67,12 +87,12 @@ function wpcf7dtx_config()
|
||||
$wpcf7_dynamic_fields_config = array(
|
||||
'dynamic_text' => array(
|
||||
'title' => __('dynamic text', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'dtx_pageload'),
|
||||
'options' => array('placeholder', 'readonly'),
|
||||
'description' => __('a single-line plain text', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_hidden' => array(
|
||||
'title' => __('dynamic hidden', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('dtx_pageload'),
|
||||
'options' => array(),
|
||||
'description' => __('a single-line plain text hidden input field', 'contact-form-7-dynamic-text-extension'),
|
||||
'features' => array(
|
||||
'display-hidden' => true // Generates an HTML element that is not visible
|
||||
@@ -80,12 +100,12 @@ function wpcf7dtx_config()
|
||||
),
|
||||
'dynamic_email' => array(
|
||||
'title' => __('dynamic email', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'dtx_pageload'),
|
||||
'options' => array('placeholder', 'readonly'),
|
||||
'description' => __('a single-line email address input field', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_url' => array(
|
||||
'title' => __('dynamic URL', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'dtx_pageload'),
|
||||
'options' => array('placeholder', 'readonly'),
|
||||
'description' => __('a single-line URL input field', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_tel' => array(
|
||||
@@ -105,7 +125,7 @@ function wpcf7dtx_config()
|
||||
),
|
||||
'dynamic_textarea' => array(
|
||||
'title' => __('dynamic textarea', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'dtx_pageload'),
|
||||
'options' => array('placeholder', 'readonly'),
|
||||
'description' => __('a multi-line plain text input field', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_select' => array(
|
||||
@@ -136,12 +156,12 @@ function wpcf7dtx_config()
|
||||
),
|
||||
'dynamic_date' => array(
|
||||
'title' => __('dynamic date', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'min', 'max'),
|
||||
'options' => array('placeholder', 'readonly', 'min', 'max', 'step'),
|
||||
'description' => __('a date input field', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_submit' => array(
|
||||
'title' => __('dynamic submit', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('dtx_pageload'),
|
||||
'options' => array(),
|
||||
'description' => __('a submit button', 'contact-form-7-dynamic-text-extension')
|
||||
)
|
||||
);
|
||||
@@ -249,7 +269,6 @@ function wpcf7dtx_shortcode_handler($tag)
|
||||
$atts['name'] = $tag->name;
|
||||
$atts['id'] = strval($tag->get_id_option());
|
||||
$atts['tabindex'] = $tag->get_option('tabindex', 'signed_int', true);
|
||||
$atts['size'] = $tag->get_size_option('40');
|
||||
$atts['class'] = explode(' ', wpcf7_form_controls_class($atts['type']));
|
||||
$atts['class'][] = 'wpcf7dtx';
|
||||
$atts['class'][] = sanitize_html_class('wpcf7dtx-' . $atts['type']);
|
||||
@@ -260,10 +279,22 @@ function wpcf7dtx_shortcode_handler($tag)
|
||||
} else {
|
||||
$atts['aria-invalid'] = 'false';
|
||||
}
|
||||
|
||||
if ($tag->has_option('readonly')) {
|
||||
$atts['readonly'] = 'readonly';
|
||||
}
|
||||
|
||||
// Dynamically determine disabled attribute, remove if invalid
|
||||
$atts['disabled'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('disabled', '', true)), ENT_QUOTES));
|
||||
if ($atts['disabled'] != 'disabled') {
|
||||
unset($atts['disabled']);
|
||||
}
|
||||
|
||||
// Dynamically determine autofocus attribute, remove if invalid
|
||||
$atts['autofocus'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('autofocus', '', true)), ENT_QUOTES));
|
||||
if ($atts['autofocus'] != 'autofocus') {
|
||||
unset($atts['autofocus']);
|
||||
}
|
||||
|
||||
// Add required attribute to applicable input types
|
||||
if ($tag->is_required() && !in_array($atts['type'], array('hidden', 'quiz'))) {
|
||||
$atts['aria-required'] = 'true';
|
||||
@@ -329,12 +360,22 @@ function wpcf7dtx_shortcode_handler($tag)
|
||||
if ($atts['type'] == 'select' && $tag->has_option('include_blank')) {
|
||||
$atts['placeholder'] = wpcf7dtx_array_has_key('placeholder', $atts, __('—Please choose an option—', 'contact-form-7-dynamic-text-extension'));
|
||||
}
|
||||
if ($atts['type'] == 'select') {
|
||||
$atts['size'] = $tag->get_size_option('1');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Configuration for text-based fields
|
||||
*/
|
||||
$atts['size'] = $tag->get_size_option('40');
|
||||
$atts['list'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('list', '', true)), ENT_QUOTES));
|
||||
$atts['autocapitalize'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('autocapitalize', '', true)), ENT_QUOTES));
|
||||
$atts['pattern'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('pattern', '', true)), ENT_QUOTES));
|
||||
$atts['min'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('min', '', true)), ENT_QUOTES));
|
||||
$atts['max'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('max', '', true)), ENT_QUOTES));
|
||||
$atts['step'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('step', '', true)), ENT_QUOTES));
|
||||
|
||||
// Attributes
|
||||
// Min and Max length attributes
|
||||
$atts['maxlength'] = $tag->get_maxlength_option();
|
||||
$atts['minlength'] = $tag->get_minlength_option();
|
||||
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
|
||||
@@ -350,22 +391,26 @@ function wpcf7dtx_shortcode_handler($tag)
|
||||
}
|
||||
|
||||
switch ($atts['type']) {
|
||||
case 'email':
|
||||
case 'url':
|
||||
case 'tel':
|
||||
case 'number':
|
||||
case 'date':
|
||||
// Client-side validation by type
|
||||
$atts['class'][] = sanitize_html_class('wpcf7-validates-as-' . $atts['type']);
|
||||
break;
|
||||
case 'range':
|
||||
// Client-side validation by type
|
||||
$atts['class'][] = 'wpcf7-validates-as-number';
|
||||
break;
|
||||
case 'date':
|
||||
case 'number':
|
||||
case 'email':
|
||||
case 'url':
|
||||
case 'tel':
|
||||
// Client-side validation by type
|
||||
$atts['class'][] = sanitize_html_class('wpcf7-validates-as-' . $atts['type']);
|
||||
break;
|
||||
case 'textarea':
|
||||
// Attributes unique to textareas
|
||||
$atts['cols'] = $tag->get_cols_option('40');
|
||||
$atts['rows'] = $tag->get_rows_option('10');
|
||||
$atts['wrap'] = $tag->get_option('wrap', '', true);
|
||||
if (!in_array($atts['wrap'], array('hard', 'soft'))) {
|
||||
unset($atts['wrap']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
// Include the Settings Page & Update Check
|
||||
include_once( 'admin/settings.php' );
|
||||
include_once( 'admin/update-check.php' );
|
||||
include_once('admin/settings.php');
|
||||
include_once('admin/update-check.php');
|
||||
|
||||
/**
|
||||
* Admin Scripts and Styles
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,97 +1,140 @@
|
||||
<?php
|
||||
|
||||
|
||||
add_action( 'plugins_loaded', 'wpcf7dtx_update_check' );
|
||||
function wpcf7dtx_update_check(){
|
||||
if( WPCF7DTX_VERSION !== get_option( 'cf7dtx_version', '' ) ){
|
||||
|
||||
// Update the database version with the current plugin version
|
||||
update_option( 'cf7dtx_version', WPCF7DTX_VERSION );
|
||||
|
||||
// Run the update handler
|
||||
add_action('admin_init', 'wpcf7dtx_update');
|
||||
}
|
||||
}
|
||||
function wpcf7dtx_update(){
|
||||
|
||||
// v4.2.0 will scan for meta and user keys that should be allow-listed and display an admin alert
|
||||
wpcf7dtx_v4_2_0_access_scan_check();
|
||||
|
||||
// Future update processes would go here
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** 4.2.0 - Security Access ***/
|
||||
function wpcf7dtx_v4_2_0_access_scan_check(){
|
||||
|
||||
$op = 'cf7dtx_v4_2_0_access_scan_check_status';
|
||||
$status = get_option( $op, '' );
|
||||
|
||||
// Status values:
|
||||
// intervention_required - show a notice to the admin
|
||||
// intervention_not_required - we can ignore
|
||||
// intervention_completed - no need to show notice any longer
|
||||
// notice_dismissed - alert was dismissed by user
|
||||
|
||||
// If we've never checked before
|
||||
if( $status === '' ){
|
||||
// Run a scan - 20 by default. If they have more than 20 forms, we'll alert regardless.
|
||||
// For less than 20 forms, we'll only alert if we detect an issue
|
||||
$num_to_scan = 20;
|
||||
$r = wpcf7dtx_scan_forms_for_access_keys( $num_to_scan );
|
||||
$found = count($r['forms']);
|
||||
$scanned = $r['forms_scanned'];
|
||||
|
||||
// If keys were found, or if we scanned the max number (so there are likely more to be scanned)
|
||||
if( $found || $scanned === $num_to_scan ){
|
||||
// We'll show a notice to the user
|
||||
$status = 'intervention_required';
|
||||
}
|
||||
else{
|
||||
// No keys need to be allow-listed, no need to show the user a list
|
||||
$status = 'intervention_not_required';
|
||||
}
|
||||
wpcf7dtx_set_update_access_scan_check_status( $status );
|
||||
}
|
||||
}
|
||||
|
||||
add_action('admin_notices', 'wpcf7dtx_access_keys_notice');
|
||||
/**
|
||||
* Display an admin notice if there are unresolved issues with accessing disallowed keys via DTX shortcodes
|
||||
*/
|
||||
function wpcf7dtx_access_keys_notice(){
|
||||
|
||||
// Don't show this notice on the Scan Results screen to avoid confusion
|
||||
if( isset($_GET['page']) && $_GET['page'] === 'cf7dtx_settings' && ( isset( $_GET['scan-meta-keys']) || isset($_GET['dismiss-access-keys-notice']))) return;
|
||||
|
||||
// If this user is not an administrator, don't do anything. Only admins should see this.
|
||||
$user = wp_get_current_user();
|
||||
if ( !in_array( 'administrator', (array) $user->roles ) ) return;
|
||||
|
||||
// If the status doesn't require intervention, don't do anything
|
||||
$status = get_option( 'cf7dtx_v4_2_0_access_scan_check_status', '' );
|
||||
if( $status !== 'intervention_required' ){
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="notice notice-error">
|
||||
<p>
|
||||
<?php _e('CF7 DTX: Shortcode data access requires allow-listing.', 'contact-form-7-dynamic-text-extension'); ?>
|
||||
<a href="<?php echo wpcf7dtx_get_admin_settings_screen_url(); ?>"><?php _e('Edit Settings', 'contact-form-7-dynamic-text-extension' ); ?></a>
|
||||
|
|
||||
<a href="<?php echo wpcf7dtx_get_admin_scan_screen_url(); ?>"><?php _e('Scan & Resolve', 'contact-form-7-dynamic-text-extension' ); ?></a>
|
||||
|
|
||||
<a href="<?php echo WPCF7DTX_DATA_ACCESS_KB_URL; ?>" target="_blank"><?php _e('More Information', 'contact-form-7-dynamic-text-extension' ); ?></a>
|
||||
<?php if( isset($_GET['page']) && $_GET['page'] === 'cf7dtx_settings' ): ?>
|
||||
| <a href="<?php echo admin_url('admin.php?page=cf7dtx_settings&dismiss-access-keys-notice'); ?>"><?php _e('Dismiss', 'contact-form-7-dynamic-text-extension' ); ?></a>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
function wpcf7dtx_set_update_access_scan_check_status( $status ){
|
||||
update_option( 'cf7dtx_v4_2_0_access_scan_check_status', $status );
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Check for Updates
|
||||
*
|
||||
* Hooked to `plugins_loaded` to compare source code version with database version.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_update_check()
|
||||
{
|
||||
if (WPCF7DTX_VERSION !== get_option('cf7dtx_version', '')) {
|
||||
|
||||
// Update the database version with the current plugin version
|
||||
update_option('cf7dtx_version', WPCF7DTX_VERSION);
|
||||
|
||||
// Run the update handler
|
||||
add_action('admin_init', 'wpcf7dtx_update');
|
||||
}
|
||||
}
|
||||
add_action('plugins_loaded', 'wpcf7dtx_update_check');
|
||||
|
||||
/**
|
||||
* Maybe Update DTX
|
||||
*
|
||||
* Optionally hooked to `admin_init` when source code version is newer than database version.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_update()
|
||||
{
|
||||
|
||||
// v4.2.0 will scan for meta and user keys that should be allow-listed and display an admin alert
|
||||
wpcf7dtx_v4_2_0_access_scan_check();
|
||||
|
||||
// Future update processes would go here
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DTX Form Scan
|
||||
*
|
||||
* Scan for meta and user keys that should be allowlisted and display an admin alert.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_v4_2_0_access_scan_check()
|
||||
{
|
||||
|
||||
$op = 'cf7dtx_v4_2_0_access_scan_check_status';
|
||||
$status = get_option($op, '');
|
||||
|
||||
// Status values:
|
||||
// intervention_required - show a notice to the admin
|
||||
// intervention_not_required - we can ignore
|
||||
// intervention_completed - no need to show notice any longer
|
||||
// notice_dismissed - alert was dismissed by user
|
||||
|
||||
// If we've never checked before
|
||||
if ($status === '') {
|
||||
// Run a scan - 20 by default. If they have more than 20 forms, we'll alert regardless.
|
||||
// For less than 20 forms, we'll only alert if we detect an issue
|
||||
$num_to_scan = 20;
|
||||
$r = wpcf7dtx_scan_forms_for_access_keys($num_to_scan);
|
||||
$found = count($r['forms']);
|
||||
$scanned = $r['forms_scanned'];
|
||||
|
||||
// If keys were found, or if we scanned the max number (so there are likely more to be scanned)
|
||||
if ($found || $scanned === $num_to_scan) {
|
||||
// We'll show a notice to the user
|
||||
$status = 'intervention_required';
|
||||
} else {
|
||||
// No keys need to be allow-listed, no need to show the user a list
|
||||
$status = 'intervention_not_required';
|
||||
}
|
||||
wpcf7dtx_set_update_access_scan_check_status($status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DTX Admin Notice
|
||||
*
|
||||
* Display an admin notice if there are unresolved issues with accessing disallowed keys via DTX shortcodes
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_access_keys_notice()
|
||||
{
|
||||
|
||||
// Don't show this notice on the Scan Results screen to avoid confusion
|
||||
if (isset($_GET['page']) && $_GET['page'] === 'cf7dtx_settings' && (isset($_GET['scan-meta-keys']) || isset($_GET['dismiss-access-keys-notice']))) return;
|
||||
|
||||
// If this user is not an administrator, don't do anything. Only admins should see this.
|
||||
$user = wp_get_current_user();
|
||||
if (!in_array('administrator', (array) $user->roles)) return;
|
||||
|
||||
// If the status doesn't require intervention, don't do anything
|
||||
$status = get_option('cf7dtx_v4_2_0_access_scan_check_status', '');
|
||||
if ($status !== 'intervention_required') {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="notice notice-error">
|
||||
<p>
|
||||
<?php _e('CF7 DTX: Shortcode data access requires allow-listing.', 'contact-form-7-dynamic-text-extension'); ?>
|
||||
<a href="<?php echo wpcf7dtx_get_admin_settings_screen_url(); ?>"><?php _e('Edit Settings', 'contact-form-7-dynamic-text-extension'); ?></a>
|
||||
|
|
||||
<a href="<?php echo wpcf7dtx_get_admin_scan_screen_url(); ?>"><?php _e('Scan & Resolve', 'contact-form-7-dynamic-text-extension'); ?></a>
|
||||
|
|
||||
<a href="<?php echo WPCF7DTX_DATA_ACCESS_KB_URL; ?>" target="_blank"><?php _e('More Information', 'contact-form-7-dynamic-text-extension'); ?></a>
|
||||
<?php if (isset($_GET['page']) && $_GET['page'] === 'cf7dtx_settings') : ?>
|
||||
| <a href="<?php echo admin_url('admin.php?page=cf7dtx_settings&dismiss-access-keys-notice'); ?>"><?php _e('Dismiss', 'contact-form-7-dynamic-text-extension'); ?></a>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action('admin_notices', 'wpcf7dtx_access_keys_notice');
|
||||
|
||||
/**
|
||||
* Set Scan Status
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param string $status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_set_update_access_scan_check_status($status)
|
||||
{
|
||||
update_option('cf7dtx_v4_2_0_access_scan_check_status', $status);
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@ function wpcf7dtx_get_custom_field($atts = array())
|
||||
), array_change_key_case((array)$atts, CASE_LOWER)));
|
||||
|
||||
// If this key can't be accessed
|
||||
if( !wpcf7dtx_post_meta_key_access_is_allowed( $key ) ){
|
||||
if (!wpcf7dtx_post_meta_key_access_is_allowed($key)) {
|
||||
// Trigger a warning if a denied key is in use
|
||||
wpcf7dtx_access_denied_alert( $key, 'post_meta' );
|
||||
wpcf7dtx_access_denied_alert($key, 'post_meta');
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -353,9 +353,9 @@ function wpcf7dtx_get_current_user($atts = array())
|
||||
if (is_user_logged_in()) {
|
||||
|
||||
// If this key can't be accessed
|
||||
if( !wpcf7dtx_user_data_access_is_allowed( $key ) ){
|
||||
if (!wpcf7dtx_user_data_access_is_allowed($key)) {
|
||||
// Trigger a warning if a denied key is in use
|
||||
wpcf7dtx_access_denied_alert( $key, 'user_data' );
|
||||
wpcf7dtx_access_denied_alert($key, 'user_data');
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
@@ -226,6 +226,12 @@ function wpcf7dtx_get_dynamic($value, $tag = false, $sanitize = 'auto')
|
||||
/**
|
||||
* Get Allowed HTML for Form Field Properties
|
||||
*
|
||||
* @see https://www.w3schools.com/tags/tag_input.asp
|
||||
* @see https://www.w3schools.com/tags/tag_optgroup.asp
|
||||
* @see https://www.w3schools.com/tags/tag_option.asp
|
||||
* @see https://www.w3schools.com/tags/tag_select.asp
|
||||
* @see https://www.w3schools.com/tags/tag_textarea.asp
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param string $type Optional. The type of input for unique properties. Default is `text`.
|
||||
@@ -256,52 +262,61 @@ function wpcf7dtx_get_allowed_field_properties($type = 'text', $extra = 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 ($type != 'hidden') {
|
||||
$allowed_properties['autofocus'] = array();
|
||||
$allowed_properties['readonly'] = array();
|
||||
$allowed_properties['required'] = 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['size'] = array();
|
||||
$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();
|
||||
unset($allowed_properties['type'], $allowed_properties['value']); // Remove invalid select attributes
|
||||
} else {
|
||||
// Properties exclusive to text-based inputs
|
||||
$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();
|
||||
$allowed_properties['list'] = array();
|
||||
|
||||
// Placeholder
|
||||
if (in_array($type, array('text', 'search', 'url', 'tel', 'email', 'password', 'number'))) {
|
||||
$allowed_properties['placeholder'] = array();
|
||||
}
|
||||
|
||||
// Textarea
|
||||
if ($type == 'textarea') {
|
||||
// Additional properties exclusive to textarea fields
|
||||
$allowed_properties['cols'] = array();
|
||||
$allowed_properties['rows'] = array();
|
||||
$allowed_properties['minlength'] = array();
|
||||
$allowed_properties['maxlength'] = array();
|
||||
$allowed_properties['wrap'] = 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
|
||||
} elseif (in_array($type, array('text', 'search', 'url', 'tel', 'email', 'password'))) {
|
||||
// Additional properties exclusive to these text-based fields
|
||||
$allowed_properties['size'] = array();
|
||||
$allowed_properties['minlength'] = array();
|
||||
$allowed_properties['maxlength'] = array();
|
||||
$allowed_properties['pattern'] = array();
|
||||
} elseif (in_array($type, array('number', 'range', 'date', 'datetime-local', 'time'))) {
|
||||
// Number and date inputs
|
||||
$allowed_properties['min'] = array();
|
||||
$allowed_properties['max'] = array();
|
||||
$allowed_properties['step'] = array();
|
||||
}
|
||||
}
|
||||
if (is_array($extra) && count($extra)) {
|
||||
@@ -554,8 +569,10 @@ function wpcf7dtx_textarea_html($atts)
|
||||
* 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.
|
||||
* @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
|
||||
*/
|
||||
@@ -644,9 +661,11 @@ function wpcf7dtx_select_html($atts, $options, $hide_blank = false, $disable_bla
|
||||
*
|
||||
* @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.
|
||||
* @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.
|
||||
* @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 = '')
|
||||
{
|
||||
@@ -665,163 +684,163 @@ function wpcf7dtx_array_has_key($key, $array = array(), $default = '')
|
||||
|
||||
/**
|
||||
* Check if admin has allowed access to a specific post meta key
|
||||
*
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
*
|
||||
* @param string $meta_key The post meta key to test
|
||||
*
|
||||
*
|
||||
* @return bool True if this key can be accessed, false otherwise
|
||||
*/
|
||||
function wpcf7dtx_post_meta_key_access_is_allowed($meta_key)
|
||||
{
|
||||
|
||||
// Get the DTX Settings
|
||||
$settings = wpcf7dtx_get_settings();get_option('cf7dtx_settings', []);
|
||||
$settings = wpcf7dtx_get_settings();
|
||||
|
||||
// Has access to all metadata been enabled?
|
||||
if( isset($settings['post_meta_allow_all']) && $settings['post_meta_allow_all'] === 'enabled' ){
|
||||
if (isset($settings['post_meta_allow_all']) && $settings['post_meta_allow_all'] === 'enabled') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If not, check the Allow List
|
||||
|
||||
$allowed_keys;
|
||||
$allowed_keys = array();
|
||||
|
||||
// No key list from settings
|
||||
if( !isset($settings['post_meta_allow_keys'] ) || !is_string($settings['post_meta_allow_keys'])){
|
||||
$allowed_keys = [];
|
||||
}
|
||||
// Extract allowed keys from setting text area
|
||||
else{
|
||||
// $allowed_keys = preg_split('/\r\n|\r|\n/', $settings['post_meta_allow_keys']);
|
||||
$allowed_keys = wpcf7dtx_parse_allowed_keys( $settings['post_meta_allow_keys'] );
|
||||
if (isset($settings['post_meta_allow_keys']) && is_string($settings['post_meta_allow_keys'])) {
|
||||
// Extract allowed keys from setting text area
|
||||
$allowed_keys = wpcf7dtx_parse_allowed_keys($settings['post_meta_allow_keys']);
|
||||
}
|
||||
|
||||
// Allow custom filters
|
||||
$allowed_keys = apply_filters( 'wpcf7dtx_post_meta_key_allow_list', $allowed_keys );
|
||||
$allowed_keys = apply_filters('wpcf7dtx_post_meta_key_allow_list', $allowed_keys);
|
||||
|
||||
// Check if the key is in the allow list
|
||||
if( in_array( $meta_key, $allowed_keys ) ){
|
||||
if (in_array($meta_key, $allowed_keys)) {
|
||||
return true; // The key is allowed
|
||||
}
|
||||
|
||||
// Everything is disallowed by default
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if admin has allowed access to a specific user data
|
||||
*
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
*
|
||||
* @param string $key The user data key to test
|
||||
*
|
||||
*
|
||||
* @return bool True if this key can be accessed, false otherwise
|
||||
*/
|
||||
function wpcf7dtx_user_data_access_is_allowed( $key )
|
||||
function wpcf7dtx_user_data_access_is_allowed($key)
|
||||
{
|
||||
|
||||
// Get the DTX Settings
|
||||
$settings = wpcf7dtx_get_settings(); //get_option('cf7dtx_settings', []);
|
||||
|
||||
// Has access to all metadata been enabled?
|
||||
if( isset($settings['user_data_allow_all']) && $settings['user_data_allow_all'] === 'enabled' ){
|
||||
if (isset($settings['user_data_allow_all']) && $settings['user_data_allow_all'] === 'enabled') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If not, check the Allow List
|
||||
|
||||
$allowed_keys;
|
||||
$allowed_keys = array();
|
||||
|
||||
// No key list from settings
|
||||
if( !isset($settings['user_data_allow_keys'] ) || !is_string($settings['user_data_allow_keys'])){
|
||||
$allowed_keys = [];
|
||||
}
|
||||
// Extract allowed keys from setting text area
|
||||
else{
|
||||
// $allowed_keys = preg_split('/\r\n|\r|\n/', $settings['user_data_allow_keys']);
|
||||
if (isset($settings['user_data_allow_keys']) && is_string($settings['user_data_allow_keys'])) {
|
||||
// Extract allowed keys from setting text area
|
||||
$allowed_keys = wpcf7dtx_parse_allowed_keys($settings['user_data_allow_keys']);
|
||||
}
|
||||
|
||||
// Allow custom filters
|
||||
$allowed_keys = apply_filters( 'wpcf7dtx_user_data_key_allow_list', $allowed_keys );
|
||||
$allowed_keys = apply_filters('wpcf7dtx_user_data_key_allow_list', $allowed_keys);
|
||||
|
||||
// Check if the key is in the allow list
|
||||
if( in_array( $key, $allowed_keys ) ){
|
||||
if (in_array($key, $allowed_keys)) {
|
||||
return true; // The key is allowed
|
||||
}
|
||||
|
||||
|
||||
// Everything is disallowed by default
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Take the string saved in the options array from the allow list textarea and parse it into an array by newlines.
|
||||
* Also strip whitespace
|
||||
*
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param string $allowlist The string of allowed keys stored in the DB
|
||||
*
|
||||
*
|
||||
* @return array Array of allowed keys
|
||||
*/
|
||||
function wpcf7dtx_parse_allowed_keys( $allowlist ){
|
||||
function wpcf7dtx_parse_allowed_keys($allowlist)
|
||||
{
|
||||
// Split by newlines
|
||||
$keys = wpcf7dtx_split_newlines( $allowlist );
|
||||
$keys = wpcf7dtx_split_newlines($allowlist);
|
||||
// Trim whitespace
|
||||
$keys = array_map( 'trim' , $keys );
|
||||
$keys = array_map('trim', $keys);
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Used to parse strings stored in the database that are from text areas with one element per line into an array of strings
|
||||
*
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param string $str The multi-line string to be parsed into an array
|
||||
*
|
||||
*
|
||||
* @return array Array of parsed strings
|
||||
*/
|
||||
function wpcf7dtx_split_newlines( $str ){
|
||||
function wpcf7dtx_split_newlines($str)
|
||||
{
|
||||
return preg_split('/\r\n|\r|\n/', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CF7 DTX settings field from the WP options table. Returns an empty array if option has not previously been set
|
||||
*
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @return array The settings array
|
||||
*/
|
||||
function wpcf7dtx_get_settings(){
|
||||
return get_option('cf7dtx_settings', []);
|
||||
function wpcf7dtx_get_settings()
|
||||
{
|
||||
return get_option('cf7dtx_settings', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the CF7 DTX settings in the WP options table
|
||||
*
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param array $settings The settings array
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
function wpcf7dtx_update_settings($settings){
|
||||
update_option( 'cf7dtx_settings', $settings );
|
||||
function wpcf7dtx_update_settings($settings)
|
||||
{
|
||||
update_option('cf7dtx_settings', $settings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Outputs a useful PHP Warning message to users on how to allow-list denied meta and user keys
|
||||
*
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param string $key The post meta or user key to which access is currently denied
|
||||
* @param string $type Either 'post_meta' or 'user_data', used to display an appropriate message to the user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_access_denied_alert( $key, $type ){
|
||||
|
||||
function wpcf7dtx_access_denied_alert($key, $type)
|
||||
{
|
||||
// Only check on the front end
|
||||
if( is_admin() || wp_doing_ajax() || wp_is_json_request() ) return;
|
||||
if (is_admin() || wp_doing_ajax() || wp_is_json_request()) return;
|
||||
|
||||
$shortcode = '';
|
||||
$list_name = '';
|
||||
|
||||
switch( $type ){
|
||||
switch ($type) {
|
||||
case 'post_meta':
|
||||
$shortcode = 'CF7_get_custom_field';
|
||||
$list_name = __('Meta Key Allow List', 'contact-form-7-dynamic-text-extension');
|
||||
@@ -830,47 +849,21 @@ function wpcf7dtx_access_denied_alert( $key, $type ){
|
||||
$shortcode = 'CF7_get_current_user';
|
||||
$list_name = __('User Data Key Allow List', 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
$shortcode = '';
|
||||
$list_name = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$settings_page_url = admin_url('admin.php?page=cf7dtx_settings');
|
||||
|
||||
$msg = sprintf(
|
||||
__('CF7 DTX: Access denied to key: "%1$s" in dynamic contact form shortcode: [%2$s]. Please add this key to the %3$s at %4$s','contact-form-7-dynamic-text-extension'),
|
||||
__('CF7 DTX: Access denied to key: "%1$s" in dynamic contact form shortcode: [%2$s]. Please add this key to the %3$s at %4$s', 'contact-form-7-dynamic-text-extension'),
|
||||
$key,
|
||||
$shortcode,
|
||||
$list_name,
|
||||
$settings_page_url
|
||||
);
|
||||
|
||||
trigger_error( $msg, E_USER_WARNING );
|
||||
trigger_error($msg, E_USER_WARNING);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to output array and object data
|
||||
*/
|
||||
/*
|
||||
function dtxpretty ($var, $print=true, $privobj=false) {
|
||||
|
||||
$type = gettype($var);
|
||||
|
||||
if( $privobj && $type === 'object' ){
|
||||
$p = '<pre>'.print_r($var, true).'</pre>';
|
||||
}
|
||||
else {
|
||||
$p = '<pre>'.$type . ' ' . json_encode(
|
||||
$var,
|
||||
JSON_UNESCAPED_SLASHES |
|
||||
JSON_UNESCAPED_UNICODE |
|
||||
JSON_PRETTY_PRINT |
|
||||
JSON_PARTIAL_OUTPUT_ON_ERROR |
|
||||
JSON_INVALID_UTF8_SUBSTITUTE
|
||||
).'</pre>';
|
||||
}
|
||||
if( $print ) {
|
||||
echo $p;
|
||||
}
|
||||
return $p;
|
||||
}
|
||||
*/
|
||||
@@ -1,369 +1,373 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
* Add DTX Error Code to Config Validator
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $error_codes A sequential array of available error codes in Contact Form 7.
|
||||
*
|
||||
* @return array A modified sequential array of available error codes in Contact Form 7.
|
||||
*/
|
||||
function wpcf7dtx_config_validator_available_error_codes($error_codes)
|
||||
{
|
||||
$dtx_errors = array('dtx_disallowed');
|
||||
return array_merge($error_codes, $dtx_errors);
|
||||
}
|
||||
add_filter('wpcf7_config_validator_available_error_codes', 'wpcf7dtx_config_validator_available_error_codes');
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// Check for sensitive form tags
|
||||
$manager = WPCF7_FormTagsManager::get_instance();
|
||||
$contact_form = $validator->contact_form();
|
||||
$form = $contact_form->prop('form');
|
||||
if (wpcf7_autop_or_not()) {
|
||||
$form = $manager->replace_with_placeholders($form);
|
||||
$form = wpcf7_autop($form);
|
||||
$form = $manager->restore_from_placeholders($form);
|
||||
}
|
||||
$form = $manager->replace_all($form);
|
||||
$tags = $manager->get_scanned_tags();
|
||||
foreach ($tags as $tag) {
|
||||
/** @var WPCF7_FormTag $tag */
|
||||
|
||||
// Only validate DTX formtags
|
||||
if (in_array($tag->basetype, array_merge(
|
||||
array('dynamictext', 'dynamichidden'), // Deprecated DTX form tags
|
||||
array_keys(wpcf7dtx_config()) // DTX form tags
|
||||
))) {
|
||||
// Check value for sensitive data
|
||||
$default = $tag->get_option('defaultvalue', '', true);
|
||||
if (!$default) {
|
||||
$default = $tag->get_default_option(strval(reset($tag->values)));
|
||||
}
|
||||
if (
|
||||
!empty($value = trim(wpcf7_get_hangover($tag->name, $default))) && // Has value
|
||||
($result = wpcf7dtx_validate_sensitive_value($value))['status'] // Has sensitive data
|
||||
) {
|
||||
$validator->add_error('form.body', 'dtx_disallowed', array(
|
||||
'message' => sprintf(
|
||||
__('[%1$s %2$s]: Access to key "%3$s" in shortcode "%4$s" is disallowed by default. To allow access, add "%3$s" to the %5$s Allow List.', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html($tag->basetype),
|
||||
esc_html($tag->name),
|
||||
esc_html($result['key']),
|
||||
esc_html($result['shortcode']),
|
||||
esc_html($result['shortcode'] == 'CF7_get_current_user' ? __('User Data Key', 'contact-form-7-dynamic-text-extension') : __('Meta Key', 'contact-form-7-dynamic-text-extension'))
|
||||
),
|
||||
'link' => wpcf7dtx_get_admin_settings_screen_url()
|
||||
));
|
||||
}
|
||||
|
||||
// Check placeholder for sensitive data
|
||||
if (
|
||||
($tag->has_option('placeholder') || $tag->has_option('watermark')) && // Using placeholder
|
||||
!empty($placeholder = trim(html_entity_decode(urldecode($tag->get_option('placeholder', '', true)), ENT_QUOTES))) && // Has value
|
||||
($result = wpcf7dtx_validate_sensitive_value($placeholder))['status'] // Has sensitive data
|
||||
) {
|
||||
$validator->add_error('form.body', 'dtx_disallowed', array(
|
||||
'message' => sprintf(
|
||||
__('[%1$s %2$s]: Access to key "%3$s" in shortcode "%4$s" is disallowed by default. To allow access, add "%3$s" to the %5$s Allow List.', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html($tag->basetype),
|
||||
esc_html($tag->name),
|
||||
esc_html($result['key']),
|
||||
esc_html($result['shortcode']),
|
||||
esc_html($result['shortcode'] == 'CF7_get_current_user' ? __('User Data Key', 'contact-form-7-dynamic-text-extension') : __('Meta Key', 'contact-form-7-dynamic-text-extension'))
|
||||
),
|
||||
'link' => wpcf7dtx_get_admin_settings_screen_url()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate email address
|
||||
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');
|
||||
|
||||
/**
|
||||
* Validate Field Value for Sensitive Data
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @see https://developer.wordpress.org/reference/functions/get_bloginfo/#description
|
||||
*
|
||||
* @param string $content The string to validate.
|
||||
*
|
||||
* @return array An associative array with keys `status` (bool), `shortcode` (string), and `key` (string).
|
||||
* The value of `status` is true if the content is a shortcode that is attempting to access sensitive data. False
|
||||
* otherwise. The value of `shortcode` is the the shortcode that is making the attempt if `status` is true. The
|
||||
* value of `key` is the shortcode's `key` attribute of the attempt being made if `status` is true.
|
||||
*/
|
||||
function wpcf7dtx_validate_sensitive_value($content)
|
||||
{
|
||||
$r = array(
|
||||
'status' => false,
|
||||
'shortcode' => '',
|
||||
'key' => ''
|
||||
);
|
||||
|
||||
// Parse the attributes. [0] is the shortcode name. ['key'] is the key attribute
|
||||
$atts = shortcode_parse_atts($content);
|
||||
|
||||
// If we can't extract the atts, or the shortcode or `key` is not an att, don't validate
|
||||
if( !is_array($atts) || !array_key_exists('key', $atts) || !array_key_exists('0', $atts) ) return $r;
|
||||
|
||||
// Find the key and shortcode in question
|
||||
$key = sanitize_text_field($atts['key']);
|
||||
$shortcode = sanitize_text_field($atts['0']);
|
||||
|
||||
// If the shortcode or key value does not exist, don't validate
|
||||
if( empty($shortcode) || empty($key) ) return $r;
|
||||
|
||||
$allowed = true;
|
||||
switch( $shortcode ){
|
||||
case 'CF7_get_custom_field':
|
||||
$allowed = wpcf7dtx_post_meta_key_access_is_allowed( $key );
|
||||
break;
|
||||
case 'CF7_get_current_user':
|
||||
$allowed = wpcf7dtx_user_data_access_is_allowed( $key );
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
if( !$allowed ){
|
||||
$r['status'] = true;
|
||||
$r['shortcode'] = $shortcode;
|
||||
$r['key'] = $key;
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
<?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');
|
||||
|
||||
/**
|
||||
* Add DTX Error Code to Config Validator
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $error_codes A sequential array of available error codes in Contact Form 7.
|
||||
*
|
||||
* @return array A modified sequential array of available error codes in Contact Form 7.
|
||||
*/
|
||||
function wpcf7dtx_config_validator_available_error_codes($error_codes)
|
||||
{
|
||||
$dtx_errors = array('dtx_disallowed');
|
||||
return array_merge($error_codes, $dtx_errors);
|
||||
}
|
||||
add_filter('wpcf7_config_validator_available_error_codes', 'wpcf7dtx_config_validator_available_error_codes');
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validator Requires Contact Form 7 Minimum Version
|
||||
*/
|
||||
if (wpcf7dtx_dependencies()) {
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// Check for sensitive form tags
|
||||
$manager = WPCF7_FormTagsManager::get_instance();
|
||||
$contact_form = $validator->contact_form();
|
||||
$form = $contact_form->prop('form');
|
||||
if (wpcf7_autop_or_not()) {
|
||||
$form = $manager->replace_with_placeholders($form);
|
||||
$form = wpcf7_autop($form);
|
||||
$form = $manager->restore_from_placeholders($form);
|
||||
}
|
||||
$form = $manager->replace_all($form);
|
||||
$tags = $manager->get_scanned_tags();
|
||||
foreach ($tags as $tag) {
|
||||
/** @var WPCF7_FormTag $tag */
|
||||
|
||||
// Only validate DTX formtags
|
||||
if (in_array($tag->basetype, array_merge(
|
||||
array('dynamictext', 'dynamichidden'), // Deprecated DTX form tags
|
||||
array_keys(wpcf7dtx_config()) // DTX form tags
|
||||
))) {
|
||||
// Check value for sensitive data
|
||||
$default = $tag->get_option('defaultvalue', '', true);
|
||||
if (!$default) {
|
||||
$default = $tag->get_default_option(strval(reset($tag->values)));
|
||||
}
|
||||
if (
|
||||
!empty($value = trim(wpcf7_get_hangover($tag->name, $default))) && // Has value
|
||||
($result = wpcf7dtx_validate_sensitive_value($value))['status'] // Has sensitive data
|
||||
) {
|
||||
$validator->add_error('form.body', 'dtx_disallowed', array(
|
||||
'message' => sprintf(
|
||||
__('[%1$s %2$s]: Access to key "%3$s" in shortcode "%4$s" is disallowed by default. To allow access, add "%3$s" to the %5$s Allow List.', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html($tag->basetype),
|
||||
esc_html($tag->name),
|
||||
esc_html($result['key']),
|
||||
esc_html($result['shortcode']),
|
||||
esc_html($result['shortcode'] == 'CF7_get_current_user' ? __('User Data Key', 'contact-form-7-dynamic-text-extension') : __('Meta Key', 'contact-form-7-dynamic-text-extension'))
|
||||
),
|
||||
'link' => wpcf7dtx_get_admin_settings_screen_url()
|
||||
));
|
||||
}
|
||||
|
||||
// Check placeholder for sensitive data
|
||||
if (
|
||||
($tag->has_option('placeholder') || $tag->has_option('watermark')) && // Using placeholder
|
||||
!empty($placeholder = trim(html_entity_decode(urldecode($tag->get_option('placeholder', '', true)), ENT_QUOTES))) && // Has value
|
||||
($result = wpcf7dtx_validate_sensitive_value($placeholder))['status'] // Has sensitive data
|
||||
) {
|
||||
$validator->add_error('form.body', 'dtx_disallowed', array(
|
||||
'message' => sprintf(
|
||||
__('[%1$s %2$s]: Access to key "%3$s" in shortcode "%4$s" is disallowed by default. To allow access, add "%3$s" to the %5$s Allow List.', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html($tag->basetype),
|
||||
esc_html($tag->name),
|
||||
esc_html($result['key']),
|
||||
esc_html($result['shortcode']),
|
||||
esc_html($result['shortcode'] == 'CF7_get_current_user' ? __('User Data Key', 'contact-form-7-dynamic-text-extension') : __('Meta Key', 'contact-form-7-dynamic-text-extension'))
|
||||
),
|
||||
'link' => wpcf7dtx_get_admin_settings_screen_url()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate email address
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate Field Value for Sensitive Data
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @see https://developer.wordpress.org/reference/functions/get_bloginfo/#description
|
||||
*
|
||||
* @param string $content The string to validate.
|
||||
*
|
||||
* @return array An associative array with keys `status` (bool), `shortcode` (string), and `key` (string).
|
||||
* The value of `status` is true if the content is a shortcode that is attempting to access sensitive data. False
|
||||
* otherwise. The value of `shortcode` is the the shortcode that is making the attempt if `status` is true. The
|
||||
* value of `key` is the shortcode's `key` attribute of the attempt being made if `status` is true.
|
||||
*/
|
||||
function wpcf7dtx_validate_sensitive_value($content)
|
||||
{
|
||||
$r = array(
|
||||
'status' => false,
|
||||
'shortcode' => '',
|
||||
'key' => ''
|
||||
);
|
||||
|
||||
// Parse the attributes. [0] is the shortcode name. ['key'] is the key attribute
|
||||
$atts = shortcode_parse_atts($content);
|
||||
|
||||
// If we can't extract the atts, or the shortcode or `key` is not an att, don't validate
|
||||
if (!is_array($atts) || !array_key_exists('key', $atts) || !array_key_exists('0', $atts)) return $r;
|
||||
|
||||
// Find the key and shortcode in question
|
||||
$key = sanitize_text_field($atts['key']);
|
||||
$shortcode = sanitize_text_field($atts['0']);
|
||||
|
||||
// If the shortcode or key value does not exist, don't validate
|
||||
if (empty($shortcode) || empty($key)) return $r;
|
||||
|
||||
$allowed = true;
|
||||
switch ($shortcode) {
|
||||
case 'CF7_get_custom_field':
|
||||
$allowed = wpcf7dtx_post_meta_key_access_is_allowed($key);
|
||||
break;
|
||||
case 'CF7_get_current_user':
|
||||
$allowed = wpcf7dtx_user_data_access_is_allowed($key);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
if (!$allowed) {
|
||||
$r['status'] = true;
|
||||
$r['shortcode'] = $shortcode;
|
||||
$r['key'] = $key;
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ Contributors: sevenspark, tessawatkinsllc
|
||||
Donate link: https://just1voice.com/donate/
|
||||
Tags: Contact Form 7, autofill, prepopulate, input, form field, contact form, text, hidden, input, dynamic, GET, POST, title, slug, auto-fill, pre-populate
|
||||
Tested up to: 6.4.2
|
||||
Stable tag: 4.2.0
|
||||
Stable tag: 4.2.3
|
||||
|
||||
This plugin provides additional form tags for the Contact Form 7 plugin. It allows dynamic generation of content for text-based input fields like text, hidden, and email, checkboxes, radio buttons, and drop-down selections using any shortcode.
|
||||
|
||||
@@ -380,16 +380,35 @@ Please check out the [FAQ on our website](https://aurisecreative.com/docs/contac
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 4.2.0 =
|
||||
Extend functionality without losing your work!
|
||||
= 4.2.3 =
|
||||
Resolved a bug where the `dynamic_select` displayed with a default size of 40 instead of 1.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 4.2.3 =
|
||||
|
||||
* Fix: Resolved a bug where the `dynamic_select` displayed with a default size of 40 instead of 1.
|
||||
|
||||
= 4.2.2 =
|
||||
|
||||
* Feature: Cache compatibility JavaScript triggers the custom `dtx_init` event on enabled input fields, [see support thread](https://wordpress.org/support/topic/dynamic_text-cf7_url-dont-fire-onchange-event/).
|
||||
|
||||
= 4.2.1 =
|
||||
|
||||
* Feature: Allows text-based fields to use `autocapitalize` attribute
|
||||
* Feature: Allows text-based fields to use `autofocus` attribute
|
||||
* Feature: Allows text-based fields to use `list` attribute
|
||||
* Feature: Allows text-based fields to use `pattern` attribute
|
||||
* Feature: Allows textareas to use `wrap` attribute
|
||||
* Fix: Resolved the bug that prevented the `dynamic_date` shortcode from using `min`, `max`, and `step` attributes, [see support thread](https://wordpress.org/support/topic/dynamic_date-min-max-step-options-ignored/).
|
||||
* Fix: Added minimum version check for Contact Form 7, [see support thread](https://wordpress.org/support/topic/str_contains-is-php-8-0-only-broken-compatibility/).
|
||||
* Fix: Resolved an issue that used a function introduced in PHP 8 while plugin compatibility setting is currently still set to 7.4+, [see support thread](https://wordpress.org/support/topic/str_contains-is-php-8-0-only-broken-compatibility/).
|
||||
|
||||
= 4.2.0 =
|
||||
|
||||
* Security Update: ** Please be sure to review this doc, as you may need to adjust the settings: https://sevenspark.com/docs/contact-form-7-dynamic-text-extension/allow-data-access **
|
||||
* Feature: Added Settings Screen with Allow Lists
|
||||
* Feature: Added Form Scanner
|
||||
* Feature: Added Form Scanner
|
||||
* Feature: Added Allow List key validation in CF7 Form Validator
|
||||
|
||||
= 4.1.0 =
|
||||
|
||||
Reference in New Issue
Block a user