Skip to content

Commit

Permalink
fixes and improvements to formidable integration
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinfuchs committed Apr 19, 2024
1 parent fcbb19a commit 4c86382
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion friendly-captcha/modules/formidable/builder-field.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Friendly Captcha is load only on frontend.</p>
<p>Friendly Captcha will be displayed here.</p>
2 changes: 1 addition & 1 deletion friendly-captcha/modules/formidable/builder-settings.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Settings is in the plugin Friendly Captcha</p>
<p>Please configure Friendly Captcha in the plugin settings.</p>
37 changes: 13 additions & 24 deletions friendly-captcha/modules/formidable/formidable.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
<?php
/*
Plugin Name: Formidable Forms Field Friendly Captcha
Description: Friendly Captcha field type in Formidable Forms.
Version: 1.0
Plugin URI: https://formidableforms.com/
Author URI: https://netsuccess.sk/
Author: SlimCo
Original Author URI: https://netsuccess.sk/
Original Author: SlimCo
*/


// TODO: replace 'frmfrcaptcha_' and 'Frcaptcha' with your own.
// TODO: replace 'new-type' with the slug for your field.

/**
* Add the autoloader.
*/
function frmfrcaptcha_load_formidable_field() {
spl_autoload_register( 'frmfrcaptcha_forms_autoloader' );
function frcaptcha_load_formidable_field() {
spl_autoload_register( 'frcaptcha_forms_autoloader' );
}
add_action( 'plugins_loaded', 'frmfrcaptcha_load_formidable_field' );
add_action( 'plugins_loaded', 'frcaptcha_load_formidable_field' );

/**
* @since 3.0
*/
function frmfrcaptcha_forms_autoloader( $class_name ) {
function frcaptcha_forms_autoloader( $class_name ) {
// Only load Frcaptcha classes here
if ( ! preg_match( '/^Frcaptcha.+$/', $class_name ) ) {
return;
Expand All @@ -41,19 +30,19 @@ function frmfrcaptcha_forms_autoloader( $class_name ) {
* Tell Formidable where to find the new field type.
* @return string The name of the new class that extends FrmFieldType.
*/
function frmfrcaptcha_get_field_type_class( $class, $field_type ) {
if ( $field_type === 'frcaptcha' ) { // Replace 'frcaptcha' with your field slug.
$class = 'FrcaptchaFieldNewType'; // Set your class name here.
function frcaptcha_get_field_type_class( $class, $field_type ) {
if ( $field_type === 'frcaptcha' ) {
$class = 'FrcaptchaFieldNewType';
}
return $class;
}
add_filter( 'frm_get_field_type_class', 'frmfrcaptcha_get_field_type_class', 10, 2 );
add_filter( 'frm_get_field_type_class', 'frcaptcha_get_field_type_class', 10, 2 );

function frmfrcaptcha_add_new_field( $fields ) {
function frcaptcha_add_new_field( $fields ) {
$fields['frcaptcha'] = array(
'name' => 'Friendly Captcha',
'icon' => 'frm_icon_font frm_pencil_icon', // Set the class for a custom icon here.
'icon' => 'frm_icon_font frm_shield_check_icon', // Set the class for a custom icon here.
);
return $fields;
}
add_filter( 'frm_available_fields', 'frmfrcaptcha_add_new_field' );
add_filter( 'frm_available_fields', 'frcaptcha_add_new_field' );

0 comments on commit 4c86382

Please sign in to comment.