<?php /** * ACF Extended Class. * * Handles general "ACF Extended" functionality. * * @package Conditional_Form_Actions_For_ACFE */ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; /** * "ACF Extended" Class. * * A class that encapsulates ACF Extended functionality. * * @since 0.1 */ class CFAFA_ACFE { /** * Plugin object. * * @since 0.1 * @access public * @var object $plugin The plugin object. */ public $plugin; /** * Constructor. * * @since 0.1 * * @param object $plugin The plugin object. */ public function __construct( $plugin ) { // Store references to objects. $this->plugin = $plugin; // Init when ACF class is loaded. add_action( 'cfafa/loaded', [ $this, 'initialise' ] ); } /** * Initialise this object. * * @since 0.1 */ public function initialise() { // Only do this once. static $done; if ( isset( $done ) && true === $done ) { return; } // Register hooks. $this->register_hooks(); /** * Broadcast that this class is now loaded. * * @since 0.1 */ do_action( 'cfafa/acfe/loaded' ); // We're done and loaded. $done = true; } /** * Register hooks. * * @since 0.1 */ public function register_hooks() { // Register ACFE Form Actions. add_filter( 'acfe/include_form_actions', [ $this, 'register_form_actions' ], 50 ); /* // Clear Form Action Query Vars. add_action( 'acfe/form/submit', [ $this, 'form_action_query_vars_clear' ] ); */ } /** * Clear the Form Action Query Vars. * * This means we get a fresh set of Query Vars during the load process after * a Form has been submitted. * * @since 0.1 */ public function form_action_query_vars_clear() { // Clear the array of Action results. set_query_var( 'acfe_form_actions', [] ); } /** * Register Form Actions. * * @since 0.1 */ public function register_form_actions() { // Include class files. 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-email.php'; // Instantiate the Form Actions. new CFAFA_Form_Action_Redirect( $this ); new CFAFA_Form_Action_Email( $this ); // Maybe add WooCommerce Product Action. if ( function_exists( 'WC' ) ) { include CFAFA_PATH . 'includes/form-actions/cfafa-form-action-product.php'; new CFAFA_Form_Action_Product( $this ); } } }