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

Add PHP CodeSniffer and clean up

parent 54c4810e
No related branches found
No related tags found
No related merge requests found
<?php /*
--------------------------------------------------------------------------------
Plugin Name: Conditional Form Actions for ACFE
Plugin URI: https://develop.tadpole.cc/plugins/conditional-form-actions-for-acfe
Description: Provides some ACF Extended Form Actions that have a Conditional Field.
Author: Christian Wach
Version: 0.1
Author URI: https://haystack.co.uk
Text Domain: conditional-form-actions-for-acfe
Domain Path: /languages
--------------------------------------------------------------------------------
*/
<?php
/**
* -----------------------------------------------------------------------------
* Plugin Name: Conditional Form Actions for ACFE
* Plugin URI: https://develop.tadpole.cc/plugins/conditional-form-actions-for-acfe
* Description: Provides some ACF Extended Form Actions that have a Conditional Field.
* Author: Christian Wach
* Version: 0.1
* Author URI: https://haystack.co.uk
* Text Domain: conditional-form-actions-for-acfe
* Domain Path: /languages
* -----------------------------------------------------------------------------
*
* @package Conditional_Form_Actions_For_ACFE
*/
// Set plugin version here.
define( 'CFAFA_VERSION', '0.1' );
......@@ -55,7 +58,7 @@ class Conditional_Form_Actions_For_ACFE {
public function __construct() {
// Always load translations.
add_action( 'plugins_loaded', [ $this, 'translation' ] );
add_action( 'init', [ $this, 'translation' ] );
// Initialise when ACF Extended is initialised.
add_action( 'acfe/init', [ $this, 'initialise' ] );
......@@ -102,9 +105,9 @@ class Conditional_Form_Actions_For_ACFE {
// Load translations.
load_plugin_textdomain(
'conditional-form-actions-for-acfe', // Unique name.
'conditional-form-actions-for-acfe',
false, // Deprecated argument.
dirname( plugin_basename( CFAFA_FILE ) ) . '/languages/' // Relative path to files.
dirname( plugin_basename( CFAFA_FILE ) ) . '/languages/'
);
}
......@@ -144,7 +147,6 @@ class Conditional_Form_Actions_For_ACFE {
*/
function cfafa() {
// Declare as global.
static $plugin;
// Instantiate plugin if not yet instantiated.
......@@ -198,5 +200,7 @@ function cfafa_deactivated() {
// Deactivation.
register_deactivation_hook( __FILE__, 'cfafa_deactivated' );
// Uninstall uses the 'uninstall.php' method.
// See: http://codex.wordpress.org/Function_Reference/register_uninstall_hook
/*
* Uninstall uses the 'uninstall.php' method.
* @see http://codex.wordpress.org/Function_Reference/register_uninstall_hook
*/
......@@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit;
* CiviCRM Profile Sync "Base" ACFE Form Action Class.
*
* A class that is extended by CiviCRM Profile Sync ACFE Form Action classes.
* *
*
* @since 0.1
*/
class CFAFA_Form_Action_Base {
......@@ -95,9 +95,9 @@ class CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @param integer $current_post_id The ID of the Post in which the Form has been embedded.
* @param string $action The customised name of the action.
* @param string $action The customised name of the action.
*/
public function load( $form, $current_post_id, $action ) {
return $form;
......@@ -109,7 +109,7 @@ class CFAFA_Form_Action_Base {
* @since 0.1
*
* @param string $action The name of the Action.
* @param array $data The result of the Action.
* @param array $data The result of the Action.
*/
public function load_action_save( $action = '', $data ) {
......@@ -131,9 +131,9 @@ class CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
*/
public function make( $form, $current_post_id, $action ) {}
......@@ -142,9 +142,9 @@ class CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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.
* @param string $action The customised name of the Form Action.
* @return bool $prepare The net result of the set of filters.
*/
public function make_skip( $form, $current_post_id, $action ) {
......@@ -186,7 +186,7 @@ class CFAFA_Form_Action_Base {
* @since 0.1
*
* @param string $action The name of the Action.
* @param array $data The result of the Action.
* @param array $data The result of the Action.
*/
public function make_action_save( $action = '', $data ) {
......@@ -255,7 +255,7 @@ class CFAFA_Form_Action_Base {
$layout['sub_fields'] = apply_filters( 'cfafa/acfe/form/actions/sub_fields', $sub_fields );
// Add our completed layout to the layouts array.
$layouts['layout_' . $this->action_name] = $layout;
$layouts[ 'layout_' . $this->action_name ] = $layout;
// --<
return $layouts;
......@@ -377,24 +377,26 @@ class CFAFA_Form_Action_Base {
}
// "Mapping" Tab wrapper.
$mapping_tab = [ [
'key' => $this->field_key . 'tab_load',
'label' => $label,
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
'data-no-preference' => true,
$mapping_tab = [
[
'key' => $this->field_key . 'tab_load',
'label' => $label,
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
'data-no-preference' => true,
],
'acfe_permissions' => '',
'placement' => 'top',
'endpoint' => 0,
],
'acfe_permissions' => '',
'placement' => 'top',
'endpoint' => 0,
] ];
];
// Combine Fields.
$fields = array_merge(
......@@ -428,24 +430,26 @@ class CFAFA_Form_Action_Base {
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,
$attachments_tab = [
[
'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' => '',
'data-no-preference' => true,
],
'acfe_permissions' => '',
'placement' => 'top',
'endpoint' => 0,
],
'acfe_permissions' => '',
'placement' => 'top',
'endpoint' => 0,
] ];
];
// Combine Fields.
$fields = array_merge(
......@@ -464,7 +468,7 @@ class CFAFA_Form_Action_Base {
*
* @param string $code The unique code for the Field.
* @param string $label The label for the Field.
* @param array $conditional_logic The conditional logic for the Field.
* @param array $conditional_logic The conditional logic for the Field.
* @return array $field The array of Field data.
*/
public function mapping_field_get( $code, $label, $conditional_logic = [] ) {
......
......@@ -127,9 +127,9 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
*/
public function validation( $form, $current_post_id, $action ) {
......@@ -147,9 +147,9 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
*/
public function make( $form, $current_post_id, $action ) {
......@@ -184,7 +184,6 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
$this->form_attachments_delete( $attachments );
}
}
// Save the results of this Action for later use.
......@@ -280,7 +279,7 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
'width' => '',
'class' => '',
'id' => '',
'data-instruction-placement' => 'field'
'data-instruction-placement' => 'field',
],
'acfe_permissions' => '',
'default_value' => '',
......@@ -437,9 +436,9 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
* @return array $data The array of Email data.
*/
public function form_email_data( $form, $current_post_id, $action ) {
......@@ -477,9 +476,9 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
* @return array $data The array of Attachment data.
*/
public function form_attachments_data( $form, $current_post_id, $action ) {
......@@ -525,9 +524,7 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
if ( $file_delete ) {
$data['delete'][] = $file['ID'];
}
}
}
}
......@@ -555,11 +552,11 @@ class CFAFA_Form_Action_Email extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $email_data The array of Email data.
* @param array $attachments_data The array of Attachments data.
* @param array $form The array of Form data.
* @param array $email_data The array of Email data.
* @param array $attachments_data The array of Attachments data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
* @return array|bool $args The arguments array, or false on failure.
*/
public function form_build_args( $email_data, $attachments_data, $form, $current_post_id, $action ) {
......
......@@ -106,9 +106,9 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
*/
public function make( $form, $current_post_id, $action ) {
......@@ -164,8 +164,8 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base {
'allow_null' => 1,
'multiple' => 0,
'ui' => 0,
//'ajax' => 1,
//'ajax_action' => 'cfafa_get_products',
// 'ajax' => 1,
// 'ajax_action' => 'cfafa_get_products',
'return_format' => 'value',
'choices' => $this->product_choices_get(),
];
......@@ -189,9 +189,9 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
* @return array $data The array of Product data.
*/
public function form_product_data( $form, $current_post_id, $action ) {
......@@ -338,11 +338,11 @@ class CFAFA_Form_Action_Product extends CFAFA_Form_Action_Base {
// Build Cart Item data?
// Add the configured Product to the Cart.
$cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data );
// Add the configured Product to the Cart.
$cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data );
// --<
return $cart_item_key;
// --<
return $cart_item_key;
}
......
......@@ -106,9 +106,9 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
*/
public function make( $form, $current_post_id, $action ) {
......@@ -153,7 +153,7 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base {
'width' => '',
'class' => '',
'id' => '',
'data-instruction-placement' => 'field'
'data-instruction-placement' => 'field',
],
'acfe_permissions' => '',
'default_value' => '',
......@@ -182,9 +182,9 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base {
*
* @since 0.1
*
* @param array $form The array of Form data.
* @param array $form The array of Form data.
* @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 action.
* @param string $action The customised name of the action.
* @return array $data The array of Redirect data.
*/
public function form_redirect_data( $form, $current_post_id, $action ) {
......
<?xml version="1.0"?>
<ruleset name="CMW.WordPress">
<!-- Add source codes in the report -->
<arg value="s"/>
<arg name="colors"/>
<!-- Check all PHP files in directory tree by default. -->
<arg name="extensions" value="php"/>
<file>.</file>
<rule ref="WordPress">
<!-- I prefer slash-delimited Hooks -->
<exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores" />
<!-- Yoda? Really? -->
<exclude name="WordPress.PHP.YodaConditions.NotYoda" />
<!-- Not a fan of arrow or equals alignment -->
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
<!-- PSR4 -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="conditional-form-actions-for-acfe" />
</properties>
</rule>
<!-- Allow short array syntax -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
<severity>0</severity>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>
<!-- Nesting levels -->
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="absoluteNestingLevel" value="1"/>
</properties>
</rule>
<!--
<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
-->
</ruleset>
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