Skip to content

Commit

Permalink
fix style for WPForms
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso committed Apr 2, 2024
1 parent 47d83d2 commit f4d73f0
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 319 deletions.
14 changes: 14 additions & 0 deletions assets/css/wpforms.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.procaptcha input:before, .procaptcha input:after { content: none !important; }

#procaptcha > div > div > div.css-1qvfrk6 > div > div > div > div:nth-child(1) > div > div > div:nth-child(2) > div > div{
margin-top: 0px;
margin-left: 15px;
margin-right: 15px;
width: 2em;
height: 2em;
border-width: 4px;
border-style: solid;
border-color: rgb(0, 0, 0) rgb(0, 0, 0) transparent;
border-image: initial;
border-radius: 50%;
}
1 change: 0 additions & 1 deletion assets/js/apps/procaptcha.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(() => {
"use strict";
const getParentForm = (element) => element.closest('form')
const t = function (t) {
return "string" != typeof t || "" === t
? (console.error("The namespace must be a non-empty string."), !1)
Expand Down
2 changes: 1 addition & 1 deletion assets/js/general.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion docker/docker-compose.wordpress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ services:
WORDPRESS_DB_NAME: procaptchadb
volumes:
- wordpress:/var/www/html
- ..:/procaptcha-wordpress
- .:/procaptcha-wordpress
- ./wordpress.ini:/usr/local/etc/php/conf.d/wordpress.ini

db:
image: mysql:5.7
Expand Down
6 changes: 6 additions & 0 deletions docker/wordpress.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file_uploads = On
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 1000
1 change: 1 addition & 0 deletions src/php/Admin/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public function admin_enqueue_scripts() {
[],
constant( 'PROCAPTCHA_VERSION' )
);

}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/php/ElementorPro/HCaptchaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct() {
* @return void
*/
public function after_enqueue_scripts() {
$min = hcap_min_suffix();
$min = procap_min_suffix();

wp_enqueue_script(
self::ADMIN_HANDLE,
Expand Down Expand Up @@ -218,7 +218,7 @@ protected static function get_script_handle(): string {
*/
private function register_scripts() {
$src = $this->main->get_api_src();
$min = hcap_min_suffix();
$min = procap_min_suffix();

wp_register_script(
static::get_script_handle(),
Expand Down Expand Up @@ -275,8 +275,8 @@ public function validation( Form_Record $record, Ajax_Handler $ajax_handler ) {
$field = current( $fields );

// phpcs:disable WordPress.Security.NonceVerification.Missing
$procaptcha_response = isset( $_POST['h-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['h-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';
// phpcs:enable WordPress.Security.NonceVerification.Missing

Expand Down Expand Up @@ -425,7 +425,7 @@ public function filter_field_item( $item ): array {
* @return void
*/
public function print_footer_scripts() {
$min = hcap_min_suffix();
$min = procap_min_suffix();

wp_enqueue_script(
self::HANDLE,
Expand Down
30 changes: 12 additions & 18 deletions src/php/FormidableForms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct() {
public function init_hooks() {
add_filter( 'transient_frm_options', [ $this, 'get_transient' ], 10, 2 );
add_filter( 'frm_replace_shortcodes', [ $this, 'add_captcha' ], 10, 3 );
//add_filter( 'frm_is_field_hidden', [ $this, 'prevent_native_validation' ], 10, 3 );
add_filter( 'frm_is_field_hidden', [ $this, 'prevent_native_validation' ], 10, 3 );
add_filter( 'frm_validate_entry', [ $this, 'verify' ], 10, 3 );
add_action( 'wp_print_footer_scripts', [ $this, 'enqueue_scripts' ], 9 );
}
Expand All @@ -74,7 +74,7 @@ public function get_transient( $value, string $transient ) {

$settings = procaptcha()->settings();
$value->procaptcha_pubkey = $settings->get_site_key();


return $value;
}
Expand All @@ -89,29 +89,23 @@ public function get_transient( $value, string $transient ) {
* @return string|mixed
*/
public function add_captcha( $html, array $field, array $atts ) {


if ( 'captcha' !== $field['type'] ) {
return $html;
}

$frm_settings = FrmAppHelper::get_settings();


// if ( 'recaptcha' === $frm_settings->active_captcha ) {

// return $html;
// }
if ( 'recaptcha' === $frm_settings->active_captcha ) {
return $html;
}

// <div id="field_5l59" class="procaptcha" data-sitekey="ead4f33b-cd8a-49fb-aa16-51683d9cffc8"></div>
//print_r($html);

// if ( ! preg_match( '#<div id="(.+)" class="procaptcha" .+></div>#', (string) $html, $m ) ) {
// die('testing');
// return $html;
// }
if ( ! preg_match( '#<div id="(.+)" class="procaptcha" .+></div>#', (string) $html, $m ) ) {
return $html;
}

//list( $captcha_div, $div_id ) = $m;
list( $captcha_div, $div_id ) = $m;

$args = [
'action' => self::ACTION,
Expand All @@ -123,9 +117,9 @@ public function add_captcha( $html, array $field, array $atts ) {
];

$class = 'class="procaptcha"';
$form = PROCAPTCHA::form( $args );
$form = str_replace( $class, 'id="' . $div_id . '"' . $class, Procaptcha::form( $args ) );

return $form;
return str_replace( $captcha_div, $form, (string) $html );
}

/**
Expand Down
Loading

0 comments on commit f4d73f0

Please sign in to comment.