Skip to content
Snippets Groups Projects
Commit beda9ad9 authored by Christian Wach's avatar Christian Wach :soccer:
Browse files

First pass at Conditional Email action

parent 658b6565
No related branches found
No related tags found
No related merge requests found
...@@ -114,11 +114,11 @@ class CFAFA_ACFE { ...@@ -114,11 +114,11 @@ class CFAFA_ACFE {
// Include class files. // Include class files.
include CFAFA_PATH . 'includes/form-actions/cfafa-form-action-base.php'; include CFAFA_PATH . 'includes/form-actions/cfafa-form-action-base.php';
include CFAFA_PATH . 'includes/form-actions/cfafa-form-action-redirect.php'; include CFAFA_PATH . 'includes/form-actions/cfafa-form-action-redirect.php';
//include CFAFA_PATH . 'includes/form-actions/cfafa-form-action-email.php'; include CFAFA_PATH . 'includes/form-actions/cfafa-form-action-email.php';
// Instantiate the Form Actions. // Instantiate the Form Actions.
new CFAFA_Form_Action_Redirect( $this ); new CFAFA_Form_Action_Redirect( $this );
//new CFAFA_Form_Action_Email( $this ); new CFAFA_Form_Action_Email( $this );
// Maybe add WooCommerce Product Action. // Maybe add WooCommerce Product Action.
if ( function_exists( 'WC' ) ) { if ( function_exists( 'WC' ) ) {
......
...@@ -73,7 +73,7 @@ class CFAFA_Form_Action_Base { ...@@ -73,7 +73,7 @@ class CFAFA_Form_Action_Base {
public function __construct() { public function __construct() {
// Callback for the "acfe/form/load/..." hook. // Callback for the "acfe/form/load/..." hook.
add_filter( 'acfe/form/load/' . $this->action_name, [ $this, 'load' ], 10, 3 ); add_filter( 'acfe/form/load/' . $this->action_name, [ $this, 'load' ], 10, 3 );
// Callback for the "acfe/form/make/..." hook. // Callback for the "acfe/form/make/..." hook.
add_action( 'acfe/form/make/' . $this->action_name, [ $this, 'make' ], 10, 3 ); add_action( 'acfe/form/make/' . $this->action_name, [ $this, 'make' ], 10, 3 );
...@@ -235,10 +235,14 @@ class CFAFA_Form_Action_Base { ...@@ -235,10 +235,14 @@ class CFAFA_Form_Action_Base {
// Build Mapping Tab. // Build Mapping Tab.
$mapping_tab_fields = $this->tab_mapping_add(); $mapping_tab_fields = $this->tab_mapping_add();
// Build Attachments Tab.
$attachments_tab_fields = $this->tab_attachments_add();
// Combine Sub-Fields. // Combine Sub-Fields.
$sub_fields = array_merge( $sub_fields = array_merge(
$action_tab_fields, $action_tab_fields,
$mapping_tab_fields $mapping_tab_fields,
$attachments_tab_fields
); );
/** /**
...@@ -362,14 +366,20 @@ class CFAFA_Form_Action_Base { ...@@ -362,14 +366,20 @@ class CFAFA_Form_Action_Base {
* *
* @since 0.1 * @since 0.1
* *
* @param string $label The label for this section.
* @return array $fields The array of Fields for this section. * @return array $fields The array of Fields for this section.
*/ */
public function tab_mapping_header() { public function tab_mapping_header( $label = '' ) {
// Set a default label.
if ( empty( $label ) ) {
$label = __( 'Mapping', 'conditional-form-actions-for-acfe' );
}
// "Mapping" Tab wrapper. // "Mapping" Tab wrapper.
$mapping_tab = [ [ $mapping_tab = [ [
'key' => $this->field_key . 'tab_load', 'key' => $this->field_key . 'tab_load',
'label' => __( 'Mapping', 'conditional-form-actions-for-acfe' ), 'label' => $label,
'name' => '', 'name' => '',
'type' => 'tab', 'type' => 'tab',
'instructions' => '', 'instructions' => '',
...@@ -396,6 +406,57 @@ class CFAFA_Form_Action_Base { ...@@ -396,6 +406,57 @@ class CFAFA_Form_Action_Base {
} }
/**
* Defines the "Attachments" Tab.
*
* @since 0.1
*
* @return array $fields The array of Fields for this section.
*/
public function tab_attachments_add() {
$fields = [];
return $fields;
}
/**
* Defines the "Attachments" Tab Header.
*
* @since 0.1
*
* @return array $fields The array of Fields for this section.
*/
public function tab_attachments_header() {
// "Attachments" Tab wrapper.
$attachments_tab = [ [
'key' => $this->field_key . 'tab_attachments',
'label' => __( 'Attachments', 'civicrm-wp-profile-sync' ),
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
'data-no-preference' => true,
],
'acfe_permissions' => '',
'placement' => 'top',
'endpoint' => 0,
] ];
// Combine Fields.
$fields = array_merge(
$attachments_tab
);
// --<
return $fields;
}
/** /**
* Gets the array that defines a "Map Field" for the "Mapping" Tab. * Gets the array that defines a "Map Field" for the "Mapping" Tab.
* *
...@@ -460,7 +521,24 @@ class CFAFA_Form_Action_Base { ...@@ -460,7 +521,24 @@ class CFAFA_Form_Action_Base {
$helpers = acf_get_instance( 'acfe_dynamic_forms_helpers' ); $helpers = acf_get_instance( 'acfe_dynamic_forms_helpers' );
// Populate mapping Fields. // Populate mapping Fields.
add_filter( 'acf/prepare_field/name=' . $this->field_name . 'map_' . $code, [ $helpers, 'map_fields_deep_no_custom' ] ); add_filter( 'acf/prepare_field/name=' . $this->field_name . 'map_' . $code, [ $helpers, 'map_fields_deep_no_custom' ] );
}
/**
* Adds filters that configure a named Field when loaded.
*
* @since 0.1
*
* @param string $name The unique name for the Field.
*/
public function mapping_field_filter_deep( $name ) {
// Grab reference to ACFE Helper object.
$helpers = acf_get_instance( 'acfe_dynamic_forms_helpers' );
// Populate named Field.
add_filter( 'acf/prepare_field/name=' . $name, [ $helpers, 'map_fields_deep' ] );
} }
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment