1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* The main plugin class |
4
|
|
|
* |
5
|
|
|
* @class Object_Sync_Salesforce |
6
|
|
|
* @package Object_Sync_Salesforce |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
defined( 'ABSPATH' ) || exit; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Object_Sync_Salesforce class. |
13
|
|
|
*/ |
14
|
|
|
class Object_Sync_Salesforce { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Current version of the plugin |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
public $version; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The main plugin file |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
public $file; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Global object of `$wpdb`, the WordPress database |
32
|
|
|
* |
33
|
|
|
* @var object |
34
|
|
|
*/ |
35
|
|
|
public $wpdb; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The plugin's slug so we can include it when necessary |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $slug; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The plugin's prefix when saving options to the database |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
public $option_prefix; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Login credentials for the Salesforce API; comes from wp-config or from the plugin settings |
53
|
|
|
* |
54
|
|
|
* @var array |
55
|
|
|
*/ |
56
|
|
|
public $login_credentials; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Array of what classes in the plugin can be scheduled to occur with `wp_cron` events |
60
|
|
|
* |
61
|
|
|
* @var array |
62
|
|
|
*/ |
63
|
|
|
public $schedulable_classes; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Array of what classes in the plugin can be scheduled to occur with `wp_cron` events |
67
|
|
|
* |
68
|
|
|
* @var array |
69
|
|
|
*/ |
70
|
|
|
public $queue; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Tells us if composer has been autoloaded |
74
|
|
|
* |
75
|
|
|
* @var bool |
76
|
|
|
*/ |
77
|
|
|
private $composer_loaded; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Object_Sync_Sf_Activate class |
81
|
|
|
* |
82
|
|
|
* @var object |
83
|
|
|
*/ |
84
|
|
|
private $activated; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Object_Sync_Sf_Logging class |
88
|
|
|
* |
89
|
|
|
* @var object |
90
|
|
|
*/ |
91
|
|
|
public $logging; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Object_Sync_Sf_Mapping class |
95
|
|
|
* |
96
|
|
|
* @var object |
97
|
|
|
*/ |
98
|
|
|
public $mappings; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Object_Sync_Sf_WordPress class |
102
|
|
|
* |
103
|
|
|
* @var object |
104
|
|
|
*/ |
105
|
|
|
public $wordpress; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Object_Sync_Sf_Salesforce class |
109
|
|
|
* This contains Salesforce API methods |
110
|
|
|
* |
111
|
|
|
* @var array |
112
|
|
|
*/ |
113
|
|
|
public $salesforce; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Object_Sync_Sf_Salesforce_Push class |
117
|
|
|
* |
118
|
|
|
* @var object |
119
|
|
|
*/ |
120
|
|
|
public $push; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Object_Sync_Sf_Salesforce_Pull class |
124
|
|
|
* |
125
|
|
|
* @var object |
126
|
|
|
*/ |
127
|
|
|
public $pull; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Object_Sync_Sf_Rest class |
131
|
|
|
* |
132
|
|
|
* @var object |
133
|
|
|
*/ |
134
|
|
|
private $rest; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Legacy property that holds an instance of the plugin class. |
138
|
|
|
* |
139
|
|
|
* @var object |
140
|
|
|
* @deprecated since 2.0.0 |
141
|
|
|
*/ |
142
|
|
|
public static $instance; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* This is our constructor |
146
|
|
|
* |
147
|
|
|
* @param string $version is the plugin version. |
148
|
|
|
* @param string $file is the main plugin file. |
149
|
|
|
* @return void |
150
|
|
|
*/ |
151
|
|
|
public function __construct( $version, $file ) { |
152
|
|
|
|
153
|
|
|
global $wpdb; |
154
|
|
|
|
155
|
|
|
$this->version = $version; |
156
|
|
|
$this->file = $file; |
157
|
|
|
$this->wpdb = $wpdb; |
158
|
|
|
$this->slug = 'object-sync-for-salesforce'; |
159
|
|
|
$this->option_prefix = 'object_sync_for_salesforce_'; |
160
|
|
|
|
161
|
|
|
$this->schedulable_classes = array( |
162
|
|
|
'salesforce_push' => array( |
163
|
|
|
'label' => 'Push to Salesforce', |
164
|
|
|
'class' => 'Object_Sync_Sf_Salesforce_Push', |
165
|
|
|
'callback' => $this->option_prefix . 'push_record', |
166
|
|
|
), |
167
|
|
|
'salesforce_pull' => array( |
168
|
|
|
'label' => 'Pull from Salesforce', |
169
|
|
|
'class' => 'Object_Sync_Sf_Salesforce_Pull', |
170
|
|
|
'initializer' => $this->option_prefix . 'pull_check_records', |
171
|
|
|
'callback' => $this->option_prefix . 'pull_process_records', |
172
|
|
|
), |
173
|
|
|
); |
174
|
|
|
|
175
|
|
|
// users can modify the list of schedulable classes. |
176
|
|
|
$this->schedulable_classes = apply_filters( $this->option_prefix . 'modify_schedulable_classes', $this->schedulable_classes ); |
177
|
|
|
|
178
|
|
|
/* // phpcs:ignore Squiz.PHP.CommentedOutCode.Found |
179
|
|
|
* example to modify the array of classes by adding one and removing one |
180
|
|
|
* add_filter( 'object_sync_for_salesforce_modify_schedulable_classes', 'modify_schedulable_classes', 10, 1 ); |
181
|
|
|
* function modify_schedulable_classes( $schedulable_classes ) { |
182
|
|
|
* $schedulable_classes = array( |
183
|
|
|
* 'salesforce_push' => array( |
184
|
|
|
* 'label' => 'Push to Salesforce', |
185
|
|
|
* 'class' => 'Object_Sync_Sf_Salesforce_Push', |
186
|
|
|
* 'callback' => 'salesforce_push_sync_rest', |
187
|
|
|
* ), |
188
|
|
|
* 'wordpress' => array( // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled |
189
|
|
|
* 'label' => 'WordPress', |
190
|
|
|
* 'class' => 'Object_Sync_Sf_WordPress', |
191
|
|
|
* ), |
192
|
|
|
* 'salesforce' => array( |
193
|
|
|
* 'label' => 'Salesforce Authorization', |
194
|
|
|
* 'class' => 'Object_Sync_Sf_Salesforce', |
195
|
|
|
* ), |
196
|
|
|
* ); |
197
|
|
|
* return $schedulable_classes; |
198
|
|
|
* } |
199
|
|
|
*/ |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Load the static $instance property that holds the instance of the class. |
204
|
|
|
* This is preserved for legacy usage, as the same thing exists in the `object_sync_for_salesforce` function. |
205
|
|
|
* |
206
|
|
|
* @return object $plugin |
207
|
|
|
* @deprecated since 2.0.0 |
208
|
|
|
*/ |
209
|
|
|
public static function get_instance() { |
210
|
|
|
|
211
|
|
|
if ( function_exists( 'object_sync_for_salesforce' ) ) { |
212
|
|
|
return object_sync_for_salesforce(); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
static $plugin; |
216
|
|
|
|
217
|
|
|
if ( is_null( $plugin ) ) { |
218
|
|
|
$plugin = new Object_Sync_Salesforce( OBJECT_SYNC_SALESFORCE_VERSION, OBJECT_SYNC_SALESFORCE_FILE ); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
return $plugin; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Initialize the plugin and start the action hooks. |
226
|
|
|
* We run this separately because activate can't run without the right priority. |
227
|
|
|
*/ |
228
|
|
|
public function init() { |
229
|
|
|
$this->activated = $this->activate( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->schedulable_classes, $this->queue ); |
|
|
|
|
230
|
|
|
$this->add_actions(); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* What to do upon activation of the plugin |
235
|
|
|
* |
236
|
|
|
* @return object $activate |
237
|
|
|
*/ |
238
|
|
|
private function activate() { |
239
|
|
|
$activate = new Object_Sync_Sf_Activate( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->schedulable_classes, $this->queue ); |
|
|
|
|
240
|
|
|
return $activate; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Run non-activation actions. |
245
|
|
|
* We do this on -10 because ActionScheduler has to have access to plugins_loaded with priority of zero. |
246
|
|
|
*/ |
247
|
|
|
private function add_actions() { |
248
|
|
|
// public actions. |
249
|
|
|
add_action( 'plugins_loaded', array( $this, 'run' ), -10 ); |
250
|
|
|
add_action( 'plugins_loaded', array( $this, 'textdomain' ) ); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Run the plugin, independent of activation methods. |
255
|
|
|
*/ |
256
|
|
|
public function run() { |
257
|
|
|
|
258
|
|
|
$this->composer_loaded = $this->composer_loaded(); |
259
|
|
|
|
260
|
|
|
$this->login_credentials = $this->get_login_credentials(); |
261
|
|
|
|
262
|
|
|
$this->deactivate( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->schedulable_classes, $this->queue ); |
|
|
|
|
263
|
|
|
|
264
|
|
|
$this->logging = $this->logging( $this->wpdb, $this->version, $this->slug, $this->option_prefix ); |
|
|
|
|
265
|
|
|
|
266
|
|
|
$this->queue = $this->queue( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->schedulable_classes ); |
|
|
|
|
267
|
|
|
|
268
|
|
|
$this->mappings = $this->mappings( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->logging ); |
|
|
|
|
269
|
|
|
|
270
|
|
|
$this->wordpress = $this->wordpress( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->mappings, $this->logging ); |
|
|
|
|
271
|
|
|
$this->salesforce = $this->salesforce_get_api(); |
272
|
|
|
|
273
|
|
|
$this->push = $this->push( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->option_prefix, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue ); |
|
|
|
|
274
|
|
|
|
275
|
|
|
$this->pull = $this->pull( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->option_prefix, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue ); |
|
|
|
|
276
|
|
|
|
277
|
|
|
$this->rest = $this->rest( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->wordpress, $this->salesforce, $this->mappings, $this->push, $this->pull ); |
|
|
|
|
278
|
|
|
|
279
|
|
|
new Object_Sync_Sf_Admin(); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Autoload things from Composer. |
284
|
|
|
* |
285
|
|
|
* @return bool true |
286
|
|
|
*/ |
287
|
|
|
private function composer_loaded() { |
288
|
|
|
require_once plugin_dir_path( $this->file ) . 'vendor/autoload.php'; |
289
|
|
|
return true; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* Get the pre-login Salesforce credentials. |
294
|
|
|
* These depend on the plugin's settings or constants defined in wp-config.php. |
295
|
|
|
* |
296
|
|
|
* @return array $login_credentials |
297
|
|
|
*/ |
298
|
|
|
private function get_login_credentials() { |
299
|
|
|
|
300
|
|
|
$consumer_key = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( $this->option_prefix . 'consumer_key', '' ); |
|
|
|
|
301
|
|
|
$consumer_secret = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option( $this->option_prefix . 'consumer_secret', '' ); |
|
|
|
|
302
|
|
|
$callback_url = defined( 'OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option( $this->option_prefix . 'callback_url', '' ); |
|
|
|
|
303
|
|
|
$login_base_url = defined( 'OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL : get_option( $this->option_prefix . 'login_base_url', '' ); |
|
|
|
|
304
|
|
|
$authorize_url_path = defined( 'OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH' ) ? OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH : get_option( $this->option_prefix . 'authorize_url_path', '' ); |
|
|
|
|
305
|
|
|
$token_url_path = defined( 'OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH' ) ? OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH : get_option( $this->option_prefix . 'token_url_path', '' ); |
|
|
|
|
306
|
|
|
$api_version = defined( 'OBJECT_SYNC_SF_SALESFORCE_API_VERSION' ) ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option( $this->option_prefix . 'api_version', '' ); |
|
|
|
|
307
|
|
|
|
308
|
|
|
$login_credentials = array( |
309
|
|
|
'consumer_key' => $consumer_key, |
310
|
|
|
'consumer_secret' => $consumer_secret, |
311
|
|
|
'callback_url' => $callback_url, |
312
|
|
|
'login_url' => $login_base_url, |
313
|
|
|
'authorize_path' => $authorize_url_path, |
314
|
|
|
'token_path' => $token_url_path, |
315
|
|
|
'rest_api_version' => $api_version, |
316
|
|
|
); |
317
|
|
|
|
318
|
|
|
return $login_credentials; |
319
|
|
|
|
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* What to do upon deactivation of the plugin |
324
|
|
|
*/ |
325
|
|
|
private function deactivate() { |
326
|
|
|
$deactivate = new Object_Sync_Sf_Deactivate( $this->wpdb, $this->version, $this->slug, $this->schedulable_classes, $this->option_prefix, $this->queue ); |
|
|
|
|
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* Log plugin events |
331
|
|
|
* |
332
|
|
|
* @return object $logging |
333
|
|
|
*/ |
334
|
|
|
private function logging() { |
335
|
|
|
$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version, $this->slug, $this->option_prefix ); |
336
|
|
|
return $logging; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* Get queue instance |
341
|
|
|
* |
342
|
|
|
* @return object $queue |
343
|
|
|
*/ |
344
|
|
|
public function queue() { |
345
|
|
|
$queue = new Object_Sync_Sf_Queue( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->schedulable_classes ); |
346
|
|
|
return $queue; |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* Map the Salesforce and WordPress objects and fields to each other |
351
|
|
|
* |
352
|
|
|
* @return object $mappings |
353
|
|
|
*/ |
354
|
|
|
public function mappings() { |
355
|
|
|
$mappings = new Object_Sync_Sf_Mapping( $this->wpdb, $this->version, $this->slug, $this->logging, $this->option_prefix ); |
356
|
|
|
return $mappings; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* Load methods for manipulating core WordPress data across the plugin |
361
|
|
|
* |
362
|
|
|
* @return object $wordpress |
363
|
|
|
*/ |
364
|
|
|
public function wordpress() { |
365
|
|
|
$wordpress = new Object_Sync_Sf_WordPress( $this->wpdb, $this->version, $this->slug, $this->mappings, $this->logging, $this->option_prefix ); |
366
|
|
|
return $wordpress; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Public helper to load the Salesforce API and see if it is authenticated. |
371
|
|
|
* This is public so other plugins can access the same SF API instance we use. |
372
|
|
|
* |
373
|
|
|
* @return array |
374
|
|
|
*/ |
375
|
|
|
public function salesforce_get_api() { |
376
|
|
|
|
377
|
|
|
$soap_available = $this->is_soap_available(); |
378
|
|
|
$soap_loaded = $this->is_soap_loaded(); |
379
|
|
|
|
380
|
|
|
$consumer_key = $this->login_credentials['consumer_key']; |
381
|
|
|
$consumer_secret = $this->login_credentials['consumer_secret']; |
382
|
|
|
$login_url = $this->login_credentials['login_url']; |
383
|
|
|
$callback_url = $this->login_credentials['callback_url']; |
384
|
|
|
$authorize_path = $this->login_credentials['authorize_path']; |
385
|
|
|
$token_path = $this->login_credentials['token_path']; |
386
|
|
|
$rest_api_version = $this->login_credentials['rest_api_version']; |
387
|
|
|
$slug = $this->slug; |
388
|
|
|
$option_prefix = $this->option_prefix; |
389
|
|
|
$wordpress = $this->wordpress; |
390
|
|
|
$logging = $this->logging; |
391
|
|
|
$schedulable_classes = $this->schedulable_classes; |
392
|
|
|
$is_authorized = false; |
393
|
|
|
$sfapi = ''; |
394
|
|
|
if ( $consumer_key && $consumer_secret ) { |
395
|
|
|
$sfapi = new Object_Sync_Sf_Salesforce( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes, $option_prefix ); |
396
|
|
|
if ( true === $sfapi->is_authorized() ) { |
397
|
|
|
$is_authorized = true; |
398
|
|
|
} |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
return array( |
402
|
|
|
'is_authorized' => $is_authorized, |
403
|
|
|
'sfapi' => $sfapi, |
404
|
|
|
'soap_available' => $soap_available, |
405
|
|
|
'soap_loaded' => $soap_loaded, |
406
|
|
|
); |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* Methods to push data from WordPress to Salesforce |
411
|
|
|
* |
412
|
|
|
* @return object $push |
413
|
|
|
*/ |
414
|
|
|
public function push() { |
415
|
|
|
$push = new Object_Sync_Sf_Salesforce_Push( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue, $this->option_prefix ); |
|
|
|
|
416
|
|
|
return $push; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Methods to pull data from Salesforce to WordPress |
421
|
|
|
* |
422
|
|
|
* @return object $pull |
423
|
|
|
*/ |
424
|
|
|
public function pull() { |
425
|
|
|
$pull = new Object_Sync_Sf_Salesforce_Pull( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue, $this->option_prefix ); |
|
|
|
|
426
|
|
|
return $pull; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* REST API methods |
431
|
|
|
* |
432
|
|
|
* @return object $rest |
433
|
|
|
*/ |
434
|
|
|
private function rest() { |
435
|
|
|
$rest = new Object_Sync_Sf_Rest( $this->wpdb, $this->version, $this->slug, $this->option_prefix, $this->wordpress, $this->salesforce, $this->mappings, $this->push, $this->pull ); |
|
|
|
|
436
|
|
|
return $rest; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
/** |
440
|
|
|
* Load textdomain |
441
|
|
|
*/ |
442
|
|
|
public function textdomain() { |
443
|
|
|
load_plugin_textdomain( 'object-sync-for-salesforce', false, dirname( plugin_basename( $this->file ) ) . '/languages/' ); |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* Check the server to see if Soap is available |
448
|
|
|
* |
449
|
|
|
* @return bool $is_soap_available |
450
|
|
|
*/ |
451
|
|
|
private function is_soap_available() { |
452
|
|
|
$is_soap_available = false; |
453
|
|
|
if ( extension_loaded( 'soap' ) && class_exists( 'SoapClient' ) ) { |
454
|
|
|
$is_soap_available = true; |
455
|
|
|
} |
456
|
|
|
return $is_soap_available; |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* Check the plugin to see if the Soap option has been enabled and the class has been loaded |
461
|
|
|
* |
462
|
|
|
* @return bool $is_soap_loaded |
463
|
|
|
*/ |
464
|
|
|
private function is_soap_loaded() { |
465
|
|
|
$is_soap_loaded = false; |
466
|
|
|
if ( false === $this->is_soap_available() ) { |
467
|
|
|
return $is_soap_loaded; |
468
|
|
|
} |
469
|
|
|
$use_soap = filter_var( get_option( 'object_sync_for_salesforce_use_soap', false ), FILTER_VALIDATE_BOOLEAN ); |
470
|
|
|
if ( false === $use_soap ) { |
471
|
|
|
return $is_soap_loaded; |
472
|
|
|
} |
473
|
|
|
if ( class_exists( 'Object_Sync_Sf_Salesforce_Soap_Partner' ) ) { |
474
|
|
|
$is_soap_loaded = true; |
475
|
|
|
} |
476
|
|
|
return $is_soap_loaded; |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
} // end class |
480
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.