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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?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
--------------------------------------------------------------------------------
*/
// Set plugin version here.
define( 'CFAFA_VERSION', '0.1' );
// Store reference to this file.
if ( ! defined( 'CFAFA_FILE' ) ) {
define( 'CFAFA_FILE', __FILE__ );
}
// Store URL to this plugin's directory.
if ( ! defined( 'CFAFA_URL' ) ) {
define( 'CFAFA_URL', plugin_dir_url( CFAFA_FILE ) );
}
// Store PATH to this plugin's directory.
if ( ! defined( 'CFAFA_PATH' ) ) {
define( 'CFAFA_PATH', plugin_dir_path( CFAFA_FILE ) );
}
/**
* Conditional Form Actions for ACFE Class.
*
* A class that encapsulates this plugin's functionality.
*
* @since 0.1
*/
class Conditional_Form_Actions_For_ACFE {
/**
* ACF Extended object.
*
* @since 0.1
* @access public
* @var object $acfe The ACF Extended object.
*/
public $acfe;
/**
* Initialises this object.
*
* @since 0.1
*/
public function __construct() {
// Always load translations.
add_action( 'plugins_loaded', [ $this, 'translation' ] );
// Initialise when ACF Extended is initialised.
add_action( 'acfe/init', [ $this, 'initialise' ] );
}
/**
* Initialise this plugin.
*
* @since 0.1
*/
public function initialise() {
// Only do this once.
static $done;
if ( isset( $done ) && $done === true ) {
return;
}
// Include files.
$this->include_files();
// Set up objects and references.
$this->setup_objects();
/**
* Broadcast that this plugin is loaded.
*
* @since 0.1
*/
do_action( 'cfafa/loaded' );
// We're done.
$done = true;
}
/**
* Enable translation.
*
* @since 0.1
*/
public function translation() {
// Load translations.
load_plugin_textdomain(
'conditional-form-actions-for-acfe', // Unique name.
false, // Deprecated argument.
dirname( plugin_basename( CFAFA_FILE ) ) . '/languages/' // Relative path to files.
);
}
/**
* Include files.
*
* @since 0.1
*/
public function include_files() {
// Load our class files.
require CFAFA_PATH . 'includes/cfafa-acfe.php';
}
/**
* Set up this plugin's objects.
*
* @since 0.1
*/
public function setup_objects() {
// Initialise objects.
$this->acfe = new CFAFA_ACFE( $this );
}
/**
* Check if this plugin is network activated.
*
* @since 0.1
*
* @return bool $is_network_active True if network activated, false otherwise.
*/
public function is_network_activated() {
// Only need to test once.
static $is_network_active;
// Have we done this already?
if ( isset( $is_network_active ) ) {
return $is_network_active;
}
// If not multisite, it cannot be.
if ( ! is_multisite() ) {
$is_network_active = false;
return $is_network_active;
}
// Make sure plugin file is included when outside admin.
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
// Get path from 'plugins' directory to this plugin.
$this_plugin = plugin_basename( CFAFA_FILE );
// Test if network active.
$is_network_active = is_plugin_active_for_network( $this_plugin );
// --<
return $is_network_active;
}
} // Class ends.
/**
* Load plugin if not yet loaded and return reference.
*
* @since 0.1
*
* @return Conditional_Form_Actions_For_ACFE $plugin The plugin reference.
*/
function cfafa() {
// Declare as global.
static $plugin;
// Instantiate plugin if not yet instantiated.
if ( ! isset( $plugin ) ) {
$plugin = new Conditional_Form_Actions_For_ACFE();
}
// --<
return $plugin;
}
// Load immediately.
cfafa();
/**
* Performs plugin activation tasks.
*
* @since 0.1
*/
function cfafa_activate() {
/**
* Broadcast that this plugin has been activated.
*
* @since 0.1
*/
do_action( 'cfafa/activated' );
}
// Activation.
register_activation_hook( __FILE__, 'cfafa_activate' );
/**
* Performs plugin deactivation tasks.
*
* @since 0.1
*/
function cfafa_deactivated() {
/**
* Broadcast that this plugin has been deactivated.
*
* @since 0.1
*/
do_action( '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