Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* ACF Extended Class.
*
* Handles general "ACF Extended" functionality.
*
* @package Conditional_Form_Actions_For_ACFE
* @since 0.1
*/
// 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 ) && $done === true ) {
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 );
// Add Form Actions Javascript.
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 );
}
}
} // Class ends.