From 529ba481633251dfebb84b17d5f0f80b3e61ecc2 Mon Sep 17 00:00:00 2001 From: Christian Wach <needle@haystack.co.uk> Date: Wed, 20 Mar 2024 19:24:57 +0000 Subject: [PATCH] Align docblock internals --- .../form-actions/cfafa-form-action-base.php | 160 +++++------ .../form-actions/cfafa-form-action-email.php | 260 +++++++++--------- .../cfafa-form-action-product.php | 64 ++--- .../cfafa-form-action-redirect.php | 50 ++-- phpcs.xml | 6 +- 5 files changed, 268 insertions(+), 272 deletions(-) diff --git a/includes/form-actions/cfafa-form-action-base.php b/includes/form-actions/cfafa-form-action-base.php index f57dc4e..60df503 100644 --- a/includes/form-actions/cfafa-form-action-base.php +++ b/includes/form-actions/cfafa-form-action-base.php @@ -150,7 +150,7 @@ class CFAFA_Form_Action_Base { // Get some Form details. $form_name = acf_maybe_get( $form, 'name' ); - $form_id = acf_maybe_get( $form, 'ID' ); + $form_id = acf_maybe_get( $form, 'ID' ); // Assume we're good to go. $prepare = true; @@ -167,7 +167,7 @@ class CFAFA_Form_Action_Base { * @param integer $current_post_id The ID of the Post from which the Form has been submitted. * @param string $action The customised name of the Form Action. */ - $filter = 'acfe/form/prepare/' . $this->action_name; + $filter = 'acfe/form/prepare/' . $this->action_name; $prepare = apply_filters( $filter, $prepare, $form, $current_post_id, $action ); $prepare = apply_filters( $filter . '/form=' . $form_name, $prepare, $form, $current_post_id, $action ); if ( ! empty( $action ) ) { @@ -220,12 +220,12 @@ class CFAFA_Form_Action_Base { // Init our layout. $layout = [ - 'key' => 'layout_' . $this->action_name, - 'name' => $this->action_name, - 'label' => $this->action_label, + 'key' => 'layout_' . $this->action_name, + 'name' => $this->action_name, + 'label' => $this->action_label, 'display' => 'row', - 'min' => '', - 'max' => '', + 'min' => '', + 'max' => '', ]; // Build Action Tab. @@ -281,45 +281,45 @@ class CFAFA_Form_Action_Base { // "Action" Tab wrapper. $fields[] = [ - 'key' => $this->field_key . 'tab_action', - 'label' => __( 'Action', 'conditional-form-actions-for-acfe' ), - 'name' => '', - 'type' => 'tab', - 'instructions' => '', - 'required' => 0, + 'key' => $this->field_key . 'tab_action', + 'label' => __( 'Action', 'conditional-form-actions-for-acfe' ), + 'name' => '', + 'type' => 'tab', + 'instructions' => '', + 'required' => 0, 'conditional_logic' => 0, - 'wrapper' => [ - 'width' => '', - 'class' => '', - 'id' => '', + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', 'data-no-preference' => true, ], - 'acfe_permissions' => '', - 'placement' => 'top', - 'endpoint' => 0, + 'acfe_permissions' => '', + 'placement' => 'top', + 'endpoint' => 0, ]; // "Action name" Field. $fields[] = [ - 'key' => $this->field_key . 'custom_alias', - 'label' => __( 'Action name', 'conditional-form-actions-for-acfe' ), - 'name' => 'acfe_form_custom_alias', - 'type' => 'acfe_slug', - 'instructions' => __( '(Required) Name this action so it can be referenced.', 'conditional-form-actions-for-acfe' ), - 'required' => 1, + 'key' => $this->field_key . 'custom_alias', + 'label' => __( 'Action name', 'conditional-form-actions-for-acfe' ), + 'name' => 'acfe_form_custom_alias', + 'type' => 'acfe_slug', + 'instructions' => __( '(Required) Name this action so it can be referenced.', 'conditional-form-actions-for-acfe' ), + 'required' => 1, 'conditional_logic' => 0, - 'wrapper' => [ - 'width' => '', - 'class' => '', - 'id' => '', + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', 'data-instruction-placement' => 'field', ], - 'acfe_permissions' => '', - 'default_value' => '', - 'placeholder' => $this->alias_placeholder, - 'prepend' => '', - 'append' => '', - 'maxlength' => '', + 'acfe_permissions' => '', + 'default_value' => '', + 'placeholder' => $this->alias_placeholder, + 'prepend' => '', + 'append' => '', + 'maxlength' => '', ]; // Add any further Fields. @@ -378,22 +378,22 @@ class CFAFA_Form_Action_Base { // "Mapping" Tab wrapper. $mapping_tab = [ [ - 'key' => $this->field_key . 'tab_load', - 'label' => $label, - 'name' => '', - 'type' => 'tab', - 'instructions' => '', - 'required' => 0, + 'key' => $this->field_key . 'tab_load', + 'label' => $label, + 'name' => '', + 'type' => 'tab', + 'instructions' => '', + 'required' => 0, 'conditional_logic' => 0, - 'wrapper' => [ - 'width' => '', - 'class' => '', - 'id' => '', + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', 'data-no-preference' => true, ], - 'acfe_permissions' => '', - 'placement' => 'top', - 'endpoint' => 0, + 'acfe_permissions' => '', + 'placement' => 'top', + 'endpoint' => 0, ], ]; @@ -431,22 +431,22 @@ class CFAFA_Form_Action_Base { // "Attachments" Tab wrapper. $attachments_tab = [ [ - 'key' => $this->field_key . 'tab_attachments', - 'label' => __( 'Attachments', 'conditional-form-actions-for-acfe' ), - 'name' => '', - 'type' => 'tab', - 'instructions' => '', - 'required' => 0, + 'key' => $this->field_key . 'tab_attachments', + 'label' => __( 'Attachments', 'conditional-form-actions-for-acfe' ), + 'name' => '', + 'type' => 'tab', + 'instructions' => '', + 'required' => 0, 'conditional_logic' => 0, - 'wrapper' => [ - 'width' => '', - 'class' => '', - 'id' => '', + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', 'data-no-preference' => true, ], - 'acfe_permissions' => '', - 'placement' => 'top', - 'endpoint' => 0, + 'acfe_permissions' => '', + 'placement' => 'top', + 'endpoint' => 0, ], ]; @@ -474,28 +474,28 @@ class CFAFA_Form_Action_Base { // Build the Field array. $field = [ - 'key' => $this->field_key . 'map_' . $code, - 'label' => $label, - 'name' => $this->field_name . 'map_' . $code, - 'type' => 'select', - 'instructions' => '', - 'required' => 0, - 'wrapper' => [ + 'key' => $this->field_key . 'map_' . $code, + 'label' => $label, + 'name' => $this->field_name . 'map_' . $code, + 'type' => 'select', + 'instructions' => '', + 'required' => 0, + 'wrapper' => [ 'width' => '', 'class' => '', - 'id' => '', + 'id' => '', ], - 'acfe_permissions' => '', - 'choices' => [], - 'default_value' => [], - 'allow_null' => 1, - 'multiple' => 0, - 'ui' => 1, - 'return_format' => 'value', - 'placeholder' => __( 'Default', 'conditional-form-actions-for-acfe' ), - 'ajax' => 0, + 'acfe_permissions' => '', + 'choices' => [], + 'default_value' => [], + 'allow_null' => 1, + 'multiple' => 0, + 'ui' => 1, + 'return_format' => 'value', + 'placeholder' => __( 'Default', 'conditional-form-actions-for-acfe' ), + 'ajax' => 0, 'search_placeholder' => __( 'Enter a custom value or template tag. (See "Cheatsheet" tab)', 'conditional-form-actions-for-acfe' ), - 'allow_custom' => 1, + 'allow_custom' => 1, ]; // Default conditional logic. diff --git a/includes/form-actions/cfafa-form-action-email.php b/includes/form-actions/cfafa-form-action-email.php index 0200783..a159ea1 100644 --- a/includes/form-actions/cfafa-form-action-email.php +++ b/includes/form-actions/cfafa-form-action-email.php @@ -84,7 +84,7 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Store references to objects. $this->plugin = $parent->plugin; - $this->acfe = $parent; + $this->acfe = $parent; // Label this Form Action. $this->action_label = __( 'Conditional Email action', 'conditional-form-actions-for-acfe' ); @@ -106,15 +106,15 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Declare the mapped Email Fields with translatable titles. $this->mapped_email_fields = [ - 'from_name' => __( 'From Name', 'conditional-form-actions-for-acfe' ), - 'from_email' => __( 'From Email', 'conditional-form-actions-for-acfe' ), - 'reply_to_name' => __( 'Reply To Name', 'conditional-form-actions-for-acfe' ), + 'from_name' => __( 'From Name', 'conditional-form-actions-for-acfe' ), + 'from_email' => __( 'From Email', 'conditional-form-actions-for-acfe' ), + 'reply_to_name' => __( 'Reply To Name', 'conditional-form-actions-for-acfe' ), 'reply_to_email' => __( 'Reply To Email', 'conditional-form-actions-for-acfe' ), - 'to_name' => __( 'To Name', 'conditional-form-actions-for-acfe' ), - 'to_email' => __( 'To Email', 'conditional-form-actions-for-acfe' ), - 'cc' => __( 'Cc', 'conditional-form-actions-for-acfe' ), - 'bcc' => __( 'Bcc', 'conditional-form-actions-for-acfe' ), - 'subject' => __( 'Subject', 'conditional-form-actions-for-acfe' ), + 'to_name' => __( 'To Name', 'conditional-form-actions-for-acfe' ), + 'to_email' => __( 'To Email', 'conditional-form-actions-for-acfe' ), + 'cc' => __( 'Cc', 'conditional-form-actions-for-acfe' ), + 'bcc' => __( 'Bcc', 'conditional-form-actions-for-acfe' ), + 'subject' => __( 'Subject', 'conditional-form-actions-for-acfe' ), ]; // Populate mapping Fields. @@ -168,7 +168,7 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Get some Form details. $form_name = acf_maybe_get( $form, 'name' ); - $form_id = acf_maybe_get( $form, 'ID' ); + $form_id = acf_maybe_get( $form, 'ID' ); // Populate Email data array. $email = $this->form_email_data( $form, $current_post_id, $action ); @@ -212,12 +212,12 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { $fields = []; // Add Conditional Field. - $code = 'email_conditional'; - $label = __( 'Conditional On', 'conditional-form-actions-for-acfe' ); - $conditional = $this->mapping_field_get( $code, $label ); + $code = 'email_conditional'; + $label = __( 'Conditional On', 'conditional-form-actions-for-acfe' ); + $conditional = $this->mapping_field_get( $code, $label ); $conditional['placeholder'] = __( 'Always send', 'conditional-form-actions-for-acfe' ); $conditional['wrapper']['data-instruction-placement'] = 'field'; - $conditional['instructions'] = __( 'To send the Email only when a Form Field is populated (e.g. "First Name") link this to the Form Field. To send the Email only when more complex conditions are met, link this to a Hidden Field with value "1" where the conditional logic of that Field shows it when the conditions are met.', 'conditional-form-actions-for-acfe' ); + $conditional['instructions'] = __( 'To send the Email only when a Form Field is populated (e.g. "First Name") link this to the Form Field. To send the Email only when more complex conditions are met, link this to a Hidden Field with value "1" where the conditional logic of that Field shows it when the conditions are met.', 'conditional-form-actions-for-acfe' ); $fields[] = $conditional; // --< @@ -235,7 +235,7 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { public function tab_mapping_add() { // Get Tab Header. - $label = __( 'Email', 'conditional-form-actions-for-acfe' ); + $label = __( 'Email', 'conditional-form-actions-for-acfe' ); $mapping_tab_header = $this->tab_mapping_header( $label ); // Build Email Details Accordion. @@ -271,32 +271,32 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Add Content Field. $fields[] = [ - 'key' => $this->field_key . 'content', - 'label' => __( 'Content', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'content', - 'type' => 'wysiwyg', - 'instructions' => sprintf( + 'key' => $this->field_key . 'content', + 'label' => __( 'Content', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'content', + 'type' => 'wysiwyg', + 'instructions' => sprintf( /* translators: 1: Opening code tag, 2: Closing code tag, 3: Line break tag. */ __( 'Fields values may be included using %1$s{field:field_key}%2$s %1$s{field:title}%2$s. All fields may be included using %1$s{fields}%2$s.%3$sSee "Cheatsheet" tab for advanced usage.', 'conditional-form-actions-for-acfe' ), '<code>', '</code>', '<br />' ), - 'required' => 0, + 'required' => 0, 'conditional_logic' => 0, - 'wrapper' => [ - 'width' => '', - 'class' => '', - 'id' => '', + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', 'data-instruction-placement' => 'field', ], - 'acfe_permissions' => '', - 'default_value' => '', - 'tabs' => 'all', - 'toolbar' => 'full', - 'media_upload' => 1, - 'delay' => 0, - 'endpoint' => 1, + 'acfe_permissions' => '', + 'default_value' => '', + 'tabs' => 'all', + 'toolbar' => 'full', + 'media_upload' => 1, + 'delay' => 0, + 'endpoint' => 1, ]; // --< @@ -318,110 +318,110 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Add "Dynamic Files" Repeater. $attachments_tab[] = [ - 'key' => $this->field_key . 'files', - 'label' => __( 'Dynamic Files', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'files', - 'type' => 'repeater', - 'instructions' => '', - 'required' => 0, - 'conditional_logic' => 0, - 'wrapper' => [ + 'key' => $this->field_key . 'files', + 'label' => __( 'Dynamic Files', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'files', + 'type' => 'repeater', + 'instructions' => '', + 'required' => 0, + 'conditional_logic' => 0, + 'wrapper' => [ 'width' => '', 'class' => '', - 'id' => '', + 'id' => '', ], - 'acfe_permissions' => '', + 'acfe_permissions' => '', 'acfe_repeater_stylised_button' => 0, - 'collapsed' => '', - 'min' => 0, - 'max' => 0, - 'layout' => 'table', - 'button_label' => __( 'Add File', 'conditional-form-actions-for-acfe' ), - 'sub_fields' => [ + 'collapsed' => '', + 'min' => 0, + 'max' => 0, + 'layout' => 'table', + 'button_label' => __( 'Add File', 'conditional-form-actions-for-acfe' ), + 'sub_fields' => [ [ - 'key' => $this->field_key . 'file', - 'label' => __( 'File', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'file', - 'type' => 'select', - 'instructions' => '', - 'required' => 0, - 'conditional_logic' => 0, - 'wrapper' => [ + 'key' => $this->field_key . 'file', + 'label' => __( 'File', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'file', + 'type' => 'select', + 'instructions' => '', + 'required' => 0, + 'conditional_logic' => 0, + 'wrapper' => [ 'width' => '', 'class' => '', - 'id' => '', + 'id' => '', ], - 'acfe_permissions' => '', - 'choices' => [], - 'default_value' => [], - 'allow_null' => 0, - 'multiple' => 0, - 'ui' => 1, - 'return_format' => 'value', - 'ajax' => 0, - 'placeholder' => '', + 'acfe_permissions' => '', + 'choices' => [], + 'default_value' => [], + 'allow_null' => 0, + 'multiple' => 0, + 'ui' => 1, + 'return_format' => 'value', + 'ajax' => 0, + 'placeholder' => '', 'search_placeholder' => __( 'Enter a custom value or template tag. (See "Cheatsheet" tab)', 'conditional-form-actions-for-acfe' ), - 'allow_custom' => 1, + 'allow_custom' => 1, ], [ - 'key' => $this->field_key . 'file_delete', - 'label' => __( 'Delete File', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'file_delete', - 'type' => 'true_false', - 'instructions' => '', - 'required' => 0, - 'wrapper' => [ + 'key' => $this->field_key . 'file_delete', + 'label' => __( 'Delete File', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'file_delete', + 'type' => 'true_false', + 'instructions' => '', + 'required' => 0, + 'wrapper' => [ 'width' => '', 'class' => '', - 'id' => '', + 'id' => '', ], 'acfe_permissions' => '', - 'message' => __( 'Delete once submitted', 'conditional-form-actions-for-acfe' ), - 'default_value' => 0, - 'ui' => 1, - 'ui_on_text' => '', - 'ui_off_text' => '', + 'message' => __( 'Delete once submitted', 'conditional-form-actions-for-acfe' ), + 'default_value' => 0, + 'ui' => 1, + 'ui_on_text' => '', + 'ui_off_text' => '', ], ], ]; // Add "Static Files" Repeater. $attachments_tab[] = [ - 'key' => $this->field_key . 'files_static', - 'label' => __( 'Static Files', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'files_static', - 'type' => 'repeater', - 'instructions' => '', - 'required' => 0, - 'conditional_logic' => 0, - 'wrapper' => [ + 'key' => $this->field_key . 'files_static', + 'label' => __( 'Static Files', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'files_static', + 'type' => 'repeater', + 'instructions' => '', + 'required' => 0, + 'conditional_logic' => 0, + 'wrapper' => [ 'width' => '', 'class' => '', - 'id' => '', + 'id' => '', ], - 'acfe_permissions' => '', + 'acfe_permissions' => '', 'acfe_repeater_stylised_button' => 0, - 'collapsed' => '', - 'min' => 0, - 'max' => 0, - 'layout' => 'table', - 'button_label' => __( 'Add File', 'conditional-form-actions-for-acfe' ), - 'sub_fields' => [ + 'collapsed' => '', + 'min' => 0, + 'max' => 0, + 'layout' => 'table', + 'button_label' => __( 'Add File', 'conditional-form-actions-for-acfe' ), + 'sub_fields' => [ [ - 'key' => $this->field_key . 'file_static', - 'label' => __( 'File', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'file_static', - 'type' => 'file', - 'instructions' => '', - 'required' => 0, + 'key' => $this->field_key . 'file_static', + 'label' => __( 'File', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'file_static', + 'type' => 'file', + 'instructions' => '', + 'required' => 0, 'conditional_logic' => 0, - 'wrapper' => [ + 'wrapper' => [ 'width' => '', 'class' => '', - 'id' => '', + 'id' => '', ], - 'acfe_permissions' => '', - 'return_format' => 'id', + 'acfe_permissions' => '', + 'return_format' => 'id', ], ], ]; @@ -462,12 +462,12 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { $data = acfe_form_map_vs_fields( $fields, $fields, $current_post_id, $form ); // Add Email Content. - $content = get_sub_field( $this->field_key . 'content' ); + $content = get_sub_field( $this->field_key . 'content' ); $data['content'] = acfe_form_map_field_value( $content, $current_post_id, $form ); // Get Email Conditional Reference. $data['email_conditional_ref'] = get_sub_field( $this->field_key . 'map_email_conditional' ); - $conditionals = [ $data['email_conditional_ref'] ]; + $conditionals = [ $data['email_conditional_ref'] ]; // Populate array with mapped Conditional Field values. $conditionals = acfe_form_map_vs_fields( $conditionals, $conditionals, $current_post_id, $form ); @@ -495,7 +495,7 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Init return array. $data = [ 'attachments' => [], - 'delete' => [], + 'delete' => [], ]; // Process Dynamic Attachments. @@ -505,10 +505,10 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Find the ID of the File. $file_field_key = get_sub_field( $this->field_name . 'file' ); - $file_id = acfe_form_map_field_value( $file_field_key, $current_post_id, $form ); + $file_id = acfe_form_map_field_value( $file_field_key, $current_post_id, $form ); // Configure the File Field to return an array. - $field = acf_get_field( $file_field_key ); + $field = acf_get_field( $file_field_key ); $field['return_format'] = 'array'; // Build an array of data for the Dynamic Attachments. @@ -571,7 +571,7 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { public function form_build_args( $email_data, $attachments_data, $form, $current_post_id, $action ) { // Build "From" and "Reply To" params. - $from = $this->form_email_item_build( $email_data['from_name'], $email_data['from_email'] ); + $from = $this->form_email_item_build( $email_data['from_name'], $email_data['from_email'] ); $reply_to = $this->form_email_item_build( $email_data['reply_to_name'], $email_data['reply_to_email'] ); // Maybe use "From" when "Reply To" is empty. @@ -604,14 +604,14 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Finally, build args array. $args = [ - 'from' => $from, - 'to' => $to, - 'reply_to' => $reply_to, - 'cc' => $email_data['cc'], - 'bcc' => $email_data['bcc'], - 'subject' => $email_data['subject'], - 'content' => $email_data['content'], - 'headers' => $headers, + 'from' => $from, + 'to' => $to, + 'reply_to' => $reply_to, + 'cc' => $email_data['cc'], + 'bcc' => $email_data['bcc'], + 'subject' => $email_data['subject'], + 'content' => $email_data['content'], + 'headers' => $headers, 'attachments' => $attachments_data['attachments'], ]; @@ -631,8 +631,8 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { * @param string $action The customised name of the Form Action. */ $filter = 'acfe/form/submit/' . $this->action_name . '/email_args'; - $args = apply_filters( $filter, $args, $form, $current_post_id, $action ); - $args = apply_filters( $filter . '/form=' . $form_name, $args, $form, $current_post_id, $action ); + $args = apply_filters( $filter, $args, $form, $current_post_id, $action ); + $args = apply_filters( $filter . '/form=' . $form_name, $args, $form, $current_post_id, $action ); if ( ! empty( $action ) ) { $args = apply_filters( $filter . '/action=' . $action, $args, $form, $current_post_id, $action ); } @@ -682,23 +682,23 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base { // Define rules for checking Email headers. $rules = [ [ - 'args_key' => 'from', - 'value_old' => $this->form_email_item_build( $email_data['from_name'], $email_data['from_email'] ), + 'args_key' => 'from', + 'value_old' => $this->form_email_item_build( $email_data['from_name'], $email_data['from_email'] ), 'header_key' => 'From:', ], [ - 'args_key' => 'reply_to', - 'value_old' => $this->form_email_item_build( $email_data['reply_to_name'], $email_data['reply_to_email'] ), + 'args_key' => 'reply_to', + 'value_old' => $this->form_email_item_build( $email_data['reply_to_name'], $email_data['reply_to_email'] ), 'header_key' => 'Reply-To:', ], [ - 'args_key' => 'cc', - 'value_old' => $email_data['cc'], + 'args_key' => 'cc', + 'value_old' => $email_data['cc'], 'header_key' => 'Cc:', ], [ - 'args_key' => 'bcc', - 'value_old' => $email_data['bcc'], + 'args_key' => 'bcc', + 'value_old' => $email_data['bcc'], 'header_key' => 'Bcc:', ], ]; diff --git a/includes/form-actions/cfafa-form-action-product.php b/includes/form-actions/cfafa-form-action-product.php index 7d57cb3..8465662 100644 --- a/includes/form-actions/cfafa-form-action-product.php +++ b/includes/form-actions/cfafa-form-action-product.php @@ -75,7 +75,7 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base { // Store references to objects. $this->plugin = $parent->plugin; - $this->acfe = $parent; + $this->acfe = $parent; // Label this Form Action. $this->action_label = __( 'WooCommerce Product action', 'conditional-form-actions-for-acfe' ); @@ -118,7 +118,7 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base { // Get some Form details. $form_name = acf_maybe_get( $form, 'name' ); - $form_id = acf_maybe_get( $form, 'ID' ); + $form_id = acf_maybe_get( $form, 'ID' ); // Populate Product data array. $product_data = $this->form_product_data( $form, $current_post_id, $action ); @@ -144,38 +144,38 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base { $fields = []; $fields[] = [ - 'key' => $this->field_key . 'product_id', - 'label' => __( 'WooCommerce Product', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'product_id', - 'type' => 'select', - 'instructions' => __( 'Use this to add a WooCommerce Product to the Cart.', 'conditional-form-actions-for-acfe' ), - 'required' => 0, + 'key' => $this->field_key . 'product_id', + 'label' => __( 'WooCommerce Product', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'product_id', + 'type' => 'select', + 'instructions' => __( 'Use this to add a WooCommerce Product to the Cart.', 'conditional-form-actions-for-acfe' ), + 'required' => 0, 'conditional_logic' => 0, - 'wrapper' => [ - 'width' => '', - 'class' => '', - 'id' => '', + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', 'data-instruction-placement' => 'field', ], - 'acfe_permissions' => '', - 'default_value' => '', - 'placeholder' => '', - 'allow_null' => 1, - 'multiple' => 0, - 'ui' => 0, + 'acfe_permissions' => '', + 'default_value' => '', + 'placeholder' => '', + 'allow_null' => 1, + 'multiple' => 0, + 'ui' => 0, // 'ajax' => 1, // 'ajax_action' => 'cfafa_get_products', - 'return_format' => 'value', - 'choices' => $this->product_choices_get(), + 'return_format' => 'value', + 'choices' => $this->product_choices_get(), ]; // Add Conditional Field. - $code = 'product_conditional'; - $label = __( 'Conditional On', 'conditional-form-actions-for-acfe' ); - $conditional = $this->mapping_field_get( $code, $label ); + $code = 'product_conditional'; + $label = __( 'Conditional On', 'conditional-form-actions-for-acfe' ); + $conditional = $this->mapping_field_get( $code, $label ); $conditional['placeholder'] = __( 'Always add', 'conditional-form-actions-for-acfe' ); $conditional['wrapper']['data-instruction-placement'] = 'field'; - $conditional['instructions'] = __( 'To add the Product to the Cart only when a Form Field is populated (e.g. "First Name") link this to the Form Field. To add the Product to the Cart only when more complex conditions are met, link this to a Hidden Field with value "1" where the conditional logic of that Field shows it when the conditions are met.', 'conditional-form-actions-for-acfe' ); + $conditional['instructions'] = __( 'To add the Product to the Cart only when a Form Field is populated (e.g. "First Name") link this to the Form Field. To add the Product to the Cart only when more complex conditions are met, link this to a Hidden Field with value "1" where the conditional logic of that Field shows it when the conditions are met.', 'conditional-form-actions-for-acfe' ); $fields[] = $conditional; // --< @@ -200,7 +200,7 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base { // Get Product Conditional Reference. $data['product_conditional_ref'] = get_sub_field( $this->field_key . 'map_product_conditional' ); - $conditionals = [ $data['product_conditional_ref'] ]; + $conditionals = [ $data['product_conditional_ref'] ]; // Populate array with mapped Conditional Field values. $conditionals = acfe_form_map_vs_fields( $conditionals, $conditionals, $current_post_id, $form ); @@ -286,9 +286,9 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base { * This may need to be looked at again in future. */ $args = [ - 'post_type' => 'product', - 'post_status' => [ 'publish' ], - 'no_found_rows' => true, + 'post_type' => 'product', + 'post_status' => [ 'publish' ], + 'no_found_rows' => true, 'posts_per_page' => -1, ]; @@ -329,10 +329,10 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base { } // Some defaults. - $product_id = $product->get_id(); - $quantity = 1; - $variation_id = 0; - $variation = []; + $product_id = $product->get_id(); + $quantity = 1; + $variation_id = 0; + $variation = []; $cart_item_data = []; // Build Cart Item data? diff --git a/includes/form-actions/cfafa-form-action-redirect.php b/includes/form-actions/cfafa-form-action-redirect.php index 172c4b5..343c615 100644 --- a/includes/form-actions/cfafa-form-action-redirect.php +++ b/includes/form-actions/cfafa-form-action-redirect.php @@ -75,7 +75,7 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base { // Store references to objects. $this->plugin = $parent->plugin; - $this->acfe = $parent; + $this->acfe = $parent; // Label this Form Action. $this->action_label = __( 'Conditional Redirect action', 'conditional-form-actions-for-acfe' ); @@ -141,34 +141,34 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base { // Add URL Field. $fields[] = [ - 'key' => $this->field_key . 'redirect_url', - 'label' => __( 'Redirect URL', 'conditional-form-actions-for-acfe' ), - 'name' => $this->field_name . 'redirect_url', - 'type' => 'text', - 'instructions' => __( 'The URL to redirect to. See "Cheatsheet" tab for all available template tags.', 'conditional-form-actions-for-acfe' ), - 'required' => 0, + 'key' => $this->field_key . 'redirect_url', + 'label' => __( 'Redirect URL', 'conditional-form-actions-for-acfe' ), + 'name' => $this->field_name . 'redirect_url', + 'type' => 'text', + 'instructions' => __( 'The URL to redirect to. See "Cheatsheet" tab for all available template tags.', 'conditional-form-actions-for-acfe' ), + 'required' => 0, 'conditional_logic' => 0, - 'wrapper' => [ - 'width' => '', - 'class' => '', - 'id' => '', + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', 'data-instruction-placement' => 'field', ], - 'acfe_permissions' => '', - 'default_value' => '', - 'placeholder' => '', - 'prepend' => '', - 'append' => '', - 'maxlength' => '', + 'acfe_permissions' => '', + 'default_value' => '', + 'placeholder' => '', + 'prepend' => '', + 'append' => '', + 'maxlength' => '', ]; // Add Conditional Field. - $code = 'redirect_conditional'; - $label = __( 'Conditional On', 'conditional-form-actions-for-acfe' ); - $conditional = $this->mapping_field_get( $code, $label ); + $code = 'redirect_conditional'; + $label = __( 'Conditional On', 'conditional-form-actions-for-acfe' ); + $conditional = $this->mapping_field_get( $code, $label ); $conditional['placeholder'] = __( 'Always redirect', 'conditional-form-actions-for-acfe' ); $conditional['wrapper']['data-instruction-placement'] = 'field'; - $conditional['instructions'] = __( 'To redirect only when a Form Field is populated, link this to the Form Field. To redirect only when more complex conditions are met, link this to a Hidden Field with value "1" where the conditional logic of that Field shows it when the conditions are met.', 'conditional-form-actions-for-acfe' ); + $conditional['instructions'] = __( 'To redirect only when a Form Field is populated, link this to the Form Field. To redirect only when more complex conditions are met, link this to a Hidden Field with value "1" where the conditional logic of that Field shows it when the conditions are met.', 'conditional-form-actions-for-acfe' ); $fields[] = $conditional; // --< @@ -190,7 +190,7 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base { // Get some Form details. $form_name = acf_maybe_get( $form, 'name' ); - $form_id = acf_maybe_get( $form, 'ID' ); + $form_id = acf_maybe_get( $form, 'ID' ); // Init data array. $data = []; @@ -210,8 +210,8 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base { * @param string $action The customised name of the Form Action. */ $filter = 'acfe/form/submit/' . $this->action_name . '/url'; - $url = apply_filters( $filter, $url, $form, $current_post_id, $action ); - $url = apply_filters( $filter . '/form=' . $form_name, $url, $form, $current_post_id, $action ); + $url = apply_filters( $filter, $url, $form, $current_post_id, $action ); + $url = apply_filters( $filter . '/form=' . $form_name, $url, $form, $current_post_id, $action ); if ( ! empty( $action ) ) { $url = apply_filters( $filter . '/action=' . $action, $url, $form, $current_post_id, $action ); } @@ -221,7 +221,7 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base { // Get Redirect Conditional Reference. $data['redirect_conditional_ref'] = get_sub_field( $this->field_key . 'map_redirect_conditional' ); - $conditionals = [ $data['redirect_conditional_ref'] ]; + $conditionals = [ $data['redirect_conditional_ref'] ]; // Populate array with mapped Conditional Field values. $conditionals = acfe_form_map_vs_fields( $conditionals, $conditionals, $current_post_id, $form ); diff --git a/phpcs.xml b/phpcs.xml index 11871e7..801b2d5 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -11,13 +11,9 @@ <rule ref="WordPress"> - <!-- Allow slash-delimited Hooks. --> + <!-- Allow slash-delimited hooks. --> <exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores" /> - <!-- Not a fan of arrow or equals alignment --> - <exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" /> - <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" /> - <!-- PSR4: Allow short file names. --> <exclude name="WordPress.Files.FileName.InvalidClassFileName" /> -- GitLab