Test Setup Failed
Pull Request — master (#169)
by Jonathan
03:40
created
classes/schedule.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 	protected $logging;
26 26
 
27 27
 	/**
28
-	* Constructor which sets up schedule and handler for when schedule runs
29
-	*
30
-	* @param object $wpdb
31
-	* @param string $version
32
-	* @param array $login_credentials
33
-	* @param string $slug
34
-	* @param object $wordpress
35
-	* @param object $salesforce
36
-	* @param object $mappings
37
-	* @param string $schedule_name
38
-	* @throws \Exception
39
-	*/
28
+	 * Constructor which sets up schedule and handler for when schedule runs
29
+	 *
30
+	 * @param object $wpdb
31
+	 * @param string $version
32
+	 * @param array $login_credentials
33
+	 * @param string $slug
34
+	 * @param object $wordpress
35
+	 * @param object $salesforce
36
+	 * @param object $mappings
37
+	 * @param string $schedule_name
38
+	 * @throws \Exception
39
+	 */
40 40
 
41 41
 	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $schedule_name, $logging, $schedulable_classes ) {
42 42
 
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
 	}
60 60
 
61 61
 	/**
62
-	* Create the filters we need to run
63
-	*
64
-	*/
62
+	 * Create the filters we need to run
63
+	 *
64
+	 */
65 65
 	public function add_filters() {
66 66
 		add_filter( 'cron_schedules', array( $this, 'set_schedule_frequency' ) );
67 67
 	}
68 68
 
69 69
 	/**
70
-	* Convert the schedule frequency from the admin settings into an array
71
-	* interval must be in seconds for the class to use it
72
-	*
73
-	*/
70
+	 * Convert the schedule frequency from the admin settings into an array
71
+	 * interval must be in seconds for the class to use it
72
+	 *
73
+	 */
74 74
 	public function set_schedule_frequency( $schedules ) {
75 75
 
76 76
 		// create an option in the core schedules array for each one the plugin defines
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	}
109 109
 
110 110
 	/**
111
-	* Convert the schedule frequency from the admin settings into an array
112
-	* interval must be in seconds for the class to use it
113
-	*
114
-	*/
111
+	 * Convert the schedule frequency from the admin settings into an array
112
+	 * interval must be in seconds for the class to use it
113
+	 *
114
+	 */
115 115
 	public function get_schedule_frequency_key( $name = '' ) {
116 116
 
117 117
 		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 	}
139 139
 
140 140
 	/**
141
-	* Convert the schedule frequency from the admin settings into seconds
142
-	*
143
-	*/
141
+	 * Convert the schedule frequency from the admin settings into seconds
142
+	 *
143
+	 */
144 144
 	public function get_schedule_frequency_seconds( $name = '' ) {
145 145
 
146 146
 		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	* @throws \Exception
39 39
 	*/
40 40
 
41
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $schedule_name, $logging, $schedulable_classes ) {
41
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $schedule_name, $logging, $schedulable_classes) {
42 42
 
43 43
 		$this->wpdb                = $wpdb;
44 44
 		$this->version             = $version;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$this->identifier = $this->schedule_name;
55 55
 
56 56
 		$this->add_filters();
57
-		add_action( $this->schedule_name, array( $this, 'maybe_handle' ) ); // run the handle method
57
+		add_action($this->schedule_name, array($this, 'maybe_handle')); // run the handle method
58 58
 
59 59
 	}
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	*
64 64
 	*/
65 65
 	public function add_filters() {
66
-		add_filter( 'cron_schedules', array( $this, 'set_schedule_frequency' ) );
66
+		add_filter('cron_schedules', array($this, 'set_schedule_frequency'));
67 67
 	}
68 68
 
69 69
 	/**
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	* interval must be in seconds for the class to use it
72 72
 	*
73 73
 	*/
74
-	public function set_schedule_frequency( $schedules ) {
74
+	public function set_schedule_frequency($schedules) {
75 75
 
76 76
 		// create an option in the core schedules array for each one the plugin defines
77
-		foreach ( $this->schedulable_classes as $key => $value ) {
78
-			$schedule_number = absint( get_option( 'object_sync_for_salesforce_' . $key . '_schedule_number', '' ) );
79
-			$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $key . '_schedule_unit', '' );
77
+		foreach ($this->schedulable_classes as $key => $value) {
78
+			$schedule_number = absint(get_option('object_sync_for_salesforce_' . $key . '_schedule_number', ''));
79
+			$schedule_unit   = get_option('object_sync_for_salesforce_' . $key . '_schedule_unit', '');
80 80
 
81
-			switch ( $schedule_unit ) {
81
+			switch ($schedule_unit) {
82 82
 				case 'minutes':
83 83
 					$seconds = 60;
84 84
 					break;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
 			$key = $schedule_unit . '_' . $schedule_number;
96 96
 
97
-			$schedules[ $key ] = array(
97
+			$schedules[$key] = array(
98 98
 				'interval' => $seconds * $schedule_number,
99 99
 				'display'  => 'Every ' . $schedule_number . ' ' . $schedule_unit,
100 100
 			);
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 	* interval must be in seconds for the class to use it
113 113
 	*
114 114
 	*/
115
-	public function get_schedule_frequency_key( $name = '' ) {
115
+	public function get_schedule_frequency_key($name = '') {
116 116
 
117
-		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
118
-		$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_unit', '' );
117
+		$schedule_number = get_option('object_sync_for_salesforce_' . $name . '_schedule_number', '');
118
+		$schedule_unit   = get_option('object_sync_for_salesforce_' . $name . '_schedule_unit', '');
119 119
 
120
-		switch ( $schedule_unit ) {
120
+		switch ($schedule_unit) {
121 121
 			case 'minutes':
122 122
 				$seconds = 60;
123 123
 				break;
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
 	* Convert the schedule frequency from the admin settings into seconds
142 142
 	*
143 143
 	*/
144
-	public function get_schedule_frequency_seconds( $name = '' ) {
144
+	public function get_schedule_frequency_seconds($name = '') {
145 145
 
146
-		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
147
-		$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_unit', '' );
146
+		$schedule_number = get_option('object_sync_for_salesforce_' . $name . '_schedule_number', '');
147
+		$schedule_unit   = get_option('object_sync_for_salesforce_' . $name . '_schedule_unit', '');
148 148
 
149
-		switch ( $schedule_unit ) {
149
+		switch ($schedule_unit) {
150 150
 			case 'minutes':
151 151
 				$seconds = 60;
152 152
 				break;
@@ -172,18 +172,18 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return void
174 174
 	 */
175
-	public function use_schedule( $name = '' ) {
175
+	public function use_schedule($name = '') {
176 176
 
177
-		if ( '' !== $name ) {
177
+		if ('' !== $name) {
178 178
 			$schedule_name = $name;
179 179
 		} else {
180 180
 			$schedule_name = $this->schedule_name;
181 181
 		}
182 182
 
183
-		$schedule_frequency = $this->get_schedule_frequency_key( $name );
183
+		$schedule_frequency = $this->get_schedule_frequency_key($name);
184 184
 
185
-		if ( ! wp_next_scheduled( $schedule_name ) ) {
186
-			wp_schedule_event( time(), $schedule_frequency, $schedule_name );
185
+		if ( ! wp_next_scheduled($schedule_name)) {
186
+			wp_schedule_event(time(), $schedule_frequency, $schedule_name);
187 187
 		}
188 188
 
189 189
 	}
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return mixed
202 202
 	 */
203
-	protected function task( $data ) {
204
-		if ( is_array( $this->schedulable_classes[ $this->schedule_name ] ) ) {
205
-			$schedule = $this->schedulable_classes[ $this->schedule_name ];
206
-			if ( isset( $schedule['class'] ) ) {
207
-				$class  = new $schedule['class']( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes );
203
+	protected function task($data) {
204
+		if (is_array($this->schedulable_classes[$this->schedule_name])) {
205
+			$schedule = $this->schedulable_classes[$this->schedule_name];
206
+			if (isset($schedule['class'])) {
207
+				$class  = new $schedule['class']($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes);
208 208
 				$method = $schedule['callback'];
209
-				$task   = $class->$method( $data['object_type'], $data['object'], $data['mapping'], $data['sf_sync_trigger'] );
209
+				$task   = $class->$method($data['object_type'], $data['object'], $data['mapping'], $data['sf_sync_trigger']);
210 210
 			}
211 211
 		}
212 212
 		return false;
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
 	 * @return $data
223 223
 	 */
224 224
 	protected function check_for_data() {
225
-		if ( is_array( $this->schedulable_classes[ $this->schedule_name ] ) ) {
226
-			$schedule = $this->schedulable_classes[ $this->schedule_name ];
227
-			if ( isset( $schedule['class'] ) ) {
228
-				$class  = new $schedule['class']( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes );
225
+		if (is_array($this->schedulable_classes[$this->schedule_name])) {
226
+			$schedule = $this->schedulable_classes[$this->schedule_name];
227
+			if (isset($schedule['class'])) {
228
+				$class  = new $schedule['class']($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes);
229 229
 				$method = $schedule['initializer'];
230 230
 				$task   = $class->$method();
231 231
 			}
232 232
 		}
233 233
 		// we have checked for data and it's in the queue if it exists
234 234
 		// now run maybe_handle again to see if it nees to be processed
235
-		$this->maybe_handle( true );
235
+		$this->maybe_handle(true);
236 236
 	}
237 237
 
238 238
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 	 * Checks whether data exists within the queue and that
242 242
 	 * the process is not already running.
243 243
 	 */
244
-	public function maybe_handle( $already_checked = false, $ajax = false ) {
245
-		if ( $this->is_process_running() ) {
244
+	public function maybe_handle($already_checked = false, $ajax = false) {
245
+		if ($this->is_process_running()) {
246 246
 			// Background process already running.
247 247
 			wp_die();
248 248
 		}
@@ -251,19 +251,19 @@  discard block
 block discarded – undo
251 251
 		// it should call its corresponding class method that saves data to the queue
252 252
 		// it should then run maybe_handle() again
253 253
 
254
-		$check_for_data_first = isset( $this->schedulable_classes[ $this->schedule_name ]['initializer'] ) ? true : false;
254
+		$check_for_data_first = isset($this->schedulable_classes[$this->schedule_name]['initializer']) ? true : false;
255 255
 
256
-		if ( false === $already_checked && true === $check_for_data_first ) {
256
+		if (false === $already_checked && true === $check_for_data_first) {
257 257
 			$this->check_for_data();
258 258
 		}
259 259
 
260
-		if ( $this->is_queue_empty() ) {
260
+		if ($this->is_queue_empty()) {
261 261
 			// No data to process.
262 262
 			wp_die();
263 263
 		}
264 264
 
265
-		if ( true === $ajax ) {
266
-			check_ajax_referer( $this->identifier, 'nonce' );
265
+		if (true === $ajax) {
266
+			check_ajax_referer($this->identifier, 'nonce');
267 267
 		}
268 268
 
269 269
 		$this->handle();
@@ -275,15 +275,15 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * This is modeled off the cancel_process method in wp-background-process but that one doesn't seem to work when we need to specify the queue name
277 277
 	 */
278
-	public function cancel_by_name( $name ) {
279
-		if ( ! isset( $name ) ) {
278
+	public function cancel_by_name($name) {
279
+		if ( ! isset($name)) {
280 280
 			$name = $this->identifier . '_cron';
281 281
 		}
282
-		if ( ! $this->is_queue_empty() ) {
283
-			while ( $this->count_queue_items() > 0 ) {
282
+		if ( ! $this->is_queue_empty()) {
283
+			while ($this->count_queue_items() > 0) {
284 284
 				$batch = $this->get_batch();
285
-				$this->delete( $batch->key );
286
-				wp_clear_scheduled_hook( $name );
285
+				$this->delete($batch->key);
286
+				wp_clear_scheduled_hook($name);
287 287
 			}
288 288
 		}
289 289
 	}
@@ -294,28 +294,28 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @return bool
296 296
 	 */
297
-	public function count_queue_items( $schedule_name = '' ) {
297
+	public function count_queue_items($schedule_name = '') {
298 298
 		$wpdb = $this->wpdb;
299 299
 
300 300
 		$table  = $wpdb->options;
301 301
 		$column = 'option_name';
302 302
 
303
-		if ( is_multisite() ) {
303
+		if (is_multisite()) {
304 304
 			$table  = $wpdb->sitemeta;
305 305
 			$column = 'meta_key';
306 306
 		}
307 307
 
308
-		if ( '' === $schedule_name ) {
308
+		if ('' === $schedule_name) {
309 309
 			$key = $this->identifier . '_batch_%';
310 310
 		} else {
311 311
 			$key = $schedule_name . '_batch_%';
312 312
 		}
313 313
 
314
-		$count = $wpdb->get_var( $wpdb->prepare( "
314
+		$count = $wpdb->get_var($wpdb->prepare("
315 315
 			SELECT COUNT(*)
316 316
 			FROM {$table}
317 317
 			WHERE {$column} LIKE %s
318
-		", $key ) );
318
+		", $key));
319 319
 
320 320
 		return $count;
321 321
 	}
Please login to merge, or discard this patch.
classes/salesforce_soap_partner.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
 	public $wsdl;
23 23
 
24 24
 	/**
25
-	* Constructor which loads the SOAP client
26
-	*
27
-	*/
25
+	 * Constructor which loads the SOAP client
26
+	 *
27
+	 */
28 28
 	public function __construct( Object_Sync_Sf_Salesforce $sfapi, $wsdl = null ) {
29 29
 		if ( ! class_exists( 'SforceBaseClient' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
30 30
 			require_once plugin_dir_path( __FILE__ ) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/SforcePartnerClient.php';
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -25,33 +25,33 @@  discard block
 block discarded – undo
25 25
 	* Constructor which loads the SOAP client
26 26
 	*
27 27
 	*/
28
-	public function __construct( Object_Sync_Sf_Salesforce $sfapi, $wsdl = null ) {
29
-		if ( ! class_exists( 'SforceBaseClient' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
30
-			require_once plugin_dir_path( __FILE__ ) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/SforcePartnerClient.php';
28
+	public function __construct(Object_Sync_Sf_Salesforce $sfapi, $wsdl = null) {
29
+		if ( ! class_exists('SforceBaseClient') && file_exists(plugin_dir_path(__FILE__) . '../vendor/autoload.php')) {
30
+			require_once plugin_dir_path(__FILE__) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/SforcePartnerClient.php';
31 31
 		}
32 32
 		parent::__construct();
33
-		if ( empty( $wsdl ) ) {
34
-			$wsdl = plugin_dir_path( __FILE__ ) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/partner.wsdl.xml';
33
+		if (empty($wsdl)) {
34
+			$wsdl = plugin_dir_path(__FILE__) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/partner.wsdl.xml';
35 35
 		}
36
-		$this->set_authorized( false );
37
-		$this->createConnection( $wsdl );
36
+		$this->set_authorized(false);
37
+		$this->createConnection($wsdl);
38 38
 		$this->salesforce_api = $sfapi;
39 39
 
40
-		if ( $this->salesforce_api->is_authorized() ) {
40
+		if ($this->salesforce_api->is_authorized()) {
41 41
 			$token = $this->salesforce_api->get_access_token();
42
-			if ( ! $token ) {
42
+			if ( ! $token) {
43 43
 				$token = $this->salesforce_api->refresh_token();
44 44
 			}
45
-			$this->setSessionHeader( $token );
46
-			$this->setEndPoint( $this->salesforce_api->get_api_endpoint( 'partner' ) );
47
-			$this->set_authorized( true );
45
+			$this->setSessionHeader($token);
46
+			$this->setEndPoint($this->salesforce_api->get_api_endpoint('partner'));
47
+			$this->set_authorized(true);
48 48
 		} else {
49
-			error_log( 'salesforce is not authorized so we cannot use soap' );
50
-			$this->set_authorized( false );
49
+			error_log('salesforce is not authorized so we cannot use soap');
50
+			$this->set_authorized(false);
51 51
 		}
52 52
 	}
53 53
 
54
-	protected function set_authorized( $is_authorized ) {
54
+	protected function set_authorized($is_authorized) {
55 55
 		$this->is_authorized = $is_authorized;
56 56
 	}
57 57
 
@@ -59,35 +59,35 @@  discard block
 block discarded – undo
59 59
 		return $this->is_authorized;
60 60
 	}
61 61
 
62
-	public function try_soap( $function ) {
62
+	public function try_soap($function) {
63 63
 		$args = func_get_args();
64
-		array_shift( $args );
64
+		array_shift($args);
65 65
 		try {
66
-			$results = call_user_func_array( array( $this, $function ), $args );
66
+			$results = call_user_func_array(array($this, $function), $args);
67 67
 			// If returned without exceptions, reset the refreshed flag.
68 68
 			$this->refreshed = false;
69 69
 			return $results;
70
-		} catch ( SoapFault $e ) {
70
+		} catch (SoapFault $e) {
71 71
 			// sf:INVALID_SESSION_ID is thrown on expired login (and other reasons).
72 72
 			// Our only recourse is to try refreshing our auth token. If we get any
73 73
 			// other exception, bubble it up.
74
-			if ( 'sf:INVALID_SESSION_ID' !== $e->faultcode ) {
74
+			if ('sf:INVALID_SESSION_ID' !== $e->faultcode) {
75 75
 				throw $e;
76 76
 			}
77 77
 
78
-			if ( ! $this->refreshed ) {
78
+			if ( ! $this->refreshed) {
79 79
 				// If we got an invalid session exception, try to refresh the auth
80 80
 				// token through REST API. The "refreshed" flag will make sure we retry
81 81
 				// only once.
82 82
 				$this->refreshed = true;
83 83
 				$this->salesforce_api->refresh_token();
84
-				return $this->trySoap( $function, $args );
84
+				return $this->trySoap($function, $args);
85 85
 			}
86 86
 
87 87
 			// If we've already tried a refresh, this refresh token is probably
88 88
 			// invalid. Kill it, log, and bubble the exception.
89
-			$this->set_authorized( false );
90
-			error_log( 'website is not authorized to connect to salesforce. visit authorize page.' );
89
+			$this->set_authorized(false);
90
+			error_log('website is not authorized to connect to salesforce. visit authorize page.');
91 91
 			throw $e;
92 92
 
93 93
 		}
Please login to merge, or discard this patch.
classes/salesforce.php 2 patches
Indentation   +406 added lines, -406 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@  discard block
 block discarded – undo
17 17
 	public $response;
18 18
 
19 19
 	/**
20
-	* Constructor which initializes the Salesforce APIs.
21
-	*
22
-	* @param string $consumer_key
23
-	*   Salesforce key to connect to your Salesforce instance.
24
-	* @param string $consumer_secret
25
-	*   Salesforce secret to connect to your Salesforce instance.
26
-	* @param string $login_url
27
-	*   Login URL for Salesforce auth requests - differs for production and sandbox
28
-	* @param string $callback_url
29
-	*   WordPress URL where Salesforce should send you after authentication
30
-	* @param string $authorize_path
31
-	*   Oauth path that Salesforce wants
32
-	* @param string $token_path
33
-	*   Path Salesforce uses to give you a token
34
-	* @param string $rest_api_version
35
-	*   What version of the Salesforce REST API to use
36
-	* @param object $wordpress
37
-	*   Object for doing things to WordPress - retrieving data, cache, etc.
38
-	* @param string $slug
39
-	*   Slug for this plugin. Can be used for file including, especially
40
-	* @param object $logging
41
-	*   Logging object for this plugin.
42
-	* @param array $schedulable_classes
43
-	*   array of classes that can have scheduled tasks specific to them
44
-	*/
20
+	 * Constructor which initializes the Salesforce APIs.
21
+	 *
22
+	 * @param string $consumer_key
23
+	 *   Salesforce key to connect to your Salesforce instance.
24
+	 * @param string $consumer_secret
25
+	 *   Salesforce secret to connect to your Salesforce instance.
26
+	 * @param string $login_url
27
+	 *   Login URL for Salesforce auth requests - differs for production and sandbox
28
+	 * @param string $callback_url
29
+	 *   WordPress URL where Salesforce should send you after authentication
30
+	 * @param string $authorize_path
31
+	 *   Oauth path that Salesforce wants
32
+	 * @param string $token_path
33
+	 *   Path Salesforce uses to give you a token
34
+	 * @param string $rest_api_version
35
+	 *   What version of the Salesforce REST API to use
36
+	 * @param object $wordpress
37
+	 *   Object for doing things to WordPress - retrieving data, cache, etc.
38
+	 * @param string $slug
39
+	 *   Slug for this plugin. Can be used for file including, especially
40
+	 * @param object $logging
41
+	 *   Logging object for this plugin.
42
+	 * @param array $schedulable_classes
43
+	 *   array of classes that can have scheduled tasks specific to them
44
+	 */
45 45
 	public function __construct( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes ) {
46 46
 		$this->consumer_key        = $consumer_key;
47 47
 		$this->consumer_secret     = $consumer_secret;
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	/**
73
-	* Converts a 15-character case-sensitive Salesforce ID to 18-character
74
-	* case-insensitive ID. If input is not 15-characters, return input unaltered.
75
-	*
76
-	* @param string $sf_id_15
77
-	*   15-character case-sensitive Salesforce ID
78
-	* @return string
79
-	*   18-character case-insensitive Salesforce ID
80
-	*/
73
+	 * Converts a 15-character case-sensitive Salesforce ID to 18-character
74
+	 * case-insensitive ID. If input is not 15-characters, return input unaltered.
75
+	 *
76
+	 * @param string $sf_id_15
77
+	 *   15-character case-sensitive Salesforce ID
78
+	 * @return string
79
+	 *   18-character case-insensitive Salesforce ID
80
+	 */
81 81
 	public static function convert_id( $sf_id_15 ) {
82 82
 		if ( strlen( $sf_id_15 ) !== 15 ) {
83 83
 			return $sf_id_15;
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	/**
100
-	* Given a Salesforce ID, return the corresponding SObject name. (Based on
101
-	*  keyPrefix from object definition, @see
102
-	*  https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ )
103
-	*
104
-	* @param string $sf_id
105
-	*   15- or 18-character Salesforce ID
106
-	* @return string
107
-	*   sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE
108
-	*   if no match could be found.
109
-	* @throws Object_Sync_Sf_Exception
110
-	*/
100
+	 * Given a Salesforce ID, return the corresponding SObject name. (Based on
101
+	 *  keyPrefix from object definition, @see
102
+	 *  https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ )
103
+	 *
104
+	 * @param string $sf_id
105
+	 *   15- or 18-character Salesforce ID
106
+	 * @return string
107
+	 *   sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE
108
+	 *   if no match could be found.
109
+	 * @throws Object_Sync_Sf_Exception
110
+	 */
111 111
 	public function get_sobject_type( $sf_id ) {
112 112
 		$objects = $this->objects(
113 113
 			array(
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	/**
127
-	* Determine if this SF instance is fully configured.
128
-	*
129
-	*/
127
+	 * Determine if this SF instance is fully configured.
128
+	 *
129
+	 */
130 130
 	public function is_authorized() {
131 131
 		return ! empty( $this->consumer_key ) && ! empty( $this->consumer_secret ) && $this->get_refresh_token();
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Get REST API versions available on this Salesforce organization
136
-	* This is not an authenticated call, so it would not be a helpful test
137
-	*/
135
+	 * Get REST API versions available on this Salesforce organization
136
+	 * This is not an authenticated call, so it would not be a helpful test
137
+	 */
138 138
 	public function get_api_versions() {
139 139
 		$options = array(
140 140
 			'authenticated' => false,
@@ -144,26 +144,26 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 
146 146
 	/**
147
-	* Make a call to the Salesforce REST API.
148
-	*
149
-	* @param string $path
150
-	*   Path to resource.
151
-	* @param array $params
152
-	*   Parameters to provide.
153
-	* @param string $method
154
-	*   Method to initiate the call, such as GET or POST. Defaults to GET.
155
-	* @param array $options
156
-	*   Any method can supply options for the API call, and they'll be preserved as far as the curl request
157
-	*   They get merged with the class options
158
-	* @param string $type
159
-	*   Type of call. Defaults to 'rest' - currently we don't support other types.
160
-	*   Other exammple in Drupal is 'apexrest'
161
-	*
162
-	* @return mixed
163
-	*   The requested response.
164
-	*
165
-	* @throws Object_Sync_Sf_Exception
166
-	*/
147
+	 * Make a call to the Salesforce REST API.
148
+	 *
149
+	 * @param string $path
150
+	 *   Path to resource.
151
+	 * @param array $params
152
+	 *   Parameters to provide.
153
+	 * @param string $method
154
+	 *   Method to initiate the call, such as GET or POST. Defaults to GET.
155
+	 * @param array $options
156
+	 *   Any method can supply options for the API call, and they'll be preserved as far as the curl request
157
+	 *   They get merged with the class options
158
+	 * @param string $type
159
+	 *   Type of call. Defaults to 'rest' - currently we don't support other types.
160
+	 *   Other exammple in Drupal is 'apexrest'
161
+	 *
162
+	 * @return mixed
163
+	 *   The requested response.
164
+	 *
165
+	 * @throws Object_Sync_Sf_Exception
166
+	 */
167 167
 	public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
168 168
 		if ( ! $this->get_access_token() ) {
169 169
 			$this->refresh_token();
@@ -214,25 +214,25 @@  discard block
 block discarded – undo
214 214
 	}
215 215
 
216 216
 	/**
217
-	* Private helper to issue an SF API request.
218
-	* This method is the only place where we read to or write from the cache
219
-	*
220
-	* @param string $path
221
-	*   Path to resource.
222
-	* @param array $params
223
-	*   Parameters to provide.
224
-	* @param string $method
225
-	*   Method to initiate the call, such as GET or POST.  Defaults to GET.
226
-	* @param array $options
227
-	*   This is the options array from the api_call method
228
-	*   This is where it gets merged with $this->options
229
-	* @param string $type
230
-	*   Type of call. Defaults to 'rest' - currently we don't support other types
231
-	*   Other exammple in Drupal is 'apexrest'
232
-	*
233
-	* @return array
234
-	*   The requested data.
235
-	*/
217
+	 * Private helper to issue an SF API request.
218
+	 * This method is the only place where we read to or write from the cache
219
+	 *
220
+	 * @param string $path
221
+	 *   Path to resource.
222
+	 * @param array $params
223
+	 *   Parameters to provide.
224
+	 * @param string $method
225
+	 *   Method to initiate the call, such as GET or POST.  Defaults to GET.
226
+	 * @param array $options
227
+	 *   This is the options array from the api_call method
228
+	 *   This is where it gets merged with $this->options
229
+	 * @param string $type
230
+	 *   Type of call. Defaults to 'rest' - currently we don't support other types
231
+	 *   Other exammple in Drupal is 'apexrest'
232
+	 *
233
+	 * @return array
234
+	 *   The requested data.
235
+	 */
236 236
 	protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
237 237
 		$options = array_merge( $this->options, $options ); // this will override a value in $this->options with the one in $options if there is a matching key
238 238
 		$url     = $this->get_api_endpoint( $type ) . $path;
@@ -310,22 +310,22 @@  discard block
 block discarded – undo
310 310
 	}
311 311
 
312 312
 	/**
313
-	* Make the HTTP request. Wrapper around curl().
314
-	*
315
-	* @param string $url
316
-	*   Path to make request from.
317
-	* @param array $data
318
-	*   The request body.
319
-	* @param array $headers
320
-	*   Request headers to send as name => value.
321
-	* @param string $method
322
-	*   Method to initiate the call, such as GET or POST. Defaults to GET.
323
-	* @param array $options
324
-	*   This is the options array from the api_http_request method
325
-	*
326
-	* @return array
327
-	*   Salesforce response object.
328
-	*/
313
+	 * Make the HTTP request. Wrapper around curl().
314
+	 *
315
+	 * @param string $url
316
+	 *   Path to make request from.
317
+	 * @param array $data
318
+	 *   The request body.
319
+	 * @param array $headers
320
+	 *   Request headers to send as name => value.
321
+	 * @param string $method
322
+	 *   Method to initiate the call, such as GET or POST. Defaults to GET.
323
+	 * @param array $options
324
+	 *   This is the options array from the api_http_request method
325
+	 *
326
+	 * @return array
327
+	 *   Salesforce response object.
328
+	 */
329 329
 	protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
330 330
 		// Build the request, including path and headers. Internal use.
331 331
 
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
 	}
461 461
 
462 462
 	/**
463
-	* Get the API end point for a given type of the API.
464
-	*
465
-	* @param string $api_type
466
-	*   E.g., rest, partner, enterprise.
467
-	*
468
-	* @return string
469
-	*   Complete URL endpoint for API access.
470
-	*/
463
+	 * Get the API end point for a given type of the API.
464
+	 *
465
+	 * @param string $api_type
466
+	 *   E.g., rest, partner, enterprise.
467
+	 *
468
+	 * @return string
469
+	 *   Complete URL endpoint for API access.
470
+	 */
471 471
 	public function get_api_endpoint( $api_type = 'rest' ) {
472 472
 		// Special handling for apexrest, since it's not in the identity object.
473 473
 		if ( 'apexrest' === $api_type ) {
@@ -483,67 +483,67 @@  discard block
 block discarded – undo
483 483
 	}
484 484
 
485 485
 	/**
486
-	* Get the SF instance URL. Useful for linking to objects.
487
-	*/
486
+	 * Get the SF instance URL. Useful for linking to objects.
487
+	 */
488 488
 	public function get_instance_url() {
489 489
 		return get_option( 'object_sync_for_salesforce_instance_url', '' );
490 490
 	}
491 491
 
492 492
 	/**
493
-	* Set the SF instanc URL.
494
-	*
495
-	* @param string $url
496
-	*   URL to set.
497
-	*/
493
+	 * Set the SF instanc URL.
494
+	 *
495
+	 * @param string $url
496
+	 *   URL to set.
497
+	 */
498 498
 	protected function set_instance_url( $url ) {
499 499
 		update_option( 'object_sync_for_salesforce_instance_url', $url );
500 500
 	}
501 501
 
502 502
 	/**
503
-	* Get the access token.
504
-	*/
503
+	 * Get the access token.
504
+	 */
505 505
 	public function get_access_token() {
506 506
 		return get_option( 'object_sync_for_salesforce_access_token', '' );
507 507
 	}
508 508
 
509 509
 	/**
510
-	* Set the access token.
511
-	*
512
-	* It is stored in session.
513
-	*
514
-	* @param string $token
515
-	*   Access token from Salesforce.
516
-	*/
510
+	 * Set the access token.
511
+	 *
512
+	 * It is stored in session.
513
+	 *
514
+	 * @param string $token
515
+	 *   Access token from Salesforce.
516
+	 */
517 517
 	protected function set_access_token( $token ) {
518 518
 		update_option( 'object_sync_for_salesforce_access_token', $token );
519 519
 	}
520 520
 
521 521
 	/**
522
-	* Get refresh token.
523
-	*/
522
+	 * Get refresh token.
523
+	 */
524 524
 	protected function get_refresh_token() {
525 525
 		return get_option( 'object_sync_for_salesforce_refresh_token', '' );
526 526
 	}
527 527
 
528 528
 	/**
529
-	* Set refresh token.
530
-	*
531
-	* @param string $token
532
-	*   Refresh token from Salesforce.
533
-	*/
529
+	 * Set refresh token.
530
+	 *
531
+	 * @param string $token
532
+	 *   Refresh token from Salesforce.
533
+	 */
534 534
 	protected function set_refresh_token( $token ) {
535 535
 		update_option( 'object_sync_for_salesforce_refresh_token', $token );
536 536
 	}
537 537
 
538 538
 	/**
539
-	* Refresh access token based on the refresh token. Updates session variable.
540
-	*
541
-	* todo: figure out how to do this as part of the schedule class
542
-	* this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to.
543
-	* but it could be a performance boost to do it at scheduleable intervals instead.
544
-	*
545
-	* @throws Object_Sync_Sf_Exception
546
-	*/
539
+	 * Refresh access token based on the refresh token. Updates session variable.
540
+	 *
541
+	 * todo: figure out how to do this as part of the schedule class
542
+	 * this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to.
543
+	 * but it could be a performance boost to do it at scheduleable intervals instead.
544
+	 *
545
+	 * @throws Object_Sync_Sf_Exception
546
+	 */
547 547
 	protected function refresh_token() {
548 548
 		$refresh_token = $this->get_refresh_token();
549 549
 		if ( empty( $refresh_token ) ) {
@@ -590,13 +590,13 @@  discard block
 block discarded – undo
590 590
 	}
591 591
 
592 592
 	/**
593
-	* Retrieve and store the Salesforce identity given an ID url.
594
-	*
595
-	* @param string $id
596
-	*   Identity URL.
597
-	*
598
-	* @throws Object_Sync_Sf_Exception
599
-	*/
593
+	 * Retrieve and store the Salesforce identity given an ID url.
594
+	 *
595
+	 * @param string $id
596
+	 *   Identity URL.
597
+	 *
598
+	 * @throws Object_Sync_Sf_Exception
599
+	 */
600 600
 	protected function set_identity( $id ) {
601 601
 		$headers  = array(
602 602
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
@@ -612,18 +612,18 @@  discard block
 block discarded – undo
612 612
 	}
613 613
 
614 614
 	/**
615
-	* Return the Salesforce identity, which is stored in a variable.
616
-	*
617
-	* @return array
618
-	*   Returns FALSE if no identity has been stored.
619
-	*/
615
+	 * Return the Salesforce identity, which is stored in a variable.
616
+	 *
617
+	 * @return array
618
+	 *   Returns FALSE if no identity has been stored.
619
+	 */
620 620
 	public function get_identity() {
621 621
 		return get_option( 'object_sync_for_salesforce_identity', false );
622 622
 	}
623 623
 
624 624
 	/**
625
-	* OAuth step 1: Redirect to Salesforce and request and authorization code.
626
-	*/
625
+	 * OAuth step 1: Redirect to Salesforce and request and authorization code.
626
+	 */
627 627
 	public function get_authorization_code() {
628 628
 		$url = add_query_arg(
629 629
 			array(
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
 	}
638 638
 
639 639
 	/**
640
-	* OAuth step 2: Exchange an authorization code for an access token.
641
-	*
642
-	* @param string $code
643
-	*   Code from Salesforce.
644
-	*/
640
+	 * OAuth step 2: Exchange an authorization code for an access token.
641
+	 *
642
+	 * @param string $code
643
+	 *   Code from Salesforce.
644
+	 */
645 645
 	public function request_token( $code ) {
646 646
 		$data = array(
647 647
 			'code'          => $code,
@@ -686,22 +686,22 @@  discard block
 block discarded – undo
686 686
 	/* Core API calls */
687 687
 
688 688
 	/**
689
-	* Available objects and their metadata for your organization's data.
690
-	*
691
-	* @param array $conditions
692
-	*   Associative array of filters to apply to the returned objects. Filters
693
-	*   are applied after the list is returned from Salesforce.
694
-	* @param bool $reset
695
-	*   Whether to reset the cache and retrieve a fresh version from Salesforce.
696
-	*
697
-	* @return array
698
-	*   Available objects and metadata.
699
-	*
700
-	* part of core API calls. this call does require authentication, and the basic url it becomes is like this:
701
-	* https://instance.salesforce.com/services/data/v#.0/sobjects
702
-	*
703
-	* updateable is really how the api spells it
704
-	*/
689
+	 * Available objects and their metadata for your organization's data.
690
+	 *
691
+	 * @param array $conditions
692
+	 *   Associative array of filters to apply to the returned objects. Filters
693
+	 *   are applied after the list is returned from Salesforce.
694
+	 * @param bool $reset
695
+	 *   Whether to reset the cache and retrieve a fresh version from Salesforce.
696
+	 *
697
+	 * @return array
698
+	 *   Available objects and metadata.
699
+	 *
700
+	 * part of core API calls. this call does require authentication, and the basic url it becomes is like this:
701
+	 * https://instance.salesforce.com/services/data/v#.0/sobjects
702
+	 *
703
+	 * updateable is really how the api spells it
704
+	 */
705 705
 	public function objects(
706 706
 		$conditions = array(
707 707
 			'updateable'  => true,
@@ -731,22 +731,22 @@  discard block
 block discarded – undo
731 731
 	}
732 732
 
733 733
 	/**
734
-	* Use SOQL to get objects based on query string.
735
-	*
736
-	* @param string $query
737
-	*   The SOQL query.
738
-	* @param array $options
739
-	*   Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc.
740
-	* @param boolean $all
741
-	*   Whether this should get all results for the query
742
-	* @param boolean $explain
743
-	*   If set, Salesforce will return feedback on the query performance
744
-	*
745
-	* @return array
746
-	*   Array of Salesforce objects that match the query.
747
-	*
748
-	* part of core API calls
749
-	*/
734
+	 * Use SOQL to get objects based on query string.
735
+	 *
736
+	 * @param string $query
737
+	 *   The SOQL query.
738
+	 * @param array $options
739
+	 *   Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc.
740
+	 * @param boolean $all
741
+	 *   Whether this should get all results for the query
742
+	 * @param boolean $explain
743
+	 *   If set, Salesforce will return feedback on the query performance
744
+	 *
745
+	 * @return array
746
+	 *   Array of Salesforce objects that match the query.
747
+	 *
748
+	 * part of core API calls
749
+	 */
750 750
 	public function query( $query, $options = array(), $all = false, $explain = false ) {
751 751
 		$search_data = [
752 752
 			'q' => (string) $query,
@@ -766,19 +766,19 @@  discard block
 block discarded – undo
766 766
 	}
767 767
 
768 768
 	/**
769
-	* Retrieve all the metadata for an object.
770
-	*
771
-	* @param string $name
772
-	*   Object type name, E.g., Contact, Account, etc.
773
-	* @param bool $reset
774
-	*   Whether to reset the cache and retrieve a fresh version from Salesforce.
775
-	*
776
-	* @return array
777
-	*   All the metadata for an object, including information about each field,
778
-	*   URLs, and child relationships.
779
-	*
780
-	* part of core API calls
781
-	*/
769
+	 * Retrieve all the metadata for an object.
770
+	 *
771
+	 * @param string $name
772
+	 *   Object type name, E.g., Contact, Account, etc.
773
+	 * @param bool $reset
774
+	 *   Whether to reset the cache and retrieve a fresh version from Salesforce.
775
+	 *
776
+	 * @return array
777
+	 *   All the metadata for an object, including information about each field,
778
+	 *   URLs, and child relationships.
779
+	 *
780
+	 * part of core API calls
781
+	 */
782 782
 	public function object_describe( $name, $reset = false ) {
783 783
 		if ( empty( $name ) ) {
784 784
 			return array();
@@ -806,26 +806,26 @@  discard block
 block discarded – undo
806 806
 	}
807 807
 
808 808
 	/**
809
-	* Create a new object of the given type.
810
-	*
811
-	* @param string $name
812
-	*   Object type name, E.g., Contact, Account, etc.
813
-	* @param array $params
814
-	*   Values of the fields to set for the object.
815
-	*
816
-	* @return array
817
-	*   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
818
-	*   code: 201
819
-	*   data:
820
-	*     "id" : "00190000001pPvHAAU",
821
-	*     "success" : true
822
-	*     "errors" : [ ],
823
-	*   from_cache:
824
-	*   cached:
825
-	*   is_redo:
826
-	*
827
-	* part of core API calls
828
-	*/
809
+	 * Create a new object of the given type.
810
+	 *
811
+	 * @param string $name
812
+	 *   Object type name, E.g., Contact, Account, etc.
813
+	 * @param array $params
814
+	 *   Values of the fields to set for the object.
815
+	 *
816
+	 * @return array
817
+	 *   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
818
+	 *   code: 201
819
+	 *   data:
820
+	 *     "id" : "00190000001pPvHAAU",
821
+	 *     "success" : true
822
+	 *     "errors" : [ ],
823
+	 *   from_cache:
824
+	 *   cached:
825
+	 *   is_redo:
826
+	 *
827
+	 * part of core API calls
828
+	 */
829 829
 	public function object_create( $name, $params ) {
830 830
 		$options = array(
831 831
 			'type' => 'write',
@@ -835,34 +835,34 @@  discard block
 block discarded – undo
835 835
 	}
836 836
 
837 837
 	/**
838
-	* Create new records or update existing records.
839
-	*
840
-	* The new records or updated records are based on the value of the specified
841
-	* field.  If the value is not unique, REST API returns a 300 response with
842
-	* the list of matching records.
843
-	*
844
-	* @param string $name
845
-	*   Object type name, E.g., Contact, Account.
846
-	* @param string $key
847
-	*   The field to check if this record should be created or updated.
848
-	* @param string $value
849
-	*   The value for this record of the field specified for $key.
850
-	* @param array $params
851
-	*   Values of the fields to set for the object.
852
-	*
853
-	* @return array
854
-	*   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
855
-	*   code: 201
856
-	*   data:
857
-	*     "id" : "00190000001pPvHAAU",
858
-	*     "success" : true
859
-	*     "errors" : [ ],
860
-	*   from_cache:
861
-	*   cached:
862
-	*   is_redo:
863
-	*
864
-	* part of core API calls
865
-	*/
838
+	 * Create new records or update existing records.
839
+	 *
840
+	 * The new records or updated records are based on the value of the specified
841
+	 * field.  If the value is not unique, REST API returns a 300 response with
842
+	 * the list of matching records.
843
+	 *
844
+	 * @param string $name
845
+	 *   Object type name, E.g., Contact, Account.
846
+	 * @param string $key
847
+	 *   The field to check if this record should be created or updated.
848
+	 * @param string $value
849
+	 *   The value for this record of the field specified for $key.
850
+	 * @param array $params
851
+	 *   Values of the fields to set for the object.
852
+	 *
853
+	 * @return array
854
+	 *   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
855
+	 *   code: 201
856
+	 *   data:
857
+	 *     "id" : "00190000001pPvHAAU",
858
+	 *     "success" : true
859
+	 *     "errors" : [ ],
860
+	 *   from_cache:
861
+	 *   cached:
862
+	 *   is_redo:
863
+	 *
864
+	 * part of core API calls
865
+	 */
866 866
 	public function object_upsert( $name, $key, $value, $params ) {
867 867
 		$options = array(
868 868
 			'type' => 'write',
@@ -884,27 +884,27 @@  discard block
 block discarded – undo
884 884
 	}
885 885
 
886 886
 	/**
887
-	* Update an existing object.
888
-	*
889
-	* @param string $name
890
-	*   Object type name, E.g., Contact, Account.
891
-	* @param string $id
892
-	*   Salesforce id of the object.
893
-	* @param array $params
894
-	*   Values of the fields to set for the object.
895
-	*
896
-	* part of core API calls
897
-	*
898
-	* @return array
899
-	*   json: {"success":true,"body":""}
900
-	*   code: 204
901
-	*   data:
887
+	 * Update an existing object.
888
+	 *
889
+	 * @param string $name
890
+	 *   Object type name, E.g., Contact, Account.
891
+	 * @param string $id
892
+	 *   Salesforce id of the object.
893
+	 * @param array $params
894
+	 *   Values of the fields to set for the object.
895
+	 *
896
+	 * part of core API calls
897
+	 *
898
+	 * @return array
899
+	 *   json: {"success":true,"body":""}
900
+	 *   code: 204
901
+	 *   data:
902 902
 		success: 1
903 903
 		body:
904
-	*   from_cache:
905
-	*   cached:
906
-	*   is_redo:
907
-	*/
904
+	 *   from_cache:
905
+	 *   cached:
906
+	 *   is_redo:
907
+	 */
908 908
 	public function object_update( $name, $id, $params ) {
909 909
 		$options = array(
910 910
 			'type' => 'write',
@@ -914,62 +914,62 @@  discard block
 block discarded – undo
914 914
 	}
915 915
 
916 916
 	/**
917
-	* Return a full loaded Salesforce object.
918
-	*
919
-	* @param string $name
920
-	*   Object type name, E.g., Contact, Account.
921
-	* @param string $id
922
-	*   Salesforce id of the object.
923
-	*
924
-	* @return object
925
-	*   Object of the requested Salesforce object.
926
-	*
927
-	* part of core API calls
928
-	*/
917
+	 * Return a full loaded Salesforce object.
918
+	 *
919
+	 * @param string $name
920
+	 *   Object type name, E.g., Contact, Account.
921
+	 * @param string $id
922
+	 *   Salesforce id of the object.
923
+	 *
924
+	 * @return object
925
+	 *   Object of the requested Salesforce object.
926
+	 *
927
+	 * part of core API calls
928
+	 */
929 929
 	public function object_read( $name, $id ) {
930 930
 		return $this->api_call( "sobjects/{$name}/{$id}", array(), 'GET' );
931 931
 	}
932 932
 
933 933
 	/**
934
-	* Make a call to the Analytics API
935
-	*
936
-	* @param string $name
937
-	*   Object type name, E.g., Report
938
-	* @param string $id
939
-	*   Salesforce id of the object.
940
-	* @param string $route
941
-	*   What comes after the ID? E.g. instances, ?includeDetails=True
942
-	* @param array $params
943
-	*   Params to put with the request
944
-	* @param string $method
945
-	*   GET or POST
946
-	*
947
-	* @return object
948
-	*   Object of the requested Salesforce object.
949
-	*
950
-	* part of core API calls
951
-	*/
934
+	 * Make a call to the Analytics API
935
+	 *
936
+	 * @param string $name
937
+	 *   Object type name, E.g., Report
938
+	 * @param string $id
939
+	 *   Salesforce id of the object.
940
+	 * @param string $route
941
+	 *   What comes after the ID? E.g. instances, ?includeDetails=True
942
+	 * @param array $params
943
+	 *   Params to put with the request
944
+	 * @param string $method
945
+	 *   GET or POST
946
+	 *
947
+	 * @return object
948
+	 *   Object of the requested Salesforce object.
949
+	 *
950
+	 * part of core API calls
951
+	 */
952 952
 	public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
953 953
 		return $this->api_call( "analytics/{$name}/{$id}/{$route}", $params, $method );
954 954
 	}
955 955
 
956 956
 	/**
957
-	* Run a specific Analytics report
958
-	*
959
-	* @param string $id
960
-	*   Salesforce id of the object.
961
-	* @param bool $async
962
-	*   Whether the report is asynchronous
963
-	* @param array $params
964
-	*   Params to put with the request
965
-	* @param string $method
966
-	*   GET or POST
967
-	*
968
-	* @return object
969
-	*   Object of the requested Salesforce object.
970
-	*
971
-	* part of core API calls
972
-	*/
957
+	 * Run a specific Analytics report
958
+	 *
959
+	 * @param string $id
960
+	 *   Salesforce id of the object.
961
+	 * @param bool $async
962
+	 *   Whether the report is asynchronous
963
+	 * @param array $params
964
+	 *   Params to put with the request
965
+	 * @param string $method
966
+	 *   GET or POST
967
+	 *
968
+	 * @return object
969
+	 *   Object of the requested Salesforce object.
970
+	 *
971
+	 * part of core API calls
972
+	 */
973 973
 	public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
974 974
 
975 975
 		$id         = $this->convert_id( $id );
@@ -1055,36 +1055,36 @@  discard block
 block discarded – undo
1055 1055
 	}
1056 1056
 
1057 1057
 	/**
1058
-	* Return a full loaded Salesforce object from External ID.
1059
-	*
1060
-	* @param string $name
1061
-	*   Object type name, E.g., Contact, Account.
1062
-	* @param string $field
1063
-	*   Salesforce external id field name.
1064
-	* @param string $value
1065
-	*   Value of external id.
1066
-	*
1067
-	* @return object
1068
-	*   Object of the requested Salesforce object.
1069
-	*
1070
-	* part of core API calls
1071
-	*/
1058
+	 * Return a full loaded Salesforce object from External ID.
1059
+	 *
1060
+	 * @param string $name
1061
+	 *   Object type name, E.g., Contact, Account.
1062
+	 * @param string $field
1063
+	 *   Salesforce external id field name.
1064
+	 * @param string $value
1065
+	 *   Value of external id.
1066
+	 *
1067
+	 * @return object
1068
+	 *   Object of the requested Salesforce object.
1069
+	 *
1070
+	 * part of core API calls
1071
+	 */
1072 1072
 	public function object_readby_external_id( $name, $field, $value ) {
1073 1073
 		return $this->api_call( "sobjects/{$name}/{$field}/{$value}" );
1074 1074
 	}
1075 1075
 
1076 1076
 	/**
1077
-	* Delete a Salesforce object.
1078
-	*
1079
-	* @param string $name
1080
-	*   Object type name, E.g., Contact, Account.
1081
-	* @param string $id
1082
-	*   Salesforce id of the object.
1083
-	*
1084
-	* @return array
1085
-	*
1086
-	* part of core API calls
1087
-	*/
1077
+	 * Delete a Salesforce object.
1078
+	 *
1079
+	 * @param string $name
1080
+	 *   Object type name, E.g., Contact, Account.
1081
+	 * @param string $id
1082
+	 *   Salesforce id of the object.
1083
+	 *
1084
+	 * @return array
1085
+	 *
1086
+	 * part of core API calls
1087
+	 */
1088 1088
 	public function object_delete( $name, $id ) {
1089 1089
 		$options = array(
1090 1090
 			'type' => 'write',
@@ -1094,17 +1094,17 @@  discard block
 block discarded – undo
1094 1094
 	}
1095 1095
 
1096 1096
 	/**
1097
-	* Retrieves the list of individual objects that have been deleted within the
1098
-	* given timespan for a specified object type.
1099
-	*
1100
-	* @param string $type
1101
-	*   Object type name, E.g., Contact, Account.
1102
-	* @param string $startDate
1103
-	*   Start date to check for deleted objects (in ISO 8601 format).
1104
-	* @param string $endDate
1105
-	*   End date to check for deleted objects (in ISO 8601 format).
1106
-	* @return GetDeletedResult
1107
-	*/
1097
+	 * Retrieves the list of individual objects that have been deleted within the
1098
+	 * given timespan for a specified object type.
1099
+	 *
1100
+	 * @param string $type
1101
+	 *   Object type name, E.g., Contact, Account.
1102
+	 * @param string $startDate
1103
+	 *   Start date to check for deleted objects (in ISO 8601 format).
1104
+	 * @param string $endDate
1105
+	 *   End date to check for deleted objects (in ISO 8601 format).
1106
+	 * @return GetDeletedResult
1107
+	 */
1108 1108
 	public function get_deleted( $type, $start_date, $end_date ) {
1109 1109
 		$options = array(
1110 1110
 			'cache' => false,
@@ -1114,13 +1114,13 @@  discard block
 block discarded – undo
1114 1114
 
1115 1115
 
1116 1116
 	/**
1117
-	* Return a list of available resources for the configured API version.
1118
-	*
1119
-	* @return array
1120
-	*   Associative array keyed by name with a URI value.
1121
-	*
1122
-	* part of core API calls
1123
-	*/
1117
+	 * Return a list of available resources for the configured API version.
1118
+	 *
1119
+	 * @return array
1120
+	 *   Associative array keyed by name with a URI value.
1121
+	 *
1122
+	 * part of core API calls
1123
+	 */
1124 1124
 	public function list_resources() {
1125 1125
 		$resources = $this->api_call( '' );
1126 1126
 		foreach ( $resources as $key => $path ) {
@@ -1130,31 +1130,31 @@  discard block
 block discarded – undo
1130 1130
 	}
1131 1131
 
1132 1132
 	/**
1133
-	* Return a list of SFIDs for the given object, which have been created or
1134
-	* updated in the given timeframe.
1135
-	*
1136
-	* @param string $type
1137
-	*   Object type name, E.g., Contact, Account.
1138
-	*
1139
-	* @param int $start
1140
-	*   unix timestamp for older timeframe for updates.
1141
-	*   Defaults to "-29 days" if empty.
1142
-	*
1143
-	* @param int $end
1144
-	*   unix timestamp for end of timeframe for updates.
1145
-	*   Defaults to now if empty
1146
-	*
1147
-	* @return array
1148
-	*   return array has 2 indexes:
1149
-	*     "ids": a list of SFIDs of those records which have been created or
1150
-	*       updated in the given timeframe.
1151
-	*     "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date
1152
-	*       covered in the request.
1153
-	*
1154
-	* @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm
1155
-	*
1156
-	* part of core API calls
1157
-	*/
1133
+	 * Return a list of SFIDs for the given object, which have been created or
1134
+	 * updated in the given timeframe.
1135
+	 *
1136
+	 * @param string $type
1137
+	 *   Object type name, E.g., Contact, Account.
1138
+	 *
1139
+	 * @param int $start
1140
+	 *   unix timestamp for older timeframe for updates.
1141
+	 *   Defaults to "-29 days" if empty.
1142
+	 *
1143
+	 * @param int $end
1144
+	 *   unix timestamp for end of timeframe for updates.
1145
+	 *   Defaults to now if empty
1146
+	 *
1147
+	 * @return array
1148
+	 *   return array has 2 indexes:
1149
+	 *     "ids": a list of SFIDs of those records which have been created or
1150
+	 *       updated in the given timeframe.
1151
+	 *     "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date
1152
+	 *       covered in the request.
1153
+	 *
1154
+	 * @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm
1155
+	 *
1156
+	 * part of core API calls
1157
+	 */
1158 1158
 	public function get_updated( $type, $start = null, $end = null ) {
1159 1159
 		if ( empty( $start ) ) {
1160 1160
 			$start = strtotime( '-29 days' );
@@ -1173,19 +1173,19 @@  discard block
 block discarded – undo
1173 1173
 	}
1174 1174
 
1175 1175
 	/**
1176
-	* Given a DeveloperName and SObject Name, return the SFID of the
1177
-	* corresponding RecordType. DeveloperName doesn't change between Salesforce
1178
-	* environments, so it's safer to rely on compared to SFID.
1179
-	*
1180
-	* @param string $name
1181
-	*   Object type name, E.g., Contact, Account.
1182
-	*
1183
-	* @param string $devname
1184
-	*   RecordType DeveloperName, e.g. Donation, Membership, etc.
1185
-	*
1186
-	* @return string SFID
1187
-	*   The Salesforce ID of the given Record Type, or null.
1188
-	*/
1176
+	 * Given a DeveloperName and SObject Name, return the SFID of the
1177
+	 * corresponding RecordType. DeveloperName doesn't change between Salesforce
1178
+	 * environments, so it's safer to rely on compared to SFID.
1179
+	 *
1180
+	 * @param string $name
1181
+	 *   Object type name, E.g., Contact, Account.
1182
+	 *
1183
+	 * @param string $devname
1184
+	 *   RecordType DeveloperName, e.g. Donation, Membership, etc.
1185
+	 *
1186
+	 * @return string SFID
1187
+	 *   The Salesforce ID of the given Record Type, or null.
1188
+	 */
1189 1189
 
1190 1190
 	public function get_record_type_id_by_developer_name( $name, $devname, $reset = false ) {
1191 1191
 
@@ -1213,10 +1213,10 @@  discard block
 block discarded – undo
1213 1213
 	}
1214 1214
 
1215 1215
 	/**
1216
-	* If there is a WordPress setting for how long to keep the cache, return it and set the object property
1217
-	* Otherwise, return seconds in 24 hours
1218
-	*
1219
-	*/
1216
+	 * If there is a WordPress setting for how long to keep the cache, return it and set the object property
1217
+	 * Otherwise, return seconds in 24 hours
1218
+	 *
1219
+	 */
1220 1220
 	private function cache_expiration() {
1221 1221
 		$cache_expiration = $this->wordpress->cache_expiration( 'object_sync_for_salesforce_cache_expiration', 86400 );
1222 1222
 		return $cache_expiration;
Please login to merge, or discard this patch.
Spacing   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	* @param array $schedulable_classes
43 43
 	*   array of classes that can have scheduled tasks specific to them
44 44
 	*/
45
-	public function __construct( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes ) {
45
+	public function __construct($consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes) {
46 46
 		$this->consumer_key        = $consumer_key;
47 47
 		$this->consumer_secret     = $consumer_secret;
48 48
 		$this->login_url           = $login_url;
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 			'type'             => 'read',
61 61
 		);
62 62
 
63
-		$this->success_codes              = array( 200, 201, 204 );
63
+		$this->success_codes              = array(200, 201, 204);
64 64
 		$this->refresh_code               = 401;
65 65
 		$this->success_or_refresh_codes   = $this->success_codes;
66 66
 		$this->success_or_refresh_codes[] = $this->refresh_code;
67 67
 
68
-		$this->debug = get_option( 'object_sync_for_salesforce_debug_mode', false );
68
+		$this->debug = get_option('object_sync_for_salesforce_debug_mode', false);
69 69
 
70 70
 	}
71 71
 
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 	* @return string
79 79
 	*   18-character case-insensitive Salesforce ID
80 80
 	*/
81
-	public static function convert_id( $sf_id_15 ) {
82
-		if ( strlen( $sf_id_15 ) !== 15 ) {
81
+	public static function convert_id($sf_id_15) {
82
+		if (strlen($sf_id_15) !== 15) {
83 83
 			return $sf_id_15;
84 84
 		}
85
-		$chunks = str_split( $sf_id_15, 5 );
85
+		$chunks = str_split($sf_id_15, 5);
86 86
 		$extra  = '';
87
-		foreach ( $chunks as $chunk ) {
88
-			$chars = str_split( $chunk, 1 );
87
+		foreach ($chunks as $chunk) {
88
+			$chars = str_split($chunk, 1);
89 89
 			$bits  = '';
90
-			foreach ( $chars as $char ) {
91
-				$bits .= ( ! is_numeric( $char ) && strtoupper( $char ) === $char ) ? '1' : '0';
90
+			foreach ($chars as $char) {
91
+				$bits .= ( ! is_numeric($char) && strtoupper($char) === $char) ? '1' : '0';
92 92
 			}
93 93
 			$map    = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345';
94
-			$extra .= substr( $map, base_convert( strrev( $bits ), 2, 10 ), 1 );
94
+			$extra .= substr($map, base_convert(strrev($bits), 2, 10), 1);
95 95
 		}
96 96
 		return $sf_id_15 . $extra;
97 97
 	}
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	*   if no match could be found.
109 109
 	* @throws Object_Sync_Sf_Exception
110 110
 	*/
111
-	public function get_sobject_type( $sf_id ) {
111
+	public function get_sobject_type($sf_id) {
112 112
 		$objects = $this->objects(
113 113
 			array(
114
-				'keyPrefix' => substr( $sf_id, 0, 3 ),
114
+				'keyPrefix' => substr($sf_id, 0, 3),
115 115
 			)
116 116
 		);
117
-		if ( 1 === count( $objects ) ) {
117
+		if (1 === count($objects)) {
118 118
 			// keyPrefix is unique across objects. If there is exactly one return value from objects(), then we have a match.
119
-			$object = reset( $objects );
119
+			$object = reset($objects);
120 120
 			return $object['name'];
121 121
 		}
122 122
 		// Otherwise, we did not find a match.
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	*
129 129
 	*/
130 130
 	public function is_authorized() {
131
-		return ! empty( $this->consumer_key ) && ! empty( $this->consumer_secret ) && $this->get_refresh_token();
131
+		return ! empty($this->consumer_key) && ! empty($this->consumer_secret) && $this->get_refresh_token();
132 132
 	}
133 133
 
134 134
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 			'authenticated' => false,
141 141
 			'full_url'      => true,
142 142
 		);
143
-		return $this->api_call( $this->get_instance_url() . '/services/data', [], 'GET', $options );
143
+		return $this->api_call($this->get_instance_url() . '/services/data', [], 'GET', $options);
144 144
 	}
145 145
 
146 146
 	/**
@@ -164,50 +164,50 @@  discard block
 block discarded – undo
164 164
 	*
165 165
 	* @throws Object_Sync_Sf_Exception
166 166
 	*/
167
-	public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
168
-		if ( ! $this->get_access_token() ) {
167
+	public function api_call($path, $params = array(), $method = 'GET', $options = array(), $type = 'rest') {
168
+		if ( ! $this->get_access_token()) {
169 169
 			$this->refresh_token();
170 170
 		}
171
-		$this->response = $this->api_http_request( $path, $params, $method, $options, $type );
171
+		$this->response = $this->api_http_request($path, $params, $method, $options, $type);
172 172
 
173 173
 		// analytic calls that are expired return 404s for some absurd reason
174
-		if ( $this->response['code'] && 'run_analytics_report' === debug_backtrace()[1]['function'] ) {
174
+		if ($this->response['code'] && 'run_analytics_report' === debug_backtrace()[1]['function']) {
175 175
 			return $this->response;
176 176
 		}
177 177
 
178
-		switch ( $this->response['code'] ) {
178
+		switch ($this->response['code']) {
179 179
 			// The session ID or OAuth token used has expired or is invalid.
180 180
 			case $this->response['code'] === $this->refresh_code:
181 181
 				// Refresh token.
182 182
 				$this->refresh_token();
183 183
 				// Rebuild our request and repeat request.
184 184
 				$options['is_redo'] = true;
185
-				$this->response     = $this->api_http_request( $path, $params, $method, $options, $type );
185
+				$this->response     = $this->api_http_request($path, $params, $method, $options, $type);
186 186
 				// Throw an error if we still have bad response.
187
-				if ( ! in_array( $this->response['code'], $this->success_codes, true ) ) {
188
-					throw new Object_Sync_Sf_Exception( $this->response['data'][0]['message'], $this->response['code'] );
187
+				if ( ! in_array($this->response['code'], $this->success_codes, true)) {
188
+					throw new Object_Sync_Sf_Exception($this->response['data'][0]['message'], $this->response['code']);
189 189
 				}
190 190
 				break;
191
-			case in_array( $this->response['code'], $this->success_codes, true ):
191
+			case in_array($this->response['code'], $this->success_codes, true):
192 192
 				// All clear.
193 193
 				break;
194 194
 			default:
195 195
 				// We have problem and no specific Salesforce error provided.
196
-				if ( empty( $this->response['data'] ) ) {
197
-					throw new Object_Sync_Sf_Exception( $this->response['error'], $this->response['code'] );
196
+				if (empty($this->response['data'])) {
197
+					throw new Object_Sync_Sf_Exception($this->response['error'], $this->response['code']);
198 198
 				}
199 199
 		}
200 200
 
201
-		if ( ! empty( $this->response['data'][0] ) && 1 === count( $this->response['data'] ) ) {
201
+		if ( ! empty($this->response['data'][0]) && 1 === count($this->response['data'])) {
202 202
 			$this->response['data'] = $this->response['data'][0];
203 203
 		}
204 204
 
205
-		if ( isset( $this->response['data']['error'] ) ) {
206
-			throw new Object_Sync_Sf_Exception( $this->response['data']['error_description'], $this->response['data']['error'] );
205
+		if (isset($this->response['data']['error'])) {
206
+			throw new Object_Sync_Sf_Exception($this->response['data']['error_description'], $this->response['data']['error']);
207 207
 		}
208 208
 
209
-		if ( ! empty( $this->response['data']['errorCode'] ) ) {
210
-			throw new Object_Sync_Sf_Exception( $this->response['data']['message'], $this->response['code'] );
209
+		if ( ! empty($this->response['data']['errorCode'])) {
210
+			throw new Object_Sync_Sf_Exception($this->response['data']['message'], $this->response['code']);
211 211
 		}
212 212
 
213 213
 		return $this->response;
@@ -233,73 +233,73 @@  discard block
 block discarded – undo
233 233
 	* @return array
234 234
 	*   The requested data.
235 235
 	*/
236
-	protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
237
-		$options = array_merge( $this->options, $options ); // this will override a value in $this->options with the one in $options if there is a matching key
238
-		$url     = $this->get_api_endpoint( $type ) . $path;
239
-		if ( isset( $options['full_url'] ) && true === $options['full_url'] ) {
236
+	protected function api_http_request($path, $params, $method, $options = array(), $type = 'rest') {
237
+		$options = array_merge($this->options, $options); // this will override a value in $this->options with the one in $options if there is a matching key
238
+		$url     = $this->get_api_endpoint($type) . $path;
239
+		if (isset($options['full_url']) && true === $options['full_url']) {
240 240
 			$url = $path;
241 241
 		}
242 242
 		$headers = array(
243 243
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
244 244
 			'Accept-Encoding' => 'Accept-Encoding: gzip, deflate',
245 245
 		);
246
-		if ( 'POST' === $method || 'PATCH' === $method ) {
246
+		if ('POST' === $method || 'PATCH' === $method) {
247 247
 			$headers['Content-Type'] = 'Content-Type: application/json';
248 248
 		}
249
-		if ( isset( $options['authenticated'] ) && true === $options['authenticated'] ) {
249
+		if (isset($options['authenticated']) && true === $options['authenticated']) {
250 250
 			$headers = false;
251 251
 		}
252 252
 		// if this request should be cached, see if it already exists
253 253
 		// if it is already cached, load it. if not, load it and then cache it if it should be cached
254 254
 		// add parameters to the array so we can tell if it was cached or not
255
-		if ( true === $options['cache'] && 'write' !== $options['type'] ) {
256
-			$cached = $this->wordpress->cache_get( $url, $params );
255
+		if (true === $options['cache'] && 'write' !== $options['type']) {
256
+			$cached = $this->wordpress->cache_get($url, $params);
257 257
 			// some api calls can send a reset option, in which case we should redo the request anyway
258
-			if ( is_array( $cached ) && ( ! isset( $options['reset'] ) || true !== $options['reset'] ) ) {
258
+			if (is_array($cached) && ( ! isset($options['reset']) || true !== $options['reset'])) {
259 259
 				$result               = $cached;
260 260
 				$result['from_cache'] = true;
261 261
 				$result['cached']     = true;
262 262
 			} else {
263
-				$data   = wp_json_encode( $params );
264
-				$result = $this->http_request( $url, $data, $headers, $method, $options );
265
-				if ( in_array( $result['code'], $this->success_codes, true ) ) {
266
-					$result['cached'] = $this->wordpress->cache_set( $url, $params, $result, $options['cache_expiration'] );
263
+				$data   = wp_json_encode($params);
264
+				$result = $this->http_request($url, $data, $headers, $method, $options);
265
+				if (in_array($result['code'], $this->success_codes, true)) {
266
+					$result['cached'] = $this->wordpress->cache_set($url, $params, $result, $options['cache_expiration']);
267 267
 				} else {
268 268
 					$result['cached'] = false;
269 269
 				}
270 270
 				$result['from_cache'] = false;
271 271
 			}
272 272
 		} else {
273
-			$data                 = wp_json_encode( $params );
274
-			$result               = $this->http_request( $url, $data, $headers, $method, $options );
273
+			$data                 = wp_json_encode($params);
274
+			$result               = $this->http_request($url, $data, $headers, $method, $options);
275 275
 			$result['from_cache'] = false;
276 276
 			$result['cached']     = false;
277 277
 		}
278 278
 
279
-		if ( isset( $options['is_redo'] ) && true === $options['is_redo'] ) {
279
+		if (isset($options['is_redo']) && true === $options['is_redo']) {
280 280
 			$result['is_redo'] = true;
281 281
 		} else {
282 282
 			$result['is_redo'] = false;
283 283
 		}
284 284
 
285 285
 		// it would be very unfortunate to ever have to do this in a production site
286
-		if ( 1 === (int) $this->debug ) {
286
+		if (1 === (int) $this->debug) {
287 287
 			// create log entry for the api call if debug is true
288 288
 			$status = 'debug';
289
-			if ( isset( $this->logging ) ) {
289
+			if (isset($this->logging)) {
290 290
 				$logging = $this->logging;
291
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
292
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
291
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
292
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
293 293
 			}
294 294
 
295 295
 			// translators: placeholder is the URL of the Salesforce API request
296
-			$title = sprintf( esc_html__( 'Debug: on Salesforce API HTTP Request to URL: %1$s.', 'object-sync-for-salesforce' ),
297
-				esc_url( $url )
296
+			$title = sprintf(esc_html__('Debug: on Salesforce API HTTP Request to URL: %1$s.', 'object-sync-for-salesforce'),
297
+				esc_url($url)
298 298
 			);
299 299
 
300 300
 			$logging->setup(
301 301
 				$title,
302
-				print_r( $result, true ), // log the result because we are debugging the whole api call
302
+				print_r($result, true), // log the result because we are debugging the whole api call
303 303
 				0,
304 304
 				0,
305 305
 				$status
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	* @return array
327 327
 	*   Salesforce response object.
328 328
 	*/
329
-	protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
329
+	protected function http_request($url, $data, $headers = array(), $method = 'GET', $options = array()) {
330 330
 		// Build the request, including path and headers. Internal use.
331 331
 
332 332
 		/*
@@ -335,60 +335,60 @@  discard block
 block discarded – undo
335 335
 		*/
336 336
 
337 337
 		$curl = curl_init();
338
-		curl_setopt( $curl, CURLOPT_URL, $url );
339
-		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
340
-		curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
341
-		if ( false !== $headers ) {
342
-			curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
338
+		curl_setopt($curl, CURLOPT_URL, $url);
339
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
340
+		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
341
+		if (false !== $headers) {
342
+			curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
343 343
 		} else {
344
-			curl_setopt( $curl, CURLOPT_HEADER, false );
344
+			curl_setopt($curl, CURLOPT_HEADER, false);
345 345
 		}
346 346
 
347
-		if ( 'POST' === $method ) {
348
-			curl_setopt( $curl, CURLOPT_POST, true );
349
-			curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
350
-		} elseif ( 'PATCH' === $method || 'DELETE' === $method ) {
351
-			curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, $method );
352
-			curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
347
+		if ('POST' === $method) {
348
+			curl_setopt($curl, CURLOPT_POST, true);
349
+			curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
350
+		} elseif ('PATCH' === $method || 'DELETE' === $method) {
351
+			curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
352
+			curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
353 353
 		}
354
-		$json_response = curl_exec( $curl ); // this is possibly gzipped json data
355
-		$code          = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
354
+		$json_response = curl_exec($curl); // this is possibly gzipped json data
355
+		$code          = curl_getinfo($curl, CURLINFO_HTTP_CODE);
356 356
 
357
-		if ( ( 'PATCH' === $method || 'DELETE' === $method ) && '' === $json_response && 204 === $code ) {
357
+		if (('PATCH' === $method || 'DELETE' === $method) && '' === $json_response && 204 === $code) {
358 358
 			// delete and patch requests return a 204 with an empty body upon success for whatever reason
359 359
 			$data = array(
360 360
 				'success' => true,
361 361
 				'body'    => '',
362 362
 			);
363
-			curl_close( $curl );
363
+			curl_close($curl);
364 364
 			return array(
365
-				'json' => wp_json_encode( $data ),
365
+				'json' => wp_json_encode($data),
366 366
 				'code' => $code,
367 367
 				'data' => $data,
368 368
 			);
369 369
 		}
370 370
 
371
-		if ( ( ord( $json_response[0] ) == 0x1f ) && ( ord( $json_response[1] ) == 0x8b ) ) {
371
+		if ((ord($json_response[0]) == 0x1f) && (ord($json_response[1]) == 0x8b)) {
372 372
 			// skip header and ungzip the data
373
-			$json_response = gzinflate( substr( $json_response, 10 ) );
373
+			$json_response = gzinflate(substr($json_response, 10));
374 374
 		}
375
-		$data = json_decode( $json_response, true ); // decode it into an array
375
+		$data = json_decode($json_response, true); // decode it into an array
376 376
 
377 377
 		// don't use the exception if the status is a success one, or if it just needs a refresh token (salesforce uses 401 for this)
378
-		if ( ! in_array( $code, $this->success_or_refresh_codes, true ) ) {
379
-			$curl_error = curl_error( $curl );
380
-			if ( '' !== $curl_error ) {
378
+		if ( ! in_array($code, $this->success_or_refresh_codes, true)) {
379
+			$curl_error = curl_error($curl);
380
+			if ('' !== $curl_error) {
381 381
 				// create log entry for failed curl
382 382
 				$status = 'error';
383
-				if ( isset( $this->logging ) ) {
383
+				if (isset($this->logging)) {
384 384
 					$logging = $this->logging;
385
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
386
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
385
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
386
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
387 387
 				}
388 388
 
389 389
 				// translators: placeholder is the URL of the Salesforce API request
390
-				$title = sprintf( esc_html__( 'Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce' ),
391
-					esc_attr( $code )
390
+				$title = sprintf(esc_html__('Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce'),
391
+					esc_attr($code)
392 392
 				);
393 393
 
394 394
 				$logging->setup(
@@ -398,25 +398,25 @@  discard block
 block discarded – undo
398 398
 					0,
399 399
 					$status
400 400
 				);
401
-			} elseif ( isset( $data[0]['errorCode'] ) && '' !== $data[0]['errorCode'] ) { // salesforce uses this structure to return errors
401
+			} elseif (isset($data[0]['errorCode']) && '' !== $data[0]['errorCode']) { // salesforce uses this structure to return errors
402 402
 				// create log entry for failed curl
403 403
 				$status = 'error';
404
-				if ( isset( $this->logging ) ) {
404
+				if (isset($this->logging)) {
405 405
 					$logging = $this->logging;
406
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
407
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
406
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
407
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
408 408
 				}
409 409
 
410 410
 				// translators: placeholder is the server code returned by the api
411
-				$title = sprintf( esc_html__( 'Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce' ),
412
-					absint( $code )
411
+				$title = sprintf(esc_html__('Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce'),
412
+					absint($code)
413 413
 				);
414 414
 
415 415
 				// translators: placeholders are: 1) the URL requested, 2) the message returned by the error, 3) the server code returned
416
-				$body = sprintf( '<p>' . esc_html__( 'URL: %1$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: %2$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Code: %3$s', 'object-sync-for-salesforce' ),
417
-					esc_attr( $url ),
418
-					esc_html( $data[0]['message'] ),
419
-					absint( $code )
416
+				$body = sprintf('<p>' . esc_html__('URL: %1$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: %2$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Code: %3$s', 'object-sync-for-salesforce'),
417
+					esc_attr($url),
418
+					esc_html($data[0]['message']),
419
+					absint($code)
420 420
 				);
421 421
 
422 422
 				$logging->setup(
@@ -429,20 +429,20 @@  discard block
 block discarded – undo
429 429
 			} else {
430 430
 				// create log entry for failed curl
431 431
 				$status = 'error';
432
-				if ( isset( $this->logging ) ) {
432
+				if (isset($this->logging)) {
433 433
 					$logging = $this->logging;
434
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
435
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
434
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
435
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
436 436
 				}
437 437
 
438 438
 				// translators: placeholder is the server code returned by Salesforce
439
-				$title = sprintf( esc_html__( 'Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce' ),
440
-					absint( $code )
439
+				$title = sprintf(esc_html__('Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce'),
440
+					absint($code)
441 441
 				);
442 442
 
443 443
 				$logging->setup(
444 444
 					$title,
445
-					print_r( $data, true ), // log the result because we are debugging the whole api call
445
+					print_r($data, true), // log the result because we are debugging the whole api call
446 446
 					0,
447 447
 					0,
448 448
 					$status
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 			} // End if().
451 451
 		} // End if().
452 452
 
453
-		curl_close( $curl );
453
+		curl_close($curl);
454 454
 
455 455
 		return array(
456 456
 			'json' => $json_response,
@@ -468,14 +468,14 @@  discard block
 block discarded – undo
468 468
 	* @return string
469 469
 	*   Complete URL endpoint for API access.
470 470
 	*/
471
-	public function get_api_endpoint( $api_type = 'rest' ) {
471
+	public function get_api_endpoint($api_type = 'rest') {
472 472
 		// Special handling for apexrest, since it's not in the identity object.
473
-		if ( 'apexrest' === $api_type ) {
473
+		if ('apexrest' === $api_type) {
474 474
 			$url = $this->get_instance_url() . '/services/apexrest/';
475 475
 		} else {
476 476
 			$identity = $this->get_identity();
477
-			$url      = str_replace( '{version}', $this->rest_api_version, $identity['urls'][ $api_type ] );
478
-			if ( '' === $identity ) {
477
+			$url      = str_replace('{version}', $this->rest_api_version, $identity['urls'][$api_type]);
478
+			if ('' === $identity) {
479 479
 				$url = $this->get_instance_url() . '/services/data/v' . $this->rest_api_version . '/';
480 480
 			}
481 481
 		}
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 	* Get the SF instance URL. Useful for linking to objects.
487 487
 	*/
488 488
 	public function get_instance_url() {
489
-		return get_option( 'object_sync_for_salesforce_instance_url', '' );
489
+		return get_option('object_sync_for_salesforce_instance_url', '');
490 490
 	}
491 491
 
492 492
 	/**
@@ -495,15 +495,15 @@  discard block
 block discarded – undo
495 495
 	* @param string $url
496 496
 	*   URL to set.
497 497
 	*/
498
-	protected function set_instance_url( $url ) {
499
-		update_option( 'object_sync_for_salesforce_instance_url', $url );
498
+	protected function set_instance_url($url) {
499
+		update_option('object_sync_for_salesforce_instance_url', $url);
500 500
 	}
501 501
 
502 502
 	/**
503 503
 	* Get the access token.
504 504
 	*/
505 505
 	public function get_access_token() {
506
-		return get_option( 'object_sync_for_salesforce_access_token', '' );
506
+		return get_option('object_sync_for_salesforce_access_token', '');
507 507
 	}
508 508
 
509 509
 	/**
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
 	* @param string $token
515 515
 	*   Access token from Salesforce.
516 516
 	*/
517
-	protected function set_access_token( $token ) {
518
-		update_option( 'object_sync_for_salesforce_access_token', $token );
517
+	protected function set_access_token($token) {
518
+		update_option('object_sync_for_salesforce_access_token', $token);
519 519
 	}
520 520
 
521 521
 	/**
522 522
 	* Get refresh token.
523 523
 	*/
524 524
 	protected function get_refresh_token() {
525
-		return get_option( 'object_sync_for_salesforce_refresh_token', '' );
525
+		return get_option('object_sync_for_salesforce_refresh_token', '');
526 526
 	}
527 527
 
528 528
 	/**
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	* @param string $token
532 532
 	*   Refresh token from Salesforce.
533 533
 	*/
534
-	protected function set_refresh_token( $token ) {
535
-		update_option( 'object_sync_for_salesforce_refresh_token', $token );
534
+	protected function set_refresh_token($token) {
535
+		update_option('object_sync_for_salesforce_refresh_token', $token);
536 536
 	}
537 537
 
538 538
 	/**
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	*/
547 547
 	protected function refresh_token() {
548 548
 		$refresh_token = $this->get_refresh_token();
549
-		if ( empty( $refresh_token ) ) {
550
-			throw new Object_Sync_Sf_Exception( esc_html__( 'There is no refresh token.', 'object-sync-for-salesforce' ) );
549
+		if (empty($refresh_token)) {
550
+			throw new Object_Sync_Sf_Exception(esc_html__('There is no refresh token.', 'object-sync-for-salesforce'));
551 551
 		}
552 552
 
553 553
 		$data = array(
@@ -565,13 +565,13 @@  discard block
 block discarded – undo
565 565
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
566 566
 		);
567 567
 		$headers  = false;
568
-		$response = $this->http_request( $url, $data, $headers, 'POST' );
568
+		$response = $this->http_request($url, $data, $headers, 'POST');
569 569
 
570
-		if ( 200 !== $response['code'] ) {
570
+		if (200 !== $response['code']) {
571 571
 			throw new Object_Sync_Sf_Exception(
572 572
 				esc_html(
573 573
 					sprintf(
574
-						__( 'Unable to get a Salesforce access token. Salesforce returned the following errorCode: ', 'object-sync-for-salesforce' ) . $response['code']
574
+						__('Unable to get a Salesforce access token. Salesforce returned the following errorCode: ', 'object-sync-for-salesforce') . $response['code']
575 575
 					)
576 576
 				),
577 577
 				$response['code']
@@ -580,13 +580,13 @@  discard block
 block discarded – undo
580 580
 
581 581
 		$data = $response['data'];
582 582
 
583
-		if ( is_array( $data ) && isset( $data['error'] ) ) {
584
-			throw new Object_Sync_Sf_Exception( $data['error_description'], $data['error'] );
583
+		if (is_array($data) && isset($data['error'])) {
584
+			throw new Object_Sync_Sf_Exception($data['error_description'], $data['error']);
585 585
 		}
586 586
 
587
-		$this->set_access_token( $data['access_token'] );
588
-		$this->set_identity( $data['id'] );
589
-		$this->set_instance_url( $data['instance_url'] );
587
+		$this->set_access_token($data['access_token']);
588
+		$this->set_identity($data['id']);
589
+		$this->set_instance_url($data['instance_url']);
590 590
 	}
591 591
 
592 592
 	/**
@@ -597,18 +597,18 @@  discard block
 block discarded – undo
597 597
 	*
598 598
 	* @throws Object_Sync_Sf_Exception
599 599
 	*/
600
-	protected function set_identity( $id ) {
601
-		$headers  = array(
600
+	protected function set_identity($id) {
601
+		$headers = array(
602 602
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
603 603
 			//'Content-type'  => 'application/json',
604 604
 			'Accept-Encoding' => 'Accept-Encoding: gzip, deflate',
605 605
 		);
606
-		$response = $this->http_request( $id, null, $headers );
607
-		if ( 200 !== $response['code'] ) {
608
-			throw new Object_Sync_Sf_Exception( esc_html__( 'Unable to access identity service.', 'object-sync-for-salesforce' ), $response['code'] );
606
+		$response = $this->http_request($id, null, $headers);
607
+		if (200 !== $response['code']) {
608
+			throw new Object_Sync_Sf_Exception(esc_html__('Unable to access identity service.', 'object-sync-for-salesforce'), $response['code']);
609 609
 		}
610 610
 		$data = $response['data'];
611
-		update_option( 'object_sync_for_salesforce_identity', $data );
611
+		update_option('object_sync_for_salesforce_identity', $data);
612 612
 	}
613 613
 
614 614
 	/**
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	*   Returns FALSE if no identity has been stored.
619 619
 	*/
620 620
 	public function get_identity() {
621
-		return get_option( 'object_sync_for_salesforce_identity', false );
621
+		return get_option('object_sync_for_salesforce_identity', false);
622 622
 	}
623 623
 
624 624
 	/**
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	* @param string $code
643 643
 	*   Code from Salesforce.
644 644
 	*/
645
-	public function request_token( $code ) {
645
+	public function request_token($code) {
646 646
 		$data = array(
647 647
 			'code'          => $code,
648 648
 			'grant_type'    => 'authorization_code',
@@ -657,28 +657,28 @@  discard block
 block discarded – undo
657 657
 			//'Content-Type'  => 'application/x-www-form-urlencoded',
658 658
 			'Accept-Encoding' => 'Accept-Encoding: gzip, deflate',
659 659
 		);
660
-		$response = $this->http_request( $url, $data, $headers, 'POST' );
660
+		$response = $this->http_request($url, $data, $headers, 'POST');
661 661
 
662 662
 		$data = $response['data'];
663 663
 
664
-		if ( 200 !== $response['code'] ) {
665
-			$error = isset( $data['error_description'] ) ? $data['error_description'] : $response['error'];
666
-			throw new Object_Sync_Sf_Exception( $error, $response['code'] );
664
+		if (200 !== $response['code']) {
665
+			$error = isset($data['error_description']) ? $data['error_description'] : $response['error'];
666
+			throw new Object_Sync_Sf_Exception($error, $response['code']);
667 667
 		}
668 668
 
669 669
 		// Ensure all required attributes are returned. They can be omitted if the
670 670
 		// OAUTH scope is inadequate.
671
-		$required = array( 'refresh_token', 'access_token', 'id', 'instance_url' );
672
-		foreach ( $required as $key ) {
673
-			if ( ! isset( $data[ $key ] ) ) {
671
+		$required = array('refresh_token', 'access_token', 'id', 'instance_url');
672
+		foreach ($required as $key) {
673
+			if ( ! isset($data[$key])) {
674 674
 				return false;
675 675
 			}
676 676
 		}
677 677
 
678
-		$this->set_refresh_token( $data['refresh_token'] );
679
-		$this->set_access_token( $data['access_token'] );
680
-		$this->set_identity( $data['id'] );
681
-		$this->set_instance_url( $data['instance_url'] );
678
+		$this->set_refresh_token($data['refresh_token']);
679
+		$this->set_access_token($data['access_token']);
680
+		$this->set_identity($data['id']);
681
+		$this->set_instance_url($data['instance_url']);
682 682
 
683 683
 		return true;
684 684
 	}
@@ -713,19 +713,19 @@  discard block
 block discarded – undo
713 713
 		$options = array(
714 714
 			'reset' => $reset,
715 715
 		);
716
-		$result  = $this->api_call( 'sobjects', array(), 'GET', $options );
716
+		$result  = $this->api_call('sobjects', array(), 'GET', $options);
717 717
 
718
-		if ( ! empty( $conditions ) ) {
719
-			foreach ( $result['data']['sobjects'] as $key => $object ) {
720
-				foreach ( $conditions as $condition => $value ) {
721
-					if ( $object[ $condition ] !== $value ) {
722
-						unset( $result['data']['sobjects'][ $key ] );
718
+		if ( ! empty($conditions)) {
719
+			foreach ($result['data']['sobjects'] as $key => $object) {
720
+				foreach ($conditions as $condition => $value) {
721
+					if ($object[$condition] !== $value) {
722
+						unset($result['data']['sobjects'][$key]);
723 723
 					}
724 724
 				}
725 725
 			}
726 726
 		}
727 727
 
728
-		ksort( $result['data']['sobjects'] );
728
+		ksort($result['data']['sobjects']);
729 729
 
730 730
 		return $result['data']['sobjects'];
731 731
 	}
@@ -747,21 +747,21 @@  discard block
 block discarded – undo
747 747
 	*
748 748
 	* part of core API calls
749 749
 	*/
750
-	public function query( $query, $options = array(), $all = false, $explain = false ) {
750
+	public function query($query, $options = array(), $all = false, $explain = false) {
751 751
 		$search_data = [
752 752
 			'q' => (string) $query,
753 753
 		];
754
-		if ( true === $explain ) {
754
+		if (true === $explain) {
755 755
 			$search_data['explain'] = $search_data['q'];
756
-			unset( $search_data['q'] );
756
+			unset($search_data['q']);
757 757
 		}
758 758
 		// all is a search through deleted and merged data as well
759
-		if ( true === $all ) {
759
+		if (true === $all) {
760 760
 			$path = 'queryAll';
761 761
 		} else {
762 762
 			$path = 'query';
763 763
 		}
764
-		$result = $this->api_call( $path . '?' . http_build_query( $search_data ), array(), 'GET', $options );
764
+		$result = $this->api_call($path . '?' . http_build_query($search_data), array(), 'GET', $options);
765 765
 		return $result;
766 766
 	}
767 767
 
@@ -779,28 +779,28 @@  discard block
 block discarded – undo
779 779
 	*
780 780
 	* part of core API calls
781 781
 	*/
782
-	public function object_describe( $name, $reset = false ) {
783
-		if ( empty( $name ) ) {
782
+	public function object_describe($name, $reset = false) {
783
+		if (empty($name)) {
784 784
 			return array();
785 785
 		}
786 786
 		$options = array(
787 787
 			'reset' => $reset,
788 788
 		);
789
-		$object  = $this->api_call( "sobjects/{$name}/describe", array(), 'GET', $options );
789
+		$object  = $this->api_call("sobjects/{$name}/describe", array(), 'GET', $options);
790 790
 		// Sort field properties, because salesforce API always provides them in a
791 791
 		// random order. We sort them so that stored and exported data are
792 792
 		// standardized and predictable.
793 793
 		$fields = array();
794
-		foreach ( $object['data']['fields'] as &$field ) {
795
-			ksort( $field );
796
-			if ( ! empty( $field['picklistValues'] ) ) {
797
-				foreach ( $field['picklistValues'] as &$picklist_value ) {
798
-					ksort( $picklist_value );
794
+		foreach ($object['data']['fields'] as &$field) {
795
+			ksort($field);
796
+			if ( ! empty($field['picklistValues'])) {
797
+				foreach ($field['picklistValues'] as &$picklist_value) {
798
+					ksort($picklist_value);
799 799
 				}
800 800
 			}
801
-			$fields[ $field['name'] ] = $field;
801
+			$fields[$field['name']] = $field;
802 802
 		}
803
-		ksort( $fields );
803
+		ksort($fields);
804 804
 		$object['fields'] = $fields;
805 805
 		return $object;
806 806
 	}
@@ -826,11 +826,11 @@  discard block
 block discarded – undo
826 826
 	*
827 827
 	* part of core API calls
828 828
 	*/
829
-	public function object_create( $name, $params ) {
829
+	public function object_create($name, $params) {
830 830
 		$options = array(
831 831
 			'type' => 'write',
832 832
 		);
833
-		$result  = $this->api_call( "sobjects/{$name}", $params, 'POST', $options );
833
+		$result  = $this->api_call("sobjects/{$name}", $params, 'POST', $options);
834 834
 		return $result;
835 835
 	}
836 836
 
@@ -863,22 +863,22 @@  discard block
 block discarded – undo
863 863
 	*
864 864
 	* part of core API calls
865 865
 	*/
866
-	public function object_upsert( $name, $key, $value, $params ) {
866
+	public function object_upsert($name, $key, $value, $params) {
867 867
 		$options = array(
868 868
 			'type' => 'write',
869 869
 		);
870 870
 		// If key is set, remove from $params to avoid UPSERT errors.
871
-		if ( isset( $params[ $key ] ) ) {
872
-			unset( $params[ $key ] );
871
+		if (isset($params[$key])) {
872
+			unset($params[$key]);
873 873
 		}
874 874
 
875 875
 		// allow developers to change both the key and value by which objects should be matched
876
-		$key   = apply_filters( 'object_sync_for_salesforce_modify_upsert_key', $key );
877
-		$value = apply_filters( 'object_sync_for_salesforce_modify_upsert_value', $value );
876
+		$key   = apply_filters('object_sync_for_salesforce_modify_upsert_key', $key);
877
+		$value = apply_filters('object_sync_for_salesforce_modify_upsert_value', $value);
878 878
 
879
-		$data = $this->api_call( "sobjects/{$name}/{$key}/{$value}", $params, 'PATCH', $options );
880
-		if ( 300 === $this->response['code'] ) {
881
-			$data['message'] = esc_html( 'The value provided is not unique.' );
879
+		$data = $this->api_call("sobjects/{$name}/{$key}/{$value}", $params, 'PATCH', $options);
880
+		if (300 === $this->response['code']) {
881
+			$data['message'] = esc_html('The value provided is not unique.');
882 882
 		}
883 883
 		return $data;
884 884
 	}
@@ -905,11 +905,11 @@  discard block
 block discarded – undo
905 905
 	*   cached:
906 906
 	*   is_redo:
907 907
 	*/
908
-	public function object_update( $name, $id, $params ) {
908
+	public function object_update($name, $id, $params) {
909 909
 		$options = array(
910 910
 			'type' => 'write',
911 911
 		);
912
-		$result  = $this->api_call( "sobjects/{$name}/{$id}", $params, 'PATCH', $options );
912
+		$result  = $this->api_call("sobjects/{$name}/{$id}", $params, 'PATCH', $options);
913 913
 		return $result;
914 914
 	}
915 915
 
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	*
927 927
 	* part of core API calls
928 928
 	*/
929
-	public function object_read( $name, $id ) {
930
-		return $this->api_call( "sobjects/{$name}/{$id}", array(), 'GET' );
929
+	public function object_read($name, $id) {
930
+		return $this->api_call("sobjects/{$name}/{$id}", array(), 'GET');
931 931
 	}
932 932
 
933 933
 	/**
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	*
950 950
 	* part of core API calls
951 951
 	*/
952
-	public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
953
-		return $this->api_call( "analytics/{$name}/{$id}/{$route}", $params, $method );
952
+	public function analytics_api($name, $id, $route = '', $params = array(), $method = 'GET') {
953
+		return $this->api_call("analytics/{$name}/{$id}/{$route}", $params, $method);
954 954
 	}
955 955
 
956 956
 	/**
@@ -970,19 +970,19 @@  discard block
 block discarded – undo
970 970
 	*
971 971
 	* part of core API calls
972 972
 	*/
973
-	public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
973
+	public function run_analytics_report($id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '') {
974 974
 
975
-		$id         = $this->convert_id( $id );
975
+		$id         = $this->convert_id($id);
976 976
 		$report_url = 'analytics/reports/' . $id . '/' . 'instances';
977 977
 
978
-		if ( true === $clear_cache ) {
979
-			delete_transient( $report_url );
978
+		if (true === $clear_cache) {
979
+			delete_transient($report_url);
980 980
 		}
981 981
 
982
-		$instance_id = $this->wordpress->cache_get( $report_url, '' );
982
+		$instance_id = $this->wordpress->cache_get($report_url, '');
983 983
 
984 984
 		// there is no stored instance id or this is synchronous; retrieve the results for that instance
985
-		if ( false === $async || false === $instance_id ) {
985
+		if (false === $async || false === $instance_id) {
986 986
 
987 987
 			$result = $this->analytics_api(
988 988
 				'reports',
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 				'GET'
993 993
 			);
994 994
 			// if we get a reportmetadata array out of this, continue
995
-			if ( is_array( $result['data']['reportMetadata'] ) ) {
995
+			if (is_array($result['data']['reportMetadata'])) {
996 996
 				$params = array(
997 997
 					'reportMetadata' => $result['data']['reportMetadata'],
998 998
 				);
@@ -1004,48 +1004,48 @@  discard block
 block discarded – undo
1004 1004
 					'POST'
1005 1005
 				);
1006 1006
 				// if we get an id from the post, that is the instance id
1007
-				if ( isset( $report['data']['id'] ) ) {
1007
+				if (isset($report['data']['id'])) {
1008 1008
 					$instance_id = $report['data']['id'];
1009 1009
 				} else {
1010 1010
 					// run the call again if we don't have an instance id
1011 1011
 					//error_log('run report again. we have no instance id.');
1012
-					$this->run_analytics_report( $id, true );
1012
+					$this->run_analytics_report($id, true);
1013 1013
 				}
1014 1014
 
1015 1015
 				// cache the instance id so we can get the report results if they are applicable
1016
-				if ( '' === $report_cache_expiration ) {
1016
+				if ('' === $report_cache_expiration) {
1017 1017
 					$report_cache_expiration = $this->cache_expiration();
1018 1018
 				}
1019
-				$this->wordpress->cache_set( $report_url, '', $instance_id, $report_cache_expiration );
1019
+				$this->wordpress->cache_set($report_url, '', $instance_id, $report_cache_expiration);
1020 1020
 			} else {
1021 1021
 				// run the call again if we don't have a reportMetadata array
1022 1022
 				//error_log('run report again. we have no reportmetadata.');
1023
-				$this->run_analytics_report( $id, true );
1023
+				$this->run_analytics_report($id, true);
1024 1024
 			}
1025 1025
 		} // End if().
1026 1026
 
1027
-		$result = $this->api_call( $report_url . "/{$instance_id}", array(), $method );
1027
+		$result = $this->api_call($report_url . "/{$instance_id}", array(), $method);
1028 1028
 
1029 1029
 		// the report instance is expired. rerun it.
1030
-		if ( 404 === $result['code'] ) {
1030
+		if (404 === $result['code']) {
1031 1031
 			//error_log('run report again. it expired.');
1032
-			$this->run_analytics_report( $id, true, true );
1032
+			$this->run_analytics_report($id, true, true);
1033 1033
 		}
1034 1034
 
1035 1035
 		// cache the instance results as a long fallback if the setting says so
1036 1036
 		// do this because salesforce will have errors if the instance has expired or is currently running
1037 1037
 		// remember: the result of the above api_call is already cached (or not) according to the plugin's generic settings
1038 1038
 		// this is fine I think, although it is a bit of redundancy in this case
1039
-		if ( true === $cache_instance ) {
1040
-			$cached = $this->wordpress->cache_get( $report_url . '_instance_cached', '' );
1041
-			if ( is_array( $cached ) ) {
1039
+		if (true === $cache_instance) {
1040
+			$cached = $this->wordpress->cache_get($report_url . '_instance_cached', '');
1041
+			if (is_array($cached)) {
1042 1042
 				$result = $cached;
1043 1043
 			} else {
1044
-				if ( 'Success' === $result['data']['attributes']['status'] ) {
1045
-					if ( '' === $instance_cache_expiration ) {
1044
+				if ('Success' === $result['data']['attributes']['status']) {
1045
+					if ('' === $instance_cache_expiration) {
1046 1046
 						$instance_cache_expiration = $this->cache_expiration();
1047 1047
 					}
1048
-					$this->wordpress->cache_set( $report_url . '_instance_cached', '', $result, $instance_cache_expiration );
1048
+					$this->wordpress->cache_set($report_url . '_instance_cached', '', $result, $instance_cache_expiration);
1049 1049
 				}
1050 1050
 			}
1051 1051
 		}
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 	*
1070 1070
 	* part of core API calls
1071 1071
 	*/
1072
-	public function object_readby_external_id( $name, $field, $value ) {
1073
-		return $this->api_call( "sobjects/{$name}/{$field}/{$value}" );
1072
+	public function object_readby_external_id($name, $field, $value) {
1073
+		return $this->api_call("sobjects/{$name}/{$field}/{$value}");
1074 1074
 	}
1075 1075
 
1076 1076
 	/**
@@ -1085,11 +1085,11 @@  discard block
 block discarded – undo
1085 1085
 	*
1086 1086
 	* part of core API calls
1087 1087
 	*/
1088
-	public function object_delete( $name, $id ) {
1088
+	public function object_delete($name, $id) {
1089 1089
 		$options = array(
1090 1090
 			'type' => 'write',
1091 1091
 		);
1092
-		$result  = $this->api_call( "sobjects/{$name}/{$id}", array(), 'DELETE', $options );
1092
+		$result  = $this->api_call("sobjects/{$name}/{$id}", array(), 'DELETE', $options);
1093 1093
 		return $result;
1094 1094
 	}
1095 1095
 
@@ -1105,11 +1105,11 @@  discard block
 block discarded – undo
1105 1105
 	*   End date to check for deleted objects (in ISO 8601 format).
1106 1106
 	* @return GetDeletedResult
1107 1107
 	*/
1108
-	public function get_deleted( $type, $start_date, $end_date ) {
1108
+	public function get_deleted($type, $start_date, $end_date) {
1109 1109
 		$options = array(
1110 1110
 			'cache' => false,
1111 1111
 		); // this is timestamp level specific; probably should not cache it
1112
-		return $this->api_call( "sobjects/{$type}/deleted/?start={$start_date}&end={$end_date}", array(), 'GET', $options );
1112
+		return $this->api_call("sobjects/{$type}/deleted/?start={$start_date}&end={$end_date}", array(), 'GET', $options);
1113 1113
 	}
1114 1114
 
1115 1115
 
@@ -1122,9 +1122,9 @@  discard block
 block discarded – undo
1122 1122
 	* part of core API calls
1123 1123
 	*/
1124 1124
 	public function list_resources() {
1125
-		$resources = $this->api_call( '' );
1126
-		foreach ( $resources as $key => $path ) {
1127
-			$items[ $key ] = $path;
1125
+		$resources = $this->api_call('');
1126
+		foreach ($resources as $key => $path) {
1127
+			$items[$key] = $path;
1128 1128
 		}
1129 1129
 		return $items;
1130 1130
 	}
@@ -1155,21 +1155,21 @@  discard block
 block discarded – undo
1155 1155
 	*
1156 1156
 	* part of core API calls
1157 1157
 	*/
1158
-	public function get_updated( $type, $start = null, $end = null ) {
1159
-		if ( empty( $start ) ) {
1160
-			$start = strtotime( '-29 days' );
1158
+	public function get_updated($type, $start = null, $end = null) {
1159
+		if (empty($start)) {
1160
+			$start = strtotime('-29 days');
1161 1161
 		}
1162
-		$start = rawurlencode( gmdate( DATE_ATOM, $start ) );
1162
+		$start = rawurlencode(gmdate(DATE_ATOM, $start));
1163 1163
 
1164
-		if ( empty( $end ) ) {
1164
+		if (empty($end)) {
1165 1165
 			$end = time();
1166 1166
 		}
1167
-		$end = rawurlencode( gmdate( DATE_ATOM, $end ) );
1167
+		$end = rawurlencode(gmdate(DATE_ATOM, $end));
1168 1168
 
1169 1169
 		$options = array(
1170 1170
 			'cache' => false,
1171 1171
 		); // this is timestamp level specific; probably should not cache it
1172
-		return $this->api_call( "sobjects/{$type}/updated/?start=$start&end=$end", array(), 'GET', $options );
1172
+		return $this->api_call("sobjects/{$type}/updated/?start=$start&end=$end", array(), 'GET', $options);
1173 1173
 	}
1174 1174
 
1175 1175
 	/**
@@ -1187,28 +1187,28 @@  discard block
 block discarded – undo
1187 1187
 	*   The Salesforce ID of the given Record Type, or null.
1188 1188
 	*/
1189 1189
 
1190
-	public function get_record_type_id_by_developer_name( $name, $devname, $reset = false ) {
1190
+	public function get_record_type_id_by_developer_name($name, $devname, $reset = false) {
1191 1191
 
1192 1192
 		// example of how this runs: $this->get_record_type_id_by_developer_name( 'Account', 'HH_Account' );
1193 1193
 
1194
-		$cached = $this->wordpress->cache_get( 'salesforce_record_types', '' );
1195
-		if ( is_array( $cached ) && ( ! isset( $reset ) || true !== $reset ) ) {
1196
-			return ! empty( $cached[ $name ][ $devname ] ) ? $cached[ $name ][ $devname ]['Id'] : null;
1194
+		$cached = $this->wordpress->cache_get('salesforce_record_types', '');
1195
+		if (is_array($cached) && ( ! isset($reset) || true !== $reset)) {
1196
+			return ! empty($cached[$name][$devname]) ? $cached[$name][$devname]['Id'] : null;
1197 1197
 		}
1198 1198
 
1199
-		$query         = new Object_Sync_Sf_Salesforce_Select_Query( 'RecordType' );
1200
-		$query->fields = array( 'Id', 'Name', 'DeveloperName', 'SobjectType' );
1199
+		$query         = new Object_Sync_Sf_Salesforce_Select_Query('RecordType');
1200
+		$query->fields = array('Id', 'Name', 'DeveloperName', 'SobjectType');
1201 1201
 
1202
-		$result       = $this->query( $query );
1202
+		$result       = $this->query($query);
1203 1203
 		$record_types = array();
1204 1204
 
1205
-		foreach ( $result['data']['records'] as $record_type ) {
1206
-			$record_types[ $record_type['SobjectType'] ][ $record_type['DeveloperName'] ] = $record_type;
1205
+		foreach ($result['data']['records'] as $record_type) {
1206
+			$record_types[$record_type['SobjectType']][$record_type['DeveloperName']] = $record_type;
1207 1207
 		}
1208 1208
 
1209
-		$cached = $this->wordpress->cache_set( 'salesforce_record_types', '', $record_types, $this->options['cache_expiration'] );
1209
+		$cached = $this->wordpress->cache_set('salesforce_record_types', '', $record_types, $this->options['cache_expiration']);
1210 1210
 
1211
-		return ! empty( $record_types[ $name ][ $devname ] ) ? $record_types[ $name ][ $devname ]['Id'] : null;
1211
+		return ! empty($record_types[$name][$devname]) ? $record_types[$name][$devname]['Id'] : null;
1212 1212
 
1213 1213
 	}
1214 1214
 
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 	*
1219 1219
 	*/
1220 1220
 	private function cache_expiration() {
1221
-		$cache_expiration = $this->wordpress->cache_expiration( 'object_sync_for_salesforce_cache_expiration', 86400 );
1221
+		$cache_expiration = $this->wordpress->cache_expiration('object_sync_for_salesforce_cache_expiration', 86400);
1222 1222
 		return $cache_expiration;
1223 1223
 	}
1224 1224
 
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
  * @package Object_Sync_Salesforce
6 6
  */
7 7
 
8
-$_tests_dir = getenv( 'WP_TESTS_DIR' );
9
-if ( ! $_tests_dir ) {
8
+$_tests_dir = getenv('WP_TESTS_DIR');
9
+if ( ! $_tests_dir) {
10 10
 	$_tests_dir = '/tmp/wordpress-tests-lib';
11 11
 }
12 12
 
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
  * Manually load the plugin being tested.
18 18
  */
19 19
 function _manually_load_plugin() {
20
-	require dirname( dirname( __FILE__ ) ) . '/object-sync-for-salesforce.php';
20
+	require dirname(dirname(__FILE__)) . '/object-sync-for-salesforce.php';
21 21
 }
22
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
22
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
23 23
 
24 24
 // Start up the WP testing environment.
25 25
 require $_tests_dir . '/includes/bootstrap.php';
Please login to merge, or discard this patch.
tests/test-sample.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
15 15
 	 */
16 16
 	function test_sample() {
17 17
 		// Replace this with some actual testing code.
18
-		$this->assertTrue( true );
18
+		$this->assertTrue(true);
19 19
 	}
20 20
 }
Please login to merge, or discard this patch.
classes/wordpress.php 1 patch
Spacing   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -30,26 +30,26 @@  discard block
 block discarded – undo
30 30
 	 * @param object $logging a Object_Sync_Sf_Logging instance.
31 31
 	 * @throws \Exception
32 32
 	 */
33
-	public function __construct( $wpdb, $version, $slug, $mappings, $logging ) {
33
+	public function __construct($wpdb, $version, $slug, $mappings, $logging) {
34 34
 		$this->wpdb     = $wpdb;
35 35
 		$this->version  = $version;
36 36
 		$this->slug     = $slug;
37 37
 		$this->mappings = $mappings;
38 38
 		$this->logging  = $logging;
39 39
 
40
-		add_action( 'admin_init', function() {
40
+		add_action('admin_init', function() {
41 41
 			$this->wordpress_objects = $this->get_object_types();
42 42
 		} );
43 43
 
44 44
 		$this->options = array(
45 45
 			'cache'            => true,
46
-			'cache_expiration' => $this->cache_expiration( 'wordpress_data_cache', 86400 ),
46
+			'cache_expiration' => $this->cache_expiration('wordpress_data_cache', 86400),
47 47
 			'type'             => 'read',
48 48
 		);
49 49
 
50
-		$this->sfwp_transients = new Object_Sync_Sf_WordPress_Transient( 'sfwp_transients' );
50
+		$this->sfwp_transients = new Object_Sync_Sf_WordPress_Transient('sfwp_transients');
51 51
 
52
-		$this->debug = get_option( 'object_sync_for_salesforce_debug_mode', false );
52
+		$this->debug = get_option('object_sync_for_salesforce_debug_mode', false);
53 53
 
54 54
 	}
55 55
 
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
 		*/
78 78
 
79 79
 		// this should include the available object types and send them to the hook
80
-		$wordpress_types_not_posts_include = array( 'user', 'comment', 'category', 'tag' );
81
-		$wordpress_objects                 = array_merge( get_post_types(), $wordpress_types_not_posts_include );
80
+		$wordpress_types_not_posts_include = array('user', 'comment', 'category', 'tag');
81
+		$wordpress_objects                 = array_merge(get_post_types(), $wordpress_types_not_posts_include);
82 82
 		// this should be all the objects
83
-		$wordpress_objects = apply_filters( 'object_sync_for_salesforce_add_more_wordpress_types', $wordpress_objects );
83
+		$wordpress_objects = apply_filters('object_sync_for_salesforce_add_more_wordpress_types', $wordpress_objects);
84 84
 
85 85
 		// by default, only remove the log type we use in this plugin
86
-		$types_to_remove = apply_filters( 'object_sync_for_salesforce_remove_wordpress_types', array( 'wp_log' ) );
86
+		$types_to_remove = apply_filters('object_sync_for_salesforce_remove_wordpress_types', array('wp_log'));
87 87
 
88 88
 		// if the hook filters out any types, remove them from the visible list
89
-		if ( ! empty( $types_to_remove ) ) {
90
-			$wordpress_objects = array_diff( $wordpress_objects, $types_to_remove );
89
+		if ( ! empty($types_to_remove)) {
90
+			$wordpress_objects = array_diff($wordpress_objects, $types_to_remove);
91 91
 		}
92 92
 
93
-		sort( $wordpress_objects );
93
+		sort($wordpress_objects);
94 94
 		return $wordpress_objects;
95 95
 	}
96 96
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 * @param string $object_type The type of object.
101 101
 	 * @return array $object_table_structure The table structure.
102 102
 	 */
103
-	public function get_wordpress_table_structure( $object_type ) {
104
-		if ( 'attachment' === $object_type ) {
103
+	public function get_wordpress_table_structure($object_type) {
104
+		if ('attachment' === $object_type) {
105 105
 			$object_table_structure = array(
106 106
 				'object_name'     => 'post',
107 107
 				'content_methods' => array(
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 				'where'           => 'AND ' . $this->wpdb->prefix . 'posts.post_type = "' . $object_type . '"',
124 124
 				'ignore_keys'     => array(),
125 125
 			);
126
-		} elseif ( 'user' === $object_type ) {
126
+		} elseif ('user' === $object_type) {
127 127
 			// User meta fields need to use update_user_meta for create as well, otherwise it'll just get created twice because apparently when the post is created it's already there.
128 128
 			$object_table_structure = array(
129 129
 				'object_name'     => 'user',
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 					'session_tokens',
151 151
 				),
152 152
 			);
153
-		} elseif ( 'post' === $object_type ) {
153
+		} elseif ('post' === $object_type) {
154 154
 			$object_table_structure = array(
155 155
 				'object_name'     => 'post',
156 156
 				'content_methods' => array(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 				'where'           => 'AND ' . $this->wpdb->prefix . 'posts.post_type = "' . $object_type . '"',
173 173
 				'ignore_keys'     => array(),
174 174
 			);
175
-		} elseif ( 'category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type ) {
175
+		} elseif ('category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type) {
176 176
 			// I am unsure why post_tag wasn't here for so long, but i figure it probably needs to be there.
177 177
 			$object_table_structure = array(
178 178
 				'object_name'     => 'term',
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 				),
191 191
 				'content_table'   => $this->wpdb->prefix . 'terms',
192 192
 				'id_field'        => 'term_id',
193
-				'meta_table'      => array( $this->wpdb->prefix . 'termmeta', $this->wpdb->prefix . 'term_taxonomy' ),
193
+				'meta_table'      => array($this->wpdb->prefix . 'termmeta', $this->wpdb->prefix . 'term_taxonomy'),
194 194
 				'meta_join_field' => 'term_id',
195 195
 				'where'           => '',
196 196
 				'ignore_keys'     => array(),
197 197
 			);
198
-		} elseif ( 'comment' === $object_type ) {
198
+		} elseif ('comment' === $object_type) {
199 199
 			$object_table_structure = array(
200 200
 				'object_name'     => 'comment',
201 201
 				'content_methods' => array(
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 	 * @param string $id_field The field of that object that corresponds with its ID in the database.
252 252
 	 * @return array $object_fields
253 253
 	 */
254
-	public function get_wordpress_object_fields( $wordpress_object, $id_field = 'ID' ) {
254
+	public function get_wordpress_object_fields($wordpress_object, $id_field = 'ID') {
255 255
 
256
-		$object_table_structure = $this->get_wordpress_table_structure( $wordpress_object );
256
+		$object_table_structure = $this->get_wordpress_table_structure($wordpress_object);
257 257
 
258 258
 		$meta_table      = $object_table_structure['meta_table'];
259
-		$meta_methods    = maybe_unserialize( $object_table_structure['meta_methods'] );
259
+		$meta_methods    = maybe_unserialize($object_table_structure['meta_methods']);
260 260
 		$content_table   = $object_table_structure['content_table'];
261
-		$content_methods = maybe_unserialize( $object_table_structure['content_methods'] );
261
+		$content_methods = maybe_unserialize($object_table_structure['content_methods']);
262 262
 		$id_field        = $object_table_structure['id_field'];
263 263
 		$object_name     = $object_table_structure['object_name'];
264 264
 		$where           = $object_table_structure['where'];
@@ -267,23 +267,23 @@  discard block
 block discarded – undo
267 267
 		$object_fields = array();
268 268
 
269 269
 		// Try to find the object fields in cache before acquiring it from other source.
270
-		if ( true === $this->options['cache'] && 'write' !== $this->options['cache'] ) {
271
-			$cached = $this->cache_get( $wordpress_object, array( 'data', 'meta' ) );
272
-			if ( is_array( $cached ) ) {
270
+		if (true === $this->options['cache'] && 'write' !== $this->options['cache']) {
271
+			$cached = $this->cache_get($wordpress_object, array('data', 'meta'));
272
+			if (is_array($cached)) {
273 273
 				$object_fields['data']       = $cached;
274 274
 				$object_fields['from_cache'] = true;
275 275
 				$object_fields['cached']     = true;
276 276
 			} else {
277
-				$object_fields['data'] = $this->object_fields( $object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys );
278
-				if ( ! empty( $object_fields['data'] ) ) {
279
-					$object_fields['cached'] = $this->cache_set( $wordpress_object, array( 'data', 'meta' ), $object_fields['data'], $this->options['cache_expiration'] );
277
+				$object_fields['data'] = $this->object_fields($object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys);
278
+				if ( ! empty($object_fields['data'])) {
279
+					$object_fields['cached'] = $this->cache_set($wordpress_object, array('data', 'meta'), $object_fields['data'], $this->options['cache_expiration']);
280 280
 				} else {
281 281
 					$object_fields['cached'] = false;
282 282
 				}
283 283
 				$object_fields['from_cache'] = false;
284 284
 			}
285 285
 		} else {
286
-			$object_fields['data']       = $this->object_fields( $object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys );
286
+			$object_fields['data']       = $this->object_fields($object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys);
287 287
 			$object_fields['from_cache'] = false;
288 288
 			$object_fields['cached']     = false;
289 289
 		}
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		 *     $object_fields = array( 'data' => array(), 'from_cache' => bool, 'cached' => bool );
295 295
 		 * This is useful for custom objects that do not use the normal metadata table structure.
296 296
 		 */
297
-		$object_fields = apply_filters( 'object_sync_for_salesforce_wordpress_object_fields', $object_fields, $wordpress_object );
297
+		$object_fields = apply_filters('object_sync_for_salesforce_wordpress_object_fields', $object_fields, $wordpress_object);
298 298
 
299 299
 		return $object_fields['data'];
300 300
 
@@ -307,36 +307,36 @@  discard block
 block discarded – undo
307 307
 	 * @param string $object_id The ID of the object.
308 308
 	 * @return array $wordpress_object
309 309
 	 */
310
-	public function get_wordpress_object_data( $object_type, $object_id ) {
310
+	public function get_wordpress_object_data($object_type, $object_id) {
311 311
 
312 312
 		$wordpress_object       = array();
313
-		$object_table_structure = $this->get_wordpress_table_structure( $object_type );
313
+		$object_table_structure = $this->get_wordpress_table_structure($object_type);
314 314
 
315 315
 		$meta_table      = $object_table_structure['meta_table'];
316
-		$meta_methods    = maybe_unserialize( $object_table_structure['meta_methods'] );
316
+		$meta_methods    = maybe_unserialize($object_table_structure['meta_methods']);
317 317
 		$content_table   = $object_table_structure['content_table'];
318
-		$content_methods = maybe_unserialize( $object_table_structure['content_methods'] );
318
+		$content_methods = maybe_unserialize($object_table_structure['content_methods']);
319 319
 		$id_field        = $object_table_structure['id_field'];
320 320
 		$object_name     = $object_table_structure['object_name'];
321 321
 		$where           = $object_table_structure['where'];
322 322
 		$ignore_keys     = $object_table_structure['ignore_keys'];
323 323
 
324
-		if ( 'user' === $object_type ) {
325
-			$data = get_userdata( $object_id );
326
-		} elseif ( 'post' === $object_type || 'attachment' === $object_type ) {
327
-			$data = get_post( $object_id );
328
-		} elseif ( 'category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type ) {
329
-			$data = get_term( $object_id );
330
-		} elseif ( 'comment' === $object_type ) {
331
-			$data = get_comment( $object_id );
324
+		if ('user' === $object_type) {
325
+			$data = get_userdata($object_id);
326
+		} elseif ('post' === $object_type || 'attachment' === $object_type) {
327
+			$data = get_post($object_id);
328
+		} elseif ('category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type) {
329
+			$data = get_term($object_id);
330
+		} elseif ('comment' === $object_type) {
331
+			$data = get_comment($object_id);
332 332
 		} else { // This is for custom post types.
333
-			$data = get_post( $object_id );
333
+			$data = get_post($object_id);
334 334
 		}
335 335
 
336
-		$fields = $this->get_wordpress_object_fields( $object_type );
337
-		foreach ( $fields as $key => $value ) {
336
+		$fields = $this->get_wordpress_object_fields($object_type);
337
+		foreach ($fields as $key => $value) {
338 338
 			$field                      = $value['key'];
339
-			$wordpress_object[ $field ] = $data->{$field};
339
+			$wordpress_object[$field] = $data->{$field};
340 340
 		}
341 341
 
342 342
 		/*
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 			}
353 353
 		*/
354 354
 
355
-		$wordpress_object = apply_filters( 'object_sync_for_salesforce_wordpress_object_data', $wordpress_object );
355
+		$wordpress_object = apply_filters('object_sync_for_salesforce_wordpress_object_data', $wordpress_object);
356 356
 
357 357
 		return $wordpress_object;
358 358
 
@@ -366,16 +366,16 @@  discard block
 block discarded – undo
366 366
 	 * @param array  $args The arguents of the API call.
367 367
 	 * @return $this->sfwp_transients->get $cachekey
368 368
 	 */
369
-	public function cache_get( $url, $args ) {
370
-		if ( is_array( $args ) ) {
369
+	public function cache_get($url, $args) {
370
+		if (is_array($args)) {
371 371
 			$args[] = $url;
372
-			array_multisort( $args );
372
+			array_multisort($args);
373 373
 		} else {
374 374
 			$args .= $url;
375 375
 		}
376 376
 
377
-		$cachekey = md5( wp_json_encode( $args ) );
378
-		return $this->sfwp_transients->get( $cachekey );
377
+		$cachekey = md5(wp_json_encode($args));
378
+		return $this->sfwp_transients->get($cachekey);
379 379
 	}
380 380
 
381 381
 	/**
@@ -388,20 +388,20 @@  discard block
 block discarded – undo
388 388
 	 * @return Bool whether or not the value was set
389 389
 	 * @link https://wordpress.stackexchange.com/questions/174330/transient-storage-location-database-xcache-w3total-cache
390 390
 	 */
391
-	public function cache_set( $url, $args, $data, $cache_expiration = '' ) {
392
-		if ( is_array( $args ) ) {
391
+	public function cache_set($url, $args, $data, $cache_expiration = '') {
392
+		if (is_array($args)) {
393 393
 			$args[] = $url;
394
-			array_multisort( $args );
394
+			array_multisort($args);
395 395
 		} else {
396 396
 			$args .= $url;
397 397
 		}
398
-		$cachekey = md5( wp_json_encode( $args ) );
398
+		$cachekey = md5(wp_json_encode($args));
399 399
 		// Cache_expiration is how long it should be stored in the cache.
400 400
 		// If we didn't give a custom one, use the default.
401
-		if ( '' === $cache_expiration ) {
401
+		if ('' === $cache_expiration) {
402 402
 			$cache_expiration = $this->options['cache_expiration'];
403 403
 		}
404
-		return $this->sfwp_transients->set( $cachekey, $data, $cache_expiration );
404
+		return $this->sfwp_transients->set($cachekey, $data, $cache_expiration);
405 405
 	}
406 406
 
407 407
 	/**
@@ -412,8 +412,8 @@  discard block
 block discarded – undo
412 412
 	 * @param int    $expire The default time after which to expire the cache.
413 413
 	 * @return The cache expiration saved in the database.
414 414
 	 */
415
-	public function cache_expiration( $option_key, $expire ) {
416
-		$cache_expiration = get_option( $option_key, $expire );
415
+	public function cache_expiration($option_key, $expire) {
416
+		$cache_expiration = get_option($option_key, $expire);
417 417
 		return $cache_expiration;
418 418
 	}
419 419
 
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 	 * @param array  $ignore_keys Fields to ignore from the database.
435 435
 	 * @return array $all_fields The fields for the object.
436 436
 	 */
437
-	private function object_fields( $object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys ) {
437
+	private function object_fields($object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys) {
438 438
 		// These two queries load all the fields from the specified object unless they have been specified as ignore fields.
439 439
 		// They also load the fields that are meta_keys from the specified object's meta table.
440 440
 		// Maybe a box for a custom query, since custom fields get done in so many ways.
441 441
 		// Eventually this would be the kind of thing we could use fields api for, if it ever gets done.
442
-		$data_fields      = $this->wpdb->get_col( "DESC {$content_table}", 0 );
443
-		$data_field_types = $this->wpdb->get_col( "DESC {$content_table}", 1 ); // get the database field types
442
+		$data_fields      = $this->wpdb->get_col("DESC {$content_table}", 0);
443
+		$data_field_types = $this->wpdb->get_col("DESC {$content_table}", 1); // get the database field types
444 444
 
445
-		if ( is_array( $meta_table ) ) {
445
+		if (is_array($meta_table)) {
446 446
 			$tax_table  = $meta_table[1];
447 447
 			$meta_table = $meta_table[0];
448 448
 		}
@@ -454,39 +454,39 @@  discard block
 block discarded – undo
454 454
 		WHERE ' . $meta_table . '.meta_key != ""
455 455
 		' . $where . '
456 456
 		';
457
-		$meta_fields = $this->wpdb->get_results( $select_meta );
457
+		$meta_fields = $this->wpdb->get_results($select_meta);
458 458
 		$all_fields  = array();
459 459
 
460
-		foreach ( $data_fields as $key => $value ) {
461
-			if ( ! in_array( $value, $ignore_keys, true ) ) {
460
+		foreach ($data_fields as $key => $value) {
461
+			if ( ! in_array($value, $ignore_keys, true)) {
462 462
 				$all_fields[] = array(
463 463
 					'key'     => $value,
464 464
 					'table'   => $content_table,
465
-					'methods' => serialize( $content_methods ),
466
-					'type'    => $data_field_types[ $key ],
465
+					'methods' => serialize($content_methods),
466
+					'type'    => $data_field_types[$key],
467 467
 				);
468 468
 			}
469 469
 		}
470 470
 
471
-		foreach ( $meta_fields as $key => $value ) {
472
-			if ( ! in_array( $value->meta_key, $ignore_keys, true ) ) {
471
+		foreach ($meta_fields as $key => $value) {
472
+			if ( ! in_array($value->meta_key, $ignore_keys, true)) {
473 473
 				$all_fields[] = array(
474 474
 					'key'     => $value->meta_key,
475 475
 					'table'   => $meta_table,
476
-					'methods' => serialize( $meta_methods ),
476
+					'methods' => serialize($meta_methods),
477 477
 				);
478 478
 			}
479 479
 		}
480 480
 
481
-		if ( 'term' === $object_name ) {
482
-			$taxonomy = $this->wpdb->get_col( "DESC {$tax_table}", 0 );
483
-			foreach ( $taxonomy as $key => $value ) {
484
-				$exists = array_search( $value, array_column( $all_fields, 'key' ), true );
485
-				if ( 0 !== $exists ) {
481
+		if ('term' === $object_name) {
482
+			$taxonomy = $this->wpdb->get_col("DESC {$tax_table}", 0);
483
+			foreach ($taxonomy as $key => $value) {
484
+				$exists = array_search($value, array_column($all_fields, 'key'), true);
485
+				if (0 !== $exists) {
486 486
 					$all_fields[] = array(
487 487
 						'key'     => $value,
488 488
 						'table'   => $tax_table,
489
-						'methods' => serialize( $content_methods ),
489
+						'methods' => serialize($content_methods),
490 490
 					);
491 491
 				}
492 492
 			}
@@ -513,28 +513,28 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * part of CRUD for WordPress objects
515 515
 	 */
516
-	public function object_create( $name, $params ) {
516
+	public function object_create($name, $params) {
517 517
 
518
-		$structure = $this->get_wordpress_table_structure( $name );
518
+		$structure = $this->get_wordpress_table_structure($name);
519 519
 		$id_field  = $structure['id_field'];
520 520
 
521
-		switch ( $name ) {
521
+		switch ($name) {
522 522
 			case 'user':
523
-				$result = $this->user_create( $params, $id_field );
523
+				$result = $this->user_create($params, $id_field);
524 524
 				break;
525 525
 			case 'post':
526
-				$result = $this->post_create( $params, $id_field );
526
+				$result = $this->post_create($params, $id_field);
527 527
 				break;
528 528
 			case 'attachment':
529
-				$result = $this->attachment_create( $params, $id_field );
529
+				$result = $this->attachment_create($params, $id_field);
530 530
 				break;
531 531
 			case 'category':
532 532
 			case 'tag':
533 533
 			case 'post_tag':
534
-				$result = $this->term_create( $params, $name, $id_field );
534
+				$result = $this->term_create($params, $name, $id_field);
535 535
 				break;
536 536
 			case 'comment':
537
-				$result = $this->comment_create( $params, $id_field );
537
+				$result = $this->comment_create($params, $id_field);
538 538
 				break;
539 539
 			default:
540 540
 				/*
@@ -547,14 +547,14 @@  discard block
 block discarded – undo
547 547
 				 * the one param is: array( 'name' => objecttype, 'params' => array_of_params, 'id_field' => idfield )
548 548
 				 */
549 549
 				// Check to see if someone is calling the filter, and apply it if so.
550
-				if ( ! has_filter( 'object_sync_for_salesforce_create_custom_wordpress_item' ) ) {
551
-					$result = $this->post_create( $params, $id_field, $name );
550
+				if ( ! has_filter('object_sync_for_salesforce_create_custom_wordpress_item')) {
551
+					$result = $this->post_create($params, $id_field, $name);
552 552
 				} else {
553
-					$result = apply_filters( 'object_sync_for_salesforce_create_custom_wordpress_item', array(
553
+					$result = apply_filters('object_sync_for_salesforce_create_custom_wordpress_item', array(
554 554
 						'params'   => $params,
555 555
 						'name'     => $name,
556 556
 						'id_field' => $id_field,
557
-					) );
557
+					));
558 558
 				}
559 559
 				break;
560 560
 		} // End switch().
@@ -590,37 +590,37 @@  discard block
 block discarded – undo
590 590
 	 *
591 591
 	 * part of CRUD for WordPress objects
592 592
 	 */
593
-	public function object_upsert( $name, $key, $value, $methods = array(), $params, $push_drafts = false, $check_only = false ) {
593
+	public function object_upsert($name, $key, $value, $methods = array(), $params, $push_drafts = false, $check_only = false) {
594 594
 
595
-		$structure = $this->get_wordpress_table_structure( $name );
595
+		$structure = $this->get_wordpress_table_structure($name);
596 596
 		$id_field  = $structure['id_field'];
597 597
 
598 598
 		// If key is set, remove from $params to avoid SQL errors.
599
-		if ( isset( $params[ $key ] ) ) {
600
-			unset( $params[ $key ] );
599
+		if (isset($params[$key])) {
600
+			unset($params[$key]);
601 601
 		}
602 602
 
603 603
 		// Allow developers to change both the key and value by which objects should be matched.
604
-		$key   = apply_filters( 'object_sync_for_salesforce_modify_upsert_key', $key );
605
-		$value = apply_filters( 'object_sync_for_salesforce_modify_upsert_value', $value );
604
+		$key   = apply_filters('object_sync_for_salesforce_modify_upsert_key', $key);
605
+		$value = apply_filters('object_sync_for_salesforce_modify_upsert_value', $value);
606 606
 
607
-		switch ( $name ) {
607
+		switch ($name) {
608 608
 			case 'user':
609
-				$result = $this->user_upsert( $key, $value, $methods, $params, $id_field, $push_drafts, $check_only );
609
+				$result = $this->user_upsert($key, $value, $methods, $params, $id_field, $push_drafts, $check_only);
610 610
 				break;
611 611
 			case 'post':
612
-				$result = $this->post_upsert( $key, $value, $methods, $params, $id_field, $push_drafts, $name, $check_only );
612
+				$result = $this->post_upsert($key, $value, $methods, $params, $id_field, $push_drafts, $name, $check_only);
613 613
 				break;
614 614
 			case 'attachment':
615
-				$result = $this->attachment_upsert( $key, $value, $methods, $params, $id_field, $check_only );
615
+				$result = $this->attachment_upsert($key, $value, $methods, $params, $id_field, $check_only);
616 616
 				break;
617 617
 			case 'category':
618 618
 			case 'tag':
619 619
 			case 'post_tag':
620
-				$result = $this->term_upsert( $key, $value, $methods, $params, $name, $id_field, $push_drafts, $check_only );
620
+				$result = $this->term_upsert($key, $value, $methods, $params, $name, $id_field, $push_drafts, $check_only);
621 621
 				break;
622 622
 			case 'comment':
623
-				$result = $this->comment_upsert( $key, $value, $methods, $params, $id_field, $push_drafts, $check_only );
623
+				$result = $this->comment_upsert($key, $value, $methods, $params, $id_field, $push_drafts, $check_only);
624 624
 				break;
625 625
 			default:
626 626
 				/*
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
 				 *     array( 'key' => key, 'value' => value, 'methods' => methods, 'params' => array_of_params, 'id_field' => idfield, 'push_drafts' => pushdrafts, 'name' => name, 'check_only' => $check_only )
636 636
 				*/
637 637
 				// Check to see if someone is calling the filter, and apply it if so.
638
-				if ( ! has_filter( 'object_sync_for_salesforce_upsert_custom_wordpress_item' ) ) {
639
-					$result = $this->post_upsert( $key, $value, $methods, $params, $id_field, $push_drafts, $name, $check_only );
638
+				if ( ! has_filter('object_sync_for_salesforce_upsert_custom_wordpress_item')) {
639
+					$result = $this->post_upsert($key, $value, $methods, $params, $id_field, $push_drafts, $name, $check_only);
640 640
 				} else {
641
-					$result = apply_filters( 'object_sync_for_salesforce_upsert_custom_wordpress_item', array(
641
+					$result = apply_filters('object_sync_for_salesforce_upsert_custom_wordpress_item', array(
642 642
 						'key'         => $key,
643 643
 						'value'       => $value,
644 644
 						'methods'     => $methods,
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 						'push_drafts' => $push_drafts,
648 648
 						'name'        => $name,
649 649
 						'check_only'  => $check_only,
650
-					) );
650
+					));
651 651
 				}
652 652
 				break;
653 653
 		} // End switch().
@@ -673,29 +673,29 @@  discard block
 block discarded – undo
673 673
 	 *   cached:
674 674
 	 *   is_redo:
675 675
 	 */
676
-	public function object_update( $name, $id, $params ) {
676
+	public function object_update($name, $id, $params) {
677 677
 
678
-		$structure = $this->get_wordpress_table_structure( $name );
678
+		$structure = $this->get_wordpress_table_structure($name);
679 679
 		$id_field  = $structure['id_field'];
680 680
 
681
-		switch ( $name ) {
681
+		switch ($name) {
682 682
 			case 'user':
683 683
 				// User id does not come through by default, but we need it to pass to wp method.
684
-				$result = $this->user_update( $id, $params, $id_field );
684
+				$result = $this->user_update($id, $params, $id_field);
685 685
 				break;
686 686
 			case 'post':
687
-				$result = $this->post_update( $id, $params, $id_field );
687
+				$result = $this->post_update($id, $params, $id_field);
688 688
 				break;
689 689
 			case 'attachment':
690
-				$result = $this->attachment_update( $id, $params, $id_field );
690
+				$result = $this->attachment_update($id, $params, $id_field);
691 691
 				break;
692 692
 			case 'category':
693 693
 			case 'tag':
694 694
 			case 'post_tag':
695
-				$result = $this->term_update( $id, $params, $name, $id_field );
695
+				$result = $this->term_update($id, $params, $name, $id_field);
696 696
 				break;
697 697
 			case 'comment':
698
-				$result = $this->comment_update( $id, $params, $id_field );
698
+				$result = $this->comment_update($id, $params, $id_field);
699 699
 				break;
700 700
 			default:
701 701
 				/*
@@ -710,15 +710,15 @@  discard block
 block discarded – undo
710 710
 				 *     array( 'key' => key, 'value' => value, 'name' => objecttype, 'params' => array_of_params, 'push_drafts' => pushdrafts, 'methods' => methods )
711 711
 				 */
712 712
 				// Check to see if someone is calling the filter, and apply it if so.
713
-				if ( ! has_filter( 'object_sync_for_salesforce_update_custom_wordpress_item' ) ) {
714
-					$result = $this->post_update( $id, $params, $id_field, $name );
713
+				if ( ! has_filter('object_sync_for_salesforce_update_custom_wordpress_item')) {
714
+					$result = $this->post_update($id, $params, $id_field, $name);
715 715
 				} else {
716
-					$result = apply_filters( 'object_sync_for_salesforce_update_custom_wordpress_item', array(
716
+					$result = apply_filters('object_sync_for_salesforce_update_custom_wordpress_item', array(
717 717
 						'id'       => $id,
718 718
 						'params'   => $params,
719 719
 						'name'     => $name,
720 720
 						'id_field' => $id_field,
721
-					) );
721
+					));
722 722
 				}
723 723
 				break;
724 724
 		} // End switch().
@@ -739,27 +739,27 @@  discard block
 block discarded – undo
739 739
 	 *
740 740
 	 * part of CRUD for WordPress objects
741 741
 	 */
742
-	public function object_delete( $name, $id ) {
743
-		$structure = $this->get_wordpress_table_structure( $name );
742
+	public function object_delete($name, $id) {
743
+		$structure = $this->get_wordpress_table_structure($name);
744 744
 		$id_field  = $structure['id_field'];
745 745
 
746
-		switch ( $name ) {
746
+		switch ($name) {
747 747
 			case 'user':
748
-				$success = $this->user_delete( $id );
748
+				$success = $this->user_delete($id);
749 749
 				break;
750 750
 			case 'post':
751
-				$success = $this->post_delete( $id );
751
+				$success = $this->post_delete($id);
752 752
 				break;
753 753
 			case 'attachment':
754
-				$success = $this->attachment_delete( $id );
754
+				$success = $this->attachment_delete($id);
755 755
 				break;
756 756
 			case 'category':
757 757
 			case 'tag':
758 758
 			case 'post_tag':
759
-				$success = $this->term_delete( $id, $name );
759
+				$success = $this->term_delete($id, $name);
760 760
 				break;
761 761
 			case 'comment':
762
-				$success = $this->comment_delete( $id );
762
+				$success = $this->comment_delete($id);
763 763
 				break;
764 764
 			default:
765 765
 				/*
@@ -771,16 +771,16 @@  discard block
 block discarded – undo
771 771
 				 *     array( 'id' => id, 'name' => objecttype )
772 772
 				 */
773 773
 				// Check to see if someone is calling the filter, and apply it if so.
774
-				if ( ! has_filter( 'object_sync_for_salesforce_delete_custom_wordpress_item' ) ) {
775
-					$success = $this->post_delete( $id );
774
+				if ( ! has_filter('object_sync_for_salesforce_delete_custom_wordpress_item')) {
775
+					$success = $this->post_delete($id);
776 776
 				} else {
777
-					$success = apply_filters( 'object_sync_for_salesforce_delete_custom_wordpress_item', array(
777
+					$success = apply_filters('object_sync_for_salesforce_delete_custom_wordpress_item', array(
778 778
 						'id'   => $id,
779 779
 						'name' => $name,
780
-					) );
780
+					));
781 781
 				}
782 782
 
783
-				$success = $this->post_delete( $id );
783
+				$success = $this->post_delete($id);
784 784
 				break;
785 785
 		} // End switch().
786 786
 
@@ -805,13 +805,13 @@  discard block
 block discarded – undo
805 805
 	 *     success: 1
806 806
 	 *   "errors" : [ ],
807 807
 	 */
808
-	private function user_create( $params, $id_field = 'ID' ) {
808
+	private function user_create($params, $id_field = 'ID') {
809 809
 
810 810
 		// Allow username to be email address or username.
811 811
 		// The username could be autogenerated before this point for the sake of URLs.
812 812
 		$username      = $params['user_email']['value'];
813 813
 		$email_address = $params['user_email']['value'];
814
-		if ( isset( $params['user_login']['value'] ) ) { // User_login is used by username_exists.
814
+		if (isset($params['user_login']['value'])) { // User_login is used by username_exists.
815 815
 			$username = $params['user_login']['value'];
816 816
 		} else {
817 817
 			$params['user_login'] = array(
@@ -822,44 +822,44 @@  discard block
 block discarded – undo
822 822
 		}
823 823
 
824 824
 		// This is a new user.
825
-		if ( false === username_exists( $username ) ) {
825
+		if (false === username_exists($username)) {
826 826
 
827 827
 			// Create the user
828 828
 			// WordPress sends a password reset link so this password doesn't get used, but it does exist in the database, which is helpful to prevent access before the user uses their password reset email.
829 829
 			$params['user_pass'] = array(
830
-				'value'         => wp_generate_password( 12, false ),
830
+				'value'         => wp_generate_password(12, false),
831 831
 				'method_modify' => 'wp_insert_user',
832 832
 				'method_read'   => 'get_user_by',
833 833
 			);
834 834
 			// Load all params with a method_modify of the object structure's content_method into $content
835 835
 			$content   = array();
836
-			$structure = $this->get_wordpress_table_structure( 'user' );
837
-			foreach ( $params as $key => $value ) {
838
-				if ( in_array( $value['method_modify'], $structure['content_methods'] ) ) {
839
-					$content[ $key ] = $value['value'];
840
-					unset( $params[ $key ] );
836
+			$structure = $this->get_wordpress_table_structure('user');
837
+			foreach ($params as $key => $value) {
838
+				if (in_array($value['method_modify'], $structure['content_methods'])) {
839
+					$content[$key] = $value['value'];
840
+					unset($params[$key]);
841 841
 				}
842 842
 			}
843 843
 
844
-			$user_id = wp_insert_user( $content );
844
+			$user_id = wp_insert_user($content);
845 845
 
846
-			if ( is_wp_error( $user_id ) ) {
846
+			if (is_wp_error($user_id)) {
847 847
 				$success = false;
848 848
 				$errors  = $user_id;
849 849
 			} else {
850 850
 				$success = true;
851 851
 				$errors  = array();
852
-				foreach ( $params as $key => $value ) {
852
+				foreach ($params as $key => $value) {
853 853
 					$method = $value['method_modify'];
854 854
 					// we need to provide a way for passing the values in a custom order here
855
-					$meta_id = $method( $user_id, $key, $value['value'] );
856
-					if ( false === $meta_id ) {
855
+					$meta_id = $method($user_id, $key, $value['value']);
856
+					if (false === $meta_id) {
857 857
 						$success  = false;
858 858
 						$errors[] = array(
859 859
 							'message' => sprintf(
860 860
 								// translators: %1$s is a method name.
861
-								esc_html__( 'Tried to upsert meta with method %1$s.', 'object-sync-for-salesforce' ),
862
-								esc_html( $method )
861
+								esc_html__('Tried to upsert meta with method %1$s.', 'object-sync-for-salesforce'),
862
+								esc_html($method)
863 863
 							),
864 864
 							'key'     => $key,
865 865
 							'value'   => $value,
@@ -868,18 +868,18 @@  discard block
 block discarded – undo
868 868
 				}
869 869
 
870 870
 				// Developers can use this hook to set any other user data - permissions, etc.
871
-				do_action( 'object_sync_for_salesforce_set_more_user_data', $user_id, $params, 'create' );
871
+				do_action('object_sync_for_salesforce_set_more_user_data', $user_id, $params, 'create');
872 872
 
873 873
 				// Send notification of new user.
874 874
 				// todo: Figure out what permissions ought to get notifications for this and make sure it works the right way.
875
-				wp_new_user_notification( $user_id, null, 'admin user' );
875
+				wp_new_user_notification($user_id, null, 'admin user');
876 876
 
877 877
 			}
878 878
 		} else {
879
-			$user_id = username_exists( $username );
879
+			$user_id = username_exists($username);
880 880
 		} // End if().
881 881
 
882
-		if ( is_wp_error( $user_id ) ) {
882
+		if (is_wp_error($user_id)) {
883 883
 			$success = false;
884 884
 			$errors  = $user_id;
885 885
 		} else {
@@ -916,47 +916,47 @@  discard block
 block discarded – undo
916 916
 	 *     success: 1
917 917
 	 *   "errors" : [ ],
918 918
 	 */
919
-	private function user_upsert( $key, $value, $methods = array(), $params, $id_field = 'ID', $push_drafts = false, $check_only = false ) {
919
+	private function user_upsert($key, $value, $methods = array(), $params, $id_field = 'ID', $push_drafts = false, $check_only = false) {
920 920
 
921 921
 		// If the key is user_email, we need to make it just email because that is how the WordPress method reads it.
922 922
 		$method = $methods['method_match'];
923
-		if ( '' !== $method ) {
923
+		if ('' !== $method) {
924 924
 			// This should give us the user object.
925
-			$user = $method( str_replace( 'user_', '', $key ), $value );
926
-			if ( isset( $user->{$id_field} ) ) {
925
+			$user = $method(str_replace('user_', '', $key), $value);
926
+			if (isset($user->{$id_field} )) {
927 927
 				// User does exist after checking the matching value. we want its id.
928 928
 				$user_id = $user->{$id_field};
929 929
 
930
-				if ( true === $check_only ) {
930
+				if (true === $check_only) {
931 931
 					// We are just checking to see if there is a match.
932 932
 					return $user_id;
933 933
 				}
934 934
 
935 935
 				// On the prematch fields, we specify the method_update param.
936
-				if ( isset( $methods['method_update'] ) ) {
936
+				if (isset($methods['method_update'])) {
937 937
 					$method = $methods['method_update'];
938 938
 				} else {
939 939
 					$method = $methods['method_modify'];
940 940
 				}
941
-				$params[ $key ] = array(
941
+				$params[$key] = array(
942 942
 					'value'         => $value,
943 943
 					'method_modify' => $method,
944 944
 					'method_read'   => $methods['method_read'],
945 945
 				);
946
-			} elseif ( false === $check_only ) {
946
+			} elseif (false === $check_only) {
947 947
 				// User does not exist after checking the matching value. create it.
948 948
 				// On the prematch fields, we specify the method_create param.
949
-				if ( isset( $methods['method_create'] ) ) {
949
+				if (isset($methods['method_create'])) {
950 950
 					$method = $methods['method_create'];
951 951
 				} else {
952 952
 					$method = $methods['method_modify'];
953 953
 				}
954
-				$params[ $key ] = array(
954
+				$params[$key] = array(
955 955
 					'value'         => $value,
956 956
 					'method_modify' => $method,
957 957
 					'method_read'   => $methods['method_read'],
958 958
 				);
959
-				$result         = $this->user_create( $params );
959
+				$result = $this->user_create($params);
960 960
 				return $result;
961 961
 			} else {
962 962
 				// Check only is true but there's not a user yet.
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			} // End if().
965 965
 		} else {
966 966
 			// There is no method by which to check the user. we can check other ways here.
967
-			$params[ $key ] = array(
967
+			$params[$key] = array(
968 968
 				'value'         => $value,
969 969
 				'method_modify' => $methods['method_modify'],
970 970
 				'method_read'   => $methods['method_read'],
@@ -972,21 +972,21 @@  discard block
 block discarded – undo
972 972
 
973 973
 			// Allow username to be email address or username.
974 974
 			// The username could be autogenerated before this point for the sake of URLs.
975
-			if ( isset( $params['user_email']['value'] ) ) {
975
+			if (isset($params['user_email']['value'])) {
976 976
 				$username      = $params['user_email']['value'];
977 977
 				$email_address = $params['user_email']['value'];
978 978
 			}
979
-			if ( isset( $params['user_login']['value'] ) ) { // user_login is used by username_exists.
979
+			if (isset($params['user_login']['value'])) { // user_login is used by username_exists.
980 980
 				$username = $params['user_login']['value'];
981 981
 			}
982 982
 
983
-			$existing_id = username_exists( $username ); // Returns an id if there is a result.
983
+			$existing_id = username_exists($username); // Returns an id if there is a result.
984 984
 
985 985
 			// User does not exist after more checking. we want to create it.
986
-			if ( false === $existing_id && false === $check_only ) {
987
-				$result = $this->user_create( $params );
986
+			if (false === $existing_id && false === $check_only) {
987
+				$result = $this->user_create($params);
988 988
 				return $result;
989
-			} elseif ( true === $check_only ) {
989
+			} elseif (true === $check_only) {
990 990
 				// We are just checking to see if there is a match.
991 991
 				return $existing_id;
992 992
 			} else {
@@ -995,23 +995,23 @@  discard block
 block discarded – undo
995 995
 			}
996 996
 		} // End if().
997 997
 
998
-		if ( isset( $user_id ) ) {
999
-			foreach ( $params as $key => $value ) {
1000
-				$params[ $key ]['method_modify'] = $methods['method_update'];
998
+		if (isset($user_id)) {
999
+			foreach ($params as $key => $value) {
1000
+				$params[$key]['method_modify'] = $methods['method_update'];
1001 1001
 			}
1002
-			$result = $this->user_update( $user_id, $params );
1002
+			$result = $this->user_update($user_id, $params);
1003 1003
 			return $result;
1004 1004
 		}
1005 1005
 
1006 1006
 		// Create log entry for lack of a user id.
1007
-		if ( isset( $this->logging ) ) {
1007
+		if (isset($this->logging)) {
1008 1008
 			$logging = $this->logging;
1009
-		} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1010
-			$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1009
+		} elseif (class_exists('Object_Sync_Sf_Logging')) {
1010
+			$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1011 1011
 		}
1012 1012
 		$logging->setup(
1013 1013
 			// todo: can we get any more specific about this?
1014
-			esc_html__( 'Error: Users: Tried to run user_upsert, and ended up without a user id', 'object-sync-for-salesforce' ),
1014
+			esc_html__('Error: Users: Tried to run user_upsert, and ended up without a user id', 'object-sync-for-salesforce'),
1015 1015
 			'',
1016 1016
 			0,
1017 1017
 			0,
@@ -1032,28 +1032,28 @@  discard block
 block discarded – undo
1032 1032
 	 *     success: 1
1033 1033
 	 *   "errors" : [ ],
1034 1034
 	 */
1035
-	private function user_update( $user_id, $params, $id_field = 'ID' ) {
1035
+	private function user_update($user_id, $params, $id_field = 'ID') {
1036 1036
 		$content              = array();
1037
-		$content[ $id_field ] = $user_id;
1038
-		foreach ( $params as $key => $value ) {
1039
-			if ( 'wp_update_user' === $value['method_modify'] ) {
1040
-				$content[ $key ] = $value['value'];
1041
-				unset( $params[ $key ] );
1037
+		$content[$id_field] = $user_id;
1038
+		foreach ($params as $key => $value) {
1039
+			if ('wp_update_user' === $value['method_modify']) {
1040
+				$content[$key] = $value['value'];
1041
+				unset($params[$key]);
1042 1042
 			}
1043 1043
 		}
1044 1044
 
1045
-		$user_id = wp_update_user( $content );
1045
+		$user_id = wp_update_user($content);
1046 1046
 
1047
-		if ( is_wp_error( $user_id ) ) {
1047
+		if (is_wp_error($user_id)) {
1048 1048
 			$success = false;
1049 1049
 			$errors  = $user_id;
1050 1050
 		} else {
1051 1051
 			$success = true;
1052 1052
 			$errors  = array();
1053
-			foreach ( $params as $key => $value ) {
1053
+			foreach ($params as $key => $value) {
1054 1054
 				$method  = $value['method_modify'];
1055
-				$meta_id = $method( $user_id, $key, $value['value'] );
1056
-				if ( false === $meta_id ) {
1055
+				$meta_id = $method($user_id, $key, $value['value']);
1056
+				if (false === $meta_id) {
1057 1057
 					$success  = false;
1058 1058
 					$errors[] = array(
1059 1059
 						'key'   => $key,
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 			}
1064 1064
 
1065 1065
 			// Developers can use this hook to set any other user data - permissions, etc.
1066
-			do_action( 'object_sync_for_salesforce_set_more_user_data', $user_id, $params, 'update' );
1066
+			do_action('object_sync_for_salesforce_set_more_user_data', $user_id, $params, 'update');
1067 1067
 
1068 1068
 		}
1069 1069
 
@@ -1085,10 +1085,10 @@  discard block
 block discarded – undo
1085 1085
 	 *
1086 1086
 	 * @return boolean true if successful
1087 1087
 	 */
1088
-	private function user_delete( $id, $reassign = null ) {
1088
+	private function user_delete($id, $reassign = null) {
1089 1089
 		// According to https://codex.wordpress.org/Function_Reference/wp_delete_user we have to include user.php first; otherwise it throws undefined error.
1090
-		require_once( './wp-admin/includes/user.php' );
1091
-		$result = wp_delete_user( $id, $reassign );
1090
+		require_once('./wp-admin/includes/user.php');
1091
+		$result = wp_delete_user($id, $reassign);
1092 1092
 		return $result;
1093 1093
 	}
1094 1094
 
@@ -1105,18 +1105,18 @@  discard block
 block discarded – undo
1105 1105
 	 *     success: 1
1106 1106
 	 *   "errors" : [ ],
1107 1107
 	 */
1108
-	private function post_create( $params, $id_field = 'ID', $post_type = 'post' ) {
1108
+	private function post_create($params, $id_field = 'ID', $post_type = 'post') {
1109 1109
 		// Load all params with a method_modify of the object structure's content_method into $content
1110 1110
 		$content   = array();
1111
-		$structure = $this->get_wordpress_table_structure( $post_type );
1112
-		foreach ( $params as $key => $value ) {
1113
-			if ( in_array( $value['method_modify'], $structure['content_methods'] ) ) {
1114
-				$content[ $key ] = $value['value'];
1115
-				unset( $params[ $key ] );
1111
+		$structure = $this->get_wordpress_table_structure($post_type);
1112
+		foreach ($params as $key => $value) {
1113
+			if (in_array($value['method_modify'], $structure['content_methods'])) {
1114
+				$content[$key] = $value['value'];
1115
+				unset($params[$key]);
1116 1116
 			}
1117 1117
 		}
1118 1118
 
1119
-		if ( '' !== $post_type ) {
1119
+		if ('' !== $post_type) {
1120 1120
 			$content['post_type'] = $post_type;
1121 1121
 		}
1122 1122
 
@@ -1124,31 +1124,31 @@  discard block
 block discarded – undo
1124 1124
 		// I think we should allow this to happen and not make users' data decisions, so
1125 1125
 		// if we're receiving nothing for either of these, create a blank one so it doesn't fail
1126 1126
 		// here we have to use $content because $params has already been unset
1127
-		if ( ! isset( $content['post_title'] ) ) {
1127
+		if ( ! isset($content['post_title'])) {
1128 1128
 			$content['post_title'] = ' ';
1129 1129
 		}
1130
-		if ( ! isset( $content['post_content'] ) ) {
1130
+		if ( ! isset($content['post_content'])) {
1131 1131
 			$content['post_content'] = ' ';
1132 1132
 		}
1133 1133
 
1134
-		$post_id = wp_insert_post( $content, true ); // return an error instead of a 0 id
1134
+		$post_id = wp_insert_post($content, true); // return an error instead of a 0 id
1135 1135
 
1136
-		if ( is_wp_error( $post_id ) ) {
1136
+		if (is_wp_error($post_id)) {
1137 1137
 			$success = false;
1138 1138
 			$errors  = $post_id;
1139 1139
 		} else {
1140 1140
 			$success = true;
1141 1141
 			$errors  = array();
1142 1142
 			// If it's a custom post type, fix the methods.
1143
-			if ( isset( $params['RecordTypeId']['value'] ) ) {
1143
+			if (isset($params['RecordTypeId']['value'])) {
1144 1144
 				$params['RecordTypeId']['method_modify'] = 'update_post_meta';
1145 1145
 				$params['RecordTypeId']['method_read']   = 'get_post_meta';
1146 1146
 			}
1147
-			if ( is_array( $params ) && ! empty( $params ) ) {
1148
-				foreach ( $params as $key => $value ) {
1147
+			if (is_array($params) && ! empty($params)) {
1148
+				foreach ($params as $key => $value) {
1149 1149
 					$method  = $value['method_modify'];
1150
-					$meta_id = $method( $post_id, $key, $value['value'] );
1151
-					if ( false === $meta_id ) {
1150
+					$meta_id = $method($post_id, $key, $value['value']);
1151
+					if (false === $meta_id) {
1152 1152
 						$success  = false;
1153 1153
 						$errors[] = array(
1154 1154
 							'key'   => $key,
@@ -1159,11 +1159,11 @@  discard block
 block discarded – undo
1159 1159
 			}
1160 1160
 
1161 1161
 			// Developers can use this hook to set any other post data.
1162
-			do_action( 'object_sync_for_salesforce_set_more_post_data', $post_id, $params, 'create' );
1162
+			do_action('object_sync_for_salesforce_set_more_post_data', $post_id, $params, 'create');
1163 1163
 
1164 1164
 		}
1165 1165
 
1166
-		if ( is_wp_error( $post_id ) ) {
1166
+		if (is_wp_error($post_id)) {
1167 1167
 			$success = false;
1168 1168
 			$errors  = $post_id;
1169 1169
 		} else {
@@ -1201,68 +1201,68 @@  discard block
 block discarded – undo
1201 1201
 	 *     success: 1
1202 1202
 	 *   "errors" : [ ],
1203 1203
 	 */
1204
-	private function post_upsert( $key, $value, $methods = array(), $params, $id_field = 'ID', $push_drafts = false, $post_type = 'post', $check_only = false ) {
1204
+	private function post_upsert($key, $value, $methods = array(), $params, $id_field = 'ID', $push_drafts = false, $post_type = 'post', $check_only = false) {
1205 1205
 
1206 1206
 		$method = $methods['method_match'];
1207 1207
 
1208
-		if ( '' !== $method ) {
1208
+		if ('' !== $method) {
1209 1209
 			// By default, posts use get_posts as the method. args can be like this.
1210 1210
 			// The args don't really make sense, and are inconsistently documented.
1211 1211
 			// This should give us the post object.
1212 1212
 			$args = array();
1213
-			if ( 'post_title' === $key ) {
1213
+			if ('post_title' === $key) {
1214 1214
 				$params['post_title'] = array(
1215 1215
 					'value'         => $value,
1216 1216
 					'method_modify' => $method,
1217 1217
 					'method_read'   => $methods['method_read'],
1218 1218
 				);
1219
-				$args['name']         = sanitize_title( $value );
1219
+				$args['name'] = sanitize_title($value);
1220 1220
 			} else {
1221
-				$args[ $key ] = $value;
1221
+				$args[$key] = $value;
1222 1222
 			}
1223 1223
 			$args['post_type'] = $post_type;
1224
-			$post_statuses     = array( 'publish' );
1225
-			if ( true === $push_drafts ) {
1224
+			$post_statuses     = array('publish');
1225
+			if (true === $push_drafts) {
1226 1226
 				$post_statuses[] = 'draft';
1227 1227
 			}
1228 1228
 			$args['post_status'] = $post_statuses;
1229 1229
 
1230
-			$posts = $method( $args );
1230
+			$posts = $method($args);
1231 1231
 
1232
-			if ( isset( $posts[0]->{$id_field} ) ) {
1232
+			if (isset($posts[0]->{$id_field} )) {
1233 1233
 				// Post does exist after checking the matching value. We want its id.
1234 1234
 				$post_id = $posts[0]->{$id_field};
1235 1235
 
1236
-				if ( true === $check_only ) {
1236
+				if (true === $check_only) {
1237 1237
 					// We are just checking to see if there is a match.
1238 1238
 					return $post_id;
1239 1239
 				}
1240 1240
 
1241 1241
 				// On the prematch fields, we specify the method_update param.
1242
-				if ( isset( $methods['method_update'] ) ) {
1242
+				if (isset($methods['method_update'])) {
1243 1243
 					$method = $methods['method_update'];
1244 1244
 				} else {
1245 1245
 					$method = $methods['method_modify'];
1246 1246
 				}
1247
-				$params[ $key ] = array(
1247
+				$params[$key] = array(
1248 1248
 					'value'         => $value,
1249 1249
 					'method_modify' => $method,
1250 1250
 					'method_read'   => $methods['method_read'],
1251 1251
 				);
1252
-			} elseif ( false === $check_only ) {
1252
+			} elseif (false === $check_only) {
1253 1253
 				// Post does not exist after checking the matching value. create it.
1254 1254
 				// On the prematch fields, we specify the method_create param.
1255
-				if ( isset( $methods['method_create'] ) ) {
1255
+				if (isset($methods['method_create'])) {
1256 1256
 					$method = $methods['method_create'];
1257 1257
 				} else {
1258 1258
 					$method = $methods['method_modify'];
1259 1259
 				}
1260
-				$params[ $key ] = array(
1260
+				$params[$key] = array(
1261 1261
 					'value'         => $value,
1262 1262
 					'method_modify' => $method,
1263 1263
 					'method_read'   => $methods['method_read'],
1264 1264
 				);
1265
-				$result         = $this->post_create( $params, $id_field, $post_type );
1265
+				$result = $this->post_create($params, $id_field, $post_type);
1266 1266
 				return $result;
1267 1267
 			} else {
1268 1268
 				// Check only is true but there's not a post yet.
@@ -1270,38 +1270,38 @@  discard block
 block discarded – undo
1270 1270
 			} // End if().
1271 1271
 		} else {
1272 1272
 			// There is no method by which to check the post. we can check other ways here.
1273
-			$params[ $key ] = array(
1273
+			$params[$key] = array(
1274 1274
 				'value'         => $value,
1275 1275
 				'method_modify' => $methods['method_modify'],
1276 1276
 				'method_read'   => $methods['method_read'],
1277 1277
 			);
1278 1278
 
1279 1279
 			// If we have a title, use it to check for existing post.
1280
-			if ( isset( $params['post_title']['value'] ) ) {
1280
+			if (isset($params['post_title']['value'])) {
1281 1281
 				$title = $params['post_title']['value'];
1282 1282
 			}
1283 1283
 
1284 1284
 			// If we have content, use it to check for existing post.
1285
-			if ( isset( $params['post_content']['value'] ) ) {
1285
+			if (isset($params['post_content']['value'])) {
1286 1286
 				$content = $params['post_content']['value'];
1287 1287
 			} else {
1288 1288
 				$content = '';
1289 1289
 			}
1290 1290
 
1291 1291
 			// If we have a date, use it to check for existing post.
1292
-			if ( isset( $params['post_date']['value'] ) ) {
1292
+			if (isset($params['post_date']['value'])) {
1293 1293
 				$date = $params['post_date']['value'];
1294 1294
 			} else {
1295 1295
 				$date = '';
1296 1296
 			}
1297 1297
 
1298
-			$existing_id = post_exists( $title, $content, $date ); // Returns an id if there is a result. Returns 0 if not.
1298
+			$existing_id = post_exists($title, $content, $date); // Returns an id if there is a result. Returns 0 if not.
1299 1299
 
1300 1300
 			// Post does not exist after more checking. maybe we want to create it.
1301
-			if ( 0 === $existing_id && false === $check_only ) {
1302
-				$result = $this->post_create( $params, $id_field, $post_type );
1301
+			if (0 === $existing_id && false === $check_only) {
1302
+				$result = $this->post_create($params, $id_field, $post_type);
1303 1303
 				return $result;
1304
-			} elseif ( true === $check_only ) {
1304
+			} elseif (true === $check_only) {
1305 1305
 				// We are just checking to see if there is a match.
1306 1306
 				return $existing_id;
1307 1307
 			} else {
@@ -1313,22 +1313,22 @@  discard block
 block discarded – undo
1313 1313
 
1314 1314
 		} // End if().
1315 1315
 
1316
-		if ( isset( $post_id ) ) {
1317
-			foreach ( $params as $key => $value ) {
1318
-				$params[ $key ]['method_modify'] = $methods['method_update'];
1316
+		if (isset($post_id)) {
1317
+			foreach ($params as $key => $value) {
1318
+				$params[$key]['method_modify'] = $methods['method_update'];
1319 1319
 			}
1320
-			$result = $this->post_update( $post_id, $params, $id_field, $post_type );
1320
+			$result = $this->post_update($post_id, $params, $id_field, $post_type);
1321 1321
 			return $result;
1322 1322
 		}
1323 1323
 		// Create log entry for lack of a post id.
1324
-		if ( isset( $this->logging ) ) {
1324
+		if (isset($this->logging)) {
1325 1325
 			$logging = $this->logging;
1326
-		} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1327
-			$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1326
+		} elseif (class_exists('Object_Sync_Sf_Logging')) {
1327
+			$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1328 1328
 		}
1329 1329
 		$logging->setup(
1330 1330
 			// todo: can we be more explicit here about what post upsert failed?
1331
-			esc_html__( 'Error: Posts: Tried to run post_upsert, and ended up without a post id', 'object-sync-for-salesforce' ),
1331
+			esc_html__('Error: Posts: Tried to run post_upsert, and ended up without a post id', 'object-sync-for-salesforce'),
1332 1332
 			'',
1333 1333
 			0,
1334 1334
 			0,
@@ -1350,38 +1350,38 @@  discard block
 block discarded – undo
1350 1350
 	 *     success: 1
1351 1351
 	 *   "errors" : [ ],
1352 1352
 	 */
1353
-	private function post_update( $post_id, $params, $id_field = 'ID', $post_type = '' ) {
1353
+	private function post_update($post_id, $params, $id_field = 'ID', $post_type = '') {
1354 1354
 		$content              = array();
1355
-		$content[ $id_field ] = $post_id;
1356
-		foreach ( $params as $key => $value ) {
1357
-			if ( 'wp_update_post' === $value['method_modify'] ) {
1358
-				$content[ $key ] = $value['value'];
1359
-				unset( $params[ $key ] );
1355
+		$content[$id_field] = $post_id;
1356
+		foreach ($params as $key => $value) {
1357
+			if ('wp_update_post' === $value['method_modify']) {
1358
+				$content[$key] = $value['value'];
1359
+				unset($params[$key]);
1360 1360
 			}
1361 1361
 		}
1362 1362
 
1363
-		if ( '' !== $post_type ) {
1363
+		if ('' !== $post_type) {
1364 1364
 			$content['post_type'] = $post_type;
1365 1365
 		}
1366 1366
 
1367
-		$post_id = wp_update_post( $content, true ); // return an error instead of a 0 id
1367
+		$post_id = wp_update_post($content, true); // return an error instead of a 0 id
1368 1368
 
1369
-		if ( is_wp_error( $post_id ) ) {
1369
+		if (is_wp_error($post_id)) {
1370 1370
 			$success = false;
1371 1371
 			$errors  = $post_id;
1372 1372
 		} else {
1373 1373
 			$success = true;
1374 1374
 			$errors  = array();
1375 1375
 			// If it's a custom post type, fix the methods.
1376
-			if ( isset( $params['RecordTypeId']['value'] ) ) {
1376
+			if (isset($params['RecordTypeId']['value'])) {
1377 1377
 				$params['RecordTypeId']['method_modify'] = 'update_post_meta';
1378 1378
 				$params['RecordTypeId']['method_read']   = 'get_post_meta';
1379 1379
 			}
1380
-			if ( is_array( $params ) && ! empty( $params ) ) {
1381
-				foreach ( $params as $key => $value ) {
1380
+			if (is_array($params) && ! empty($params)) {
1381
+				foreach ($params as $key => $value) {
1382 1382
 					$method  = $value['method_modify'];
1383
-					$meta_id = $method( $post_id, $key, $value['value'] );
1384
-					if ( false === $meta_id ) {
1383
+					$meta_id = $method($post_id, $key, $value['value']);
1384
+					if (false === $meta_id) {
1385 1385
 						$success  = false;
1386 1386
 						$errors[] = array(
1387 1387
 							'key'   => $key,
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 			}
1393 1393
 
1394 1394
 			// Developers can use this hook to set any other post data.
1395
-			do_action( 'object_sync_for_salesforce_set_more_post_data', $post_id, $params, 'update' );
1395
+			do_action('object_sync_for_salesforce_set_more_post_data', $post_id, $params, 'update');
1396 1396
 
1397 1397
 		}
1398 1398
 
@@ -1414,8 +1414,8 @@  discard block
 block discarded – undo
1414 1414
 	 *
1415 1415
 	 * @return mixed post object if successful, false if failed
1416 1416
 	 */
1417
-	private function post_delete( $id, $force_delete = false ) {
1418
-		$result = wp_delete_post( $id, $force_delete );
1417
+	private function post_delete($id, $force_delete = false) {
1418
+		$result = wp_delete_post($id, $force_delete);
1419 1419
 		return $result;
1420 1420
 	}
1421 1421
 
@@ -1431,56 +1431,56 @@  discard block
 block discarded – undo
1431 1431
 	 *     success: 1
1432 1432
 	 *   "errors" : [ ],
1433 1433
 	 */
1434
-	private function attachment_create( $params, $id_field = 'ID' ) {
1434
+	private function attachment_create($params, $id_field = 'ID') {
1435 1435
 		// Load all params with a method_modify of the object structure's content_method into $content
1436 1436
 		$content   = array();
1437
-		$structure = $this->get_wordpress_table_structure( 'attachment' );
1437
+		$structure = $this->get_wordpress_table_structure('attachment');
1438 1438
 		// WP requires post_title, post_content (can be empty), post_status, and post_mime_type to create an attachment.
1439
-		foreach ( $params as $key => $value ) {
1440
-			if ( in_array( $value['method_modify'], $structure['content_methods'] ) ) {
1441
-				$content[ $key ] = $value['value'];
1442
-				unset( $params[ $key ] );
1439
+		foreach ($params as $key => $value) {
1440
+			if (in_array($value['method_modify'], $structure['content_methods'])) {
1441
+				$content[$key] = $value['value'];
1442
+				unset($params[$key]);
1443 1443
 			}
1444 1444
 		}
1445 1445
 
1446 1446
 		// Developers can use this hook to pass filename and parent data for the attachment.
1447
-		$params = apply_filters( 'object_sync_for_salesforce_set_initial_attachment_data', $params );
1447
+		$params = apply_filters('object_sync_for_salesforce_set_initial_attachment_data', $params);
1448 1448
 
1449
-		if ( isset( $params['filename']['value'] ) ) {
1449
+		if (isset($params['filename']['value'])) {
1450 1450
 			$filename = $params['filename']['value'];
1451 1451
 		} else {
1452 1452
 			$filename = false;
1453 1453
 		}
1454 1454
 
1455
-		if ( isset( $params['parent']['value'] ) ) {
1455
+		if (isset($params['parent']['value'])) {
1456 1456
 			$parent = $params['parent']['value'];
1457 1457
 		} else {
1458 1458
 			$parent = 0;
1459 1459
 		}
1460 1460
 
1461
-		$attachment_id = wp_insert_attachment( $content, $filename, $parent );
1461
+		$attachment_id = wp_insert_attachment($content, $filename, $parent);
1462 1462
 
1463
-		if ( is_wp_error( $attachment_id ) ) {
1463
+		if (is_wp_error($attachment_id)) {
1464 1464
 			$success = false;
1465 1465
 			$errors  = $attachment_id;
1466 1466
 		} else {
1467 1467
 			$success = true;
1468 1468
 			$errors  = array();
1469 1469
 
1470
-			if ( false !== $filename ) {
1470
+			if (false !== $filename) {
1471 1471
 				// According to https://codex.wordpress.org/Function_Reference/wp_insert_attachment we need this file.
1472
-				require_once( ABSPATH . 'wp-admin/includes/image.php' );
1472
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
1473 1473
 				// Generate metadata for the attachment.
1474
-				$attach_data = wp_generate_attachment_metadata( $attachment_id, $filename );
1475
-				wp_update_attachment_metadata( $attachment_id, $attach_data );
1474
+				$attach_data = wp_generate_attachment_metadata($attachment_id, $filename);
1475
+				wp_update_attachment_metadata($attachment_id, $attach_data);
1476 1476
 			}
1477 1477
 
1478
-			if ( 0 !== $parent ) {
1479
-				set_post_thumbnail( $parent_post_id, $attachment_id );
1478
+			if (0 !== $parent) {
1479
+				set_post_thumbnail($parent_post_id, $attachment_id);
1480 1480
 			}
1481 1481
 
1482 1482
 			// Developers can use this hook to set any other attachment data.
1483
-			do_action( 'object_sync_for_salesforce_set_more_attachment_data', $attachment_id, $params, 'create' );
1483
+			do_action('object_sync_for_salesforce_set_more_attachment_data', $attachment_id, $params, 'create');
1484 1484
 
1485 1485
 		}
1486 1486
 
@@ -1512,64 +1512,64 @@  discard block
 block discarded – undo
1512 1512
 	 *     success: 1
1513 1513
 	 *   "errors" : [ ],
1514 1514
 	 */
1515
-	private function attachment_upsert( $key, $value, $methods = array(), $params, $id_field = 'ID', $check_only = false ) {
1515
+	private function attachment_upsert($key, $value, $methods = array(), $params, $id_field = 'ID', $check_only = false) {
1516 1516
 
1517 1517
 		$method = $methods['method_match'];
1518 1518
 
1519
-		if ( '' !== $method ) {
1519
+		if ('' !== $method) {
1520 1520
 			// Get_posts is more helpful here, so that is the method attachment uses for 'read'.
1521 1521
 			// By default, posts use get_posts as the method. args can be like this.
1522 1522
 			// The args don't really make sense, and are inconsistently documented.
1523 1523
 			// This should give us the post object.
1524 1524
 			$args = array();
1525
-			if ( 'post_title' === $key ) {
1525
+			if ('post_title' === $key) {
1526 1526
 				$params['post_title'] = array(
1527 1527
 					'value'         => $value,
1528 1528
 					'method_modify' => $method,
1529 1529
 					'method_read'   => $methods['method_read'],
1530 1530
 				);
1531
-				$args['name']         = sanitize_title( $value );
1531
+				$args['name'] = sanitize_title($value);
1532 1532
 			} else {
1533
-				$args[ $key ] = $value;
1533
+				$args[$key] = $value;
1534 1534
 			}
1535 1535
 			$args['post_type'] = 'attachment';
1536 1536
 
1537
-			$posts = $method( $args );
1537
+			$posts = $method($args);
1538 1538
 
1539
-			if ( isset( $posts[0]->{$id_field} ) ) {
1539
+			if (isset($posts[0]->{$id_field} )) {
1540 1540
 				// Attachment does exist after checking the matching value. we want its id.
1541 1541
 				$attachment_id = $posts[0]->{$id_field};
1542 1542
 
1543
-				if ( true === $check_only ) {
1543
+				if (true === $check_only) {
1544 1544
 					// We are just checking to see if there is a match.
1545 1545
 					return $attachment_id;
1546 1546
 				}
1547 1547
 
1548 1548
 				// On the prematch fields, we specify the method_update param.
1549
-				if ( isset( $methods['method_update'] ) ) {
1549
+				if (isset($methods['method_update'])) {
1550 1550
 					$method = $methods['method_update'];
1551 1551
 				} else {
1552 1552
 					$method = $methods['method_modify'];
1553 1553
 				}
1554
-				$params[ $key ] = array(
1554
+				$params[$key] = array(
1555 1555
 					'value'         => $value,
1556 1556
 					'method_modify' => $method,
1557 1557
 					'method_read'   => $methods['method_read'],
1558 1558
 				);
1559
-			} elseif ( false === $check_only ) {
1559
+			} elseif (false === $check_only) {
1560 1560
 				// Attachment does not exist after checking the matching value. create it.
1561 1561
 				// On the prematch fields, we specify the method_create param.
1562
-				if ( isset( $methods['method_create'] ) ) {
1562
+				if (isset($methods['method_create'])) {
1563 1563
 					$method = $methods['method_create'];
1564 1564
 				} else {
1565 1565
 					$method = $methods['method_modify'];
1566 1566
 				}
1567
-				$params[ $key ] = array(
1567
+				$params[$key] = array(
1568 1568
 					'value'         => $value,
1569 1569
 					'method_modify' => $method,
1570 1570
 					'method_read'   => $methods['method_read'],
1571 1571
 				);
1572
-				$result         = $this->attachment_create( $params );
1572
+				$result = $this->attachment_create($params);
1573 1573
 				return $result;
1574 1574
 			} else {
1575 1575
 				// Check only is true but there's not an attachment yet.
@@ -1577,38 +1577,38 @@  discard block
 block discarded – undo
1577 1577
 			} // End if().
1578 1578
 		} else {
1579 1579
 			// There is no method by which to check the post. we can check other ways here.
1580
-			$params[ $key ] = array(
1580
+			$params[$key] = array(
1581 1581
 				'value'         => $value,
1582 1582
 				'method_modify' => $methods['method_modify'],
1583 1583
 				'method_read'   => $methods['method_read'],
1584 1584
 			);
1585 1585
 
1586 1586
 			// If we have a title, use it to check for existing post.
1587
-			if ( isset( $params['post_title']['value'] ) ) {
1587
+			if (isset($params['post_title']['value'])) {
1588 1588
 				$title = $params['post_title']['value'];
1589 1589
 			}
1590 1590
 
1591 1591
 			// If we have content, use it to check for existing post.
1592
-			if ( isset( $params['post_content']['value'] ) ) {
1592
+			if (isset($params['post_content']['value'])) {
1593 1593
 				$content = $params['post_content']['value'];
1594 1594
 			} else {
1595 1595
 				$content = '';
1596 1596
 			}
1597 1597
 
1598 1598
 			// If we have a date, use it to check for existing post.
1599
-			if ( isset( $params['post_date']['value'] ) ) {
1599
+			if (isset($params['post_date']['value'])) {
1600 1600
 				$date = $params['post_date']['value'];
1601 1601
 			} else {
1602 1602
 				$date = '';
1603 1603
 			}
1604 1604
 
1605
-			$existing_id = post_exists( $title, $content, $date ); // Returns an id if there is a result. Returns 0 if not.
1605
+			$existing_id = post_exists($title, $content, $date); // Returns an id if there is a result. Returns 0 if not.
1606 1606
 
1607 1607
 			// Attachment does not exist after more checking. maybe we want to create it.
1608
-			if ( 0 === $existing_id && false === $check_only ) {
1609
-				$result = $this->attachment_create( $params );
1608
+			if (0 === $existing_id && false === $check_only) {
1609
+				$result = $this->attachment_create($params);
1610 1610
 				return $result;
1611
-			} elseif ( true === $check_only ) {
1611
+			} elseif (true === $check_only) {
1612 1612
 				// We are just checking to see if there is a match.
1613 1613
 				return $existing_id;
1614 1614
 			} else {
@@ -1620,22 +1620,22 @@  discard block
 block discarded – undo
1620 1620
 
1621 1621
 		} // End if().
1622 1622
 
1623
-		if ( isset( $attachment_id ) ) {
1624
-			foreach ( $params as $key => $value ) {
1625
-				$params[ $key ]['method_modify'] = $methods['method_update'];
1623
+		if (isset($attachment_id)) {
1624
+			foreach ($params as $key => $value) {
1625
+				$params[$key]['method_modify'] = $methods['method_update'];
1626 1626
 			}
1627
-			$result = $this->attachment_update( $attachment_id, $params );
1627
+			$result = $this->attachment_update($attachment_id, $params);
1628 1628
 			return $result;
1629 1629
 		}
1630 1630
 
1631 1631
 		// Create log entry for lack of an attachment id.
1632
-		if ( isset( $this->logging ) ) {
1632
+		if (isset($this->logging)) {
1633 1633
 			$logging = $this->logging;
1634
-		} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1635
-			$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1634
+		} elseif (class_exists('Object_Sync_Sf_Logging')) {
1635
+			$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1636 1636
 		}
1637 1637
 		$logging->setup(
1638
-			esc_html__( 'Error: Attachment: Tried to run attachment_upsert, and ended up without an attachment id', 'object-sync-for-salesforce' ),
1638
+			esc_html__('Error: Attachment: Tried to run attachment_upsert, and ended up without an attachment id', 'object-sync-for-salesforce'),
1639 1639
 			'',
1640 1640
 			0,
1641 1641
 			0,
@@ -1660,60 +1660,60 @@  discard block
 block discarded – undo
1660 1660
 	 * it does use wp_update_attachment_metadata for the meta fields, though.
1661 1661
 	 * Developers should use hooks to change this, if it does not meet their needs.
1662 1662
 	 */
1663
-	private function attachment_update( $attachment_id, $params, $id_field = 'ID' ) {
1663
+	private function attachment_update($attachment_id, $params, $id_field = 'ID') {
1664 1664
 		$content              = array();
1665
-		$content[ $id_field ] = $attachment_id;
1666
-		foreach ( $params as $key => $value ) {
1667
-			if ( 'wp_insert_attachment' === $value['method_modify'] ) { // Should also be insert attachment maybe.
1668
-				$content[ $key ] = $value['value'];
1669
-				unset( $params[ $key ] );
1665
+		$content[$id_field] = $attachment_id;
1666
+		foreach ($params as $key => $value) {
1667
+			if ('wp_insert_attachment' === $value['method_modify']) { // Should also be insert attachment maybe.
1668
+				$content[$key] = $value['value'];
1669
+				unset($params[$key]);
1670 1670
 			}
1671 1671
 		}
1672 1672
 
1673
-		if ( isset( $params['filename']['value'] ) ) {
1673
+		if (isset($params['filename']['value'])) {
1674 1674
 			$filename = $params['filename']['value'];
1675 1675
 		} else {
1676 1676
 			$filename = false;
1677 1677
 		}
1678 1678
 
1679
-		if ( isset( $params['parent']['value'] ) ) {
1679
+		if (isset($params['parent']['value'])) {
1680 1680
 			$parent = $params['parent']['value'];
1681 1681
 		} else {
1682 1682
 			$parent = 0;
1683 1683
 		}
1684 1684
 
1685
-		$attachment_id = wp_insert_attachment( $content, $filename, $parent );
1685
+		$attachment_id = wp_insert_attachment($content, $filename, $parent);
1686 1686
 
1687
-		if ( is_wp_error( $attachment_id ) ) {
1687
+		if (is_wp_error($attachment_id)) {
1688 1688
 			$success = false;
1689 1689
 			$errors  = $attachment_id;
1690 1690
 		} else {
1691 1691
 			$success = true;
1692 1692
 			$errors  = array();
1693 1693
 
1694
-			if ( false !== $filename ) {
1694
+			if (false !== $filename) {
1695 1695
 				// According to https://codex.wordpress.org/Function_Reference/wp_insert_attachment we need this file.
1696
-				require_once( ABSPATH . 'wp-admin/includes/image.php' );
1696
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
1697 1697
 				// Generate metadata for the attachment.
1698
-				$attach_data = wp_generate_attachment_metadata( $attachment_id, $filename );
1698
+				$attach_data = wp_generate_attachment_metadata($attachment_id, $filename);
1699 1699
 			}
1700 1700
 
1701 1701
 			// Put the data from salesforce into the meta array.
1702 1702
 			$attach_new_data = array();
1703
-			foreach ( $params as $key => $value ) {
1703
+			foreach ($params as $key => $value) {
1704 1704
 				$method                  = $value['method_modify'];
1705
-				$attach_new_data[ $key ] = $value['value'];
1705
+				$attach_new_data[$key] = $value['value'];
1706 1706
 			}
1707 1707
 
1708
-			if ( isset( $attach_data ) ) {
1709
-				$attach_data = array_merge( $attach_data, $attach_new_data );
1708
+			if (isset($attach_data)) {
1709
+				$attach_data = array_merge($attach_data, $attach_new_data);
1710 1710
 			} else {
1711 1711
 				$attach_data = $attach_new_data;
1712 1712
 			}
1713 1713
 
1714
-			$meta_updated = wp_update_attachment_metadata( $attachment_id, $attach_data );
1714
+			$meta_updated = wp_update_attachment_metadata($attachment_id, $attach_data);
1715 1715
 
1716
-			if ( false === $meta_updated ) {
1716
+			if (false === $meta_updated) {
1717 1717
 				$success  = false;
1718 1718
 				$errors[] = array(
1719 1719
 					'key'   => $key,
@@ -1721,12 +1721,12 @@  discard block
 block discarded – undo
1721 1721
 				);
1722 1722
 			}
1723 1723
 
1724
-			if ( 0 !== $parent ) {
1725
-				set_post_thumbnail( $parent_post_id, $attachment_id );
1724
+			if (0 !== $parent) {
1725
+				set_post_thumbnail($parent_post_id, $attachment_id);
1726 1726
 			}
1727 1727
 
1728 1728
 			// Developers can use this hook to set any other attachment data.
1729
-			do_action( 'object_sync_for_salesforce_set_more_attachment_data', $attachment_id, $params, 'update' );
1729
+			do_action('object_sync_for_salesforce_set_more_attachment_data', $attachment_id, $params, 'update');
1730 1730
 
1731 1731
 		} // End if().
1732 1732
 
@@ -1749,8 +1749,8 @@  discard block
 block discarded – undo
1749 1749
 	 * @return mixed
1750 1750
 	 *   attachment object if successful, false if failed
1751 1751
 	 */
1752
-	private function attachment_delete( $id, $force_delete = false ) {
1753
-		$result = wp_delete_attachment( $id, $force_delete );
1752
+	private function attachment_delete($id, $force_delete = false) {
1753
+		$result = wp_delete_attachment($id, $force_delete);
1754 1754
 		return $result;
1755 1755
 	}
1756 1756
 
@@ -1767,45 +1767,45 @@  discard block
 block discarded – undo
1767 1767
 	 *     success: 1
1768 1768
 	 *   "errors" : [ ],
1769 1769
 	 */
1770
-	private function term_create( $params, $taxonomy, $id_field = 'ID' ) {
1771
-		if ( 'tag' === $taxonomy ) {
1770
+	private function term_create($params, $taxonomy, $id_field = 'ID') {
1771
+		if ('tag' === $taxonomy) {
1772 1772
 			$taxonomy = 'post_tag';
1773 1773
 		}
1774 1774
 		// Load all params with a method_modify of the object structure's content_method into $content
1775 1775
 		$content   = array();
1776
-		$structure = $this->get_wordpress_table_structure( $taxonomy );
1776
+		$structure = $this->get_wordpress_table_structure($taxonomy);
1777 1777
 		$args      = array();
1778
-		foreach ( $params as $key => $value ) {
1779
-			if ( 'name' === $key ) {
1778
+		foreach ($params as $key => $value) {
1779
+			if ('name' === $key) {
1780 1780
 				$name = $value['value'];
1781
-				unset( $params[ $key ] );
1781
+				unset($params[$key]);
1782 1782
 			}
1783
-			if ( in_array( $value['method_modify'], $structure['content_methods'] ) && 'name' !== $key ) {
1784
-				$args[ $key ] = $value['value'];
1785
-				unset( $params[ $key ] );
1783
+			if (in_array($value['method_modify'], $structure['content_methods']) && 'name' !== $key) {
1784
+				$args[$key] = $value['value'];
1785
+				unset($params[$key]);
1786 1786
 			}
1787 1787
 		}
1788
-		if ( isset( $name ) ) {
1789
-			$term = wp_insert_term( $name, $taxonomy, $args );
1788
+		if (isset($name)) {
1789
+			$term = wp_insert_term($name, $taxonomy, $args);
1790 1790
 		}
1791 1791
 
1792
-		if ( is_wp_error( $term ) ) {
1792
+		if (is_wp_error($term)) {
1793 1793
 			$success = false;
1794 1794
 			$errors  = $term;
1795 1795
 		} else {
1796
-			$term_id = $term[ "$id_field" ];
1796
+			$term_id = $term["$id_field"];
1797 1797
 			$success = true;
1798 1798
 			$errors  = array();
1799
-			foreach ( $params as $key => $value ) {
1799
+			foreach ($params as $key => $value) {
1800 1800
 				$method  = $value['method_modify'];
1801
-				$meta_id = $method( $term_id, $key, $value['value'] );
1802
-				if ( false === $meta_id ) {
1801
+				$meta_id = $method($term_id, $key, $value['value']);
1802
+				if (false === $meta_id) {
1803 1803
 					$success  = false;
1804 1804
 					$errors[] = array(
1805 1805
 						'message' => sprintf(
1806 1806
 							// translators: %1$s is a method name.
1807
-							esc_html__( 'Tried to upsert meta with method %1$s.', 'object-sync-for-salesforce' ),
1808
-							esc_html( $method )
1807
+							esc_html__('Tried to upsert meta with method %1$s.', 'object-sync-for-salesforce'),
1808
+							esc_html($method)
1809 1809
 						),
1810 1810
 						'key'     => $key,
1811 1811
 						'value'   => $value,
@@ -1814,11 +1814,11 @@  discard block
 block discarded – undo
1814 1814
 			}
1815 1815
 
1816 1816
 			// Developers can use this hook to set any other term data.
1817
-			do_action( 'object_sync_for_salesforce_set_more_term_data', $term_id, $params, 'create' );
1817
+			do_action('object_sync_for_salesforce_set_more_term_data', $term_id, $params, 'create');
1818 1818
 
1819 1819
 		}
1820 1820
 
1821
-		if ( is_wp_error( $term ) ) {
1821
+		if (is_wp_error($term)) {
1822 1822
 			$success = false;
1823 1823
 			$errors  = $term;
1824 1824
 		} else {
@@ -1856,48 +1856,48 @@  discard block
 block discarded – undo
1856 1856
 	 *     success: 1
1857 1857
 	 *   "errors" : [ ],
1858 1858
 	 */
1859
-	private function term_upsert( $key, $value, $methods = array(), $params, $taxonomy, $id_field = 'ID', $push_drafts = false, $check_only = false ) {
1860
-		if ( 'tag' === $taxonomy ) {
1859
+	private function term_upsert($key, $value, $methods = array(), $params, $taxonomy, $id_field = 'ID', $push_drafts = false, $check_only = false) {
1860
+		if ('tag' === $taxonomy) {
1861 1861
 			$taxonomy = 'post_tag';
1862 1862
 		}
1863 1863
 		$method = $methods['method_match'];
1864
-		if ( '' !== $method ) {
1864
+		if ('' !== $method) {
1865 1865
 			// This should give us the term object.
1866
-			$term = $method( $key, $value, $taxonomy ); // We need to put the taxonomy in there probably.
1867
-			if ( isset( $term->{$id_field} ) ) {
1866
+			$term = $method($key, $value, $taxonomy); // We need to put the taxonomy in there probably.
1867
+			if (isset($term->{$id_field} )) {
1868 1868
 				// Term does exist after checking the matching value. we want its id.
1869 1869
 				$term_id = $term->{$id_field};
1870 1870
 
1871
-				if ( true === $check_only ) {
1871
+				if (true === $check_only) {
1872 1872
 					// We are just checking to see if there is a match.
1873 1873
 					return $term_id;
1874 1874
 				}
1875 1875
 
1876 1876
 				// On the prematch fields, we specify the method_update param.
1877
-				if ( isset( $methods['method_update'] ) ) {
1877
+				if (isset($methods['method_update'])) {
1878 1878
 					$method = $methods['method_update'];
1879 1879
 				} else {
1880 1880
 					$method = $methods['method_modify'];
1881 1881
 				}
1882
-				$params[ $key ] = array(
1882
+				$params[$key] = array(
1883 1883
 					'value'         => $value,
1884 1884
 					'method_modify' => $method,
1885 1885
 					'method_read'   => $methods['method_read'],
1886 1886
 				);
1887
-			} elseif ( false === $check_only ) {
1887
+			} elseif (false === $check_only) {
1888 1888
 				// Term does not exist after checking the matching value. Create it.
1889 1889
 				// On the prematch fields, we specify the method_create param.
1890
-				if ( isset( $methods['method_create'] ) ) {
1890
+				if (isset($methods['method_create'])) {
1891 1891
 					$method = $methods['method_create'];
1892 1892
 				} else {
1893 1893
 					$method = $methods['method_modify'];
1894 1894
 				}
1895
-				$params[ $key ] = array(
1895
+				$params[$key] = array(
1896 1896
 					'value'         => $value,
1897 1897
 					'method_modify' => $method,
1898 1898
 					'method_read'   => $methods['method_read'],
1899 1899
 				);
1900
-				$result         = $this->term_create( $params, $taxonomy, $id_field );
1900
+				$result = $this->term_create($params, $taxonomy, $id_field);
1901 1901
 				return $result;
1902 1902
 			} else {
1903 1903
 				// Check only is true but there's not a term yet.
@@ -1905,17 +1905,17 @@  discard block
 block discarded – undo
1905 1905
 			} // End if().
1906 1906
 		} else {
1907 1907
 			// There is no method by which to check the term. we can check other ways here.
1908
-			$params[ $key ] = array(
1908
+			$params[$key] = array(
1909 1909
 				'value'         => $value,
1910 1910
 				'method_modify' => $methods['method_modify'],
1911 1911
 				'method_read'   => $methods['method_read'],
1912 1912
 			);
1913 1913
 
1914
-			if ( isset( $params['name']['value'] ) ) {
1914
+			if (isset($params['name']['value'])) {
1915 1915
 				$term = $params['name']['value'];
1916 1916
 			}
1917 1917
 
1918
-			if ( isset( $params['parent']['value'] ) ) {
1918
+			if (isset($params['parent']['value'])) {
1919 1919
 				$parent = $params['parent']['value'];
1920 1920
 			} else {
1921 1921
 				$parent = 0;
@@ -1923,17 +1923,17 @@  discard block
 block discarded – undo
1923 1923
 
1924 1924
 			// Returns an id if there is a result. Returns null if it does not exist.
1925 1925
 			// wpcom_vip_term_exists is cached, and therefore preferred.
1926
-			if ( function_exists( 'wpcom_vip_term_exists' ) ) {
1927
-				$existing_id = wpcom_vip_term_exists( $term, $taxonomy, $parent );
1926
+			if (function_exists('wpcom_vip_term_exists')) {
1927
+				$existing_id = wpcom_vip_term_exists($term, $taxonomy, $parent);
1928 1928
 			} else {
1929
-				$existing_id = term_exists( $term, $taxonomy, $parent );
1929
+				$existing_id = term_exists($term, $taxonomy, $parent);
1930 1930
 			}
1931 1931
 
1932 1932
 			// Term does not exist after more checking. maybe we want to create it.
1933
-			if ( null === $existing_id && false === $check_only ) {
1934
-				$result = $this->term_create( $params, $taxonomy, $id_field );
1933
+			if (null === $existing_id && false === $check_only) {
1934
+				$result = $this->term_create($params, $taxonomy, $id_field);
1935 1935
 				return $result;
1936
-			} elseif ( true === $check_only ) {
1936
+			} elseif (true === $check_only) {
1937 1937
 				// We are just checking to see if there is a match.
1938 1938
 				return $existing_id;
1939 1939
 			} else {
@@ -1942,21 +1942,21 @@  discard block
 block discarded – undo
1942 1942
 			}
1943 1943
 		} // End if().
1944 1944
 
1945
-		if ( isset( $term_id ) ) {
1946
-			foreach ( $params as $key => $value ) {
1947
-				$params[ $key ]['method_modify'] = $methods['method_update'];
1945
+		if (isset($term_id)) {
1946
+			foreach ($params as $key => $value) {
1947
+				$params[$key]['method_modify'] = $methods['method_update'];
1948 1948
 			}
1949
-			$result = $this->term_update( $term_id, $params, $taxonomy, $id_field );
1949
+			$result = $this->term_update($term_id, $params, $taxonomy, $id_field);
1950 1950
 			return $result;
1951 1951
 		}
1952 1952
 		// Create log entry for lack of a term id.
1953
-		if ( isset( $this->logging ) ) {
1953
+		if (isset($this->logging)) {
1954 1954
 			$logging = $this->logging;
1955
-		} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1956
-			$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1955
+		} elseif (class_exists('Object_Sync_Sf_Logging')) {
1956
+			$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1957 1957
 		}
1958 1958
 		$logging->setup(
1959
-			esc_html__( 'Error: Terms: Tried to run term_upsert, and ended up without a term id', 'object-sync-for-salesforce' ),
1959
+			esc_html__('Error: Terms: Tried to run term_upsert, and ended up without a term id', 'object-sync-for-salesforce'),
1960 1960
 			'',
1961 1961
 			0,
1962 1962
 			0,
@@ -1978,36 +1978,36 @@  discard block
 block discarded – undo
1978 1978
 	 *     success: 1
1979 1979
 	 *   "errors" : [ ],
1980 1980
 	 */
1981
-	private function term_update( $term_id, $params, $taxonomy, $id_field = 'ID' ) {
1982
-		if ( 'tag' === $taxonomy ) {
1981
+	private function term_update($term_id, $params, $taxonomy, $id_field = 'ID') {
1982
+		if ('tag' === $taxonomy) {
1983 1983
 			$taxonomy = 'post_tag';
1984 1984
 		}
1985 1985
 		$args = array();
1986
-		foreach ( $params as $key => $value ) {
1987
-			if ( 'wp_update_term' === $value['method_modify'] ) {
1988
-				$args[ $key ] = $value['value'];
1989
-				unset( $params[ $key ] );
1986
+		foreach ($params as $key => $value) {
1987
+			if ('wp_update_term' === $value['method_modify']) {
1988
+				$args[$key] = $value['value'];
1989
+				unset($params[$key]);
1990 1990
 			}
1991 1991
 		}
1992
-		$term = wp_update_term( $term_id, $taxonomy, $args );
1992
+		$term = wp_update_term($term_id, $taxonomy, $args);
1993 1993
 
1994
-		if ( is_wp_error( $term ) ) {
1994
+		if (is_wp_error($term)) {
1995 1995
 			$success = false;
1996 1996
 			$errors  = $term;
1997 1997
 		} else {
1998
-			$term_id = $term[ "$id_field" ];
1998
+			$term_id = $term["$id_field"];
1999 1999
 			$success = true;
2000 2000
 			$errors  = array();
2001
-			foreach ( $params as $key => $value ) {
2001
+			foreach ($params as $key => $value) {
2002 2002
 				$method  = $value['method_modify'];
2003
-				$meta_id = $method( $term_id, $key, $value['value'] );
2004
-				if ( false === $meta_id ) {
2003
+				$meta_id = $method($term_id, $key, $value['value']);
2004
+				if (false === $meta_id) {
2005 2005
 					$success  = false;
2006 2006
 					$errors[] = array(
2007 2007
 						'message' => sprintf(
2008 2008
 							// translators: %1$s is a method name.
2009
-							esc_html__( 'Tried to update meta with method %1$s.', 'object-sync-for-salesforce' ),
2010
-							esc_html( $method )
2009
+							esc_html__('Tried to update meta with method %1$s.', 'object-sync-for-salesforce'),
2010
+							esc_html($method)
2011 2011
 						),
2012 2012
 						'key'     => $key,
2013 2013
 						'value'   => $value,
@@ -2016,11 +2016,11 @@  discard block
 block discarded – undo
2016 2016
 			}
2017 2017
 
2018 2018
 			// Developers can use this hook to set any other term data.
2019
-			do_action( 'object_sync_for_salesforce_set_more_term_data', $term_id, $params, 'update' );
2019
+			do_action('object_sync_for_salesforce_set_more_term_data', $term_id, $params, 'update');
2020 2020
 
2021 2021
 		}
2022 2022
 
2023
-		if ( is_wp_error( $term ) ) {
2023
+		if (is_wp_error($term)) {
2024 2024
 			$success = false;
2025 2025
 			$errors  = $term;
2026 2026
 		} else {
@@ -2048,11 +2048,11 @@  discard block
 block discarded – undo
2048 2048
 	 *
2049 2049
 	 * @return bool True if successful, false if failed.
2050 2050
 	 */
2051
-	private function term_delete( $term_id, $taxonomy ) {
2052
-		if ( 'tag' === $taxonomy ) {
2051
+	private function term_delete($term_id, $taxonomy) {
2052
+		if ('tag' === $taxonomy) {
2053 2053
 			$taxonomy = 'post_tag';
2054 2054
 		}
2055
-		$result = wp_delete_term( $term_id, $taxonomy );
2055
+		$result = wp_delete_term($term_id, $taxonomy);
2056 2056
 		return $result;
2057 2057
 	}
2058 2058
 
@@ -2068,52 +2068,52 @@  discard block
 block discarded – undo
2068 2068
 	 *     success: 1
2069 2069
 	 *   "errors" : [ ],
2070 2070
 	 */
2071
-	private function comment_create( $params, $id_field = 'comment_ID' ) {
2071
+	private function comment_create($params, $id_field = 'comment_ID') {
2072 2072
 		// Load all params with a method_modify of the object structure's content_method into $content
2073 2073
 		$content   = array();
2074
-		$structure = $this->get_wordpress_table_structure( 'comment' );
2075
-		foreach ( $params as $key => $value ) {
2076
-			if ( in_array( $value['method_modify'], $structure['content_methods'] ) ) {
2077
-				$content[ $key ] = $value['value'];
2078
-				unset( $params[ $key ] );
2074
+		$structure = $this->get_wordpress_table_structure('comment');
2075
+		foreach ($params as $key => $value) {
2076
+			if (in_array($value['method_modify'], $structure['content_methods'])) {
2077
+				$content[$key] = $value['value'];
2078
+				unset($params[$key]);
2079 2079
 			}
2080 2080
 		}
2081 2081
 
2082 2082
 		// Fields that are required for comments, even if they are empty values.
2083
-		if ( ! isset( $content['comment_author'] ) ) {
2083
+		if ( ! isset($content['comment_author'])) {
2084 2084
 			$content['comment_author'] = '';
2085 2085
 		}
2086
-		if ( ! isset( $content['comment_author_IP'] ) ) {
2086
+		if ( ! isset($content['comment_author_IP'])) {
2087 2087
 			$content['comment_author_IP'] = '';
2088 2088
 		}
2089
-		if ( ! isset( $content['comment_author_email'] ) ) {
2089
+		if ( ! isset($content['comment_author_email'])) {
2090 2090
 			$content['comment_author_email'] = '';
2091 2091
 		}
2092
-		if ( ! isset( $content['comment_author_url'] ) ) {
2092
+		if ( ! isset($content['comment_author_url'])) {
2093 2093
 			$content['comment_author_url'] = '';
2094 2094
 		}
2095
-		if ( ! isset( $content['comment_type'] ) ) {
2095
+		if ( ! isset($content['comment_type'])) {
2096 2096
 			$content['comment_type'] = '';
2097 2097
 		}
2098 2098
 
2099
-		$comment_id = wp_new_comment( $content );
2099
+		$comment_id = wp_new_comment($content);
2100 2100
 
2101
-		if ( is_wp_error( $comment_id ) ) {
2101
+		if (is_wp_error($comment_id)) {
2102 2102
 			$success = false;
2103 2103
 			$errors  = $comment_id;
2104 2104
 		} else {
2105 2105
 			$success = true;
2106 2106
 			$errors  = array();
2107
-			foreach ( $params as $key => $value ) {
2107
+			foreach ($params as $key => $value) {
2108 2108
 				$method  = $value['method_modify'];
2109
-				$meta_id = $method( $comment_id, $key, $value['value'] );
2110
-				if ( false === $meta_id ) {
2109
+				$meta_id = $method($comment_id, $key, $value['value']);
2110
+				if (false === $meta_id) {
2111 2111
 					$success  = false;
2112 2112
 					$errors[] = array(
2113 2113
 						'message' => sprintf(
2114 2114
 							// translators: %1$s is a method name.
2115
-							esc_html__( 'Tried to add meta with method %1$s.', 'object-sync-for-salesforce' ),
2116
-							esc_html( $method )
2115
+							esc_html__('Tried to add meta with method %1$s.', 'object-sync-for-salesforce'),
2116
+							esc_html($method)
2117 2117
 						),
2118 2118
 						'key'     => $key,
2119 2119
 						'value'   => $value,
@@ -2122,11 +2122,11 @@  discard block
 block discarded – undo
2122 2122
 			}
2123 2123
 
2124 2124
 			// Developers can use this hook to set any other comment data.
2125
-			do_action( 'object_sync_for_salesforce_set_more_comment_data', $comment_id, $params, 'create' );
2125
+			do_action('object_sync_for_salesforce_set_more_comment_data', $comment_id, $params, 'create');
2126 2126
 
2127 2127
 		}
2128 2128
 
2129
-		if ( is_wp_error( $comment_id ) ) {
2129
+		if (is_wp_error($comment_id)) {
2130 2130
 			$success = false;
2131 2131
 			$errors  = $comment_id;
2132 2132
 		} else {
@@ -2163,79 +2163,79 @@  discard block
 block discarded – undo
2163 2163
 	 *     success: 1
2164 2164
 	 *   "errors" : [ ],
2165 2165
 	 */
2166
-	private function comment_upsert( $key, $value, $methods, $params, $id_field = 'comment_ID', $push_drafts = false, $check_only = false ) {
2166
+	private function comment_upsert($key, $value, $methods, $params, $id_field = 'comment_ID', $push_drafts = false, $check_only = false) {
2167 2167
 		$method = $methods['method_match'];
2168
-		if ( 'get_comment' === $method ) {
2168
+		if ('get_comment' === $method) {
2169 2169
 			$method = 'get_comments';
2170 2170
 		}
2171
-		if ( '' !== $method ) {
2171
+		if ('' !== $method) {
2172 2172
 			// This should give us the comment object.
2173 2173
 			$match = array();
2174
-			if ( 'comment_author' === $key ) {
2175
-				$match['author__in'] = array( $value );
2174
+			if ('comment_author' === $key) {
2175
+				$match['author__in'] = array($value);
2176 2176
 			} else {
2177
-				$key           = str_replace( 'comment_', '', $key );
2178
-				$match[ $key ] = $value;
2177
+				$key           = str_replace('comment_', '', $key);
2178
+				$match[$key] = $value;
2179 2179
 			}
2180
-			$comments = $method( $match );
2180
+			$comments = $method($match);
2181 2181
 
2182
-			if ( 1 === count( $comments ) ) {
2182
+			if (1 === count($comments)) {
2183 2183
 				$comment = $comments[0];
2184 2184
 				// Comment does exist after checking the matching value. we want its id.
2185 2185
 				$comment_id = $comment->{$id_field};
2186 2186
 
2187
-				if ( true === $check_only ) {
2187
+				if (true === $check_only) {
2188 2188
 					// We are just checking to see if there is a match.
2189 2189
 					return $comment_id;
2190 2190
 				}
2191 2191
 
2192 2192
 				// On the prematch fields, we specify the method_update param.
2193
-				if ( isset( $methods['method_update'] ) ) {
2193
+				if (isset($methods['method_update'])) {
2194 2194
 					$method = $methods['method_update'];
2195 2195
 				} else {
2196 2196
 					$method = $methods['method_modify'];
2197 2197
 				}
2198
-				$params[ $key ] = array(
2198
+				$params[$key] = array(
2199 2199
 					'value'         => $value,
2200 2200
 					'method_modify' => $method,
2201 2201
 					'method_read'   => $methods['method_read'],
2202 2202
 				);
2203
-			} elseif ( count( $comments ) > 1 ) {
2203
+			} elseif (count($comments) > 1) {
2204 2204
 				$status = 'error';
2205 2205
 				// Create log entry for multiple matches.
2206
-				if ( isset( $this->logging ) ) {
2206
+				if (isset($this->logging)) {
2207 2207
 					$logging = $this->logging;
2208
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
2209
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
2208
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
2209
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
2210 2210
 				}
2211 2211
 				$logging->setup(
2212 2212
 					sprintf(
2213 2213
 						// translators: %1$s is a number. %2$s is a key. %3$s is the value of that key. %4$s is a var_export'd array of comments.
2214
-						esc_html__( 'Error: Comments: there are %1$s comment matches for the Salesforce key %2$s with the value of %3$s. Here they are: %4$s', 'object-sync-for-salesforce' ),
2215
-						absint( count( $comments ) ),
2216
-						esc_html( $key ),
2217
-						esc_html( $value ),
2218
-						esc_html( var_export( $comments ) ) // Debugging code in production because having useful error messages is good.
2214
+						esc_html__('Error: Comments: there are %1$s comment matches for the Salesforce key %2$s with the value of %3$s. Here they are: %4$s', 'object-sync-for-salesforce'),
2215
+						absint(count($comments)),
2216
+						esc_html($key),
2217
+						esc_html($value),
2218
+						esc_html(var_export($comments)) // Debugging code in production because having useful error messages is good.
2219 2219
 					),
2220 2220
 					'',
2221 2221
 					0,
2222 2222
 					0,
2223 2223
 					$status
2224 2224
 				);
2225
-			} elseif ( false === $check_only ) {
2225
+			} elseif (false === $check_only) {
2226 2226
 				// Comment does not exist after checking the matching value. Create it.
2227 2227
 				// On the prematch fields, we specify the method_create param.
2228
-				if ( isset( $methods['method_create'] ) ) {
2228
+				if (isset($methods['method_create'])) {
2229 2229
 					$method = $methods['method_create'];
2230 2230
 				} else {
2231 2231
 					$method = $methods['method_modify'];
2232 2232
 				}
2233
-				$params[ $key ] = array(
2233
+				$params[$key] = array(
2234 2234
 					'value'         => $value,
2235 2235
 					'method_modify' => $method,
2236 2236
 					'method_read'   => $methods['method_read'],
2237 2237
 				);
2238
-				$result         = $this->comment_create( $params, $id_field );
2238
+				$result = $this->comment_create($params, $id_field);
2239 2239
 				return $result;
2240 2240
 			} else {
2241 2241
 				// Check only is true but there's not a comment yet.
@@ -2243,33 +2243,33 @@  discard block
 block discarded – undo
2243 2243
 			} // End if().
2244 2244
 		} else {
2245 2245
 			// There is no method by which to check the comment. We can check other ways here.
2246
-			$params[ $key ] = array(
2246
+			$params[$key] = array(
2247 2247
 				'value'         => $value,
2248 2248
 				'method_modify' => $methods['method_modify'],
2249 2249
 				'method_read'   => $methods['method_read'],
2250 2250
 			);
2251 2251
 
2252
-			if ( isset( $params['comment_author']['value'] ) ) {
2252
+			if (isset($params['comment_author']['value'])) {
2253 2253
 				$comment_author = $params['comment_author']['value'];
2254 2254
 			}
2255 2255
 
2256
-			if ( isset( $params['comment_date']['value'] ) ) {
2256
+			if (isset($params['comment_date']['value'])) {
2257 2257
 				$comment_date = $params['comment_date']['value'];
2258 2258
 			}
2259 2259
 
2260
-			if ( isset( $params['timezone']['value'] ) ) {
2260
+			if (isset($params['timezone']['value'])) {
2261 2261
 				$timezone = $params['timezone']['value'];
2262 2262
 			} else {
2263 2263
 				$timezone = 'blog';
2264 2264
 			}
2265 2265
 
2266
-			$existing_id = comment_exists( $comment_author, $comment_date, $timezone ); // Returns an id if there is a result. Uses $wpdb->get_var, so it returns null if there is no value
2266
+			$existing_id = comment_exists($comment_author, $comment_date, $timezone); // Returns an id if there is a result. Uses $wpdb->get_var, so it returns null if there is no value
2267 2267
 
2268 2268
 			// Comment does not exist after more checking. We want to create it.
2269
-			if ( null === $existing_id && false === $check_only ) {
2270
-				$result = $this->comment_create( $params, $id_field );
2269
+			if (null === $existing_id && false === $check_only) {
2270
+				$result = $this->comment_create($params, $id_field);
2271 2271
 				return $result;
2272
-			} elseif ( true === $check_only ) {
2272
+			} elseif (true === $check_only) {
2273 2273
 				// We are just checking to see if there is a match.
2274 2274
 				return $existing_id;
2275 2275
 			} else {
@@ -2278,22 +2278,22 @@  discard block
 block discarded – undo
2278 2278
 			}
2279 2279
 		} // End if() that sets up the parameters in the $params array.
2280 2280
 
2281
-		if ( isset( $comment_id ) ) {
2282
-			foreach ( $params as $key => $value ) {
2283
-				$params[ $key ]['method_modify'] = $methods['method_update'];
2281
+		if (isset($comment_id)) {
2282
+			foreach ($params as $key => $value) {
2283
+				$params[$key]['method_modify'] = $methods['method_update'];
2284 2284
 			}
2285
-			$result = $this->comment_update( $comment_id, $params, $id_field );
2285
+			$result = $this->comment_update($comment_id, $params, $id_field);
2286 2286
 			return $result;
2287 2287
 		}
2288 2288
 
2289 2289
 		// Create log entry for lack of a comment id.
2290
-		if ( isset( $this->logging ) ) {
2290
+		if (isset($this->logging)) {
2291 2291
 			$logging = $this->logging;
2292
-		} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
2293
-			$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
2292
+		} elseif (class_exists('Object_Sync_Sf_Logging')) {
2293
+			$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
2294 2294
 		}
2295 2295
 		$logging->setup(
2296
-			esc_html__( 'Error: Comments: Tried to run comment_upsert, and ended up without a comment id', 'object-sync-for-salesforce' ),
2296
+			esc_html__('Error: Comments: Tried to run comment_upsert, and ended up without a comment id', 'object-sync-for-salesforce'),
2297 2297
 			'',
2298 2298
 			0,
2299 2299
 			0,
@@ -2314,34 +2314,34 @@  discard block
 block discarded – undo
2314 2314
 	 *     success: 1
2315 2315
 	 *   "errors" : [ ],
2316 2316
 	 */
2317
-	private function comment_update( $comment_id, $params, $id_field = 'comment_ID' ) {
2317
+	private function comment_update($comment_id, $params, $id_field = 'comment_ID') {
2318 2318
 		$content              = array();
2319
-		$content[ $id_field ] = $comment_id;
2320
-		foreach ( $params as $key => $value ) {
2321
-			if ( 'wp_update_comment' === $value['method_modify'] ) {
2322
-				$content[ $key ] = $value['value'];
2323
-				unset( $params[ $key ] );
2319
+		$content[$id_field] = $comment_id;
2320
+		foreach ($params as $key => $value) {
2321
+			if ('wp_update_comment' === $value['method_modify']) {
2322
+				$content[$key] = $value['value'];
2323
+				unset($params[$key]);
2324 2324
 			}
2325 2325
 		}
2326 2326
 
2327
-		$updated = wp_update_comment( $content );
2327
+		$updated = wp_update_comment($content);
2328 2328
 
2329
-		if ( 0 === $updated ) {
2329
+		if (0 === $updated) {
2330 2330
 			$success = false;
2331 2331
 			$errors  = $updated;
2332 2332
 		} else {
2333 2333
 			$success = true;
2334 2334
 			$errors  = array();
2335
-			foreach ( $params as $key => $value ) {
2335
+			foreach ($params as $key => $value) {
2336 2336
 				$method  = $value['method_modify'];
2337
-				$meta_id = $method( $comment_id, $key, $value['value'] );
2338
-				if ( false === $meta_id ) {
2337
+				$meta_id = $method($comment_id, $key, $value['value']);
2338
+				if (false === $meta_id) {
2339 2339
 					$success  = false;
2340 2340
 					$errors[] = array(
2341 2341
 						'message' => sprintf(
2342 2342
 							// Translators: %1$s is a method name.
2343
-							esc_html__( 'Tried to update meta with method %1$s.', 'object-sync-for-salesforce' ),
2344
-							esc_html( $method )
2343
+							esc_html__('Tried to update meta with method %1$s.', 'object-sync-for-salesforce'),
2344
+							esc_html($method)
2345 2345
 						),
2346 2346
 						'key'     => $key,
2347 2347
 						'value'   => $value,
@@ -2350,11 +2350,11 @@  discard block
 block discarded – undo
2350 2350
 			}
2351 2351
 
2352 2352
 			// Developers can use this hook to set any other comment data.
2353
-			do_action( 'object_sync_for_salesforce_set_more_comment_data', $comment_id, $params, 'update' );
2353
+			do_action('object_sync_for_salesforce_set_more_comment_data', $comment_id, $params, 'update');
2354 2354
 
2355 2355
 		}
2356 2356
 
2357
-		if ( is_wp_error( $updated ) ) {
2357
+		if (is_wp_error($updated)) {
2358 2358
 			$success = false;
2359 2359
 			$errors  = $updated;
2360 2360
 		} else {
@@ -2382,8 +2382,8 @@  discard block
 block discarded – undo
2382 2382
 	 *
2383 2383
 	 * @return boolean true if successful, false if failed.
2384 2384
 	 */
2385
-	private function comment_delete( $id, $force_delete = false ) {
2386
-		$result = wp_delete_comment( $id, $force_delete );
2385
+	private function comment_delete($id, $force_delete = false) {
2386
+		$result = wp_delete_comment($id, $force_delete);
2387 2387
 		return $result;
2388 2388
 	}
2389 2389
 
@@ -2407,9 +2407,9 @@  discard block
 block discarded – undo
2407 2407
 	 *
2408 2408
 	 * @param string $name The name of the field that lists all cache keys.
2409 2409
 	 */
2410
-	public function __construct( $name ) {
2410
+	public function __construct($name) {
2411 2411
 		$this->name         = $name;
2412
-		$this->cache_prefix = esc_sql( 'sfwp_' );
2412
+		$this->cache_prefix = esc_sql('sfwp_');
2413 2413
 	}
2414 2414
 
2415 2415
 	/**
@@ -2418,7 +2418,7 @@  discard block
 block discarded – undo
2418 2418
 	 * @return mixed value of transient. False of empty, otherwise array.
2419 2419
 	 */
2420 2420
 	public function all_keys() {
2421
-		return get_transient( $this->name );
2421
+		return get_transient($this->name);
2422 2422
 	}
2423 2423
 
2424 2424
 	/**
@@ -2429,16 +2429,16 @@  discard block
 block discarded – undo
2429 2429
 	 * @param int $cache_expiration. How long the plugin key cache, and this individual item cache, should last before expiring.
2430 2430
 	 * @return mixed value of transient. False of empty, otherwise array.
2431 2431
 	 */
2432
-	public function set( $cachekey, $value, $cache_expiration = 0 ) {
2432
+	public function set($cachekey, $value, $cache_expiration = 0) {
2433 2433
 
2434 2434
 		$prefix   = $this->cache_prefix;
2435 2435
 		$cachekey = $prefix . $cachekey;
2436 2436
 
2437 2437
 		$keys   = $this->all_keys();
2438 2438
 		$keys[] = $cachekey;
2439
-		set_transient( $this->name, $keys, $cache_expiration );
2439
+		set_transient($this->name, $keys, $cache_expiration);
2440 2440
 
2441
-		return set_transient( $cachekey, $value, $cache_expiration );
2441
+		return set_transient($cachekey, $value, $cache_expiration);
2442 2442
 	}
2443 2443
 
2444 2444
 	/**
@@ -2447,10 +2447,10 @@  discard block
 block discarded – undo
2447 2447
 	 * @param string $cachekey the key for this cache item
2448 2448
 	 * @return mixed value of transient. False of empty, otherwise array.
2449 2449
 	 */
2450
-	public function get( $cachekey ) {
2450
+	public function get($cachekey) {
2451 2451
 		$prefix   = $this->cache_prefix;
2452 2452
 		$cachekey = $prefix . $cachekey;
2453
-		return get_transient( $cachekey );
2453
+		return get_transient($cachekey);
2454 2454
 	}
2455 2455
 
2456 2456
 	/**
@@ -2459,10 +2459,10 @@  discard block
 block discarded – undo
2459 2459
 	 * @param string $cachekey the key for this cache item
2460 2460
 	 * @return bool True if successful, false otherwise.
2461 2461
 	 */
2462
-	public function delete( $cachekey ) {
2462
+	public function delete($cachekey) {
2463 2463
 		$prefix   = $this->cache_prefix;
2464 2464
 		$cachekey = $prefix . $cachekey;
2465
-		return delete_transient( $cachekey );
2465
+		return delete_transient($cachekey);
2466 2466
 	}
2467 2467
 
2468 2468
 	/**
@@ -2473,10 +2473,10 @@  discard block
 block discarded – undo
2473 2473
 	public function flush() {
2474 2474
 		$keys   = $this->all_keys();
2475 2475
 		$result = true;
2476
-		foreach ( $keys as $key ) {
2477
-			$result = delete_transient( $key );
2476
+		foreach ($keys as $key) {
2477
+			$result = delete_transient($key);
2478 2478
 		}
2479
-		$result = delete_transient( $this->name );
2479
+		$result = delete_transient($this->name);
2480 2480
 		return $result;
2481 2481
 	}
2482 2482
 
Please login to merge, or discard this patch.
object-sync-for-salesforce.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -16,75 +16,75 @@  discard block
 block discarded – undo
16 16
 class Object_Sync_Salesforce {
17 17
 
18 18
 	/**
19
-	* @var object
20
-	* Global object of `$wpdb`, the WordPress database
21
-	*/
19
+	 * @var object
20
+	 * Global object of `$wpdb`, the WordPress database
21
+	 */
22 22
 	private $wpdb;
23 23
 
24 24
 	/**
25
-	* @var array
26
-	* Login credentials for the Salesforce API; comes from wp-config or from the plugin settings
27
-	*/
25
+	 * @var array
26
+	 * Login credentials for the Salesforce API; comes from wp-config or from the plugin settings
27
+	 */
28 28
 	private $login_credentials;
29 29
 
30 30
 	/**
31
-	* @var string
32
-	* The plugin's slug so we can include it when necessary
33
-	*/
31
+	 * @var string
32
+	 * The plugin's slug so we can include it when necessary
33
+	 */
34 34
 	private $slug;
35 35
 
36 36
 	/**
37
-	* @var array
38
-	* Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
39
-	*/
37
+	 * @var array
38
+	 * Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
39
+	 */
40 40
 	public $schedulable_classes;
41 41
 
42 42
 	/**
43
-	* @var string
44
-	* Current version of the plugin
45
-	*/
43
+	 * @var string
44
+	 * Current version of the plugin
45
+	 */
46 46
 	private $version;
47 47
 
48 48
 	/**
49
-	* @var object
50
-	*/
49
+	 * @var object
50
+	 */
51 51
 	private $activated;
52 52
 
53 53
 	/**
54
-	* @var object
55
-	* Load and initialize the Object_Sync_Sf_Logging class
56
-	*/
54
+	 * @var object
55
+	 * Load and initialize the Object_Sync_Sf_Logging class
56
+	 */
57 57
 	private $logging;
58 58
 
59 59
 	/**
60
-	* @var object
61
-	* Load and initialize the Object_Sync_Sf_Mapping class
62
-	*/
60
+	 * @var object
61
+	 * Load and initialize the Object_Sync_Sf_Mapping class
62
+	 */
63 63
 	private $mappings;
64 64
 
65 65
 	/**
66
-	* @var object
67
-	* Load and initialize the Object_Sync_Sf_WordPress class
68
-	*/
66
+	 * @var object
67
+	 * Load and initialize the Object_Sync_Sf_WordPress class
68
+	 */
69 69
 	private $wordpress;
70 70
 
71 71
 	/**
72
-	* @var object
73
-	* Load and initialize the Object_Sync_Sf_Salesforce class.
74
-	* This contains the Salesforce API methods
75
-	*/
72
+	 * @var object
73
+	 * Load and initialize the Object_Sync_Sf_Salesforce class.
74
+	 * This contains the Salesforce API methods
75
+	 */
76 76
 	public $salesforce;
77 77
 
78 78
 	/**
79
-	* @var object
80
-	* Load and initialize the Object_Sync_Sf_Salesforce_Push class
81
-	*/
79
+	 * @var object
80
+	 * Load and initialize the Object_Sync_Sf_Salesforce_Push class
81
+	 */
82 82
 	private $push;
83 83
 
84 84
 	/**
85
-	* @var object
86
-	* Load and initialize the Object_Sync_Sf_Salesforce_Pull class
87
-	*/
85
+	 * @var object
86
+	 * Load and initialize the Object_Sync_Sf_Salesforce_Pull class
87
+	 */
88 88
 	private $pull;
89 89
 
90 90
 	/**
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	static $instance = null;
96 96
 
97 97
 	/**
98
-	* Load the static $instance property that holds the instance of the class.
99
-	* This instance makes the class reusable by other plugins
100
-	*
101
-	* @return object
102
-	*   The sfapi object if it is authenticated (empty, otherwise)
103
-	*
104
-	*/
98
+	 * Load the static $instance property that holds the instance of the class.
99
+	 * This instance makes the class reusable by other plugins
100
+	 *
101
+	 * @return object
102
+	 *   The sfapi object if it is authenticated (empty, otherwise)
103
+	 *
104
+	 */
105 105
 	static public function get_instance() {
106 106
 		if ( null === self::$instance ) {
107 107
 			self::$instance = new Object_Sync_Salesforce();
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	/**
225
-	* Private helper to load methods for manipulating core WordPress data across the plugin
226
-	*
227
-	* @param object $wpdb
228
-	* @param string $version
229
-	* @param string $slug
230
-	* @param object $mappings
231
-	* @param object $logging
232
-	*
233
-	* @return object
234
-	*   Instance of Object_Sync_Sf_WordPress
235
-	*/
225
+	 * Private helper to load methods for manipulating core WordPress data across the plugin
226
+	 *
227
+	 * @param object $wpdb
228
+	 * @param string $version
229
+	 * @param string $slug
230
+	 * @param object $mappings
231
+	 * @param object $logging
232
+	 *
233
+	 * @return object
234
+	 *   Instance of Object_Sync_Sf_WordPress
235
+	 */
236 236
 	private function wordpress( $wpdb, $version, $slug, $mappings, $logging ) {
237 237
 		require_once plugin_dir_path( __FILE__ ) . 'classes/wordpress.php';
238 238
 		$wordpress = new Object_Sync_Sf_WordPress( $wpdb, $version, $slug, $mappings, $logging );
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 
242 242
 	/**
243
-	* Public helper to load the Salesforce API and see if it is authenticated.
244
-	* This is public so other plugins can access the same SF API instance
245
-	*
246
-	* @return array
247
-	*   Whether Salesforce is authenticated (boolean)
248
-	*   The sfapi object if it is authenticated (empty, otherwise)
249
-	*/
243
+	 * Public helper to load the Salesforce API and see if it is authenticated.
244
+	 * This is public so other plugins can access the same SF API instance
245
+	 *
246
+	 * @return array
247
+	 *   Whether Salesforce is authenticated (boolean)
248
+	 *   The sfapi object if it is authenticated (empty, otherwise)
249
+	 */
250 250
 	public function salesforce_get_api() {
251 251
 		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce.php' );
252 252
 		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_query.php' ); // this can be used to generate soql queries, but we don't often need it so it gets initialized whenever it's needed
@@ -352,24 +352,24 @@  discard block
 block discarded – undo
352 352
 	}
353 353
 
354 354
 	/**
355
-	* Load the admin class.
356
-	* This also creates admin menu, unless the plugin that calls this library has indicated that it has its own menu
357
-	*
358
-	* @param object $wpdb
359
-	* @param string $version
360
-	* @param array $login_credentials
361
-	* @param string $slug
362
-	* @param object $wordpress
363
-	* @param object $salesforce
364
-	* @param object $mappings
365
-	* @param object $push
366
-	* @param object $pull
367
-	* @param object $logging
368
-	* @param array $schedulable_classes
369
-	* @return object $admin
370
-	*   Instance of Object_Sync_Sf_Admin
371
-	*
372
-	*/
355
+	 * Load the admin class.
356
+	 * This also creates admin menu, unless the plugin that calls this library has indicated that it has its own menu
357
+	 *
358
+	 * @param object $wpdb
359
+	 * @param string $version
360
+	 * @param array $login_credentials
361
+	 * @param string $slug
362
+	 * @param object $wordpress
363
+	 * @param object $salesforce
364
+	 * @param object $mappings
365
+	 * @param object $push
366
+	 * @param object $pull
367
+	 * @param object $logging
368
+	 * @param array $schedulable_classes
369
+	 * @return object $admin
370
+	 *   Instance of Object_Sync_Sf_Admin
371
+	 *
372
+	 */
373 373
 	private function load_admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes ) {
374 374
 		require_once( plugin_dir_path( __FILE__ ) . 'classes/admin.php' );
375 375
 		$admin = new Object_Sync_Sf_Admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes );
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
 	}
382 382
 
383 383
 	/**
384
-	* Display a Settings link on the main Plugins page
385
-	*
386
-	* @param array $links
387
-	* @param string $file
388
-	* @return array $links
389
-	*   These are the links that go with this plugin's entry
390
-	*/
384
+	 * Display a Settings link on the main Plugins page
385
+	 *
386
+	 * @param array $links
387
+	 * @param string $file
388
+	 * @return array $links
389
+	 *   These are the links that go with this plugin's entry
390
+	 */
391 391
 	public function plugin_action_links( $links, $file ) {
392 392
 		if ( plugin_basename( __FILE__ ) === $file ) {
393 393
 			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __( 'Settings', 'object-sync-for-salesforce' ) . '</a>';
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 
400 400
 
401 401
 	/**
402
-	* Admin styles. Load the CSS and JavaScript for the plugin's settings
403
-	*
404
-	* @return void
405
-	*/
402
+	 * Admin styles. Load the CSS and JavaScript for the plugin's settings
403
+	 *
404
+	 * @return void
405
+	 */
406 406
 	public function admin_scripts_and_styles() {
407 407
 		wp_enqueue_script( $this->slug . '-admin', plugins_url( 'assets/js/object-sync-for-salesforce-admin.min.js', __FILE__ ), array( 'jquery' ), filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/object-sync-for-salesforce-admin.js' ), true );
408 408
 		wp_enqueue_style( $this->slug . '-admin', plugins_url( 'assets/css/object-sync-for-salesforce-admin.min.css', __FILE__ ), array(), filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/object-sync-for-salesforce-admin.css' ), 'all' );
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
 	}
419 419
 
420 420
 	/**
421
-	* Get the pre-login Salesforce credentials.
422
-	* These depend on the plugin's settings or constants defined in wp-config.php.
423
-	*
424
-	* @return array $login_credentials
425
-	*   Includes all settings necessary to log into the Salesforce API.
426
-	*   Replaces settings options with wp-config.php values if they exist.
427
-	*/
421
+	 * Get the pre-login Salesforce credentials.
422
+	 * These depend on the plugin's settings or constants defined in wp-config.php.
423
+	 *
424
+	 * @return array $login_credentials
425
+	 *   Includes all settings necessary to log into the Salesforce API.
426
+	 *   Replaces settings options with wp-config.php values if they exist.
427
+	 */
428 428
 	private function get_login_credentials() {
429 429
 
430 430
 		$consumer_key       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( 'object_sync_for_salesforce_consumer_key', '' );
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	*
104 104
 	*/
105 105
 	static public function get_instance() {
106
-		if ( null === self::$instance ) {
106
+		if (null === self::$instance) {
107 107
 			self::$instance = new Object_Sync_Salesforce();
108 108
 		}
109 109
 		return self::$instance;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		);
143 143
 
144 144
 		// users can modify the list of schedulable classes
145
-		$this->schedulable_classes = apply_filters( 'object_sync_for_salesforce_modify_schedulable_classes', $this->schedulable_classes );
145
+		$this->schedulable_classes = apply_filters('object_sync_for_salesforce_modify_schedulable_classes', $this->schedulable_classes);
146 146
 
147 147
 		/*
148 148
 		 * example to modify the array of classes by adding one and removing one
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
 		 * }
168 168
 		*/
169 169
 
170
-		$this->activated = $this->activate( $this->wpdb, $this->version, $this->slug );
171
-		$this->deactivate( $this->wpdb, $this->version, $this->slug, $this->schedulable_classes );
170
+		$this->activated = $this->activate($this->wpdb, $this->version, $this->slug);
171
+		$this->deactivate($this->wpdb, $this->version, $this->slug, $this->schedulable_classes);
172 172
 
173
-		$this->logging = $this->logging( $this->wpdb, $this->version );
173
+		$this->logging = $this->logging($this->wpdb, $this->version);
174 174
 
175
-		$this->mappings = $this->mappings( $this->wpdb, $this->version, $this->slug, $this->logging );
175
+		$this->mappings = $this->mappings($this->wpdb, $this->version, $this->slug, $this->logging);
176 176
 
177
-		$this->wordpress  = $this->wordpress( $this->wpdb, $this->version, $this->slug, $this->mappings, $this->logging );
177
+		$this->wordpress  = $this->wordpress($this->wpdb, $this->version, $this->slug, $this->mappings, $this->logging);
178 178
 		$this->salesforce = $this->salesforce_get_api();
179 179
 
180
-		$this->push = $this->push( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes );
180
+		$this->push = $this->push($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes);
181 181
 
182
-		$this->pull = $this->pull( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes );
182
+		$this->pull = $this->pull($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes);
183 183
 
184
-		$this->load_admin( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->push, $this->pull, $this->logging, $this->schedulable_classes );
184
+		$this->load_admin($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->push, $this->pull, $this->logging, $this->schedulable_classes);
185 185
 
186 186
 	}
187 187
 
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 	 * @return object
196 196
 	 *   Instance of Object_Sync_Sf_Logging
197 197
 	 */
198
-	private function logging( $wpdb, $version ) {
199
-		if ( ! class_exists( 'WP_Logging' ) && file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) {
200
-			require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
201
-			require_once plugin_dir_path( __FILE__ ) . 'classes/logging.php';
198
+	private function logging($wpdb, $version) {
199
+		if ( ! class_exists('WP_Logging') && file_exists(plugin_dir_path(__FILE__) . 'vendor/autoload.php')) {
200
+			require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';
201
+			require_once plugin_dir_path(__FILE__) . 'classes/logging.php';
202 202
 		}
203
-		$logging = new Object_Sync_Sf_Logging( $wpdb, $version );
203
+		$logging = new Object_Sync_Sf_Logging($wpdb, $version);
204 204
 		return $logging;
205 205
 	}
206 206
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 	 * @return object
216 216
 	 *   Instance of Object_Sync_Sf_Mapping
217 217
 	 */
218
-	private function mappings( $wpdb, $version, $slug, $logging ) {
219
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_mapping.php' );
220
-		$mappings = new Object_Sync_Sf_Mapping( $wpdb, $version, $slug, $logging );
218
+	private function mappings($wpdb, $version, $slug, $logging) {
219
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce_mapping.php');
220
+		$mappings = new Object_Sync_Sf_Mapping($wpdb, $version, $slug, $logging);
221 221
 		return $mappings;
222 222
 	}
223 223
 
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 	* @return object
234 234
 	*   Instance of Object_Sync_Sf_WordPress
235 235
 	*/
236
-	private function wordpress( $wpdb, $version, $slug, $mappings, $logging ) {
237
-		require_once plugin_dir_path( __FILE__ ) . 'classes/wordpress.php';
238
-		$wordpress = new Object_Sync_Sf_WordPress( $wpdb, $version, $slug, $mappings, $logging );
236
+	private function wordpress($wpdb, $version, $slug, $mappings, $logging) {
237
+		require_once plugin_dir_path(__FILE__) . 'classes/wordpress.php';
238
+		$wordpress = new Object_Sync_Sf_WordPress($wpdb, $version, $slug, $mappings, $logging);
239 239
 		return $wordpress;
240 240
 	}
241 241
 
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	*   The sfapi object if it is authenticated (empty, otherwise)
249 249
 	*/
250 250
 	public function salesforce_get_api() {
251
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce.php' );
252
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_query.php' ); // this can be used to generate soql queries, but we don't often need it so it gets initialized whenever it's needed
251
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce.php');
252
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce_query.php'); // this can be used to generate soql queries, but we don't often need it so it gets initialized whenever it's needed
253 253
 		$consumer_key        = $this->login_credentials['consumer_key'];
254 254
 		$consumer_secret     = $this->login_credentials['consumer_secret'];
255 255
 		$login_url           = $this->login_credentials['login_url'];
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 		$schedulable_classes = $this->schedulable_classes;
264 264
 		$is_authorized       = false;
265 265
 		$sfapi               = '';
266
-		if ( $consumer_key && $consumer_secret ) {
267
-			$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 );
268
-			if ( $sfapi->is_authorized() === true ) {
266
+		if ($consumer_key && $consumer_secret) {
267
+			$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);
268
+			if ($sfapi->is_authorized() === true) {
269 269
 				$is_authorized = true;
270 270
 			}
271 271
 		}
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 	 * @return object
286 286
 	 *   Instance of Object_Sync_Sf_Activate
287 287
 	 */
288
-	private function activate( $wpdb, $version, $slug ) {
289
-		require_once plugin_dir_path( __FILE__ ) . 'classes/activate.php';
290
-		$activate = new Object_Sync_Sf_Activate( $wpdb, $version, $slug );
288
+	private function activate($wpdb, $version, $slug) {
289
+		require_once plugin_dir_path(__FILE__) . 'classes/activate.php';
290
+		$activate = new Object_Sync_Sf_Activate($wpdb, $version, $slug);
291 291
 		return $activate;
292 292
 	}
293 293
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 	 * @return object
303 303
 	 *   Instance of Object_Sync_Sf_Deactivate
304 304
 	 */
305
-	private function deactivate( $wpdb, $version, $slug, $schedulable_classes ) {
306
-		require_once plugin_dir_path( __FILE__ ) . 'classes/deactivate.php';
307
-		$deactivate = new Object_Sync_Sf_Deactivate( $wpdb, $version, $slug, $schedulable_classes );
305
+	private function deactivate($wpdb, $version, $slug, $schedulable_classes) {
306
+		require_once plugin_dir_path(__FILE__) . 'classes/deactivate.php';
307
+		$deactivate = new Object_Sync_Sf_Deactivate($wpdb, $version, $slug, $schedulable_classes);
308 308
 	}
309 309
 
310 310
 
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 	 * @return object
325 325
 	 *   Instance of Object_Sync_Sf_Salesforce_Push
326 326
 	 */
327
-	private function push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
328
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_push.php';
329
-		$push = new Object_Sync_Sf_Salesforce_Push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes );
327
+	private function push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes) {
328
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_push.php';
329
+		$push = new Object_Sync_Sf_Salesforce_Push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes);
330 330
 		return $push;
331 331
 	}
332 332
 
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 	 * @return object
346 346
 	 *   Instance of Object_Sync_Sf_Salesforce_Pull
347 347
 	 */
348
-	private function pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
349
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_pull.php';
350
-		$pull = new Object_Sync_Sf_Salesforce_Pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes );
348
+	private function pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes) {
349
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_pull.php';
350
+		$pull = new Object_Sync_Sf_Salesforce_Pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes);
351 351
 		return $pull;
352 352
 	}
353 353
 
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 	*   Instance of Object_Sync_Sf_Admin
371 371
 	*
372 372
 	*/
373
-	private function load_admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes ) {
374
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/admin.php' );
375
-		$admin = new Object_Sync_Sf_Admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes );
376
-		add_action( 'admin_menu', array( $admin, 'create_admin_menu' ) );
377
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_and_styles' ) );
378
-		add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
379
-		add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 5 );
373
+	private function load_admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes) {
374
+		require_once(plugin_dir_path(__FILE__) . 'classes/admin.php');
375
+		$admin = new Object_Sync_Sf_Admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes);
376
+		add_action('admin_menu', array($admin, 'create_admin_menu'));
377
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts_and_styles'));
378
+		add_action('plugins_loaded', array($this, 'textdomain'));
379
+		add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 5);
380 380
 		return $admin;
381 381
 	}
382 382
 
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
 	* @return array $links
389 389
 	*   These are the links that go with this plugin's entry
390 390
 	*/
391
-	public function plugin_action_links( $links, $file ) {
392
-		if ( plugin_basename( __FILE__ ) === $file ) {
393
-			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __( 'Settings', 'object-sync-for-salesforce' ) . '</a>';
391
+	public function plugin_action_links($links, $file) {
392
+		if (plugin_basename(__FILE__) === $file) {
393
+			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __('Settings', 'object-sync-for-salesforce') . '</a>';
394 394
 			// make the 'Settings' link appear first
395
-			array_unshift( $links, $settings );
395
+			array_unshift($links, $settings);
396 396
 		}
397 397
 		return $links;
398 398
 	}
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	* @return void
405 405
 	*/
406 406
 	public function admin_scripts_and_styles() {
407
-		wp_enqueue_script( $this->slug . '-admin', plugins_url( 'assets/js/object-sync-for-salesforce-admin.min.js', __FILE__ ), array( 'jquery' ), filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/object-sync-for-salesforce-admin.js' ), true );
408
-		wp_enqueue_style( $this->slug . '-admin', plugins_url( 'assets/css/object-sync-for-salesforce-admin.min.css', __FILE__ ), array(), filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/object-sync-for-salesforce-admin.css' ), 'all' );
407
+		wp_enqueue_script($this->slug . '-admin', plugins_url('assets/js/object-sync-for-salesforce-admin.min.js', __FILE__), array('jquery'), filemtime(plugin_dir_path(__FILE__) . 'assets/js/object-sync-for-salesforce-admin.js'), true);
408
+		wp_enqueue_style($this->slug . '-admin', plugins_url('assets/css/object-sync-for-salesforce-admin.min.css', __FILE__), array(), filemtime(plugin_dir_path(__FILE__) . 'assets/css/object-sync-for-salesforce-admin.css'), 'all');
409 409
 	}
410 410
 
411 411
 	/**
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 * @return void
415 415
 	 */
416 416
 	public function textdomain() {
417
-		load_plugin_textdomain( 'object-sync-for-salesforce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
417
+		load_plugin_textdomain('object-sync-for-salesforce', false, dirname(plugin_basename(__FILE__)) . '/languages/');
418 418
 	}
419 419
 
420 420
 	/**
@@ -427,13 +427,13 @@  discard block
 block discarded – undo
427 427
 	*/
428 428
 	private function get_login_credentials() {
429 429
 
430
-		$consumer_key       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( 'object_sync_for_salesforce_consumer_key', '' );
431
-		$consumer_secret    = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option( 'object_sync_for_salesforce_consumer_secret', '' );
432
-		$callback_url       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option( 'object_sync_for_salesforce_callback_url', '' );
433
-		$login_base_url     = defined( 'OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL : get_option( 'object_sync_for_salesforce_login_base_url', '' );
434
-		$authorize_url_path = defined( 'OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH' ) ? OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH : get_option( 'object_sync_for_salesforce_authorize_url_path', '' );
435
-		$token_url_path     = defined( 'OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH' ) ? OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH : get_option( 'object_sync_for_salesforce_token_url_path', '' );
436
-		$api_version        = defined( 'OBJECT_SYNC_SF_SALESFORCE_API_VERSION' ) ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option( 'object_sync_for_salesforce_api_version', '' );
430
+		$consumer_key       = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option('object_sync_for_salesforce_consumer_key', '');
431
+		$consumer_secret    = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option('object_sync_for_salesforce_consumer_secret', '');
432
+		$callback_url       = defined('OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL') ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option('object_sync_for_salesforce_callback_url', '');
433
+		$login_base_url     = defined('OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL') ? OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL : get_option('object_sync_for_salesforce_login_base_url', '');
434
+		$authorize_url_path = defined('OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH') ? OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH : get_option('object_sync_for_salesforce_authorize_url_path', '');
435
+		$token_url_path     = defined('OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH') ? OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH : get_option('object_sync_for_salesforce_token_url_path', '');
436
+		$api_version        = defined('OBJECT_SYNC_SF_SALESFORCE_API_VERSION') ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option('object_sync_for_salesforce_api_version', '');
437 437
 
438 438
 		$login_credentials = array(
439 439
 			'consumer_key'     => $consumer_key,
Please login to merge, or discard this patch.
templates/admin/fieldmaps-add-edit-clone.php 1 patch
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -1,35 +1,35 @@  discard block
 block discarded – undo
1
-<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="fieldmap">
2
-	<input type="hidden" name="redirect_url_error" value="<?php echo esc_url( $error_url ); ?>" />
3
-	<input type="hidden" name="redirect_url_success" value="<?php echo esc_url( $success_url ); ?>" />
4
-	<?php if ( isset( $transient ) ) { ?>
5
-	<input type="hidden" name="transient" value="<?php echo esc_html( $transient ); ?>" />
1
+<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" class="fieldmap">
2
+	<input type="hidden" name="redirect_url_error" value="<?php echo esc_url($error_url); ?>" />
3
+	<input type="hidden" name="redirect_url_success" value="<?php echo esc_url($success_url); ?>" />
4
+	<?php if (isset($transient)) { ?>
5
+	<input type="hidden" name="transient" value="<?php echo esc_html($transient); ?>" />
6 6
 	<?php } ?>
7 7
 	<input type="hidden" name="action" value="post_fieldmap" >
8
-	<input type="hidden" name="method" value="<?php echo esc_attr( $method ); ?>" />
9
-	<?php if ( 'edit' === $method ) { ?>
10
-	<input type="hidden" name="id" value="<?php echo absint( $map['id'] ); ?>" />
8
+	<input type="hidden" name="method" value="<?php echo esc_attr($method); ?>" />
9
+	<?php if ('edit' === $method) { ?>
10
+	<input type="hidden" name="id" value="<?php echo absint($map['id']); ?>" />
11 11
 	<?php } ?>
12 12
 	<div class="fieldmap_label">
13
-		<label for="label"><?php echo esc_html__( 'Label', 'object-sync-for-salesforce' ); ?>: </label>
14
-		<input type="text" id="label" name="label" required value="<?php echo isset( $label ) ? esc_html( $label ) : ''; ?>" />
13
+		<label for="label"><?php echo esc_html__('Label', 'object-sync-for-salesforce'); ?>: </label>
14
+		<input type="text" id="label" name="label" required value="<?php echo isset($label) ? esc_html($label) : ''; ?>" />
15 15
 	</div>
16 16
 	<fieldset class="wordpress_side">
17 17
 		<div class="wordpress_object">
18
-			<label for="wordpress_object"><?php echo esc_html__( 'WordPress Object', 'object-sync-for-salesforce' ); ?>: </label>
18
+			<label for="wordpress_object"><?php echo esc_html__('WordPress Object', 'object-sync-for-salesforce'); ?>: </label>
19 19
 			<select id="wordpress_object" name="wordpress_object" required>
20
-				<option value="">- <?php echo esc_html__( 'Select object type', 'object-sync-for-salesforce' ); ?> -</option>
20
+				<option value="">- <?php echo esc_html__('Select object type', 'object-sync-for-salesforce'); ?> -</option>
21 21
 				<?php
22 22
 				$wordpress_objects = $this->wordpress->wordpress_objects;
23
-				foreach ( $wordpress_objects as $object ) {
24
-					if ( isset( $wordpress_object ) && $wordpress_object === $object ) {
23
+				foreach ($wordpress_objects as $object) {
24
+					if (isset($wordpress_object) && $wordpress_object === $object) {
25 25
 						$selected = ' selected';
26 26
 					} else {
27 27
 						$selected = '';
28 28
 					}
29
-					echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
30
-						esc_html( $object ),
31
-						esc_attr( $selected ),
32
-						esc_html( $object )
29
+					echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
30
+						esc_html($object),
31
+						esc_attr($selected),
32
+						esc_html($object)
33 33
 					);
34 34
 				}
35 35
 				?>
@@ -38,31 +38,31 @@  discard block
 block discarded – undo
38 38
 	</fieldset>
39 39
 	<fieldset class="salesforce_side">
40 40
 		<div class="salesforce_object">
41
-			<label for="salesforce_object"><?php echo esc_html__( 'Salesforce Object', 'object-sync-for-salesforce' ); ?>: </label>
41
+			<label for="salesforce_object"><?php echo esc_html__('Salesforce Object', 'object-sync-for-salesforce'); ?>: </label>
42 42
 			<div class="spinner"></div>
43 43
 			<select id="salesforce_object" name="salesforce_object" required>
44
-				<option value="">- <?php echo esc_html__( 'Select object type', 'object-sync-for-salesforce' ); ?> -</option>
44
+				<option value="">- <?php echo esc_html__('Select object type', 'object-sync-for-salesforce'); ?> -</option>
45 45
 				<?php
46 46
 				$sfapi          = $this->salesforce['sfapi'];
47
-				$object_filters = maybe_unserialize( get_option( 'salesforce_api_object_filters' ), array() );
47
+				$object_filters = maybe_unserialize(get_option('salesforce_api_object_filters'), array());
48 48
 				$conditions     = array();
49
-				if ( is_array( $object_filters ) && in_array( 'updateable', $object_filters, true ) ) {
49
+				if (is_array($object_filters) && in_array('updateable', $object_filters, true)) {
50 50
 					$conditions['updateable'] = true;
51 51
 				}
52
-				if ( is_array( $object_filters ) && in_array( 'triggerable', $object_filters, true ) ) {
52
+				if (is_array($object_filters) && in_array('triggerable', $object_filters, true)) {
53 53
 					$conditions['triggerable'] = true;
54 54
 				}
55
-				$salesforce_objects = $sfapi->objects( $conditions );
56
-				foreach ( $salesforce_objects as $object ) {
57
-					if ( isset( $salesforce_object ) && $salesforce_object === $object['name'] ) {
55
+				$salesforce_objects = $sfapi->objects($conditions);
56
+				foreach ($salesforce_objects as $object) {
57
+					if (isset($salesforce_object) && $salesforce_object === $object['name']) {
58 58
 						$selected = ' selected';
59 59
 					} else {
60 60
 						$selected = '';
61 61
 					}
62
-					echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
63
-						esc_html( $object['name'] ),
64
-						esc_attr( $selected ),
65
-						esc_html( $object['label'] )
62
+					echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
63
+						esc_html($object['name']),
64
+						esc_attr($selected),
65
+						esc_html($object['label'])
66 66
 					);
67 67
 				}
68 68
 				?>
@@ -70,30 +70,30 @@  discard block
 block discarded – undo
70 70
 		</div>
71 71
 		<div class="salesforce_record_types_allowed">
72 72
 			<?php
73
-			if ( isset( $salesforce_record_types_allowed ) ) :
73
+			if (isset($salesforce_record_types_allowed)) :
74 74
 				$record_types = $this->get_salesforce_object_description(
75 75
 					array(
76 76
 						'salesforce_object' => $salesforce_object,
77 77
 						'include'           => 'recordTypeInfos',
78 78
 					)
79 79
 				);
80
-				if ( isset( $record_types['recordTypeInfos'] ) ) :
80
+				if (isset($record_types['recordTypeInfos'])) :
81 81
 					?>
82
-					<label for="salesforce_record_types_allowed"><?php echo __( 'Allowed Record Types', 'object-sync-for-salesforce' ); ?>:</label>
82
+					<label for="salesforce_record_types_allowed"><?php echo __('Allowed Record Types', 'object-sync-for-salesforce'); ?>:</label>
83 83
 					<div class="checkboxes">
84
-					<?php foreach ( $record_types['recordTypeInfos'] as $key => $value ) : ?>
84
+					<?php foreach ($record_types['recordTypeInfos'] as $key => $value) : ?>
85 85
 						<?php
86
-						if ( in_array( $key, $salesforce_record_types_allowed, true ) ) {
86
+						if (in_array($key, $salesforce_record_types_allowed, true)) {
87 87
 							$checked = ' checked';
88 88
 						} else {
89 89
 							$checked = '';
90 90
 						}
91
-						echo sprintf( '<label><input type="checkbox" class="form-checkbox" value="%1$s" name="%2$s" id="%3$s"%4$s>%5$s</label>',
92
-							esc_html( $key ),
93
-							esc_attr( 'salesforce_record_types_allowed[' . $key . ']' ),
94
-							esc_attr( 'salesforce_record_types_allowed-' . $key ),
95
-							esc_html( $checked ),
96
-							esc_html( $value )
91
+						echo sprintf('<label><input type="checkbox" class="form-checkbox" value="%1$s" name="%2$s" id="%3$s"%4$s>%5$s</label>',
92
+							esc_html($key),
93
+							esc_attr('salesforce_record_types_allowed[' . $key . ']'),
94
+							esc_attr('salesforce_record_types_allowed-' . $key),
95
+							esc_html($checked),
96
+							esc_html($value)
97 97
 						);
98 98
 						?>
99 99
 					<?php endforeach; ?>
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 		</div>
104 104
 		<div class="salesforce_record_type_default">
105 105
 			<?php
106
-			if ( isset( $salesforce_record_type_default ) ) :
106
+			if (isset($salesforce_record_type_default)) :
107 107
 				$record_types = $this->get_salesforce_object_description(
108 108
 					array(
109 109
 						'salesforce_object' => $salesforce_object,
110 110
 						'include'           => 'recordTypeInfos',
111 111
 					)
112 112
 				);
113
-				if ( isset( $record_types['recordTypeInfos'] ) ) :
113
+				if (isset($record_types['recordTypeInfos'])) :
114 114
 					?>
115
-					<label for="salesforce_record_type_default"><?php echo __( 'Default Record Type', 'object-sync-for-salesforce' ); ?>:</label>
116
-					<select id="salesforce_record_type_default" name="salesforce_record_type_default" required><option value="">- <?php echo __( 'Select record type', 'object-sync-for-salesforce' ); ?> -</option>
115
+					<label for="salesforce_record_type_default"><?php echo __('Default Record Type', 'object-sync-for-salesforce'); ?>:</label>
116
+					<select id="salesforce_record_type_default" name="salesforce_record_type_default" required><option value="">- <?php echo __('Select record type', 'object-sync-for-salesforce'); ?> -</option>
117 117
 					<?php
118
-					foreach ( $record_types['recordTypeInfos'] as $key => $value ) :
119
-						if ( isset( $salesforce_record_type_default ) && $salesforce_record_type_default === $key ) {
118
+					foreach ($record_types['recordTypeInfos'] as $key => $value) :
119
+						if (isset($salesforce_record_type_default) && $salesforce_record_type_default === $key) {
120 120
 							$selected = ' selected';
121 121
 						} else {
122 122
 							$selected = '';
123 123
 						}
124
-						if ( ! isset( $salesforce_record_types_allowed ) || in_array( $key, $salesforce_record_types_allowed, true ) ) {
125
-							echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
126
-								esc_attr( $key ),
127
-								esc_attr( $selected ),
128
-								esc_html( $value )
124
+						if ( ! isset($salesforce_record_types_allowed) || in_array($key, $salesforce_record_types_allowed, true)) {
125
+							echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
126
+								esc_attr($key),
127
+								esc_attr($selected),
128
+								esc_html($value)
129 129
 							);
130 130
 						}
131 131
 					endforeach;
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 			?>
138 138
 		</div>
139 139
 		<div class="pull_trigger_field">
140
-			<?php if ( isset( $pull_trigger_field ) ) : ?>
141
-				<label for="pull_trigger_field"><?php echo __( 'Date field to trigger pull', 'object-sync-for-salesforce' ); ?>:</label>
140
+			<?php if (isset($pull_trigger_field)) : ?>
141
+				<label for="pull_trigger_field"><?php echo __('Date field to trigger pull', 'object-sync-for-salesforce'); ?>:</label>
142 142
 				<?php
143 143
 				$object_fields = $this->get_salesforce_object_fields(
144 144
 					array(
@@ -149,35 +149,35 @@  discard block
 block discarded – undo
149 149
 				?>
150 150
 				<select name="pull_trigger_field" id="pull_trigger_field">
151 151
 				<?php
152
-				foreach ( $object_fields as $key => $value ) {
153
-					if ( $pull_trigger_field === $value['name'] ) {
152
+				foreach ($object_fields as $key => $value) {
153
+					if ($pull_trigger_field === $value['name']) {
154 154
 						$selected = ' selected';
155 155
 					} else {
156 156
 						$selected = '';
157 157
 					}
158
-					echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
159
-						esc_attr( $value['name'] ),
160
-						esc_attr( $selected ),
161
-						esc_html( $value['label'] )
158
+					echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
159
+						esc_attr($value['name']),
160
+						esc_attr($selected),
161
+						esc_html($value['label'])
162 162
 					);
163 163
 				}
164 164
 				?>
165 165
 				</select>
166
-				<p class="description"><?php echo esc_html__( 'When the plugin checks for data to bring from Salesforce into WordPress, it will use the selected field to determine what relevant changes have occurred in Salesforce.', 'object-sync-for-salesforce' ); ?></p>
166
+				<p class="description"><?php echo esc_html__('When the plugin checks for data to bring from Salesforce into WordPress, it will use the selected field to determine what relevant changes have occurred in Salesforce.', 'object-sync-for-salesforce'); ?></p>
167 167
 			<?php endif; ?>
168 168
 		</div>
169 169
 	</fieldset>
170 170
 	<fieldset class="fields">
171
-		<legend><?php echo esc_html__( 'Fieldmap', 'object-sync-for-salesforce' ); ?></legend>
171
+		<legend><?php echo esc_html__('Fieldmap', 'object-sync-for-salesforce'); ?></legend>
172 172
 		<table class="wp-list-table widefat striped fields">
173 173
 			<thead>
174 174
 				<tr>
175
-					<th class="column-wordpress_field"><?php echo esc_html__( 'WordPress Field', 'object-sync-for-salesforce' ); ?></th>
176
-					<th class="column-salesforce_field"><?php echo esc_html__( 'Salesforce Field', 'object-sync-for-salesforce' ); ?></th>
177
-					<th class="column-is_prematch"><?php echo esc_html__( 'Prematch', 'object-sync-for-salesforce' ); ?></th>
178
-					<th class="column-is_key"><?php echo esc_html__( 'Salesforce Key', 'object-sync-for-salesforce' ); ?></th>
179
-					<th class="column-direction"><?php echo esc_html__( 'Direction', 'object-sync-for-salesforce' ); ?></th>
180
-					<th class="column-is_delete"><?php echo esc_html__( 'Delete', 'object-sync-for-salesforce' ); ?></th>
175
+					<th class="column-wordpress_field"><?php echo esc_html__('WordPress Field', 'object-sync-for-salesforce'); ?></th>
176
+					<th class="column-salesforce_field"><?php echo esc_html__('Salesforce Field', 'object-sync-for-salesforce'); ?></th>
177
+					<th class="column-is_prematch"><?php echo esc_html__('Prematch', 'object-sync-for-salesforce'); ?></th>
178
+					<th class="column-is_key"><?php echo esc_html__('Salesforce Key', 'object-sync-for-salesforce'); ?></th>
179
+					<th class="column-direction"><?php echo esc_html__('Direction', 'object-sync-for-salesforce'); ?></th>
180
+					<th class="column-is_delete"><?php echo esc_html__('Delete', 'object-sync-for-salesforce'); ?></th>
181 181
 				</tr>
182 182
 			</thead>
183 183
 			<tfoot>
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 						<p><small>
187 187
 							<?php
188 188
 							// translators: the placeholders refer to: 1) the cache clear link, 2) the cache clear link text
189
-							echo sprintf( '<strong>' . esc_html__( 'Note:', 'object-sync-for-salesforce' ) . '</strong>' . esc_html__( ' to map a custom meta field (such as wp_postmeta, wp_usermeta, wp_termmeta, etc.), WordPress must have at least one value for that field. If you add a new meta field and want to map it, make sure to add a value for it and ', 'object-sync-for-salesforce' ) . '<a href="%1$s" id="clear-sfwp-cache">%2$s</a>' . esc_html__( ' to see the field listed here', 'object-sync-for-salesforce' ),
190
-								esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=clear_cache' ) ),
191
-								esc_html__( 'clear the plugin cache', 'object-sync-for-salesforce' )
189
+							echo sprintf('<strong>' . esc_html__('Note:', 'object-sync-for-salesforce') . '</strong>' . esc_html__(' to map a custom meta field (such as wp_postmeta, wp_usermeta, wp_termmeta, etc.), WordPress must have at least one value for that field. If you add a new meta field and want to map it, make sure to add a value for it and ', 'object-sync-for-salesforce') . '<a href="%1$s" id="clear-sfwp-cache">%2$s</a>' . esc_html__(' to see the field listed here', 'object-sync-for-salesforce'),
190
+								esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=clear_cache')),
191
+								esc_html__('clear the plugin cache', 'object-sync-for-salesforce')
192 192
 							);
193 193
 							?>
194 194
 						</small></p>
@@ -197,26 +197,26 @@  discard block
 block discarded – undo
197 197
 			</tfoot>
198 198
 			<tbody>
199 199
 				<?php
200
-				if ( isset( $fieldmap_fields ) && null !== $fieldmap_fields && is_array( $fieldmap_fields ) ) {
201
-					foreach ( $fieldmap_fields as $key => $value ) {
202
-						$key = md5( $key . time() );
200
+				if (isset($fieldmap_fields) && null !== $fieldmap_fields && is_array($fieldmap_fields)) {
201
+					foreach ($fieldmap_fields as $key => $value) {
202
+						$key = md5($key . time());
203 203
 				?>
204 204
 				<tr>
205 205
 					<td class="column-wordpress_field">
206
-						<select name="wordpress_field[<?php echo esc_attr( $key ); ?>]" id="wordpress_field-<?php echo esc_attr( $key ); ?>">
207
-							<option value="">- <?php echo esc_html__( 'Select WordPress field', 'object-sync-for-salesforce' ); ?> -</option>
206
+						<select name="wordpress_field[<?php echo esc_attr($key); ?>]" id="wordpress_field-<?php echo esc_attr($key); ?>">
207
+							<option value="">- <?php echo esc_html__('Select WordPress field', 'object-sync-for-salesforce'); ?> -</option>
208 208
 							<?php
209
-							$wordpress_fields = $this->get_wordpress_object_fields( $wordpress_object );
210
-							foreach ( $wordpress_fields as $wordpress_field ) {
211
-								if ( isset( $value['wordpress_field']['label'] ) && $value['wordpress_field']['label'] === $wordpress_field['key'] ) {
209
+							$wordpress_fields = $this->get_wordpress_object_fields($wordpress_object);
210
+							foreach ($wordpress_fields as $wordpress_field) {
211
+								if (isset($value['wordpress_field']['label']) && $value['wordpress_field']['label'] === $wordpress_field['key']) {
212 212
 									$selected = ' selected';
213 213
 								} else {
214 214
 									$selected = '';
215 215
 								}
216
-								echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
217
-									esc_attr( $wordpress_field['key'] ),
218
-									esc_attr( $selected ),
219
-									esc_html( $wordpress_field['key'] )
216
+								echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
217
+									esc_attr($wordpress_field['key']),
218
+									esc_attr($selected),
219
+									esc_html($wordpress_field['key'])
220 220
 								);
221 221
 							}
222 222
 							?>
@@ -224,27 +224,27 @@  discard block
 block discarded – undo
224 224
 
225 225
 					</td>
226 226
 					<td class="column-salesforce_field">
227
-						<select name="salesforce_field[<?php echo esc_attr( $key ); ?>]" id="salesforce_field-<?php echo esc_attr( $key ); ?>">
228
-							<option value="">- <?php echo esc_html__( 'Select Salesforce field', 'object-sync-for-salesforce' ); ?> -</option>
227
+						<select name="salesforce_field[<?php echo esc_attr($key); ?>]" id="salesforce_field-<?php echo esc_attr($key); ?>">
228
+							<option value="">- <?php echo esc_html__('Select Salesforce field', 'object-sync-for-salesforce'); ?> -</option>
229 229
 							<?php
230 230
 							$salesforce_fields = $this->get_salesforce_object_fields(
231 231
 								array(
232 232
 									'salesforce_object' => $salesforce_object,
233 233
 								)
234 234
 							);
235
-							foreach ( $salesforce_fields as $salesforce_field ) {
236
-								if ( isset( $value['salesforce_field']['name'] ) && $value['salesforce_field']['name'] === $salesforce_field['name'] ) {
235
+							foreach ($salesforce_fields as $salesforce_field) {
236
+								if (isset($value['salesforce_field']['name']) && $value['salesforce_field']['name'] === $salesforce_field['name']) {
237 237
 									$selected = ' selected';
238
-								} elseif ( isset( $value['salesforce_field']['label'] ) && $value['salesforce_field']['label'] === $salesforce_field['name'] ) {
238
+								} elseif (isset($value['salesforce_field']['label']) && $value['salesforce_field']['label'] === $salesforce_field['name']) {
239 239
 									// this conditional is for versions up to 1.1.2, but i think it's fine to leave it for now. if we remove it, people's fieldmaps will not show correctly in the admin.
240 240
 									$selected = ' selected';
241 241
 								} else {
242 242
 									$selected = '';
243 243
 								}
244
-								echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
245
-									esc_attr( $salesforce_field['name'] ),
246
-									esc_attr( $selected ),
247
-									esc_html( $salesforce_field['label'] )
244
+								echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
245
+									esc_attr($salesforce_field['name']),
246
+									esc_attr($selected),
247
+									esc_html($salesforce_field['label'])
248 248
 								);
249 249
 							}
250 250
 							?>
@@ -253,32 +253,32 @@  discard block
 block discarded – undo
253 253
 					</td>
254 254
 					<td class="column-is_prematch">
255 255
 						<?php
256
-						if ( isset( $value['is_prematch'] ) && '1' === $value['is_prematch'] ) {
256
+						if (isset($value['is_prematch']) && '1' === $value['is_prematch']) {
257 257
 							$checked = ' checked';
258 258
 						} else {
259 259
 							$checked = '';
260 260
 						}
261 261
 						?>
262
-						<input type="checkbox" name="is_prematch[<?php echo esc_attr( $key ); ?>]" id="is_prematch-<?php echo esc_attr( $key ); ?>" value="1" <?php echo esc_attr( $checked ); ?> title="<?php echo esc_html__( 'This pair should be checked for existing matches in Salesforce before adding', 'object-sync-for-salesforce' ); ?>" />
262
+						<input type="checkbox" name="is_prematch[<?php echo esc_attr($key); ?>]" id="is_prematch-<?php echo esc_attr($key); ?>" value="1" <?php echo esc_attr($checked); ?> title="<?php echo esc_html__('This pair should be checked for existing matches in Salesforce before adding', 'object-sync-for-salesforce'); ?>" />
263 263
 					</td>
264 264
 					<td class="column-is_key">
265 265
 						<?php
266
-						if ( isset( $value['is_key'] ) && '1' === $value['is_key'] ) {
266
+						if (isset($value['is_key']) && '1' === $value['is_key']) {
267 267
 							$checked = ' checked';
268 268
 						} else {
269 269
 							$checked = '';
270 270
 						}
271 271
 						?>
272
-						<input type="checkbox" name="is_key[<?php echo esc_attr( $key ); ?>]" id="is_key-<?php echo esc_attr( $key ); ?>" value="1" <?php echo esc_attr( $checked ); ?> title="<?php echo esc_html__( 'This Salesforce field is an External ID in Salesforce', 'object-sync-for-salesforce' ); ?>" />
272
+						<input type="checkbox" name="is_key[<?php echo esc_attr($key); ?>]" id="is_key-<?php echo esc_attr($key); ?>" value="1" <?php echo esc_attr($checked); ?> title="<?php echo esc_html__('This Salesforce field is an External ID in Salesforce', 'object-sync-for-salesforce'); ?>" />
273 273
 					</td>
274 274
 					<td class="column-direction">
275 275
 						<?php
276
-						if ( isset( $value['direction'] ) ) {
277
-							if ( 'sf_wp' === $value['direction'] ) {
276
+						if (isset($value['direction'])) {
277
+							if ('sf_wp' === $value['direction']) {
278 278
 								$checked_sf_wp = ' checked';
279 279
 								$checked_wp_sf = '';
280 280
 								$checked_sync  = '';
281
-							} elseif ( 'wp_sf' === $value['direction'] ) {
281
+							} elseif ('wp_sf' === $value['direction']) {
282 282
 								$checked_sf_wp = '';
283 283
 								$checked_wp_sf = ' checked';
284 284
 								$checked_sync  = '';
@@ -294,29 +294,29 @@  discard block
 block discarded – undo
294 294
 						}
295 295
 						?>
296 296
 						<div class="radios">
297
-							<label><input type="radio" value="sf_wp" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-sf-wp" <?php echo esc_attr( $checked_sf_wp ); ?> required> <?php echo esc_html__( 'Salesforce to WordPress', 'object-sync-for-salesforce' ); ?></label>
298
-							<label><input type="radio" value="wp_sf" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-wp-sf" <?php echo esc_attr( $checked_wp_sf ); ?> required> <?php echo esc_html__( 'WordPress to Salesforce', 'object-sync-for-salesforce' ); ?></label>
299
-							<label><input type="radio" value="sync" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-sync" <?php echo esc_attr( $checked_sync ); ?> required> <?php echo esc_html__( 'Sync', 'object-sync-for-salesforce' ); ?></label>
297
+							<label><input type="radio" value="sf_wp" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-sf-wp" <?php echo esc_attr($checked_sf_wp); ?> required> <?php echo esc_html__('Salesforce to WordPress', 'object-sync-for-salesforce'); ?></label>
298
+							<label><input type="radio" value="wp_sf" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-wp-sf" <?php echo esc_attr($checked_wp_sf); ?> required> <?php echo esc_html__('WordPress to Salesforce', 'object-sync-for-salesforce'); ?></label>
299
+							<label><input type="radio" value="sync" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-sync" <?php echo esc_attr($checked_sync); ?> required> <?php echo esc_html__('Sync', 'object-sync-for-salesforce'); ?></label>
300 300
 						</div>
301 301
 					</td>
302 302
 					<td class="column-is_delete">
303
-						<input type="checkbox" name="is_delete[<?php echo esc_attr( $key ); ?>]" id="is_delete-<?php echo esc_attr( $key ); ?>" value="1" />
303
+						<input type="checkbox" name="is_delete[<?php echo esc_attr($key); ?>]" id="is_delete-<?php echo esc_attr($key); ?>" value="1" />
304 304
 					</td>
305 305
 				</tr>
306 306
 				<?php
307 307
 					} // End foreach().
308
-				} elseif ( isset( $wordpress_object ) && isset( $salesforce_object ) ) {
308
+				} elseif (isset($wordpress_object) && isset($salesforce_object)) {
309 309
 				?>
310 310
 				<tr>
311 311
 					<td class="column-wordpress_field">
312 312
 						<select name="wordpress_field[0]" id="wordpress_field-0">
313
-							<option value="">- <?php echo esc_html__( 'Select WordPress field', 'object-sync-for-salesforce' ); ?> -</option>
313
+							<option value="">- <?php echo esc_html__('Select WordPress field', 'object-sync-for-salesforce'); ?> -</option>
314 314
 							<?php
315
-							$wordpress_fields = $this->get_wordpress_object_fields( $wordpress_object );
316
-							foreach ( $wordpress_fields as $wordpress_field ) {
317
-								echo sprintf( '<option value="%1$s">%2$s</option>',
318
-									esc_attr( $wordpress_field['key'] ),
319
-									esc_html( $wordpress_field['key'] )
315
+							$wordpress_fields = $this->get_wordpress_object_fields($wordpress_object);
316
+							foreach ($wordpress_fields as $wordpress_field) {
317
+								echo sprintf('<option value="%1$s">%2$s</option>',
318
+									esc_attr($wordpress_field['key']),
319
+									esc_html($wordpress_field['key'])
320 320
 								);
321 321
 							}
322 322
 							?>
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
 					</td>
325 325
 					<td class="column-salesforce_field">
326 326
 						<select name="salesforce_field[0]" id="salesforce_field-0">
327
-							<option value="">- <?php echo esc_html__( 'Select Salesforce field', 'object-sync-for-salesforce' ); ?> -</option>
327
+							<option value="">- <?php echo esc_html__('Select Salesforce field', 'object-sync-for-salesforce'); ?> -</option>
328 328
 							<?php
329 329
 							$salesforce_fields = $this->get_salesforce_object_fields(
330 330
 								array(
331 331
 									'salesforce_object' => $salesforce_object,
332 332
 								)
333 333
 							);
334
-							foreach ( $salesforce_fields as $salesforce_field ) {
335
-								echo sprintf( '<option value="%1$s">%2$s</option>',
336
-									esc_attr( $salesforce_field['name'] ),
337
-									esc_html( $salesforce_field['label'] )
334
+							foreach ($salesforce_fields as $salesforce_field) {
335
+								echo sprintf('<option value="%1$s">%2$s</option>',
336
+									esc_attr($salesforce_field['name']),
337
+									esc_html($salesforce_field['label'])
338 338
 								);
339 339
 							}
340 340
 							?>
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 					</td>
349 349
 					<td class="column-direction">
350 350
 						<div class="radios">
351
-							<label><input type="radio" value="sf_wp" name="direction[0]" id="direction-0-sf-wp" required> <?php echo esc_html__( 'Salesforce to WordPress', 'object-sync-for-salesforce' ); ?></label>
352
-							<label><input type="radio" value="wp_sf" name="direction[0]" id="direction-0-wp-sf" required> <?php echo esc_html__( 'WordPress to Salesforce', 'object-sync-for-salesforce' ); ?></label>
353
-							<label><input type="radio" value="sync" name="direction[0]" id="direction-0-sync" required checked> <?php echo esc_html__( 'Sync', 'object-sync-for-salesforce' ); ?></label>
351
+							<label><input type="radio" value="sf_wp" name="direction[0]" id="direction-0-sf-wp" required> <?php echo esc_html__('Salesforce to WordPress', 'object-sync-for-salesforce'); ?></label>
352
+							<label><input type="radio" value="wp_sf" name="direction[0]" id="direction-0-wp-sf" required> <?php echo esc_html__('WordPress to Salesforce', 'object-sync-for-salesforce'); ?></label>
353
+							<label><input type="radio" value="sync" name="direction[0]" id="direction-0-sync" required checked> <?php echo esc_html__('Sync', 'object-sync-for-salesforce'); ?></label>
354 354
 						</div>
355 355
 					</td>
356 356
 					<td class="column-is_delete">
@@ -364,17 +364,17 @@  discard block
 block discarded – undo
364 364
 		</table>
365 365
 		<!--<div class="spinner"></div>-->
366 366
 		<?php
367
-		if ( isset( $fieldmap_fields ) && null !== $fieldmap_fields ) {
368
-			$add_button_label = esc_html__( 'Add another field mapping', 'object-sync-for-salesforce' );
367
+		if (isset($fieldmap_fields) && null !== $fieldmap_fields) {
368
+			$add_button_label = esc_html__('Add another field mapping', 'object-sync-for-salesforce');
369 369
 		} else {
370
-			$add_button_label = esc_html__( 'Add field mapping', 'object-sync-for-salesforce' );
370
+			$add_button_label = esc_html__('Add field mapping', 'object-sync-for-salesforce');
371 371
 		}
372 372
 		?>
373 373
 		<p><button type="button" id="add-field-mapping" class="button button-secondary"><?php echo $add_button_label; ?></button></p>
374
-		<p class="description"><?php echo esc_html__( 'Prematch tells the plugin to match records that have the same value before sending data to Salesforce. Salesforce Key indicates the Salesforce field is an External ID. If either of these is checked, the plugin will do an UPSERT to avoid duplicate data when possible.', 'object-sync-for-salesforce' ); ?></p>
374
+		<p class="description"><?php echo esc_html__('Prematch tells the plugin to match records that have the same value before sending data to Salesforce. Salesforce Key indicates the Salesforce field is an External ID. If either of these is checked, the plugin will do an UPSERT to avoid duplicate data when possible.', 'object-sync-for-salesforce'); ?></p>
375 375
 	</fieldset>
376 376
 	<fieldset class="sync_triggers">
377
-		<legend><?php echo esc_html__( 'Action triggers', 'object-sync-for-salesforce' ); ?></legend>
377
+		<legend><?php echo esc_html__('Action triggers', 'object-sync-for-salesforce'); ?></legend>
378 378
 		<div class="checkboxes">
379 379
 			<?php
380 380
 			$wordpress_create_checked  = '';
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 			$salesforce_create_checked = '';
384 384
 			$salesforce_update_checked = '';
385 385
 			$salesforce_delete_checked = '';
386
-			if ( isset( $sync_triggers ) && is_array( $sync_triggers ) ) {
387
-				foreach ( $sync_triggers as $trigger ) {
388
-					switch ( $trigger ) {
386
+			if (isset($sync_triggers) && is_array($sync_triggers)) {
387
+				foreach ($sync_triggers as $trigger) {
388
+					switch ($trigger) {
389 389
 						case $this->mappings->sync_wordpress_create:
390 390
 							$wordpress_create_checked = ' checked';
391 391
 							break;
@@ -408,31 +408,31 @@  discard block
 block discarded – undo
408 408
 				}
409 409
 			}
410 410
 			?>
411
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_create ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-create" <?php echo esc_attr( $wordpress_create_checked ); ?>><?php echo esc_html__( 'WordPress create', 'object-sync-for-salesforce' ); ?></label>
412
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_update ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-update" <?php echo esc_attr( $wordpress_update_checked ); ?>><?php echo esc_html__( 'WordPress update', 'object-sync-for-salesforce' ); ?></label>
413
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_delete ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-delete" <?php echo esc_attr( $wordpress_delete_checked ); ?>><?php echo esc_html__( 'WordPress delete', 'object-sync-for-salesforce' ); ?></label>
414
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_create ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-create" <?php echo esc_attr( $salesforce_create_checked ); ?>><?php echo esc_html__( 'Salesforce create', 'object-sync-for-salesforce' ); ?></label>
415
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_update ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-update" <?php echo esc_attr( $salesforce_update_checked ); ?>><?php echo esc_html__( 'Salesforce update', 'object-sync-for-salesforce' ); ?></label>
416
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_delete ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-delete" <?php echo esc_attr( $salesforce_delete_checked ); ?>><?php echo esc_html__( 'Salesforce delete', 'object-sync-for-salesforce' ); ?></label>
411
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_create); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-create" <?php echo esc_attr($wordpress_create_checked); ?>><?php echo esc_html__('WordPress create', 'object-sync-for-salesforce'); ?></label>
412
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_update); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-update" <?php echo esc_attr($wordpress_update_checked); ?>><?php echo esc_html__('WordPress update', 'object-sync-for-salesforce'); ?></label>
413
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_delete); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-delete" <?php echo esc_attr($wordpress_delete_checked); ?>><?php echo esc_html__('WordPress delete', 'object-sync-for-salesforce'); ?></label>
414
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_create); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-create" <?php echo esc_attr($salesforce_create_checked); ?>><?php echo esc_html__('Salesforce create', 'object-sync-for-salesforce'); ?></label>
415
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_update); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-update" <?php echo esc_attr($salesforce_update_checked); ?>><?php echo esc_html__('Salesforce update', 'object-sync-for-salesforce'); ?></label>
416
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_delete); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-delete" <?php echo esc_attr($salesforce_delete_checked); ?>><?php echo esc_html__('Salesforce delete', 'object-sync-for-salesforce'); ?></label>
417 417
 			<p class="description">
418 418
 				<?php
419 419
 				// translators: placeholders are for the class names: salesforce_push and salesforce_pull
420
-				echo sprintf( esc_html__( 'Select which actions on WordPress objects and Salesforce objects should trigger a synchronization. These settings are used by the %1$s and %2$s classes respectively.', 'object-sync-for-salesforce' ), '<code>salesforce_push</code>', '<code>salesforce_pull</code>' );
420
+				echo sprintf(esc_html__('Select which actions on WordPress objects and Salesforce objects should trigger a synchronization. These settings are used by the %1$s and %2$s classes respectively.', 'object-sync-for-salesforce'), '<code>salesforce_push</code>', '<code>salesforce_pull</code>');
421 421
 				?>
422 422
 			</p>
423 423
 		</div>
424 424
 		<div class="checkboxes">
425
-			<label><input type="checkbox" name="push_async" id="process-async" value="1" <?php echo isset( $push_async ) && '1' === $push_async ? ' checked' : ''; ?>><?php echo esc_html__( 'Process asynchronously', 'object-sync-for-salesforce' ); ?></label>
425
+			<label><input type="checkbox" name="push_async" id="process-async" value="1" <?php echo isset($push_async) && '1' === $push_async ? ' checked' : ''; ?>><?php echo esc_html__('Process asynchronously', 'object-sync-for-salesforce'); ?></label>
426 426
 			<p class="description">
427 427
 				<?php
428 428
 				// translators: placeholder is for WordPress cron method name
429
-				echo sprintf( esc_html__( 'If selected, push data will be queued for processing and synchronized when %s is run. This may increase site performance, but changes will not be reflected in real time.', 'object-sync-for-salesforce' ), '<code>wp_cron</code>' );
429
+				echo sprintf(esc_html__('If selected, push data will be queued for processing and synchronized when %s is run. This may increase site performance, but changes will not be reflected in real time.', 'object-sync-for-salesforce'), '<code>wp_cron</code>');
430 430
 				?>
431 431
 			</p>
432 432
 		</div>
433 433
 		<div class="checkboxes">
434
-			<label><input type="checkbox" name="push_drafts" id="push-drafts" value="1" <?php echo isset( $push_drafts ) && '1' === $push_drafts ? ' checked' : ''; ?>><?php echo esc_html__( 'Push drafts', 'object-sync-for-salesforce' ); ?></label>
435
-			<p class="description"><?php echo esc_html__( 'If selected, WordPress will send drafts of this object type (if it creates drafts for it) to Salesforce.', 'object-sync-for-salesforce' ); ?></p>
434
+			<label><input type="checkbox" name="push_drafts" id="push-drafts" value="1" <?php echo isset($push_drafts) && '1' === $push_drafts ? ' checked' : ''; ?>><?php echo esc_html__('Push drafts', 'object-sync-for-salesforce'); ?></label>
435
+			<p class="description"><?php echo esc_html__('If selected, WordPress will send drafts of this object type (if it creates drafts for it) to Salesforce.', 'object-sync-for-salesforce'); ?></p>
436 436
 		</div>
437 437
 		<?php
438 438
 		/*
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	<?php
452 452
 		submit_button(
453 453
 			// translators: the placeholder refers to the currently selected method (add, edit, or clone)
454
-			sprintf( esc_html__( '%1$s fieldmap', 'object-sync-for-salesforce' ), ucfirst( $method ) )
454
+			sprintf(esc_html__('%1$s fieldmap', 'object-sync-for-salesforce'), ucfirst($method))
455 455
 		);
456 456
 	?>
457 457
 </form>
Please login to merge, or discard this patch.
classes/salesforce_mapping.php 1 patch
Spacing   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param object $logging Object_Sync_Sf_Logging.
61 61
 	 * @throws \Exception
62 62
 	 */
63
-	public function __construct( $wpdb, $version, $slug, $logging ) {
63
+	public function __construct($wpdb, $version, $slug, $logging) {
64 64
 		$this->wpdb    = $wpdb;
65 65
 		$this->version = $version;
66 66
 		$this->slug    = $slug;
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 		$this->sync_sf_delete        = 0x0020;
84 84
 
85 85
 		// Define which events are initialized by which system.
86
-		$this->wordpress_events  = array( $this->sync_wordpress_create, $this->sync_wordpress_update, $this->sync_wordpress_delete );
87
-		$this->salesforce_events = array( $this->sync_sf_create, $this->sync_sf_update, $this->sync_sf_delete );
86
+		$this->wordpress_events  = array($this->sync_wordpress_create, $this->sync_wordpress_update, $this->sync_wordpress_delete);
87
+		$this->salesforce_events = array($this->sync_sf_create, $this->sync_sf_update, $this->sync_sf_delete);
88 88
 
89 89
 		// Constants for the directions to map things.
90 90
 		$this->direction_wordpress_sf = 'wp_sf';
91 91
 		$this->direction_sf_wordpress = 'sf_wp';
92 92
 		$this->direction_sync         = 'sync';
93 93
 
94
-		$this->direction_wordpress  = array( $this->direction_wordpress_sf, $this->direction_sync );
95
-		$this->direction_salesforce = array( $this->direction_sf_wordpress, $this->direction_sync );
94
+		$this->direction_wordpress  = array($this->direction_wordpress_sf, $this->direction_sync);
95
+		$this->direction_salesforce = array($this->direction_sf_wordpress, $this->direction_sync);
96 96
 
97 97
 		// This is used when we map a record with default or Master.
98 98
 		$this->salesforce_default_record_type = 'default';
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 		// Salesforce has multipicklists and they have a delimiter.
101 101
 		$this->array_delimiter = ';';
102 102
 		// What data types in Salesforce should be an array?
103
-		$this->array_types_from_salesforce = array( 'multipicklist' );
103
+		$this->array_types_from_salesforce = array('multipicklist');
104 104
 		// What data types in Salesforce should be a date field?
105
-		$this->date_types_from_salesforce = array( 'date', 'datetime' );
105
+		$this->date_types_from_salesforce = array('date', 'datetime');
106 106
 		// What data types in Salesforce should be an integer?
107
-		$this->int_types_from_salesforce = array( 'integer', 'boolean' );
107
+		$this->int_types_from_salesforce = array('integer', 'boolean');
108 108
 
109 109
 		// Max length for a mapping field.
110 110
 		$this->name_length = 128;
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 	 * @param array $salesforce_fields The fields for the Salesforce side of the mapping.
124 124
 	 * @throws \Exception
125 125
 	 */
126
-	public function create_fieldmap( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
127
-		$data = $this->setup_fieldmap_data( $posted, $wordpress_fields, $salesforce_fields );
128
-		if ( version_compare( $this->version, '1.2.5', '>=' ) ) {
126
+	public function create_fieldmap($posted = array(), $wordpress_fields = array(), $salesforce_fields = array()) {
127
+		$data = $this->setup_fieldmap_data($posted, $wordpress_fields, $salesforce_fields);
128
+		if (version_compare($this->version, '1.2.5', '>=')) {
129 129
 			$data['version'] = $this->version;
130 130
 		}
131
-		$insert = $this->wpdb->insert( $this->fieldmap_table, $data );
132
-		if ( 1 === $insert ) {
131
+		$insert = $this->wpdb->insert($this->fieldmap_table, $data);
132
+		if (1 === $insert) {
133 133
 			return $this->wpdb->insert_id;
134 134
 		} else {
135 135
 			return false;
@@ -145,29 +145,29 @@  discard block
 block discarded – undo
145 145
 	 * @return Array $map a single mapping or $mappings, an array of mappings.
146 146
 	 * @throws \Exception
147 147
 	 */
148
-	public function get_fieldmaps( $id = null, $conditions = array(), $reset = false ) {
148
+	public function get_fieldmaps($id = null, $conditions = array(), $reset = false) {
149 149
 		$table = $this->fieldmap_table;
150
-		if ( null !== $id ) { // get one fieldmap.
151
-			$map                                    = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );
152
-			$map['salesforce_record_types_allowed'] = maybe_unserialize( $map['salesforce_record_types_allowed'] );
150
+		if (null !== $id) { // get one fieldmap.
151
+			$map                                    = $this->wpdb->get_row('SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A);
152
+			$map['salesforce_record_types_allowed'] = maybe_unserialize($map['salesforce_record_types_allowed']);
153 153
 
154
-			$map['fields']        = maybe_unserialize( $map['fields'] );
155
-			$map['sync_triggers'] = maybe_unserialize( $map['sync_triggers'] );
154
+			$map['fields']        = maybe_unserialize($map['fields']);
155
+			$map['sync_triggers'] = maybe_unserialize($map['sync_triggers']);
156 156
 			return $map;
157
-		} elseif ( ! empty( $conditions ) ) { // get multiple but with a limitation.
157
+		} elseif ( ! empty($conditions)) { // get multiple but with a limitation.
158 158
 			$mappings    = array();
159 159
 			$record_type = '';
160 160
 
161 161
 			// Assemble the SQL.
162
-			if ( ! empty( $conditions ) ) {
162
+			if ( ! empty($conditions)) {
163 163
 				$where = ' WHERE ';
164 164
 				$i     = 0;
165
-				foreach ( $conditions as $key => $value ) {
166
-					if ( 'salesforce_record_type' === $key ) {
167
-						$record_type = sanitize_text_field( $value );
165
+				foreach ($conditions as $key => $value) {
166
+					if ('salesforce_record_type' === $key) {
167
+						$record_type = sanitize_text_field($value);
168 168
 					} else {
169 169
 						$i++;
170
-						if ( $i > 1 ) {
170
+						if ($i > 1) {
171 171
 							$where .= ' AND ';
172 172
 						}
173 173
 						$where .= '`' . $key . '` = "' . $value . '"';
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 				$where = '';
178 178
 			}
179 179
 
180
-			$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . ' ORDER BY `weight`', ARRAY_A );
180
+			$mappings = $this->wpdb->get_results('SELECT * FROM ' . $table . $where . ' ORDER BY `weight`', ARRAY_A);
181 181
 
182
-			if ( ! empty( $mappings ) ) {
183
-				$mappings = $this->prepare_fieldmap_data( $mappings, $record_type );
182
+			if ( ! empty($mappings)) {
183
+				$mappings = $this->prepare_fieldmap_data($mappings, $record_type);
184 184
 			}
185 185
 
186 186
 			return $mappings;
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 		} else { // get all of the mappings. ALL THE MAPPINGS.
189 189
 
190 190
 			// if the version is greater than or equal to 1.2.5, the fieldmap table has a version column
191
-			if ( version_compare( $this->version, '1.2.5', '>=' ) ) {
192
-				$mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight`, `version` FROM $table", ARRAY_A );
191
+			if (version_compare($this->version, '1.2.5', '>=')) {
192
+				$mappings = $this->wpdb->get_results("SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight`, `version` FROM $table", ARRAY_A);
193 193
 			} else {
194
-				$mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight` FROM $table", ARRAY_A );
194
+				$mappings = $this->wpdb->get_results("SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight` FROM $table", ARRAY_A);
195 195
 			}
196 196
 
197
-			if ( ! empty( $mappings ) ) {
198
-				$mappings = $this->prepare_fieldmap_data( $mappings );
197
+			if ( ! empty($mappings)) {
198
+				$mappings = $this->prepare_fieldmap_data($mappings);
199 199
 			}
200 200
 
201 201
 			return $mappings;
@@ -211,29 +211,29 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return Array of mapped fields
213 213
 	 */
214
-	public function get_mapped_fields( $mapping, $directions = array() ) {
214
+	public function get_mapped_fields($mapping, $directions = array()) {
215 215
 		$mapped_fields = array();
216
-		foreach ( $mapping['fields'] as $fields ) {
217
-			if ( empty( $directions ) || in_array( $fields['direction'], $directions, true ) ) {
216
+		foreach ($mapping['fields'] as $fields) {
217
+			if (empty($directions) || in_array($fields['direction'], $directions, true)) {
218 218
 
219
-				if ( version_compare( $this->version, '1.2.0', '>=' ) && isset( $fields['salesforce_field']['name'] ) ) {
219
+				if (version_compare($this->version, '1.2.0', '>=') && isset($fields['salesforce_field']['name'])) {
220 220
 					$array_key = 'name';
221 221
 				} else {
222 222
 					$array_key = 'label';
223 223
 				}
224 224
 
225 225
 				// Some field map types (Relation) store a collection of SF objects.
226
-				if ( is_array( $fields['salesforce_field'] ) && ! isset( $fields['salesforce_field'][ $array_key ] ) ) {
227
-					foreach ( $fields['salesforce_field'] as $sf_field ) {
228
-						$mapped_fields[ $sf_field[ $array_key ] ] = $sf_field[ $array_key ];
226
+				if (is_array($fields['salesforce_field']) && ! isset($fields['salesforce_field'][$array_key])) {
227
+					foreach ($fields['salesforce_field'] as $sf_field) {
228
+						$mapped_fields[$sf_field[$array_key]] = $sf_field[$array_key];
229 229
 					}
230 230
 				} else { // The rest are just a name/value pair.
231
-					$mapped_fields[ $fields['salesforce_field'][ $array_key ] ] = $fields['salesforce_field'][ $array_key ];
231
+					$mapped_fields[$fields['salesforce_field'][$array_key]] = $fields['salesforce_field'][$array_key];
232 232
 				}
233 233
 			}
234 234
 		}
235 235
 
236
-		if ( ! empty( $this->get_mapped_record_types ) ) {
236
+		if ( ! empty($this->get_mapped_record_types)) {
237 237
 			$mapped_fields['RecordTypeId'] = 'RecordTypeId';
238 238
 		}
239 239
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @param Array $mapping A mapping from which we wish to estract the record type.
247 247
 	 * @return Array of mappings. Empty if the mapping's record type is default, else full of the record types.
248 248
 	 */
249
-	public function get_mapped_record_types( $mapping ) {
250
-		return $mapping['salesforce_record_type_default'] === $this->salesforce_default_record_type ? array() : array_filter( maybe_unserialize( $mapping['salesforce_record_types_allowed'] ) );
249
+	public function get_mapped_record_types($mapping) {
250
+		return $mapping['salesforce_record_type_default'] === $this->salesforce_default_record_type ? array() : array_filter(maybe_unserialize($mapping['salesforce_record_types_allowed']));
251 251
 	}
252 252
 
253 253
 	/**
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	 * @return $map
261 261
 	 * @throws \Exception
262 262
 	 */
263
-	public function update_fieldmap( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array(), $id = '' ) {
264
-		$data = $this->setup_fieldmap_data( $posted, $wordpress_fields, $salesforce_fields );
265
-		if ( version_compare( $this->version, '1.2.5', '>=' ) && ! isset( $data['updated'] ) ) {
263
+	public function update_fieldmap($posted = array(), $wordpress_fields = array(), $salesforce_fields = array(), $id = '') {
264
+		$data = $this->setup_fieldmap_data($posted, $wordpress_fields, $salesforce_fields);
265
+		if (version_compare($this->version, '1.2.5', '>=') && ! isset($data['updated'])) {
266 266
 			$data['version'] = $this->version;
267 267
 		}
268 268
 		$update = $this->wpdb->update(
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				'id' => $id,
273 273
 			)
274 274
 		);
275
-		if ( false === $update ) {
275
+		if (false === $update) {
276 276
 			return false;
277 277
 		} else {
278 278
 			return true;
@@ -288,76 +288,76 @@  discard block
 block discarded – undo
288 288
 	 * @param array $salesforce_fields The fields for the Salesforce side of the mapping.
289 289
 	 * @return $data
290 290
 	 */
291
-	private function setup_fieldmap_data( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
291
+	private function setup_fieldmap_data($posted = array(), $wordpress_fields = array(), $salesforce_fields = array()) {
292 292
 		$data = array(
293 293
 			'label'             => $posted['label'],
294
-			'name'              => sanitize_title( $posted['label'] ),
294
+			'name'              => sanitize_title($posted['label']),
295 295
 			'salesforce_object' => $posted['salesforce_object'],
296 296
 			'wordpress_object'  => $posted['wordpress_object'],
297 297
 		);
298
-		if ( isset( $posted['wordpress_field'] ) && is_array( $posted['wordpress_field'] ) && isset( $posted['salesforce_field'] ) && is_array( $posted['salesforce_field'] ) ) {
298
+		if (isset($posted['wordpress_field']) && is_array($posted['wordpress_field']) && isset($posted['salesforce_field']) && is_array($posted['salesforce_field'])) {
299 299
 			$setup['fields'] = array();
300
-			foreach ( $posted['wordpress_field'] as $key => $value ) {
301
-				$method_key = array_search( $value, array_column( $wordpress_fields, 'key' ), true );
302
-				if ( ! isset( $posted['direction'][ $key ] ) ) {
303
-					$posted['direction'][ $key ] = 'sync';
300
+			foreach ($posted['wordpress_field'] as $key => $value) {
301
+				$method_key = array_search($value, array_column($wordpress_fields, 'key'), true);
302
+				if ( ! isset($posted['direction'][$key])) {
303
+					$posted['direction'][$key] = 'sync';
304 304
 				}
305
-				if ( ! isset( $posted['is_prematch'][ $key ] ) ) {
306
-					$posted['is_prematch'][ $key ] = false;
305
+				if ( ! isset($posted['is_prematch'][$key])) {
306
+					$posted['is_prematch'][$key] = false;
307 307
 				}
308
-				if ( ! isset( $posted['is_key'][ $key ] ) ) {
309
-					$posted['is_key'][ $key ] = false;
308
+				if ( ! isset($posted['is_key'][$key])) {
309
+					$posted['is_key'][$key] = false;
310 310
 				}
311
-				if ( ! isset( $posted['is_delete'][ $key ] ) ) {
312
-					$posted['is_delete'][ $key ] = false;
311
+				if ( ! isset($posted['is_delete'][$key])) {
312
+					$posted['is_delete'][$key] = false;
313 313
 				}
314
-				if ( false === $posted['is_delete'][ $key ] ) {
314
+				if (false === $posted['is_delete'][$key]) {
315 315
 					// I think it's good to over-mention that updateable is really how the Salesforce api spells it.
316
-					$updateable_key = array_search( $posted['salesforce_field'][ $key ], array_column( $salesforce_fields, 'name' ), true );
316
+					$updateable_key = array_search($posted['salesforce_field'][$key], array_column($salesforce_fields, 'name'), true);
317 317
 
318 318
 					$salesforce_field_attributes = array();
319
-					foreach ( $salesforce_fields[ $updateable_key ] as $sf_key => $sf_value ) {
320
-						if ( isset( $sf_value ) && ! is_array( $sf_value ) ) {
321
-							$salesforce_field_attributes[ $sf_key ] = esc_attr( $sf_value );
322
-						} elseif ( ! empty( $sf_value ) && is_array( $sf_value ) ) {
323
-							$salesforce_field_attributes[ $sf_key ] = maybe_unserialize( $sf_value );
319
+					foreach ($salesforce_fields[$updateable_key] as $sf_key => $sf_value) {
320
+						if (isset($sf_value) && ! is_array($sf_value)) {
321
+							$salesforce_field_attributes[$sf_key] = esc_attr($sf_value);
322
+						} elseif ( ! empty($sf_value) && is_array($sf_value)) {
323
+							$salesforce_field_attributes[$sf_key] = maybe_unserialize($sf_value);
324 324
 						} else {
325
-							$salesforce_field_attributes[ $sf_key ] = '';
325
+							$salesforce_field_attributes[$sf_key] = '';
326 326
 						}
327 327
 					}
328 328
 
329
-					$setup['fields'][ $key ] = array(
329
+					$setup['fields'][$key] = array(
330 330
 						'wordpress_field'  => array(
331
-							'label'   => sanitize_text_field( $posted['wordpress_field'][ $key ] ),
332
-							'methods' => maybe_unserialize( $wordpress_fields[ $method_key ]['methods'] ),
333
-							'type'    => isset( $wordpress_fields[ $method_key ]['type'] ) ? sanitize_text_field( $wordpress_fields[ $method_key ]['type'] ) : 'text',
331
+							'label'   => sanitize_text_field($posted['wordpress_field'][$key]),
332
+							'methods' => maybe_unserialize($wordpress_fields[$method_key]['methods']),
333
+							'type'    => isset($wordpress_fields[$method_key]['type']) ? sanitize_text_field($wordpress_fields[$method_key]['type']) : 'text',
334 334
 						),
335 335
 						'salesforce_field' => $salesforce_field_attributes,
336
-						'is_prematch'      => sanitize_text_field( $posted['is_prematch'][ $key ] ),
337
-						'is_key'           => sanitize_text_field( $posted['is_key'][ $key ] ),
338
-						'direction'        => sanitize_text_field( $posted['direction'][ $key ] ),
339
-						'is_delete'        => sanitize_text_field( $posted['is_delete'][ $key ] ),
336
+						'is_prematch'      => sanitize_text_field($posted['is_prematch'][$key]),
337
+						'is_key'           => sanitize_text_field($posted['is_key'][$key]),
338
+						'direction'        => sanitize_text_field($posted['direction'][$key]),
339
+						'is_delete'        => sanitize_text_field($posted['is_delete'][$key]),
340 340
 					);
341 341
 
342 342
 					// If the WordPress key or the Salesforce key are blank, remove this incomplete mapping.
343 343
 					// This prevents https://github.com/MinnPost/object-sync-for-salesforce/issues/82 .
344 344
 					if (
345
-						empty( $setup['fields'][ $key ]['wordpress_field']['label'] )
345
+						empty($setup['fields'][$key]['wordpress_field']['label'])
346 346
 						||
347
-						empty( $setup['fields'][ $key ]['salesforce_field']['name'] )
347
+						empty($setup['fields'][$key]['salesforce_field']['name'])
348 348
 					) {
349
-						unset( $setup['fields'][ $key ] );
349
+						unset($setup['fields'][$key]);
350 350
 					}
351 351
 				}
352 352
 			} // End foreach() on WordPress fields.
353
-			$data['fields'] = maybe_serialize( $setup['fields'] );
354
-		} elseif ( isset( $posted['fields'] ) && is_array( $posted['fields'] ) ) {
353
+			$data['fields'] = maybe_serialize($setup['fields']);
354
+		} elseif (isset($posted['fields']) && is_array($posted['fields'])) {
355 355
 			// if $posted['fields'] is already set, use that
356
-			$data['fields'] = maybe_serialize( $posted['fields'] );
356
+			$data['fields'] = maybe_serialize($posted['fields']);
357 357
 		} // End if() WordPress fields are present.
358 358
 
359
-		if ( isset( $posted['salesforce_record_types_allowed'] ) ) {
360
-			$data['salesforce_record_types_allowed'] = maybe_serialize( $posted['salesforce_record_types_allowed'] );
359
+		if (isset($posted['salesforce_record_types_allowed'])) {
360
+			$data['salesforce_record_types_allowed'] = maybe_serialize($posted['salesforce_record_types_allowed']);
361 361
 		} else {
362 362
 			$data['salesforce_record_types_allowed'] = maybe_serialize(
363 363
 				array(
@@ -365,29 +365,29 @@  discard block
 block discarded – undo
365 365
 				)
366 366
 			);
367 367
 		}
368
-		if ( isset( $posted['salesforce_record_type_default'] ) ) {
368
+		if (isset($posted['salesforce_record_type_default'])) {
369 369
 			$data['salesforce_record_type_default'] = $posted['salesforce_record_type_default'];
370 370
 		} else {
371
-			$data['salesforce_record_type_default'] = maybe_serialize( $this->salesforce_default_record_type );
371
+			$data['salesforce_record_type_default'] = maybe_serialize($this->salesforce_default_record_type);
372 372
 		}
373
-		if ( isset( $posted['pull_trigger_field'] ) ) {
373
+		if (isset($posted['pull_trigger_field'])) {
374 374
 			$data['pull_trigger_field'] = $posted['pull_trigger_field'];
375 375
 		}
376
-		if ( isset( $posted['sync_triggers'] ) && is_array( $posted['sync_triggers'] ) ) {
376
+		if (isset($posted['sync_triggers']) && is_array($posted['sync_triggers'])) {
377 377
 			$setup['sync_triggers'] = array();
378
-			foreach ( $posted['sync_triggers'] as $key => $value ) {
379
-				$setup['sync_triggers'][ $key ] = esc_html( $posted['sync_triggers'][ $key ] );
378
+			foreach ($posted['sync_triggers'] as $key => $value) {
379
+				$setup['sync_triggers'][$key] = esc_html($posted['sync_triggers'][$key]);
380 380
 			}
381 381
 		} else {
382 382
 			$setup['sync_triggers'] = array();
383 383
 		}
384
-		$data['sync_triggers'] = maybe_serialize( $setup['sync_triggers'] );
385
-		if ( isset( $posted['pull_trigger_field'] ) ) {
384
+		$data['sync_triggers'] = maybe_serialize($setup['sync_triggers']);
385
+		if (isset($posted['pull_trigger_field'])) {
386 386
 			$data['pull_trigger_field'] = $posted['pull_trigger_field'];
387 387
 		}
388
-		$data['push_async']  = isset( $posted['push_async'] ) ? $posted['push_async'] : '';
389
-		$data['push_drafts'] = isset( $posted['push_drafts'] ) ? $posted['push_drafts'] : '';
390
-		$data['weight']      = isset( $posted['weight'] ) ? $posted['weight'] : '';
388
+		$data['push_async']  = isset($posted['push_async']) ? $posted['push_async'] : '';
389
+		$data['push_drafts'] = isset($posted['push_drafts']) ? $posted['push_drafts'] : '';
390
+		$data['weight']      = isset($posted['weight']) ? $posted['weight'] : '';
391 391
 		return $data;
392 392
 	}
393 393
 
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 	 * @return Boolean
399 399
 	 * @throws \Exception
400 400
 	 */
401
-	public function delete_fieldmap( $id = '' ) {
401
+	public function delete_fieldmap($id = '') {
402 402
 		$data   = array(
403 403
 			'id' => $id,
404 404
 		);
405
-		$delete = $this->wpdb->delete( $this->fieldmap_table, $data );
406
-		if ( 1 === $delete ) {
405
+		$delete = $this->wpdb->delete($this->fieldmap_table, $data);
406
+		if (1 === $delete) {
407 407
 			return true;
408 408
 		} else {
409 409
 			return false;
@@ -417,27 +417,27 @@  discard block
 block discarded – undo
417 417
 	 * @return false|Int of field mapping between WordPress and Salesforce objects
418 418
 	 * @throws \Exception
419 419
 	 */
420
-	public function create_object_map( $posted = array() ) {
421
-		$data            = $this->setup_object_map_data( $posted );
422
-		$data['created'] = current_time( 'mysql' );
420
+	public function create_object_map($posted = array()) {
421
+		$data            = $this->setup_object_map_data($posted);
422
+		$data['created'] = current_time('mysql');
423 423
 		// Check to see if we don't know the salesforce id and it is not a temporary id, or if this is pending.
424 424
 		// If it is using a temporary id, the map will get updated after it finishes running; it won't call this method unless there's an error, which we should log.
425
-		if ( substr( $data['salesforce_id'], 0, 7 ) !== 'tmp_sf_' || 'pending' === $data['action'] ) {
426
-			unset( $data['action'] );
427
-			$insert = $this->wpdb->insert( $this->object_map_table, $data );
425
+		if (substr($data['salesforce_id'], 0, 7) !== 'tmp_sf_' || 'pending' === $data['action']) {
426
+			unset($data['action']);
427
+			$insert = $this->wpdb->insert($this->object_map_table, $data);
428 428
 		} else {
429 429
 			$status = 'error';
430
-			if ( isset( $this->logging ) ) {
430
+			if (isset($this->logging)) {
431 431
 				$logging = $this->logging;
432
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
433
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
432
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
433
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
434 434
 			}
435 435
 			$logging->setup(
436 436
 				sprintf(
437 437
 					// translators: %1$s is the name of a WordPress object. %2$s is the id of that object.
438
-					esc_html__( 'Error Mapping: error caused by trying to map the WordPress %1$s with ID of %2$s to Salesforce ID starting with "tmp_sf_", which is invalid.', 'object-sync-for-salesforce' ),
439
-					esc_attr( $data['wordpress_object'] ),
440
-					absint( $data['wordpress_id'] )
438
+					esc_html__('Error Mapping: error caused by trying to map the WordPress %1$s with ID of %2$s to Salesforce ID starting with "tmp_sf_", which is invalid.', 'object-sync-for-salesforce'),
439
+					esc_attr($data['wordpress_object']),
440
+					absint($data['wordpress_id'])
441 441
 				),
442 442
 				'',
443 443
 				0,
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 			);
447 447
 			return false;
448 448
 		}
449
-		if ( 1 === $insert ) {
449
+		if (1 === $insert) {
450 450
 			return $this->wpdb->insert_id;
451
-		} elseif ( false !== strpos( $this->wpdb->last_error, 'Duplicate entry' ) ) {
452
-			$mapping = $this->load_by_salesforce( $data['salesforce_id'] );
451
+		} elseif (false !== strpos($this->wpdb->last_error, 'Duplicate entry')) {
452
+			$mapping = $this->load_by_salesforce($data['salesforce_id']);
453 453
 			$id      = $mapping['id'];
454 454
 			$status  = 'error';
455
-			if ( isset( $this->logging ) ) {
455
+			if (isset($this->logging)) {
456 456
 				$logging = $this->logging;
457
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
458
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
457
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
458
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
459 459
 			}
460 460
 			$logging->setup(
461 461
 				sprintf(
462 462
 					// translators: %1$s is the status word "Error". %1$s is the Id of a Salesforce object. %2$s is the ID of a mapping object.
463
-					esc_html__( 'Error: Mapping: there is already a WordPress object mapped to the Salesforce object %1$s and the mapping object ID is %2$s', 'object-sync-for-salesforce' ),
464
-					esc_attr( $data['salesforce_id'] ),
465
-					absint( $id )
463
+					esc_html__('Error: Mapping: there is already a WordPress object mapped to the Salesforce object %1$s and the mapping object ID is %2$s', 'object-sync-for-salesforce'),
464
+					esc_attr($data['salesforce_id']),
465
+					absint($id)
466 466
 				),
467 467
 				'',
468 468
 				0,
@@ -483,18 +483,18 @@  discard block
 block discarded – undo
483 483
 	 * @return $map or $mappings
484 484
 	 * @throws \Exception
485 485
 	 */
486
-	public function get_object_maps( $conditions = array(), $reset = false ) {
486
+	public function get_object_maps($conditions = array(), $reset = false) {
487 487
 		$table = $this->object_map_table;
488 488
 		$order = ' ORDER BY object_updated, created';
489
-		if ( ! empty( $conditions ) ) { // get multiple but with a limitation.
489
+		if ( ! empty($conditions)) { // get multiple but with a limitation.
490 490
 			$mappings = array();
491 491
 
492
-			if ( ! empty( $conditions ) ) {
492
+			if ( ! empty($conditions)) {
493 493
 				$where = ' WHERE ';
494 494
 				$i     = 0;
495
-				foreach ( $conditions as $key => $value ) {
495
+				foreach ($conditions as $key => $value) {
496 496
 					$i++;
497
-					if ( $i > 1 ) {
497
+					if ($i > 1) {
498 498
 						$where .= ' AND ';
499 499
 					}
500 500
 					$where .= '`' . $key . '` = "' . $value . '"';
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 				$where = '';
504 504
 			}
505 505
 
506
-			$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
507
-			if ( ! empty( $mappings ) && 1 === $this->wpdb->num_rows ) {
506
+			$mappings = $this->wpdb->get_results('SELECT * FROM ' . $table . $where . $order, ARRAY_A);
507
+			if ( ! empty($mappings) && 1 === $this->wpdb->num_rows) {
508 508
 				$mappings = $mappings[0];
509 509
 			}
510 510
 		} else { // get all of the mappings. ALL THE MAPPINGS.
511
-			$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $order, ARRAY_A );
512
-			if ( ! empty( $mappings ) && 1 === $this->wpdb->num_rows ) {
511
+			$mappings = $this->wpdb->get_results('SELECT * FROM ' . $table . $order, ARRAY_A);
512
+			if ( ! empty($mappings) && 1 === $this->wpdb->num_rows) {
513 513
 				$mappings = $mappings[0];
514 514
 			}
515 515
 		}
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 	 * @return $map
527 527
 	 * @throws \Exception
528 528
 	 */
529
-	public function update_object_map( $posted = array(), $id = '' ) {
530
-		$data = $this->setup_object_map_data( $posted );
531
-		if ( ! isset( $data['object_updated'] ) ) {
532
-			$data['object_updated'] = current_time( 'mysql' );
529
+	public function update_object_map($posted = array(), $id = '') {
530
+		$data = $this->setup_object_map_data($posted);
531
+		if ( ! isset($data['object_updated'])) {
532
+			$data['object_updated'] = current_time('mysql');
533 533
 		}
534 534
 		$update = $this->wpdb->update(
535 535
 			$this->object_map_table,
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 				'id' => $id,
539 539
 			)
540 540
 		);
541
-		if ( false === $update ) {
541
+		if (false === $update) {
542 542
 			return false;
543 543
 		} else {
544 544
 			return true;
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
 	 * @param array $posted It's $_POST.
552 552
 	 * @return $data Filtered array with only the keys that are in the object map database table. Strips out things from WordPress form if they're present.
553 553
 	 */
554
-	private function setup_object_map_data( $posted = array() ) {
555
-		$allowed_fields   = $this->wpdb->get_col( "DESC {$this->object_map_table}", 0 );
554
+	private function setup_object_map_data($posted = array()) {
555
+		$allowed_fields   = $this->wpdb->get_col("DESC {$this->object_map_table}", 0);
556 556
 		$allowed_fields[] = 'action'; // we use this in both directions even though it isn't in the database; we remove it from the array later if it is present
557 557
 
558
-		$data = array_intersect_key( $posted, array_flip( $allowed_fields ) );
558
+		$data = array_intersect_key($posted, array_flip($allowed_fields));
559 559
 		return $data;
560 560
 	}
561 561
 
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
 	 * @param array $id The ID of the object map row.
566 566
 	 * @throws \Exception
567 567
 	 */
568
-	public function delete_object_map( $id = '' ) {
568
+	public function delete_object_map($id = '') {
569 569
 		$data   = array(
570 570
 			'id' => $id,
571 571
 		);
572
-		$delete = $this->wpdb->delete( $this->object_map_table, $data );
573
-		if ( 1 === $delete ) {
572
+		$delete = $this->wpdb->delete($this->object_map_table, $data);
573
+		if (1 === $delete) {
574 574
 			return true;
575 575
 		} else {
576 576
 			return false;
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 	 * @param string $direction Whether this is part of a push or pull action
584 584
 	 * @return $id is a temporary string that will be replaced if the modification is successful
585 585
 	 */
586
-	public function generate_temporary_id( $direction ) {
587
-		if ( 'push' === $direction ) {
586
+	public function generate_temporary_id($direction) {
587
+		if ('push' === $direction) {
588 588
 			$prefix = 'tmp_sf_';
589
-		} elseif ( 'pull' === $direction ) {
589
+		} elseif ('pull' === $direction) {
590 590
 			$prefix = 'tmp_wp_';
591 591
 		}
592
-		$id = uniqid( $prefix, true );
592
+		$id = uniqid($prefix, true);
593 593
 		return $id;
594 594
 	}
595 595
 
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
 	 * @return SalesforceMappingObject
604 604
 	 *   The requested SalesforceMappingObject or FALSE if none was found.
605 605
 	 */
606
-	public function load_by_wordpress( $object_type, $object_id, $reset = false ) {
606
+	public function load_by_wordpress($object_type, $object_id, $reset = false) {
607 607
 		$conditions = array(
608 608
 			'wordpress_id'     => $object_id,
609 609
 			'wordpress_object' => $object_type,
610 610
 		);
611
-		return $this->get_object_maps( $conditions, $reset );
611
+		return $this->get_object_maps($conditions, $reset);
612 612
 	}
613 613
 
614 614
 	/**
@@ -620,24 +620,24 @@  discard block
 block discarded – undo
620 620
 	 * @return array $map
621 621
 	 *   The most recent fieldmap
622 622
 	 */
623
-	public function load_by_salesforce( $salesforce_id, $reset = false ) {
623
+	public function load_by_salesforce($salesforce_id, $reset = false) {
624 624
 		$conditions = array(
625 625
 			'salesforce_id' => $salesforce_id,
626 626
 		);
627 627
 
628
-		$map = $this->get_object_maps( $conditions, $reset );
628
+		$map = $this->get_object_maps($conditions, $reset);
629 629
 
630
-		if ( isset( $map[0] ) && is_array( $map[0] ) && count( $map ) > 1 ) {
630
+		if (isset($map[0]) && is_array($map[0]) && count($map) > 1) {
631 631
 			$status = 'notice';
632 632
 			$log    = '';
633 633
 			$log   .= 'Mapping: there is more than one mapped WordPress object for the Salesforce object ' . $salesforce_id . '. These WordPress IDs are: ';
634 634
 			$i      = 0;
635
-			foreach ( $map as $mapping ) {
635
+			foreach ($map as $mapping) {
636 636
 				$i++;
637
-				if ( isset( $mapping['wordpress_id'] ) ) {
637
+				if (isset($mapping['wordpress_id'])) {
638 638
 					$log .= 'object type: ' . $mapping['wordpress_object'] . ', id: ' . $mapping['wordpress_id'];
639 639
 				}
640
-				if ( count( $map ) !== $i ) {
640
+				if (count($map) !== $i) {
641 641
 					$log .= '; ';
642 642
 				} else {
643 643
 					$log .= '.';
@@ -645,16 +645,16 @@  discard block
 block discarded – undo
645 645
 			}
646 646
 			$map = $map[0];
647 647
 			// Create log entry for multiple maps.
648
-			if ( isset( $this->logging ) ) {
648
+			if (isset($this->logging)) {
649 649
 				$logging = $this->logging;
650
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
651
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
650
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
651
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
652 652
 			}
653 653
 			$logging->setup(
654 654
 				sprintf(
655 655
 					// translators: %1$s is the Id of a Salesforce object.
656
-					esc_html__( 'Notice: Mapping: there is more than one mapped WordPress object for the Salesforce object %2$s', 'object-sync-for-salesforce' ),
657
-					esc_attr( $salesforce_id )
656
+					esc_html__('Notice: Mapping: there is more than one mapped WordPress object for the Salesforce object %2$s', 'object-sync-for-salesforce'),
657
+					esc_attr($salesforce_id)
658 658
 				),
659 659
 				$log,
660 660
 				0,
@@ -677,20 +677,20 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return array Associative array of key value pairs.
679 679
 	 */
680
-	public function map_params( $mapping, $object, $trigger, $use_soap = false, $is_new = true ) {
680
+	public function map_params($mapping, $object, $trigger, $use_soap = false, $is_new = true) {
681 681
 
682 682
 		$params = array();
683 683
 
684
-		foreach ( $mapping['fields'] as $fieldmap ) {
684
+		foreach ($mapping['fields'] as $fieldmap) {
685 685
 
686
-			$wordpress_haystack  = array_values( $this->wordpress_events );
687
-			$salesforce_haystack = array_values( $this->salesforce_events );
686
+			$wordpress_haystack  = array_values($this->wordpress_events);
687
+			$salesforce_haystack = array_values($this->salesforce_events);
688 688
 
689
-			$fieldmap['wordpress_field']['methods'] = maybe_unserialize( $fieldmap['wordpress_field']['methods'] );
689
+			$fieldmap['wordpress_field']['methods'] = maybe_unserialize($fieldmap['wordpress_field']['methods']);
690 690
 
691 691
 			$wordpress_field = $fieldmap['wordpress_field']['label'];
692 692
 
693
-			if ( version_compare( $this->version, '1.2.0', '>=' ) && isset( $fieldmap['salesforce_field']['name'] ) ) {
693
+			if (version_compare($this->version, '1.2.0', '>=') && isset($fieldmap['salesforce_field']['name'])) {
694 694
 				$salesforce_field = $fieldmap['salesforce_field']['name'];
695 695
 				// Load the type of the Salesforce field. We can use this to handle Salesforce field value issues that come up based on what the field sends into WordPress or expects from WordPress.
696 696
 				$salesforce_field_type = $fieldmap['salesforce_field']['type'];
@@ -699,113 +699,113 @@  discard block
 block discarded – undo
699 699
 			}
700 700
 
701 701
 			// A WordPress event caused this.
702
-			if ( in_array( $trigger, array_values( $wordpress_haystack ), true ) ) {
702
+			if (in_array($trigger, array_values($wordpress_haystack), true)) {
703 703
 
704 704
 				// Is the field in WordPress an array, if we unserialize it? Salesforce wants it to be an imploded string.
705
-				if ( is_array( maybe_unserialize( $object[ $wordpress_field ] ) ) ) {
706
-					$object[ $wordpress_field ] = implode( $this->array_delimiter, $object[ $wordpress_field ] );
705
+				if (is_array(maybe_unserialize($object[$wordpress_field]))) {
706
+					$object[$wordpress_field] = implode($this->array_delimiter, $object[$wordpress_field]);
707 707
 				}
708 708
 
709
-				if ( isset( $salesforce_field_type ) ) {
709
+				if (isset($salesforce_field_type)) {
710 710
 					// Is the Salesforce field a date, and is the WordPress value a valid date?
711 711
 					// According to https://salesforce.stackexchange.com/questions/57032/date-format-with-salesforce-rest-api
712
-					if ( in_array( $salesforce_field_type, $this->date_types_from_salesforce ) ) {
713
-						if ( '' === $object[ $wordpress_field ] ) {
714
-							$object[ $wordpress_field ] = null;
712
+					if (in_array($salesforce_field_type, $this->date_types_from_salesforce)) {
713
+						if ('' === $object[$wordpress_field]) {
714
+							$object[$wordpress_field] = null;
715 715
 						} else {
716
-							if ( false !== strtotime( $object[ $wordpress_field ] ) ) {
717
-								$timestamp = strtotime( $object[ $wordpress_field ] );
716
+							if (false !== strtotime($object[$wordpress_field])) {
717
+								$timestamp = strtotime($object[$wordpress_field]);
718 718
 							} else {
719
-								$timestamp = $object[ $wordpress_field ];
719
+								$timestamp = $object[$wordpress_field];
720 720
 							}
721
-							if ( 'datetime' === $salesforce_field_type ) {
722
-								$object[ $wordpress_field ] = date_i18n( 'c', $timestamp );
721
+							if ('datetime' === $salesforce_field_type) {
722
+								$object[$wordpress_field] = date_i18n('c', $timestamp);
723 723
 							} else {
724
-								$object[ $wordpress_field ] = date_i18n( 'Y-m-d', $timestamp );
724
+								$object[$wordpress_field] = date_i18n('Y-m-d', $timestamp);
725 725
 							}
726 726
 						}
727 727
 					}
728 728
 
729 729
 					// Boolean SF fields only want real boolean values. NULL is also not allowed.
730
-					if ( 'boolean' === $salesforce_field_type ) {
731
-						$object[ $wordpress_field ] = (bool) $object[ $wordpress_field ];
730
+					if ('boolean' === $salesforce_field_type) {
731
+						$object[$wordpress_field] = (bool) $object[$wordpress_field];
732 732
 					}
733 733
 				}
734 734
 
735
-				$params[ $salesforce_field ] = $object[ $wordpress_field ];
735
+				$params[$salesforce_field] = $object[$wordpress_field];
736 736
 
737 737
 				// If the field is a key in Salesforce, remove it from $params to avoid upsert errors from Salesforce,
738 738
 				// but still put its name in the params array so we can check for it later.
739
-				if ( '1' === $fieldmap['is_key'] ) {
740
-					if ( ! $use_soap ) {
741
-						unset( $params[ $salesforce_field ] );
739
+				if ('1' === $fieldmap['is_key']) {
740
+					if ( ! $use_soap) {
741
+						unset($params[$salesforce_field]);
742 742
 					}
743 743
 					$params['key'] = array(
744 744
 						'salesforce_field' => $salesforce_field,
745 745
 						'wordpress_field'  => $wordpress_field,
746
-						'value'            => $object[ $wordpress_field ],
746
+						'value'            => $object[$wordpress_field],
747 747
 					);
748 748
 				}
749 749
 
750 750
 				// If the field is a prematch in Salesforce, put its name in the params array so we can check for it later.
751
-				if ( '1' === $fieldmap['is_prematch'] ) {
751
+				if ('1' === $fieldmap['is_prematch']) {
752 752
 					$params['prematch'] = array(
753 753
 						'salesforce_field' => $salesforce_field,
754 754
 						'wordpress_field'  => $wordpress_field,
755
-						'value'            => $object[ $wordpress_field ],
755
+						'value'            => $object[$wordpress_field],
756 756
 					);
757 757
 				}
758 758
 
759 759
 				// Skip fields that aren't being pushed to Salesforce.
760
-				if ( ! in_array( $fieldmap['direction'], array_values( $this->direction_wordpress ), true ) ) {
760
+				if ( ! in_array($fieldmap['direction'], array_values($this->direction_wordpress), true)) {
761 761
 					// The trigger is a WordPress trigger, but the fieldmap direction is not a WordPress direction.
762
-					unset( $params[ $salesforce_field ] );
762
+					unset($params[$salesforce_field]);
763 763
 				}
764 764
 
765 765
 				// I think it's good to over-mention that updateable is really how the Salesforce api spells it.
766 766
 				// Skip fields that aren't updateable when mapping params because Salesforce will error otherwise.
767 767
 				// This happens after dealing with the field types because key and prematch should still be available to the plugin, even if the values are not updateable in Salesforce.
768
-				if ( 1 !== (int) $fieldmap['salesforce_field']['updateable'] ) {
769
-					unset( $params[ $salesforce_field ] );
768
+				if (1 !== (int) $fieldmap['salesforce_field']['updateable']) {
769
+					unset($params[$salesforce_field]);
770 770
 				}
771 771
 
772 772
 				// we don't need a continue with the unset methods because there's no array being created down here
773
-			} elseif ( in_array( $trigger, $salesforce_haystack, true ) ) {
773
+			} elseif (in_array($trigger, $salesforce_haystack, true)) {
774 774
 
775 775
 				// A Salesforce event caused this.
776 776
 
777
-				if ( isset( $salesforce_field_type ) ) {
777
+				if (isset($salesforce_field_type)) {
778 778
 					// Salesforce provides multipicklist values as a delimited string. If the
779 779
 					// destination field in WordPress accepts multiple values, explode the string into an array and then serialize it.
780
-					if ( in_array( $salesforce_field_type, $this->array_types_from_salesforce ) ) {
781
-						$object[ $salesforce_field ] = explode( $this->array_delimiter, $object[ $salesforce_field ] );
780
+					if (in_array($salesforce_field_type, $this->array_types_from_salesforce)) {
781
+						$object[$salesforce_field] = explode($this->array_delimiter, $object[$salesforce_field]);
782 782
 					}
783 783
 
784 784
 					// Handle specific data types from Salesforce.
785
-					switch ( $salesforce_field_type ) {
786
-						case ( in_array( $salesforce_field_type, $this->date_types_from_salesforce ) ):
787
-							$format = get_option( 'date_format', 'U' );
788
-							if ( isset( $fieldmap['wordpress_field']['type'] ) && 'datetime' === $fieldmap['wordpress_field']['type'] ) {
785
+					switch ($salesforce_field_type) {
786
+						case (in_array($salesforce_field_type, $this->date_types_from_salesforce)):
787
+							$format = get_option('date_format', 'U');
788
+							if (isset($fieldmap['wordpress_field']['type']) && 'datetime' === $fieldmap['wordpress_field']['type']) {
789 789
 								$format = 'Y-m-d H:i:s';
790 790
 							}
791
-							$object[ $salesforce_field ] = date_i18n( $format, strtotime( $object[ $salesforce_field ] ) );
791
+							$object[$salesforce_field] = date_i18n($format, strtotime($object[$salesforce_field]));
792 792
 							break;
793
-						case ( in_array( $salesforce_field_type, $this->int_types_from_salesforce ) ):
794
-							$object[ $salesforce_field ] = isset( $object[ $salesforce_field ] ) ? (int) $object[ $salesforce_field ] : 0;
793
+						case (in_array($salesforce_field_type, $this->int_types_from_salesforce)):
794
+							$object[$salesforce_field] = isset($object[$salesforce_field]) ? (int) $object[$salesforce_field] : 0;
795 795
 							break;
796 796
 						case 'text':
797
-							$object[ $salesforce_field ] = (string) $object[ $salesforce_field ];
797
+							$object[$salesforce_field] = (string) $object[$salesforce_field];
798 798
 							break;
799 799
 						case 'url':
800
-							$object[ $salesforce_field ] = esc_url_raw( $object[ $salesforce_field ] );
800
+							$object[$salesforce_field] = esc_url_raw($object[$salesforce_field]);
801 801
 							break;
802 802
 					}
803 803
 				}
804 804
 
805 805
 				// Make an array because we need to store the methods for each field as well.
806
-				if ( '' !== $object[ $salesforce_field ] ) {
807
-					$params[ $wordpress_field ]          = array();
808
-					$params[ $wordpress_field ]['value'] = $object[ $salesforce_field ];
806
+				if ('' !== $object[$salesforce_field]) {
807
+					$params[$wordpress_field]          = array();
808
+					$params[$wordpress_field]['value'] = $object[$salesforce_field];
809 809
 				} else {
810 810
 					// If we try to save certain fields with empty values, WordPress will silently start skipping stuff. This keeps that from happening.
811 811
 					continue;
@@ -813,15 +813,15 @@  discard block
 block discarded – undo
813 813
 
814 814
 				// If the field is a key in Salesforce, remove it from $params to avoid upsert errors from Salesforce,
815 815
 				// but still put its name in the params array so we can check for it later.
816
-				if ( '1' === $fieldmap['is_key'] ) {
817
-					if ( ! $use_soap ) {
818
-						unset( $params[ $wordpress_field ] );
816
+				if ('1' === $fieldmap['is_key']) {
817
+					if ( ! $use_soap) {
818
+						unset($params[$wordpress_field]);
819 819
 						continue;
820 820
 					}
821 821
 					$params['key'] = array(
822 822
 						'salesforce_field' => $salesforce_field,
823 823
 						'wordpress_field'  => $wordpress_field,
824
-						'value'            => $object[ $salesforce_field ],
824
+						'value'            => $object[$salesforce_field],
825 825
 						'method_read'      => $fieldmap['wordpress_field']['methods']['read'],
826 826
 						'method_create'    => $fieldmap['wordpress_field']['methods']['create'],
827 827
 						'method_update'    => $fieldmap['wordpress_field']['methods']['update'],
@@ -829,11 +829,11 @@  discard block
 block discarded – undo
829 829
 				}
830 830
 
831 831
 				// If the field is a prematch in Salesforce, put its name in the params array so we can check for it later.
832
-				if ( '1' === $fieldmap['is_prematch'] ) {
832
+				if ('1' === $fieldmap['is_prematch']) {
833 833
 					$params['prematch'] = array(
834 834
 						'salesforce_field' => $salesforce_field,
835 835
 						'wordpress_field'  => $wordpress_field,
836
-						'value'            => $object[ $salesforce_field ],
836
+						'value'            => $object[$salesforce_field],
837 837
 						'method_read'      => $fieldmap['wordpress_field']['methods']['read'],
838 838
 						'method_create'    => $fieldmap['wordpress_field']['methods']['create'],
839 839
 						'method_update'    => $fieldmap['wordpress_field']['methods']['update'],
@@ -841,26 +841,26 @@  discard block
 block discarded – undo
841 841
 				}
842 842
 
843 843
 				// Skip fields that aren't being pulled from Salesforce.
844
-				if ( ! in_array( $fieldmap['direction'], array_values( $this->direction_salesforce ), true ) ) {
844
+				if ( ! in_array($fieldmap['direction'], array_values($this->direction_salesforce), true)) {
845 845
 					// The trigger is a Salesforce trigger, but the fieldmap direction is not a Salesforce direction.
846
-					unset( $params[ $wordpress_field ] );
846
+					unset($params[$wordpress_field]);
847 847
 					// we also need to continue here, so it doesn't create an empty array below for fields that are WordPress -> Salesforce only
848 848
 					continue;
849 849
 				}
850 850
 
851
-				switch ( $trigger ) {
851
+				switch ($trigger) {
852 852
 					case $this->sync_sf_create:
853
-						$params[ $wordpress_field ]['method_modify'] = $fieldmap['wordpress_field']['methods']['create'];
853
+						$params[$wordpress_field]['method_modify'] = $fieldmap['wordpress_field']['methods']['create'];
854 854
 						break;
855 855
 					case $this->sync_sf_update:
856
-						$params[ $wordpress_field ]['method_modify'] = $fieldmap['wordpress_field']['methods']['update'];
856
+						$params[$wordpress_field]['method_modify'] = $fieldmap['wordpress_field']['methods']['update'];
857 857
 						break;
858 858
 					case $this->sync_sf_delete:
859
-						$params[ $wordpress_field ]['method_modify'] = $fieldmap['wordpress_field']['methods']['delete'];
859
+						$params[$wordpress_field]['method_modify'] = $fieldmap['wordpress_field']['methods']['delete'];
860 860
 						break;
861 861
 				}
862 862
 
863
-				$params[ $wordpress_field ]['method_read'] = $fieldmap['wordpress_field']['methods']['read'];
863
+				$params[$wordpress_field]['method_read'] = $fieldmap['wordpress_field']['methods']['read'];
864 864
 
865 865
 			} // End if().
866 866
 		} // End foreach().
@@ -877,14 +877,14 @@  discard block
 block discarded – undo
877 877
 	 *
878 878
 	 * @return array $mappings Associative array of field maps ready to use
879 879
 	 */
880
-	private function prepare_fieldmap_data( $mappings, $record_type = '' ) {
881
-
882
-		foreach ( $mappings as $id => $mapping ) {
883
-			$mappings[ $id ]['salesforce_record_types_allowed'] = maybe_unserialize( $mapping['salesforce_record_types_allowed'] );
884
-			$mappings[ $id ]['fields']                          = maybe_unserialize( $mapping['fields'] );
885
-			$mappings[ $id ]['sync_triggers']                   = maybe_unserialize( $mapping['sync_triggers'] );
886
-			if ( '' !== $record_type && ! in_array( $record_type, $mappings[ $id ]['salesforce_record_types_allowed'], true ) ) {
887
-				unset( $mappings[ $id ] );
880
+	private function prepare_fieldmap_data($mappings, $record_type = '') {
881
+
882
+		foreach ($mappings as $id => $mapping) {
883
+			$mappings[$id]['salesforce_record_types_allowed'] = maybe_unserialize($mapping['salesforce_record_types_allowed']);
884
+			$mappings[$id]['fields']                          = maybe_unserialize($mapping['fields']);
885
+			$mappings[$id]['sync_triggers']                   = maybe_unserialize($mapping['sync_triggers']);
886
+			if ('' !== $record_type && ! in_array($record_type, $mappings[$id]['salesforce_record_types_allowed'], true)) {
887
+				unset($mappings[$id]);
888 888
 			}
889 889
 		}
890 890
 
@@ -900,12 +900,12 @@  discard block
 block discarded – undo
900 900
 	public function get_failed_object_maps() {
901 901
 		$table       = $this->object_map_table;
902 902
 		$errors      = array();
903
-		$push_errors = $this->wpdb->get_results( 'SELECT * FROM ' . $table . ' WHERE salesforce_id LIKE "tmp_sf_%"', ARRAY_A );
904
-		$pull_errors = $this->wpdb->get_results( 'SELECT * FROM ' . $table . ' WHERE wordpress_id LIKE "tmp_wp_%"', ARRAY_A );
905
-		if ( ! empty( $push_errors ) ) {
903
+		$push_errors = $this->wpdb->get_results('SELECT * FROM ' . $table . ' WHERE salesforce_id LIKE "tmp_sf_%"', ARRAY_A);
904
+		$pull_errors = $this->wpdb->get_results('SELECT * FROM ' . $table . ' WHERE wordpress_id LIKE "tmp_wp_%"', ARRAY_A);
905
+		if ( ! empty($push_errors)) {
906 906
 			$errors['push_errors'] = $push_errors;
907 907
 		}
908
-		if ( ! empty( $pull_errors ) ) {
908
+		if ( ! empty($pull_errors)) {
909 909
 			$errors['pull_errors'] = $pull_errors;
910 910
 		}
911 911
 		return $errors;
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
 	 *
919 919
 	 * @return array $error Associative array of single row that failed to finish based on id
920 920
 	 */
921
-	public function get_failed_object_map( $id ) {
921
+	public function get_failed_object_map($id) {
922 922
 		$table     = $this->object_map_table;
923 923
 		$error     = array();
924
-		$error_row = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = "' . $id . '"', ARRAY_A );
925
-		if ( ! empty( $error_row ) ) {
924
+		$error_row = $this->wpdb->get_row('SELECT * FROM ' . $table . ' WHERE id = "' . $id . '"', ARRAY_A);
925
+		if ( ! empty($error_row)) {
926 926
 			$error = $error_row;
927 927
 		}
928 928
 		return $error;
Please login to merge, or discard this patch.