rebase code on oct-10-2023
This commit is contained in:
@@ -147,6 +147,7 @@ data:
|
||||
}
|
||||
|
||||
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
|
||||
expires 7d;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
fastcgi_cache MYAPP;
|
||||
fastcgi_cache_valid 200 302 60m;
|
||||
|
||||
@@ -266,6 +266,7 @@ data:
|
||||
}
|
||||
|
||||
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
|
||||
expires 7d;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
fastcgi_cache MYAPP;
|
||||
fastcgi_cache_valid 200 302 60m;
|
||||
|
||||
@@ -266,6 +266,7 @@ data:
|
||||
}
|
||||
|
||||
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
|
||||
expires 7d;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
fastcgi_cache MYAPP;
|
||||
fastcgi_cache_valid 200 302 60m;
|
||||
|
||||
@@ -266,6 +266,7 @@ data:
|
||||
}
|
||||
|
||||
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
|
||||
expires 7d;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
fastcgi_cache MYAPP;
|
||||
fastcgi_cache_valid 200 302 60m;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Override the defaults specified here in a site-specific `pantheon.yml` file.
|
||||
# For more information see: https://pantheon.io/docs/pantheon-upstream-yml
|
||||
api_version: 1
|
||||
php_version: 8.1
|
||||
php_version: 7.4
|
||||
|
||||
# See https://pantheon.io/docs/pantheon-yml#specify-a-version-of-mariadb
|
||||
database:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
api_version: 1
|
||||
enforce_https: full+subdomains
|
||||
php_version: 7.4
|
||||
|
||||
protected_web_paths:
|
||||
- /.user.ini
|
||||
|
||||
@@ -43,37 +43,6 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
<a href="contribute.php" class="nav-tab"><?php _e( 'Get Involved' ); ?></a>
|
||||
</nav>
|
||||
|
||||
<div class="about__section changelog has-subtle-background-color">
|
||||
<div class="column">
|
||||
<h2><?php _e( 'Maintenance Release' ); ?></h2>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: WordPress version number, 2: Plural number of bugs. */
|
||||
_n(
|
||||
'<strong>Version %1$s</strong> addressed %2$s bug.',
|
||||
'<strong>Version %1$s</strong> addressed %2$s bugs.',
|
||||
10
|
||||
),
|
||||
'6.3.1',
|
||||
'10'
|
||||
);
|
||||
?>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: HelpHub URL. */
|
||||
__( 'For more information, see <a href="%s">the release notes</a>.' ),
|
||||
sprintf(
|
||||
/* translators: %s: WordPress version. */
|
||||
esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
|
||||
sanitize_title( '6.3.1' )
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="about__section aligncenter">
|
||||
<div class="column">
|
||||
<h2>
|
||||
|
||||
@@ -1943,6 +1943,10 @@ class WP_Site_Health {
|
||||
public function get_test_available_updates_disk_space() {
|
||||
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;
|
||||
|
||||
$available_space = false !== $available_space
|
||||
? (int) $available_space
|
||||
: 0;
|
||||
|
||||
$result = array(
|
||||
'label' => __( 'Disk space available to safely perform updates' ),
|
||||
'status' => 'good',
|
||||
@@ -1959,14 +1963,18 @@ class WP_Site_Health {
|
||||
'test' => 'available_updates_disk_space',
|
||||
);
|
||||
|
||||
if ( false === $available_space ) {
|
||||
$result['description'] = __( 'Could not determine available disk space for updates.' );
|
||||
if ( $available_space < 100 * MB_IN_BYTES ) {
|
||||
$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
|
||||
$result['status'] = 'recommended';
|
||||
} elseif ( $available_space < 20 * MB_IN_BYTES ) {
|
||||
}
|
||||
|
||||
if ( $available_space < 20 * MB_IN_BYTES ) {
|
||||
$result['description'] = __( 'Available disk space is critically low, less than 20 MB available. Proceed with caution, updates may fail.' );
|
||||
$result['status'] = 'critical';
|
||||
} elseif ( $available_space < 100 * MB_IN_BYTES ) {
|
||||
$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
|
||||
}
|
||||
|
||||
if ( ! $available_space ) {
|
||||
$result['description'] = __( 'Could not determine available disk space for updates.' );
|
||||
$result['status'] = 'recommended';
|
||||
}
|
||||
|
||||
|
||||
@@ -1431,13 +1431,9 @@ function update_core( $from, $to ) {
|
||||
} else {
|
||||
$lang_dir = WP_CONTENT_DIR . '/languages';
|
||||
}
|
||||
/*
|
||||
* Note: str_starts_with() is not used here, as this file is included
|
||||
* when updating from older WordPress versions, in which case
|
||||
* the polyfills from wp-includes/compat.php may not be available.
|
||||
*/
|
||||
|
||||
// Check if the language directory exists first.
|
||||
if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
|
||||
if ( ! @is_dir( $lang_dir ) && str_starts_with( $lang_dir, ABSPATH ) ) {
|
||||
// If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
|
||||
$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR );
|
||||
clearstatcache(); // For FTP, need to clear the stat cache.
|
||||
|
||||
@@ -55,7 +55,7 @@ var $ = jQuery.noConflict(),
|
||||
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') });
|
||||
dtx.queue.push(raw_value);
|
||||
}
|
||||
return; // Don't continue after queuing it for AJAX
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
/*! Do not edit, this file is generated automatically - 2023-09-18 14:09:50 EDT */
|
||||
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 - 2023-08-07 16:08:32 EDT */
|
||||
var $=jQuery.noConflict(),dtx={queue:[],init:function(){var $inputs=$("input.dtx-pageload[data-dtx-value]");$inputs.length&&($inputs.each(function(i,el){var el=$(el),raw_value=el.attr("data-dtx-value"),v=decodeURIComponent(raw_value).split(" ");if(v.length){var tag=v[0],atts={};if(1<v.length)for(var x=1;x<v.length;x++){var att=v[x].split("=");2===att.length&&(atts[att[0]]=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")||"url"!=atts.key)return;value=dtx.current_url(atts);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(tag&&dtx.queue.push(raw_value))}dtx.set(el,value)}}),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(xhr,status,error){console.error("[CF7 DTX AJAX ERROR]",error,status,xhr)},success:function(data,status,xhr){"object"==typeof data&&data.length&&$.each(data,function(i,obj){var $inputs=$('.wpcf7 form input.dtx-pageload[data-dtx-value="'+obj.raw_value+'"]');$inputs.length&&(dtx.set($inputs,obj.value),$inputs.addClass("dtx-ajax-loaded"))})}})},10)},validKey:function(obj,key){return obj.hasOwnProperty(key)&&"string"==typeof obj[key]&&obj[key].trim()},obfuscate:function(value,atts){if(value=value.trim(),dtx.validKey(atts,"obfuscate")&&atts.obfuscate){for(var o="",i=0;i<value.length;i++)o+="&#"+value.codePointAt(i)+";";return o}return value},set:function($input,value){$input.attr("value",value).addClass("dtx-loaded")},get:function(atts){if(dtx.validKey(atts,"key")){var query=window.location.search;if(query)return query=new URLSearchParams(query),dtx.obfuscate(query.get(atts.key).trim(),atts)}return""},referrer:function(atts){return dtx.obfuscate(document.referrer,atts)},current_url:function(atts){if(!atts.hasOwnProperty("part"))return dtx.obfuscate(window.location.href,atts);if(["scheme","host","port","path","query","fragment"].includes(atts.part))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)}return""},get_cookie:function(atts){var keyValue;return atts.hasOwnProperty("key")&&"string"==typeof atts.key&&""!=atts.key.trim()&&(keyValue=document.cookie.match("(^|;) ?"+atts.key.trim()+"=([^;]*)(;|$)"))?dtx.obfuscate(keyValue[2],atts):""},guid:function(){if(void 0!==window.crypto&&void 0!==window.crypto.getRandomValues)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(),d2="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var r=16*Math.random();return 0<d?(r=(d+r)%16|0,d=Math.floor(d/16)):(r=(d2+r)%16|0,d2=Math.floor(d2/16)),("x"===c?r:3&r|8).toString(16).toUpperCase()}).toUpperCase()}};$(document).ready(dtx.init);
|
||||
+1
-9
@@ -26,14 +26,6 @@
|
||||
};
|
||||
|
||||
$(function() {
|
||||
$('form.tag-generator-panel .dtx-option').on('change keyup click', wpcf7dtx.taggen.updateOption);
|
||||
$('.contact-form-editor-panel #tag-generator-list a.thickbox.button[href*="inlineId=tag-generator-panel-dynamic_"]').each(function() {
|
||||
var $btn = $(this),
|
||||
name = $btn.text();
|
||||
$btn.addClass('dtx-form-tag');
|
||||
if (name == 'dynamic drop-down menu' || name == 'dynamic checkboxes' || name == 'dynamic radio buttons') {
|
||||
$btn.attr('href', $btn.attr('href').replace('height=500', 'height=750'));
|
||||
}
|
||||
});
|
||||
$('form.tag-generator-panel input.dtx-option').on('change keyup', wpcf7dtx.taggen.updateOption);
|
||||
});
|
||||
})(jQuery);
|
||||
Vendored
+2
-2
@@ -1,2 +1,2 @@
|
||||
/*! Do not edit, this file is generated automatically - 2023-09-18 14:09:50 EDT */
|
||||
!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);
|
||||
/*! Do not edit, this file is generated automatically - 2023-08-07 16:08:32 EDT */
|
||||
!function($){"use strict";"undefined"!=typeof wpcf7&&null!==wpcf7&&(window.wpcf7dtx=window.wpcf7dtx||{},wpcf7dtx.taggen={},wpcf7dtx.taggen.escapeRegExp=function(str){return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")},wpcf7dtx.taggen.replaceAll=function(input,f,r,no_escape){var rexp;return null!=input&&"string"==typeof input&&""!==input.trim()&&-1<input.indexOf(f)?(rexp=new RegExp(wpcf7dtx.taggen.escapeRegExp(f),"g"),no_escape&&(rexp=new RegExp(f,"g")),input.replace(rexp,r)):input},wpcf7dtx.taggen.updateOption=function(e){var e=$(e.currentTarget),value=encodeURIComponent(wpcf7dtx.taggen.replaceAll(e.val(),"'","'"));e.siblings('input[type="hidden"].option').val(value)},$(function(){$("form.tag-generator-panel input.dtx-option").on("change keyup",wpcf7dtx.taggen.updateOption)}))}(jQuery);
|
||||
+1
-40
@@ -1,46 +1,7 @@
|
||||
.tag-generator-panel[data-id^="dynamic_select"],
|
||||
.tag-generator-panel[data-id^="dynamic_checkbox"],
|
||||
.tag-generator-panel[data-id^="dynamic_radio"] {
|
||||
height: 740px;
|
||||
}
|
||||
|
||||
#tag-generator-list a.button.dtx-form-tag {
|
||||
border-color: #765cb9;
|
||||
color: #765cb9;
|
||||
}
|
||||
|
||||
.tag-generator-panel table.form-table th {
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
.tag-generator-panel table.form-table td small {
|
||||
display: block;
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
|
||||
.tag-generator-panel .control-box input.oneline,
|
||||
.tag-generator-panel .control-box input.multiline,
|
||||
.tag-generator-panel .control-box textarea {
|
||||
.tag-generator-panel .control-box input.oneline {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tag-generator-panel .control-box input[list],
|
||||
.tag-generator-panel .control-box input.multiline,
|
||||
.tag-generator-panel .control-box textarea {
|
||||
height: 30px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.tag-generator-panel .control-box input.multiline {
|
||||
display: inline-block;
|
||||
/* -webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none; */
|
||||
resize: vertical;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.tag-generator-panel .control-box textarea {
|
||||
height: 3.5em;
|
||||
}
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
.tag-generator-panel[data-id^=dynamic_checkbox],.tag-generator-panel[data-id^=dynamic_radio],.tag-generator-panel[data-id^=dynamic_select]{height:740px}#tag-generator-list a.button.dtx-form-tag{border-color:#765cb9;color:#765cb9}.tag-generator-panel table.form-table th{width:130px}.tag-generator-panel table.form-table td small{display:block;margin-top:.25em}.tag-generator-panel .control-box input.multiline,.tag-generator-panel .control-box input.oneline,.tag-generator-panel .control-box textarea{width:100%}.tag-generator-panel .control-box input.multiline,.tag-generator-panel .control-box input[list],.tag-generator-panel .control-box textarea{height:30px;min-height:30px}.tag-generator-panel .control-box input.multiline{display:inline-block;resize:vertical;overflow-x:hidden;overflow-y:scroll}.tag-generator-panel .control-box textarea{height:3.5em}
|
||||
@@ -1,48 +1,5 @@
|
||||
== Changelog ==
|
||||
|
||||
= 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
|
||||
|
||||
+125
-342
@@ -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.1.0
|
||||
* Version: 3.5.4
|
||||
* Author: SevenSpark, AuRise Creative
|
||||
* Author URI: https://sevenspark.com
|
||||
* License: GPL2
|
||||
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
// Define current version
|
||||
define('WPCF7DTX_VERSION', '4.1.0');
|
||||
define('WPCF7DTX_VERSION', '3.5.4');
|
||||
|
||||
// Define root directory
|
||||
defined('WPCF7DTX_DIR') || define('WPCF7DTX_DIR', __DIR__);
|
||||
@@ -47,139 +47,31 @@ defined('WPCF7DTX_FILE') || define('WPCF7DTX_FILE', __FILE__);
|
||||
*/
|
||||
function wpcf7dtx_init()
|
||||
{
|
||||
add_action('wpcf7_init', 'wpcf7dtx_add_shortcodes'); // Add custom form tags to CF7
|
||||
add_action('wpcf7_init', 'wpcf7dtx_add_shortcode_dynamictext'); // Add custom form tags to CF7
|
||||
add_filter('wpcf7_validate_dynamictext*', 'wpcf7dtx_dynamictext_validation_filter', 20, 2); // Validate custom form tags
|
||||
}
|
||||
add_action('plugins_loaded', 'wpcf7dtx_init', 20);
|
||||
|
||||
/**
|
||||
* DTX Formg Tag Configuration
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wpcf7dtx_config()
|
||||
{
|
||||
global $wpcf7_dynamic_fields_config;
|
||||
if (!isset($wpcf7_dynamic_fields_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'),
|
||||
'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'),
|
||||
'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
|
||||
)
|
||||
),
|
||||
'dynamic_email' => array(
|
||||
'title' => __('dynamic email', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'dtx_pageload'),
|
||||
'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'),
|
||||
'description' => __('a single-line URL input field', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_tel' => array(
|
||||
'title' => __('dynamic tel', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'pattern'),
|
||||
'description' => __('a single-line telephone number input field', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_number' => array(
|
||||
'title' => __('dynamic number', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'min', 'max', 'step', 'pattern'),
|
||||
'description' => __('a numeric input field displayed as a number spinbox', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_range' => array(
|
||||
'title' => __('dynamic range', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'min', 'max', 'step', 'pattern'),
|
||||
'description' => __('a numeric input field displayed as a slider between a minimum and maximum range', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_textarea' => array(
|
||||
'title' => __('dynamic textarea', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'dtx_pageload'),
|
||||
'description' => __('a multi-line plain text input field', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dynamic_select' => array(
|
||||
'title' => __('dynamic drop-down menu', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'multiple', 'include_blank'),
|
||||
'description' => __('a drop-down menu (i.e select input field)', 'contact-form-7-dynamic-text-extension'),
|
||||
'features' => array(
|
||||
'selectable-values' => true // Generates an option (or group of options) from which you can select one or more options
|
||||
)
|
||||
),
|
||||
'dynamic_checkbox' => array(
|
||||
'title' => __('dynamic checkboxes', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('readonly', 'label_first', 'use_label_element', 'exclusive'),
|
||||
'description' => __('a group of checkboxes', 'contact-form-7-dynamic-text-extension'),
|
||||
'features' => array(
|
||||
'multiple-controls-container' => true, // Generates an HTML element that can contain multiple form controls
|
||||
'selectable-values' => true // Generates an option (or group of options) from which you can select one or more options
|
||||
)
|
||||
),
|
||||
'dynamic_radio' => array(
|
||||
'title' => __('dynamic radio buttons', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('readonly', 'label_first', 'use_label_element'),
|
||||
'description' => __('a group of radio buttons', 'contact-form-7-dynamic-text-extension'),
|
||||
'features' => array(
|
||||
'multiple-controls-container' => true, // Generates an HTML element that can contain multiple form controls
|
||||
'selectable-values' => true // Generates an option (or group of options) from which you can select one or more options
|
||||
)
|
||||
),
|
||||
'dynamic_date' => array(
|
||||
'title' => __('dynamic date', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'options' => array('placeholder', 'readonly', 'min', 'max'),
|
||||
'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'),
|
||||
'description' => __('a submit button', 'contact-form-7-dynamic-text-extension')
|
||||
)
|
||||
);
|
||||
}
|
||||
return $wpcf7_dynamic_fields_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Custom Shortcodes to Contact Form 7
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_add_shortcodes()
|
||||
function wpcf7dtx_add_shortcode_dynamictext()
|
||||
{
|
||||
//Add the dynamic form fields
|
||||
foreach (wpcf7dtx_config() as $form_tag => $field) {
|
||||
$input_type = str_replace('dynamic_', '', $form_tag);
|
||||
$tag_types = array($form_tag, "$form_tag*");
|
||||
$callback = 'wpcf7dtx_shortcode_handler';
|
||||
$features = array_merge(array('name-attr' => true), wpcf7dtx_array_has_key('features', $field, array()));
|
||||
switch ($input_type) {
|
||||
case 'text':
|
||||
case 'hidden':
|
||||
// Add deprecated tags
|
||||
$dep_tag = str_replace('_', '', $form_tag);
|
||||
$tag_types[] = $dep_tag;
|
||||
$tag_types[] = "$dep_tag*";
|
||||
add_filter("wpcf7_validate_$dep_tag*", 'wpcf7dtx_validation_filter', 20, 2); // Validate required deprecated form tags
|
||||
break;
|
||||
case 'submit':
|
||||
case 'reset':
|
||||
$callback = 'wpcf7dtx_button_shortcode_handler';
|
||||
$features['name-attr'] = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
add_filter("wpcf7_validate_$form_tag*", 'wpcf7dtx_validation_filter', 20, 2); // Validate required custom form tags
|
||||
wpcf7_add_form_tag($tag_types, $callback, $features);
|
||||
}
|
||||
//Add the dynamic text and hidden form fields
|
||||
wpcf7_add_form_tag(
|
||||
array(
|
||||
'dynamictext', 'dynamictext*',
|
||||
'dynamichidden', 'dynamichidden*' //Required hidden fields do nothing
|
||||
),
|
||||
'wpcf7dtx_dynamictext_shortcode_handler', //Callback
|
||||
array( //Features
|
||||
'name-attr' => true,
|
||||
'dtx_pageload' => true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,9 +112,35 @@ add_action('wp_enqueue_scripts', 'wpcf7dtx_enqueue_frontend_assets');
|
||||
include_once(WPCF7DTX_DIR . '/includes/utilities.php');
|
||||
|
||||
/**
|
||||
* Include Validation Functions
|
||||
* Get Dynamic Value
|
||||
*
|
||||
* @since 3.2.2
|
||||
*
|
||||
* @param string $value The form tag value.
|
||||
* @param WPCF7_FormTag|false $tag Optional. Use to look up default value.
|
||||
*
|
||||
* @return string The dynamic output or the original value, not escaped or sanitized.
|
||||
*/
|
||||
include_once(WPCF7DTX_DIR . '/includes/validation.php');
|
||||
function wpcf7dtx_get_dynamic($value, $tag = false)
|
||||
{
|
||||
if ($tag !== false) {
|
||||
$default = $tag->get_option('defaultvalue', '', true);
|
||||
if (!$default) {
|
||||
$default = $tag->get_default_option(strval(reset($tag->values)));
|
||||
}
|
||||
$value = wpcf7_get_hangover($tag->name, $default);
|
||||
}
|
||||
$value = apply_filters('wpcf7dtx_sanitize', $value);
|
||||
if (is_string($value) && !empty($value)) {
|
||||
// If a shortcode was passed as the options, evaluate it and use the result
|
||||
$shortcode_tag = '[' . $value . ']';
|
||||
$shortcode_output = do_shortcode($shortcode_tag); //Shortcode value
|
||||
if (is_string($shortcode_output) && $shortcode_output != $shortcode_tag) {
|
||||
return apply_filters('wpcf7dtx_sanitize', $shortcode_output);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form Tag Handler
|
||||
@@ -231,54 +149,59 @@ include_once(WPCF7DTX_DIR . '/includes/validation.php');
|
||||
*
|
||||
* @return string HTML output of the shortcode
|
||||
*/
|
||||
function wpcf7dtx_shortcode_handler($tag)
|
||||
function wpcf7dtx_dynamictext_shortcode_handler($tag)
|
||||
{
|
||||
// Name attribute is required for these form tags
|
||||
if (empty($tag->name)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Validate
|
||||
//Validate
|
||||
$validation_error = wpcf7_get_validation_error($tag->name);
|
||||
|
||||
//Configure classes
|
||||
$class = wpcf7_form_controls_class($tag->type, 'wpcf7dtx-dynamictext');
|
||||
if ($validation_error) {
|
||||
$class .= ' wpcf7-not-valid';
|
||||
}
|
||||
|
||||
//Configure input attributes
|
||||
$atts = array();
|
||||
$atts['type'] = sanitize_key(str_replace(array('dynamic_', 'dynamic'), '', $tag->basetype));
|
||||
$atts['name'] = $tag->name;
|
||||
$atts['id'] = strval($tag->get_id_option());
|
||||
$atts['id'] = $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']);
|
||||
if ($validation_error) {
|
||||
$atts['class'][] = 'wpcf7-not-valid';
|
||||
$atts['aria-invalid'] = 'true';
|
||||
$atts['aria-describedby'] = wpcf7_get_validation_error_reference($tag->name);
|
||||
} else {
|
||||
$atts['aria-invalid'] = 'false';
|
||||
$atts['maxlength'] = $tag->get_maxlength_option();
|
||||
$atts['minlength'] = $tag->get_minlength_option();
|
||||
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
|
||||
switch ($tag->basetype) {
|
||||
case 'dynamichidden':
|
||||
$atts['type'] = 'hidden'; //Override type as hidden
|
||||
break;
|
||||
default: // Includes `dynamictext`
|
||||
$atts['type'] = 'text'; //Override type as text
|
||||
break;
|
||||
}
|
||||
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
|
||||
unset($atts['maxlength'], $atts['minlength']);
|
||||
}
|
||||
|
||||
if ($tag->has_option('readonly')) {
|
||||
$atts['readonly'] = 'readonly';
|
||||
}
|
||||
// Add required attribute to applicable input types
|
||||
if ($tag->is_required() && !in_array($atts['type'], array('hidden', 'quiz'))) {
|
||||
if ($tag->is_required() && $atts['type'] !== 'hidden') {
|
||||
$atts['aria-required'] = 'true';
|
||||
$atts['required'] = 'required';
|
||||
}
|
||||
|
||||
// Evaluate the dynamic value
|
||||
$sanitize_type = $atts['type'] == 'textarea' ? $atts['type'] : 'auto';
|
||||
$value = wpcf7dtx_get_dynamic(false, $tag, $sanitize_type);
|
||||
$value = wpcf7dtx_get_dynamic(false, $tag);
|
||||
|
||||
// Identify placeholder
|
||||
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
|
||||
//Reverse engineer what JS did (converted quotes to HTML entities --> URL encode) then sanitize
|
||||
$placeholder = html_entity_decode(urldecode($tag->get_option('placeholder', '', true)), ENT_QUOTES);
|
||||
$placeholder = html_entity_decode(urldecode(implode('', (array)$tag->get_option('placeholder'))), ENT_QUOTES);
|
||||
if ($placeholder) {
|
||||
//If a different placeholder text has been specified, set both attributes
|
||||
$placeholder = wpcf7dtx_get_dynamic($placeholder, false, $sanitize_type);
|
||||
$placeholder = wpcf7dtx_get_dynamic($placeholder);
|
||||
$atts['placeholder'] = $placeholder;
|
||||
$atts['value'] = $value;
|
||||
} else {
|
||||
@@ -289,10 +212,18 @@ function wpcf7dtx_shortcode_handler($tag)
|
||||
$atts['value'] = $value;
|
||||
}
|
||||
|
||||
if ($atts['type'] == 'hidden') {
|
||||
// Always disable for hidden fields
|
||||
$atts['autocomplete'] = 'off';
|
||||
} else {
|
||||
// Disable autocomplete for this field if a value has been specified
|
||||
$atts['autocomplete'] = $atts['value'] ? 'off' : $tag->get_option('autocomplete', '[-0-9a-zA-Z]+', true);
|
||||
}
|
||||
|
||||
// Page load attribute
|
||||
if ($tag->has_option('dtx_pageload') && is_array($tag->raw_values) && count($tag->raw_values)) {
|
||||
$atts['data-dtx-value'] = rawurlencode(sanitize_text_field($tag->raw_values[0]));
|
||||
$atts['class'][] = 'dtx-pageload';
|
||||
if ($tag->has_option('dtx_pageload')) {
|
||||
$atts['data-dtx-value'] = rawurlencode(sanitize_text_field(implode('', (array)$tag->raw_values)));
|
||||
$class .= ' dtx-pageload';
|
||||
if (wp_style_is('wpcf7dtx', 'registered') && !wp_script_is('wpcf7dtx', 'queue')) {
|
||||
// If already registered, just enqueue it
|
||||
wp_enqueue_script('wpcf7dtx');
|
||||
@@ -303,190 +234,54 @@ function wpcf7dtx_shortcode_handler($tag)
|
||||
}
|
||||
}
|
||||
|
||||
// Additional configuration based on form field type
|
||||
if (in_array($atts['type'], array('select', 'checkbox', 'radio'))) {
|
||||
/**
|
||||
* Configuration for selection-based fields
|
||||
*/
|
||||
if ($tag->has_option('default')) {
|
||||
$atts['dtx-default'] = wpcf7dtx_get_dynamic(html_entity_decode(urldecode($tag->get_option('default', '', true)), ENT_QUOTES));
|
||||
}
|
||||
|
||||
// Get options for selection-based fields
|
||||
$options = array();
|
||||
$pipes = $tag->pipes->to_array();
|
||||
if (count($pipes)) {
|
||||
foreach ($pipes as $pipe) {
|
||||
$key = trim(strval($pipe[0]));
|
||||
$value = trim(strval($pipe[1]));
|
||||
if ($key && $value) {
|
||||
$options[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
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'));
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Configuration for text-based fields
|
||||
*/
|
||||
|
||||
// Attributes
|
||||
$atts['maxlength'] = $tag->get_maxlength_option();
|
||||
$atts['minlength'] = $tag->get_minlength_option();
|
||||
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
|
||||
unset($atts['maxlength'], $atts['minlength']);
|
||||
}
|
||||
|
||||
// Autocomplete attribute
|
||||
if ($atts['type'] == 'hidden') {
|
||||
$atts['autocomplete'] = 'off'; // Always disable for hidden fields
|
||||
} else {
|
||||
// Disable autocomplete for this field if a dynamic value has been specified
|
||||
$atts['autocomplete'] = $atts['value'] ? 'off' : $tag->get_option('autocomplete', '[-0-9a-zA-Z]+', true);
|
||||
}
|
||||
|
||||
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 'textarea':
|
||||
// Attributes unique to textareas
|
||||
$atts['cols'] = $tag->get_cols_option('40');
|
||||
$atts['rows'] = $tag->get_rows_option('10');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap up class attribute
|
||||
$atts['class'] = $tag->get_class_option($atts['class']);
|
||||
$atts['class'] = $tag->get_class_option($class);
|
||||
|
||||
// Output the form field HTML
|
||||
$wrapper = '<span class="wpcf7-form-control-wrap %1$s" data-name="%1$s">%2$s%3$s</span>';
|
||||
$allowed_html = array('br' => array(), 'span' => array('id' => array(), 'class' => array(), 'data-name' => array(), 'aria-hidden' => array()));
|
||||
switch ($atts['type']) {
|
||||
case 'checkbox':
|
||||
case 'radio':
|
||||
return wp_kses(sprintf(
|
||||
str_replace('<span class=', '<span%4$s class=', $wrapper), // Insert a 4th parameter for wrapper
|
||||
esc_attr($tag->name),
|
||||
wpcf7dtx_checkbox_group_html(
|
||||
$atts,
|
||||
$options,
|
||||
in_array('use_label_element', $tag->options),
|
||||
in_array('label_first', $tag->options),
|
||||
in_array('exclusive', $tag->options)
|
||||
),
|
||||
$validation_error,
|
||||
$atts['id'] ? sprintf(' id="%s"', esc_attr($atts['id'])) : ''
|
||||
), array_merge($allowed_html, array(
|
||||
'label' => array('for' => array()),
|
||||
'input' => wpcf7dtx_get_allowed_field_properties($atts['type'])
|
||||
)));
|
||||
case 'select':
|
||||
$allowed_html = array_merge($allowed_html, wpcf7dtx_get_allowed_field_properties('option'), array(
|
||||
'select' => wpcf7dtx_get_allowed_field_properties($atts['type'])
|
||||
));
|
||||
return wp_kses(sprintf(
|
||||
$wrapper,
|
||||
esc_attr($tag->name),
|
||||
wpcf7dtx_select_html(
|
||||
$atts,
|
||||
$options,
|
||||
$tag->has_option('dtx_hide_blank'),
|
||||
$tag->has_option('dtx_disable_blank')
|
||||
),
|
||||
$validation_error
|
||||
), array_merge($allowed_html, wpcf7dtx_get_allowed_field_properties('option'), array(
|
||||
'select' => wpcf7dtx_get_allowed_field_properties($atts['type']),
|
||||
)));
|
||||
case 'textarea':
|
||||
return wp_kses(sprintf(
|
||||
$wrapper,
|
||||
esc_attr($tag->name),
|
||||
wpcf7dtx_textarea_html($atts),
|
||||
$validation_error
|
||||
), array_merge($allowed_html, array(
|
||||
'textarea' => wpcf7dtx_get_allowed_field_properties($atts['type'])
|
||||
)));
|
||||
default:
|
||||
return wp_kses(sprintf(
|
||||
$wrapper,
|
||||
esc_attr($tag->name),
|
||||
wpcf7dtx_input_html($atts),
|
||||
$validation_error
|
||||
), array_merge($allowed_html, array(
|
||||
'input' => wpcf7dtx_get_allowed_field_properties($atts['type'])
|
||||
)));
|
||||
}
|
||||
//Output the HTML
|
||||
return sprintf(
|
||||
'<span class="wpcf7-form-control-wrap %s" data-name="%s"><input %s />%s</span>',
|
||||
sanitize_html_class($tag->name),
|
||||
esc_attr($tag->name),
|
||||
wpcf7_format_atts($atts), //This function already escapes attribute values
|
||||
$validation_error
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form Tag Handler for Dynamic Submit
|
||||
* Validate Required Dynamic Text Field
|
||||
*
|
||||
* @param WPCF7_FormTag $tag Current Contact Form 7 tag object
|
||||
* @param WPCF7_Validation $result the current validation result object
|
||||
* @param WPCF7_FormTag $tag the current form tag being filtered for validation
|
||||
*
|
||||
* @return string HTML output of the shortcode
|
||||
* @return WPCF7_Validation a possibly modified validation result object
|
||||
*/
|
||||
function wpcf7dtx_button_shortcode_handler($tag)
|
||||
function wpcf7dtx_dynamictext_validation_filter($result, $tag)
|
||||
{
|
||||
//Configure input attributes
|
||||
$atts = array();
|
||||
$atts['type'] = sanitize_key(str_replace('dynamic_', '', $tag->basetype));
|
||||
$atts['id'] = strval($tag->get_id_option());
|
||||
$atts['tabindex'] = $tag->get_option('tabindex', 'signed_int', true);
|
||||
$atts['value'] = wpcf7dtx_get_dynamic(false, $tag); // Evaluate the dynamic value
|
||||
$atts['class'] = explode(' ', wpcf7_form_controls_class($atts['type']));
|
||||
$atts['class'][] = 'wpcf7dtx';
|
||||
$atts['class'][] = sanitize_html_class('wpcf7dtx-' . $atts['type']);
|
||||
if ($atts['type'] == 'submit') {
|
||||
$atts['class'][] = 'has-spinner';
|
||||
}
|
||||
//Sanitize value
|
||||
$value = empty($_POST[$tag->name]) ? '' : sanitize_text_field(strval($_POST[$tag->name]));
|
||||
|
||||
// Default value if empty
|
||||
if (empty($atts['value'])) {
|
||||
switch ($atts['type']) {
|
||||
case 'reset':
|
||||
$atts['value'] = __('Clear', 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
default:
|
||||
$atts['value'] = __('Send', 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
//Validate
|
||||
if ('dynamictext' == $tag->basetype) {
|
||||
if ($tag->is_required() && '' == $value) {
|
||||
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
|
||||
}
|
||||
}
|
||||
|
||||
// Page load attribute
|
||||
if ($tag->has_option('dtx_pageload') && is_array($tag->raw_values) && count($tag->raw_values)) {
|
||||
$atts['data-dtx-value'] = rawurlencode(sanitize_text_field($tag->raw_values[0]));
|
||||
$atts['class'][] = 'dtx-pageload';
|
||||
if (wp_style_is('wpcf7dtx', 'registered') && !wp_script_is('wpcf7dtx', 'queue')) {
|
||||
// If already registered, just enqueue it
|
||||
wp_enqueue_script('wpcf7dtx');
|
||||
} elseif (!wp_style_is('wpcf7dtx', 'registered')) {
|
||||
// If not registered, do that first, then enqueue it
|
||||
wpcf7dtx_enqueue_frontend_assets();
|
||||
wp_enqueue_script('wpcf7dtx');
|
||||
if (!empty($value)) {
|
||||
$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'));
|
||||
} elseif ($minlength && $code_units < $minlength) {
|
||||
$result->invalidate($tag, wpcf7_get_message('invalid_too_short'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap up class attribute
|
||||
$atts['class'] = $tag->get_class_option($atts['class']);
|
||||
|
||||
// Output the form field HTML
|
||||
return wp_kses(
|
||||
wpcf7dtx_input_html($atts),
|
||||
array('input' => wpcf7dtx_get_allowed_field_properties($atts['type']))
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -501,14 +296,16 @@ function wpcf7dtx_button_shortcode_handler($tag)
|
||||
function wpcf7dtx_js_handler()
|
||||
{
|
||||
$return = array();
|
||||
$queue = wpcf7dtx_array_has_key('shortcodes', $_POST);
|
||||
if (is_array($queue) && count($queue)) {
|
||||
foreach ($queue as $field) {
|
||||
$multiline = wpcf7dtx_array_has_key('multiline', $field, false);
|
||||
$raw_value = sanitize_text_field(rawurldecode(wpcf7dtx_array_has_key('value', $field)));
|
||||
$shortcodes = wpcf7dtx_array_has_key('shortcodes', $_POST);
|
||||
if (is_array($shortcodes) && count($shortcodes)) {
|
||||
foreach ($shortcodes as $raw_value) {
|
||||
$value = sanitize_text_field(rawurldecode($raw_value));
|
||||
if (!empty($value)) {
|
||||
$value = wpcf7dtx_get_dynamic($value);
|
||||
}
|
||||
$return[] = array(
|
||||
'raw_value' => esc_attr($raw_value),
|
||||
'value' => esc_attr(wpcf7dtx_get_dynamic($raw_value, false, $multiline ? 'textarea' : 'auto'))
|
||||
'value' => esc_attr($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -525,20 +322,6 @@ if (is_admin()) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Built-in Shortcodes
|
||||
* Included Shortcodes
|
||||
*/
|
||||
include_once(WPCF7DTX_DIR . '/includes/shortcodes.php');
|
||||
|
||||
/**
|
||||
* Website's custom shortcodes, if they exist
|
||||
*/
|
||||
$user_files = array(
|
||||
constant('WP_CONTENT_DIR') . '/dtx.php', // e.g. C:\path\to\website\wp-content\dtx.php
|
||||
get_template_directory() . '/dtx.php', // e.g. C:\path\to\website\wp-content/themes/parent-theme/dtx.php
|
||||
get_stylesheet_directory() . '/dtx.php' // e.g. C:\path\to\website\wp-content/themes/child-theme/dtx.php
|
||||
);
|
||||
foreach ($user_files as $user_file) {
|
||||
if (file_exists($user_file)) {
|
||||
include_once($user_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ function wpcf7dtx_enqueue_admin_assets($hook)
|
||||
// Only load on CF7 Form pages (both editing forms and creating new forms)
|
||||
if ($hook === 'toplevel_page_wpcf7' || $hook === 'contact_page_wpcf7-new') {
|
||||
$prefix = 'wpcf7dtx-';
|
||||
$debug = defined('WP_DEBUG_SCRIPTS') && constant('WP_DEBUG_SCRIPTS');
|
||||
$debug = defined('WP_DEBUG') && constant('WP_DEBUG');
|
||||
$url = plugin_dir_url(WPCF7DTX_FILE);
|
||||
$path = plugin_dir_path(WPCF7DTX_FILE);
|
||||
|
||||
wp_enqueue_style(
|
||||
$prefix . 'admin', //Handle
|
||||
$url . 'assets/styles/tag-generator' . ($debug ? '' : '.min') . '.css', //Source
|
||||
$url . 'assets/styles/tag-generator.css', //Source
|
||||
array('contact-form-7-admin'), //Dependencies
|
||||
$debug ? @filemtime($path . 'assets/styles/tag-generator.css') : WPCF7DTX_VERSION //Version
|
||||
);
|
||||
@@ -44,22 +44,30 @@ add_action('admin_enqueue_scripts', 'wpcf7dtx_enqueue_admin_assets'); //Enqueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_add_tag_generators()
|
||||
function wpcf7dtx_add_tag_generator_dynamictext()
|
||||
{
|
||||
if (!class_exists('WPCF7_TagGenerator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Custom dynamic fields to add
|
||||
global $wpcf7_dynamic_fields_config;
|
||||
|
||||
// Loop fields to add them
|
||||
$tag_generator = WPCF7_TagGenerator::get_instance();
|
||||
foreach ($wpcf7_dynamic_fields_config as $id => $field) {
|
||||
$tag_generator->add($id, $field['title'], 'wpcf7dtx_tag_generator', array_merge(array('name-attr', 'dtx_pageload'), $field['options']));
|
||||
}
|
||||
|
||||
//Dynamic Text Field
|
||||
$tag_generator->add(
|
||||
'dynamictext', //id
|
||||
__('dynamic text', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'wpcf7dtx_tag_generator_dynamictext', //callback
|
||||
array('placeholder', 'readonly', 'dtx_pageload') //options
|
||||
);
|
||||
|
||||
//Dynamic Hidden Field
|
||||
$tag_generator->add(
|
||||
'dynamichidden', //id
|
||||
__('dynamic hidden', 'contact-form-7-dynamic-text-extension'), //title
|
||||
'wpcf7dtx_tag_generator_dynamictext', //callback
|
||||
array('dtx_pageload') // options
|
||||
);
|
||||
}
|
||||
add_action('wpcf7_admin_init', 'wpcf7dtx_add_tag_generators', 100);
|
||||
add_action('wpcf7_admin_init', 'wpcf7dtx_add_tag_generator_dynamictext', 100);
|
||||
|
||||
/**
|
||||
* Echo HTML for Dynamic Tag Generator
|
||||
@@ -69,43 +77,36 @@ add_action('wpcf7_admin_init', 'wpcf7dtx_add_tag_generators', 100);
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_tag_generator($contact_form, $options = '')
|
||||
function wpcf7dtx_tag_generator_dynamictext($contact_form, $options = '')
|
||||
{
|
||||
$options = wp_parse_args($options);
|
||||
global $wpcf7_dynamic_fields_config;
|
||||
$type = $options['id'];
|
||||
$input_type = str_replace('dynamic_', '', $type);
|
||||
switch ($type) {
|
||||
case 'dynamichidden': //hiden
|
||||
$description = __('Generate a form-tag for a hidden input field, with a dynamically generated default value.', 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
default:
|
||||
$description = __('Generate a form-tag for a single-line plain text input field, with a dynamically generated default value.', 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
}
|
||||
$utm_source = urlencode(home_url());
|
||||
$description = sprintf(
|
||||
__('Generate a form-tag for %s with a dynamic default value. For more details, see %s fields in the %s.', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html($wpcf7_dynamic_fields_config[$type]['description']), // dynamic description
|
||||
// Link to specific form-tag documentation
|
||||
sprintf(
|
||||
'<a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/%s?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" title="%s" target="_blank" rel="noopener">%s</a>',
|
||||
esc_attr(str_replace('_', '-', $type)), // URL component
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_attr__('View this form-tag on the DTX Documentation website', 'contact-form-7-dynamic-text-extension'), // Link title
|
||||
esc_html(ucwords(str_replace('_', ' ', $type))) // Link label
|
||||
),
|
||||
// Link to general DTX documentation
|
||||
sprintf(
|
||||
'<a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" title="%s" target="_blank" rel="noopener">%s</a>',
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_attr__('Go to DTX Documentation website', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html__('DTX knowledge base', 'contact-form-7-dynamic-text-extension')
|
||||
)
|
||||
$description .= sprintf(
|
||||
' %s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" title="%s" target="_blank" rel="noopener">%s</a>.',
|
||||
esc_html__('For more details, see', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_attr__('Go to DTX Documentation website', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_html__('DTX knowledge base', 'contact-form-7-dynamic-text-extension')
|
||||
);
|
||||
|
||||
// Open Form-Tag Generator
|
||||
//Open Form-Tag Generator
|
||||
printf(
|
||||
'<div class="control-box dtx-taggen"><fieldset><legend>%s</legend><table class="form-table"><tbody>',
|
||||
'<div class="control-box"><fieldset><legend>%s</legend><table class="form-table"><tbody>',
|
||||
wp_kses($description, array('a' => array('href' => array(), 'target' => array(), 'rel' => array(), 'title' => array()))) //Tag generator description
|
||||
);
|
||||
|
||||
// Input field - Required checkbox (not available for some fields)
|
||||
if (!in_array($input_type, array('hidden', 'quiz', 'submit', 'reset'))) {
|
||||
//Input field - Required checkbox (not available for hidden fields)
|
||||
if ($type != 'dynamichidden') {
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-required'), // field id
|
||||
@@ -119,253 +120,62 @@ function wpcf7dtx_tag_generator($contact_form, $options = '')
|
||||
);
|
||||
}
|
||||
|
||||
// Input field - Field Name (not available for some fields)
|
||||
if (!in_array($input_type, array('submit', 'reset'))) {
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /></td></tr>',
|
||||
esc_attr($options['content'] . '-name'), // field id
|
||||
esc_html__('Name', 'contact-form-7-dynamic-text-extension'), // field label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'text',
|
||||
'name' => 'name',
|
||||
'id' => $options['content'] . '-name',
|
||||
'class' => 'tg-name oneline',
|
||||
'autocomplete' => 'off'
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
// Input field - Dynamic value/options
|
||||
$value_name = __('Dynamic value', 'contact-form-7-dynamic-text-extension');
|
||||
$value_description = __('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension');
|
||||
$value_placeholder = "CF7_GET key='foo'";
|
||||
$value_input_type = '<input %s />';
|
||||
switch ($input_type) {
|
||||
case 'textarea':
|
||||
$value_placeholder = "CF7_get_post_var key='post_excerpt'";
|
||||
$value_input_type = '<textarea %s></textarea>';
|
||||
break;
|
||||
case 'select':
|
||||
$value_name = __('Dynamic options', 'contact-form-7-dynamic-text-extension');
|
||||
$value_description .= ' ' . __('If static text, use one option per line. Can define static key/value pairs using pipes.', 'contact-form-7-dynamic-text-extension');
|
||||
$value_description .= ' ' . __('If shortcode, it must return only option or optgroup HTML and can override the first option and select default settings here.', 'contact-form-7-dynamic-text-extension');
|
||||
$value_placeholder = "hello-world | Hello World" . PHP_EOL . "Foo";
|
||||
$value_input_type = '<textarea %s></textarea>';
|
||||
break;
|
||||
case 'checkbox':
|
||||
case 'radio':
|
||||
$value_name = __('Dynamic options', 'contact-form-7-dynamic-text-extension');
|
||||
$value_description .= ' ' . __('If static text, use one option per line. Can define static key/value pairs using pipes.', 'contact-form-7-dynamic-text-extension');
|
||||
$value_description .= ' ' . __('If shortcode, it must return only option or optgroup HTML.', 'contact-form-7-dynamic-text-extension');
|
||||
$value_placeholder = "hello-world | Hello World" . PHP_EOL . "Foo";
|
||||
$value_input_type = '<textarea %s></textarea>';
|
||||
break;
|
||||
default: // All other text fields
|
||||
break;
|
||||
}
|
||||
//Input field - Field Name
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td>' . $value_input_type . '<br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
esc_attr($options['content'] . '-values'), // field id
|
||||
esc_html($value_name), // field label
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /></td></tr>',
|
||||
esc_attr($options['content'] . '-name'), // field id
|
||||
esc_html__('Name', 'contact-form-7-dynamic-text-extension'), // field label
|
||||
wpcf7_format_atts(array(
|
||||
'name' => 'values',
|
||||
'id' => $options['content'] . '-values',
|
||||
'class' => 'multiline',
|
||||
'placeholder' => $value_placeholder,
|
||||
'list' => 'dtx-shortcodes'
|
||||
)),
|
||||
esc_html($value_description),
|
||||
esc_attr($utm_source), // UTM source
|
||||
esc_attr($type), // UTM content
|
||||
esc_html__('View DTX shortcode syntax documentation', 'contact-form-7-dynamic-text-extension') // Link label
|
||||
'type' => 'text',
|
||||
'name' => 'name',
|
||||
'id' => $options['content'] . '-name',
|
||||
'class' => 'tg-name oneline'
|
||||
))
|
||||
);
|
||||
|
||||
if ($input_type == 'select') {
|
||||
// Input field - Multiple selections checkbox
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-multiple'), // field id
|
||||
esc_html__('Multiple Options', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'multiple',
|
||||
'id' => $options['content'] . '-multiple',
|
||||
'class' => 'option'
|
||||
)),
|
||||
esc_html__('Allow user to select multiple options', 'contact-form-7-dynamic-text-extension') // checkbox label
|
||||
);
|
||||
//Input field - Dynamic value
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
esc_attr($options['content'] . '-values'), // field id
|
||||
esc_html__('Dynamic value', 'contact-form-7-dynamic-text-extension'), // field label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'text',
|
||||
'name' => 'values',
|
||||
'id' => $options['content'] . '-values',
|
||||
'class' => 'oneline',
|
||||
'placeholder' => "CF7_GET key='foo'"
|
||||
)),
|
||||
esc_html__('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension'),
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_html__('View DTX shortcode syntax documentation', 'contact-form-7-dynamic-text-extension') //Link label
|
||||
);
|
||||
|
||||
// Input field - Include blank checkbox
|
||||
//Input field - Dynamic placeholder (not available for hidden fields)
|
||||
if ($type != 'dynamichidden') {
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-include_blank'), // field id
|
||||
esc_html__('First Option', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'include_blank',
|
||||
'id' => $options['content'] . '-include_blank',
|
||||
'class' => 'include_blankvalue option'
|
||||
)),
|
||||
esc_html__('Insert a blank item as the first option', 'contact-form-7-dynamic-text-extension') // checkbox label
|
||||
);
|
||||
}
|
||||
|
||||
// Input field - Dynamic placeholder (not available for some fields)
|
||||
if (!in_array($input_type, array('hidden', 'radio', 'checkbox', 'quiz', 'submit', 'reset'))) {
|
||||
$placeholder_description = '';
|
||||
if (in_array($input_type, array('select', 'checkbox', 'radio'))) {
|
||||
$placeholder_label = __('First Option Label', 'contact-form-7-dynamic-text-extension');
|
||||
$placeholder_description .= __('Optionally define a label for the first option.', 'contact-form-7-dynamic-text-extension') . ' ';
|
||||
} else {
|
||||
$placeholder_label = __('Dynamic placeholder', 'contact-form-7-dynamic-text-extension');
|
||||
}
|
||||
$placeholder_description .= __('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension');
|
||||
$placeholder_input_type = $input_type == 'textarea' ? $value_input_type : '<input %s />';
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s />' . $placeholder_input_type . '<br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-placeholder/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /><input %s /><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/dtx-attribute-placeholder/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
esc_attr($options['content'] . '-placeholder'), // field id
|
||||
esc_html($placeholder_label), // field label
|
||||
esc_html__('Dynamic placeholder', 'contact-form-7-dynamic-text-extension'), // field label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'placeholder',
|
||||
'class' => 'option'
|
||||
)),
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'text',
|
||||
'name' => 'dtx-placeholder',
|
||||
'id' => $options['content'] . '-placeholder', // field id
|
||||
'class' => 'multiline dtx-option',
|
||||
'placeholder' => "CF7_get_post_var key='post_title'",
|
||||
'list' => 'dtx-shortcodes'
|
||||
'class' => 'oneline dtx-option',
|
||||
'placeholder' => 'CF7_get_post_var key=\'post_title\''
|
||||
)),
|
||||
esc_html($placeholder_description), // Small note below input
|
||||
esc_html__('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension'), // Small note below input
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_html__('View DTX placeholder documentation', 'contact-form-7-dynamic-text-extension') //Link label
|
||||
);
|
||||
}
|
||||
|
||||
// Additional fields for select regarding placeholder options
|
||||
if ($input_type == 'select') {
|
||||
|
||||
// Input field - Hide Blank Option
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
esc_attr($options['content'] . '-dtx_hide_blank'), // field id
|
||||
esc_html__('Hide First Option', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'dtx_hide_blank',
|
||||
'id' => $options['content'] . '-dtx_hide_blank',
|
||||
'class' => 'option'
|
||||
)),
|
||||
esc_html__('Hide the first blank option from being visible in the drop-down', 'contact-form-7-dynamic-text-extension'), // checkbox label
|
||||
esc_html__('Optional. Only works if "First Option" is checked.', 'contact-form-7-dynamic-text-extension'), // Small note below input
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_html__('View Dynamic Select documentation', 'contact-form-7-dynamic-text-extension') //Link label
|
||||
);
|
||||
|
||||
// Input field - Disable Blank Option
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
esc_attr($options['content'] . '-dtx_disable_blank'), // field id
|
||||
esc_html__('Disable First Option', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'dtx_disable_blank',
|
||||
'id' => $options['content'] . '-dtx_disable_blank',
|
||||
'class' => 'option'
|
||||
)),
|
||||
esc_html__('Disable the first blank option from being selectable in the drop-down', 'contact-form-7-dynamic-text-extension'), // checkbox label
|
||||
esc_html__('Optional. Only works if "First Option" is checked.', 'contact-form-7-dynamic-text-extension'), // Small note below input
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_html__('View Dynamic Select documentation', 'contact-form-7-dynamic-text-extension') //Link label
|
||||
|
||||
);
|
||||
} elseif (in_array($input_type, array('checkbox', 'radio'))) {
|
||||
// Additional fields for checkboxes and radio buttons
|
||||
|
||||
// Input field - Checkbox Layout Reverse Option
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-label_first'), // field id
|
||||
esc_html__('Reverse', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'label_first',
|
||||
'id' => $options['content'] . '-label_first',
|
||||
'class' => 'option'
|
||||
)),
|
||||
esc_html__('Put a label first, an input last', 'contact-form-7-dynamic-text-extension') // checkbox label
|
||||
);
|
||||
|
||||
// Input field - Label UI
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-use_label_element'), // field id
|
||||
esc_html__('Label', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'use_label_element',
|
||||
'id' => $options['content'] . '-use_label_element',
|
||||
'class' => 'option'
|
||||
)),
|
||||
esc_html__('Wrap each item with label element', 'contact-form-7-dynamic-text-extension') // checkbox label
|
||||
);
|
||||
|
||||
// Input field - Exclusive Checkbox
|
||||
if ($input_type == 'checkbox') {
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-exclusive'), // field id
|
||||
esc_html__('Exclusive', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'exclusive',
|
||||
'id' => $options['content'] . '-exclusive',
|
||||
'class' => 'option'
|
||||
)),
|
||||
esc_html__('Make checkboxes exclusive', 'contact-form-7-dynamic-text-extension') // checkbox label
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Input field - Dynamic default value (not available for some fields)
|
||||
if (in_array($input_type, array('select'))) {
|
||||
$default_input_type = '<input %s />';
|
||||
$default_placeholder = '';
|
||||
if ($input_type == 'checkbox') {
|
||||
$default_input_type = '<textarea %s></textarea>';
|
||||
$default_description = __('Optionally define the default on/off status of the checkboxes by putting a 1 (checked) or 0 (not checked) on each line that corresponds with the options.', 'contact-form-7-dynamic-text-extension') . ' ';
|
||||
$default_placeholder = '0' . PHP_EOL . '1';
|
||||
} else {
|
||||
$default_description = __('Optionally define the option that is selected by default. This can be different than the first [blank] option. If options use key/value pairs, only define the key here.', 'contact-form-7-dynamic-text-extension') . ' ';
|
||||
}
|
||||
$default_description .= __('Can be static text or a shortcode.', 'contact-form-7-dynamic-text-extension');
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s />' . $default_input_type . '<br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tags/dynamic-select/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
esc_attr($options['content'] . '-default'), // field id
|
||||
esc_html__('Selected Default'), // field label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'default',
|
||||
'class' => 'option'
|
||||
)),
|
||||
wpcf7_format_atts(array(
|
||||
'name' => 'dtx-default',
|
||||
'id' => $options['content'] . '-default', // field id
|
||||
'class' => 'oneline dtx-option',
|
||||
'placeholder' => $default_placeholder,
|
||||
'list' => 'dtx-shortcodes'
|
||||
)),
|
||||
esc_html($default_description), // Small note below input
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_html__('View Dynamic Select documentation', 'contact-form-7-dynamic-text-extension') //Link label
|
||||
);
|
||||
}
|
||||
|
||||
//Input field - ID attribute
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><input %s /></td></tr>',
|
||||
@@ -392,8 +202,8 @@ function wpcf7dtx_tag_generator($contact_form, $options = '')
|
||||
))
|
||||
);
|
||||
|
||||
//Input field - Readonly attribute (not available for hidden, submit, or quiz fields)
|
||||
if (!in_array($input_type, array('hidden', 'submit', 'quiz'))) {
|
||||
//Input field - Readonly attribute (not available for hidden fields)
|
||||
if ($type != 'dynamichidden') {
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-readonly'), // field id
|
||||
@@ -408,55 +218,25 @@ function wpcf7dtx_tag_generator($contact_form, $options = '')
|
||||
);
|
||||
}
|
||||
|
||||
// Input field - Page load data attribute (triggers the loading of a frontend script)
|
||||
// Page load data attribute (triggers the loading of a frontend script)
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label><br /><small>%s <a href="https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/form-tag-attribute-after-page-load/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=form-tag-generator-%s" target="_blank" rel="noopener">%s</a></small></td></tr>',
|
||||
esc_attr($options['content'] . '-dtx_pageload'), // field id
|
||||
esc_attr($options['content'] . '-frontend'), // field id
|
||||
esc_html__('Cache Compatible', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'dtx_pageload',
|
||||
'id' => $options['content'] . '-dtx_pageload',
|
||||
'class' => 'option'
|
||||
'class' => 'dtx_pageloadvalue option'
|
||||
)),
|
||||
esc_html__('Get the dynamic value after the page has loaded', 'contact-form-7-dynamic-text-extension'), // checkbox label
|
||||
esc_html__('May impact page performance.', 'contact-form-7-dynamic-text-extension'), // Small note below input
|
||||
esc_html('May impact page performance.', 'contact-form-7-dynamic-text-extension'), // Small note below input
|
||||
esc_attr($utm_source), //UTM source
|
||||
esc_attr($type), //UTM content
|
||||
esc_html__('View DTX page load documentation', 'contact-form-7-dynamic-text-extension') //Link label
|
||||
|
||||
);
|
||||
|
||||
// Input field - Akismet module (only available for text, email, and url fields)
|
||||
if (in_array($input_type, array('text', 'email', 'url'))) {
|
||||
switch ($input_type) {
|
||||
case 'email':
|
||||
$akismet_name = 'author_email';
|
||||
$akismet_desc = __("This field requires author's email address", 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
case 'url':
|
||||
$akismet_name = 'author_url';
|
||||
$akismet_desc = __("This field requires author's URL", 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
default:
|
||||
$akismet_name = 'author';
|
||||
$akismet_desc = __("This field requires author's name", 'contact-form-7-dynamic-text-extension');
|
||||
break;
|
||||
}
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="%s">%s</label></th><td><label><input %s />%s</label></td></tr>',
|
||||
esc_attr($options['content'] . '-readonly'), // field id
|
||||
esc_html__('Akismet', 'contact-form-7-dynamic-text-extension'), // field Label
|
||||
wpcf7_format_atts(array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'akismet:' . $akismet_name,
|
||||
'id' => $options['content'] . '-akismet-' . $akismet_name,
|
||||
'class' => 'akismetvalue option'
|
||||
)),
|
||||
esc_html($akismet_desc) // checkbox label
|
||||
);
|
||||
}
|
||||
|
||||
//Close Form-Tag Generator
|
||||
printf(
|
||||
'</tbody></table></fieldset></div><div class="insert-box"><input type="text" name="%s" class="tag code" readonly="readonly" onfocus="this.select()" /><div class="submitbox"><input type="button" class="button button-primary insert-tag" value="%s" /></div><br class="clear" /></div>',
|
||||
|
||||
+48
-438
@@ -50,9 +50,6 @@ add_filter('wpcf7dtx_allow_protocols', 'wpcf7dtx_allow_protocols', 10, 2);
|
||||
*/
|
||||
function wpcf7dtx_sanitize($value = '', $type = 'auto', $protocols = false)
|
||||
{
|
||||
if ($type == 'none') {
|
||||
return $value;
|
||||
}
|
||||
$value = is_string($value) ? $value : strval($value); // Force string value
|
||||
if (!empty($value)) {
|
||||
$type = $type == 'auto' ? wpcf7dtx_detect_value_type($value) : sanitize_text_field($type);
|
||||
@@ -65,8 +62,6 @@ function wpcf7dtx_sanitize($value = '', $type = 'auto', $protocols = false)
|
||||
return sanitize_key($value);
|
||||
case 'slug':
|
||||
return sanitize_title($value);
|
||||
case 'textarea':
|
||||
return sanitize_textarea_field($value);
|
||||
}
|
||||
}
|
||||
return sanitize_text_field($value);
|
||||
@@ -87,9 +82,6 @@ add_filter('wpcf7dtx_sanitize', 'wpcf7dtx_sanitize', 10, 3);
|
||||
*/
|
||||
function wpcf7dtx_escape($value = '', $obfuscate = false, $type = 'auto', $protocols = false)
|
||||
{
|
||||
if ($type == 'none') {
|
||||
return $value;
|
||||
}
|
||||
$value = apply_filters('wpcf7dtx_sanitize', $value, $type); // Sanitize value
|
||||
if (!empty($value)) {
|
||||
if ($obfuscate) {
|
||||
@@ -99,8 +91,6 @@ function wpcf7dtx_escape($value = '', $obfuscate = false, $type = 'auto', $proto
|
||||
switch ($type) {
|
||||
case 'url':
|
||||
return esc_url($value, apply_filters('wpcf7dtx_allow_protocols', $protocols));
|
||||
case 'textarea':
|
||||
return esc_textarea($value);
|
||||
}
|
||||
}
|
||||
return esc_attr($value); // Return attribute value
|
||||
@@ -192,449 +182,51 @@ function wpcf7dtx_get_post_id($post_id, $context = 'dtx')
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Dynamic Value
|
||||
* Parse Content for Specified Shortcodes
|
||||
*
|
||||
* @since 3.2.2
|
||||
* Parse a string of content for a specific shortcode to retrieve its attributes and content
|
||||
*
|
||||
* @param string $value The form tag value.
|
||||
* @param WPCF7_FormTag|false $tag Optional. Use to look up default value.
|
||||
* @param string $sanitize Optional. Specify type of sanitization. Default is `auto`.
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @return string The dynamic output or the original value, not escaped or sanitized.
|
||||
* @param string $content The content to parse
|
||||
* @param string $tag The shortcode tag
|
||||
*
|
||||
* @return array An associative array with `tag` (string) and `shortcodes` (sequential array). If shortcodes were discovered, each one has keys for `atts` (associative array) and `content` (string)
|
||||
*/
|
||||
function wpcf7dtx_get_dynamic($value, $tag = false, $sanitize = 'auto')
|
||||
function wpcf7dtx_get_shortcode_atts($content)
|
||||
{
|
||||
if ($tag !== false) {
|
||||
$default = $tag->get_option('defaultvalue', '', true);
|
||||
if (!$default) {
|
||||
$default = $tag->get_default_option(strval(reset($tag->values)));
|
||||
}
|
||||
$value = wpcf7_get_hangover($tag->name, $default);
|
||||
}
|
||||
$value = apply_filters('wpcf7dtx_sanitize', $value, $sanitize);
|
||||
if (is_string($value) && !empty($value)) {
|
||||
// If a shortcode was passed as the value, evaluate it and use the result
|
||||
$shortcode_tag = '[' . $value . ']';
|
||||
$shortcode_output = do_shortcode($shortcode_tag); //Shortcode value
|
||||
if (is_string($shortcode_output) && $shortcode_output != $shortcode_tag) {
|
||||
return apply_filters('wpcf7dtx_sanitize', $shortcode_output, $sanitize);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allowed HTML for Form Field Properties
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param string $type Optional. The type of input for unique properties. Default is `text`.
|
||||
* @param array $extra Optional. A sequential array of properties to additionally include.
|
||||
*
|
||||
* @return array An associative array of allowed properties appropriate for use in `wp_kses()`
|
||||
*/
|
||||
function wpcf7dtx_get_allowed_field_properties($type = 'text', $extra = array())
|
||||
{
|
||||
if (in_array($type, array('option', 'optgroup'))) {
|
||||
return array(
|
||||
'optgroup' => array(
|
||||
'label' => array(),
|
||||
'disabled' => array(),
|
||||
'hidden' => array()
|
||||
),
|
||||
'option' => array(
|
||||
'value' => array(),
|
||||
'selected' => array(),
|
||||
'disabled' => array(),
|
||||
'hidden' => array()
|
||||
)
|
||||
);
|
||||
}
|
||||
$allowed_properties = array(
|
||||
// Global properties
|
||||
'type' => array(),
|
||||
'id' => array(),
|
||||
'name' => array(),
|
||||
'value' => array(),
|
||||
'required' => array(),
|
||||
'class' => array(),
|
||||
'disabled' => array(),
|
||||
'readonly' => array(),
|
||||
'tabindex' => array(),
|
||||
'size' => array(),
|
||||
'title' => array(),
|
||||
'autofocus' => array(),
|
||||
// ARIA properties
|
||||
'aria-invalid' => array(),
|
||||
'aria-describedby' => array(),
|
||||
// DTX properties
|
||||
'data-dtx-value' => array(),
|
||||
$return = array(
|
||||
'tag' => '',
|
||||
'atts' => array()
|
||||
);
|
||||
if (in_array($type, array('checkbox', 'radio', 'acceptance'))) {
|
||||
// Properties exclusive to checkboxes and radio buttons
|
||||
$allowed_properties['checked'] = array();
|
||||
$allowed_properties['dtx-default'] = array();
|
||||
} elseif (in_array($type, array('number', 'range'))) {
|
||||
// Properties exclusive to number inputs
|
||||
$allowed_properties['step'] = array();
|
||||
} elseif ($type == 'select') {
|
||||
// Properties exclusive to select fields
|
||||
$allowed_properties['multiple'] = array();
|
||||
$allowed_properties['dtx-default'] = array();
|
||||
unset($allowed_properties['type'], $allowed_properties['value'], $allowed_properties['placeholder'], $allowed_properties['size']); // Remove invalid select attributes
|
||||
}
|
||||
if (!in_array($type, array('checkbox', 'radio', 'select', 'acceptance'))) {
|
||||
// Allowed properties for all text-based inputs
|
||||
$allowed_properties['placeholder'] = array();
|
||||
$allowed_properties['autocomplete'] = array();
|
||||
$allowed_properties['minlength'] = array();
|
||||
$allowed_properties['maxlength'] = array();
|
||||
if (in_array($type, array('number', 'range', 'date', 'datetime-local', 'time'))) {
|
||||
// Additional properties for number and date inputs
|
||||
$allowed_properties['min'] = array();
|
||||
$allowed_properties['max'] = array();
|
||||
}
|
||||
if ($type == 'textarea') {
|
||||
// Additional properties exclusive to textarea fields
|
||||
$allowed_properties['cols'] = array();
|
||||
$allowed_properties['rows'] = array();
|
||||
unset($allowed_properties['type'], $allowed_properties['value']); // Remove invalid textarea attributes
|
||||
} elseif (in_array($type, array('text', 'date', 'url', 'tel', 'email', 'password'))) {
|
||||
// Additional properties exclusive to specific text fields
|
||||
$allowed_properties['pattern'] = array();
|
||||
}
|
||||
}
|
||||
if (is_array($extra) && count($extra)) {
|
||||
foreach ($extra as $property) {
|
||||
$allowed_properties[sanitize_title($property)] = array();
|
||||
}
|
||||
}
|
||||
return $allowed_properties;
|
||||
}
|
||||
//Search for shortcodes with attributes
|
||||
if (false !== ($start = strpos($content, ' '))) {
|
||||
$return['tag'] = substr($content, 0, $start); //Opens the start tag, assumes there are attributes because of the space
|
||||
|
||||
/**
|
||||
* Returns a formatted string of HTML attributes
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $atts Associative array of attribute name and value pairs
|
||||
*
|
||||
* @return string Formatted HTML attributes with keys and values both escaped
|
||||
*/
|
||||
function wpcf7dtx_format_atts($atts)
|
||||
{
|
||||
if (is_array($atts) && count($atts)) {
|
||||
$sanitized_atts = array();
|
||||
static $boolean_attributes = array(
|
||||
'checked', 'disabled', 'multiple', 'readonly', 'required', 'selected'
|
||||
);
|
||||
foreach ($atts as $key => $value) {
|
||||
$key = sanitize_key(strval($key));
|
||||
if ($key) {
|
||||
if (in_array($key, $boolean_attributes) || is_bool($value)) {
|
||||
if ($value) {
|
||||
$sanitized_atts[$key] = $key;
|
||||
}
|
||||
} elseif ($value && (is_string($value) || is_numeric($value))) {
|
||||
$sanitized_atts[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($sanitized_atts)) {
|
||||
$output = array();
|
||||
foreach ($sanitized_atts as $key => $value) {
|
||||
$output[] = sprintf('%s="%s"', esc_attr($key), esc_attr($value));
|
||||
}
|
||||
return implode(' ', $output);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
//Parse for shortcode attributes: `shortcode att1='foo' att2='bar'`
|
||||
|
||||
/**
|
||||
* Create Input Field HTML
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $atts An associative array of input attributes.
|
||||
*
|
||||
* @return string HTML output of input field
|
||||
*/
|
||||
function wpcf7dtx_input_html($atts)
|
||||
{
|
||||
return sprintf('<input %s />', wpcf7dtx_format_atts($atts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Checkbox Field HTML
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $atts An associative array of select input attributes.
|
||||
* @param string $label_text Optional. The text to display next to the checkbox or radio button.
|
||||
* @param bool $label_ui Optional. If true, will place input and label text inside a `<label>` element. Default is true.
|
||||
* @param bool $reverse Optional. If true, will reverse the order to display the text label first then the button. Has no effect if label text is empty. Default is false.
|
||||
*
|
||||
* @return string HTML output of the checkbox or radio button or empty string on failure.
|
||||
*/
|
||||
function wpcf7dtx_checkbox_html($atts, $label_text = '', $label_ui = true, $reverse = false)
|
||||
{
|
||||
// Default field attributes
|
||||
$atts = array_merge(array('value' => '', 'dtx-default' => ''), array_change_key_case((array)$atts, CASE_LOWER));
|
||||
if ($atts['value'] && $atts['dtx-default'] && $atts['value'] == $atts['dtx-default']) {
|
||||
$atts['checked'] = 'checked';
|
||||
}
|
||||
$input = wpcf7dtx_input_html($atts);
|
||||
if (!empty(trim($label_text))) {
|
||||
$label_el = $label_ui ? 'span' : 'label'; // If not wrapping with a label element, display it next to it
|
||||
$label_text = sprintf(
|
||||
'<%1$s%2$s class="wpcf7-list-item-label">%3$s</%1$s>',
|
||||
$label_el,
|
||||
// If not wrapping with a label element and the element has an ID attribute, add a `for` attribute
|
||||
$label_ui ? '' : (wpcf7dtx_array_has_key('id', $atts) ? ' for="' . esc_attr($atts['id']) . '"' : ''),
|
||||
esc_html($label_text)
|
||||
);
|
||||
if ($reverse) {
|
||||
$html = $label_text . $input;
|
||||
} else {
|
||||
$html = $input . $label_text;
|
||||
}
|
||||
} else {
|
||||
$html = $input;
|
||||
}
|
||||
if ($label_ui) {
|
||||
$html = '<label>' . $html . '</label>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Checkbox Group HTML
|
||||
*
|
||||
* @since 4.0.3
|
||||
*
|
||||
* @param array $atts An associative array of select input attributes.
|
||||
* @param array|string $options Accepts an associative array of key/value pairs to use as the
|
||||
* select option's value/label pairs. It also accepts an associative array of associative
|
||||
* arrays with the keys being used as option group labels and the array values used as that
|
||||
* group's options. It also accepts a string value of HTML already formatted as options or
|
||||
* option groups. It also accepts a string value of a self-closing shortcode that is
|
||||
* evaluated and its output is either options or option groups.
|
||||
* @param bool $label_ui Optional. If true, will place input and label text inside a `<label>` element. Default is true.
|
||||
* @param bool $reverse Optional. If true, will reverse the order to display the text label first then the button. Has no effect if label text is empty. Default is false.
|
||||
*
|
||||
* @return string HTML output of the checkbox or radio button or empty string on failure.
|
||||
*/
|
||||
function wpcf7dtx_checkbox_group_html($atts, $options, $label_ui = false, $reverse = false, $exclusive = false)
|
||||
{
|
||||
$group_html = '';
|
||||
if ($count = count($options)) {
|
||||
// Attributes specific to HTML creation
|
||||
$atts = array_merge(array(
|
||||
'type' => 'checkbox',
|
||||
'id' => '',
|
||||
'name' => '',
|
||||
'value' => '',
|
||||
'dtx-default' => ''
|
||||
), array_change_key_case((array)$atts, CASE_LOWER));
|
||||
|
||||
// Loop all the options
|
||||
$group_html = array();
|
||||
$id_prefix = ($atts['id'] ? $atts['id'] : uniqid($atts['name'] . '_')) . '_'; // Create prefix from passed ID or Name
|
||||
$i = 1;
|
||||
foreach ($options as $value => $label) {
|
||||
$my_atts = array_merge($atts, array(
|
||||
'id' => sanitize_html_class($id_prefix . $i) // Always have unique IDs for group items
|
||||
//Chop only the attributes e.g. `att1="foo" att2="bar"`
|
||||
$atts_str = trim(str_replace($return['tag'], '', $content));
|
||||
if (strpos($atts_str, "'") !== false) {
|
||||
$atts = explode("' ", substr(
|
||||
$atts_str,
|
||||
0,
|
||||
-1 //Clip off the last character, which is a single quote
|
||||
));
|
||||
$dynamic_value = '';
|
||||
$dynamic_label = $label;
|
||||
if ($value && $label && $value === $label) {
|
||||
// These are identical, just handle it as one, could also be a raw shortcode
|
||||
$dynamic_option = trim(wpcf7dtx_get_dynamic($value, false, 'none')); // Do not sanitize yet, it may have HTML
|
||||
if (is_string($dynamic_option) && !empty($dynamic_option) && strpos($dynamic_option, '{') === 0 && strpos($dynamic_option, '}') === strlen($dynamic_option) - 1) {
|
||||
// If it outputs JSON, try parsing it
|
||||
try {
|
||||
$dynamic_option = json_decode($dynamic_option, true);
|
||||
if (is_array($dynamic_option) && count($dynamic_option)) {
|
||||
$group_html[] = wpcf7dtx_checkbox_group_html(
|
||||
$my_atts,
|
||||
$dynamic_option,
|
||||
$label_ui,
|
||||
$reverse,
|
||||
$exclusive
|
||||
);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Fail quietly
|
||||
if (WP_DEBUG && WP_DEBUG_LOG) {
|
||||
error_log('[Contact Form 7 - Dynamic Text Extension] Error parsing JSON value');
|
||||
error_log($e->getMessage());
|
||||
if (is_array($atts) && count($atts)) {
|
||||
foreach ($atts as $att_str) {
|
||||
$pair = explode("='", $att_str);
|
||||
if (is_array($pair) && count($pair) > 1) {
|
||||
$key = sanitize_key(trim($pair[0])); //Validate & normalize the key
|
||||
if (!empty($key)) {
|
||||
$return['atts'][$key] = sanitize_text_field(html_entity_decode($pair[1]));
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
continue; // Continue with next iteration
|
||||
} elseif (is_string($dynamic_option) && !empty($dynamic_option) && esc_html($dynamic_option) != $dynamic_option) {
|
||||
$group_html[] = force_balance_tags($dynamic_option); // If it outputs HTML, escape and use them as-is
|
||||
$i++;
|
||||
continue; // Continue with next iteration
|
||||
} else {
|
||||
$dynamic_value = $dynamic_option;
|
||||
$dynamic_label = $dynamic_option;
|
||||
}
|
||||
} else {
|
||||
// These are different, could be raw shortcodes
|
||||
$dynamic_value = wpcf7dtx_get_dynamic($value, false);
|
||||
$dynamic_label = wpcf7dtx_get_dynamic($label, false);
|
||||
}
|
||||
// This could be a single??
|
||||
$class = array('wpcf7-list-item');
|
||||
$class[] = sanitize_html_class('wpcf7-list-item-' . $i);
|
||||
if ($i === 1) {
|
||||
$class[] = 'first';
|
||||
}
|
||||
if ($i === $count) {
|
||||
$class[] = 'last';
|
||||
}
|
||||
if ($exclusive) {
|
||||
$class[] = 'wpcf7-exclusive-checkbox';
|
||||
}
|
||||
if ($dynamic_value && $atts['dtx-default'] && $dynamic_value == $atts['dtx-default']) {
|
||||
$my_atts['checked'] = 'checked';
|
||||
}
|
||||
$group_html[] = sprintf(
|
||||
'<span class="%s">%s</span>',
|
||||
esc_attr(implode(' ', $class)),
|
||||
wpcf7dtx_checkbox_html(
|
||||
// Overwrite name attribute
|
||||
array_merge($my_atts, array(
|
||||
'name' => $atts['type'] == 'radio' || $exclusive || $count === 1 ? $atts['name'] : $atts['name'] . '[]', // if there are multiple checkboxes and they aren't exclusive, names are an array
|
||||
'value' => $dynamic_value
|
||||
)),
|
||||
$dynamic_label,
|
||||
$label_ui,
|
||||
$reverse
|
||||
)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
$group_html = implode('', $group_html);
|
||||
}
|
||||
return $group_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Textarea Field HTML
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $atts An associative array of textarea field attributes.
|
||||
*
|
||||
* @return string HTML output of textarea field
|
||||
*/
|
||||
function wpcf7dtx_textarea_html($atts)
|
||||
{
|
||||
// Attributes specific to HTML creation
|
||||
$atts = array_merge(array('value' => ''), array_change_key_case((array)$atts, CASE_LOWER));
|
||||
return sprintf(
|
||||
'<textarea %s>%s</textarea>',
|
||||
wpcf7dtx_format_atts($atts),
|
||||
apply_filters('wpcf7dtx_escape', $atts['value'], false, 'textarea')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Select Field HTML
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $atts An associative array of select input attributes.
|
||||
* @param array|string $options Accepts an associative array of key/value pairs to use as the
|
||||
* select option's value/label pairs. It also accepts an associative array of associative
|
||||
* arrays with the keys being used as option group labels and the array values used as that
|
||||
* group's options. It also accepts a string value of HTML already formatted as options or
|
||||
* option groups. It also accepts a string value of a self-closing shortcode that is
|
||||
* evaluated and its output is either options or option groups.
|
||||
* @param bool $hide_blank Optional. If true, the first blank placeholder option will have the `hidden` attribute added to it. Default is false.
|
||||
* @param bool $disable_blank Optional. If true, the first blank placeholder option will have the `disabled` attribute added to it. Default is false.
|
||||
*
|
||||
* @return string HTML output of select field
|
||||
*/
|
||||
function wpcf7dtx_select_html($atts, $options, $hide_blank = false, $disable_blank = false)
|
||||
{
|
||||
// Attributes specific to HTML creation
|
||||
$atts = array_merge(array('placeholder' => '', 'dtx-default' => ''), array_change_key_case((array)$atts, CASE_LOWER));
|
||||
$options_html = ''; // Open options HTML
|
||||
|
||||
// If using a placeholder, use it as the text of the first option
|
||||
if ($atts['placeholder']) {
|
||||
$options_html .= sprintf(
|
||||
'<option value=""%s%s%s>%s</option>',
|
||||
empty($atts['dtx-default']) ? ' selected' : '',
|
||||
$hide_blank ? ' hidden' : '',
|
||||
$disable_blank ? ' disabled' : '',
|
||||
apply_filters('wpcf7dtx_escape', $atts['placeholder'])
|
||||
);
|
||||
}
|
||||
if (is_array($options) && count($options)) {
|
||||
//Check if using option groups
|
||||
if (is_array(array_values($options)[0])) {
|
||||
foreach ($options as $group_name => $opt_group) {
|
||||
$options_html .= sprintf('<optgroup label="%s">', esc_attr(apply_filters('wpcf7dtx_escape', wpcf7dtx_get_dynamic($group_name)))); // Open option group
|
||||
foreach ($opt_group as $option_value => $option_label) {
|
||||
// Check if option values and groups are dynamic
|
||||
$dynamic_option_value = wpcf7dtx_get_dynamic($option_value);
|
||||
$options_html .= sprintf(
|
||||
'<option value="%1$s"%3$s>%2$s</option>',
|
||||
esc_attr(apply_filters('wpcf7dtx_escape', $dynamic_option_value)),
|
||||
esc_html(apply_filters('wpcf7dtx_escape', wpcf7dtx_get_dynamic($option_label))),
|
||||
$atts['dtx-default'] == $dynamic_option_value ? ' selected' : ''
|
||||
);
|
||||
}
|
||||
$options_html .= '</optgroup>'; // Close option group
|
||||
}
|
||||
} else {
|
||||
$allowed_html = wpcf7dtx_get_allowed_field_properties('option');
|
||||
foreach ($options as $option_value => $option_label) {
|
||||
if ($option_value === $option_label) {
|
||||
// These are identical, just handle it as one, could also be a raw shortcode
|
||||
$dynamic_option = trim(wpcf7dtx_get_dynamic($option_value, false, 'none')); // Do not sanitize yet, it may have HTML
|
||||
if (is_string($dynamic_option) && !empty($dynamic_option) && (strpos($dynamic_option, '<option') === 0 || stripos($dynamic_option, '<optgroup') === 0)) {
|
||||
$options_html .= wp_kses($dynamic_option, $allowed_html); // If it outputs HTML, escape and use them as-is
|
||||
} elseif ($dynamic_option) {
|
||||
// Just output the option
|
||||
$dynamic_option = apply_filters('wpcf7dtx_escape', $dynamic_option);
|
||||
$options_html .= sprintf(
|
||||
'<option value="%1$s"%3$s>%2$s</option>',
|
||||
esc_attr($dynamic_option),
|
||||
esc_html($dynamic_option),
|
||||
$atts['dtx-default'] == $dynamic_option ? ' selected' : ''
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$dynamic_option_value = wpcf7dtx_get_dynamic($option_value, false);
|
||||
$options_html .= sprintf(
|
||||
'<option value="%1$s"%3$s>%2$s</option>',
|
||||
esc_attr(apply_filters('wpcf7dtx_escape', $dynamic_option_value)),
|
||||
esc_html(apply_filters('wpcf7dtx_escape', wpcf7dtx_get_dynamic($option_label))),
|
||||
$atts['dtx-default'] == $dynamic_option_value ? ' selected' : ''
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (is_string($options) && !empty($options = trim($options))) {
|
||||
$allowed_html = wpcf7dtx_get_allowed_field_properties('option');
|
||||
// If options were passed as a string, go ahead and use them
|
||||
if (strpos($options, '<option') === 0 || stripos($options, '<optgroup') === 0) {
|
||||
$options_html .= wp_kses($options, $allowed_html);
|
||||
} else {
|
||||
// If a shortcode was passed as the options, evaluate it and use the result
|
||||
$shortcode_output = wpcf7dtx_get_dynamic($options);
|
||||
if (is_string($shortcode_output) && !empty($shortcode_output) && (strpos($shortcode_output, '<option') === 0) || strpos($shortcode_output, '<optgroup') === 0) {
|
||||
$options_html .= wp_kses($shortcode_output, $allowed_html);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sprintf('<select %s>%s</select>', wpcf7dtx_format_atts($atts), $options_html);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,3 +253,21 @@ function wpcf7dtx_array_has_key($key, $array = array(), $default = '')
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (!function_exists('array_key_first')) {
|
||||
/**
|
||||
* Gets the first key of an array
|
||||
*
|
||||
* Gets the first key of the given array without affecting the internal array pointer.
|
||||
*
|
||||
* @param array $array
|
||||
* @return int|string|null
|
||||
*/
|
||||
function array_key_first($array = array())
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
return $key;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Add Frontend Validation Messages
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array An associative array of messages
|
||||
*
|
||||
* @return array A modified associative array of messages
|
||||
*/
|
||||
function wpcf7dtx_messages($messages)
|
||||
{
|
||||
return array_merge($messages, array(
|
||||
'dtx_invalid_email' => array(
|
||||
'description' => __('There is a field with an invalid email address', 'contact-form-7-dynamic-text-extension'),
|
||||
'default' => __('Please enter a valid email address.', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dtx_invalid_tel' => array(
|
||||
'description' => __('There is a field with an invalid phone number', 'contact-form-7-dynamic-text-extension'),
|
||||
'default' => __('Please enter a valid phone number.', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dtx_invalid_number' => array(
|
||||
'description' => __('There is a field with an invalid number', 'contact-form-7-dynamic-text-extension'),
|
||||
'default' => __('Please enter a valid number.', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
'dtx_invalid_date' => array(
|
||||
'description' => __('There is a field with an invalid date', 'contact-form-7-dynamic-text-extension'),
|
||||
'default' => __('Please enter a valid date.', 'contact-form-7-dynamic-text-extension')
|
||||
),
|
||||
));
|
||||
}
|
||||
add_filter('wpcf7_messages', 'wpcf7dtx_messages');
|
||||
|
||||
/**
|
||||
* Validate DTX Form Fields
|
||||
*
|
||||
* Frontend validation for DTX form tags
|
||||
*
|
||||
* @param WPCF7_Validation $result the current validation result object
|
||||
* @param WPCF7_FormTag $tag the current form tag being filtered for validation
|
||||
*
|
||||
* @return WPCF7_Validation a possibly modified validation result object
|
||||
*/
|
||||
function wpcf7dtx_validation_filter($result, $tag)
|
||||
{
|
||||
$type = str_replace(array('dynamic_', 'dynamic'), '', $tag->basetype);
|
||||
if (empty($tag->name) || in_array($type, array('hidden', 'submit', 'reset'))) {
|
||||
return $result; // Bail early for tags without names or if a specific type
|
||||
}
|
||||
|
||||
// Get the value
|
||||
$user_value = wpcf7dtx_array_has_key($tag->name, $_POST);
|
||||
if (is_array($user_value)) {
|
||||
$selection_count = count($user_value);
|
||||
if (!wpcf7_form_tag_supports($tag->type, 'selectable-values')) {
|
||||
// Field passed selectable values when it's doesn't support them
|
||||
$result->invalidate($tag, wpcf7_get_message('validation_error'));
|
||||
return $result;
|
||||
} elseif ($selection_count > 1) {
|
||||
if (!wpcf7_form_tag_supports($tag->type, 'multiple-controls-container')) {
|
||||
// Field passed multiple values when it's doesn't support them
|
||||
$result->invalidate($tag, wpcf7_get_message('validation_error'));
|
||||
return $result;
|
||||
}
|
||||
foreach ($user_value as $selection) {
|
||||
// Validate each selected choice
|
||||
$result = wpcf7dtx_validate_value($result, sanitize_textarea_field(strval($selection)), $tag, $type);
|
||||
if (!$result->is_valid($tag->name)) {
|
||||
return $result; // Return early if any are invalid
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
$user_value = sanitize_text_field(strval(implode(' ', $user_value)));
|
||||
} elseif ($type == 'textarea') {
|
||||
$user_value = sanitize_textarea_field(strval($user_value));
|
||||
} else {
|
||||
$user_value = sanitize_text_field(strval($user_value));
|
||||
}
|
||||
// Validate and return
|
||||
return wpcf7dtx_validate_value($result, $user_value, $tag, $type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate Single Value
|
||||
*
|
||||
* @param WPCF7_Validation $result the current validation result object
|
||||
* @param string $value the current value being validated, sanitized
|
||||
* @param WPCF7_FormTag $tag the current form tag being filtered for validation
|
||||
* @param string $type Optional. The type of the current form tag. Default is blank for lookup.
|
||||
*
|
||||
* @return WPCF7_Validation a possibly modified validation result object
|
||||
*/
|
||||
function wpcf7dtx_validate_value($result, $value, $tag, $type = '')
|
||||
{
|
||||
$type = $type ? $type : str_replace(array('dynamic_', 'dynamic'), '', $tag->basetype);
|
||||
|
||||
// Validate required fields for value
|
||||
if ($tag->is_required() && empty($value)) {
|
||||
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Validate value by type
|
||||
if (!empty($value)) {
|
||||
switch ($type) {
|
||||
case 'email':
|
||||
if (!wpcf7_is_email($value)) {
|
||||
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_email'));
|
||||
return $result;
|
||||
}
|
||||
break;
|
||||
case 'tel':
|
||||
if (!wpcf7_is_tel($value)) {
|
||||
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_tel'));
|
||||
return $result;
|
||||
}
|
||||
break;
|
||||
case 'number':
|
||||
case 'range':
|
||||
if (!wpcf7_is_number($value)) {
|
||||
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_number'));
|
||||
return $result;
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
if (!wpcf7_is_date($value)) {
|
||||
$result->invalidate($tag, wpcf7_get_message('dtx_invalid_date'));
|
||||
return $result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Finish validating text-based inputs
|
||||
$maxlength = $tag->get_maxlength_option();
|
||||
$minlength = $tag->get_minlength_option();
|
||||
if ($maxlength && $minlength && $maxlength < $minlength) {
|
||||
$maxlength = $minlength = null;
|
||||
}
|
||||
$code_units = wpcf7_count_code_units($value);
|
||||
if (false !== $code_units) {
|
||||
if ($maxlength && $maxlength < $code_units) {
|
||||
$result->invalidate($tag, wpcf7_get_message('invalid_too_long'));
|
||||
return $result;
|
||||
} elseif ($minlength && $code_units < $minlength) {
|
||||
$result->invalidate($tag, wpcf7_get_message('invalid_too_short'));
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backend Mail Configuration Validation
|
||||
*
|
||||
* Validate dynamic form tags used in mail configuration.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param WPCF7_ConfigValidator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpcf7dtx_validate($validator)
|
||||
{
|
||||
if (!$validator->is_valid()) {
|
||||
$contact_form = null;
|
||||
$form_tags = null;
|
||||
foreach ($validator->collect_error_messages() as $component => $errors) {
|
||||
$components = explode('.', $component);
|
||||
if (count($components) === 2 && strpos($components[0], 'mail') === 0 && in_array($components[1], array('sender', 'recipient', 'additional_headers'))) {
|
||||
foreach ($errors as $error) {
|
||||
// Focus on email fields that flag the invalid mailbox syntax warning, have to test link because code isn't sent and message could be in any language
|
||||
if (strpos(wpcf7dtx_array_has_key('link', $error), 'invalid-mailbox-syntax') !== false) {
|
||||
if (is_null($contact_form)) {
|
||||
$contact_form = $validator->contact_form();
|
||||
}
|
||||
if (is_null($form_tags)) {
|
||||
$form_tags = wpcf7_scan_form_tags();
|
||||
}
|
||||
$raw_value = $contact_form->prop($components[0])[$components[1]];
|
||||
foreach ($form_tags as $tag) {
|
||||
if (!empty($tag->name)) {
|
||||
// Check if this form tag is in the raw value
|
||||
$form_tag = '[' . $tag->name . ']';
|
||||
if (strpos($raw_value, $form_tag) !== false && in_array($tag->basetype, array_keys(wpcf7dtx_config()))) {
|
||||
$validator->remove_error($component, 'invalid_mailbox_syntax'); // Remove error, this is ours to handle now
|
||||
$utm_source = urlencode(home_url());
|
||||
if (!in_array($tag->basetype, array('dynamic_hidden', 'dynamic_email'))) {
|
||||
$validator->add_error($component, 'invalid_mailbox_syntax', array(
|
||||
'message' => __('Only email, dynamic email, hidden, or dynamic hidden form tags can be used for email addresses.', 'contact-form-7-dynamic-text-extension'),
|
||||
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-invalid_mailbox_syntax#valid-form-tags', $utm_source))
|
||||
));
|
||||
} else {
|
||||
$dynamic_value = wpcf7dtx_get_dynamic(false, $tag); // Get the dynamic value of this tag
|
||||
if (empty($dynamic_value) && $tag->basetype == 'dynamic_hidden') {
|
||||
$validator->add_error($component, 'maybe_empty', array(
|
||||
'message' => __('The dynamic hidden form tag must have a default value.', 'contact-form-7-dynamic-text-extension'),
|
||||
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-maybe_empty#maybe-empty', $utm_source))
|
||||
));
|
||||
} elseif (empty($dynamic_value) && !$tag->is_required()) {
|
||||
$validator->add_error($component, 'maybe_empty', array(
|
||||
'message' => __('The dynamic form tag must be required or have a default value.', 'contact-form-7-dynamic-text-extension'),
|
||||
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-maybe_empty#maybe-empty', $utm_source))
|
||||
));
|
||||
} elseif (!empty($dynamic_value)) {
|
||||
if (!wpcf7_is_email($dynamic_value)) {
|
||||
$validator->add_error($component, 'invalid_mailbox_syntax', array(
|
||||
'message' => __('The default dynamic value does not result in a valid email address.', 'contact-form-7-dynamic-text-extension'),
|
||||
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-invalid_mailbox_syntax#invalid-email-address', $utm_source))
|
||||
));
|
||||
} elseif ($component[1] == 'sender' && !wpcf7_is_email_in_site_domain($dynamic_value)) {
|
||||
$validator->add_error($component, 'email_not_in_site_domain', array(
|
||||
'message' => __('The dynamic email address for the sender does not belong to the site domain.', 'contact-form-7-dynamic-text-extension'),
|
||||
'link' => esc_url(sprintf('https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/configuration-errors/?utm_source=%s&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=config-error-email_not_in_site_domain#invalid-site-domain', $utm_source))
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action('wpcf7_config_validator_validate', 'wpcf7dtx_validate');
|
||||
@@ -1 +0,0 @@
|
||||
<?php // Silence is golden
|
||||
@@ -3,9 +3,9 @@ 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.3
|
||||
Stable tag: 4.1.0
|
||||
Stable tag: 3.5.4
|
||||
|
||||
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.
|
||||
This plugin provides additional form tags for the Contact Form 7 plugin. It allows dynamic generation of content for text or hidden input fields using any shortcode.
|
||||
|
||||
== Description ==
|
||||
|
||||
@@ -25,25 +25,11 @@ Contact Form 7 is an excellent WordPress plugin and one of the top choices of fr
|
||||
* Getting custom theme modifications
|
||||
* Any value using custom shortcodes
|
||||
|
||||
For over 10 years, DTX only handled `<input type="text" />` and `<input type="hidden" />` form fields, but version 4 finally introduces more:
|
||||
|
||||
* email
|
||||
* URL
|
||||
* tel (for phone numbers)
|
||||
* number
|
||||
* range (slider)
|
||||
* textarea (multiline text)
|
||||
* drop-down menu (select field)
|
||||
* checkboxes
|
||||
* radio buttons
|
||||
* date
|
||||
* submit (yes, a submit button where you can have dynamic text!)
|
||||
|
||||
The possibilities are endless!
|
||||
|
||||
## WHAT DOES IT DO? ##
|
||||
|
||||
DTX provides flexibility to WordPress users in creating dynamic forms in Contact Form 7. DTX comes with several built-in shortcodes that will allow the contact form to be populated from HTTPS GET variable or any info from the `get_bloginfo()` function, among others. See below for included shortcodes.
|
||||
DTX comes with several built-in shortcodes that will allow the contact form to be populated from HTTPS GET variable or any info from the `get_bloginfo()` function, among others. See below for included shortcodes.
|
||||
|
||||
Don't see the shortcode you need on the list? You can write a [custom one](https://aurisecreative.com/docs/contact-form-7-dynamic-text-extension/shortcodes/custom-shortcodes/?utm_source=wordpress.org&utm_medium=link&utm_campaign=contact-form-7-dynamic-text-extension&utm_content=readme)! Any shortcode that returns a string or numeric value can be used here. The included shortcodes just cover the most common scenarios, but DTX provides the flexibility for you to grab any value you have access to programmatically.
|
||||
|
||||
@@ -355,20 +341,9 @@ This method is the most involved as it requires you to be familiar with the proc
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Screenshot of the form tag buttons in the form editor of Contact Form 7. The dynamic buttons appear in purple instead of blue to visually set them apart.
|
||||
1. Screenshot of the form tag buttons in the form editor of Contact Form 7. A red square highlights the addition of two new buttons for "dynamic text" and "dynamic hidden"
|
||||
2. The form tag generator screen for the dynamic text form tag
|
||||
3. The form tag generator screen for the dynamic hidden form tag
|
||||
4. The form tag generator screen for the dynamic email form tag
|
||||
5. The form tag generator screen for the dynamic URL form tag
|
||||
6. The form tag generator screen for the dynamic phone number (tel) form tag
|
||||
7. The form tag generator screen for the dynamic number spinbox form tag
|
||||
8. The form tag generator screen for the dynamic sliding range form tag
|
||||
9. The form tag generator screen for the dynamic textarea form tag
|
||||
10. The form tag generator screen for the dynamic drop-down menu (select) form tag
|
||||
11. The form tag generator screen for the dynamic checkboxes form tag
|
||||
12. The form tag generator screen for the dynamic radio buttons form tag
|
||||
13. The form tag generator screen for the dynamic date form tag
|
||||
14. The form tag generator screen for the dynamic submit form tag
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
@@ -376,53 +351,111 @@ Please check out the [FAQ on our website](https://aurisecreative.com/docs/contac
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 4.1.0 =
|
||||
Extend functionality without losing your work!
|
||||
= 3.5.3 =
|
||||
Optimized JavaScript used in cache compatibility mode.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 4.1.0 =
|
||||
= 3.5.4 =
|
||||
|
||||
* 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/)
|
||||
* Fix: Updated JavaScript to prevent cacheable fields from making unnecessary AJAX requests
|
||||
|
||||
= 4.0.3 =
|
||||
= 3.5.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
|
||||
* Update: removed the use of sessions, [see support thread](https://wordpress.org/support/topic/add-option-to-disable-session-data/)
|
||||
|
||||
= 4.0.2 =
|
||||
= 3.5.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.
|
||||
* 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
|
||||
|
||||
= 4.0.1 =
|
||||
= 3.5.1 =
|
||||
|
||||
* Fix: addressed bug that prevented translation for cache compatibility description
|
||||
* 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
|
||||
|
||||
= 4.0.0 =
|
||||
= 3.5.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
|
||||
* 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: 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`
|
||||
|
||||
= Older Releases =
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
|
||||
<?php
|
||||
if ( ! empty( $args['use'] ) ) :
|
||||
?>
|
||||
<label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" data-config-field="" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
|
||||
<label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
|
||||
<p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action(
|
||||
'wpcf7_update_option',
|
||||
'wpcf7_config_validator_update_option',
|
||||
10, 3
|
||||
);
|
||||
|
||||
/**
|
||||
* Runs bulk validation after the reCAPTCHA integration option is updated.
|
||||
*/
|
||||
function wpcf7_config_validator_update_option( $name, $value, $old_option ) {
|
||||
if ( 'recaptcha' === $name ) {
|
||||
$contact_forms = WPCF7_ContactForm::find();
|
||||
|
||||
$options = array(
|
||||
'include' => 'unsafe_email_without_protection',
|
||||
);
|
||||
|
||||
foreach ( $contact_forms as $contact_form ) {
|
||||
$config_validator = new WPCF7_ConfigValidator( $contact_form, $options );
|
||||
$config_validator->restore();
|
||||
$config_validator->validate();
|
||||
$config_validator->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-15
@@ -6,22 +6,17 @@ trait WPCF7_ConfigValidator_AdditionalSettings {
|
||||
* Runs error detection for the additional settings section.
|
||||
*/
|
||||
public function validate_additional_settings() {
|
||||
$section = 'additional_settings.body';
|
||||
$deprecated_settings_used =
|
||||
$this->contact_form->additional_setting( 'on_sent_ok' ) ||
|
||||
$this->contact_form->additional_setting( 'on_submit' );
|
||||
|
||||
if ( $this->supports( 'deprecated_settings' ) ) {
|
||||
$deprecated_settings_used =
|
||||
$this->contact_form->additional_setting( 'on_sent_ok' ) ||
|
||||
$this->contact_form->additional_setting( 'on_submit' );
|
||||
|
||||
if ( $deprecated_settings_used ) {
|
||||
$this->add_error( $section, 'deprecated_settings',
|
||||
array(
|
||||
'message' => __( "Deprecated settings are used.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'deprecated_settings' );
|
||||
}
|
||||
if ( $deprecated_settings_used ) {
|
||||
return $this->add_error( 'additional_settings.body',
|
||||
'deprecated_settings',
|
||||
array(
|
||||
'message' => __( "Deprecated settings are used.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,83 +8,12 @@ trait WPCF7_ConfigValidator_Form {
|
||||
public function validate_form() {
|
||||
$section = 'form.body';
|
||||
$form = $this->contact_form->prop( 'form' );
|
||||
|
||||
if ( $this->supports( 'multiple_controls_in_label' ) ) {
|
||||
if ( $this->detect_multiple_controls_in_label( $section, $form ) ) {
|
||||
$this->add_error( $section, 'multiple_controls_in_label',
|
||||
array(
|
||||
'message' => __( "Multiple form controls are in a single label element.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'multiple_controls_in_label' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'unavailable_names' ) ) {
|
||||
$ng_names = $this->detect_unavailable_names( $section, $form );
|
||||
|
||||
if ( $ng_names ) {
|
||||
$this->add_error( $section, 'unavailable_names',
|
||||
array(
|
||||
'message' =>
|
||||
/* translators: %names%: a list of form control names */
|
||||
__( "Unavailable names (%names%) are used for form controls.", 'contact-form-7' ),
|
||||
'params' => array( 'names' => implode( ', ', $ng_names ) ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'unavailable_names' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'unavailable_html_elements' ) ) {
|
||||
if ( $this->detect_unavailable_html_elements( $section, $form ) ) {
|
||||
$this->add_error( $section, 'unavailable_html_elements',
|
||||
array(
|
||||
'message' => __( "Unavailable HTML elements are used in the form template.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'unavailable_html_elements' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'dots_in_names' ) ) {
|
||||
if ( $this->detect_dots_in_names( $section, $form ) ) {
|
||||
$this->add_error( $section, 'dots_in_names',
|
||||
array(
|
||||
'message' => __( "Dots are used in form-tag names.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'dots_in_names' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'colons_in_names' ) ) {
|
||||
if ( $this->detect_colons_in_names( $section, $form ) ) {
|
||||
$this->add_error( $section, 'colons_in_names',
|
||||
array(
|
||||
'message' => __( "Colons are used in form-tag names.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'colons_in_names' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'upload_filesize_overlimit' ) ) {
|
||||
if ( $this->detect_upload_filesize_overlimit( $section, $form ) ) {
|
||||
$this->add_error( $section, 'upload_filesize_overlimit',
|
||||
array(
|
||||
'message' => __( "Uploadable file size exceeds PHP’s maximum acceptable size.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'upload_filesize_overlimit' );
|
||||
}
|
||||
}
|
||||
$this->detect_multiple_controls_in_label( $section, $form );
|
||||
$this->detect_unavailable_names( $section, $form );
|
||||
$this->detect_unavailable_html_elements( $section, $form );
|
||||
$this->detect_dots_in_names( $section, $form );
|
||||
$this->detect_colons_in_names( $section, $form );
|
||||
$this->detect_upload_filesize_overlimit( $section, $form );
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +54,12 @@ trait WPCF7_ConfigValidator_Form {
|
||||
}
|
||||
|
||||
if ( 1 < $fields_count ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'multiple_controls_in_label',
|
||||
array(
|
||||
'message' => __( "Multiple form controls are in a single label element.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +98,17 @@ trait WPCF7_ConfigValidator_Form {
|
||||
}
|
||||
|
||||
if ( $ng_names ) {
|
||||
return array_unique( $ng_names );
|
||||
$ng_names = array_unique( $ng_names );
|
||||
|
||||
return $this->add_error( $section,
|
||||
'unavailable_names',
|
||||
array(
|
||||
'message' =>
|
||||
/* translators: %names%: a list of form control names */
|
||||
__( "Unavailable names (%names%) are used for form controls.", 'contact-form-7' ),
|
||||
'params' => array( 'names' => implode( ', ', $ng_names ) ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -180,7 +124,12 @@ trait WPCF7_ConfigValidator_Form {
|
||||
$pattern = '%(?:<form[\s\t>]|</form>)%i';
|
||||
|
||||
if ( preg_match( $pattern, $content ) ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'unavailable_html_elements',
|
||||
array(
|
||||
'message' => __( "Unavailable HTML elements are used in the form template.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -201,7 +150,12 @@ trait WPCF7_ConfigValidator_Form {
|
||||
|
||||
foreach ( $tags as $tag ) {
|
||||
if ( str_contains( $tag->raw_name, '.' ) ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'dots_in_names',
|
||||
array(
|
||||
'message' => __( "Dots are used in form-tag names.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +177,12 @@ trait WPCF7_ConfigValidator_Form {
|
||||
|
||||
foreach ( $tags as $tag ) {
|
||||
if ( str_contains( $tag->raw_name, ':' ) ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'colons_in_names',
|
||||
array(
|
||||
'message' => __( "Colons are used in form-tag names.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +227,12 @@ trait WPCF7_ConfigValidator_Form {
|
||||
|
||||
foreach ( $tags as $tag ) {
|
||||
if ( $upload_max_filesize < $tag->get_limit_option() ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'upload_filesize_overlimit',
|
||||
array(
|
||||
'message' => __( "Uploadable file size exceeds PHP’s maximum acceptable size.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,27 +2,11 @@
|
||||
|
||||
trait WPCF7_ConfigValidator_Mail {
|
||||
|
||||
/**
|
||||
* Replaces all mail-tags in the given content.
|
||||
*/
|
||||
public function replace_mail_tags( $content, $args = '' ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'html' => false,
|
||||
'callback' =>
|
||||
array( $this, 'replace_mail_tags_with_minimum_input_callback' ),
|
||||
) );
|
||||
|
||||
$content = new WPCF7_MailTaggedText( $content, $args );
|
||||
|
||||
return $content->replace_tags();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback function for WPCF7_MailTaggedText. Replaces mail-tags with
|
||||
* the most conservative inputs.
|
||||
*/
|
||||
public function replace_mail_tags_with_minimum_input_callback( $matches ) {
|
||||
public function replace_mail_tags_with_minimum_input( $matches ) {
|
||||
// allow [[foo]] syntax for escaping a tag
|
||||
if ( $matches[1] === '[' and $matches[4] === ']' ) {
|
||||
return substr( $matches[0], 1, -1 );
|
||||
@@ -140,253 +124,109 @@ trait WPCF7_ConfigValidator_Mail {
|
||||
'attachments' => '',
|
||||
) );
|
||||
|
||||
$this->validate_mail_subject(
|
||||
$template,
|
||||
$components['subject']
|
||||
$callback = array( $this, 'replace_mail_tags_with_minimum_input' );
|
||||
|
||||
$subject = new WPCF7_MailTaggedText(
|
||||
$components['subject'],
|
||||
array( 'callback' => $callback )
|
||||
);
|
||||
|
||||
$this->validate_mail_sender(
|
||||
$template,
|
||||
$components['sender']
|
||||
$subject = $subject->replace_tags();
|
||||
$subject = wpcf7_strip_newline( $subject );
|
||||
|
||||
$this->detect_maybe_empty( sprintf( '%s.subject', $template ), $subject );
|
||||
|
||||
$sender = new WPCF7_MailTaggedText(
|
||||
$components['sender'],
|
||||
array( 'callback' => $callback )
|
||||
);
|
||||
|
||||
$this->validate_mail_recipient(
|
||||
$template,
|
||||
$components['recipient']
|
||||
$sender = $sender->replace_tags();
|
||||
$sender = wpcf7_strip_newline( $sender );
|
||||
|
||||
$invalid_mailbox = $this->detect_invalid_mailbox_syntax(
|
||||
sprintf( '%s.sender', $template ),
|
||||
$sender
|
||||
);
|
||||
|
||||
$this->validate_mail_additional_headers(
|
||||
$template,
|
||||
$components['additional_headers']
|
||||
);
|
||||
|
||||
$this->validate_mail_body(
|
||||
$template,
|
||||
$components['body']
|
||||
);
|
||||
|
||||
$this->validate_mail_attachments(
|
||||
$template,
|
||||
$components['attachments']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs error detection for the mail subject section.
|
||||
*/
|
||||
public function validate_mail_subject( $template, $content ) {
|
||||
$section = sprintf( '%s.subject', $template );
|
||||
|
||||
if ( $this->supports( 'maybe_empty' ) ) {
|
||||
if ( $this->detect_maybe_empty( $section, $content ) ) {
|
||||
$this->add_error( $section, 'maybe_empty',
|
||||
array(
|
||||
'message' => __( "There is a possible empty field.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'maybe_empty' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs error detection for the mail sender section.
|
||||
*/
|
||||
public function validate_mail_sender( $template, $content ) {
|
||||
$section = sprintf( '%s.sender', $template );
|
||||
|
||||
if ( $this->supports( 'invalid_mailbox_syntax' ) ) {
|
||||
if ( $this->detect_invalid_mailbox_syntax( $section, $content ) ) {
|
||||
$this->add_error( $section, 'invalid_mailbox_syntax',
|
||||
array(
|
||||
'message' => __( "Invalid mailbox syntax is used.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'invalid_mailbox_syntax' );
|
||||
}
|
||||
if ( ! $invalid_mailbox and ! wpcf7_is_email_in_site_domain( $sender ) ) {
|
||||
$this->add_error( sprintf( '%s.sender', $template ),
|
||||
'email_not_in_site_domain',
|
||||
array(
|
||||
'message' => __( "Sender email address does not belong to the site domain.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( $this->supports( 'email_not_in_site_domain' ) ) {
|
||||
$this->remove_error( $section, 'email_not_in_site_domain' );
|
||||
$recipient = new WPCF7_MailTaggedText(
|
||||
$components['recipient'],
|
||||
array( 'callback' => $callback )
|
||||
);
|
||||
|
||||
if ( ! $this->has_error( $section, 'invalid_mailbox_syntax' ) ) {
|
||||
$sender = $this->replace_mail_tags( $content );
|
||||
$sender = wpcf7_strip_newline( $sender );
|
||||
$recipient = $recipient->replace_tags();
|
||||
$recipient = wpcf7_strip_newline( $recipient );
|
||||
|
||||
if ( ! wpcf7_is_email_in_site_domain( $sender ) ) {
|
||||
$this->add_error( $section, 'email_not_in_site_domain',
|
||||
array(
|
||||
'message' => __( "Sender email address does not belong to the site domain.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->detect_invalid_mailbox_syntax(
|
||||
sprintf( '%s.recipient', $template ),
|
||||
$recipient
|
||||
);
|
||||
|
||||
$additional_headers = new WPCF7_MailTaggedText(
|
||||
$components['additional_headers'],
|
||||
array( 'callback' => $callback )
|
||||
);
|
||||
|
||||
/**
|
||||
* Runs error detection for the mail recipient section.
|
||||
*/
|
||||
public function validate_mail_recipient( $template, $content ) {
|
||||
$section = sprintf( '%s.recipient', $template );
|
||||
$additional_headers = $additional_headers->replace_tags();
|
||||
$additional_headers = explode( "\n", $additional_headers );
|
||||
$mailbox_header_types = array( 'reply-to', 'cc', 'bcc' );
|
||||
$invalid_mail_header_exists = false;
|
||||
|
||||
if ( $this->supports( 'invalid_mailbox_syntax' ) ) {
|
||||
if ( $this->detect_invalid_mailbox_syntax( $section, $content ) ) {
|
||||
$this->add_error( $section, 'invalid_mailbox_syntax',
|
||||
array(
|
||||
'message' => __( "Invalid mailbox syntax is used.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'invalid_mailbox_syntax' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'unsafe_email_without_protection' ) ) {
|
||||
$this->remove_error( $section, 'unsafe_email_without_protection' );
|
||||
|
||||
if ( ! $this->has_error( $section, 'invalid_mailbox_syntax' ) ) {
|
||||
if (
|
||||
$this->detect_unsafe_email_without_protection( $section, $content )
|
||||
) {
|
||||
$this->add_error( $section, 'unsafe_email_without_protection',
|
||||
array(
|
||||
'message' => __( "Unsafe email config is used without sufficient protection.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs error detection for the mail additional headers section.
|
||||
*/
|
||||
public function validate_mail_additional_headers( $template, $content ) {
|
||||
$section = sprintf( '%s.additional_headers', $template );
|
||||
|
||||
$invalid_mail_headers = array();
|
||||
$invalid_mailbox_fields = array();
|
||||
$unsafe_email_fields = array();
|
||||
|
||||
foreach ( explode( "\n", $content ) as $header ) {
|
||||
foreach ( $additional_headers as $header ) {
|
||||
$header = trim( $header );
|
||||
|
||||
if ( '' === $header ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$is_valid_header = preg_match(
|
||||
'/^([0-9A-Za-z-]+):(.*)$/',
|
||||
$header,
|
||||
$matches
|
||||
);
|
||||
|
||||
if ( ! $is_valid_header ) {
|
||||
$invalid_mail_headers[] = $header;
|
||||
continue;
|
||||
}
|
||||
|
||||
$header_name = $matches[1];
|
||||
$header_value = trim( $matches[2] );
|
||||
|
||||
if (
|
||||
in_array(
|
||||
strtolower( $header_name ), array( 'reply-to', 'cc', 'bcc' )
|
||||
) and
|
||||
'' !== $header_value and
|
||||
$this->detect_invalid_mailbox_syntax( $section, $header_value )
|
||||
) {
|
||||
$invalid_mailbox_fields[] = $header_name;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
in_array( strtolower( $header_name ), array( 'cc', 'bcc' ) ) and
|
||||
$this->detect_unsafe_email_without_protection( $section, $header_value )
|
||||
) {
|
||||
$unsafe_email_fields[] = $header_name;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'invalid_mail_header' ) ) {
|
||||
if ( ! empty( $invalid_mail_headers ) ) {
|
||||
$this->add_error( $section, 'invalid_mail_header',
|
||||
array(
|
||||
'message' => __( "There are invalid mail header fields.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
if ( ! preg_match( '/^([0-9A-Za-z-]+):(.*)$/', $header, $matches ) ) {
|
||||
$invalid_mail_header_exists = true;
|
||||
} else {
|
||||
$this->remove_error( $section, 'invalid_mail_header' );
|
||||
}
|
||||
}
|
||||
$header_name = $matches[1];
|
||||
$header_value = trim( $matches[2] );
|
||||
|
||||
if ( $this->supports( 'invalid_mailbox_syntax' ) ) {
|
||||
if ( ! empty( $invalid_mailbox_fields ) ) {
|
||||
foreach ( $invalid_mailbox_fields as $header_name ) {
|
||||
$this->add_error( $section, 'invalid_mailbox_syntax',
|
||||
if ( in_array( strtolower( $header_name ), $mailbox_header_types )
|
||||
and '' !== $header_value ) {
|
||||
$this->detect_invalid_mailbox_syntax(
|
||||
sprintf( '%s.additional_headers', $template ),
|
||||
$header_value,
|
||||
array(
|
||||
'message' => __( "Invalid mailbox syntax is used in the %name% field.", 'contact-form-7' ),
|
||||
'params' => array( 'name' => $header_name ),
|
||||
'params' => array( 'name' => $header_name )
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->remove_error( $section, 'invalid_mailbox_syntax' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'unsafe_email_without_protection' ) ) {
|
||||
if ( ! empty( $unsafe_email_fields ) ) {
|
||||
$this->add_error( $section, 'unsafe_email_without_protection',
|
||||
array(
|
||||
'message' => __( "Unsafe email config is used without sufficient protection.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'unsafe_email_without_protection' );
|
||||
}
|
||||
if ( $invalid_mail_header_exists ) {
|
||||
$this->add_error( sprintf( '%s.additional_headers', $template ),
|
||||
'invalid_mail_header',
|
||||
array(
|
||||
'message' => __( "There are invalid mail header fields.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$body = new WPCF7_MailTaggedText(
|
||||
$components['body'],
|
||||
array( 'callback' => $callback )
|
||||
);
|
||||
|
||||
/**
|
||||
* Runs error detection for the mail body section.
|
||||
*/
|
||||
public function validate_mail_body( $template, $content ) {
|
||||
$section = sprintf( '%s.body', $template );
|
||||
$body = $body->replace_tags();
|
||||
|
||||
if ( $this->supports( 'maybe_empty' ) ) {
|
||||
if ( $this->detect_maybe_empty( $section, $content ) ) {
|
||||
$this->add_error( $section, 'maybe_empty',
|
||||
array(
|
||||
'message' => __( "There is a possible empty field.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'maybe_empty' );
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->detect_maybe_empty( sprintf( '%s.body', $template ), $body );
|
||||
|
||||
|
||||
/**
|
||||
* Runs error detection for the mail attachments section.
|
||||
*/
|
||||
public function validate_mail_attachments( $template, $content ) {
|
||||
$section = sprintf( '%s.attachments', $template );
|
||||
|
||||
$total_size = 0;
|
||||
$files_not_found = array();
|
||||
$files_out_of_content = array();
|
||||
|
||||
if ( '' !== $content ) {
|
||||
if ( '' !== $components['attachments'] ) {
|
||||
$attachables = array();
|
||||
|
||||
$tags = $this->contact_form->scan_form_tags(
|
||||
@@ -396,7 +236,7 @@ trait WPCF7_ConfigValidator_Mail {
|
||||
foreach ( $tags as $tag ) {
|
||||
$name = $tag->name;
|
||||
|
||||
if ( ! str_contains( $content, "[{$name}]" ) ) {
|
||||
if ( ! str_contains( $components['attachments'], "[{$name}]" ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -409,61 +249,41 @@ trait WPCF7_ConfigValidator_Mail {
|
||||
|
||||
$total_size = array_sum( $attachables );
|
||||
|
||||
foreach ( explode( "\n", $content ) as $line ) {
|
||||
$has_file_not_found = false;
|
||||
$has_file_not_in_content_dir = false;
|
||||
|
||||
foreach ( explode( "\n", $components['attachments'] ) as $line ) {
|
||||
$line = trim( $line );
|
||||
|
||||
if ( '' === $line or str_starts_with( $line, '[' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->detect_file_not_found( $section, $line ) ) {
|
||||
$files_not_found[] = $line;
|
||||
} elseif ( $this->detect_file_not_in_content_dir( $section, $line ) ) {
|
||||
$files_out_of_content[] = $line;
|
||||
} else {
|
||||
$has_file_not_found = $this->detect_file_not_found(
|
||||
sprintf( '%s.attachments', $template ), $line
|
||||
);
|
||||
|
||||
if ( ! $has_file_not_found and ! $has_file_not_in_content_dir ) {
|
||||
$has_file_not_in_content_dir = $this->detect_file_not_in_content_dir(
|
||||
sprintf( '%s.attachments', $template ), $line
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $has_file_not_found ) {
|
||||
$path = path_join( WP_CONTENT_DIR, $line );
|
||||
$total_size += (int) @filesize( $path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'file_not_found' ) ) {
|
||||
if ( ! empty( $files_not_found ) ) {
|
||||
foreach ( $files_not_found as $line ) {
|
||||
$this->add_error( $section, 'file_not_found',
|
||||
array(
|
||||
'message' => __( "Attachment file does not exist at %path%.", 'contact-form-7' ),
|
||||
'params' => array( 'path' => $line ),
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->remove_error( $section, 'file_not_found' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'file_not_in_content_dir' ) ) {
|
||||
if ( ! empty( $files_out_of_content ) ) {
|
||||
$this->add_error( $section, 'file_not_in_content_dir',
|
||||
array(
|
||||
'message' => __( "It is not allowed to use files outside the wp-content directory.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'file_not_in_content_dir' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->supports( 'attachments_overweight' ) ) {
|
||||
$max = 25 * MB_IN_BYTES; // 25 MB
|
||||
|
||||
if ( $max < $total_size ) {
|
||||
$this->add_error( $section, 'attachments_overweight',
|
||||
$this->add_error( sprintf( '%s.attachments', $template ),
|
||||
'attachments_overweight',
|
||||
array(
|
||||
'message' => __( "The total size of attachment files is too large.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'attachments_overweight' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -474,12 +294,17 @@ trait WPCF7_ConfigValidator_Mail {
|
||||
*
|
||||
* @link https://contactform7.com/configuration-errors/invalid-mailbox-syntax/
|
||||
*/
|
||||
public function detect_invalid_mailbox_syntax( $section, $content ) {
|
||||
$content = $this->replace_mail_tags( $content );
|
||||
$content = wpcf7_strip_newline( $content );
|
||||
public function detect_invalid_mailbox_syntax( $section, $content, $args = '' ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'message' => __( "Invalid mailbox syntax is used.", 'contact-form-7' ),
|
||||
'params' => array(),
|
||||
) );
|
||||
|
||||
if ( ! wpcf7_is_mailbox_list( $content ) ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'invalid_mailbox_syntax',
|
||||
$args
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -492,11 +317,13 @@ trait WPCF7_ConfigValidator_Mail {
|
||||
* @link https://contactform7.com/configuration-errors/maybe-empty/
|
||||
*/
|
||||
public function detect_maybe_empty( $section, $content ) {
|
||||
$content = $this->replace_mail_tags( $content );
|
||||
$content = wpcf7_strip_newline( $content );
|
||||
|
||||
if ( '' === $content ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'maybe_empty',
|
||||
array(
|
||||
'message' => __( "There is a possible empty field.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -512,7 +339,13 @@ trait WPCF7_ConfigValidator_Mail {
|
||||
$path = path_join( WP_CONTENT_DIR, $content );
|
||||
|
||||
if ( ! is_readable( $path ) or ! is_file( $path ) ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'file_not_found',
|
||||
array(
|
||||
'message' => __( "Attachment file does not exist at %path%.", 'contact-form-7' ),
|
||||
'params' => array( 'path' => $content ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -528,73 +361,12 @@ trait WPCF7_ConfigValidator_Mail {
|
||||
$path = path_join( WP_CONTENT_DIR, $content );
|
||||
|
||||
if ( ! wpcf7_is_file_path_in_content_dir( $path ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detects errors of that unsafe email config is used without
|
||||
* sufficient protection.
|
||||
*
|
||||
* @link https://contactform7.com/configuration-errors/unsafe-email-without-protection/
|
||||
*/
|
||||
public function detect_unsafe_email_without_protection( $section, $content ) {
|
||||
static $is_recaptcha_active = null;
|
||||
|
||||
if ( null === $is_recaptcha_active ) {
|
||||
$is_recaptcha_active = call_user_func( function () {
|
||||
$service = WPCF7_RECAPTCHA::get_instance();
|
||||
return $service->is_active();
|
||||
} );
|
||||
}
|
||||
|
||||
if ( $is_recaptcha_active ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$example_email = 'example@example.com';
|
||||
|
||||
// Replace mail-tags connected to an email type form-tag first.
|
||||
$content = $this->replace_mail_tags( $content, array(
|
||||
'callback' => function ( $matches ) use ( $example_email ) {
|
||||
// allow [[foo]] syntax for escaping a tag
|
||||
if ( $matches[1] === '[' and $matches[4] === ']' ) {
|
||||
return substr( $matches[0], 1, -1 );
|
||||
}
|
||||
|
||||
$tag = $matches[0];
|
||||
$tagname = $matches[2];
|
||||
$values = $matches[3];
|
||||
|
||||
$mail_tag = new WPCF7_MailTag( $tag, $tagname, $values );
|
||||
$field_name = $mail_tag->field_name();
|
||||
|
||||
$form_tags = $this->contact_form->scan_form_tags(
|
||||
array( 'name' => $field_name )
|
||||
);
|
||||
|
||||
if ( $form_tags ) {
|
||||
$form_tag = new WPCF7_FormTag( $form_tags[0] );
|
||||
|
||||
if ( 'email' === $form_tag->basetype ) {
|
||||
return $example_email;
|
||||
}
|
||||
}
|
||||
|
||||
return $tag;
|
||||
},
|
||||
) );
|
||||
|
||||
// Replace remaining mail-tags.
|
||||
$content = $this->replace_mail_tags( $content );
|
||||
|
||||
$content = wpcf7_strip_newline( $content );
|
||||
|
||||
if ( str_contains( $content, $example_email ) ) {
|
||||
return true;
|
||||
return $this->add_error( $section,
|
||||
'file_not_in_content_dir',
|
||||
array(
|
||||
'message' => __( "It is not allowed to use files outside the wp-content directory.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -12,27 +12,14 @@ trait WPCF7_ConfigValidator_Messages {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
isset( $messages['captcha_not_match'] ) and
|
||||
! wpcf7_use_really_simple_captcha()
|
||||
) {
|
||||
if ( isset( $messages['captcha_not_match'] )
|
||||
and ! wpcf7_use_really_simple_captcha() ) {
|
||||
unset( $messages['captcha_not_match'] );
|
||||
}
|
||||
|
||||
foreach ( $messages as $key => $message ) {
|
||||
$section = sprintf( 'messages.%s', $key );
|
||||
|
||||
if ( $this->supports( 'html_in_message' ) ) {
|
||||
if ( $this->detect_html_in_message( $section, $message ) ) {
|
||||
$this->add_error( $section, 'html_in_message',
|
||||
array(
|
||||
'message' => __( "HTML tags are used in a message.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->remove_error( $section, 'html_in_message' );
|
||||
}
|
||||
}
|
||||
$this->detect_html_in_message( $section, $message );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +32,13 @@ trait WPCF7_ConfigValidator_Messages {
|
||||
public function detect_html_in_message( $section, $content ) {
|
||||
$stripped = wp_strip_all_tags( $content );
|
||||
|
||||
if ( $stripped !== $content ) {
|
||||
return true;
|
||||
if ( $stripped != $content ) {
|
||||
return $this->add_error( $section,
|
||||
'html_in_message',
|
||||
array(
|
||||
'message' => __( "HTML tags are used in a message.", 'contact-form-7' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -4,7 +4,6 @@ require_once path_join( __DIR__, 'form.php' );
|
||||
require_once path_join( __DIR__, 'mail.php' );
|
||||
require_once path_join( __DIR__, 'messages.php' );
|
||||
require_once path_join( __DIR__, 'additional-settings.php' );
|
||||
require_once path_join( __DIR__, 'actions.php' );
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,10 +13,15 @@ require_once path_join( __DIR__, 'actions.php' );
|
||||
*/
|
||||
class WPCF7_ConfigValidator {
|
||||
|
||||
use WPCF7_ConfigValidator_Form;
|
||||
use WPCF7_ConfigValidator_Mail;
|
||||
use WPCF7_ConfigValidator_Messages;
|
||||
use WPCF7_ConfigValidator_AdditionalSettings;
|
||||
|
||||
/**
|
||||
* The plugin version in which important updates happened last time.
|
||||
*/
|
||||
const last_important_update = '5.8.1';
|
||||
const last_important_update = '5.6.1';
|
||||
|
||||
const error_codes = array(
|
||||
'maybe_empty',
|
||||
@@ -35,18 +39,10 @@ class WPCF7_ConfigValidator {
|
||||
'dots_in_names',
|
||||
'colons_in_names',
|
||||
'upload_filesize_overlimit',
|
||||
'unsafe_email_without_protection',
|
||||
);
|
||||
|
||||
use WPCF7_ConfigValidator_Form;
|
||||
use WPCF7_ConfigValidator_Mail;
|
||||
use WPCF7_ConfigValidator_Messages;
|
||||
use WPCF7_ConfigValidator_AdditionalSettings;
|
||||
|
||||
private $contact_form;
|
||||
private $errors = array();
|
||||
private $include;
|
||||
private $exclude;
|
||||
|
||||
|
||||
/**
|
||||
@@ -70,21 +66,8 @@ class WPCF7_ConfigValidator {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct( WPCF7_ContactForm $contact_form, $args = '' ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'include' => null,
|
||||
'exclude' => null,
|
||||
) );
|
||||
|
||||
public function __construct( WPCF7_ContactForm $contact_form ) {
|
||||
$this->contact_form = $contact_form;
|
||||
|
||||
if ( isset( $args['include'] ) ) {
|
||||
$this->include = (array) $args['include'];
|
||||
}
|
||||
|
||||
if ( isset( $args['exclude'] ) ) {
|
||||
$this->exclude = (array) $args['exclude'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,24 +87,6 @@ class WPCF7_ConfigValidator {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the given error code is supported by this instance.
|
||||
*/
|
||||
public function supports( $error_code ) {
|
||||
if ( isset( $this->include ) ) {
|
||||
$supported_codes = array_intersect( self::error_codes, $this->include );
|
||||
} else {
|
||||
$supported_codes = self::error_codes;
|
||||
}
|
||||
|
||||
if ( isset( $this->exclude ) ) {
|
||||
$supported_codes = array_diff( $supported_codes, $this->exclude );
|
||||
}
|
||||
|
||||
return in_array( $error_code, $supported_codes, true );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Counts detected errors.
|
||||
*/
|
||||
@@ -230,27 +195,6 @@ class WPCF7_ConfigValidator {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the specified section has the specified error.
|
||||
*
|
||||
* @param string $section The section where the error detected.
|
||||
* @param string $code The unique code of the error.
|
||||
*/
|
||||
public function has_error( $section, $code ) {
|
||||
if ( empty( $this->errors[$section] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( (array) $this->errors[$section] as $error ) {
|
||||
if ( isset( $error['code'] ) and $error['code'] === $code ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a validation error.
|
||||
*
|
||||
@@ -320,6 +264,8 @@ class WPCF7_ConfigValidator {
|
||||
* @return bool True if there is no error detected.
|
||||
*/
|
||||
public function validate() {
|
||||
$this->errors = array();
|
||||
|
||||
$this->validate_form();
|
||||
$this->validate_mail( 'mail' );
|
||||
$this->validate_mail( 'mail_2' );
|
||||
|
||||
@@ -221,7 +221,7 @@ function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
|
||||
return '[contact-form-7]';
|
||||
}
|
||||
|
||||
if ( 'contact-form-7' === $code ) {
|
||||
if ( 'contact-form-7' == $code ) {
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'id' => '',
|
||||
@@ -269,15 +269,11 @@ function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
|
||||
return $contact_form->form_html( $atts );
|
||||
};
|
||||
|
||||
$output = wpcf7_switch_locale(
|
||||
return wpcf7_switch_locale(
|
||||
$contact_form->locale(),
|
||||
$callback,
|
||||
$contact_form, $atts
|
||||
);
|
||||
|
||||
do_action( 'wpcf7_shortcode_callback', $contact_form, $atts );
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class WPCF7_ContactFormTemplate {
|
||||
. '-- ' . "\n"
|
||||
. sprintf(
|
||||
/* translators: 1: blog name, 2: blog URL */
|
||||
__( 'This is a notification that a contact form was submitted on your website (%1$s %2$s).', 'contact-form-7' ),
|
||||
__( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
|
||||
'[_site_title]',
|
||||
'[_site_url]'
|
||||
),
|
||||
@@ -108,7 +108,7 @@ class WPCF7_ContactFormTemplate {
|
||||
. '-- ' . "\n"
|
||||
. sprintf(
|
||||
/* translators: 1: blog name, 2: blog URL */
|
||||
__( 'This email is a receipt for your contact form submission on our website (%1$s %2$s) in which your email address was used. If that was not you, please ignore this message.', 'contact-form-7' ),
|
||||
__( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
|
||||
'[_site_title]',
|
||||
'[_site_url]'
|
||||
),
|
||||
|
||||
@@ -410,7 +410,7 @@ class WPCF7_FormTag implements ArrayAccess {
|
||||
if ( $contact_form = WPCF7_ContactForm::get_current() ) {
|
||||
$val = $contact_form->shortcode_attr( $this->name );
|
||||
|
||||
if ( isset( $val ) and strlen( $val ) ) {
|
||||
if ( strlen( $val ) ) {
|
||||
if ( $args['multiple'] ) {
|
||||
$values[] = $val;
|
||||
} else {
|
||||
|
||||
@@ -522,13 +522,7 @@ function wpcf7_format_atts( $atts ) {
|
||||
}
|
||||
|
||||
static $boolean_attributes = array(
|
||||
'checked',
|
||||
'disabled',
|
||||
'inert',
|
||||
'multiple',
|
||||
'readonly',
|
||||
'required',
|
||||
'selected',
|
||||
'checked', 'disabled', 'multiple', 'readonly', 'required', 'selected',
|
||||
);
|
||||
|
||||
if ( in_array( $name, $boolean_attributes ) and '' === $value ) {
|
||||
|
||||
@@ -210,7 +210,7 @@ function wpcf7_validate_configuration() {
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if wpcf7_autop() is applied.
|
||||
* Returns true if wpcf7_autop() is applied to form content.
|
||||
*/
|
||||
function wpcf7_autop_or_not() {
|
||||
return (bool) apply_filters( 'wpcf7_autop_or_not', WPCF7_AUTOP );
|
||||
|
||||
@@ -259,23 +259,12 @@ function wpcf7_is_file_path_in_content_dir( $path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
str_starts_with( $path, trailingslashit( realpath( WP_CONTENT_DIR ) ) )
|
||||
) {
|
||||
if ( 0 === strpos( $path, realpath( WP_CONTENT_DIR ) ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
defined( 'UPLOADS' ) and
|
||||
str_starts_with( $path, trailingslashit( realpath( ABSPATH . UPLOADS ) ) )
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
defined( 'WP_TEMP_DIR' ) and
|
||||
str_starts_with( $path, trailingslashit( realpath( WP_TEMP_DIR ) ) )
|
||||
) {
|
||||
if ( defined( 'UPLOADS' )
|
||||
and 0 === strpos( $path, realpath( ABSPATH . UPLOADS ) ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,14 +110,10 @@ class WPCF7 {
|
||||
* @param mixed $value Option value.
|
||||
*/
|
||||
public static function update_option( $name, $value ) {
|
||||
$old_option = get_option( 'wpcf7' );
|
||||
$old_option = ( false === $old_option ) ? array() : (array) $old_option;
|
||||
|
||||
update_option( 'wpcf7',
|
||||
array_merge( $old_option, array( $name => $value ) )
|
||||
);
|
||||
|
||||
do_action( 'wpcf7_update_option', $name, $value, $old_option );
|
||||
$option = get_option( 'wpcf7' );
|
||||
$option = ( false === $option ) ? array() : (array) $option;
|
||||
$option = array_merge( $option, array( $name => $value ) );
|
||||
update_option( 'wpcf7', $option );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ function wpcf7_sendinblue_editor_panels( $panels ) {
|
||||
),
|
||||
wpcf7_link(
|
||||
__( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ),
|
||||
__( 'Brevo integration', 'contact-form-7' )
|
||||
__( 'Brevo (formerly Sendinblue) integration', 'contact-form-7' )
|
||||
)
|
||||
);
|
||||
|
||||
@@ -106,7 +106,7 @@ function wpcf7_sendinblue_editor_panels( $panels ) {
|
||||
$templates = $service->get_templates();
|
||||
|
||||
?>
|
||||
<h2><?php echo esc_html( __( 'Brevo', 'contact-form-7' ) ); ?></h2>
|
||||
<h2><?php echo esc_html( __( 'Brevo (formerly Sendinblue)', 'contact-form-7' ) ); ?></h2>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php echo $description; ?></legend>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Brevo module main file
|
||||
* Brevo (formerly Sendinblue) module main file
|
||||
*
|
||||
* @link https://contactform7.com/sendinblue-integration/
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ class WPCF7_Sendinblue extends WPCF7_Service {
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Brevo', 'contact-form-7' );
|
||||
return __( 'Brevo (formerly Sendinblue)', 'contact-form-7' );
|
||||
}
|
||||
|
||||
public function is_active() {
|
||||
@@ -47,7 +47,7 @@ class WPCF7_Sendinblue extends WPCF7_Service {
|
||||
|
||||
public function link() {
|
||||
echo wpcf7_link(
|
||||
'https://www.brevo.com/',
|
||||
'https://www.brevo.com/?tap_a=30591-fb13f0&tap_s=1031580-b1bb1d',
|
||||
'brevo.com'
|
||||
);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ class WPCF7_Sendinblue extends WPCF7_Service {
|
||||
'<p><strong>%s</strong></p>',
|
||||
wpcf7_link(
|
||||
__( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ),
|
||||
__( 'Brevo integration', 'contact-form-7' )
|
||||
__( 'Brevo (formerly Sendinblue) integration', 'contact-form-7' )
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, mult
|
||||
Requires at least: 6.2
|
||||
Requires PHP: 7.4
|
||||
Tested up to: 6.3
|
||||
Stable tag: 5.8.1
|
||||
Stable tag: 5.8
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@@ -37,7 +37,7 @@ If you activate certain features in this plugin, the contact form submitter's pe
|
||||
* reCAPTCHA ([Google](https://policies.google.com/?hl=en))
|
||||
* Akismet ([Automattic](https://automattic.com/privacy/))
|
||||
* Constant Contact ([Endurance International Group](https://www.endurance.com/privacy))
|
||||
* [Brevo](https://www.brevo.com/legal/privacypolicy/)
|
||||
* [Brevo (formerly Sendinblue)](https://www.brevo.com/legal/privacypolicy/)
|
||||
* [Stripe](https://stripe.com/privacy)
|
||||
|
||||
= Recommended plugins =
|
||||
@@ -78,10 +78,6 @@ Do you have questions or issues with Contact Form 7? Use these support channels
|
||||
|
||||
For more information, see [Releases](https://contactform7.com/category/releases/).
|
||||
|
||||
= 5.8.1 =
|
||||
|
||||
[https://contactform7.com/contact-form-7-581/](https://contactform7.com/contact-form-7-581/)
|
||||
|
||||
= 5.8 =
|
||||
|
||||
[https://contactform7.com/contact-form-7-58/](https://contactform7.com/contact-form-7-58/)
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
* Author URI: https://ideasilo.wordpress.com/
|
||||
* License: GPL v2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Version: 5.8.1
|
||||
* Version: 5.8
|
||||
* Requires at least: 6.2
|
||||
* Requires PHP: 7.4
|
||||
*/
|
||||
|
||||
define( 'WPCF7_VERSION', '5.8.1' );
|
||||
define( 'WPCF7_VERSION', '5.8' );
|
||||
|
||||
define( 'WPCF7_REQUIRED_WP_VERSION', '6.2' );
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting Security Bugs
|
||||
|
||||
Please report security bugs found in the site-reviews plugin's source code through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/imagify). The Patchstack team will assist you with verification, CVE assignment and take care of notifying the developers of this plugin.
|
||||
---
|
||||
@@ -1125,15 +1125,4 @@ window.imagify = window.imagify || {};
|
||||
|
||||
w.imagify.bulk.init();
|
||||
|
||||
if (imagifyBulk.isOverQuota) {
|
||||
w.imagify.bulk.displayError( {
|
||||
title: imagifyBulk.labels.overQuotaTitle,
|
||||
html: $( '#tmpl-imagify-overquota-alert' ).html(),
|
||||
type: 'info',
|
||||
customClass: 'imagify-swal-has-subtitle imagify-swal-error-header',
|
||||
showConfirmButton: false
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
} )(jQuery, document, window);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -413,14 +413,13 @@ class Bulk {
|
||||
*
|
||||
* @since 1.9
|
||||
*
|
||||
* @param string $method The method used: 'GET' (default), or 'POST'.
|
||||
* @param string $parameter The name of the parameter to look for.
|
||||
*
|
||||
* @param string $method The method used: 'GET' (default), or 'POST'.
|
||||
* @param string $parameter The name of the parameter to look for.
|
||||
* @return string
|
||||
*/
|
||||
public function get_context( $method = 'GET', $parameter = 'context' ) {
|
||||
$context = 'POST' === $method ? wp_unslash( $_POST[ $parameter ] ) : wp_unslash( $_GET[ $parameter ] ); //phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$context = htmlspecialchars( $context );
|
||||
$method = 'POST' === $method ? INPUT_POST : INPUT_GET;
|
||||
$context = filter_input( $method, $parameter, FILTER_SANITIZE_STRING );
|
||||
|
||||
return imagify_sanitize_context( $context );
|
||||
}
|
||||
@@ -558,7 +557,7 @@ class Bulk {
|
||||
public function bulk_get_stats_callback() {
|
||||
imagify_check_nonce( 'imagify-bulk-optimize' );
|
||||
|
||||
$folder_types = filter_input( INPUT_GET, 'types', FILTER_REQUIRE_ARRAY );
|
||||
$folder_types = filter_input( INPUT_GET, 'types', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
|
||||
$folder_types = is_array( $folder_types ) ? array_filter( $folder_types, 'is_string' ) : [];
|
||||
|
||||
if ( ! $folder_types ) {
|
||||
|
||||
@@ -95,7 +95,6 @@ class CustomFolders extends AbstractBulk {
|
||||
$files_table = Imagify_Files_DB::get_instance()->get_table_name();
|
||||
$folders_table = Imagify_Folders_DB::get_instance()->get_table_name();
|
||||
$mime_types = Imagify_DB::get_mime_types( 'image' );
|
||||
$mime_types = str_replace( ",'image/webp'", '', $mime_types );
|
||||
$webp_suffix = constant( imagify_get_optimization_process_class_name( 'custom-folders' ) . '::WEBP_SUFFIX' );
|
||||
$files = $wpdb->get_results( $wpdb->prepare( // WPCS: unprepared SQL ok.
|
||||
"
|
||||
|
||||
@@ -184,7 +184,6 @@ class WP extends AbstractBulk {
|
||||
$this->set_no_time_limit();
|
||||
|
||||
$mime_types = Imagify_DB::get_mime_types( 'image' );
|
||||
$mime_types = str_replace( ",'image/webp'", '', $mime_types );
|
||||
$statuses = Imagify_DB::get_post_statuses();
|
||||
$nodata_join = Imagify_DB::get_required_wp_metadata_join_clause();
|
||||
$nodata_where = Imagify_DB::get_required_wp_metadata_where_clause( [
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
namespace Imagify\Notices;
|
||||
|
||||
use Imagify\Traits\InstanceGetterTrait;
|
||||
use Imagify\User\User;
|
||||
|
||||
/**
|
||||
* Class that handles the admin notices.
|
||||
@@ -468,7 +467,7 @@ class Notices {
|
||||
return $display;
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user = new \Imagify_User();
|
||||
|
||||
// Don't display the notice if the user's unconsumed quota is superior to 20%.
|
||||
if ( $user->get_percent_unconsumed_quota() > 20 ) {
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
<?php
|
||||
namespace Imagify\User;
|
||||
|
||||
use Date;
|
||||
use Imagify_Data;
|
||||
use WP_Error;
|
||||
|
||||
/**
|
||||
* Imagify User class.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class User {
|
||||
/**
|
||||
* The Imagify user ID.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* The user email.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* The plan ID.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $plan_id;
|
||||
|
||||
/**
|
||||
* The plan label.
|
||||
*
|
||||
* @since 1.2
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $plan_label;
|
||||
|
||||
/**
|
||||
* The total quota.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $quota;
|
||||
|
||||
/**
|
||||
* The total extra quota (Imagify Pack).
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $extra_quota;
|
||||
|
||||
/**
|
||||
* The extra quota consumed.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $extra_quota_consumed;
|
||||
|
||||
/**
|
||||
* The current month consumed quota.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $consumed_current_month_quota;
|
||||
|
||||
/**
|
||||
* The next month date to credit the account.
|
||||
*
|
||||
* @since 1.1.1
|
||||
*
|
||||
* @var Date
|
||||
*/
|
||||
public $next_date_update;
|
||||
|
||||
/**
|
||||
* If the account is activate or not.
|
||||
*
|
||||
* @since 1.0.1
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $is_active;
|
||||
|
||||
/**
|
||||
* Store a \WP_Error object if the request to fetch the user data failed.
|
||||
* False overwise.
|
||||
*
|
||||
* @var bool|WP_Error
|
||||
* @since 1.9.9
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$user = get_imagify_user();
|
||||
|
||||
if ( is_wp_error( $user ) ) {
|
||||
$this->error = $user;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->id = $user->id;
|
||||
$this->email = $user->email;
|
||||
$this->plan_id = (int) $user->plan_id;
|
||||
$this->plan_label = ucfirst( $user->plan_label );
|
||||
$this->quota = $user->quota;
|
||||
$this->extra_quota = $user->extra_quota;
|
||||
$this->extra_quota_consumed = $user->extra_quota_consumed;
|
||||
$this->consumed_current_month_quota = $user->consumed_current_month_quota;
|
||||
$this->next_date_update = $user->next_date_update;
|
||||
$this->is_active = $user->is_active;
|
||||
$this->error = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the possible error returned when fetching user data.
|
||||
*
|
||||
* @return bool|WP_Error A \WP_Error object if the request to fetch the user data failed. False overwise.
|
||||
* @since 1.9.9
|
||||
*/
|
||||
public function get_error() {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Percentage of consumed quota, including extra quota.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function get_percent_consumed_quota() {
|
||||
static $done = false;
|
||||
|
||||
if ( $this->get_error() ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$quota = $this->quota;
|
||||
$consumed_quota = $this->consumed_current_month_quota;
|
||||
|
||||
if ( imagify_round_half_five( $this->extra_quota_consumed ) < $this->extra_quota ) {
|
||||
$quota += $this->extra_quota;
|
||||
$consumed_quota += $this->extra_quota_consumed;
|
||||
}
|
||||
|
||||
if ( ! $quota || ! $consumed_quota ) {
|
||||
$percent = 0;
|
||||
} else {
|
||||
$percent = 100 * $consumed_quota / $quota;
|
||||
$percent = round( $percent, 1 );
|
||||
$percent = min( max( 0, $percent ), 100 );
|
||||
}
|
||||
|
||||
$percent = (float) $percent;
|
||||
|
||||
if ( $done ) {
|
||||
return $percent;
|
||||
}
|
||||
|
||||
$previous_percent = Imagify_Data::get_instance()->get( 'previous_quota_percent' );
|
||||
|
||||
// Percent is not 100% anymore.
|
||||
if ( 100.0 === (float) $previous_percent && $percent < 100 ) {
|
||||
/**
|
||||
* Triggered when the consumed quota percent decreases below 100%.
|
||||
*
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param float|int $percent The current percentage of consumed quota.
|
||||
*/
|
||||
do_action( 'imagify_not_over_quota_anymore', $percent );
|
||||
}
|
||||
|
||||
// Percent is not >= 80% anymore.
|
||||
if ( ( (float) $previous_percent >= 80.0 && $percent < 80 ) ) {
|
||||
/**
|
||||
* Triggered when the consumed quota percent decreases below 80%.
|
||||
*
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param float|int $percent The current percentage of consumed quota.
|
||||
* @param float|int $previous_percent The previous percentage of consumed quota.
|
||||
*/
|
||||
do_action( 'imagify_not_almost_over_quota_anymore', $percent, $previous_percent );
|
||||
}
|
||||
|
||||
if ( (float) $previous_percent !== (float) $percent ) {
|
||||
Imagify_Data::get_instance()->set( 'previous_quota_percent', $percent );
|
||||
}
|
||||
|
||||
$done = true;
|
||||
|
||||
return $percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count percent of unconsumed quota.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function get_percent_unconsumed_quota() {
|
||||
return 100 - $this->get_percent_consumed_quota();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user has a free account.
|
||||
*
|
||||
* @since 1.1.1
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_free() {
|
||||
return 1 === $this->plan_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user has consumed all his/her quota.
|
||||
*
|
||||
* @since 1.1.1
|
||||
* @since 1.9.9 Return false if the request to fetch the user data failed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_over_quota() {
|
||||
if ( $this->get_error() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
$this->is_free()
|
||||
&&
|
||||
floatval( 100 ) === round( $this->get_percent_consumed_quota() )
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ namespace Imagify\Webp\RewriteRules;
|
||||
|
||||
use Imagify\Notices\Notices;
|
||||
use Imagify\Traits\InstanceGetterTrait;
|
||||
use Imagify\WriteFile\AbstractWriteDirConfFile;
|
||||
|
||||
/**
|
||||
* Display WebP images on the site with rewrite rules.
|
||||
@@ -13,13 +12,6 @@ use Imagify\WriteFile\AbstractWriteDirConfFile;
|
||||
class Display {
|
||||
use InstanceGetterTrait;
|
||||
|
||||
/**
|
||||
* Configuration file writer.
|
||||
*
|
||||
* @var AbstractWriteDirConfFile
|
||||
*/
|
||||
protected $server_conf;
|
||||
|
||||
/**
|
||||
* Option value.
|
||||
*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: Imagify
|
||||
* Plugin URI: https://wordpress.org/plugins/imagify/
|
||||
* Description: Dramatically reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth using Imagify, the new most advanced image optimization tool.
|
||||
* Version: 2.1.2
|
||||
* Version: 2.1.1
|
||||
* Requires at least: 5.3
|
||||
* Requires PHP: 7.0
|
||||
* Author: Imagify – Optimize Images & Convert WebP
|
||||
@@ -13,13 +13,13 @@
|
||||
* Text Domain: imagify
|
||||
* Domain Path: languages
|
||||
*
|
||||
* Copyright 2023 WP Media
|
||||
* Copyright 2022 WP Media
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
// Imagify defines.
|
||||
define( 'IMAGIFY_VERSION', '2.1.2' );
|
||||
define( 'IMAGIFY_VERSION', '2.1.1' );
|
||||
define( 'IMAGIFY_SLUG', 'imagify' );
|
||||
define( 'IMAGIFY_FILE', __FILE__ );
|
||||
define( 'IMAGIFY_PATH', realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
|
||||
|
||||
@@ -123,9 +123,7 @@ function _imagify_sort_attachments_by_status( $vars ) {
|
||||
),
|
||||
) );
|
||||
|
||||
if ( ! key_exists( 'post_mime_type', $vars ) ) {
|
||||
$vars['post_mime_type'] = imagify_get_mime_types();
|
||||
}
|
||||
$vars['post_mime_type'] = imagify_get_mime_types();
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
-7
@@ -18,13 +18,6 @@ abstract class Imagify_Abstract_Background_Process extends Imagify_WP_Background
|
||||
*/
|
||||
protected $prefix = 'imagify';
|
||||
|
||||
/**
|
||||
* URL to query on.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $query_url = '';
|
||||
|
||||
/**
|
||||
* Set to true to automatically displatch at the end of the page.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Imagify\Traits\InstanceGetterTrait;
|
||||
use Imagify\User\User;
|
||||
|
||||
/**
|
||||
* Class that handles admin ajax/post callbacks.
|
||||
@@ -221,13 +220,13 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
$process = imagify_get_optimization_process( $media_id, $context );
|
||||
|
||||
if ( ! $process->is_valid() ) {
|
||||
return new WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
|
||||
return new \WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
|
||||
}
|
||||
|
||||
$data = $process->get_data();
|
||||
|
||||
if ( ! $data->is_already_optimized() ) {
|
||||
return new WP_Error( 'not_already_optimized', __( 'This media does not have the right optimization status.', 'imagify' ) );
|
||||
return new \WP_Error( 'not_already_optimized', __( 'This media does not have the right optimization status.', 'imagify' ) );
|
||||
}
|
||||
|
||||
if ( ! $process->has_webp() ) {
|
||||
@@ -238,7 +237,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
$deleted = $process->delete_webp_files();
|
||||
|
||||
if ( is_wp_error( $deleted ) ) {
|
||||
return new WP_Error( 'webp_not_deleted', __( 'Previous WebP files could not be deleted.', 'imagify' ) );
|
||||
return new \WP_Error( 'webp_not_deleted', __( 'Previous WebP files could not be deleted.', 'imagify' ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -842,7 +841,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
imagify_die();
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user = new Imagify_User();
|
||||
$views = Imagify_Views::get_instance();
|
||||
$unconsumed_quota = $views->get_quota_percent();
|
||||
$message = '';
|
||||
@@ -1149,7 +1148,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
imagify_die();
|
||||
}
|
||||
|
||||
$notice = htmlspecialchars( wp_unslash( $_GET['ad'] ) );
|
||||
$notice = filter_input( INPUT_GET, 'ad', FILTER_SANITIZE_STRING );
|
||||
|
||||
if ( ! $notice ) {
|
||||
imagify_maybe_redirect();
|
||||
@@ -1216,8 +1215,8 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
* @return string
|
||||
*/
|
||||
public function get_context( $method = 'GET', $parameter = 'context' ) {
|
||||
$context = 'POST' === $method ? wp_unslash( $_POST[ $parameter ] ) : wp_unslash( $_GET[ $parameter ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$context = htmlspecialchars( $context );
|
||||
$method = 'POST' === $method ? INPUT_POST : INPUT_GET;
|
||||
$context = filter_input( $method, $parameter, FILTER_SANITIZE_STRING );
|
||||
|
||||
return imagify_sanitize_context( $context );
|
||||
}
|
||||
@@ -1247,15 +1246,14 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
*
|
||||
* @since 1.9
|
||||
*
|
||||
* @param string $method The method used: 'GET' (default), or 'POST'.
|
||||
* @param string $parameter The name of the parameter to look for.
|
||||
*
|
||||
* @param string $method The method used: 'GET' (default), or 'POST'.
|
||||
* @param string $parameter The name of the parameter to look for.
|
||||
* @return string
|
||||
*/
|
||||
public function get_folder_type( $method = 'GET', $parameter = 'folder_type' ) {
|
||||
$folder_type = 'POST' === $method ? wp_unslash( $_POST[ $parameter ] ) : wp_unslash( $_GET[ $parameter ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$method = 'POST' === $method ? INPUT_POST : INPUT_GET;
|
||||
|
||||
return htmlspecialchars( $folder_type );
|
||||
return filter_input( $method, $parameter, FILTER_SANITIZE_STRING );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1263,14 +1261,13 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
|
||||
*
|
||||
* @since 1.9
|
||||
*
|
||||
* @param string $method The method used: 'GET' (default), or 'POST'.
|
||||
* @param string $parameter The name of the parameter to look for.
|
||||
*
|
||||
* @param string $method The method used: 'GET' (default), or 'POST'.
|
||||
* @param string $parameter The name of the parameter to look for.
|
||||
* @return string
|
||||
*/
|
||||
public function get_imagify_action( $method = 'GET', $parameter = 'imagify_action' ) {
|
||||
$action = 'POST' === $method ? wp_unslash( $_POST[ $parameter ] ) : wp_unslash( $_GET[ $parameter ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$action = htmlspecialchars( $action );
|
||||
$method = 'POST' === $method ? INPUT_POST : INPUT_GET;
|
||||
$action = filter_input( $method, $parameter, FILTER_SANITIZE_STRING );
|
||||
|
||||
return $action ? $action : 'optimize';
|
||||
}
|
||||
|
||||
@@ -4,54 +4,62 @@ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
/**
|
||||
* Class that display the "custom folders" files.
|
||||
*
|
||||
* @since 1.7
|
||||
* @package Imagify
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
class Imagify_Files_List_Table extends WP_List_Table {
|
||||
|
||||
/**
|
||||
* Class version.
|
||||
*
|
||||
* @var string
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
const VERSION = '1.1';
|
||||
|
||||
/**
|
||||
* Class version.
|
||||
*
|
||||
* @var string
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
const PER_PAGE_OPTION = 'imagify_files_per_page';
|
||||
|
||||
/**
|
||||
* List of the folders containing the listed files.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.7
|
||||
* @var array
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
protected $folders = array();
|
||||
|
||||
/**
|
||||
* Filesystem object.
|
||||
*
|
||||
* @var Imagify_Filesystem
|
||||
* @since 1.7.1
|
||||
* @var object Imagify_Filesystem
|
||||
* @since 1.7.1
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* Views object.
|
||||
*
|
||||
* @var Imagify_Views
|
||||
* @since 1.9
|
||||
* @var object Imagify_Views
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
protected $views;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param array $args An associative array of arguments.
|
||||
*/
|
||||
@@ -72,7 +80,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prepares the list of items for displaying.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function prepare_items() {
|
||||
global $wpdb;
|
||||
@@ -99,8 +108,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
$file_ids = array();
|
||||
$where = '';
|
||||
|
||||
$sent_orderby = isset( $_GET['orderby'] ) ? htmlspecialchars( wp_unslash( $_GET['orderby'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$sent_order = isset( $_GET['order'] ) ? htmlspecialchars( wp_unslash( $_GET['order'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$sent_orderby = filter_input( INPUT_GET, 'orderby', FILTER_SANITIZE_STRING );
|
||||
$sent_order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING );
|
||||
$folder_filter = self::get_folder_filter();
|
||||
$status_filter = self::get_status_filter();
|
||||
|
||||
@@ -218,7 +227,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Message to be displayed when there are no items.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function no_items() {
|
||||
if ( self::get_status_filter() ) {
|
||||
@@ -285,7 +295,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Display views.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function views() {
|
||||
global $wpdb;
|
||||
@@ -401,7 +412,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Get an associative array ( option_name => option_title ) with the list of bulk actions available on this table.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -415,7 +427,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
* Get a list of columns. The format is:
|
||||
* 'internal-name' => 'Title'
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -439,7 +452,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
*
|
||||
* The second format will make the initial sorting order be descending.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -455,7 +469,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Get a column contents.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $column The column "name": "cb", "title", "optimization_level", etc.
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
@@ -474,7 +489,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Handles the checkbox column output.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -489,7 +505,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Handles the title column output.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -538,7 +555,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Handles the parent folder column output.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -572,7 +590,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Handles the optimization data column output.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -623,7 +642,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Handles the status column output.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -657,7 +677,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Handles the optimization level column output.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -672,7 +693,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Handles the actions column output.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -708,7 +730,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints a button to optimize the file.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -735,7 +758,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints a button to retry to optimize the file.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -765,7 +789,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints buttons to re-optimize the file to other levels.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -808,7 +833,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints a button to generate WebP versions if they are missing.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -823,7 +849,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints a button to delete WebP versions when the status is "already_optimized".
|
||||
*
|
||||
* @since 1.9.6
|
||||
* @since 1.9.6
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -838,7 +865,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints a button to restore the file.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -860,7 +888,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints a button to check if the file has been modified or not.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -876,7 +905,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Prints a button for the comparison tool (before / after optimization).
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
*/
|
||||
@@ -922,7 +952,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
* Add the folder_id and folder_path properties to the $item if not set yet.
|
||||
* It may happen if the $item doesn't come from the prepare() method.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param object $item The current item. It must contain at least a $process property.
|
||||
* @return object The current item.
|
||||
@@ -957,7 +988,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Get the name of the default primary column.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string Name of the default primary column, in this case, 'title'.
|
||||
*/
|
||||
@@ -968,7 +1000,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Get a list of CSS classes for the WP_List_Table table tag.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return array List of CSS classes for the table tag.
|
||||
*/
|
||||
@@ -979,7 +1012,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Allow to save the screen options when submitted by the user.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param bool|int $status Screen option value. Default false to skip.
|
||||
* @param string $option The option name.
|
||||
@@ -997,7 +1031,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Get the requested folder filter.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -1015,7 +1050,8 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Get the requested status filter.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -1031,7 +1067,7 @@ class Imagify_Files_List_Table extends WP_List_Table {
|
||||
'unoptimized' => 1,
|
||||
'errors' => 1,
|
||||
);
|
||||
$filter = isset( $_GET['status-filter'] ) ? trim( htmlspecialchars( wp_unslash( $_GET['status-filter'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$filter = trim( filter_input( INPUT_GET, 'status-filter', FILTER_SANITIZE_STRING ) );
|
||||
$filter = isset( $values[ $filter ] ) ? $filter : '';
|
||||
|
||||
return $filter;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
|
||||
use Imagify\User\User;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
/**
|
||||
@@ -306,7 +303,7 @@ class Imagify_Requirements {
|
||||
return self::$supports['over_quota'];
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user = new Imagify_User();
|
||||
|
||||
self::$supports['over_quota'] = $user->get_error() ? false : $user->is_over_quota();
|
||||
|
||||
|
||||
@@ -131,13 +131,10 @@ class Imagify_Settings {
|
||||
* @return bool
|
||||
*/
|
||||
public function is_form_submit() {
|
||||
if ( ! isset( $_POST['option_page'], $_POST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
return false;
|
||||
}
|
||||
|
||||
return htmlspecialchars( wp_unslash( $_POST['option_page'] ) ) === $this->settings_group && htmlspecialchars( wp_unslash( $_POST['action'] ) ) === 'update'; // phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
return filter_input( INPUT_POST, 'option_page', FILTER_SANITIZE_STRING ) === $this->settings_group && filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING ) === 'update';
|
||||
}
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** ON FORM SUBMIT ========================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
+2
-5
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Deprecated class that handles Imagify User class.
|
||||
* Imagify User class.
|
||||
*
|
||||
* @since 1.0
|
||||
* @deprecated
|
||||
*/
|
||||
class Imagify_User {
|
||||
/**
|
||||
@@ -154,6 +153,7 @@ class Imagify_User {
|
||||
*/
|
||||
public function get_percent_consumed_quota() {
|
||||
static $done = false;
|
||||
|
||||
if ( $this->get_error() ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -176,15 +176,12 @@ class Imagify_User {
|
||||
|
||||
$percent = (float) $percent;
|
||||
|
||||
$percent = 100;
|
||||
|
||||
if ( $done ) {
|
||||
return $percent;
|
||||
}
|
||||
|
||||
$previous_percent = Imagify_Data::get_instance()->get( 'previous_quota_percent' );
|
||||
|
||||
|
||||
// Percent is not 100% anymore.
|
||||
if ( 100.0 === (float) $previous_percent && $percent < 100 ) {
|
||||
/**
|
||||
@@ -1,20 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Imagify\User\User;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
/**
|
||||
* Class that handles templates and menus.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
class Imagify_Views {
|
||||
|
||||
/**
|
||||
* Class version.
|
||||
*
|
||||
* @var string
|
||||
* @var string
|
||||
* @since 1.7
|
||||
*/
|
||||
const VERSION = '1.1';
|
||||
@@ -22,56 +20,64 @@ class Imagify_Views {
|
||||
/**
|
||||
* Slug used for the settings page URL.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @access protected
|
||||
*/
|
||||
protected $slug_settings;
|
||||
|
||||
/**
|
||||
* Slug used for the bulk optimization page URL.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @access protected
|
||||
*/
|
||||
protected $slug_bulk;
|
||||
|
||||
/**
|
||||
* Slug used for the "custom folders" page URL.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @var string
|
||||
* @since 1.7
|
||||
* @access protected
|
||||
*/
|
||||
protected $slug_files;
|
||||
|
||||
/**
|
||||
* A list of JS templates to print at the end of the page.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.9
|
||||
* @var array
|
||||
* @since 1.9
|
||||
* @access protected
|
||||
*/
|
||||
protected $templates_in_footer = [];
|
||||
|
||||
/**
|
||||
* Stores the "custom folders" files list instance.
|
||||
*
|
||||
* @var Imagify_Files_List_Table
|
||||
* @since 1.7
|
||||
* @var object Imagify_Files_List_Table
|
||||
* @since 1.7
|
||||
* @access protected
|
||||
*/
|
||||
protected $list_table;
|
||||
|
||||
/**
|
||||
* Filesystem object.
|
||||
*
|
||||
* @var Imagify_Filesystem
|
||||
* @since 1.7.1
|
||||
* @var object Imagify_Filesystem
|
||||
* @since 1.7.1
|
||||
* @access protected
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* The single instance of the class.
|
||||
*
|
||||
* @var object
|
||||
* @since 1.7
|
||||
* @var object
|
||||
* @since 1.7
|
||||
* @access protected
|
||||
*/
|
||||
protected static $_instance;
|
||||
|
||||
@@ -83,7 +89,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* The constructor.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct() {
|
||||
$this->slug_settings = IMAGIFY_SLUG;
|
||||
@@ -95,7 +103,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get the main Instance.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return object Main instance.
|
||||
*/
|
||||
@@ -110,7 +120,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Launch the hooks.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function init() {
|
||||
// Menu items.
|
||||
@@ -140,7 +152,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Add sub-menus for all sites.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function add_site_menus() {
|
||||
$wp_context = imagify_get_context( 'wp' );
|
||||
@@ -173,7 +187,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Add menu and sub-menus in the network admin when Imagify is network-activated.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function add_network_menus() {
|
||||
global $submenu;
|
||||
@@ -216,7 +232,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Add links to the plugin row in the plugins list.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @param array $actions An array of action links.
|
||||
* @return array
|
||||
@@ -236,7 +254,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* The main settings page.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function display_settings_page() {
|
||||
$this->print_template( 'page-settings' );
|
||||
@@ -245,7 +265,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* The bulk optimization page.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function display_bulk_page() {
|
||||
$types = array();
|
||||
@@ -341,7 +363,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* The page displaying the "custom folders" files.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function display_files_list() {
|
||||
$this->print_template( 'page-files-list' );
|
||||
@@ -350,7 +374,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Initiate the "custom folders" list table data.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function load_files_list() {
|
||||
// Instantiate the list.
|
||||
@@ -370,7 +396,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get the settings page slug.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -381,7 +409,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get the bulk optimization page slug.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -392,7 +422,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get the "custom folders" files page slug.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -408,14 +440,16 @@ class Imagify_Views {
|
||||
/**
|
||||
* Tell if we’re displaying the settings page.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_settings_page() {
|
||||
global $pagenow;
|
||||
|
||||
$page = htmlspecialchars( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
||||
|
||||
if ( $this->get_settings_page_slug() !== $page ) {
|
||||
return false;
|
||||
@@ -431,14 +465,16 @@ class Imagify_Views {
|
||||
/**
|
||||
* Tell if we’re displaying the bulk optimization page.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_bulk_page() {
|
||||
global $pagenow;
|
||||
|
||||
$page = htmlspecialchars( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
||||
|
||||
return 'upload.php' === $pagenow && $this->get_bulk_page_slug() === $page;
|
||||
}
|
||||
@@ -446,14 +482,16 @@ class Imagify_Views {
|
||||
/**
|
||||
* Tell if we’re displaying the custom files list page.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_files_page() {
|
||||
global $pagenow;
|
||||
|
||||
$page = htmlspecialchars( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
|
||||
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
||||
|
||||
return 'upload.php' === $pagenow && $this->get_files_page_slug() === $page;
|
||||
}
|
||||
@@ -461,20 +499,26 @@ class Imagify_Views {
|
||||
/**
|
||||
* Tell if we’re displaying the WP media library page.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_wp_library_page() {
|
||||
global $pagenow;
|
||||
|
||||
return 'upload.php' === $pagenow && ! isset( $_GET['page'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
||||
|
||||
return 'upload.php' === $pagenow && ! $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if we’re displaying a media page.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -492,7 +536,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get the remaining quota in percent.
|
||||
*
|
||||
* @since 1.8.1
|
||||
* @since 1.8.1
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@@ -503,7 +549,7 @@ class Imagify_Views {
|
||||
return $quota;
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user = new Imagify_User();
|
||||
$quota = $user->get_percent_unconsumed_quota();
|
||||
|
||||
return $quota;
|
||||
@@ -512,7 +558,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get the HTML class used for the quota (to change the color when out of quota for example).
|
||||
*
|
||||
* @since 1.8.1
|
||||
* @since 1.8.1
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -540,7 +588,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get the HTML tag used for the quota (the weather-like icon).
|
||||
*
|
||||
* @since 1.8.1
|
||||
* @since 1.8.1
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -572,7 +622,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Get a template contents.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @param string $template The template name.
|
||||
* @param mixed $data Some data to pass to the template.
|
||||
@@ -596,7 +648,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Print a template.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @param string $template The template name.
|
||||
* @param mixed $data Some data to pass to the template.
|
||||
@@ -608,7 +662,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Add a template to the list of JS templates to print at the end of the page.
|
||||
*
|
||||
* @since 1.7
|
||||
* @since 1.7
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*
|
||||
* @param string $template The template name.
|
||||
*/
|
||||
@@ -635,7 +691,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Print the JS templates that have been added to the "queue".
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @access public
|
||||
*/
|
||||
public function print_js_templates() {
|
||||
if ( ! $this->templates_in_footer ) {
|
||||
@@ -659,7 +717,9 @@ class Imagify_Views {
|
||||
/**
|
||||
* Create HTML attributes from an array.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 1.9
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param array $attributes A list of attribute pairs.
|
||||
* @return string HTML attributes.
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
|
||||
use Imagify\User\User;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
if ( class_exists( 'C_NextGEN_Bootstrap' ) && class_exists( 'Mixin' ) && get_site_option( 'ngg_options' ) ) :
|
||||
@@ -63,7 +60,7 @@ if ( class_exists( 'C_NextGEN_Bootstrap' ) && class_exists( 'Mixin' ) && get_sit
|
||||
|
||||
add_filter( 'imagify_count_saving_data', 'imagify_ngg_count_saving_data', 8 );
|
||||
$saving_data = imagify_count_saving_data();
|
||||
$user = new User();
|
||||
$user = new Imagify_User();
|
||||
|
||||
$response['imagify_bulk_data'] = array(
|
||||
// User account.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
use Imagify\Notices\Notices;
|
||||
use Imagify\User\User;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
@@ -401,7 +400,7 @@ function imagify_cache_user() {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user = new Imagify_User();
|
||||
$data = (object) get_object_vars( $user );
|
||||
$methods = get_class_methods( $user );
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
=== Imagify – Optimize Images & Convert WebP | Compress Images Easily ===
|
||||
Contributors: wp_rocket, imagify
|
||||
Tags: optimize images, convert webp, webp, image optimization, compress images, image compressor, resize images, reduce image size, performance, image optimizer, core web vitals, best image optimization plugin
|
||||
Tested up to: 6.3
|
||||
Stable tag: 2.1.2
|
||||
Tested up to: 6.1
|
||||
Stable tag: 2.1.1
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@@ -243,10 +243,6 @@ Yes, and no credit card is required.
|
||||
|
||||
No. However, you get 20MB of quota per month for free to optimize your images (around 200 images).
|
||||
|
||||
= Where do I report security bugs found in this plugin? =
|
||||
|
||||
You can report any security bugs found in the source code of the site-reviews plugin through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/imagify). The Patchstack team will assist you with verification, CVE assignment and take care of notifying the developers of this plugin.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Bulk Optimization
|
||||
@@ -258,13 +254,6 @@ You can report any security bugs found in the source code of the site-reviews pl
|
||||
4. Other Media Page
|
||||
|
||||
== Changelog ==
|
||||
= 2.1.2 =
|
||||
- Bugfix: Prevent deprecation notice with PHP 8.1 & 8.2 (#721, #723)
|
||||
- Bugfix: Escape error message before display (#729)
|
||||
- Bugfix: Don't count WebP images in the generate missing WebP images versions (#713)
|
||||
- Bugfix: Improve information related to out of quota on bulk optimization (#714)
|
||||
- Bugfix: Fix optimization filter type working with file filters on media library (#670)
|
||||
|
||||
= 2.1.1 =
|
||||
- Enhancement: Allow WebP images to be optimized by Imagify from the plugin (#611)
|
||||
- Enhancement: Improve error message displayed when an unknown error occured (#637)
|
||||
|
||||
+1
-1
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit799f24bb49776382616b035efaf242fe::getLoader();
|
||||
return ComposerAutoloaderInit4ba6376c0ffc3020053ab8c93bad1e1e::getLoader();
|
||||
|
||||
+55
-53
@@ -45,34 +45,35 @@ class ClassLoader
|
||||
/** @var \Closure(string):void */
|
||||
private static $includeFile;
|
||||
|
||||
/** @var string|null */
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array<string, array<string, int>>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array<string, list<string>>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* List of PSR-0 prefixes
|
||||
*
|
||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
@@ -80,7 +81,8 @@ class ClassLoader
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
@@ -88,20 +90,21 @@ class ClassLoader
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var string|null */
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var array<string, self>
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param string|null $vendorDir
|
||||
* @param ?string $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
@@ -110,7 +113,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
@@ -122,7 +125,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
@@ -130,7 +134,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
@@ -138,7 +143,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
@@ -146,7 +152,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Array of classname => path
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
@@ -154,7 +161,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $classMap Class to filename map
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -171,25 +179,24 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
@@ -198,19 +205,19 @@ class ClassLoader
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -219,9 +226,9 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
@@ -229,18 +236,17 @@ class ClassLoader
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
@@ -250,18 +256,18 @@ class ClassLoader
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -270,8 +276,8 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 base directories
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -288,8 +294,8 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
@@ -423,8 +429,7 @@ class ClassLoader
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
$includeFile = self::$includeFile;
|
||||
$includeFile($file);
|
||||
(self::$includeFile)($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -475,9 +480,9 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return array<string, self>
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
@@ -555,10 +560,7 @@ class ClassLoader
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private static function initializeIncludeClosure()
|
||||
private static function initializeIncludeClosure(): void
|
||||
{
|
||||
if (self::$includeFile !== null) {
|
||||
return;
|
||||
@@ -572,8 +574,8 @@ class ClassLoader
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
self::$includeFile = \Closure::bind(static function($file) {
|
||||
self::$includeFile = static function($file) {
|
||||
include $file;
|
||||
}, null, null);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class InstalledVersions
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class InstalledVersions
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints((string) $constraint);
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
@@ -328,9 +328,7 @@ class InstalledVersions
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require $vendorDir.'/composer/installed.php';
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
@@ -342,17 +340,12 @@ class InstalledVersions
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require __DIR__ . '/installed.php';
|
||||
self::$installed = $required;
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$installed !== array()) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ return array(
|
||||
'Imagify_Regenerate_Thumbnails_Deprecated' => $baseDir . '/inc/deprecated/classes/class-imagify-regenerate-thumbnails-deprecated.php',
|
||||
'Imagify_Requirements' => $baseDir . '/inc/classes/class-imagify-requirements.php',
|
||||
'Imagify_Settings' => $baseDir . '/inc/classes/class-imagify-settings.php',
|
||||
'Imagify_User' => $baseDir . '/inc/deprecated/classes/class-imagify-user.php',
|
||||
'Imagify_User' => $baseDir . '/inc/classes/class-imagify-user.php',
|
||||
'Imagify_Views' => $baseDir . '/inc/classes/class-imagify-views.php',
|
||||
'Imagify_WP_Async_Request' => $baseDir . '/inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php',
|
||||
'Imagify_WP_Background_Process' => $baseDir . '/inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit799f24bb49776382616b035efaf242fe
|
||||
class ComposerAutoloaderInit4ba6376c0ffc3020053ab8c93bad1e1e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@@ -24,12 +24,12 @@ class ComposerAutoloaderInit799f24bb49776382616b035efaf242fe
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit799f24bb49776382616b035efaf242fe', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4ba6376c0ffc3020053ab8c93bad1e1e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\AutoloadWPMediaImagifyWordPressPlugin\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit799f24bb49776382616b035efaf242fe', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4ba6376c0ffc3020053ab8c93bad1e1e', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit799f24bb49776382616b035efaf242fe::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4ba6376c0ffc3020053ab8c93bad1e1e::getInitializer($loader));
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Composer\Autoload;
|
||||
use Composer\AutoloadWPMediaImagifyWordPressPlugin\ClassLoader as ClassLoaderWPMediaImagifyWordPressPlugin;
|
||||
|
||||
|
||||
class ComposerStaticInit799f24bb49776382616b035efaf242fe
|
||||
class ComposerStaticInit4ba6376c0ffc3020053ab8c93bad1e1e
|
||||
{
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'I' =>
|
||||
@@ -115,7 +115,7 @@ class ComposerStaticInit799f24bb49776382616b035efaf242fe
|
||||
'Imagify_Regenerate_Thumbnails_Deprecated' => __DIR__ . '/../..' . '/inc/deprecated/classes/class-imagify-regenerate-thumbnails-deprecated.php',
|
||||
'Imagify_Requirements' => __DIR__ . '/../..' . '/inc/classes/class-imagify-requirements.php',
|
||||
'Imagify_Settings' => __DIR__ . '/../..' . '/inc/classes/class-imagify-settings.php',
|
||||
'Imagify_User' => __DIR__ . '/../..' . '/inc/deprecated/classes/class-imagify-user.php',
|
||||
'Imagify_User' => __DIR__ . '/../..' . '/inc/classes/class-imagify-user.php',
|
||||
'Imagify_Views' => __DIR__ . '/../..' . '/inc/classes/class-imagify-views.php',
|
||||
'Imagify_WP_Async_Request' => __DIR__ . '/../..' . '/inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php',
|
||||
'Imagify_WP_Background_Process' => __DIR__ . '/../..' . '/inc/classes/Dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php',
|
||||
@@ -124,9 +124,9 @@ class ComposerStaticInit799f24bb49776382616b035efaf242fe
|
||||
public static function getInitializer(ClassLoaderWPMediaImagifyWordPressPlugin $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit799f24bb49776382616b035efaf242fe::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit799f24bb49776382616b035efaf242fe::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit799f24bb49776382616b035efaf242fe::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4ba6376c0ffc3020053ab8c93bad1e1e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4ba6376c0ffc3020053ab8c93bad1e1e::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4ba6376c0ffc3020053ab8c93bad1e1e::$classMap;
|
||||
|
||||
}, null, ClassLoaderWPMediaImagifyWordPressPlugin::class);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'wp-media/imagify-plugin',
|
||||
'pretty_version' => 'v2.1.2',
|
||||
'version' => '2.1.2.0',
|
||||
'reference' => '41c64f2a6a85049272b4a32dc1dbb6e68ab37182',
|
||||
'pretty_version' => 'v2.1.1',
|
||||
'version' => '2.1.1.0',
|
||||
'reference' => '46f9df25cc18fe7a8609d1a94bec039e169282da',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@@ -29,9 +29,9 @@
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'wp-media/imagify-plugin' => array(
|
||||
'pretty_version' => 'v2.1.2',
|
||||
'version' => '2.1.2.0',
|
||||
'reference' => '41c64f2a6a85049272b4a32dc1dbb6e68ab37182',
|
||||
'pretty_version' => 'v2.1.1',
|
||||
'version' => '2.1.1.0',
|
||||
'reference' => '46f9df25cc18fe7a8609d1a94bec039e169282da',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
||||
@@ -15,7 +15,7 @@ foreach ( $notices as $type => $type_notices ) {
|
||||
?>
|
||||
<div class="<?php echo $type; ?> settings-error notice is-dismissible">
|
||||
<?php foreach ( $type_notices as $details ) { ?>
|
||||
<p><strong><?php echo wp_kses( $details['message'], [ 'code' => [] ] ); ?></strong></p>
|
||||
<p><strong><?php echo $details['message']; ?></strong></p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
|
||||
use Imagify\User\User;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
?>
|
||||
<div class="wrap imagify-settings imagify-bulk">
|
||||
@@ -89,7 +86,7 @@ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
<?php
|
||||
if ( ( ! defined( 'IMAGIFY_HIDDEN_ACCOUNT' ) || ! IMAGIFY_HIDDEN_ACCOUNT ) && Imagify_Requirements::is_api_key_valid() ) {
|
||||
$user = new User();
|
||||
$user = new Imagify_User();
|
||||
?>
|
||||
<div class="imagify-options-title">
|
||||
<div class="imagify-th-titles imagify-flex imagify-vcenter">
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
|
||||
use Imagify\User\User;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
if ( defined( 'IMAGIFY_HIDDEN_ACCOUNT' ) && IMAGIFY_HIDDEN_ACCOUNT ) {
|
||||
@@ -33,7 +30,7 @@ if ( Imagify_Requirements::is_api_key_valid() ) {
|
||||
<div class="imagify-settings-section">
|
||||
|
||||
<?php
|
||||
$imagify_user = new User();
|
||||
$imagify_user = new Imagify_User();
|
||||
|
||||
if (
|
||||
$imagify_user->is_free()
|
||||
|
||||
@@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wc-admin-layout', 'wc-components', 'wc-csv', 'wc-currency', 'wc-customer-effort-score', 'wc-date', 'wc-experimental', 'wc-explat', 'wc-navigation', 'wc-notices', 'wc-number', 'wc-product-editor', 'wc-settings', 'wc-store-data', 'wc-tracks', 'wp-a11y', 'wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-viewport', 'wp-warning'), 'version' => '23912561a6f0642f272713fb0b777e24');
|
||||
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wc-admin-layout', 'wc-components', 'wc-csv', 'wc-currency', 'wc-customer-effort-score', 'wc-date', 'wc-experimental', 'wc-explat', 'wc-navigation', 'wc-notices', 'wc-number', 'wc-product-editor', 'wc-settings', 'wc-store-data', 'wc-tracks', 'wp-a11y', 'wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-viewport', 'wp-warning'), 'version' => '7b0bf67d40b61fcab89fdf5cdef5da71');
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[7844],{28029:(e,a,s)=>{s.r(a),s.d(a,{SetupTasksPanel:()=>n,default:()=>l});var c=s(69307),t=s(159);const n=e=>{let{query:a}=e;return(0,c.createElement)("div",{className:"woocommerce-setup-panel"},(0,c.createElement)(t.TaskLists,{query:a}))},l=n}}]);
|
||||
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[7844],{28029:(e,a,s)=>{s.r(a),s.d(a,{SetupTasksPanel:()=>n,default:()=>l});var c=s(69307),t=s(95817);const n=e=>{let{query:a}=e;return(0,c.createElement)("div",{className:"woocommerce-setup-panel"},(0,c.createElement)(t.TaskLists,{query:a}))},l=n}}]);
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[925],{25:(e,t,n)=>{n.r(t),n.d(t,{CustomizeStoreController:()=>T,customizeStoreStateMachineActions:()=>h,customizeStoreStateMachineDefinition:()=>p,customizeStoreStateMachineServices:()=>u,default:()=>v});var r={};n.r(r),n.d(r,{assignThemeCards:()=>m});var o={};n.r(o),n.d(o,{fetchThemeCards:()=>d});var i=n(69307),a=n(11122),s=n(28226),c=n(50883),l=n(34374);const m=(0,n(5031).f0)({intro:(e,t)=>{const n=t.data;return{...e.intro,themeCards:n}}}),d=async()=>[{name:"Twenty Twenty One",description:"The default theme for WordPress."},{name:"Twenty Twenty",description:"The previous default theme for WordPress."}];var E=n(1718);const u={...o},h={...r},p=(0,a.C)({id:"customizeStore",initial:"intro",predictableActionArguments:!0,preserveActionOrder:!0,schema:{context:{},events:{},services:{}},context:{intro:{themeCards:[],activeTheme:""}},states:{intro:{id:"intro",initial:"preIntro",states:{preIntro:{invoke:{src:"fetchThemeCards",onDone:{target:"intro",actions:["assignThemeCards"]}}},intro:{meta:{component:e=>{let{sendEvent:t,context:n}=e;const{intro:{themeCards:r,activeTheme:o}}=n;return(0,i.createElement)(i.Fragment,null,(0,i.createElement)("h1",null,"Intro"),(0,i.createElement)("div",null,"Active theme: ",o),null==r?void 0:r.map((e=>(0,i.createElement)("button",{key:e.name,onClick:()=>t({type:"SELECTED_NEW_THEME",payload:{theme:e.name}})},e.name))),(0,i.createElement)("button",{onClick:()=>t({type:"DESIGN_WITH_AI"})},"Design with AI"))}}}},on:{DESIGN_WITH_AI:{target:"designWithAi"},SELECTED_ACTIVE_THEME:{target:"assemblerHub"},CLICKED_ON_BREADCRUMB:{target:"backToHomescreen"},SELECTED_NEW_THEME:{target:"? Appearance Task ?"},SELECTED_BROWSE_ALL_THEMES:{target:"? Appearance Task ?"}}},designWithAi:{initial:"preDesignWithAi",states:{preDesignWithAi:{always:{target:"designWithAi"}},designWithAi:{meta:{component:e=>{let{sendEvent:t}=e;return(0,i.createElement)(i.Fragment,null,(0,i.createElement)("h1",null,"Design with AI"),(0,i.createElement)("button",{onClick:()=>t({type:"THEME_SUGGESTED"})},"Back to intro"))}}}},on:{THEME_SUGGESTED:{target:"assemblerHub"}}},assemblerHub:{on:{FINISH_CUSTOMIZATION:{target:"backToHomescreen"}}},backToHomescreen:{},"? Appearance Task ?":{}}}),T=e=>{let{actionOverrides:t,servicesOverrides:n}=e;(0,l.p0)(["woocommerce-customize-store"]);const r=(0,i.useMemo)((()=>p.withConfig({services:{...u,...n},actions:{...h,...t},guards:{}})),[t,n]),[o,a,m]=(0,s.e)(r,{devTools:!1}),d=(0,c.v)(m,(e=>{var t;return(0,E.r)(null!==(t=null==e?void 0:e.meta)&&void 0!==t?t:void 0)})),[T,v]=(0,i.useState)(null);(0,i.useEffect)((()=>{null!=d&&d.component&&v((()=>null==d?void 0:d.component))}),[T,null==d?void 0:d.component]);const g=o.value instanceof Object?Object.keys(o.value)[0]:o.value;return(0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",{className:`woocommerce-profile-wizard__container woocommerce-profile-wizard__step-${g}`},T?(0,i.createElement)(T,{sendEvent:a,context:o.context}):(0,i.createElement)("div",null)))},v=T},1718:(e,t,n)=>{function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(!t.has(e)){t.add(e);for(const n in e)if(e.hasOwnProperty(n)){if("component"===n)return e;if("object"==typeof e[n]&&null!==e[n]){const o=r(e[n],t);if(void 0!==o)return o}}}}n.d(t,{r:()=>r})}}]);
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wc-currency', 'wc-date', 'wc-navigation', 'wc-store-data', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => '32ba1c8d1980522384394719dce73738');
|
||||
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wc-currency', 'wc-date', 'wc-navigation', 'wc-store-data', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => '2e6e2a0c15101a393ed4caf0a7837c54');
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user