Plugin Directory

Changeset 3143189


Ignore:
Timestamp:
08/28/2024 08:12:33 PM (19 months ago)
Author:
hcaptcha
Message:

Update to version 4.5.0 from GitHub

Location:
hcaptcha-for-forms-and-more
Files:
11 added
3 deleted
73 edited
1 copied

Legend:

Unmodified
Added
Removed
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/css/settings-base.css

    r3114572 r3143189  
    1717
    1818.hcaptcha-settings-tabs {
     19    position: sticky;
     20    top: 0;
     21    z-index: 2; /* +1 to .hcaptcha-header bar z-index, to overlap a bit */
    1922    display: flex;
    2023    flex-wrap: wrap;
     
    4649
    4750.hcaptcha-header-bar {
     51    position: sticky;
     52    top: 60px;
     53    z-index: 1;
     54    background: #f0f2f5;
    4855    display: flex;
    4956    justify-content: space-between;
    5057    align-items: center;
    51     margin: 0;
     58    margin: 0 -20px;
     59    padding: 0 20px;
    5260}
    5361
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/css/settings-base.min.css

    r3114572 r3143189  
    1 body.settings_page_hcaptcha{background:#f0f2f5;color:#5c6f8a}.wrap h1.hcaptcha-settings-header{align-items:center;display:flex;font-size:34px;font-weight:700}.hcaptcha-logo{height:64px;margin:10px 5px 10px 0}.hcaptcha-settings-tabs{background:#fff;display:flex;flex-wrap:wrap;justify-content:space-between;line-height:4.5em;margin:10px -20px 0;padding:0 20px}.hcaptcha-settings-tab{border-bottom:2px solid transparent;color:#646970;display:inline-block;font-size:1.1em;margin-right:30px;text-decoration:none}.hcaptcha-settings-tab:hover{border-bottom-color:#025176!important;border-bottom:2px solid;color:#666}.hcaptcha-settings-tab.active{border-bottom:2px solid #0075ab}.hcaptcha-header-bar{align-items:center;display:flex;justify-content:space-between;margin:0}#hcaptcha-options h2{color:#5c6f8a;font-size:1.5em}#hcaptcha-options h2~*{display:none}#hcaptcha-options h3{color:#5c6f8a;margin:1.5em 0 1em}#hcaptcha-options .notice-dismiss:before{color:#5c6f8a}#hcaptcha-options table tbody tr td{margin:0;padding:0;position:relative}#hcaptcha-options table tr td input[type=checkbox]{border:none;box-shadow:none;display:inline;height:1.25rem;margin:-.125rem .5rem 0 0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:before{background:url(../images/checkbox-off.svg);background-size:cover;content:"";display:inline-block;height:1.25rem;margin:0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:checked:before{background:no-repeat url(../images/checkbox-on.svg);background-size:cover}#hcaptcha-options fieldset:disabled{color:#dadada}#hcaptcha-options .button-primary{background-color:#026593;border-color:#026593;color:#fff}#hcaptcha-options .button-primary:hover{background-color:#025176}#hcaptcha-options .button-secondary{background-color:#fff;border-color:#026593;color:#026593}#hcaptcha-options .button-secondary:hover{background-color:#ccc}#hcaptcha-options a{color:#0075ab}#hcaptcha-navigation a{border-color:#0075ab}#hcaptcha-options a.hcaptcha-settings-tab{color:#5c6f8a}#hcaptcha-options .helper:before{background:#5c6f8a;border-radius:1.2em;color:#fff;content:"?";height:1.2em;position:absolute;right:0;text-align:center;top:0;transform:translateY(-26px);width:1.2em}#hcaptcha-options fieldset+.helper:before{top:50%;transform:translate(25px,-.8em)}#hcaptcha-options .helper .helper-content{background:#5c6f8a;box-sizing:border-box;color:#f0f2f5;display:none;padding:.5em 1em;position:absolute;right:0;top:0;transform:translate(1px,10px);width:100%}#hcaptcha-options fieldset+.helper .helper-content{top:50%;transform:translate(25px,25px);width:calc(100% + 25px)}#hcaptcha-options .helper:hover{cursor:help}#hcaptcha-options .helper:hover .helper-content{display:block;z-index:1}#hcaptcha-options .helper .helper-content:after{border:10px solid transparent;border-bottom-color:#5c6f8a;content:"";position:absolute;right:0;top:0;transform:translateY(-100%)}#hcaptcha-options .helper .helper-content a{color:#fff}#hcaptcha-message{box-sizing:border-box}#hcaptcha-message>p{font-size:13px;font-weight:600;line-height:1.5;margin:.5em 0}@keyframes blink{0%{opacity:1}16.7%{opacity:0}33.3%{opacity:1}50%{opacity:0}66.7%{opacity:1}83.3%{opacity:0}to{opacity:1}}.blink{animation:blink 3s linear}.hcaptcha-hide{display:none}.hcaptcha-excerpt{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hcaptcha-excerpt:hover .hcaptcha-hide{background:#5c6f8a;border:1px solid #c3c4c7;border-radius:6px;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);color:#f0f2f5;display:block;left:0;max-width:300px;padding:8px 10px;position:absolute;text-align:center;top:0;white-space:normal;width:max-content;z-index:1}@media (max-width:782px){.hcaptcha-settings-tabs{margin:10px -12px 0 -10px;padding:0 12px 0 10px}}@media (max-width:600px){#hcaptcha-options table tbody{grid-template-columns:1fr}#hcaptcha-options table tbody tr{position:relative}#hcaptcha-options fieldset+.helper:before{transform:translateY(-.7em)}#hcaptcha-options fieldset+.helper .helper-content{transform:translateY(25px);width:100%}#hcaptcha-options .helper{z-index:1}.hcaptcha-settings-tab{margin-right:15px}}
     1body.settings_page_hcaptcha{background:#f0f2f5;color:#5c6f8a}.wrap h1.hcaptcha-settings-header{align-items:center;display:flex;font-size:34px;font-weight:700}.hcaptcha-logo{height:64px;margin:10px 5px 10px 0}.hcaptcha-settings-tabs{background:#fff;display:flex;flex-wrap:wrap;justify-content:space-between;line-height:4.5em;margin:10px -20px 0;padding:0 20px;position:sticky;top:0;z-index:2}.hcaptcha-settings-tab{border-bottom:2px solid transparent;color:#646970;display:inline-block;font-size:1.1em;margin-right:30px;text-decoration:none}.hcaptcha-settings-tab:hover{border-bottom-color:#025176!important;border-bottom:2px solid;color:#666}.hcaptcha-settings-tab.active{border-bottom:2px solid #0075ab}.hcaptcha-header-bar{align-items:center;background:#f0f2f5;display:flex;justify-content:space-between;margin:0 -20px;padding:0 20px;position:sticky;top:60px;z-index:1}#hcaptcha-options h2{color:#5c6f8a;font-size:1.5em}#hcaptcha-options h2~*{display:none}#hcaptcha-options h3{color:#5c6f8a;margin:1.5em 0 1em}#hcaptcha-options .notice-dismiss:before{color:#5c6f8a}#hcaptcha-options table tbody tr td{margin:0;padding:0;position:relative}#hcaptcha-options table tr td input[type=checkbox]{border:none;box-shadow:none;display:inline;height:1.25rem;margin:-.125rem .5rem 0 0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:before{background:url(../images/checkbox-off.svg);background-size:cover;content:"";display:inline-block;height:1.25rem;margin:0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:checked:before{background:no-repeat url(../images/checkbox-on.svg);background-size:cover}#hcaptcha-options fieldset:disabled{color:#dadada}#hcaptcha-options .button-primary{background-color:#026593;border-color:#026593;color:#fff}#hcaptcha-options .button-primary:hover{background-color:#025176}#hcaptcha-options .button-secondary{background-color:#fff;border-color:#026593;color:#026593}#hcaptcha-options .button-secondary:hover{background-color:#ccc}#hcaptcha-options a{color:#0075ab}#hcaptcha-navigation a{border-color:#0075ab}#hcaptcha-options a.hcaptcha-settings-tab{color:#5c6f8a}#hcaptcha-options .helper:before{background:#5c6f8a;border-radius:1.2em;color:#fff;content:"?";height:1.2em;position:absolute;right:0;text-align:center;top:0;transform:translateY(-26px);width:1.2em}#hcaptcha-options fieldset+.helper:before{top:50%;transform:translate(25px,-.8em)}#hcaptcha-options .helper .helper-content{background:#5c6f8a;box-sizing:border-box;color:#f0f2f5;display:none;padding:.5em 1em;position:absolute;right:0;top:0;transform:translate(1px,10px);width:100%}#hcaptcha-options fieldset+.helper .helper-content{top:50%;transform:translate(25px,25px);width:calc(100% + 25px)}#hcaptcha-options .helper:hover{cursor:help}#hcaptcha-options .helper:hover .helper-content{display:block;z-index:1}#hcaptcha-options .helper .helper-content:after{border:10px solid transparent;border-bottom-color:#5c6f8a;content:"";position:absolute;right:0;top:0;transform:translateY(-100%)}#hcaptcha-options .helper .helper-content a{color:#fff}#hcaptcha-message{box-sizing:border-box}#hcaptcha-message>p{font-size:13px;font-weight:600;line-height:1.5;margin:.5em 0}@keyframes blink{0%{opacity:1}16.7%{opacity:0}33.3%{opacity:1}50%{opacity:0}66.7%{opacity:1}83.3%{opacity:0}to{opacity:1}}.blink{animation:blink 3s linear}.hcaptcha-hide{display:none}.hcaptcha-excerpt{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hcaptcha-excerpt:hover .hcaptcha-hide{background:#5c6f8a;border:1px solid #c3c4c7;border-radius:6px;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);color:#f0f2f5;display:block;left:0;max-width:300px;padding:8px 10px;position:absolute;text-align:center;top:0;white-space:normal;width:max-content;z-index:1}@media (max-width:782px){.hcaptcha-settings-tabs{margin:10px -12px 0 -10px;padding:0 12px 0 10px}}@media (max-width:600px){#hcaptcha-options table tbody{grid-template-columns:1fr}#hcaptcha-options table tbody tr{position:relative}#hcaptcha-options fieldset+.helper:before{transform:translateY(-.7em)}#hcaptcha-options fieldset+.helper .helper-content{transform:translateY(25px);width:100%}#hcaptcha-options .helper{z-index:1}.hcaptcha-settings-tab{margin-right:15px}}
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/js/hcaptcha-mailpoet.js

    r3026321 r3143189  
    1515        }
    1616
    17         const urlParams = new URLSearchParams( data );
    18         const formId = urlParams.get( 'data[form_id]' );
    19         const $form = $( 'input[name="data[form_id]"][value=' + formId + ']' ).parent( 'form' );
     17        // eslint-disable-next-line @wordpress/no-global-active-element
     18        const eventTarget = options.context || document.activeElement;
     19        const $form = $( eventTarget.closest( 'form' ) );
     20
    2021        let response = $form.find( '[name="h-captcha-response"]' ).val();
    2122        response = response ? response : '';
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/js/hcaptcha-mailpoet.min.js

    r3026321 r3143189  
    1 (()=>{var a;(a=jQuery).ajaxPrefilter((function(t){var e,i=null!==(e=t.data)&&void 0!==e?e:"",n="";if(i.startsWith("action=mailpoet")&&(n="hcaptcha_mailpoet_nonce"),n){var r=new URLSearchParams(i).get("data[form_id]"),c=a('input[name="data[form_id]"][value='+r+"]").parent("form"),d=c.find('[name="h-captcha-response"]').val();d=d||"";var h=c.find('[name="hcaptcha-widget-id"]').val();h=h||"";var o=c.find('[name="'+n+'"]').val();o=o||"",t.data+="&h-captcha-response="+d+"&hcaptcha-widget-id="+h+"&"+n+"="+o}}))})();
     1(()=>{var a;(a=jQuery).ajaxPrefilter((function(t){var e,c="";if((null!==(e=t.data)&&void 0!==e?e:"").startsWith("action=mailpoet")&&(c="hcaptcha_mailpoet_nonce"),c){var n=t.context||document.activeElement,i=a(n.closest("form")),o=i.find('[name="h-captcha-response"]').val();o=o||"";var r=i.find('[name="hcaptcha-widget-id"]').val();r=r||"";var d=i.find('[name="'+c+'"]').val();d=d||"",t.data+="&h-captcha-response="+o+"&hcaptcha-widget-id="+r+"&"+c+"="+d}}))})();
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/js/integrations.js

    r3114572 r3143189  
    2525 */
    2626const integrations = function( $ ) {
     27    const adminBar = document.querySelector( '#wpadminbar' );
     28    const tabs = document.querySelector( '.hcaptcha-settings-tabs' );
     29    const headerBar = document.querySelector( '.hcaptcha-header-bar' );
    2730    const msgSelector = '#hcaptcha-message';
    2831    let $message = $( msgSelector );
     
    3033    const $adminmenuwrap = $( '#adminmenuwrap' );
    3134    const $search = $( '#hcaptcha-integrations-search' );
     35
     36    function getStickyHeight() {
     37        const isAbsolute = adminBar ? window.getComputedStyle( adminBar ).position === 'absolute' : true;
     38        const adminBarHeight = ( adminBar && ! isAbsolute ) ? adminBar.offsetHeight : 0;
     39        const tabsHeight = tabs ? tabs.offsetHeight : 0;
     40        const headerBarHeight = headerBar ? headerBar.offsetHeight : 0;
     41
     42        return adminBarHeight + tabsHeight + headerBarHeight;
     43    }
    3244
    3345    function clearMessage() {
     
    223235
    224236                    const $table = $( '.form-table' ).eq( activate ? 0 : 1 );
    225                     const top = $wpWrap.position().top;
    226237
    227238                    swapThemes( activate, entity, newTheme );
     
    232243                    $( 'html, body' ).animate(
    233244                        {
    234                             scrollTop: $tr.offset().top - top - $message.outerHeight(),
     245                            scrollTop: $tr.offset().top - getStickyHeight(),
    235246                        },
    236247                        1000
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/js/integrations.min.js

    r3114572 r3143189  
    1 (()=>{function t(t,a){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var n,i,o,r,c=[],s=!0,l=!1;try{if(o=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;s=!1}else for(;!(s=(n=o.call(a)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{if(!s&&null!=a.return&&(r=a.return(),Object(r)!==r))return}finally{if(l)throw i}}return c}}(t,a)||function(t,a){if(t){if("string"==typeof t)return e(t,a);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,a):void 0}}(t,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=Array(e);a<e;a++)n[a]=t[a];return n}var a=function(e){var a="#hcaptcha-message",n=e(a),i=e("#wpwrap"),o=e("#adminmenuwrap"),r=e("#hcaptcha-integrations-search");function c(t,a){n.removeClass(),n.addClass(a+" notice settings-error is-dismissible"),n.html("<p>".concat(t,"</p>")),e(document).trigger("wp-updates-notice-added");var r=n.clone();n.css("visibility","hidden"),r.css("margin","0px"),r.css("top",i.position().top),r.css("z-index","999999");var c="block"===o.css("display")?o.width():0;r.css("left",c),r.width(e(window).width()-c),r.css("position","fixed"),e("body").append(r),setTimeout((function(){n.css("visibility","unset"),r.remove()}),3e3)}function s(t){c(t,"notice-error")}function l(t){return t.is(jQuery(".form-table").eq(0))}function d(t,a,n){var i=!1,o=a.toLowerCase(),r=!l(t),c=n.find("fieldset");c.attr("disabled",r),c.find("input").attr("disabled",r),t.find("tbody").children().each((function(t,a){var r=e(a).find(".hcaptcha-integrations-logo img").attr("alt");if((r=(r=r||"").replace(" Logo","")).toLowerCase()>o)return n.insertBefore(e(a)),i=!0,!1})),i||t.find("tbody").append(n)}e(".form-table img").on("click",(function(o){function r(){var a,o,r=v?"on":"off",h=(o=document.querySelector(".kagg-dialog select"))&&null!==(a=o.value)&&void 0!==a?a:"",m={action:HCaptchaIntegrationsObject.action,nonce:HCaptchaIntegrationsObject.nonce,activate:v,entity:u,status:g,newTheme:h};p.addClass(r),e.post({url:HCaptchaIntegrationsObject.ajaxUrl,data:m}).done((function(a){if(void 0!==a.success)if(void 0!==a.data.themes&&(window.HCaptchaIntegrationsObject.themes=a.data.themes,window.HCaptchaIntegrationsObject.defaultTheme=a.data.defaultTheme),a.success){var o=e(".form-table").eq(v?0:1),r=i.position().top;!function(t,a,n){if("theme"===a){var i=e(".form-table"),o=t?"":'[data-label="'+n+'"]',r=i.eq(t?0:1).find('.hcaptcha-integrations-logo img[data-entity="theme"]'+o);if(r.length){var c=i.eq(t?1:0),s=r.closest("tr");d(c,r.attr("data-label"),s)}}}(v,u,h),d(o,f,p),function(t){c(t,"notice-success")}(a.data.message),function(a){for(var n=e(".form-table"),i=0,o=Object.entries(a);i<o.length;i++){var r=t(o[i],2),c=r[0],s=r[1],h="hcaptcha-integrations-"+c.replace(/_/g,"-"),u=e("tr.".concat(h));l(u.closest(".form-table"))!==s&&d(n.eq(s?0:1),u.find(".hcaptcha-integrations-logo img").attr("alt"),u)}}(a.data.stati),e("html, body").animate({scrollTop:p.offset().top-r-n.outerHeight()},1e3)}else{var g,m;s(null!==(g=null===(m=a.data)||void 0===m?void 0:m.message)&&void 0!==g?g:a.data)}else c(HCaptchaIntegrationsObject.unexpectedErrorMsg,"notice-error")})).fail((function(t){s(t.statusText)})).always((function(){p.removeClass("on off")}))}o.preventDefault(),n.remove(),e('<div id="hcaptcha-message"></div>').insertAfter(".hcaptcha-header-bar"),n=e(a);var h=e(o.target),u=h.data("entity");if(u=u||"",-1!==e.inArray(u,["core","theme","plugin"])&&-1===e.inArray(u,["core"])){var f=h.attr("alt");f=(f=f||"").replace(" Logo","");var p=h.closest("tr"),g=p.attr("class");g=g.replace("hcaptcha-integrations-","");var m,v,b="";if(p.find("fieldset").attr("disabled"))m="plugin"===u?HCaptchaIntegrationsObject.activateMsg:HCaptchaIntegrationsObject.activateThemeMsg,v=!0;else{if("plugin"===u)m=HCaptchaIntegrationsObject.deactivateMsg;else{for(var y in m=HCaptchaIntegrationsObject.deactivateThemeMsg,b="<p>"+HCaptchaIntegrationsObject.selectThemeMsg+"</p>",b+="<select>",HCaptchaIntegrationsObject.themes){var C=y===HCaptchaIntegrationsObject.defaultTheme?' selected="selected"':"";b+='<option value="'.concat(y,'"').concat(C,">").concat(HCaptchaIntegrationsObject.themes[y],"</option>")}b+="</select>"}v=!1}if(-1===e.inArray(u,["theme"])||v||0!==Object.keys(HCaptchaIntegrationsObject.themes).length){if(!p.find(".hcaptcha-integrations-logo").data("installed"))return m=(m=HCaptchaIntegrationsObject.installMsg).replace("%s",f),void kaggDialog.confirm({title:m,content:b,type:"install",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}});o.ctrlKey?r():(m=m.replace("%s",f),kaggDialog.confirm({title:m,content:b,type:v?"activate":"deactivate",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText},cancel:{text:HCaptchaIntegrationsObject.CancelBtnText}},onAction:function(t){t&&r()}}))}else kaggDialog.confirm({title:HCaptchaIntegrationsObject.onlyOneThemeMsg,content:"",type:"info",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}})}}));var h,u,f;r.on("input",(h=function(){var t=r.val().trim().toLowerCase(),a=e(".hcaptcha-integrations-logo img"),n=null;if(a.each((function(a,i){var o=e(i);if("core"!==o.data("entity")){var r,c=o.closest("tr");o.data("label").toLowerCase().includes(t)?(c.show(),n=null!==(r=n)&&void 0!==r?r:c):c.hide()}})),n){var i=n.offset().top+n.outerHeight()-e(window).height()+5;e("html").stop().animate({scrollTop:i},1e3)}},u=100,function(){var t=this,e=arguments;clearTimeout(f),f=setTimeout((function(){return h.apply(t,e)}),u)})),e("#hcaptcha-options").keydown((function(t){e(t.target).is(r)&&13===t.which&&t.preventDefault()}))};window.hCaptchaIntegrations=a,jQuery(document).ready(a)})();
     1(()=>{function t(t,a){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var n,i,o,r,c=[],s=!0,l=!1;try{if(o=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;s=!1}else for(;!(s=(n=o.call(a)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{if(!s&&null!=a.return&&(r=a.return(),Object(r)!==r))return}finally{if(l)throw i}}return c}}(t,a)||function(t,a){if(t){if("string"==typeof t)return e(t,a);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,a):void 0}}(t,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=Array(e);a<e;a++)n[a]=t[a];return n}var a=function(e){var a=document.querySelector("#wpadminbar"),n=document.querySelector(".hcaptcha-settings-tabs"),i=document.querySelector(".hcaptcha-header-bar"),o="#hcaptcha-message",r=e(o),c=e("#wpwrap"),s=e("#adminmenuwrap"),l=e("#hcaptcha-integrations-search");function d(t,a){r.removeClass(),r.addClass(a+" notice settings-error is-dismissible"),r.html("<p>".concat(t,"</p>")),e(document).trigger("wp-updates-notice-added");var n=r.clone();r.css("visibility","hidden"),n.css("margin","0px"),n.css("top",c.position().top),n.css("z-index","999999");var i="block"===s.css("display")?s.width():0;n.css("left",i),n.width(e(window).width()-i),n.css("position","fixed"),e("body").append(n),setTimeout((function(){r.css("visibility","unset"),n.remove()}),3e3)}function h(t){d(t,"notice-error")}function u(t){return t.is(jQuery(".form-table").eq(0))}function f(t,a,n){var i=!1,o=a.toLowerCase(),r=!u(t),c=n.find("fieldset");c.attr("disabled",r),c.find("input").attr("disabled",r),t.find("tbody").children().each((function(t,a){var r=e(a).find(".hcaptcha-integrations-logo img").attr("alt");if((r=(r=r||"").replace(" Logo","")).toLowerCase()>o)return n.insertBefore(e(a)),i=!0,!1})),i||t.find("tbody").append(n)}e(".form-table img").on("click",(function(c){function s(){var o,r,c=y?"on":"off",s=(r=document.querySelector(".kagg-dialog select"))&&null!==(o=r.value)&&void 0!==o?o:"",l={action:HCaptchaIntegrationsObject.action,nonce:HCaptchaIntegrationsObject.nonce,activate:y,entity:p,status:b,newTheme:s};m.addClass(c),e.post({url:HCaptchaIntegrationsObject.ajaxUrl,data:l}).done((function(o){if(void 0!==o.success)if(void 0!==o.data.themes&&(window.HCaptchaIntegrationsObject.themes=o.data.themes,window.HCaptchaIntegrationsObject.defaultTheme=o.data.defaultTheme),o.success){var r,c=e(".form-table").eq(y?0:1);!function(t,a,n){if("theme"===a){var i=e(".form-table"),o=t?"":'[data-label="'+n+'"]',r=i.eq(t?0:1).find('.hcaptcha-integrations-logo img[data-entity="theme"]'+o);if(r.length){var c=i.eq(t?1:0),s=r.closest("tr");f(c,r.attr("data-label"),s)}}}(y,p,s),f(c,g,m),function(t){d(t,"notice-success")}(o.data.message),function(a){for(var n=e(".form-table"),i=0,o=Object.entries(a);i<o.length;i++){var r=t(o[i],2),c=r[0],s=r[1],l="hcaptcha-integrations-"+c.replace(/_/g,"-"),d=e("tr.".concat(l));u(d.closest(".form-table"))!==s&&f(n.eq(s?0:1),d.find(".hcaptcha-integrations-logo img").attr("alt"),d)}}(o.data.stati),e("html, body").animate({scrollTop:m.offset().top-(r=!a||"absolute"===window.getComputedStyle(a).position,(a&&!r?a.offsetHeight:0)+(n?n.offsetHeight:0)+(i?i.offsetHeight:0))},1e3)}else{var l,b;h(null!==(l=null===(b=o.data)||void 0===b?void 0:b.message)&&void 0!==l?l:o.data)}else d(HCaptchaIntegrationsObject.unexpectedErrorMsg,"notice-error")})).fail((function(t){h(t.statusText)})).always((function(){m.removeClass("on off")}))}c.preventDefault(),r.remove(),e('<div id="hcaptcha-message"></div>').insertAfter(".hcaptcha-header-bar"),r=e(o);var l=e(c.target),p=l.data("entity");if(p=p||"",-1!==e.inArray(p,["core","theme","plugin"])&&-1===e.inArray(p,["core"])){var g=l.attr("alt");g=(g=g||"").replace(" Logo","");var m=l.closest("tr"),b=m.attr("class");b=b.replace("hcaptcha-integrations-","");var v,y,C="";if(m.find("fieldset").attr("disabled"))v="plugin"===p?HCaptchaIntegrationsObject.activateMsg:HCaptchaIntegrationsObject.activateThemeMsg,y=!0;else{if("plugin"===p)v=HCaptchaIntegrationsObject.deactivateMsg;else{for(var w in v=HCaptchaIntegrationsObject.deactivateThemeMsg,C="<p>"+HCaptchaIntegrationsObject.selectThemeMsg+"</p>",C+="<select>",HCaptchaIntegrationsObject.themes){var j=w===HCaptchaIntegrationsObject.defaultTheme?' selected="selected"':"";C+='<option value="'.concat(w,'"').concat(j,">").concat(HCaptchaIntegrationsObject.themes[w],"</option>")}C+="</select>"}y=!1}if(-1===e.inArray(p,["theme"])||y||0!==Object.keys(HCaptchaIntegrationsObject.themes).length){if(!m.find(".hcaptcha-integrations-logo").data("installed"))return v=(v=HCaptchaIntegrationsObject.installMsg).replace("%s",g),void kaggDialog.confirm({title:v,content:C,type:"install",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}});c.ctrlKey?s():(v=v.replace("%s",g),kaggDialog.confirm({title:v,content:C,type:y?"activate":"deactivate",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText},cancel:{text:HCaptchaIntegrationsObject.CancelBtnText}},onAction:function(t){t&&s()}}))}else kaggDialog.confirm({title:HCaptchaIntegrationsObject.onlyOneThemeMsg,content:"",type:"info",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}})}}));var p,g,m;l.on("input",(p=function(){var t=l.val().trim().toLowerCase(),a=e(".hcaptcha-integrations-logo img"),n=null;if(a.each((function(a,i){var o=e(i);if("core"!==o.data("entity")){var r,c=o.closest("tr");o.data("label").toLowerCase().includes(t)?(c.show(),n=null!==(r=n)&&void 0!==r?r:c):c.hide()}})),n){var i=n.offset().top+n.outerHeight()-e(window).height()+5;e("html").stop().animate({scrollTop:i},1e3)}},g=100,function(){var t=this,e=arguments;clearTimeout(m),m=setTimeout((function(){return p.apply(t,e)}),g)})),e("#hcaptcha-options").keydown((function(t){e(t.target).is(l)&&13===t.which&&t.preventDefault()}))};window.hCaptchaIntegrations=a,jQuery(document).ready(a)})();
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/js/settings-base.js

    r3114572 r3143189  
    1010    const msgSelector = '#hcaptcha-message';
    1111
    12     // Move WP notices to the message area.
    13     $( h2Selector ).siblings().appendTo( msgSelector );
     12    function setHeaderBarTop() {
     13        const adminBar = document.querySelector( '#wpadminbar' );
     14        const tabs = document.querySelector( '.hcaptcha-settings-tabs' );
     15        const headerBar = document.querySelector( '.hcaptcha-header-bar' );
     16
     17        const isAbsolute = adminBar ? window.getComputedStyle( adminBar ).position === 'absolute' : true;
     18        const adminBarHeight = ( adminBar && ! isAbsolute ) ? adminBar.offsetHeight : 0;
     19        const tabsHeight = tabs ? tabs.offsetHeight : 0;
     20        // The -1 to put header bar a bit under tabs. It is a precaution when heights are in fractional pixels.
     21        const totalHeight = adminBarHeight + tabsHeight - 1;
     22
     23        if ( tabs ) {
     24            tabs.style.top = `${ adminBarHeight }px`;
     25        }
     26
     27        if ( headerBar ) {
     28            headerBar.style.top = `${ totalHeight }px`;
     29        }
     30    }
    1431
    1532    /**
     
    4360    }
    4461
     62    // Move WP notices to the message area.
     63    $( h2Selector ).siblings().appendTo( msgSelector );
     64
     65    window.addEventListener( 'resize', function() {
     66        setHeaderBarTop();
     67    } );
     68
     69    setHeaderBarTop();
     70
    4571    highLight();
    4672};
  • hcaptcha-for-forms-and-more/tags/4.5.0/assets/js/settings-base.min.js

    r3114572 r3143189  
    1 (()=>{var a=function(a){a(".hcaptcha-header h2").siblings().appendTo("#hcaptcha-message"),function(){var e=window.location.href,i=document.referrer;if(i&&i!==e){var n=window.location.hash;if(n){var s=a(n);s&&(s.is(":checkbox")?s.closest("fieldset").addClass("blink"):s.addClass("blink"))}}}()};window.hCaptchaSettingsBase=a,jQuery(document).ready(a)})();
     1(()=>{var e=function(e){function t(){var e=document.querySelector("#wpadminbar"),t=document.querySelector(".hcaptcha-settings-tabs"),a=document.querySelector(".hcaptcha-header-bar"),o=!e||"absolute"===window.getComputedStyle(e).position,n=e&&!o?e.offsetHeight:0,c=n+(t?t.offsetHeight:0)-1;t&&(t.style.top="".concat(n,"px")),a&&(a.style.top="".concat(c,"px"))}e(".hcaptcha-header h2").siblings().appendTo("#hcaptcha-message"),window.addEventListener("resize",(function(){t()})),t(),function(){var t=window.location.href,a=document.referrer;if(a&&a!==t){var o=window.location.hash;if(o){var n=e(o);n&&(n.is(":checkbox")?n.closest("fieldset").addClass("blink"):n.addClass("blink"))}}}()};window.hCaptchaSettingsBase=e,jQuery(document).ready(e)})();
  • hcaptcha-for-forms-and-more/tags/4.5.0/changelog.txt

    r3129246 r3143189  
     1= 4.5.0 =
     2* Added support for Jetpack forms in block theme templates.
     3* Added support for bbPress Login, Register and Lost Password forms.
     4* Added the second argument $atts to the 'hcap_hcaptcha_content' filter.
     5* Added support for MailPoet forms at any placement.
     6* Added the ability to have multiple MailPoet forms on the same page.
     7* Improved UX of the Integrations page.
     8* Fixed error messaging when there are several Jetpack forms on the same page.
     9* Fixed unconditional forcing hCaptcha in Jetpack forms.
     10* Fixed appearance of Beaver Builder editor with "Turn Off When Logged In" setting.
     11* Fixed appearance of Contact Form 7 editor with "Turn Off When Logged In" setting.
     12* Fixed appearance of Essential Addons editor with "Turn Off When Logged In" setting.
     13* Fixed appearance of Gravity Forms editor with "Turn Off When Logged In" setting.
     14* Fixed appearance of Fluent Forms editor with "Turn Off When Logged In" setting.
     15* Fixed appearance of Forminator editor with "Turn Off When Logged In" setting.
     16* Fixed appearance of Formidable Forms with "Turn Off When Logged In" setting.
     17* Fixed appearance of Ninja Forms editor with "Turn Off When Logged In" setting.
     18* Fixed appearance of WPForms editor with "Turn Off When Logged In" setting.
     19* Fixed fatal error on Gravity Forms Entries page.
     20* Fixed Elementor preview.
     21* Fixed Ninja Forms preview.
     22* Fixed hCaptcha nonce error on MailPoet admin pages.
     23* Fixed frontend error when recaptcha was activated in wpDiscuz.
     24
    125= 4.4.0 =
    226* Added compatibility with Contact Form 7 Stripe integration.
  • hcaptcha-for-forms-and-more/tags/4.5.0/hcaptcha.php

    r3129246 r3143189  
    1111 * Plugin URI:           https://www.hcaptcha.com/
    1212 * Description:          hCaptcha keeps out bots and spam while putting privacy first. It is a drop-in replacement for reCAPTCHA.
    13  * Version:              4.4.0
     13 * Version:              4.5.0
    1414 * Requires at least:    5.3
    1515 * Requires PHP:         7.2
     
    4040 * Plugin version.
    4141 */
    42 const HCAPTCHA_VERSION = '4.4.0';
     42const HCAPTCHA_VERSION = '4.5.0';
    4343
    4444/**
  • hcaptcha-for-forms-and-more/tags/4.5.0/readme.txt

    r3129246 r3143189  
    55Tested up to: 6.6
    66Requires PHP: 7.2
    7 Stable tag: 4.4.0
     7Stable tag: 4.5.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1717Need to keep out bots? hCaptcha protects privacy while offering better protection against spam and abuse. Help build a better web.
    1818
    19 [The hCaptcha for WP many advantages over similar captcha plugins](https://kagg.eu/why-choose-hcaptcha-for-wp/).
     19hCaptcha for WP [makes security easy](https://www.hcaptcha.com/integration-hcaptcha-for-wp) with broad integration support, detailed analytics, and strong protection. Start protecting logins, forms, and more in minutes.
    2020
    2121== How hCaptcha Works ==
     
    37375. Contact Form 7 live form in the admin editor.
    38386. Elementor Pro Form.
    39 7. Elementor Pro From in admin editor.
     397. Elementor Pro Form in admin editor.
    40408. General settings page.
    41419. Integrations settings page.
     
    197197BBPress
    198198`$source: 'bbpress/bbpress.php'`
    199 `$form_id: 'new_topic' or 'reply'`
     199`$form_id: 'new_topic', 'reply', 'login', 'register' or 'lost_password'`
    200200
    201201Beaver Builder
     
    233233Jetpack
    234234`$source: 'jetpack/jetpack.php'`
    235 `$form_id: 'contact'`
     235`$form_id: 'contact_$form_hash'`
    236236
    237237Kadence Form
     
    395395= How to whitelist certain IPs =
    396396
    397 You can use the following filter:
     397You can use the following filter. It should be added to your plugin's (or mu-plugin's) main file. This filter won't work being added to a theme's functions.php file.
    398398
    399399`
     
    495495* Avada Form
    496496* Back In Stock Notifier Form
    497 * bbPress New Topic and Reply Forms
     497* bbPress New Topic, Reply, Login, Register and Lost Password Forms
    498498* Beaver Builder Contact and Login Forms
    499499* BuddyPress — Create Group and Registration Forms
     
    566566== Changelog ==
    567567
     568= 4.5.0 =
     569* Added support for Jetpack forms in block theme templates.
     570* Added support for bbPress Login, Register and Lost Password forms.
     571* Added the second argument $atts to the 'hcap_hcaptcha_content' filter.
     572* Added support for MailPoet forms at any placement.
     573* Added the ability to have multiple MailPoet forms on the same page.
     574* Improved UX of the Integrations page.
     575* Fixed error messaging when there are several Jetpack forms on the same page.
     576* Fixed unconditional forcing hCaptcha in Jetpack forms.
     577* Fixed appearance of Beaver Builder editor with "Turn Off When Logged In" setting.
     578* Fixed appearance of Contact Form 7 editor with "Turn Off When Logged In" setting.
     579* Fixed appearance of Essential Addons editor with "Turn Off When Logged In" setting.
     580* Fixed appearance of Gravity Forms editor with "Turn Off When Logged In" setting.
     581* Fixed appearance of Fluent Forms editor with "Turn Off When Logged In" setting.
     582* Fixed appearance of Forminator editor with "Turn Off When Logged In" setting.
     583* Fixed appearance of Formidable Forms with "Turn Off When Logged In" setting.
     584* Fixed appearance of Ninja Forms editor with "Turn Off When Logged In" setting.
     585* Fixed appearance of WPForms editor with "Turn Off When Logged In" setting.
     586* Fixed fatal error on Gravity Forms Entries page.
     587* Fixed Elementor preview.
     588* Fixed Ninja Forms preview.
     589* Fixed hCaptcha nonce error on MailPoet admin pages.
     590* Fixed frontend error when recaptcha was activated in wpDiscuz.
     591
    568592= 4.4.0 =
    569593* Added compatibility with Contact Form 7 Stripe integration.
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/CF7/Admin.php

    r3129246 r3143189  
    1111namespace HCaptcha\CF7;
    1212
     13use HCaptcha\Helpers\Pages;
    1314use WPCF7_TagGenerator;
    1415
     
    3637        }
    3738
    38         if ( ! $this->is_cf7_form_admin_page() ) {
     39        if ( ! Pages::is_cf7_edit_page() ) {
    3940            return;
    4041        }
     
    294295        }
    295296    }
    296 
    297     /**
    298      * Check if the current page is a CF7 form create, edit or view page.
    299      *
    300      * @return bool
    301      */
    302     protected function is_cf7_form_admin_page(): bool {
    303 
    304         // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    305         $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
    306 
    307         if ( ! in_array( $page, [ 'wpcf7-new', 'wpcf7' ], true ) ) {
    308             return false;
    309         }
    310 
    311         // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    312         if ( ( 'wpcf7' === $page ) && ! isset( $_GET['post'] ) ) {
    313             return false;
    314         }
    315 
    316         return true;
    317     }
    318297}
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Divi/Login.php

    r3114572 r3143189  
    99
    1010use HCaptcha\Abstracts\LoginBase;
     11use Patchwork\Exceptions\NonNullToVoid;
    1112
    1213/**
     
    3435     * Add hCaptcha to the login form.
    3536     *
    36      * @param string|string[] $output      Module output.
    37      * @param string          $module_slug Module slug.
     37     * @param string|mixed $output      Module output.
     38     * @param string       $module_slug Module slug.
    3839     *
    39      * @return string|string[]
     40     * @return string|mixed
    4041     * @noinspection PhpUnusedParameterInspection
    4142     * @noinspection PhpUndefinedFunctionInspection
     
    7576
    7677        // Insert hCaptcha.
    77         return preg_replace( $pattern, $replacement, $output );
     78        return (string) preg_replace( $pattern, $replacement, $output );
    7879    }
    7980}
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/GravityForms/Field.php

    r3115148 r3143189  
    5353     * @param array $data Data.
    5454     */
    55     public function __construct( array $data = [] ) {
     55    public function __construct( $data = [] ) {
    5656        parent::__construct( $data );
    5757
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Helpers/HCaptcha.php

    r3129246 r3143189  
    873873    public static function add_type_module( string $tag ): string {
    874874        $search  = [
    875             '/type=".+?"/',
     875            '/type=".+?" /',
    876876            '/<script /',
    877877        ];
    878878        $replace = [
    879879            '',
    880             '<script type="module"',
     880            '<script type="module" ',
    881881        ];
    882882
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Helpers/Request.php

    r3129246 r3143189  
    11<?php
    22/**
    3  * Request class file.
     3 * Request class' file.
    44 *
    55 * @package hcaptcha-wp
     
    115115        return 'POST' === $request_method;
    116116    }
     117
     118    /**
     119     * Filter input in WP style.
     120     * Nonce must be checked in the calling function.
     121     *
     122     * @param int    $type     Input type.
     123     * @param string $var_name Variable name.
     124     *
     125     * @return string
     126     */
     127    public static function filter_input( int $type, string $var_name ): string {
     128        switch ( $type ) {
     129            case INPUT_GET:
     130                // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     131                return isset( $_GET[ $var_name ] ) ? sanitize_text_field( wp_unslash( $_GET[ $var_name ] ) ) : '';
     132            case INPUT_POST:
     133                // phpcs:ignore WordPress.Security.NonceVerification.Missing
     134                return isset( $_POST[ $var_name ] ) ? sanitize_text_field( wp_unslash( $_POST[ $var_name ] ) ) : '';
     135            case INPUT_SERVER:
     136                return isset( $_SERVER[ $var_name ] ) ? sanitize_text_field( wp_unslash( $_SERVER[ $var_name ] ) ) : '';
     137            default:
     138                return '';
     139        }
     140    }
    117141}
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Jetpack/JetpackBase.php

    r3114572 r3143189  
    3434
    3535    /**
     36     * Errored form hash.
     37     *
     38     * @var string|null
     39     */
     40    protected $error_form_hash;
     41
     42    /**
    3643     * Constructor.
    3744     */
     
    4653     */
    4754    private function init_hooks(): void {
    48         add_filter( 'the_content', [ $this, 'add_captcha' ] );
     55        // This filter works for a Jetpack classic and block form on a page or in a template.
     56        add_filter( 'jetpack_contact_form_html', [ $this, 'add_captcha' ] );
     57
     58        // This filter works for a Jetpack form in a classic widget.
    4959        add_filter( 'widget_text', [ $this, 'add_captcha' ], 0 );
    5060
     
    8393        }
    8494
     95        $this->error_form_hash = $this->get_submitted_form_hash();
     96
    8597        $error = new WP_Error();
     98
    8699        $error->add( 'invalid_hcaptcha', $this->error_message );
    87100        add_filter( 'hcap_hcaptcha_content', [ $this, 'error_message' ] );
     
    93106     * Print error message.
    94107     *
    95      * @param string|mixed $hcaptcha_content Content of hCaptcha.
     108     * @param string|mixed $hcaptcha The hCaptcha form.
     109     * @param array        $atts     The hCaptcha shortcode attributes.
    96110     *
    97111     * @return string|mixed
    98112     */
    99     public function error_message( $hcaptcha_content = '' ) {
     113    public function error_message( $hcaptcha = '', array $atts = [] ) {
    100114        if ( null === $this->error_message ) {
    101             return $hcaptcha_content;
     115            return $hcaptcha;
     116        }
     117
     118        $hash = $atts['id']['form_id'] ?? '';
     119        $hash = str_replace( 'contact_', '', $hash );
     120
     121        if ( $hash !== $this->error_form_hash ) {
     122            return $hcaptcha;
    102123        }
    103124
     
    112133HTML;
    113134
    114         return $hcaptcha_content . $message;
     135        return $hcaptcha . $message;
    115136    }
    116137
     
    131152        HCaptcha::css_display( $css );
    132153    }
     154
     155    /**
     156     * Get form hash.
     157     *
     158     * @param string $form Jetpack form.
     159     *
     160     * @return string
     161     */
     162    protected function get_form_hash( string $form ): string {
     163        return preg_match( "/name='contact-form-hash' value='(.+)'/", $form, $m )
     164            ? '_' . $m[1]
     165            : '';
     166    }
     167
     168    /**
     169     * Get form hash.
     170     *
     171     * @return string|null
     172     */
     173    private function get_submitted_form_hash(): ?string {
     174        // phpcs:disable WordPress.Security.NonceVerification.Missing
     175        return isset( $_POST['contact-form-hash'] )
     176            ? sanitize_text_field( wp_unslash( $_POST['contact-form-hash'] ) )
     177            : null;
     178        // phpcs:enable WordPress.Security.NonceVerification.Missing
     179    }
    133180}
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Jetpack/JetpackForm.php

    r3051014 r3143189  
    2727        // Jetpack classic form.
    2828        $content = (string) preg_replace_callback(
    29             '~(\[contact-form[\s\S]*?][\s\S]*?)(\[/contact-form])~',
    30             [ $this, 'classic_callback' ],
     29            "~<form [\s\S]*?class='contact-form[\s\S]*?(<button type='submit')[\s\S]*?</form>~",
     30            [ $this, 'replace_callback' ],
    3131            $content
    3232        );
     
    3535        return (string) preg_replace_callback(
    3636            '~<form [\s\S]*?wp-block-jetpack-contact-form[\s\S]*?(<div class="wp-block-jetpack-button wp-block-button"[\s\S]*?<button [\s\S]*?type="submit"[\s\S]*?</button>)[\s\S]*?</form>~',
    37             [ $this, 'block_callback' ],
     37            [ $this, 'replace_callback' ],
    3838            $content
    3939        );
    40     }
    41 
    42     /**
    43      * Add hCaptcha shortcode to the provided shortcode for a Jetpack classic contact form.
    44      *
    45      * @param array $matches Matches.
    46      *
    47      * @return string
    48      */
    49     public function classic_callback( array $matches ): string {
    50         if ( has_shortcode( $matches[0], 'hcaptcha' ) ) {
    51             return $matches[0];
    52         }
    53 
    54         $args = [
    55             'action' => self::ACTION,
    56             'name'   => self::NAME,
    57             'force'  => true,
    58             'id'     => [
    59                 'source'  => HCaptcha::get_class_source( __CLASS__ ),
    60                 'form_id' => 'contact',
    61             ],
    62         ];
    63 
    64         $hcaptcha = '<div class="grunion-field-wrap">' . HCaptcha::form( $args ) . '</div>';
    65 
    66         return $matches[1] . $this->error_message( $hcaptcha ) . $matches[2];
    6740    }
    6841
     
    7447     * @return string
    7548     */
    76     public function block_callback( array $matches ): string {
     49    public function replace_callback( array $matches ): string {
    7750        if ( has_shortcode( $matches[0], 'hcaptcha' ) ) {
    7851            return $matches[0];
    7952        }
    8053
     54        $hash = $this->get_form_hash( $matches[0] );
     55
    8156        $args = [
    8257            'action' => self::ACTION,
    8358            'name'   => self::NAME,
    84             'force'  => true,
    8559            'id'     => [
    8660                'source'  => HCaptcha::get_class_source( __CLASS__ ),
    87                 'form_id' => 'contact',
     61                'form_id' => 'contact' . $hash,
    8862            ],
    8963        ];
     
    9165        $hcaptcha = '<div class="grunion-field-wrap">' . HCaptcha::form( $args ) . '</div>';
    9266
     67        if ( false !== strpos( $matches[0], $hcaptcha ) ) {
     68            return $matches[0];
     69        }
     70
     71        $hcaptcha = $this->error_message( $hcaptcha, $args );
     72
    9373        return str_replace(
    9474            $matches[1],
    95             $this->error_message( $hcaptcha ) . $matches[1],
     75            $hcaptcha . $matches[1],
    9676            $matches[0]
    9777        );
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/MailPoet/Form.php

    r3129246 r3143189  
    1414
    1515use HCaptcha\Helpers\HCaptcha;
     16use HCaptcha\Helpers\Request;
    1617use MailPoet\API\JSON\API;
    1718use MailPoet\API\JSON\Response;
    18 use WP_Block;
    1919
    2020/**
     
    5151     */
    5252    private function init_hooks(): void {
    53         add_filter( 'render_block', [ $this, 'add_captcha' ], 10, 3 );
     53        add_filter( 'the_content', [ $this, 'the_content_filter' ], 20 );
    5454        add_action( 'mailpoet_api_setup', [ $this, 'verify' ] );
    5555        add_action( 'wp_print_footer_scripts', [ $this, 'enqueue_scripts' ], 9 );
     
    5757
    5858    /**
    59      * Add hcaptcha to MailPoet form.
     59     * The content filter.
    6060     *
    61      * @param string|mixed $block_content The block content.
    62      * @param array        $block         The full block, including name and attributes.
    63      * @param WP_Block     $instance      The block instance.
     61     * @param string|mixed $content Content.
    6462     *
    6563     * @return string
    66      * @noinspection PhpUnusedParameterInspection
    6764     */
    68     public function add_captcha( $block_content, array $block, WP_Block $instance ): string {
    69         if ( 'mailpoet/subscription-form-block' !== $block['blockName'] ) {
    70             return (string) $block_content;
     65    public function the_content_filter( $content ): string {
     66        $content = (string) $content;
     67
     68        if ( ! preg_match_all(
     69            '~<form[\s\S]+?"data\[form_id]" value="(\d+?)"[\s\S]+?(<input type="submit")[\s\S]+?</form>~',
     70            $content,
     71            $matches
     72        ) ) {
     73            return $content;
    7174        }
    7275
    73         $form_id = $block['attrs']['formId'] ?? 0;
    74         $search  = '<input type="submit" class="mailpoet_submit"';
    75         $args    = [
    76             'action' => self::ACTION,
    77             'name'   => self::NONCE,
    78             'id'     => [
    79                 'source'  => HCaptcha::get_class_source( __CLASS__ ),
    80                 'form_id' => $form_id,
    81             ],
    82         ];
     76        foreach ( $matches[0] as $key => $form ) {
     77            if ( false !== strpos( $form, 'h-captcha' ) ) {
     78                continue;
     79            }
    8380
    84         return str_replace(
    85             $search,
    86             HCaptcha::form( $args ) . $search,
    87             (string) $block_content
    88         );
     81            $form_id = (int) $matches[1][ $key ];
     82
     83            $args     = [
     84                'action' => self::ACTION,
     85                'name'   => self::NONCE,
     86                'id'     => [
     87                    'source'  => HCaptcha::get_class_source( __CLASS__ ),
     88                    'form_id' => $form_id,
     89                ],
     90            ];
     91            $hcaptcha = HCaptcha::form( $args );
     92
     93            $submit  = $matches[2][ $key ];
     94            $replace = str_replace( $submit, $hcaptcha . $submit, $form );
     95            $content = str_replace( $form, $replace, $content );
     96        }
     97
     98        return $content;
    8999    }
    90100
     
    93103     *
    94104     * @param API $api MailPoet API instance.
     105     *
     106     * @return void
    95107     */
    96108    public function verify( API $api ): void {
    97         if ( ! wp_doing_ajax() ) {
     109        if (
     110            Request::filter_input( INPUT_POST, 'action' ) !== 'mailpoet' ||
     111            Request::filter_input( INPUT_POST, 'endpoint' ) !== 'subscribers' ||
     112            Request::filter_input( INPUT_POST, 'method' ) !== 'subscribe'
     113        ) {
     114            // Process frontend subscription ajax request only.
    98115            return;
    99116        }
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Main.php

    r3129246 r3143189  
    2424use HCaptcha\ElementorPro\HCaptchaHandler;
    2525use HCaptcha\Helpers\HCaptcha;
     26use HCaptcha\Helpers\Pages;
    2627use HCaptcha\Helpers\Request;
    2728use HCaptcha\Jetpack\JetpackForm;
     
    6970
    7071    /**
     72     * Priority of the plugins_loaded action to load Main.
     73     */
     74    public const LOAD_PRIORITY = Migrations::LOAD_PRIORITY + 1;
     75
     76    /**
    7177     * Form shown somewhere, use this flag to run the script.
    7278     *
     
    98104
    99105    /**
     106     * Migrations class instance.
     107     *
     108     * @var Migrations
     109     */
     110    protected $migrations;
     111
     112    /**
    100113     * Settings class instance.
    101114     *
     
    125138    public function init(): void {
    126139        if ( Request::is_xml_rpc() ) {
     140            // @codeCoverageIgnoreStart
    127141            return;
    128         }
    129 
    130         new Migrations();
     142            // @codeCoverageIgnoreEnd
     143        }
     144
     145        $this->migrations = new Migrations();
    131146
    132147        if ( wp_doing_cron() ) {
     
    136151        ( new Fix() )->init();
    137152
    138         add_action( 'plugins_loaded', [ $this, 'init_hooks' ], -PHP_INT_MAX );
     153        add_action( 'plugins_loaded', [ $this, 'init_hooks' ], self::LOAD_PRIORITY );
    139154    }
    140155
     
    172187        $this->load( Events::class );
    173188
    174         add_action( 'plugins_loaded', [ $this, 'load_modules' ], -PHP_INT_MAX + 1 );
     189        add_action( 'plugins_loaded', [ $this, 'load_modules' ], self::LOAD_PRIORITY + 1 );
    175190        add_filter( 'hcap_whitelist_ip', [ $this, 'whitelist_ip' ], -PHP_INT_MAX, 2 );
    176191        add_action( 'before_woocommerce_init', [ $this, 'declare_wc_compatibility' ] );
     
    250265        );
    251266
    252         $activate = ( ! $deactivate ) || $this->is_elementor_pro_edit_page();
     267        $activate = ( ! $deactivate ) || $this->is_edit_page();
    253268
    254269        /**
     
    261276
    262277    /**
    263      * Whether we are on the Elementor Pro edit post/page and hCaptcha for Elementor Pro is active.
     278     * Whether we are on the admin edit page for a component and component is active.
    264279     *
    265280     * @return bool
    266281     */
    267     private function is_elementor_pro_edit_page(): bool {
    268         if ( ! $this->settings()->is_on( 'elementor_pro_status' ) ) {
    269             return false;
    270         }
    271 
    272         // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
    273         $request1 = (
    274             isset( $_SERVER['REQUEST_URI'], $_GET['post'], $_GET['action'] ) &&
    275             0 === strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/wp-admin/post.php' ) &&
    276             'elementor' === $_GET['action']
     282    private function is_edit_page(): bool {
     283        $settings   = $this->settings();
     284        $components = [
     285            'beaver_builder',
     286            'cf7',
     287            'elementor_pro',
     288            'gravity',
     289            'fluent',
     290            'forminator',
     291            'formidable_forms',
     292            'ninja',
     293            'wpforms',
     294        ];
     295
     296        return array_reduce(
     297            $components,
     298            static function ( $carry, $component ) use ( $settings ) {
     299                $method = 'is_' . $component . '_edit_page';
     300
     301                if (
     302                    ! method_exists( Pages::class, $method ) ||
     303                    ! $settings->is_on( $component . '_status' )
     304                ) {
     305                    return $carry;
     306                }
     307
     308                return $carry || Pages::$method();
     309            },
     310            false
    277311        );
    278         $request2 = (
    279             isset( $_SERVER['REQUEST_URI'], $_GET['elementor-preview'] ) &&
    280             0 === strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/elementor' )
    281         );
    282         $request3 = (
    283             isset( $_POST['action'] ) && 'elementor_ajax' === $_POST['action']
    284         );
    285 
    286         // phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
    287 
    288         return $request1 || $request2 || $request3;
    289312    }
    290313
     
    323346         *
    324347         * @param bool  $add_csp_headers Add Content Security Policy (CSP) headers.
    325          * @param array $headers Current headers.
     348         * @param array $headers         Current headers.
    326349         */
    327350        if ( ! apply_filters( 'hcap_add_csp_headers', false, $headers ) ) {
     
    863886                BackInStockNotifier\Form::class,
    864887            ],
     888            'bbPress Login Form'                   => [
     889                [ 'bbp_status', null ],
     890                'bbpress/bbpress.php',
     891                BBPress\Login::class,
     892            ],
     893            'bbPress Lost Password Form'           => [
     894                [ 'bbp_status', null ],
     895                'bbpress/bbpress.php',
     896                BBPress\LostPassword::class,
     897            ],
    865898            'bbPress New Topic'                    => [
    866899                [ 'bbp_status', 'new_topic' ],
    867900                'bbpress/bbpress.php',
    868901                BBPress\NewTopic::class,
     902            ],
     903            'bbPress Register Form'                => [
     904                [ 'bbp_status', null ],
     905                'bbpress/bbpress.php',
     906                BBPress\Register::class,
    869907            ],
    870908            'bbPress Reply'                        => [
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Migrations/Migrations.php

    r3114572 r3143189  
    3737
    3838    /**
     39     * Priority of the plugins_loaded action to load Migrations.
     40     */
     41    public const LOAD_PRIORITY = -PHP_INT_MAX;
     42
     43    /**
    3944     * Plugin name.
    4045     */
     
    6772     */
    6873    private function init_hooks(): void {
    69         add_action( 'plugins_loaded', [ $this, 'migrate' ], - PHP_INT_MAX );
     74        add_action( 'plugins_loaded', [ $this, 'migrate' ], self::LOAD_PRIORITY );
    7075    }
    7176
     
    142147        }
    143148
    144         return wp_doing_cron() || is_admin() || ( defined( 'WP_CLI' ) && constant( 'WP_CLI' ) );
     149        return (
     150            ( is_admin() && ! wp_doing_ajax() ) ||
     151            wp_doing_cron() ||
     152            ( defined( 'WP_CLI' ) && constant( 'WP_CLI' ) )
     153        );
     154    }
     155
     156    /**
     157     * Send plugin statistics.
     158     *
     159     * @return void
     160     */
     161    public function send_plugin_stats(): void {
     162        /**
     163         * Send plugin statistics.
     164         */
     165        do_action( 'hcap_send_plugin_stats' );
    145166    }
    146167
     
    158179
    159180        // Send statistics on plugin update.
    160         add_action(
    161             'init',
    162             static function () {
    163                 /**
    164                  * Send plugin statistics.
    165                  */
    166                 do_action( 'hcap_send_plugin_stats' );
    167             }
    168         );
     181        add_action( 'init', [ $this, 'send_plugin_stats' ] );
    169182    }
    170183
     
    199212
    200213    /**
    201      * Output message into log file.
     214     * Output message into the log file.
    202215     *
    203216     * @param string $message Message to log.
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/NF/Field.php

    r3114572 r3143189  
    1818 * Class Field
    1919 */
    20 class Field extends NF_Abstracts_Field {
     20class Field extends NF_Abstracts_Field implements Base {
    2121
    2222    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
    2323
    2424    /**
    25      * Name.
     25     * Field name.
    2626     *
    2727     * @var string
    2828     */
    29     protected $_name = 'hcaptcha-for-ninja-forms';
     29    protected $_name = self::NAME;
    3030
    3131    /**
    32      * Type.
     32     * Filed type.
    3333     *
    3434     * @var string
    3535     */
    36     protected $_type = 'hcaptcha';
     36    protected $_type = self::TYPE;
    3737
    3838    /**
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/NF/NF.php

    r3114572 r3143189  
    1515 * Support Ninja Forms.
    1616 */
    17 class NF {
     17class NF implements Base {
    1818
    1919    /**
     
    4242     * @var int
    4343     */
    44     private $form_id = 0;
     44    protected $form_id = 0;
    4545
    4646    /**
     
    4949     * @var string
    5050     */
    51     private $templates_dir;
     51    protected $templates_dir;
    5252
    5353    /**
     
    6666     */
    6767    public function init_hooks(): void {
     68        $name = Base::NAME;
     69
    6870        add_action( 'toplevel_page_ninja-forms', [ $this, 'admin_template' ], 11 );
    6971        add_action( 'nf_admin_enqueue_scripts', [ $this, 'nf_admin_enqueue_scripts' ] );
     
    7274        add_filter( 'ninja_forms_field_template_file_paths', [ $this, 'template_file_paths' ] );
    7375        add_action( 'nf_get_form_id', [ $this, 'set_form_id' ] );
    74         add_filter( 'ninja_forms_localize_field_hcaptcha-for-ninja-forms', [ $this, 'localize_field' ] );
     76        add_filter( "ninja_forms_localize_field_$name", [ $this, 'localize_field' ] );
     77        add_filter( "ninja_forms_localize_field_{$name}_preview", [ $this, 'localize_field' ] );
    7578        add_action( 'wp_print_footer_scripts', [ $this, 'nf_captcha_script' ], 9 );
    7679    }
     
    9699        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    97100        echo str_replace(
    98             'tmpl-nf-field-hcaptcha',
    99             'tmpl-nf-field-hcaptcha-for-ninja-forms',
     101            'tmpl-nf-field-' . Base::TYPE,
     102            'tmpl-nf-field-' . Base::NAME,
    100103            $template
    101104        );
     
    111114
    112115        // Add hCaptcha to the preloaded form data.
    113         $data = $wp_scripts->registered['nf-builder']->extra['data'];
     116        $data = $wp_scripts->registered['nf-builder']->extra['data'] ?? '';
    114117
    115118        if ( ! preg_match( '/var nfDashInlineVars = (.+);/', $data, $m ) ) {
     
    121124
    122125        foreach ( $vars['preloadedFormData']['fields'] as & $field ) {
    123             if ( 'hcaptcha-for-ninja-forms' === $field['type'] ) {
     126            // See comment in admin_template().
     127            if ( Base::NAME === $field['type'] ) {
    124128                $found             = true;
    125129                $search            = 'class="h-captcha"';
     
    129133                    $this->get_hcaptcha( (int) $field['id'] )
    130134                );
     135
    131136                break;
    132137            }
     
    187192        $fields = (array) $fields;
    188193
    189         $fields['hcaptcha-for-ninja-forms'] = new Field();
     194        $fields[ Base::NAME ] = new Field();
    190195
    191196        return $fields;
     
    203208
    204209        if ( false === $index ) {
     210            // @codeCoverageIgnoreStart
    205211            return;
    206         }
    207 
    208         $hcaptcha_key   = 'hcaptcha-for-ninja-forms';
     212            // @codeCoverageIgnoreEnd
     213        }
     214
     215        $hcaptcha_key   = Base::NAME;
    209216        $hcaptcha_value = $fields[ $hcaptcha_key ];
    210217
     
    255262
    256263        $field['settings']['hcaptcha'] = $field['settings']['hcaptcha'] ?? $this->get_hcaptcha( (int) $field['id'] );
     264
     265        // Mark hCaptcha as shown in any case. Needed on the preview page.
     266        hcaptcha()->form_shown = true;
    257267
    258268        return $field;
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Settings/Abstracts/SettingsBase.php

    r3114572 r3143189  
    233233            'select'   => [ $this, 'print_select_field' ],
    234234            'multiple' => [ $this, 'print_multiple_select_field' ],
     235            'file'     => [ $this, 'print_file_field' ],
    235236            'table'    => [ $this, 'print_table_field' ],
    236237            'button'   => [ $this, 'print_button_field' ],
     
    260261        $this->init_settings();
    261262
    262         if ( $this->is_main_menu_page() || $this->is_tab_active( $this ) ) {
     263        if ( is_admin() && ( $this->is_main_menu_page() || $this->is_tab_active( $this ) ) ) {
    263264            $this->init_hooks();
    264265        }
     
    708709     */
    709710    public function tabs_callback(): void {
     711        if ( ! count( $this->tabs ?? [] ) ) {
     712            return;
     713        }
     714
    710715        ?>
    711716        <div class="<?php echo esc_attr( static::PREFIX . '-settings-tabs' ); ?>">
     
    12361241
    12371242    /**
     1243     * Print file field.
     1244     *
     1245     * @param array $arguments Field arguments.
     1246     *
     1247     * @return void
     1248     * @noinspection HtmlUnknownAttribute
     1249     */
     1250    protected function print_file_field( array $arguments ): void {
     1251        $multiple = (bool) ( $arguments['multiple'] ?? '' );
     1252        $accept   = $arguments['accept'] ?? '';
     1253
     1254        printf(
     1255            '<input %1$s name="%2$s[%3$s]%4$s" id="%3$s" type="file" %5$s %6$s/>',
     1256            disabled( $arguments['disabled'], true, false ),
     1257            esc_html( $this->option_name() ),
     1258            esc_attr( $arguments['field_id'] ),
     1259            esc_attr( $multiple ? '[]' : '' ),
     1260            esc_attr( $multiple ? 'multiple' : '' ),
     1261            $accept ? 'accept="' . esc_attr( $accept ) . '"' : ''
     1262        );
     1263    }
     1264
     1265    /**
    12381266     * Print table field.
    12391267     *
     
    14611489
    14621490        foreach ( $this->form_fields() as $key => $form_field ) {
     1491            if ( 'file' === $form_field['type'] ) {
     1492                unset( $value[ $key ], $old_value[ $key ] );
     1493                continue;
     1494            }
     1495
    14631496            if ( 'checkbox' !== $form_field['type'] || isset( $value[ $key ] ) ) {
    14641497                continue;
     
    16201653        <?php
    16211654    }
     1655
     1656    /**
     1657     * Get savable for fields.
     1658     *
     1659     * @return array
     1660     */
     1661    protected function get_savable_form_fields(): array {
     1662        $not_savable_form_fields = [ 'button', 'file' ];
     1663
     1664        return array_filter(
     1665            $this->form_fields,
     1666            static function ( $field ) use ( $not_savable_form_fields ) {
     1667                return ! in_array( $field['type'] ?? '', $not_savable_form_fields, true );
     1668            }
     1669        );
     1670    }
    16221671}
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Settings/Integrations.php

    r3129246 r3143189  
    213213                'type'    => 'checkbox',
    214214                'options' => [
     215                    'login'     => __( 'Login Form', 'hcaptcha-for-forms-and-more' ),
     216                    'lost_pass' => __( 'Lost Password Form', 'hcaptcha-for-forms-and-more' ),
    215217                    'new_topic' => __( 'New Topic Form', 'hcaptcha-for-forms-and-more' ),
     218                    'register'  => __( 'Register Form', 'hcaptcha-for-forms-and-more' ),
    216219                    'reply'     => __( 'Reply Form', 'hcaptcha-for-forms-and-more' ),
    217220                ],
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Settings/PluginSettingsBase.php

    r3114572 r3143189  
    197197            settings_fields( $this->option_group() ); // Hidden protection fields.
    198198
    199             if ( ! empty( $this->form_fields ) ) {
     199            if ( ! empty( $this->get_savable_form_fields() ) ) {
    200200                $this->submit_button();
    201201            }
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Settings/Settings.php

    r3114572 r3143189  
    106106     */
    107107    public function get_tab( string $classname ): ?PluginSettingsBase {
    108         $tabs = hcaptcha()->settings()->get_tabs();
    109 
    110         foreach ( $tabs as $tab ) {
     108        foreach ( $this->tabs as $tab ) {
    111109            if ( is_a( $tab, $classname ) ) {
    112110                return $tab;
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/Spectra/Form.php

    r3114572 r3143189  
    3737     * @var bool
    3838     */
    39     private $has_recaptcha_field;
     39    protected $has_recaptcha_field;
    4040
    4141    /**
     
    7979            return $block_content;
    8080        }
     81
     82        $block_content = (string) $block_content;
    8183
    8284        $args = [
     
    8991        ];
    9092
    91         $block_content = (string) $block_content;
    92 
    9393        $this->has_recaptcha_field = false;
    9494
     
    198198     * @return bool
    199199     */
    200     private function has_recaptcha(): bool {
     200    protected function has_recaptcha(): bool {
    201201        // Spectra checks nonce.
    202202        // phpcs:disable WordPress.Security.NonceVerification.Missing
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/WPDiscuz/Base.php

    r3114572 r3143189  
    2424     *
    2525     * @return void
     26     * @noinspection PhpUndefinedFunctionInspection
    2627     */
    2728    protected function init_hooks(): void {
    28         add_filter(
    29             'wpdiscuz_recaptcha_site_key',
    30             static function () {
    31                 // Block output of reCaptcha by wpDiscuz.
    32                 return '';
    33             }
     29        if ( ! function_exists( 'wpDiscuz' ) ) {
     30            return;
     31        }
     32
     33        $wpd_recaptcha = wpDiscuz()->options->recaptcha;
     34        $wpd_recaptcha = array_merge(
     35            $wpd_recaptcha,
     36            [
     37                'siteKey'       => '',
     38                'showForGuests' => 0,
     39                'showForUsers'  => 0,
     40            ]
    3441        );
     42
     43        // Block output of reCaptcha by wpDiscuz.
     44        wpDiscuz()->options->recaptcha = $wpd_recaptcha;
    3545
    3646        add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ], 11 );
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/includes/functions.php

    r3064004 r3143189  
    1111 * Display hCaptcha shortcode.
    1212 *
    13  * @param array|string $atts hcaptcha shortcode attributes.
     13 * @param array|string $atts The hCaptcha shortcode attributes.
    1414 *
    1515 * @return string
     
    3838
    3939    /**
    40      * Filters the content of the hcaptcha form.
     40     * Filters the content of the hCaptcha form.
    4141     *
    42      * @param string $form The hcaptcha form.
     42     * @param string $form The hCaptcha form.
     43     * @param array  $atts The hCaptcha shortcode attributes.
    4344     */
    44     return (string) apply_filters( 'hcap_hcaptcha_content', HCaptcha::form( $atts ) );
     45    return (string) apply_filters( 'hcap_hcaptcha_content', HCaptcha::form( $atts ), $atts );
    4546}
    4647
  • hcaptcha-for-forms-and-more/tags/4.5.0/src/php/includes/request.php

    r3114572 r3143189  
    314314    function hcaptcha_get_verify_output( string $empty_message, string $fail_message, string $nonce_field_name, string $nonce_action_name ): ?string {
    315315        if ( ! empty( $empty_message ) || ! empty( $fail_message ) ) {
     316            // @codeCoverageIgnoreStart
    316317            _deprecated_argument( __FUNCTION__, '2.1.0' );
     318            // @codeCoverageIgnoreEnd
    317319        }
    318320
  • hcaptcha-for-forms-and-more/tags/4.5.0/vendor/autoload.php

    r3114572 r3143189  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470::getLoader();
     25return ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f::getLoader();
  • hcaptcha-for-forms-and-more/tags/4.5.0/vendor/composer/autoload_classmap.php

    r3129246 r3143189  
    2323    'HCaptcha\\Avada\\Form' => $baseDir . '/src/php/Avada/Form.php',
    2424    'HCaptcha\\BBPress\\Base' => $baseDir . '/src/php/BBPress/Base.php',
     25    'HCaptcha\\BBPress\\Login' => $baseDir . '/src/php/BBPress/Login.php',
     26    'HCaptcha\\BBPress\\LostPassword' => $baseDir . '/src/php/BBPress/LostPassword.php',
    2527    'HCaptcha\\BBPress\\NewTopic' => $baseDir . '/src/php/BBPress/NewTopic.php',
     28    'HCaptcha\\BBPress\\Register' => $baseDir . '/src/php/BBPress/Register.php',
    2629    'HCaptcha\\BBPress\\Reply' => $baseDir . '/src/php/BBPress/Reply.php',
    2730    'HCaptcha\\BackInStockNotifier\\Form' => $baseDir . '/src/php/BackInStockNotifier/Form.php',
     
    7174    'HCaptcha\\HTMLForms\\Form' => $baseDir . '/src/php/HTMLForms/Form.php',
    7275    'HCaptcha\\Helpers\\HCaptcha' => $baseDir . '/src/php/Helpers/HCaptcha.php',
     76    'HCaptcha\\Helpers\\Pages' => $baseDir . '/src/php/Helpers/Pages.php',
    7377    'HCaptcha\\Helpers\\Request' => $baseDir . '/src/php/Helpers/Request.php',
    7478    'HCaptcha\\Jetpack\\JetpackBase' => $baseDir . '/src/php/Jetpack/JetpackBase.php',
     
    8892    'HCaptcha\\MemberPress\\Register' => $baseDir . '/src/php/MemberPress/Register.php',
    8993    'HCaptcha\\Migrations\\Migrations' => $baseDir . '/src/php/Migrations/Migrations.php',
     94    'HCaptcha\\NF\\Base' => $baseDir . '/src/php/NF/Base.php',
    9095    'HCaptcha\\NF\\Field' => $baseDir . '/src/php/NF/Field.php',
    9196    'HCaptcha\\NF\\NF' => $baseDir . '/src/php/NF/NF.php',
  • hcaptcha-for-forms-and-more/tags/4.5.0/vendor/composer/autoload_real.php

    r3129246 r3143189  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470
     5class ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInita6c3d020c47c988d11030e9a25036470::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
  • hcaptcha-for-forms-and-more/tags/4.5.0/vendor/composer/autoload_static.php

    r3129246 r3143189  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInita6c3d020c47c988d11030e9a25036470
     7class ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    5151        'HCaptcha\\Avada\\Form' => __DIR__ . '/../..' . '/src/php/Avada/Form.php',
    5252        'HCaptcha\\BBPress\\Base' => __DIR__ . '/../..' . '/src/php/BBPress/Base.php',
     53        'HCaptcha\\BBPress\\Login' => __DIR__ . '/../..' . '/src/php/BBPress/Login.php',
     54        'HCaptcha\\BBPress\\LostPassword' => __DIR__ . '/../..' . '/src/php/BBPress/LostPassword.php',
    5355        'HCaptcha\\BBPress\\NewTopic' => __DIR__ . '/../..' . '/src/php/BBPress/NewTopic.php',
     56        'HCaptcha\\BBPress\\Register' => __DIR__ . '/../..' . '/src/php/BBPress/Register.php',
    5457        'HCaptcha\\BBPress\\Reply' => __DIR__ . '/../..' . '/src/php/BBPress/Reply.php',
    5558        'HCaptcha\\BackInStockNotifier\\Form' => __DIR__ . '/../..' . '/src/php/BackInStockNotifier/Form.php',
     
    99102        'HCaptcha\\HTMLForms\\Form' => __DIR__ . '/../..' . '/src/php/HTMLForms/Form.php',
    100103        'HCaptcha\\Helpers\\HCaptcha' => __DIR__ . '/../..' . '/src/php/Helpers/HCaptcha.php',
     104        'HCaptcha\\Helpers\\Pages' => __DIR__ . '/../..' . '/src/php/Helpers/Pages.php',
    101105        'HCaptcha\\Helpers\\Request' => __DIR__ . '/../..' . '/src/php/Helpers/Request.php',
    102106        'HCaptcha\\Jetpack\\JetpackBase' => __DIR__ . '/../..' . '/src/php/Jetpack/JetpackBase.php',
     
    116120        'HCaptcha\\MemberPress\\Register' => __DIR__ . '/../..' . '/src/php/MemberPress/Register.php',
    117121        'HCaptcha\\Migrations\\Migrations' => __DIR__ . '/../..' . '/src/php/Migrations/Migrations.php',
     122        'HCaptcha\\NF\\Base' => __DIR__ . '/../..' . '/src/php/NF/Base.php',
    118123        'HCaptcha\\NF\\Field' => __DIR__ . '/../..' . '/src/php/NF/Field.php',
    119124        'HCaptcha\\NF\\NF' => __DIR__ . '/../..' . '/src/php/NF/NF.php',
     
    191196    {
    192197        return \Closure::bind(function () use ($loader) {
    193             $loader->prefixLengthsPsr4 = ComposerStaticInita6c3d020c47c988d11030e9a25036470::$prefixLengthsPsr4;
    194             $loader->prefixDirsPsr4 = ComposerStaticInita6c3d020c47c988d11030e9a25036470::$prefixDirsPsr4;
    195             $loader->classMap = ComposerStaticInita6c3d020c47c988d11030e9a25036470::$classMap;
     198            $loader->prefixLengthsPsr4 = ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::$prefixLengthsPsr4;
     199            $loader->prefixDirsPsr4 = ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::$prefixDirsPsr4;
     200            $loader->classMap = ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::$classMap;
    196201
    197202        }, null, ClassLoader::class);
  • hcaptcha-for-forms-and-more/tags/4.5.0/vendor/composer/installed.php

    r3129246 r3143189  
    22    'root' => array(
    33        'name' => 'hcaptcha/hcaptcha-wordpress-plugin',
    4         'pretty_version' => '4.4.0',
    5         'version' => '4.4.0.0',
    6         'reference' => '25bdd39c5629233960c20655da571516f475acb3',
     4        'pretty_version' => '4.5.0',
     5        'version' => '4.5.0.0',
     6        'reference' => '0ba34f4533d55163e1ba8af8e119a49ec192be45',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'hcaptcha/hcaptcha-wordpress-plugin' => array(
    14             'pretty_version' => '4.4.0',
    15             'version' => '4.4.0.0',
    16             'reference' => '25bdd39c5629233960c20655da571516f475acb3',
     14            'pretty_version' => '4.5.0',
     15            'version' => '4.5.0.0',
     16            'reference' => '0ba34f4533d55163e1ba8af8e119a49ec192be45',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • hcaptcha-for-forms-and-more/trunk/assets/css/settings-base.css

    r3114572 r3143189  
    1717
    1818.hcaptcha-settings-tabs {
     19    position: sticky;
     20    top: 0;
     21    z-index: 2; /* +1 to .hcaptcha-header bar z-index, to overlap a bit */
    1922    display: flex;
    2023    flex-wrap: wrap;
     
    4649
    4750.hcaptcha-header-bar {
     51    position: sticky;
     52    top: 60px;
     53    z-index: 1;
     54    background: #f0f2f5;
    4855    display: flex;
    4956    justify-content: space-between;
    5057    align-items: center;
    51     margin: 0;
     58    margin: 0 -20px;
     59    padding: 0 20px;
    5260}
    5361
  • hcaptcha-for-forms-and-more/trunk/assets/css/settings-base.min.css

    r3114572 r3143189  
    1 body.settings_page_hcaptcha{background:#f0f2f5;color:#5c6f8a}.wrap h1.hcaptcha-settings-header{align-items:center;display:flex;font-size:34px;font-weight:700}.hcaptcha-logo{height:64px;margin:10px 5px 10px 0}.hcaptcha-settings-tabs{background:#fff;display:flex;flex-wrap:wrap;justify-content:space-between;line-height:4.5em;margin:10px -20px 0;padding:0 20px}.hcaptcha-settings-tab{border-bottom:2px solid transparent;color:#646970;display:inline-block;font-size:1.1em;margin-right:30px;text-decoration:none}.hcaptcha-settings-tab:hover{border-bottom-color:#025176!important;border-bottom:2px solid;color:#666}.hcaptcha-settings-tab.active{border-bottom:2px solid #0075ab}.hcaptcha-header-bar{align-items:center;display:flex;justify-content:space-between;margin:0}#hcaptcha-options h2{color:#5c6f8a;font-size:1.5em}#hcaptcha-options h2~*{display:none}#hcaptcha-options h3{color:#5c6f8a;margin:1.5em 0 1em}#hcaptcha-options .notice-dismiss:before{color:#5c6f8a}#hcaptcha-options table tbody tr td{margin:0;padding:0;position:relative}#hcaptcha-options table tr td input[type=checkbox]{border:none;box-shadow:none;display:inline;height:1.25rem;margin:-.125rem .5rem 0 0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:before{background:url(../images/checkbox-off.svg);background-size:cover;content:"";display:inline-block;height:1.25rem;margin:0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:checked:before{background:no-repeat url(../images/checkbox-on.svg);background-size:cover}#hcaptcha-options fieldset:disabled{color:#dadada}#hcaptcha-options .button-primary{background-color:#026593;border-color:#026593;color:#fff}#hcaptcha-options .button-primary:hover{background-color:#025176}#hcaptcha-options .button-secondary{background-color:#fff;border-color:#026593;color:#026593}#hcaptcha-options .button-secondary:hover{background-color:#ccc}#hcaptcha-options a{color:#0075ab}#hcaptcha-navigation a{border-color:#0075ab}#hcaptcha-options a.hcaptcha-settings-tab{color:#5c6f8a}#hcaptcha-options .helper:before{background:#5c6f8a;border-radius:1.2em;color:#fff;content:"?";height:1.2em;position:absolute;right:0;text-align:center;top:0;transform:translateY(-26px);width:1.2em}#hcaptcha-options fieldset+.helper:before{top:50%;transform:translate(25px,-.8em)}#hcaptcha-options .helper .helper-content{background:#5c6f8a;box-sizing:border-box;color:#f0f2f5;display:none;padding:.5em 1em;position:absolute;right:0;top:0;transform:translate(1px,10px);width:100%}#hcaptcha-options fieldset+.helper .helper-content{top:50%;transform:translate(25px,25px);width:calc(100% + 25px)}#hcaptcha-options .helper:hover{cursor:help}#hcaptcha-options .helper:hover .helper-content{display:block;z-index:1}#hcaptcha-options .helper .helper-content:after{border:10px solid transparent;border-bottom-color:#5c6f8a;content:"";position:absolute;right:0;top:0;transform:translateY(-100%)}#hcaptcha-options .helper .helper-content a{color:#fff}#hcaptcha-message{box-sizing:border-box}#hcaptcha-message>p{font-size:13px;font-weight:600;line-height:1.5;margin:.5em 0}@keyframes blink{0%{opacity:1}16.7%{opacity:0}33.3%{opacity:1}50%{opacity:0}66.7%{opacity:1}83.3%{opacity:0}to{opacity:1}}.blink{animation:blink 3s linear}.hcaptcha-hide{display:none}.hcaptcha-excerpt{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hcaptcha-excerpt:hover .hcaptcha-hide{background:#5c6f8a;border:1px solid #c3c4c7;border-radius:6px;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);color:#f0f2f5;display:block;left:0;max-width:300px;padding:8px 10px;position:absolute;text-align:center;top:0;white-space:normal;width:max-content;z-index:1}@media (max-width:782px){.hcaptcha-settings-tabs{margin:10px -12px 0 -10px;padding:0 12px 0 10px}}@media (max-width:600px){#hcaptcha-options table tbody{grid-template-columns:1fr}#hcaptcha-options table tbody tr{position:relative}#hcaptcha-options fieldset+.helper:before{transform:translateY(-.7em)}#hcaptcha-options fieldset+.helper .helper-content{transform:translateY(25px);width:100%}#hcaptcha-options .helper{z-index:1}.hcaptcha-settings-tab{margin-right:15px}}
     1body.settings_page_hcaptcha{background:#f0f2f5;color:#5c6f8a}.wrap h1.hcaptcha-settings-header{align-items:center;display:flex;font-size:34px;font-weight:700}.hcaptcha-logo{height:64px;margin:10px 5px 10px 0}.hcaptcha-settings-tabs{background:#fff;display:flex;flex-wrap:wrap;justify-content:space-between;line-height:4.5em;margin:10px -20px 0;padding:0 20px;position:sticky;top:0;z-index:2}.hcaptcha-settings-tab{border-bottom:2px solid transparent;color:#646970;display:inline-block;font-size:1.1em;margin-right:30px;text-decoration:none}.hcaptcha-settings-tab:hover{border-bottom-color:#025176!important;border-bottom:2px solid;color:#666}.hcaptcha-settings-tab.active{border-bottom:2px solid #0075ab}.hcaptcha-header-bar{align-items:center;background:#f0f2f5;display:flex;justify-content:space-between;margin:0 -20px;padding:0 20px;position:sticky;top:60px;z-index:1}#hcaptcha-options h2{color:#5c6f8a;font-size:1.5em}#hcaptcha-options h2~*{display:none}#hcaptcha-options h3{color:#5c6f8a;margin:1.5em 0 1em}#hcaptcha-options .notice-dismiss:before{color:#5c6f8a}#hcaptcha-options table tbody tr td{margin:0;padding:0;position:relative}#hcaptcha-options table tr td input[type=checkbox]{border:none;box-shadow:none;display:inline;height:1.25rem;margin:-.125rem .5rem 0 0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:before{background:url(../images/checkbox-off.svg);background-size:cover;content:"";display:inline-block;height:1.25rem;margin:0;width:2.3611rem}#hcaptcha-options table tr td input[type=checkbox]:checked:before{background:no-repeat url(../images/checkbox-on.svg);background-size:cover}#hcaptcha-options fieldset:disabled{color:#dadada}#hcaptcha-options .button-primary{background-color:#026593;border-color:#026593;color:#fff}#hcaptcha-options .button-primary:hover{background-color:#025176}#hcaptcha-options .button-secondary{background-color:#fff;border-color:#026593;color:#026593}#hcaptcha-options .button-secondary:hover{background-color:#ccc}#hcaptcha-options a{color:#0075ab}#hcaptcha-navigation a{border-color:#0075ab}#hcaptcha-options a.hcaptcha-settings-tab{color:#5c6f8a}#hcaptcha-options .helper:before{background:#5c6f8a;border-radius:1.2em;color:#fff;content:"?";height:1.2em;position:absolute;right:0;text-align:center;top:0;transform:translateY(-26px);width:1.2em}#hcaptcha-options fieldset+.helper:before{top:50%;transform:translate(25px,-.8em)}#hcaptcha-options .helper .helper-content{background:#5c6f8a;box-sizing:border-box;color:#f0f2f5;display:none;padding:.5em 1em;position:absolute;right:0;top:0;transform:translate(1px,10px);width:100%}#hcaptcha-options fieldset+.helper .helper-content{top:50%;transform:translate(25px,25px);width:calc(100% + 25px)}#hcaptcha-options .helper:hover{cursor:help}#hcaptcha-options .helper:hover .helper-content{display:block;z-index:1}#hcaptcha-options .helper .helper-content:after{border:10px solid transparent;border-bottom-color:#5c6f8a;content:"";position:absolute;right:0;top:0;transform:translateY(-100%)}#hcaptcha-options .helper .helper-content a{color:#fff}#hcaptcha-message{box-sizing:border-box}#hcaptcha-message>p{font-size:13px;font-weight:600;line-height:1.5;margin:.5em 0}@keyframes blink{0%{opacity:1}16.7%{opacity:0}33.3%{opacity:1}50%{opacity:0}66.7%{opacity:1}83.3%{opacity:0}to{opacity:1}}.blink{animation:blink 3s linear}.hcaptcha-hide{display:none}.hcaptcha-excerpt{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hcaptcha-excerpt:hover .hcaptcha-hide{background:#5c6f8a;border:1px solid #c3c4c7;border-radius:6px;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);color:#f0f2f5;display:block;left:0;max-width:300px;padding:8px 10px;position:absolute;text-align:center;top:0;white-space:normal;width:max-content;z-index:1}@media (max-width:782px){.hcaptcha-settings-tabs{margin:10px -12px 0 -10px;padding:0 12px 0 10px}}@media (max-width:600px){#hcaptcha-options table tbody{grid-template-columns:1fr}#hcaptcha-options table tbody tr{position:relative}#hcaptcha-options fieldset+.helper:before{transform:translateY(-.7em)}#hcaptcha-options fieldset+.helper .helper-content{transform:translateY(25px);width:100%}#hcaptcha-options .helper{z-index:1}.hcaptcha-settings-tab{margin-right:15px}}
  • hcaptcha-for-forms-and-more/trunk/assets/js/hcaptcha-mailpoet.js

    r3026321 r3143189  
    1515        }
    1616
    17         const urlParams = new URLSearchParams( data );
    18         const formId = urlParams.get( 'data[form_id]' );
    19         const $form = $( 'input[name="data[form_id]"][value=' + formId + ']' ).parent( 'form' );
     17        // eslint-disable-next-line @wordpress/no-global-active-element
     18        const eventTarget = options.context || document.activeElement;
     19        const $form = $( eventTarget.closest( 'form' ) );
     20
    2021        let response = $form.find( '[name="h-captcha-response"]' ).val();
    2122        response = response ? response : '';
  • hcaptcha-for-forms-and-more/trunk/assets/js/hcaptcha-mailpoet.min.js

    r3026321 r3143189  
    1 (()=>{var a;(a=jQuery).ajaxPrefilter((function(t){var e,i=null!==(e=t.data)&&void 0!==e?e:"",n="";if(i.startsWith("action=mailpoet")&&(n="hcaptcha_mailpoet_nonce"),n){var r=new URLSearchParams(i).get("data[form_id]"),c=a('input[name="data[form_id]"][value='+r+"]").parent("form"),d=c.find('[name="h-captcha-response"]').val();d=d||"";var h=c.find('[name="hcaptcha-widget-id"]').val();h=h||"";var o=c.find('[name="'+n+'"]').val();o=o||"",t.data+="&h-captcha-response="+d+"&hcaptcha-widget-id="+h+"&"+n+"="+o}}))})();
     1(()=>{var a;(a=jQuery).ajaxPrefilter((function(t){var e,c="";if((null!==(e=t.data)&&void 0!==e?e:"").startsWith("action=mailpoet")&&(c="hcaptcha_mailpoet_nonce"),c){var n=t.context||document.activeElement,i=a(n.closest("form")),o=i.find('[name="h-captcha-response"]').val();o=o||"";var r=i.find('[name="hcaptcha-widget-id"]').val();r=r||"";var d=i.find('[name="'+c+'"]').val();d=d||"",t.data+="&h-captcha-response="+o+"&hcaptcha-widget-id="+r+"&"+c+"="+d}}))})();
  • hcaptcha-for-forms-and-more/trunk/assets/js/integrations.js

    r3114572 r3143189  
    2525 */
    2626const integrations = function( $ ) {
     27    const adminBar = document.querySelector( '#wpadminbar' );
     28    const tabs = document.querySelector( '.hcaptcha-settings-tabs' );
     29    const headerBar = document.querySelector( '.hcaptcha-header-bar' );
    2730    const msgSelector = '#hcaptcha-message';
    2831    let $message = $( msgSelector );
     
    3033    const $adminmenuwrap = $( '#adminmenuwrap' );
    3134    const $search = $( '#hcaptcha-integrations-search' );
     35
     36    function getStickyHeight() {
     37        const isAbsolute = adminBar ? window.getComputedStyle( adminBar ).position === 'absolute' : true;
     38        const adminBarHeight = ( adminBar && ! isAbsolute ) ? adminBar.offsetHeight : 0;
     39        const tabsHeight = tabs ? tabs.offsetHeight : 0;
     40        const headerBarHeight = headerBar ? headerBar.offsetHeight : 0;
     41
     42        return adminBarHeight + tabsHeight + headerBarHeight;
     43    }
    3244
    3345    function clearMessage() {
     
    223235
    224236                    const $table = $( '.form-table' ).eq( activate ? 0 : 1 );
    225                     const top = $wpWrap.position().top;
    226237
    227238                    swapThemes( activate, entity, newTheme );
     
    232243                    $( 'html, body' ).animate(
    233244                        {
    234                             scrollTop: $tr.offset().top - top - $message.outerHeight(),
     245                            scrollTop: $tr.offset().top - getStickyHeight(),
    235246                        },
    236247                        1000
  • hcaptcha-for-forms-and-more/trunk/assets/js/integrations.min.js

    r3114572 r3143189  
    1 (()=>{function t(t,a){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var n,i,o,r,c=[],s=!0,l=!1;try{if(o=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;s=!1}else for(;!(s=(n=o.call(a)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{if(!s&&null!=a.return&&(r=a.return(),Object(r)!==r))return}finally{if(l)throw i}}return c}}(t,a)||function(t,a){if(t){if("string"==typeof t)return e(t,a);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,a):void 0}}(t,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=Array(e);a<e;a++)n[a]=t[a];return n}var a=function(e){var a="#hcaptcha-message",n=e(a),i=e("#wpwrap"),o=e("#adminmenuwrap"),r=e("#hcaptcha-integrations-search");function c(t,a){n.removeClass(),n.addClass(a+" notice settings-error is-dismissible"),n.html("<p>".concat(t,"</p>")),e(document).trigger("wp-updates-notice-added");var r=n.clone();n.css("visibility","hidden"),r.css("margin","0px"),r.css("top",i.position().top),r.css("z-index","999999");var c="block"===o.css("display")?o.width():0;r.css("left",c),r.width(e(window).width()-c),r.css("position","fixed"),e("body").append(r),setTimeout((function(){n.css("visibility","unset"),r.remove()}),3e3)}function s(t){c(t,"notice-error")}function l(t){return t.is(jQuery(".form-table").eq(0))}function d(t,a,n){var i=!1,o=a.toLowerCase(),r=!l(t),c=n.find("fieldset");c.attr("disabled",r),c.find("input").attr("disabled",r),t.find("tbody").children().each((function(t,a){var r=e(a).find(".hcaptcha-integrations-logo img").attr("alt");if((r=(r=r||"").replace(" Logo","")).toLowerCase()>o)return n.insertBefore(e(a)),i=!0,!1})),i||t.find("tbody").append(n)}e(".form-table img").on("click",(function(o){function r(){var a,o,r=v?"on":"off",h=(o=document.querySelector(".kagg-dialog select"))&&null!==(a=o.value)&&void 0!==a?a:"",m={action:HCaptchaIntegrationsObject.action,nonce:HCaptchaIntegrationsObject.nonce,activate:v,entity:u,status:g,newTheme:h};p.addClass(r),e.post({url:HCaptchaIntegrationsObject.ajaxUrl,data:m}).done((function(a){if(void 0!==a.success)if(void 0!==a.data.themes&&(window.HCaptchaIntegrationsObject.themes=a.data.themes,window.HCaptchaIntegrationsObject.defaultTheme=a.data.defaultTheme),a.success){var o=e(".form-table").eq(v?0:1),r=i.position().top;!function(t,a,n){if("theme"===a){var i=e(".form-table"),o=t?"":'[data-label="'+n+'"]',r=i.eq(t?0:1).find('.hcaptcha-integrations-logo img[data-entity="theme"]'+o);if(r.length){var c=i.eq(t?1:0),s=r.closest("tr");d(c,r.attr("data-label"),s)}}}(v,u,h),d(o,f,p),function(t){c(t,"notice-success")}(a.data.message),function(a){for(var n=e(".form-table"),i=0,o=Object.entries(a);i<o.length;i++){var r=t(o[i],2),c=r[0],s=r[1],h="hcaptcha-integrations-"+c.replace(/_/g,"-"),u=e("tr.".concat(h));l(u.closest(".form-table"))!==s&&d(n.eq(s?0:1),u.find(".hcaptcha-integrations-logo img").attr("alt"),u)}}(a.data.stati),e("html, body").animate({scrollTop:p.offset().top-r-n.outerHeight()},1e3)}else{var g,m;s(null!==(g=null===(m=a.data)||void 0===m?void 0:m.message)&&void 0!==g?g:a.data)}else c(HCaptchaIntegrationsObject.unexpectedErrorMsg,"notice-error")})).fail((function(t){s(t.statusText)})).always((function(){p.removeClass("on off")}))}o.preventDefault(),n.remove(),e('<div id="hcaptcha-message"></div>').insertAfter(".hcaptcha-header-bar"),n=e(a);var h=e(o.target),u=h.data("entity");if(u=u||"",-1!==e.inArray(u,["core","theme","plugin"])&&-1===e.inArray(u,["core"])){var f=h.attr("alt");f=(f=f||"").replace(" Logo","");var p=h.closest("tr"),g=p.attr("class");g=g.replace("hcaptcha-integrations-","");var m,v,b="";if(p.find("fieldset").attr("disabled"))m="plugin"===u?HCaptchaIntegrationsObject.activateMsg:HCaptchaIntegrationsObject.activateThemeMsg,v=!0;else{if("plugin"===u)m=HCaptchaIntegrationsObject.deactivateMsg;else{for(var y in m=HCaptchaIntegrationsObject.deactivateThemeMsg,b="<p>"+HCaptchaIntegrationsObject.selectThemeMsg+"</p>",b+="<select>",HCaptchaIntegrationsObject.themes){var C=y===HCaptchaIntegrationsObject.defaultTheme?' selected="selected"':"";b+='<option value="'.concat(y,'"').concat(C,">").concat(HCaptchaIntegrationsObject.themes[y],"</option>")}b+="</select>"}v=!1}if(-1===e.inArray(u,["theme"])||v||0!==Object.keys(HCaptchaIntegrationsObject.themes).length){if(!p.find(".hcaptcha-integrations-logo").data("installed"))return m=(m=HCaptchaIntegrationsObject.installMsg).replace("%s",f),void kaggDialog.confirm({title:m,content:b,type:"install",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}});o.ctrlKey?r():(m=m.replace("%s",f),kaggDialog.confirm({title:m,content:b,type:v?"activate":"deactivate",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText},cancel:{text:HCaptchaIntegrationsObject.CancelBtnText}},onAction:function(t){t&&r()}}))}else kaggDialog.confirm({title:HCaptchaIntegrationsObject.onlyOneThemeMsg,content:"",type:"info",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}})}}));var h,u,f;r.on("input",(h=function(){var t=r.val().trim().toLowerCase(),a=e(".hcaptcha-integrations-logo img"),n=null;if(a.each((function(a,i){var o=e(i);if("core"!==o.data("entity")){var r,c=o.closest("tr");o.data("label").toLowerCase().includes(t)?(c.show(),n=null!==(r=n)&&void 0!==r?r:c):c.hide()}})),n){var i=n.offset().top+n.outerHeight()-e(window).height()+5;e("html").stop().animate({scrollTop:i},1e3)}},u=100,function(){var t=this,e=arguments;clearTimeout(f),f=setTimeout((function(){return h.apply(t,e)}),u)})),e("#hcaptcha-options").keydown((function(t){e(t.target).is(r)&&13===t.which&&t.preventDefault()}))};window.hCaptchaIntegrations=a,jQuery(document).ready(a)})();
     1(()=>{function t(t,a){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var n,i,o,r,c=[],s=!0,l=!1;try{if(o=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;s=!1}else for(;!(s=(n=o.call(a)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{if(!s&&null!=a.return&&(r=a.return(),Object(r)!==r))return}finally{if(l)throw i}}return c}}(t,a)||function(t,a){if(t){if("string"==typeof t)return e(t,a);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,a):void 0}}(t,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=Array(e);a<e;a++)n[a]=t[a];return n}var a=function(e){var a=document.querySelector("#wpadminbar"),n=document.querySelector(".hcaptcha-settings-tabs"),i=document.querySelector(".hcaptcha-header-bar"),o="#hcaptcha-message",r=e(o),c=e("#wpwrap"),s=e("#adminmenuwrap"),l=e("#hcaptcha-integrations-search");function d(t,a){r.removeClass(),r.addClass(a+" notice settings-error is-dismissible"),r.html("<p>".concat(t,"</p>")),e(document).trigger("wp-updates-notice-added");var n=r.clone();r.css("visibility","hidden"),n.css("margin","0px"),n.css("top",c.position().top),n.css("z-index","999999");var i="block"===s.css("display")?s.width():0;n.css("left",i),n.width(e(window).width()-i),n.css("position","fixed"),e("body").append(n),setTimeout((function(){r.css("visibility","unset"),n.remove()}),3e3)}function h(t){d(t,"notice-error")}function u(t){return t.is(jQuery(".form-table").eq(0))}function f(t,a,n){var i=!1,o=a.toLowerCase(),r=!u(t),c=n.find("fieldset");c.attr("disabled",r),c.find("input").attr("disabled",r),t.find("tbody").children().each((function(t,a){var r=e(a).find(".hcaptcha-integrations-logo img").attr("alt");if((r=(r=r||"").replace(" Logo","")).toLowerCase()>o)return n.insertBefore(e(a)),i=!0,!1})),i||t.find("tbody").append(n)}e(".form-table img").on("click",(function(c){function s(){var o,r,c=y?"on":"off",s=(r=document.querySelector(".kagg-dialog select"))&&null!==(o=r.value)&&void 0!==o?o:"",l={action:HCaptchaIntegrationsObject.action,nonce:HCaptchaIntegrationsObject.nonce,activate:y,entity:p,status:b,newTheme:s};m.addClass(c),e.post({url:HCaptchaIntegrationsObject.ajaxUrl,data:l}).done((function(o){if(void 0!==o.success)if(void 0!==o.data.themes&&(window.HCaptchaIntegrationsObject.themes=o.data.themes,window.HCaptchaIntegrationsObject.defaultTheme=o.data.defaultTheme),o.success){var r,c=e(".form-table").eq(y?0:1);!function(t,a,n){if("theme"===a){var i=e(".form-table"),o=t?"":'[data-label="'+n+'"]',r=i.eq(t?0:1).find('.hcaptcha-integrations-logo img[data-entity="theme"]'+o);if(r.length){var c=i.eq(t?1:0),s=r.closest("tr");f(c,r.attr("data-label"),s)}}}(y,p,s),f(c,g,m),function(t){d(t,"notice-success")}(o.data.message),function(a){for(var n=e(".form-table"),i=0,o=Object.entries(a);i<o.length;i++){var r=t(o[i],2),c=r[0],s=r[1],l="hcaptcha-integrations-"+c.replace(/_/g,"-"),d=e("tr.".concat(l));u(d.closest(".form-table"))!==s&&f(n.eq(s?0:1),d.find(".hcaptcha-integrations-logo img").attr("alt"),d)}}(o.data.stati),e("html, body").animate({scrollTop:m.offset().top-(r=!a||"absolute"===window.getComputedStyle(a).position,(a&&!r?a.offsetHeight:0)+(n?n.offsetHeight:0)+(i?i.offsetHeight:0))},1e3)}else{var l,b;h(null!==(l=null===(b=o.data)||void 0===b?void 0:b.message)&&void 0!==l?l:o.data)}else d(HCaptchaIntegrationsObject.unexpectedErrorMsg,"notice-error")})).fail((function(t){h(t.statusText)})).always((function(){m.removeClass("on off")}))}c.preventDefault(),r.remove(),e('<div id="hcaptcha-message"></div>').insertAfter(".hcaptcha-header-bar"),r=e(o);var l=e(c.target),p=l.data("entity");if(p=p||"",-1!==e.inArray(p,["core","theme","plugin"])&&-1===e.inArray(p,["core"])){var g=l.attr("alt");g=(g=g||"").replace(" Logo","");var m=l.closest("tr"),b=m.attr("class");b=b.replace("hcaptcha-integrations-","");var v,y,C="";if(m.find("fieldset").attr("disabled"))v="plugin"===p?HCaptchaIntegrationsObject.activateMsg:HCaptchaIntegrationsObject.activateThemeMsg,y=!0;else{if("plugin"===p)v=HCaptchaIntegrationsObject.deactivateMsg;else{for(var w in v=HCaptchaIntegrationsObject.deactivateThemeMsg,C="<p>"+HCaptchaIntegrationsObject.selectThemeMsg+"</p>",C+="<select>",HCaptchaIntegrationsObject.themes){var j=w===HCaptchaIntegrationsObject.defaultTheme?' selected="selected"':"";C+='<option value="'.concat(w,'"').concat(j,">").concat(HCaptchaIntegrationsObject.themes[w],"</option>")}C+="</select>"}y=!1}if(-1===e.inArray(p,["theme"])||y||0!==Object.keys(HCaptchaIntegrationsObject.themes).length){if(!m.find(".hcaptcha-integrations-logo").data("installed"))return v=(v=HCaptchaIntegrationsObject.installMsg).replace("%s",g),void kaggDialog.confirm({title:v,content:C,type:"install",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}});c.ctrlKey?s():(v=v.replace("%s",g),kaggDialog.confirm({title:v,content:C,type:y?"activate":"deactivate",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText},cancel:{text:HCaptchaIntegrationsObject.CancelBtnText}},onAction:function(t){t&&s()}}))}else kaggDialog.confirm({title:HCaptchaIntegrationsObject.onlyOneThemeMsg,content:"",type:"info",buttons:{ok:{text:HCaptchaIntegrationsObject.OKBtnText}}})}}));var p,g,m;l.on("input",(p=function(){var t=l.val().trim().toLowerCase(),a=e(".hcaptcha-integrations-logo img"),n=null;if(a.each((function(a,i){var o=e(i);if("core"!==o.data("entity")){var r,c=o.closest("tr");o.data("label").toLowerCase().includes(t)?(c.show(),n=null!==(r=n)&&void 0!==r?r:c):c.hide()}})),n){var i=n.offset().top+n.outerHeight()-e(window).height()+5;e("html").stop().animate({scrollTop:i},1e3)}},g=100,function(){var t=this,e=arguments;clearTimeout(m),m=setTimeout((function(){return p.apply(t,e)}),g)})),e("#hcaptcha-options").keydown((function(t){e(t.target).is(l)&&13===t.which&&t.preventDefault()}))};window.hCaptchaIntegrations=a,jQuery(document).ready(a)})();
  • hcaptcha-for-forms-and-more/trunk/assets/js/settings-base.js

    r3114572 r3143189  
    1010    const msgSelector = '#hcaptcha-message';
    1111
    12     // Move WP notices to the message area.
    13     $( h2Selector ).siblings().appendTo( msgSelector );
     12    function setHeaderBarTop() {
     13        const adminBar = document.querySelector( '#wpadminbar' );
     14        const tabs = document.querySelector( '.hcaptcha-settings-tabs' );
     15        const headerBar = document.querySelector( '.hcaptcha-header-bar' );
     16
     17        const isAbsolute = adminBar ? window.getComputedStyle( adminBar ).position === 'absolute' : true;
     18        const adminBarHeight = ( adminBar && ! isAbsolute ) ? adminBar.offsetHeight : 0;
     19        const tabsHeight = tabs ? tabs.offsetHeight : 0;
     20        // The -1 to put header bar a bit under tabs. It is a precaution when heights are in fractional pixels.
     21        const totalHeight = adminBarHeight + tabsHeight - 1;
     22
     23        if ( tabs ) {
     24            tabs.style.top = `${ adminBarHeight }px`;
     25        }
     26
     27        if ( headerBar ) {
     28            headerBar.style.top = `${ totalHeight }px`;
     29        }
     30    }
    1431
    1532    /**
     
    4360    }
    4461
     62    // Move WP notices to the message area.
     63    $( h2Selector ).siblings().appendTo( msgSelector );
     64
     65    window.addEventListener( 'resize', function() {
     66        setHeaderBarTop();
     67    } );
     68
     69    setHeaderBarTop();
     70
    4571    highLight();
    4672};
  • hcaptcha-for-forms-and-more/trunk/assets/js/settings-base.min.js

    r3114572 r3143189  
    1 (()=>{var a=function(a){a(".hcaptcha-header h2").siblings().appendTo("#hcaptcha-message"),function(){var e=window.location.href,i=document.referrer;if(i&&i!==e){var n=window.location.hash;if(n){var s=a(n);s&&(s.is(":checkbox")?s.closest("fieldset").addClass("blink"):s.addClass("blink"))}}}()};window.hCaptchaSettingsBase=a,jQuery(document).ready(a)})();
     1(()=>{var e=function(e){function t(){var e=document.querySelector("#wpadminbar"),t=document.querySelector(".hcaptcha-settings-tabs"),a=document.querySelector(".hcaptcha-header-bar"),o=!e||"absolute"===window.getComputedStyle(e).position,n=e&&!o?e.offsetHeight:0,c=n+(t?t.offsetHeight:0)-1;t&&(t.style.top="".concat(n,"px")),a&&(a.style.top="".concat(c,"px"))}e(".hcaptcha-header h2").siblings().appendTo("#hcaptcha-message"),window.addEventListener("resize",(function(){t()})),t(),function(){var t=window.location.href,a=document.referrer;if(a&&a!==t){var o=window.location.hash;if(o){var n=e(o);n&&(n.is(":checkbox")?n.closest("fieldset").addClass("blink"):n.addClass("blink"))}}}()};window.hCaptchaSettingsBase=e,jQuery(document).ready(e)})();
  • hcaptcha-for-forms-and-more/trunk/changelog.txt

    r3129246 r3143189  
     1= 4.5.0 =
     2* Added support for Jetpack forms in block theme templates.
     3* Added support for bbPress Login, Register and Lost Password forms.
     4* Added the second argument $atts to the 'hcap_hcaptcha_content' filter.
     5* Added support for MailPoet forms at any placement.
     6* Added the ability to have multiple MailPoet forms on the same page.
     7* Improved UX of the Integrations page.
     8* Fixed error messaging when there are several Jetpack forms on the same page.
     9* Fixed unconditional forcing hCaptcha in Jetpack forms.
     10* Fixed appearance of Beaver Builder editor with "Turn Off When Logged In" setting.
     11* Fixed appearance of Contact Form 7 editor with "Turn Off When Logged In" setting.
     12* Fixed appearance of Essential Addons editor with "Turn Off When Logged In" setting.
     13* Fixed appearance of Gravity Forms editor with "Turn Off When Logged In" setting.
     14* Fixed appearance of Fluent Forms editor with "Turn Off When Logged In" setting.
     15* Fixed appearance of Forminator editor with "Turn Off When Logged In" setting.
     16* Fixed appearance of Formidable Forms with "Turn Off When Logged In" setting.
     17* Fixed appearance of Ninja Forms editor with "Turn Off When Logged In" setting.
     18* Fixed appearance of WPForms editor with "Turn Off When Logged In" setting.
     19* Fixed fatal error on Gravity Forms Entries page.
     20* Fixed Elementor preview.
     21* Fixed Ninja Forms preview.
     22* Fixed hCaptcha nonce error on MailPoet admin pages.
     23* Fixed frontend error when recaptcha was activated in wpDiscuz.
     24
    125= 4.4.0 =
    226* Added compatibility with Contact Form 7 Stripe integration.
  • hcaptcha-for-forms-and-more/trunk/hcaptcha.php

    r3129246 r3143189  
    1111 * Plugin URI:           https://www.hcaptcha.com/
    1212 * Description:          hCaptcha keeps out bots and spam while putting privacy first. It is a drop-in replacement for reCAPTCHA.
    13  * Version:              4.4.0
     13 * Version:              4.5.0
    1414 * Requires at least:    5.3
    1515 * Requires PHP:         7.2
     
    4040 * Plugin version.
    4141 */
    42 const HCAPTCHA_VERSION = '4.4.0';
     42const HCAPTCHA_VERSION = '4.5.0';
    4343
    4444/**
  • hcaptcha-for-forms-and-more/trunk/readme.txt

    r3129246 r3143189  
    55Tested up to: 6.6
    66Requires PHP: 7.2
    7 Stable tag: 4.4.0
     7Stable tag: 4.5.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1717Need to keep out bots? hCaptcha protects privacy while offering better protection against spam and abuse. Help build a better web.
    1818
    19 [The hCaptcha for WP many advantages over similar captcha plugins](https://kagg.eu/why-choose-hcaptcha-for-wp/).
     19hCaptcha for WP [makes security easy](https://www.hcaptcha.com/integration-hcaptcha-for-wp) with broad integration support, detailed analytics, and strong protection. Start protecting logins, forms, and more in minutes.
    2020
    2121== How hCaptcha Works ==
     
    37375. Contact Form 7 live form in the admin editor.
    38386. Elementor Pro Form.
    39 7. Elementor Pro From in admin editor.
     397. Elementor Pro Form in admin editor.
    40408. General settings page.
    41419. Integrations settings page.
     
    197197BBPress
    198198`$source: 'bbpress/bbpress.php'`
    199 `$form_id: 'new_topic' or 'reply'`
     199`$form_id: 'new_topic', 'reply', 'login', 'register' or 'lost_password'`
    200200
    201201Beaver Builder
     
    233233Jetpack
    234234`$source: 'jetpack/jetpack.php'`
    235 `$form_id: 'contact'`
     235`$form_id: 'contact_$form_hash'`
    236236
    237237Kadence Form
     
    395395= How to whitelist certain IPs =
    396396
    397 You can use the following filter:
     397You can use the following filter. It should be added to your plugin's (or mu-plugin's) main file. This filter won't work being added to a theme's functions.php file.
    398398
    399399`
     
    495495* Avada Form
    496496* Back In Stock Notifier Form
    497 * bbPress New Topic and Reply Forms
     497* bbPress New Topic, Reply, Login, Register and Lost Password Forms
    498498* Beaver Builder Contact and Login Forms
    499499* BuddyPress — Create Group and Registration Forms
     
    566566== Changelog ==
    567567
     568= 4.5.0 =
     569* Added support for Jetpack forms in block theme templates.
     570* Added support for bbPress Login, Register and Lost Password forms.
     571* Added the second argument $atts to the 'hcap_hcaptcha_content' filter.
     572* Added support for MailPoet forms at any placement.
     573* Added the ability to have multiple MailPoet forms on the same page.
     574* Improved UX of the Integrations page.
     575* Fixed error messaging when there are several Jetpack forms on the same page.
     576* Fixed unconditional forcing hCaptcha in Jetpack forms.
     577* Fixed appearance of Beaver Builder editor with "Turn Off When Logged In" setting.
     578* Fixed appearance of Contact Form 7 editor with "Turn Off When Logged In" setting.
     579* Fixed appearance of Essential Addons editor with "Turn Off When Logged In" setting.
     580* Fixed appearance of Gravity Forms editor with "Turn Off When Logged In" setting.
     581* Fixed appearance of Fluent Forms editor with "Turn Off When Logged In" setting.
     582* Fixed appearance of Forminator editor with "Turn Off When Logged In" setting.
     583* Fixed appearance of Formidable Forms with "Turn Off When Logged In" setting.
     584* Fixed appearance of Ninja Forms editor with "Turn Off When Logged In" setting.
     585* Fixed appearance of WPForms editor with "Turn Off When Logged In" setting.
     586* Fixed fatal error on Gravity Forms Entries page.
     587* Fixed Elementor preview.
     588* Fixed Ninja Forms preview.
     589* Fixed hCaptcha nonce error on MailPoet admin pages.
     590* Fixed frontend error when recaptcha was activated in wpDiscuz.
     591
    568592= 4.4.0 =
    569593* Added compatibility with Contact Form 7 Stripe integration.
  • hcaptcha-for-forms-and-more/trunk/src/php/CF7/Admin.php

    r3129246 r3143189  
    1111namespace HCaptcha\CF7;
    1212
     13use HCaptcha\Helpers\Pages;
    1314use WPCF7_TagGenerator;
    1415
     
    3637        }
    3738
    38         if ( ! $this->is_cf7_form_admin_page() ) {
     39        if ( ! Pages::is_cf7_edit_page() ) {
    3940            return;
    4041        }
     
    294295        }
    295296    }
    296 
    297     /**
    298      * Check if the current page is a CF7 form create, edit or view page.
    299      *
    300      * @return bool
    301      */
    302     protected function is_cf7_form_admin_page(): bool {
    303 
    304         // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    305         $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
    306 
    307         if ( ! in_array( $page, [ 'wpcf7-new', 'wpcf7' ], true ) ) {
    308             return false;
    309         }
    310 
    311         // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    312         if ( ( 'wpcf7' === $page ) && ! isset( $_GET['post'] ) ) {
    313             return false;
    314         }
    315 
    316         return true;
    317     }
    318297}
  • hcaptcha-for-forms-and-more/trunk/src/php/Divi/Login.php

    r3114572 r3143189  
    99
    1010use HCaptcha\Abstracts\LoginBase;
     11use Patchwork\Exceptions\NonNullToVoid;
    1112
    1213/**
     
    3435     * Add hCaptcha to the login form.
    3536     *
    36      * @param string|string[] $output      Module output.
    37      * @param string          $module_slug Module slug.
     37     * @param string|mixed $output      Module output.
     38     * @param string       $module_slug Module slug.
    3839     *
    39      * @return string|string[]
     40     * @return string|mixed
    4041     * @noinspection PhpUnusedParameterInspection
    4142     * @noinspection PhpUndefinedFunctionInspection
     
    7576
    7677        // Insert hCaptcha.
    77         return preg_replace( $pattern, $replacement, $output );
     78        return (string) preg_replace( $pattern, $replacement, $output );
    7879    }
    7980}
  • hcaptcha-for-forms-and-more/trunk/src/php/GravityForms/Field.php

    r3115148 r3143189  
    5353     * @param array $data Data.
    5454     */
    55     public function __construct( array $data = [] ) {
     55    public function __construct( $data = [] ) {
    5656        parent::__construct( $data );
    5757
  • hcaptcha-for-forms-and-more/trunk/src/php/Helpers/HCaptcha.php

    r3129246 r3143189  
    873873    public static function add_type_module( string $tag ): string {
    874874        $search  = [
    875             '/type=".+?"/',
     875            '/type=".+?" /',
    876876            '/<script /',
    877877        ];
    878878        $replace = [
    879879            '',
    880             '<script type="module"',
     880            '<script type="module" ',
    881881        ];
    882882
  • hcaptcha-for-forms-and-more/trunk/src/php/Helpers/Request.php

    r3129246 r3143189  
    11<?php
    22/**
    3  * Request class file.
     3 * Request class' file.
    44 *
    55 * @package hcaptcha-wp
     
    115115        return 'POST' === $request_method;
    116116    }
     117
     118    /**
     119     * Filter input in WP style.
     120     * Nonce must be checked in the calling function.
     121     *
     122     * @param int    $type     Input type.
     123     * @param string $var_name Variable name.
     124     *
     125     * @return string
     126     */
     127    public static function filter_input( int $type, string $var_name ): string {
     128        switch ( $type ) {
     129            case INPUT_GET:
     130                // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     131                return isset( $_GET[ $var_name ] ) ? sanitize_text_field( wp_unslash( $_GET[ $var_name ] ) ) : '';
     132            case INPUT_POST:
     133                // phpcs:ignore WordPress.Security.NonceVerification.Missing
     134                return isset( $_POST[ $var_name ] ) ? sanitize_text_field( wp_unslash( $_POST[ $var_name ] ) ) : '';
     135            case INPUT_SERVER:
     136                return isset( $_SERVER[ $var_name ] ) ? sanitize_text_field( wp_unslash( $_SERVER[ $var_name ] ) ) : '';
     137            default:
     138                return '';
     139        }
     140    }
    117141}
  • hcaptcha-for-forms-and-more/trunk/src/php/Jetpack/JetpackBase.php

    r3114572 r3143189  
    3434
    3535    /**
     36     * Errored form hash.
     37     *
     38     * @var string|null
     39     */
     40    protected $error_form_hash;
     41
     42    /**
    3643     * Constructor.
    3744     */
     
    4653     */
    4754    private function init_hooks(): void {
    48         add_filter( 'the_content', [ $this, 'add_captcha' ] );
     55        // This filter works for a Jetpack classic and block form on a page or in a template.
     56        add_filter( 'jetpack_contact_form_html', [ $this, 'add_captcha' ] );
     57
     58        // This filter works for a Jetpack form in a classic widget.
    4959        add_filter( 'widget_text', [ $this, 'add_captcha' ], 0 );
    5060
     
    8393        }
    8494
     95        $this->error_form_hash = $this->get_submitted_form_hash();
     96
    8597        $error = new WP_Error();
     98
    8699        $error->add( 'invalid_hcaptcha', $this->error_message );
    87100        add_filter( 'hcap_hcaptcha_content', [ $this, 'error_message' ] );
     
    93106     * Print error message.
    94107     *
    95      * @param string|mixed $hcaptcha_content Content of hCaptcha.
     108     * @param string|mixed $hcaptcha The hCaptcha form.
     109     * @param array        $atts     The hCaptcha shortcode attributes.
    96110     *
    97111     * @return string|mixed
    98112     */
    99     public function error_message( $hcaptcha_content = '' ) {
     113    public function error_message( $hcaptcha = '', array $atts = [] ) {
    100114        if ( null === $this->error_message ) {
    101             return $hcaptcha_content;
     115            return $hcaptcha;
     116        }
     117
     118        $hash = $atts['id']['form_id'] ?? '';
     119        $hash = str_replace( 'contact_', '', $hash );
     120
     121        if ( $hash !== $this->error_form_hash ) {
     122            return $hcaptcha;
    102123        }
    103124
     
    112133HTML;
    113134
    114         return $hcaptcha_content . $message;
     135        return $hcaptcha . $message;
    115136    }
    116137
     
    131152        HCaptcha::css_display( $css );
    132153    }
     154
     155    /**
     156     * Get form hash.
     157     *
     158     * @param string $form Jetpack form.
     159     *
     160     * @return string
     161     */
     162    protected function get_form_hash( string $form ): string {
     163        return preg_match( "/name='contact-form-hash' value='(.+)'/", $form, $m )
     164            ? '_' . $m[1]
     165            : '';
     166    }
     167
     168    /**
     169     * Get form hash.
     170     *
     171     * @return string|null
     172     */
     173    private function get_submitted_form_hash(): ?string {
     174        // phpcs:disable WordPress.Security.NonceVerification.Missing
     175        return isset( $_POST['contact-form-hash'] )
     176            ? sanitize_text_field( wp_unslash( $_POST['contact-form-hash'] ) )
     177            : null;
     178        // phpcs:enable WordPress.Security.NonceVerification.Missing
     179    }
    133180}
  • hcaptcha-for-forms-and-more/trunk/src/php/Jetpack/JetpackForm.php

    r3051014 r3143189  
    2727        // Jetpack classic form.
    2828        $content = (string) preg_replace_callback(
    29             '~(\[contact-form[\s\S]*?][\s\S]*?)(\[/contact-form])~',
    30             [ $this, 'classic_callback' ],
     29            "~<form [\s\S]*?class='contact-form[\s\S]*?(<button type='submit')[\s\S]*?</form>~",
     30            [ $this, 'replace_callback' ],
    3131            $content
    3232        );
     
    3535        return (string) preg_replace_callback(
    3636            '~<form [\s\S]*?wp-block-jetpack-contact-form[\s\S]*?(<div class="wp-block-jetpack-button wp-block-button"[\s\S]*?<button [\s\S]*?type="submit"[\s\S]*?</button>)[\s\S]*?</form>~',
    37             [ $this, 'block_callback' ],
     37            [ $this, 'replace_callback' ],
    3838            $content
    3939        );
    40     }
    41 
    42     /**
    43      * Add hCaptcha shortcode to the provided shortcode for a Jetpack classic contact form.
    44      *
    45      * @param array $matches Matches.
    46      *
    47      * @return string
    48      */
    49     public function classic_callback( array $matches ): string {
    50         if ( has_shortcode( $matches[0], 'hcaptcha' ) ) {
    51             return $matches[0];
    52         }
    53 
    54         $args = [
    55             'action' => self::ACTION,
    56             'name'   => self::NAME,
    57             'force'  => true,
    58             'id'     => [
    59                 'source'  => HCaptcha::get_class_source( __CLASS__ ),
    60                 'form_id' => 'contact',
    61             ],
    62         ];
    63 
    64         $hcaptcha = '<div class="grunion-field-wrap">' . HCaptcha::form( $args ) . '</div>';
    65 
    66         return $matches[1] . $this->error_message( $hcaptcha ) . $matches[2];
    6740    }
    6841
     
    7447     * @return string
    7548     */
    76     public function block_callback( array $matches ): string {
     49    public function replace_callback( array $matches ): string {
    7750        if ( has_shortcode( $matches[0], 'hcaptcha' ) ) {
    7851            return $matches[0];
    7952        }
    8053
     54        $hash = $this->get_form_hash( $matches[0] );
     55
    8156        $args = [
    8257            'action' => self::ACTION,
    8358            'name'   => self::NAME,
    84             'force'  => true,
    8559            'id'     => [
    8660                'source'  => HCaptcha::get_class_source( __CLASS__ ),
    87                 'form_id' => 'contact',
     61                'form_id' => 'contact' . $hash,
    8862            ],
    8963        ];
     
    9165        $hcaptcha = '<div class="grunion-field-wrap">' . HCaptcha::form( $args ) . '</div>';
    9266
     67        if ( false !== strpos( $matches[0], $hcaptcha ) ) {
     68            return $matches[0];
     69        }
     70
     71        $hcaptcha = $this->error_message( $hcaptcha, $args );
     72
    9373        return str_replace(
    9474            $matches[1],
    95             $this->error_message( $hcaptcha ) . $matches[1],
     75            $hcaptcha . $matches[1],
    9676            $matches[0]
    9777        );
  • hcaptcha-for-forms-and-more/trunk/src/php/MailPoet/Form.php

    r3129246 r3143189  
    1414
    1515use HCaptcha\Helpers\HCaptcha;
     16use HCaptcha\Helpers\Request;
    1617use MailPoet\API\JSON\API;
    1718use MailPoet\API\JSON\Response;
    18 use WP_Block;
    1919
    2020/**
     
    5151     */
    5252    private function init_hooks(): void {
    53         add_filter( 'render_block', [ $this, 'add_captcha' ], 10, 3 );
     53        add_filter( 'the_content', [ $this, 'the_content_filter' ], 20 );
    5454        add_action( 'mailpoet_api_setup', [ $this, 'verify' ] );
    5555        add_action( 'wp_print_footer_scripts', [ $this, 'enqueue_scripts' ], 9 );
     
    5757
    5858    /**
    59      * Add hcaptcha to MailPoet form.
     59     * The content filter.
    6060     *
    61      * @param string|mixed $block_content The block content.
    62      * @param array        $block         The full block, including name and attributes.
    63      * @param WP_Block     $instance      The block instance.
     61     * @param string|mixed $content Content.
    6462     *
    6563     * @return string
    66      * @noinspection PhpUnusedParameterInspection
    6764     */
    68     public function add_captcha( $block_content, array $block, WP_Block $instance ): string {
    69         if ( 'mailpoet/subscription-form-block' !== $block['blockName'] ) {
    70             return (string) $block_content;
     65    public function the_content_filter( $content ): string {
     66        $content = (string) $content;
     67
     68        if ( ! preg_match_all(
     69            '~<form[\s\S]+?"data\[form_id]" value="(\d+?)"[\s\S]+?(<input type="submit")[\s\S]+?</form>~',
     70            $content,
     71            $matches
     72        ) ) {
     73            return $content;
    7174        }
    7275
    73         $form_id = $block['attrs']['formId'] ?? 0;
    74         $search  = '<input type="submit" class="mailpoet_submit"';
    75         $args    = [
    76             'action' => self::ACTION,
    77             'name'   => self::NONCE,
    78             'id'     => [
    79                 'source'  => HCaptcha::get_class_source( __CLASS__ ),
    80                 'form_id' => $form_id,
    81             ],
    82         ];
     76        foreach ( $matches[0] as $key => $form ) {
     77            if ( false !== strpos( $form, 'h-captcha' ) ) {
     78                continue;
     79            }
    8380
    84         return str_replace(
    85             $search,
    86             HCaptcha::form( $args ) . $search,
    87             (string) $block_content
    88         );
     81            $form_id = (int) $matches[1][ $key ];
     82
     83            $args     = [
     84                'action' => self::ACTION,
     85                'name'   => self::NONCE,
     86                'id'     => [
     87                    'source'  => HCaptcha::get_class_source( __CLASS__ ),
     88                    'form_id' => $form_id,
     89                ],
     90            ];
     91            $hcaptcha = HCaptcha::form( $args );
     92
     93            $submit  = $matches[2][ $key ];
     94            $replace = str_replace( $submit, $hcaptcha . $submit, $form );
     95            $content = str_replace( $form, $replace, $content );
     96        }
     97
     98        return $content;
    8999    }
    90100
     
    93103     *
    94104     * @param API $api MailPoet API instance.
     105     *
     106     * @return void
    95107     */
    96108    public function verify( API $api ): void {
    97         if ( ! wp_doing_ajax() ) {
     109        if (
     110            Request::filter_input( INPUT_POST, 'action' ) !== 'mailpoet' ||
     111            Request::filter_input( INPUT_POST, 'endpoint' ) !== 'subscribers' ||
     112            Request::filter_input( INPUT_POST, 'method' ) !== 'subscribe'
     113        ) {
     114            // Process frontend subscription ajax request only.
    98115            return;
    99116        }
  • hcaptcha-for-forms-and-more/trunk/src/php/Main.php

    r3129246 r3143189  
    2424use HCaptcha\ElementorPro\HCaptchaHandler;
    2525use HCaptcha\Helpers\HCaptcha;
     26use HCaptcha\Helpers\Pages;
    2627use HCaptcha\Helpers\Request;
    2728use HCaptcha\Jetpack\JetpackForm;
     
    6970
    7071    /**
     72     * Priority of the plugins_loaded action to load Main.
     73     */
     74    public const LOAD_PRIORITY = Migrations::LOAD_PRIORITY + 1;
     75
     76    /**
    7177     * Form shown somewhere, use this flag to run the script.
    7278     *
     
    98104
    99105    /**
     106     * Migrations class instance.
     107     *
     108     * @var Migrations
     109     */
     110    protected $migrations;
     111
     112    /**
    100113     * Settings class instance.
    101114     *
     
    125138    public function init(): void {
    126139        if ( Request::is_xml_rpc() ) {
     140            // @codeCoverageIgnoreStart
    127141            return;
    128         }
    129 
    130         new Migrations();
     142            // @codeCoverageIgnoreEnd
     143        }
     144
     145        $this->migrations = new Migrations();
    131146
    132147        if ( wp_doing_cron() ) {
     
    136151        ( new Fix() )->init();
    137152
    138         add_action( 'plugins_loaded', [ $this, 'init_hooks' ], -PHP_INT_MAX );
     153        add_action( 'plugins_loaded', [ $this, 'init_hooks' ], self::LOAD_PRIORITY );
    139154    }
    140155
     
    172187        $this->load( Events::class );
    173188
    174         add_action( 'plugins_loaded', [ $this, 'load_modules' ], -PHP_INT_MAX + 1 );
     189        add_action( 'plugins_loaded', [ $this, 'load_modules' ], self::LOAD_PRIORITY + 1 );
    175190        add_filter( 'hcap_whitelist_ip', [ $this, 'whitelist_ip' ], -PHP_INT_MAX, 2 );
    176191        add_action( 'before_woocommerce_init', [ $this, 'declare_wc_compatibility' ] );
     
    250265        );
    251266
    252         $activate = ( ! $deactivate ) || $this->is_elementor_pro_edit_page();
     267        $activate = ( ! $deactivate ) || $this->is_edit_page();
    253268
    254269        /**
     
    261276
    262277    /**
    263      * Whether we are on the Elementor Pro edit post/page and hCaptcha for Elementor Pro is active.
     278     * Whether we are on the admin edit page for a component and component is active.
    264279     *
    265280     * @return bool
    266281     */
    267     private function is_elementor_pro_edit_page(): bool {
    268         if ( ! $this->settings()->is_on( 'elementor_pro_status' ) ) {
    269             return false;
    270         }
    271 
    272         // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
    273         $request1 = (
    274             isset( $_SERVER['REQUEST_URI'], $_GET['post'], $_GET['action'] ) &&
    275             0 === strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/wp-admin/post.php' ) &&
    276             'elementor' === $_GET['action']
     282    private function is_edit_page(): bool {
     283        $settings   = $this->settings();
     284        $components = [
     285            'beaver_builder',
     286            'cf7',
     287            'elementor_pro',
     288            'gravity',
     289            'fluent',
     290            'forminator',
     291            'formidable_forms',
     292            'ninja',
     293            'wpforms',
     294        ];
     295
     296        return array_reduce(
     297            $components,
     298            static function ( $carry, $component ) use ( $settings ) {
     299                $method = 'is_' . $component . '_edit_page';
     300
     301                if (
     302                    ! method_exists( Pages::class, $method ) ||
     303                    ! $settings->is_on( $component . '_status' )
     304                ) {
     305                    return $carry;
     306                }
     307
     308                return $carry || Pages::$method();
     309            },
     310            false
    277311        );
    278         $request2 = (
    279             isset( $_SERVER['REQUEST_URI'], $_GET['elementor-preview'] ) &&
    280             0 === strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/elementor' )
    281         );
    282         $request3 = (
    283             isset( $_POST['action'] ) && 'elementor_ajax' === $_POST['action']
    284         );
    285 
    286         // phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
    287 
    288         return $request1 || $request2 || $request3;
    289312    }
    290313
     
    323346         *
    324347         * @param bool  $add_csp_headers Add Content Security Policy (CSP) headers.
    325          * @param array $headers Current headers.
     348         * @param array $headers         Current headers.
    326349         */
    327350        if ( ! apply_filters( 'hcap_add_csp_headers', false, $headers ) ) {
     
    863886                BackInStockNotifier\Form::class,
    864887            ],
     888            'bbPress Login Form'                   => [
     889                [ 'bbp_status', null ],
     890                'bbpress/bbpress.php',
     891                BBPress\Login::class,
     892            ],
     893            'bbPress Lost Password Form'           => [
     894                [ 'bbp_status', null ],
     895                'bbpress/bbpress.php',
     896                BBPress\LostPassword::class,
     897            ],
    865898            'bbPress New Topic'                    => [
    866899                [ 'bbp_status', 'new_topic' ],
    867900                'bbpress/bbpress.php',
    868901                BBPress\NewTopic::class,
     902            ],
     903            'bbPress Register Form'                => [
     904                [ 'bbp_status', null ],
     905                'bbpress/bbpress.php',
     906                BBPress\Register::class,
    869907            ],
    870908            'bbPress Reply'                        => [
  • hcaptcha-for-forms-and-more/trunk/src/php/Migrations/Migrations.php

    r3114572 r3143189  
    3737
    3838    /**
     39     * Priority of the plugins_loaded action to load Migrations.
     40     */
     41    public const LOAD_PRIORITY = -PHP_INT_MAX;
     42
     43    /**
    3944     * Plugin name.
    4045     */
     
    6772     */
    6873    private function init_hooks(): void {
    69         add_action( 'plugins_loaded', [ $this, 'migrate' ], - PHP_INT_MAX );
     74        add_action( 'plugins_loaded', [ $this, 'migrate' ], self::LOAD_PRIORITY );
    7075    }
    7176
     
    142147        }
    143148
    144         return wp_doing_cron() || is_admin() || ( defined( 'WP_CLI' ) && constant( 'WP_CLI' ) );
     149        return (
     150            ( is_admin() && ! wp_doing_ajax() ) ||
     151            wp_doing_cron() ||
     152            ( defined( 'WP_CLI' ) && constant( 'WP_CLI' ) )
     153        );
     154    }
     155
     156    /**
     157     * Send plugin statistics.
     158     *
     159     * @return void
     160     */
     161    public function send_plugin_stats(): void {
     162        /**
     163         * Send plugin statistics.
     164         */
     165        do_action( 'hcap_send_plugin_stats' );
    145166    }
    146167
     
    158179
    159180        // Send statistics on plugin update.
    160         add_action(
    161             'init',
    162             static function () {
    163                 /**
    164                  * Send plugin statistics.
    165                  */
    166                 do_action( 'hcap_send_plugin_stats' );
    167             }
    168         );
     181        add_action( 'init', [ $this, 'send_plugin_stats' ] );
    169182    }
    170183
     
    199212
    200213    /**
    201      * Output message into log file.
     214     * Output message into the log file.
    202215     *
    203216     * @param string $message Message to log.
  • hcaptcha-for-forms-and-more/trunk/src/php/NF/Field.php

    r3114572 r3143189  
    1818 * Class Field
    1919 */
    20 class Field extends NF_Abstracts_Field {
     20class Field extends NF_Abstracts_Field implements Base {
    2121
    2222    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
    2323
    2424    /**
    25      * Name.
     25     * Field name.
    2626     *
    2727     * @var string
    2828     */
    29     protected $_name = 'hcaptcha-for-ninja-forms';
     29    protected $_name = self::NAME;
    3030
    3131    /**
    32      * Type.
     32     * Filed type.
    3333     *
    3434     * @var string
    3535     */
    36     protected $_type = 'hcaptcha';
     36    protected $_type = self::TYPE;
    3737
    3838    /**
  • hcaptcha-for-forms-and-more/trunk/src/php/NF/NF.php

    r3114572 r3143189  
    1515 * Support Ninja Forms.
    1616 */
    17 class NF {
     17class NF implements Base {
    1818
    1919    /**
     
    4242     * @var int
    4343     */
    44     private $form_id = 0;
     44    protected $form_id = 0;
    4545
    4646    /**
     
    4949     * @var string
    5050     */
    51     private $templates_dir;
     51    protected $templates_dir;
    5252
    5353    /**
     
    6666     */
    6767    public function init_hooks(): void {
     68        $name = Base::NAME;
     69
    6870        add_action( 'toplevel_page_ninja-forms', [ $this, 'admin_template' ], 11 );
    6971        add_action( 'nf_admin_enqueue_scripts', [ $this, 'nf_admin_enqueue_scripts' ] );
     
    7274        add_filter( 'ninja_forms_field_template_file_paths', [ $this, 'template_file_paths' ] );
    7375        add_action( 'nf_get_form_id', [ $this, 'set_form_id' ] );
    74         add_filter( 'ninja_forms_localize_field_hcaptcha-for-ninja-forms', [ $this, 'localize_field' ] );
     76        add_filter( "ninja_forms_localize_field_$name", [ $this, 'localize_field' ] );
     77        add_filter( "ninja_forms_localize_field_{$name}_preview", [ $this, 'localize_field' ] );
    7578        add_action( 'wp_print_footer_scripts', [ $this, 'nf_captcha_script' ], 9 );
    7679    }
     
    9699        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    97100        echo str_replace(
    98             'tmpl-nf-field-hcaptcha',
    99             'tmpl-nf-field-hcaptcha-for-ninja-forms',
     101            'tmpl-nf-field-' . Base::TYPE,
     102            'tmpl-nf-field-' . Base::NAME,
    100103            $template
    101104        );
     
    111114
    112115        // Add hCaptcha to the preloaded form data.
    113         $data = $wp_scripts->registered['nf-builder']->extra['data'];
     116        $data = $wp_scripts->registered['nf-builder']->extra['data'] ?? '';
    114117
    115118        if ( ! preg_match( '/var nfDashInlineVars = (.+);/', $data, $m ) ) {
     
    121124
    122125        foreach ( $vars['preloadedFormData']['fields'] as & $field ) {
    123             if ( 'hcaptcha-for-ninja-forms' === $field['type'] ) {
     126            // See comment in admin_template().
     127            if ( Base::NAME === $field['type'] ) {
    124128                $found             = true;
    125129                $search            = 'class="h-captcha"';
     
    129133                    $this->get_hcaptcha( (int) $field['id'] )
    130134                );
     135
    131136                break;
    132137            }
     
    187192        $fields = (array) $fields;
    188193
    189         $fields['hcaptcha-for-ninja-forms'] = new Field();
     194        $fields[ Base::NAME ] = new Field();
    190195
    191196        return $fields;
     
    203208
    204209        if ( false === $index ) {
     210            // @codeCoverageIgnoreStart
    205211            return;
    206         }
    207 
    208         $hcaptcha_key   = 'hcaptcha-for-ninja-forms';
     212            // @codeCoverageIgnoreEnd
     213        }
     214
     215        $hcaptcha_key   = Base::NAME;
    209216        $hcaptcha_value = $fields[ $hcaptcha_key ];
    210217
     
    255262
    256263        $field['settings']['hcaptcha'] = $field['settings']['hcaptcha'] ?? $this->get_hcaptcha( (int) $field['id'] );
     264
     265        // Mark hCaptcha as shown in any case. Needed on the preview page.
     266        hcaptcha()->form_shown = true;
    257267
    258268        return $field;
  • hcaptcha-for-forms-and-more/trunk/src/php/Settings/Abstracts/SettingsBase.php

    r3114572 r3143189  
    233233            'select'   => [ $this, 'print_select_field' ],
    234234            'multiple' => [ $this, 'print_multiple_select_field' ],
     235            'file'     => [ $this, 'print_file_field' ],
    235236            'table'    => [ $this, 'print_table_field' ],
    236237            'button'   => [ $this, 'print_button_field' ],
     
    260261        $this->init_settings();
    261262
    262         if ( $this->is_main_menu_page() || $this->is_tab_active( $this ) ) {
     263        if ( is_admin() && ( $this->is_main_menu_page() || $this->is_tab_active( $this ) ) ) {
    263264            $this->init_hooks();
    264265        }
     
    708709     */
    709710    public function tabs_callback(): void {
     711        if ( ! count( $this->tabs ?? [] ) ) {
     712            return;
     713        }
     714
    710715        ?>
    711716        <div class="<?php echo esc_attr( static::PREFIX . '-settings-tabs' ); ?>">
     
    12361241
    12371242    /**
     1243     * Print file field.
     1244     *
     1245     * @param array $arguments Field arguments.
     1246     *
     1247     * @return void
     1248     * @noinspection HtmlUnknownAttribute
     1249     */
     1250    protected function print_file_field( array $arguments ): void {
     1251        $multiple = (bool) ( $arguments['multiple'] ?? '' );
     1252        $accept   = $arguments['accept'] ?? '';
     1253
     1254        printf(
     1255            '<input %1$s name="%2$s[%3$s]%4$s" id="%3$s" type="file" %5$s %6$s/>',
     1256            disabled( $arguments['disabled'], true, false ),
     1257            esc_html( $this->option_name() ),
     1258            esc_attr( $arguments['field_id'] ),
     1259            esc_attr( $multiple ? '[]' : '' ),
     1260            esc_attr( $multiple ? 'multiple' : '' ),
     1261            $accept ? 'accept="' . esc_attr( $accept ) . '"' : ''
     1262        );
     1263    }
     1264
     1265    /**
    12381266     * Print table field.
    12391267     *
     
    14611489
    14621490        foreach ( $this->form_fields() as $key => $form_field ) {
     1491            if ( 'file' === $form_field['type'] ) {
     1492                unset( $value[ $key ], $old_value[ $key ] );
     1493                continue;
     1494            }
     1495
    14631496            if ( 'checkbox' !== $form_field['type'] || isset( $value[ $key ] ) ) {
    14641497                continue;
     
    16201653        <?php
    16211654    }
     1655
     1656    /**
     1657     * Get savable for fields.
     1658     *
     1659     * @return array
     1660     */
     1661    protected function get_savable_form_fields(): array {
     1662        $not_savable_form_fields = [ 'button', 'file' ];
     1663
     1664        return array_filter(
     1665            $this->form_fields,
     1666            static function ( $field ) use ( $not_savable_form_fields ) {
     1667                return ! in_array( $field['type'] ?? '', $not_savable_form_fields, true );
     1668            }
     1669        );
     1670    }
    16221671}
  • hcaptcha-for-forms-and-more/trunk/src/php/Settings/Integrations.php

    r3129246 r3143189  
    213213                'type'    => 'checkbox',
    214214                'options' => [
     215                    'login'     => __( 'Login Form', 'hcaptcha-for-forms-and-more' ),
     216                    'lost_pass' => __( 'Lost Password Form', 'hcaptcha-for-forms-and-more' ),
    215217                    'new_topic' => __( 'New Topic Form', 'hcaptcha-for-forms-and-more' ),
     218                    'register'  => __( 'Register Form', 'hcaptcha-for-forms-and-more' ),
    216219                    'reply'     => __( 'Reply Form', 'hcaptcha-for-forms-and-more' ),
    217220                ],
  • hcaptcha-for-forms-and-more/trunk/src/php/Settings/PluginSettingsBase.php

    r3114572 r3143189  
    197197            settings_fields( $this->option_group() ); // Hidden protection fields.
    198198
    199             if ( ! empty( $this->form_fields ) ) {
     199            if ( ! empty( $this->get_savable_form_fields() ) ) {
    200200                $this->submit_button();
    201201            }
  • hcaptcha-for-forms-and-more/trunk/src/php/Settings/Settings.php

    r3114572 r3143189  
    106106     */
    107107    public function get_tab( string $classname ): ?PluginSettingsBase {
    108         $tabs = hcaptcha()->settings()->get_tabs();
    109 
    110         foreach ( $tabs as $tab ) {
     108        foreach ( $this->tabs as $tab ) {
    111109            if ( is_a( $tab, $classname ) ) {
    112110                return $tab;
  • hcaptcha-for-forms-and-more/trunk/src/php/Spectra/Form.php

    r3114572 r3143189  
    3737     * @var bool
    3838     */
    39     private $has_recaptcha_field;
     39    protected $has_recaptcha_field;
    4040
    4141    /**
     
    7979            return $block_content;
    8080        }
     81
     82        $block_content = (string) $block_content;
    8183
    8284        $args = [
     
    8991        ];
    9092
    91         $block_content = (string) $block_content;
    92 
    9393        $this->has_recaptcha_field = false;
    9494
     
    198198     * @return bool
    199199     */
    200     private function has_recaptcha(): bool {
     200    protected function has_recaptcha(): bool {
    201201        // Spectra checks nonce.
    202202        // phpcs:disable WordPress.Security.NonceVerification.Missing
  • hcaptcha-for-forms-and-more/trunk/src/php/WPDiscuz/Base.php

    r3114572 r3143189  
    2424     *
    2525     * @return void
     26     * @noinspection PhpUndefinedFunctionInspection
    2627     */
    2728    protected function init_hooks(): void {
    28         add_filter(
    29             'wpdiscuz_recaptcha_site_key',
    30             static function () {
    31                 // Block output of reCaptcha by wpDiscuz.
    32                 return '';
    33             }
     29        if ( ! function_exists( 'wpDiscuz' ) ) {
     30            return;
     31        }
     32
     33        $wpd_recaptcha = wpDiscuz()->options->recaptcha;
     34        $wpd_recaptcha = array_merge(
     35            $wpd_recaptcha,
     36            [
     37                'siteKey'       => '',
     38                'showForGuests' => 0,
     39                'showForUsers'  => 0,
     40            ]
    3441        );
     42
     43        // Block output of reCaptcha by wpDiscuz.
     44        wpDiscuz()->options->recaptcha = $wpd_recaptcha;
    3545
    3646        add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ], 11 );
  • hcaptcha-for-forms-and-more/trunk/src/php/includes/functions.php

    r3064004 r3143189  
    1111 * Display hCaptcha shortcode.
    1212 *
    13  * @param array|string $atts hcaptcha shortcode attributes.
     13 * @param array|string $atts The hCaptcha shortcode attributes.
    1414 *
    1515 * @return string
     
    3838
    3939    /**
    40      * Filters the content of the hcaptcha form.
     40     * Filters the content of the hCaptcha form.
    4141     *
    42      * @param string $form The hcaptcha form.
     42     * @param string $form The hCaptcha form.
     43     * @param array  $atts The hCaptcha shortcode attributes.
    4344     */
    44     return (string) apply_filters( 'hcap_hcaptcha_content', HCaptcha::form( $atts ) );
     45    return (string) apply_filters( 'hcap_hcaptcha_content', HCaptcha::form( $atts ), $atts );
    4546}
    4647
  • hcaptcha-for-forms-and-more/trunk/src/php/includes/request.php

    r3114572 r3143189  
    314314    function hcaptcha_get_verify_output( string $empty_message, string $fail_message, string $nonce_field_name, string $nonce_action_name ): ?string {
    315315        if ( ! empty( $empty_message ) || ! empty( $fail_message ) ) {
     316            // @codeCoverageIgnoreStart
    316317            _deprecated_argument( __FUNCTION__, '2.1.0' );
     318            // @codeCoverageIgnoreEnd
    317319        }
    318320
  • hcaptcha-for-forms-and-more/trunk/vendor/autoload.php

    r3114572 r3143189  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470::getLoader();
     25return ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f::getLoader();
  • hcaptcha-for-forms-and-more/trunk/vendor/composer/autoload_classmap.php

    r3129246 r3143189  
    2323    'HCaptcha\\Avada\\Form' => $baseDir . '/src/php/Avada/Form.php',
    2424    'HCaptcha\\BBPress\\Base' => $baseDir . '/src/php/BBPress/Base.php',
     25    'HCaptcha\\BBPress\\Login' => $baseDir . '/src/php/BBPress/Login.php',
     26    'HCaptcha\\BBPress\\LostPassword' => $baseDir . '/src/php/BBPress/LostPassword.php',
    2527    'HCaptcha\\BBPress\\NewTopic' => $baseDir . '/src/php/BBPress/NewTopic.php',
     28    'HCaptcha\\BBPress\\Register' => $baseDir . '/src/php/BBPress/Register.php',
    2629    'HCaptcha\\BBPress\\Reply' => $baseDir . '/src/php/BBPress/Reply.php',
    2730    'HCaptcha\\BackInStockNotifier\\Form' => $baseDir . '/src/php/BackInStockNotifier/Form.php',
     
    7174    'HCaptcha\\HTMLForms\\Form' => $baseDir . '/src/php/HTMLForms/Form.php',
    7275    'HCaptcha\\Helpers\\HCaptcha' => $baseDir . '/src/php/Helpers/HCaptcha.php',
     76    'HCaptcha\\Helpers\\Pages' => $baseDir . '/src/php/Helpers/Pages.php',
    7377    'HCaptcha\\Helpers\\Request' => $baseDir . '/src/php/Helpers/Request.php',
    7478    'HCaptcha\\Jetpack\\JetpackBase' => $baseDir . '/src/php/Jetpack/JetpackBase.php',
     
    8892    'HCaptcha\\MemberPress\\Register' => $baseDir . '/src/php/MemberPress/Register.php',
    8993    'HCaptcha\\Migrations\\Migrations' => $baseDir . '/src/php/Migrations/Migrations.php',
     94    'HCaptcha\\NF\\Base' => $baseDir . '/src/php/NF/Base.php',
    9095    'HCaptcha\\NF\\Field' => $baseDir . '/src/php/NF/Field.php',
    9196    'HCaptcha\\NF\\NF' => $baseDir . '/src/php/NF/NF.php',
  • hcaptcha-for-forms-and-more/trunk/vendor/composer/autoload_real.php

    r3129246 r3143189  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470
     5class ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInita6c3d020c47c988d11030e9a25036470', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit02b6959c9a88d67618a6c0c1eb5fcc5f', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInita6c3d020c47c988d11030e9a25036470::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
  • hcaptcha-for-forms-and-more/trunk/vendor/composer/autoload_static.php

    r3129246 r3143189  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInita6c3d020c47c988d11030e9a25036470
     7class ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    5151        'HCaptcha\\Avada\\Form' => __DIR__ . '/../..' . '/src/php/Avada/Form.php',
    5252        'HCaptcha\\BBPress\\Base' => __DIR__ . '/../..' . '/src/php/BBPress/Base.php',
     53        'HCaptcha\\BBPress\\Login' => __DIR__ . '/../..' . '/src/php/BBPress/Login.php',
     54        'HCaptcha\\BBPress\\LostPassword' => __DIR__ . '/../..' . '/src/php/BBPress/LostPassword.php',
    5355        'HCaptcha\\BBPress\\NewTopic' => __DIR__ . '/../..' . '/src/php/BBPress/NewTopic.php',
     56        'HCaptcha\\BBPress\\Register' => __DIR__ . '/../..' . '/src/php/BBPress/Register.php',
    5457        'HCaptcha\\BBPress\\Reply' => __DIR__ . '/../..' . '/src/php/BBPress/Reply.php',
    5558        'HCaptcha\\BackInStockNotifier\\Form' => __DIR__ . '/../..' . '/src/php/BackInStockNotifier/Form.php',
     
    99102        'HCaptcha\\HTMLForms\\Form' => __DIR__ . '/../..' . '/src/php/HTMLForms/Form.php',
    100103        'HCaptcha\\Helpers\\HCaptcha' => __DIR__ . '/../..' . '/src/php/Helpers/HCaptcha.php',
     104        'HCaptcha\\Helpers\\Pages' => __DIR__ . '/../..' . '/src/php/Helpers/Pages.php',
    101105        'HCaptcha\\Helpers\\Request' => __DIR__ . '/../..' . '/src/php/Helpers/Request.php',
    102106        'HCaptcha\\Jetpack\\JetpackBase' => __DIR__ . '/../..' . '/src/php/Jetpack/JetpackBase.php',
     
    116120        'HCaptcha\\MemberPress\\Register' => __DIR__ . '/../..' . '/src/php/MemberPress/Register.php',
    117121        'HCaptcha\\Migrations\\Migrations' => __DIR__ . '/../..' . '/src/php/Migrations/Migrations.php',
     122        'HCaptcha\\NF\\Base' => __DIR__ . '/../..' . '/src/php/NF/Base.php',
    118123        'HCaptcha\\NF\\Field' => __DIR__ . '/../..' . '/src/php/NF/Field.php',
    119124        'HCaptcha\\NF\\NF' => __DIR__ . '/../..' . '/src/php/NF/NF.php',
     
    191196    {
    192197        return \Closure::bind(function () use ($loader) {
    193             $loader->prefixLengthsPsr4 = ComposerStaticInita6c3d020c47c988d11030e9a25036470::$prefixLengthsPsr4;
    194             $loader->prefixDirsPsr4 = ComposerStaticInita6c3d020c47c988d11030e9a25036470::$prefixDirsPsr4;
    195             $loader->classMap = ComposerStaticInita6c3d020c47c988d11030e9a25036470::$classMap;
     198            $loader->prefixLengthsPsr4 = ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::$prefixLengthsPsr4;
     199            $loader->prefixDirsPsr4 = ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::$prefixDirsPsr4;
     200            $loader->classMap = ComposerStaticInit02b6959c9a88d67618a6c0c1eb5fcc5f::$classMap;
    196201
    197202        }, null, ClassLoader::class);
  • hcaptcha-for-forms-and-more/trunk/vendor/composer/installed.php

    r3129246 r3143189  
    22    'root' => array(
    33        'name' => 'hcaptcha/hcaptcha-wordpress-plugin',
    4         'pretty_version' => '4.4.0',
    5         'version' => '4.4.0.0',
    6         'reference' => '25bdd39c5629233960c20655da571516f475acb3',
     4        'pretty_version' => '4.5.0',
     5        'version' => '4.5.0.0',
     6        'reference' => '0ba34f4533d55163e1ba8af8e119a49ec192be45',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'hcaptcha/hcaptcha-wordpress-plugin' => array(
    14             'pretty_version' => '4.4.0',
    15             'version' => '4.4.0.0',
    16             'reference' => '25bdd39c5629233960c20655da571516f475acb3',
     14            'pretty_version' => '4.5.0',
     15            'version' => '4.5.0.0',
     16            'reference' => '0ba34f4533d55163e1ba8af8e119a49ec192be45',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.