Passed
Pull Request — master (#195)
by Jonathan
03:37
created
classes/class-object-sync-sf-queue.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Object Sync for Salesforce Queue
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if ( ! defined('ABSPATH')) {
7 7
 	exit; // Exit if accessed directly.
8 8
 }
9 9
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	protected $slug;
21 21
 	protected $schedulable_classes;
22 22
 
23
-	public function __construct( $wpdb, $version, $slug, $schedulable_classes ) {
23
+	public function __construct($wpdb, $version, $slug, $schedulable_classes) {
24 24
 		$this->wpdb                = $wpdb;
25 25
 		$this->version             = $version;
26 26
 		$this->slug                = $slug;
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
 	 * @param string  $sort Which direction to sort
35 35
 	 * @return array $this->schedulable_classes
36 36
 	 */
37
-	public function get_frequencies( $unit = 'seconds', $sort = 'asc' ) {
37
+	public function get_frequencies($unit = 'seconds', $sort = 'asc') {
38 38
 
39
-		foreach ( $this->schedulable_classes as $key => $schedule ) {
40
-			$this->schedulable_classes[ $key ]['frequency'] = $this->get_frequency( $key, 'seconds' );
39
+		foreach ($this->schedulable_classes as $key => $schedule) {
40
+			$this->schedulable_classes[$key]['frequency'] = $this->get_frequency($key, 'seconds');
41 41
 		}
42 42
 
43
-		if ( 'asc' === $sort ) {
44
-			uasort( $this->schedulable_classes, function( $a, $b ) {
43
+		if ('asc' === $sort) {
44
+			uasort($this->schedulable_classes, function($a, $b) {
45 45
 				return $a['frequency'] - $b['frequency'];
46 46
 			});
47 47
 		} else {
48
-			uasort( $this->schedulable_classes, function( $a, $b ) {
48
+			uasort($this->schedulable_classes, function($a, $b) {
49 49
 				return $b['frequency'] - $a['frequency'];
50 50
 			});
51 51
 		}
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	 * @param string  $unit The unit of time
62 62
 	 * @return int How often it runs in that unit of time
63 63
 	 */
64
-	public function get_frequency( $name, $unit ) {
65
-		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
66
-		$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_unit', '' );
64
+	public function get_frequency($name, $unit) {
65
+		$schedule_number = get_option('object_sync_for_salesforce_' . $name . '_schedule_number', '');
66
+		$schedule_unit   = get_option('object_sync_for_salesforce_' . $name . '_schedule_unit', '');
67 67
 
68
-		switch ( $schedule_unit ) {
68
+		switch ($schedule_unit) {
69 69
 			case 'minutes':
70 70
 				$seconds = 60;
71 71
 				$minutes = 1;
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @param string $group The group to assign this job to.
97 97
 	 * @return string The action ID.
98 98
 	 */
99
-	public function add( $hook, $args = array(), $group = '' ) {
100
-		return $this->schedule_single( time(), $hook, $args, $group );
99
+	public function add($hook, $args = array(), $group = '') {
100
+		return $this->schedule_single(time(), $hook, $args, $group);
101 101
 	}
102 102
 
103 103
 	/**
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param string $group The group to assign this job to.
110 110
 	 * @return string The action ID.
111 111
 	 */
112
-	public function schedule_single( $timestamp, $hook, $args = array(), $group = '' ) {
113
-		return as_schedule_single_action( $timestamp, $hook, $args, $group );
112
+	public function schedule_single($timestamp, $hook, $args = array(), $group = '') {
113
+		return as_schedule_single_action($timestamp, $hook, $args, $group);
114 114
 	}
115 115
 
116 116
 	/**
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * @param string $group The group to assign this job to.
124 124
 	 * @return string The action ID.
125 125
 	 */
126
-	public function schedule_recurring( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
127
-		return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
126
+	public function schedule_recurring($timestamp, $interval_in_seconds, $hook, $args = array(), $group = '') {
127
+		return as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, $group);
128 128
 	}
129 129
 
130 130
 	/**
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	 * @param string $group The group to assign this job to.
148 148
 	 * @return string The action ID
149 149
 	 */
150
-	public function schedule_cron( $timestamp, $cron_schedule, $hook, $args = array(), $group = '' ) {
151
-		return as_schedule_cron_action( $timestamp, $cron_schedule, $hook, $args, $group );
150
+	public function schedule_cron($timestamp, $cron_schedule, $hook, $args = array(), $group = '') {
151
+		return as_schedule_cron_action($timestamp, $cron_schedule, $hook, $args, $group);
152 152
 	}
153 153
 
154 154
 	/**
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param array  $args Args that would have been passed to the job.
165 165
 	 * @param string $group Group name.
166 166
 	 */
167
-	public function cancel( $hook, $args = array(), $group = '' ) {
168
-		as_unschedule_action( $hook, $args, $group );
167
+	public function cancel($hook, $args = array(), $group = '') {
168
+		as_unschedule_action($hook, $args, $group);
169 169
 	}
170 170
 
171 171
 	/**
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * @param string $group Group name.
178 178
 	 * @return time|null The date and time for the next occurrence, or null if there is no pending, scheduled action for the given hook.
179 179
 	 */
180
-	public function get_next( $hook, $args = null, $group = '' ) {
180
+	public function get_next($hook, $args = null, $group = '') {
181 181
 
182
-		$next_timestamp = as_next_scheduled_action( $hook, $args, $group );
182
+		$next_timestamp = as_next_scheduled_action($hook, $args, $group);
183 183
 
184
-		if ( $next_timestamp ) {
184
+		if ($next_timestamp) {
185 185
 			return $next_timestamp;
186 186
 		}
187 187
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @param string $return_format OBJECT, ARRAY_A, or ids.
210 210
 	 * @return array
211 211
 	 */
212
-	public function search( $args = array(), $return_format = OBJECT ) {
213
-		return as_get_scheduled_actions( $args, $return_format );
212
+	public function search($args = array(), $return_format = OBJECT) {
213
+		return as_get_scheduled_actions($args, $return_format);
214 214
 	}
215 215
 }
Please login to merge, or discard this patch.
classes/salesforce_pull.php 1 patch
Spacing   +319 added lines, -319 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
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	* @param object $queue
45 45
 	* @throws \Exception
46 46
 	*/
47
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
47
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
48 48
 		$this->wpdb                = $wpdb;
49 49
 		$this->version             = $version;
50 50
 		$this->login_credentials   = $login_credentials;
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 		$this->schedule_name = 'salesforce_pull';
60 60
 
61 61
 		// Create action hooks for WordPress objects. We run this after plugins are loaded in case something depends on another plugin.
62
-		add_action( 'plugins_loaded', array( $this, 'add_actions' ) );
62
+		add_action('plugins_loaded', array($this, 'add_actions'));
63 63
 
64
-		$this->debug = get_option( 'object_sync_for_salesforce_debug_mode', false );
64
+		$this->debug = get_option('object_sync_for_salesforce_debug_mode', false);
65 65
 
66 66
 	}
67 67
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	public function add_actions() {
73 73
 
74 74
 		// ajax hook
75
-		add_action( 'wp_ajax_salesforce_pull_webhook', array( $this, 'salesforce_pull_webhook' ) );
75
+		add_action('wp_ajax_salesforce_pull_webhook', array($this, 'salesforce_pull_webhook'));
76 76
 
77 77
 		// action-scheduler needs two hooks: one to check for records, and one to process them
78
-		add_action( 'object_sync_for_salesforce_pull_check_records', array( $this, 'salesforce_pull' ), 10 );
79
-		add_action( 'object_sync_for_salesforce_pull_process_records', array( $this, 'salesforce_pull_process_records' ), 10, 4 );
78
+		add_action('object_sync_for_salesforce_pull_check_records', array($this, 'salesforce_pull'), 10);
79
+		add_action('object_sync_for_salesforce_pull_process_records', array($this, 'salesforce_pull_process_records'), 10, 4);
80 80
 	}
81 81
 
82 82
 	/**
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 	*/
88 88
 	public function salesforce_pull_webhook() {
89 89
 
90
-		if ( true === $this->salesforce_pull() ) {
90
+		if (true === $this->salesforce_pull()) {
91 91
 			$code = '200';
92 92
 
93 93
 			// single task for action-scheduler to check for data
94 94
 			$this->queue->add(
95
-				$this->schedulable_classes[ $this->schedule_name ]['initializer'],
95
+				$this->schedulable_classes[$this->schedule_name]['initializer'],
96 96
 				array(),
97 97
 				$this->schedule_name
98 98
 			);
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 			$code = '403';
102 102
 		}
103 103
 
104
-		if ( ! empty( $_POST ) ) { // linter flags this, but we're not doing anything with the array just checking to see if it is empty
105
-			wp_send_json_success( $code );
104
+		if ( ! empty($_POST)) { // linter flags this, but we're not doing anything with the array just checking to see if it is empty
105
+			wp_send_json_success($code);
106 106
 		} else {
107 107
 			return $code;
108 108
 		}
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	public function salesforce_pull() {
116 116
 		$sfapi = $this->salesforce['sfapi'];
117 117
 
118
-		if ( true === $this->salesforce['is_authorized'] && true === $this->check_throttle() ) {
118
+		if (true === $this->salesforce['is_authorized'] && true === $this->check_throttle()) {
119 119
 
120 120
 			$this->get_updated_records();
121 121
 			$this->get_deleted_records();
122 122
 
123 123
 			// Store this request time for the throttle check.
124
-			update_option( 'object_sync_for_salesforce_pull_last_sync', current_time( 'timestamp', true ) );
124
+			update_option('object_sync_for_salesforce_pull_last_sync', current_time('timestamp', true));
125 125
 			return true;
126 126
 
127 127
 		} else {
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 	*    Returns false if the time elapsed between recent pulls is too short.
140 140
 	*/
141 141
 	private function check_throttle() {
142
-		$pull_throttle = get_option( 'object_sync_for_salesforce_pull_throttle', 5 );
143
-		$last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync', 0 );
142
+		$pull_throttle = get_option('object_sync_for_salesforce_pull_throttle', 5);
143
+		$last_sync     = get_option('object_sync_for_salesforce_pull_last_sync', 0);
144 144
 
145
-		if ( current_time( 'timestamp', true ) > ( $last_sync + $pull_throttle ) ) {
145
+		if (current_time('timestamp', true) > ($last_sync + $pull_throttle)) {
146 146
 			return true;
147 147
 		} else {
148 148
 			return false;
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 	*/
161 161
 	private function get_updated_records() {
162 162
 		$sfapi = $this->salesforce['sfapi'];
163
-		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
163
+		foreach ($this->mappings->get_fieldmaps() as $salesforce_mapping) {
164 164
 			$map_sync_triggers = $salesforce_mapping['sync_triggers']; // this sets which Salesforce triggers are allowed for the mapping
165 165
 			$type              = $salesforce_mapping['salesforce_object']; // this sets the salesfore object type for the SOQL query
166 166
 
167
-			$soql = $this->get_pull_query( $type, $salesforce_mapping );
167
+			$soql = $this->get_pull_query($type, $salesforce_mapping);
168 168
 
169 169
 			// get_pull_query returns null if it has no matching fields
170
-			if ( null === $soql ) {
170
+			if (null === $soql) {
171 171
 				continue;
172 172
 			}
173 173
 
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 			);
183 183
 
184 184
 			$response     = $results['data'];
185
-			$version_path = wp_parse_url( $sfapi->get_api_endpoint(), PHP_URL_PATH );
185
+			$version_path = wp_parse_url($sfapi->get_api_endpoint(), PHP_URL_PATH);
186 186
 
187
-			$sf_last_sync = get_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, null );
188
-			$last_sync    = gmdate( 'Y-m-d\TH:i:s\Z', $sf_last_sync );
187
+			$sf_last_sync = get_option('object_sync_for_salesforce_pull_last_sync_' . $type, null);
188
+			$last_sync    = gmdate('Y-m-d\TH:i:s\Z', $sf_last_sync);
189 189
 
190
-			if ( ! isset( $response['errorCode'] ) ) {
190
+			if ( ! isset($response['errorCode'])) {
191 191
 				// Write items to the queue.
192
-				foreach ( $response['records'] as $result ) {
192
+				foreach ($response['records'] as $result) {
193 193
 
194 194
 					// if this record is new as of the last sync, use the create trigger
195
-					if ( isset( $result['CreatedDate'] ) && $result['CreatedDate'] > $last_sync ) {
195
+					if (isset($result['CreatedDate']) && $result['CreatedDate'] > $last_sync) {
196 196
 						$sf_sync_trigger = $this->mappings->sync_sf_create;
197 197
 					} else {
198 198
 						$sf_sync_trigger = $this->mappings->sync_sf_update;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 
201 201
 					// Only queue when the record's trigger is configured for the mapping
202 202
 					// these are bit operators, so we leave out the strict
203
-					if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
203
+					if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
204 204
 						$data = array(
205 205
 							'object_type'     => $type,
206 206
 							'object'          => $result,
@@ -212,16 +212,16 @@  discard block
 block discarded – undo
212 212
 						$pull_allowed = true;
213 213
 
214 214
 						// if the current fieldmap does not allow create, we need to check if there is a fieldmap for the Salesforce object Id. if not, set pull_allowed to false.
215
-						if ( isset( $map_sync_triggers ) && ! in_array( $this->mappings->sync_sf_create, $map_sync_triggers ) ) {
216
-							$object_map = $this->mappings->load_by_salesforce( $result['Id'] );
217
-							if ( empty( $object_map ) ) {
215
+						if (isset($map_sync_triggers) && ! in_array($this->mappings->sync_sf_create, $map_sync_triggers)) {
216
+							$object_map = $this->mappings->load_by_salesforce($result['Id']);
217
+							if (empty($object_map)) {
218 218
 								$pull_allowed = false;
219 219
 							}
220 220
 						}
221 221
 
222 222
 						// Hook to allow other plugins to prevent a pull per-mapping.
223 223
 						// Putting the pull_allowed hook here will keep the queue from storing data when it is not supposed to store it
224
-						$pull_allowed = apply_filters( 'object_sync_for_salesforce_pull_object_allowed', $pull_allowed, $type, $result, $sf_sync_trigger, $salesforce_mapping );
224
+						$pull_allowed = apply_filters('object_sync_for_salesforce_pull_object_allowed', $pull_allowed, $type, $result, $sf_sync_trigger, $salesforce_mapping);
225 225
 
226 226
 						// example to keep from pulling the Contact with id of abcdef
227 227
 						/*
@@ -234,35 +234,35 @@  discard block
 block discarded – undo
234 234
 						}
235 235
 						*/
236 236
 
237
-						if ( false === $pull_allowed ) {
238
-							update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, current_time( 'timestamp', true ) );
237
+						if (false === $pull_allowed) {
238
+							update_option('object_sync_for_salesforce_pull_last_sync_' . $type, current_time('timestamp', true));
239 239
 							continue;
240 240
 						}
241 241
 
242 242
 						// add a queue action to save data from salesforce
243 243
 						$this->queue->add(
244
-							$this->schedulable_classes[ $this->schedule_name ]['callback'],
244
+							$this->schedulable_classes[$this->schedule_name]['callback'],
245 245
 							array(
246 246
 								'object_type'     => $type,
247 247
 								'object'          => $result['Id'],
248
-								'mapping'         => filter_var( $salesforce_mapping['id'], FILTER_VALIDATE_INT ),
248
+								'mapping'         => filter_var($salesforce_mapping['id'], FILTER_VALIDATE_INT),
249 249
 								'sf_sync_trigger' => $sf_sync_trigger,
250 250
 							),
251 251
 							$this->schedule_name
252 252
 						);
253 253
 
254 254
 						// Update the last pull sync timestamp for this record type to avoid re-processing in case of error
255
-						$last_sync_pull_trigger = DateTime::createFromFormat( 'Y-m-d\TH:i:s+', $result[ $salesforce_mapping['pull_trigger_field'] ], new DateTimeZone( 'UTC' ) );
256
-						update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format( 'U' ) );
255
+						$last_sync_pull_trigger = DateTime::createFromFormat('Y-m-d\TH:i:s+', $result[$salesforce_mapping['pull_trigger_field']], new DateTimeZone('UTC'));
256
+						update_option('object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format('U'));
257 257
 					}
258 258
 				}
259 259
 
260 260
 				// Handle requests larger than the batch limit (usually 2000).
261
-				$next_records_url = isset( $response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $response['nextRecordsUrl'] ) : false;
261
+				$next_records_url = isset($response['nextRecordsUrl']) ? str_replace($version_path, '', $response['nextRecordsUrl']) : false;
262 262
 
263
-				while ( $next_records_url ) {
263
+				while ($next_records_url) {
264 264
 					// shouldn't cache this either. it's going into the queue if it exists anyway.
265
-					$new_results  = $sfapi->api_call(
265
+					$new_results = $sfapi->api_call(
266 266
 						$next_records_url,
267 267
 						array(),
268 268
 						'GET',
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 						)
272 272
 					);
273 273
 					$new_response = $new_results['data'];
274
-					if ( ! isset( $new_response['errorCode'] ) ) {
274
+					if ( ! isset($new_response['errorCode'])) {
275 275
 						// Write items to the queue.
276
-						foreach ( $new_response['records'] as $result ) {
276
+						foreach ($new_response['records'] as $result) {
277 277
 							// if this record is new as of the last sync, use the create trigger
278
-							if ( isset( $result['CreatedDate'] ) && $result['CreatedDate'] > $last_sync ) {
278
+							if (isset($result['CreatedDate']) && $result['CreatedDate'] > $last_sync) {
279 279
 								$sf_sync_trigger = $this->mappings->sync_sf_create;
280 280
 							} else {
281 281
 								$sf_sync_trigger = $this->mappings->sync_sf_update;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
 							// Only queue when the record's trigger is configured for the mapping
285 285
 							// these are bit operators, so we leave out the strict
286
-							if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
286
+							if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
287 287
 								$data = array(
288 288
 									'object_type'     => $type,
289 289
 									'object'          => $result,
@@ -293,39 +293,39 @@  discard block
 block discarded – undo
293 293
 
294 294
 								// add a queue action to save data from salesforce
295 295
 								$this->queue->add(
296
-									$this->schedulable_classes[ $this->schedule_name ]['callback'],
296
+									$this->schedulable_classes[$this->schedule_name]['callback'],
297 297
 									array(
298 298
 										'object_type'     => $type,
299 299
 										'object'          => $result['Id'],
300
-										'mapping'         => filter_var( $salesforce_mapping['id'], FILTER_VALIDATE_INT ),
300
+										'mapping'         => filter_var($salesforce_mapping['id'], FILTER_VALIDATE_INT),
301 301
 										'sf_sync_trigger' => $sf_sync_trigger,
302 302
 									),
303 303
 									$this->schedule_name
304 304
 								);
305 305
 
306 306
 								// Update the last pull sync timestamp for this record type to avoid re-processing in case of error
307
-								$last_sync_pull_trigger = DateTime::createFromFormat( 'Y-m-d\TH:i:s+', $result[ $salesforce_mapping['pull_trigger_field'] ], new DateTimeZone( 'UTC' ) );
308
-								update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format( 'U' ) );
307
+								$last_sync_pull_trigger = DateTime::createFromFormat('Y-m-d\TH:i:s+', $result[$salesforce_mapping['pull_trigger_field']], new DateTimeZone('UTC'));
308
+								update_option('object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format('U'));
309 309
 							}
310 310
 						}
311 311
 					}
312 312
 
313
-					$next_records_url = isset( $new_response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $new_response['nextRecordsUrl'] ) : false;
313
+					$next_records_url = isset($new_response['nextRecordsUrl']) ? str_replace($version_path, '', $new_response['nextRecordsUrl']) : false;
314 314
 				}
315 315
 			} else {
316 316
 
317 317
 				// create log entry for failed pull
318 318
 				$status = 'error';
319 319
 				// translators: placeholders are: 1) the server error code, and 2) the name of the Salesforce object
320
-				$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
321
-					absint( $response['errorCode'] ),
322
-					esc_attr( $salesforce_mapping['salesforce_object'] )
320
+				$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
321
+					absint($response['errorCode']),
322
+					esc_attr($salesforce_mapping['salesforce_object'])
323 323
 				);
324 324
 
325
-				if ( isset( $this->logging ) ) {
325
+				if (isset($this->logging)) {
326 326
 					$logging = $this->logging;
327
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
328
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
327
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
328
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
329 329
 				}
330 330
 
331 331
 				$logging->setup(
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	* @see Object_Sync_Sf_Mapping::get_mapped_fields
354 354
 	* @see Object_Sync_Sf_Mapping::get_mapped_record_types
355 355
 	*/
356
-	private function get_pull_query( $type, $salesforce_mapping = array() ) {
356
+	private function get_pull_query($type, $salesforce_mapping = array()) {
357 357
 		$mapped_fields       = array();
358 358
 		$mapped_record_types = array();
359 359
 
@@ -365,35 +365,35 @@  discard block
 block discarded – undo
365 365
 		);
366 366
 
367 367
 		// Iterate over each field mapping to determine our query parameters.
368
-		foreach ( $mappings as $mapping ) {
368
+		foreach ($mappings as $mapping) {
369 369
 
370 370
 			// only use fields that come from Salesforce to WordPress, or that sync
371 371
 			$mapped_fields = array_merge(
372 372
 				$mapped_fields,
373 373
 				$this->mappings->get_mapped_fields(
374 374
 					$mapping,
375
-					array( $this->mappings->direction_sync, $this->mappings->direction_sf_wordpress )
375
+					array($this->mappings->direction_sync, $this->mappings->direction_sf_wordpress)
376 376
 				)
377 377
 			);
378 378
 
379 379
 			// If Record Type is specified, restrict query.
380
-			$mapping_record_types = $this->mappings->get_mapped_record_types( $mapping );
380
+			$mapping_record_types = $this->mappings->get_mapped_record_types($mapping);
381 381
 
382 382
 			// If Record Type is not specified for a given mapping, ensure query is unrestricted.
383
-			if ( empty( $mapping_record_types ) ) {
383
+			if (empty($mapping_record_types)) {
384 384
 				$mapped_record_types = false;
385
-			} elseif ( is_array( $mapped_record_types ) ) {
386
-				$mapped_record_types = array_merge( $mapped_record_types, $mapping_record_types );
385
+			} elseif (is_array($mapped_record_types)) {
386
+				$mapped_record_types = array_merge($mapped_record_types, $mapping_record_types);
387 387
 			}
388 388
 		} // End foreach().
389 389
 
390 390
 		// There are no field mappings configured to pull data from Salesforce so
391 391
 		// move on to the next mapped object. Prevents querying unmapped data.
392
-		if ( empty( $mapped_fields ) ) {
392
+		if (empty($mapped_fields)) {
393 393
 			return null;
394 394
 		}
395 395
 
396
-		$soql = new Object_Sync_Sf_Salesforce_Select_Query( $type );
396
+		$soql = new Object_Sync_Sf_Salesforce_Select_Query($type);
397 397
 
398 398
 		// Convert field mappings to SOQL.
399 399
 		$soql->fields = array_merge(
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 		);
406 406
 
407 407
 		// these are bit operators, so we leave out the strict
408
-		if ( in_array( $this->mappings->sync_sf_create, $salesforce_mapping['sync_triggers'] ) ) {
408
+		if (in_array($this->mappings->sync_sf_create, $salesforce_mapping['sync_triggers'])) {
409 409
 			$soql->fields['CreatedDate'] = 'CreatedDate';
410 410
 		}
411 411
 
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
 		// this should be what keeps it from getting all the records, whether or not they've ever been updated
414 414
 		// we also use the option for when the plugin was installed, and don't go back further than that by default
415 415
 
416
-		$sf_activate_time = get_option( 'object_sync_for_salesforce_activate_time', '' );
417
-		$sf_last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, null );
418
-		if ( $sf_last_sync ) {
419
-			$last_sync = gmdate( 'Y-m-d\TH:i:s\Z', $sf_last_sync );
420
-			$soql->add_condition( $salesforce_mapping['pull_trigger_field'], $last_sync, '>' );
416
+		$sf_activate_time = get_option('object_sync_for_salesforce_activate_time', '');
417
+		$sf_last_sync     = get_option('object_sync_for_salesforce_pull_last_sync_' . $type, null);
418
+		if ($sf_last_sync) {
419
+			$last_sync = gmdate('Y-m-d\TH:i:s\Z', $sf_last_sync);
420
+			$soql->add_condition($salesforce_mapping['pull_trigger_field'], $last_sync, '>');
421 421
 		} else {
422
-			$activated = gmdate( 'Y-m-d\TH:i:s\Z', $sf_activate_time );
423
-			$soql->add_condition( $salesforce_mapping['pull_trigger_field'], $activated, '>' );
422
+			$activated = gmdate('Y-m-d\TH:i:s\Z', $sf_activate_time);
423
+			$soql->add_condition($salesforce_mapping['pull_trigger_field'], $activated, '>');
424 424
 			// put a hook in here to let devs go retroactive if they want, and sync data from before plugin was activated
425 425
 		}
426 426
 
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 		// we are not incorporating that part of this branch at this time
447 447
 
448 448
 		// Load all unique SF record types that we have mappings for.
449
-		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
449
+		foreach ($this->mappings->get_fieldmaps() as $salesforce_mapping) {
450 450
 
451 451
 			$type = $salesforce_mapping['salesforce_object'];
452 452
 
@@ -458,37 +458,37 @@  discard block
 block discarded – undo
458 458
 			);
459 459
 
460 460
 			// Iterate over each field mapping to determine our query parameters.
461
-			foreach ( $mappings as $mapping ) {
461
+			foreach ($mappings as $mapping) {
462 462
 
463
-				$last_delete_sync = get_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, current_time( 'timestamp', true ) );
464
-				$now              = current_time( 'timestamp', true );
465
-				update_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, $now );
463
+				$last_delete_sync = get_option('object_sync_for_salesforce_pull_delete_last_' . $type, current_time('timestamp', true));
464
+				$now              = current_time('timestamp', true);
465
+				update_option('object_sync_for_salesforce_pull_delete_last_' . $type, $now);
466 466
 
467 467
 				// get_deleted() constraint: startDate cannot be more than 30 days ago
468 468
 				// (using an incompatible date may lead to exceptions).
469
-				$last_delete_sync = $last_delete_sync > ( current_time( 'timestamp', true ) - 2505600 ) ? $last_delete_sync : ( current_time( 'timestamp', true ) - 2505600 );
469
+				$last_delete_sync = $last_delete_sync > (current_time('timestamp', true) - 2505600) ? $last_delete_sync : (current_time('timestamp', true) - 2505600);
470 470
 
471 471
 				// get_deleted() constraint: startDate must be at least one minute greater
472 472
 				// than endDate.
473
-				$now = $now > ( $last_delete_sync + 60 ) ? $now : $now + 60;
473
+				$now = $now > ($last_delete_sync + 60) ? $now : $now + 60;
474 474
 
475 475
 				// need to be using gmdate for salesforce call
476
-				$last_delete_sync_sf = gmdate( 'Y-m-d\TH:i:s\Z', $last_delete_sync );
477
-				$now_sf              = gmdate( 'Y-m-d\TH:i:s\Z', $now );
476
+				$last_delete_sync_sf = gmdate('Y-m-d\TH:i:s\Z', $last_delete_sync);
477
+				$now_sf              = gmdate('Y-m-d\TH:i:s\Z', $now);
478 478
 
479 479
 				// salesforce call
480
-				$deleted = $sfapi->get_deleted( $type, $last_delete_sync_sf, $now_sf );
480
+				$deleted = $sfapi->get_deleted($type, $last_delete_sync_sf, $now_sf);
481 481
 
482
-				if ( empty( $deleted['data']['deletedRecords'] ) ) {
482
+				if (empty($deleted['data']['deletedRecords'])) {
483 483
 					continue;
484 484
 				}
485 485
 
486
-				foreach ( $deleted['data']['deletedRecords'] as $result ) {
486
+				foreach ($deleted['data']['deletedRecords'] as $result) {
487 487
 
488 488
 					$sf_sync_trigger = $this->mappings->sync_sf_delete;
489 489
 
490 490
 					// salesforce seriously returns Id for update requests and id for delete requests and this makes no sense but maybe one day they might change it somehow?
491
-					if ( ! isset( $result['Id'] ) && isset( $result['id'] ) ) {
491
+					if ( ! isset($result['Id']) && isset($result['id'])) {
492 492
 						$result['Id'] = $result['id'];
493 493
 					}
494 494
 					$data = array(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 
501 501
 					// Hook to allow other plugins to prevent a pull per-mapping.
502 502
 					// Putting the pull_allowed hook here will keep the queue from storing data when it is not supposed to store it
503
-					$pull_allowed = apply_filters( 'object_sync_for_salesforce_pull_object_allowed', true, $type, $result, $sf_sync_trigger, $salesforce_mapping );
503
+					$pull_allowed = apply_filters('object_sync_for_salesforce_pull_object_allowed', true, $type, $result, $sf_sync_trigger, $salesforce_mapping);
504 504
 
505 505
 					// example to keep from pulling the Contact with id of abcdef
506 506
 					/*
@@ -513,17 +513,17 @@  discard block
 block discarded – undo
513 513
 					}
514 514
 					*/
515 515
 
516
-					if ( false === $pull_allowed ) {
516
+					if (false === $pull_allowed) {
517 517
 						continue;
518 518
 					}
519 519
 
520 520
 					// add a queue action to save data from salesforce
521 521
 					$this->queue->add(
522
-						$this->schedulable_classes[ $this->schedule_name ]['callback'],
522
+						$this->schedulable_classes[$this->schedule_name]['callback'],
523 523
 						array(
524 524
 							'object_type'     => $type,
525 525
 							'object'          => $result['Id'],
526
-							'mapping'         => filter_var( $salesforce_mapping['id'], FILTER_VALIDATE_INT ),
526
+							'mapping'         => filter_var($salesforce_mapping['id'], FILTER_VALIDATE_INT),
527 527
 							'sf_sync_trigger' => $sf_sync_trigger,
528 528
 						),
529 529
 						$this->schedule_name
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 
532 532
 				}
533 533
 
534
-				update_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, current_time( 'timestamp', true ) );
534
+				update_option('object_sync_for_salesforce_pull_delete_last_' . $type, current_time('timestamp', true));
535 535
 
536 536
 			} // End foreach().
537 537
 		} // End foreach().
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
 	* @param string $wordpress_object
546 546
 	*
547 547
 	*/
548
-	public function manual_pull( $object_type, $salesforce_id, $wordpress_object ) {
548
+	public function manual_pull($object_type, $salesforce_id, $wordpress_object) {
549 549
 		$sfapi   = $this->salesforce['sfapi'];
550
-		$object  = $sfapi->api_call( 'sobjects/' . $object_type . '/' . $salesforce_id );
550
+		$object  = $sfapi->api_call('sobjects/' . $object_type . '/' . $salesforce_id);
551 551
 		$mapping = $this->mappings->get_fieldmaps(
552 552
 			null,
553 553
 			array(
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 				'wordpress_object'  => $wordpress_object,
556 556
 			)
557 557
 		);
558
-		$this->salesforce_pull_process_records( $object_type, $object['data'], $mapping[0], $this->mappings->sync_sf_update );
558
+		$this->salesforce_pull_process_records($object_type, $object['data'], $mapping[0], $this->mappings->sync_sf_update);
559 559
 	}
560 560
 
561 561
 	/**
@@ -573,59 +573,59 @@  discard block
 block discarded – undo
573 573
 	* @return true or exit the method
574 574
 	*
575 575
 	*/
576
-	public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) {
576
+	public function salesforce_pull_process_records($object_type, $object, $mapping, $sf_sync_trigger) {
577 577
 
578 578
 		$sfapi = $this->salesforce['sfapi'];
579 579
 
580
-		if ( is_string( $object ) ) {
580
+		if (is_string($object)) {
581 581
 			$object_id = $object;
582
-			$object    = $sfapi->object_read( $object_type, $object_id )['data'];
582
+			$object    = $sfapi->object_read($object_type, $object_id)['data'];
583 583
 		}
584 584
 
585
-		if ( is_int( $mapping ) ) {
585
+		if (is_int($mapping)) {
586 586
 			$mapping_id = $mapping;
587
-			$mapping    = $this->mappings->get_fieldmaps( $mapping_id );
587
+			$mapping    = $this->mappings->get_fieldmaps($mapping_id);
588 588
 		}
589 589
 
590 590
 		$mapping_conditions = array(
591 591
 			'salesforce_object' => $object_type,
592 592
 		);
593 593
 
594
-		if ( isset( $object['RecordTypeId'] ) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type ) {
594
+		if (isset($object['RecordTypeId']) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type) {
595 595
 			// use this condition to filter the mappings, at that time
596 596
 			$mapping_conditions['salesforce_record_type'] = $object['RecordTypeId'];
597 597
 		}
598 598
 
599
-		$salesforce_mappings = $this->mappings->get_fieldmaps( null, $mapping_conditions );
599
+		$salesforce_mappings = $this->mappings->get_fieldmaps(null, $mapping_conditions);
600 600
 
601 601
 		// from drupal: if there is more than one mapping, don't throw exceptions
602
-		$hold_exceptions = count( $salesforce_mappings ) > 1;
602
+		$hold_exceptions = count($salesforce_mappings) > 1;
603 603
 		$exception       = false;
604 604
 
605 605
 		$frequencies = $this->queue->get_frequencies();
606
-		$seconds     = reset( $frequencies )['frequency'] + 60;
606
+		$seconds     = reset($frequencies)['frequency'] + 60;
607 607
 
608 608
 		$transients_to_delete = array();
609 609
 
610
-		foreach ( $salesforce_mappings as $salesforce_mapping ) {
610
+		foreach ($salesforce_mappings as $salesforce_mapping) {
611 611
 
612 612
 			// this returns the row that maps the individual Salesforce row to the individual WordPress row
613
-			if ( isset( $object['Id'] ) ) {
614
-				$mapping_object = $this->mappings->load_by_salesforce( $object['Id'] );
613
+			if (isset($object['Id'])) {
614
+				$mapping_object = $this->mappings->load_by_salesforce($object['Id']);
615 615
 			} else {
616 616
 				// if we don't have a Salesforce object id, we've got no business doing stuff in WordPress
617 617
 				$status = 'error';
618
-				if ( isset( $this->logging ) ) {
618
+				if (isset($this->logging)) {
619 619
 					$logging = $this->logging;
620
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
621
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
620
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
621
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
622 622
 				}
623 623
 
624
-				$title = sprintf( esc_html__( 'Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce' ) );
624
+				$title = sprintf(esc_html__('Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce'));
625 625
 
626 626
 				$logging->setup(
627 627
 					$title,
628
-					print_r( $object, true ), // log whatever we have in the event of this error, so print the array
628
+					print_r($object, true), // log whatever we have in the event of this error, so print the array
629 629
 					$sf_sync_trigger,
630 630
 					0, // parent id goes here but we don't have one, so make it 0
631 631
 					$status
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			// if it's not already connected (ie on create), the array will be empty
638 638
 
639 639
 			// hook to allow other plugins to define or alter the mapping object
640
-			$mapping_object = apply_filters( 'object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping );
640
+			$mapping_object = apply_filters('object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping);
641 641
 
642 642
 			// we already have the data from Salesforce at this point; we just need to work with it in WordPress
643 643
 			$synced_object = array(
@@ -646,58 +646,58 @@  discard block
 block discarded – undo
646 646
 				'mapping'           => $mapping,
647 647
 			);
648 648
 
649
-			$structure = $this->wordpress->get_wordpress_table_structure( $salesforce_mapping['wordpress_object'] );
649
+			$structure = $this->wordpress->get_wordpress_table_structure($salesforce_mapping['wordpress_object']);
650 650
 			$object_id = $structure['id_field'];
651 651
 
652 652
 			$op = '';
653 653
 
654 654
 			// are these objects already connected in WordPress?
655
-			if ( isset( $mapping_object['id'] ) ) {
655
+			if (isset($mapping_object['id'])) {
656 656
 				$is_new                      = false;
657 657
 				$mapping_object_id_transient = $mapping_object['id'];
658 658
 			} else {
659 659
 				// there is not a mapping object for this WordPress object id yet
660 660
 				// check for that transient with the currently pushing id
661 661
 				$is_new                      = true;
662
-				$mapping_object_id_transient = get_transient( 'salesforce_pushing_object_id' );
662
+				$mapping_object_id_transient = get_transient('salesforce_pushing_object_id');
663 663
 			}
664 664
 
665 665
 			// Drupal only does a salesforce_pull flag, but we might as well do push and pull because WordPress
666
-			$salesforce_pushing = (int) get_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
667
-			if ( 1 === $salesforce_pushing ) {
666
+			$salesforce_pushing = (int) get_transient('salesforce_pushing_' . $mapping_object_id_transient);
667
+			if (1 === $salesforce_pushing) {
668 668
 				$transients_to_delete[] = $mapping_object_id_transient;
669 669
 				continue;
670 670
 			}
671 671
 
672 672
 			// deleting mapped objects
673
-			if ( $sf_sync_trigger == $this->mappings->sync_sf_delete ) { // trigger is a bit operator
674
-				if ( isset( $mapping_object['id'] ) ) {
673
+			if ($sf_sync_trigger == $this->mappings->sync_sf_delete) { // trigger is a bit operator
674
+				if (isset($mapping_object['id'])) {
675 675
 
676
-					set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
677
-					set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
676
+					set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
677
+					set_transient('salesforce_pulling_object_id', $mapping_object['id']);
678 678
 
679 679
 					$op              = 'Delete';
680
-					$wordpress_check = $this->mappings->load_by_wordpress( $mapping_object['wordpress_object'], $mapping_object['wordpress_id'] );
681
-					if ( count( $wordpress_check ) === count( $wordpress_check, COUNT_RECURSIVE ) ) {
680
+					$wordpress_check = $this->mappings->load_by_wordpress($mapping_object['wordpress_object'], $mapping_object['wordpress_id']);
681
+					if (count($wordpress_check) === count($wordpress_check, COUNT_RECURSIVE)) {
682 682
 						try {
683
-							$result = $this->wordpress->object_delete( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'] );
684
-						} catch ( WordpressException $e ) {
683
+							$result = $this->wordpress->object_delete($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id']);
684
+						} catch (WordpressException $e) {
685 685
 							$status = 'error';
686 686
 							// create log entry for failed delete
687
-							if ( isset( $this->logging ) ) {
687
+							if (isset($this->logging)) {
688 688
 								$logging = $this->logging;
689
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
690
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
689
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
690
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
691 691
 							}
692 692
 
693 693
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
694
-							$title = sprintf( esc_html__( 'Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
695
-								esc_attr( $op ),
696
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
697
-								esc_attr( $object_id ),
698
-								esc_attr( $mapping_object['wordpress_id'] ),
699
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
700
-								esc_attr( $mapping_object['salesforce_id'] )
694
+							$title = sprintf(esc_html__('Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
695
+								esc_attr($op),
696
+								esc_attr($salesforce_mapping['wordpress_object']),
697
+								esc_attr($object_id),
698
+								esc_attr($mapping_object['wordpress_id']),
699
+								esc_attr($salesforce_mapping['salesforce_object']),
700
+								esc_attr($mapping_object['salesforce_id'])
701 701
 							);
702 702
 
703 703
 							$logging->setup(
@@ -708,38 +708,38 @@  discard block
 block discarded – undo
708 708
 								$status
709 709
 							);
710 710
 
711
-							if ( false === $hold_exceptions ) {
711
+							if (false === $hold_exceptions) {
712 712
 								throw $e;
713 713
 							}
714
-							if ( empty( $exception ) ) {
714
+							if (empty($exception)) {
715 715
 								$exception = $e;
716 716
 							} else {
717
-								$my_class  = get_class( $e );
718
-								$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
717
+								$my_class  = get_class($e);
718
+								$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
719 719
 							}
720 720
 
721 721
 							// hook for pull fail
722
-							do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
722
+							do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
723 723
 
724 724
 						} // End try().
725 725
 
726
-						if ( ! isset( $e ) ) {
726
+						if ( ! isset($e)) {
727 727
 							// create log entry for successful delete if the result had no errors
728 728
 							$status = 'success';
729
-							if ( isset( $this->logging ) ) {
729
+							if (isset($this->logging)) {
730 730
 								$logging = $this->logging;
731
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
732
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
731
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
732
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
733 733
 							}
734 734
 
735 735
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
736
-							$title = sprintf( esc_html__( 'Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
737
-								esc_attr( $op ),
738
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
739
-								esc_attr( $object_id ),
740
-								esc_attr( $mapping_object['wordpress_id'] ),
741
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
742
-								esc_attr( $mapping_object['salesforce_id'] )
736
+							$title = sprintf(esc_html__('Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
737
+								esc_attr($op),
738
+								esc_attr($salesforce_mapping['wordpress_object']),
739
+								esc_attr($object_id),
740
+								esc_attr($mapping_object['wordpress_id']),
741
+								esc_attr($salesforce_mapping['salesforce_object']),
742
+								esc_attr($mapping_object['salesforce_id'])
743 743
 							);
744 744
 
745 745
 							$logging->setup(
@@ -751,38 +751,38 @@  discard block
 block discarded – undo
751 751
 							);
752 752
 
753 753
 							// hook for pull success
754
-							do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
754
+							do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
755 755
 						}
756 756
 					} else {
757
-						$more_ids = sprintf( '<p>' . esc_html__( 'The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce' ) );
757
+						$more_ids = sprintf('<p>' . esc_html__('The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce'));
758 758
 						$i        = 0;
759
-						foreach ( $wordpress_check as $match ) {
759
+						foreach ($wordpress_check as $match) {
760 760
 							$i++;
761
-							$more_ids .= sprintf( $match['salesforce_id'] );
762
-							if ( count( $wordpress_check ) !== $i ) {
763
-								$more_ids .= sprintf( ', ' );
761
+							$more_ids .= sprintf($match['salesforce_id']);
762
+							if (count($wordpress_check) !== $i) {
763
+								$more_ids .= sprintf(', ');
764 764
 							} else {
765
-								$more_ids .= sprintf( '.</p>' );
765
+								$more_ids .= sprintf('.</p>');
766 766
 							}
767 767
 						}
768 768
 
769
-						$more_ids .= sprintf( '<p>' . esc_html__( 'The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce' ) . '</p>' );
769
+						$more_ids .= sprintf('<p>' . esc_html__('The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce') . '</p>');
770 770
 
771 771
 						$status = 'notice';
772
-						if ( isset( $this->logging ) ) {
772
+						if (isset($this->logging)) {
773 773
 							$logging = $this->logging;
774
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
775
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
774
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
775
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
776 776
 						}
777 777
 
778 778
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
779
-						$title = sprintf( esc_html__( 'Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce' ),
780
-							esc_attr( $op ),
781
-							esc_attr( $salesforce_mapping['wordpress_object'] ),
782
-							esc_attr( $object_id ),
783
-							esc_attr( $mapping_object['wordpress_id'] ),
784
-							esc_attr( $salesforce_mapping['salesforce_object'] ),
785
-							esc_attr( $mapping_object['salesforce_id'] )
779
+						$title = sprintf(esc_html__('Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce'),
780
+							esc_attr($op),
781
+							esc_attr($salesforce_mapping['wordpress_object']),
782
+							esc_attr($object_id),
783
+							esc_attr($mapping_object['wordpress_id']),
784
+							esc_attr($salesforce_mapping['salesforce_object']),
785
+							esc_attr($mapping_object['salesforce_id'])
786 786
 						);
787 787
 
788 788
 						$logging->setup(
@@ -796,27 +796,27 @@  discard block
 block discarded – undo
796 796
 
797 797
 					// delete the map row from WordPress after the WordPress row has been deleted
798 798
 					// we delete the map row even if the WordPress delete failed, because the Salesforce object is gone
799
-					$this->mappings->delete_object_map( $mapping_object['id'] );
799
+					$this->mappings->delete_object_map($mapping_object['id']);
800 800
 					// there is no map row if we end this if statement
801 801
 				} // End if().
802 802
 				return;
803 803
 			} // End if().
804 804
 
805 805
 			// map the Salesforce values to WordPress fields
806
-			$params = $this->mappings->map_params( $mapping, $object, $sf_sync_trigger, false, $is_new );
806
+			$params = $this->mappings->map_params($mapping, $object, $sf_sync_trigger, false, $is_new);
807 807
 
808 808
 			// hook to allow other plugins to modify the $params array
809 809
 			// use hook to map fields between the WordPress and Salesforce objects
810 810
 			// returns $params.
811
-			$params = apply_filters( 'object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new );
811
+			$params = apply_filters('object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new);
812 812
 
813 813
 			// if we don't get any params, there are no fields that should be sent to WordPress
814
-			if ( empty( $params ) ) {
814
+			if (empty($params)) {
815 815
 				return;
816 816
 			}
817 817
 
818 818
 			// if there is a prematch WordPress field - ie email - on the fieldmap object
819
-			if ( isset( $params['prematch'] ) && is_array( $params['prematch'] ) ) {
819
+			if (isset($params['prematch']) && is_array($params['prematch'])) {
820 820
 				$prematch_field_wordpress  = $params['prematch']['wordpress_field'];
821 821
 				$prematch_field_salesforce = $params['prematch']['salesforce_field'];
822 822
 				$prematch_value            = $params['prematch']['value'];
@@ -826,22 +826,22 @@  discard block
 block discarded – undo
826 826
 					'method_update' => $params['prematch']['method_update'],
827 827
 					'method_read'   => $params['prematch']['method_read'],
828 828
 				);
829
-				unset( $params['prematch'] );
829
+				unset($params['prematch']);
830 830
 			}
831 831
 
832 832
 			// if there is an external key field in Salesforce - ie a Mailchimp user id - on the fieldmap object, this should not affect how WordPress handles it so we have removed it from the pull parameters.
833 833
 
834 834
 			// methods to run the wp create or update operations
835 835
 
836
-			if ( true === $is_new ) {
836
+			if (true === $is_new) {
837 837
 
838 838
 				// setup SF record type. CampaignMember objects get their Campaign's type
839 839
 				// i am still a bit confused about this
840 840
 				// we should store this as a meta field on each object, if it meets these criteria
841 841
 				// we need to store the read/modify attributes because the field doesn't exist in the mapping
842
-				if ( $salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty( $params['RecordTypeId'] ) && ( 'CampaignMember' !== $salesforce_mapping['salesforce_object'] ) ) {
842
+				if ($salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty($params['RecordTypeId']) && ('CampaignMember' !== $salesforce_mapping['salesforce_object'])) {
843 843
 					$type = $salesforce_mapping['wordpress_object'];
844
-					if ( 'category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object'] ) {
844
+					if ('category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object']) {
845 845
 						$type = 'term';
846 846
 					}
847 847
 					$params['RecordTypeId'] = array(
@@ -859,24 +859,24 @@  discard block
 block discarded – undo
859 859
 					// returns a $salesforce_id.
860 860
 					// it should keep NULL if there is no match
861 861
 					// the function that calls this hook needs to check the mapping to make sure the WordPress object is the right type
862
-					$wordpress_id = apply_filters( 'object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull' );
862
+					$wordpress_id = apply_filters('object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull');
863 863
 
864 864
 					// hook to allow other plugins to do something right before WordPress data is saved
865 865
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
866
-					do_action( 'object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params );
866
+					do_action('object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params);
867 867
 
868
-					if ( isset( $prematch_field_salesforce ) || null !== $wordpress_id ) {
868
+					if (isset($prematch_field_salesforce) || null !== $wordpress_id) {
869 869
 
870 870
 						$op = 'Upsert';
871 871
 
872 872
 						// if either prematch criteria exists, make the values queryable
873
-						if ( isset( $prematch_field_salesforce ) ) {
873
+						if (isset($prematch_field_salesforce)) {
874 874
 							$upsert_key     = $prematch_field_wordpress;
875 875
 							$upsert_value   = $prematch_value;
876 876
 							$upsert_methods = $prematch_methods;
877 877
 						}
878 878
 
879
-						if ( null !== $wordpress_id ) {
879
+						if (null !== $wordpress_id) {
880 880
 							$upsert_key     = $object_id;
881 881
 							$upsert_value   = $wordpress_id;
882 882
 							$upsert_methods = array();
@@ -885,13 +885,13 @@  discard block
 block discarded – undo
885 885
 						// with the flag at the end, upsert returns a $wordpress_id only
886 886
 						// we can then check to see if it has a mapping object
887 887
 						// we should only do this if the above hook didn't already set the $wordpress_id
888
-						if ( null === $wordpress_id ) {
889
-							$wordpress_id = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true );
888
+						if (null === $wordpress_id) {
889
+							$wordpress_id = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true);
890 890
 						}
891 891
 
892 892
 						// find out if there is a mapping object for this WordPress object already
893 893
 						// don't do it if the WordPress id is 0.
894
-						if ( 0 !== $wordpress_id ) {
894
+						if (0 !== $wordpress_id) {
895 895
 							$mapping_object = $this->mappings->get_object_maps(
896 896
 								array(
897 897
 									'wordpress_id'     => $wordpress_id,
@@ -906,35 +906,35 @@  discard block
 block discarded – undo
906 906
 								)
907 907
 							);
908 908
 
909
-							if ( array() !== $mapping_object_debug ) {
909
+							if (array() !== $mapping_object_debug) {
910 910
 								// create log entry to warn about at least one id of 0
911 911
 								$status = 'error';
912
-								$title  = sprintf( esc_html__( 'Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce' ) );
912
+								$title  = sprintf(esc_html__('Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce'));
913 913
 
914
-								if ( 1 === count( $mapping_object_debug ) ) {
914
+								if (1 === count($mapping_object_debug)) {
915 915
 									// translators: placeholders are: 1) the mapping object row ID, 2) the name of the WordPress object, 3) the ID of the Salesforce object it was trying to map
916
-									$body = sprintf( esc_html__( 'There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce' ),
917
-										absint( $mapping_object_debug['id'] ),
918
-										esc_attr( $salesforce_mapping['wordpress_object'] ),
919
-										esc_attr( $mapping_object_debug['salesforce_id'] )
916
+									$body = sprintf(esc_html__('There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce'),
917
+										absint($mapping_object_debug['id']),
918
+										esc_attr($salesforce_mapping['wordpress_object']),
919
+										esc_attr($mapping_object_debug['salesforce_id'])
920 920
 									);
921 921
 								} else {
922
-									$body = sprintf( esc_html__( 'There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce' ) . '<ul>' );
923
-									foreach ( $mapping_object_debug as $mapping_object ) {
922
+									$body = sprintf(esc_html__('There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce') . '<ul>');
923
+									foreach ($mapping_object_debug as $mapping_object) {
924 924
 										// translators: placeholders are: 1) the mapping object row ID, 2) the ID of the Salesforce object, 3) the WordPress object type
925
-										$body .= sprintf( '<li>' . esc_html__( 'Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
926
-											absint( $mapping_object['id'] ),
927
-											esc_attr( $mapping_object['salesforce_id'] ),
928
-											esc_attr( $salesforce_mapping['wordpress_object'] )
925
+										$body .= sprintf('<li>' . esc_html__('Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce') . '</li>',
926
+											absint($mapping_object['id']),
927
+											esc_attr($mapping_object['salesforce_id']),
928
+											esc_attr($salesforce_mapping['wordpress_object'])
929 929
 										);
930 930
 									}
931
-									$body .= sprintf( '</ul>' );
931
+									$body .= sprintf('</ul>');
932 932
 								}
933 933
 
934
-								if ( isset( $this->logging ) ) {
934
+								if (isset($this->logging)) {
935 935
 									$logging = $this->logging;
936
-								} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
937
-									$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
936
+								} elseif (class_exists('Object_Sync_Sf_Logging')) {
937
+									$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
938 938
 								}
939 939
 								$parent = 0;
940 940
 								$logging->setup(
@@ -948,37 +948,37 @@  discard block
 block discarded – undo
948 948
 						} // End if().
949 949
 
950 950
 						// there is already a mapping object. don't change the WordPress data to match this new Salesforce record, but log it
951
-						if ( isset( $mapping_object['id'] ) ) {
951
+						if (isset($mapping_object['id'])) {
952 952
 							// set the transient so that salesforce_push doesn't start doing stuff, then return out of here
953
-							set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
954
-							set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
953
+							set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
954
+							set_transient('salesforce_pulling_object_id', $mapping_object['id']);
955 955
 							// create log entry to indicate that nothing happened
956 956
 							$status = 'notice';
957 957
 							// translators: placeholders are: 1) mapping object row id, 2) WordPress object tyoe, 3) individual WordPress item ID, 4) individual Salesforce item ID
958
-							$title = sprintf( esc_html__( 'Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce' ),
959
-								absint( $mapping_object['id'] ),
960
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
961
-								absint( $wordpress_id ),
962
-								esc_attr( $object['Id'] )
958
+							$title = sprintf(esc_html__('Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce'),
959
+								absint($mapping_object['id']),
960
+								esc_attr($salesforce_mapping['wordpress_object']),
961
+								absint($wordpress_id),
962
+								esc_attr($object['Id'])
963 963
 							);
964 964
 
965 965
 							// translators: placeholders are 1) WordPress object type, 2) field name for the WordPress id, 3) the WordPress id value, 4) the Salesforce object type, 5) the Salesforce object Id that was modified, 6) the mapping object row id
966
-							$body = sprintf( esc_html__( 'The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce' ),
967
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
968
-								esc_attr( $structure['id_field'] ),
969
-								absint( $wordpress_id ),
970
-								esc_attr( $mapping_object['salesforce_object'] ),
971
-								esc_attr( $object['Id'] ),
972
-								absint( $mapping_object['id'] )
966
+							$body = sprintf(esc_html__('The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce'),
967
+								esc_attr($salesforce_mapping['wordpress_object']),
968
+								esc_attr($structure['id_field']),
969
+								absint($wordpress_id),
970
+								esc_attr($mapping_object['salesforce_object']),
971
+								esc_attr($object['Id']),
972
+								absint($mapping_object['id'])
973 973
 							);
974 974
 
975
-							if ( isset( $this->logging ) ) {
975
+							if (isset($this->logging)) {
976 976
 								$logging = $this->logging;
977
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
978
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
977
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
978
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
979 979
 							}
980 980
 							// if we know the WordPress object id we can put it in there
981
-							if ( null !== $wordpress_id ) {
981
+							if (null !== $wordpress_id) {
982 982
 								$parent = $wordpress_id;
983 983
 							} else {
984 984
 								$parent = 0;
@@ -997,9 +997,9 @@  discard block
 block discarded – undo
997 997
 						// right here we should set the pulling transient
998 998
 						// this means we have to create the mapping object here as well, and update it with the correct IDs after successful response
999 999
 						// create the mapping object between the rows
1000
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
1001
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
1002
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
1000
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
1001
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
1002
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
1003 1003
 						$mapping_object = $this->mappings->get_object_maps(
1004 1004
 							array(
1005 1005
 								'id' => $mapping_object_id,
@@ -1008,50 +1008,50 @@  discard block
 block discarded – undo
1008 1008
 
1009 1009
 						// now we can upsert the object in wp if we've gotten to this point
1010 1010
 						// this command will either create or update the object
1011
-						$result = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'] );
1011
+						$result = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts']);
1012 1012
 
1013 1013
 					} else {
1014 1014
 						// No key or prematch field exists on this field map object, create a new object in WordPress.
1015 1015
 						$op                = 'Create';
1016
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
1017
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
1018
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
1016
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
1017
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
1018
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
1019 1019
 						$mapping_object = $this->mappings->get_object_maps(
1020 1020
 							array(
1021 1021
 								'id' => $mapping_object_id,
1022 1022
 							)
1023 1023
 						);
1024 1024
 
1025
-						$result = $this->wordpress->object_create( $salesforce_mapping['wordpress_object'], $params );
1025
+						$result = $this->wordpress->object_create($salesforce_mapping['wordpress_object'], $params);
1026 1026
 					} // End if().
1027
-				} catch ( WordpressException $e ) {
1027
+				} catch (WordpressException $e) {
1028 1028
 					// create log entry for failed create or upsert
1029 1029
 					$status = 'error';
1030 1030
 
1031 1031
 					// translators: placeholders are: 1) what operation is happening, and 2) the name of the WordPress object
1032
-					$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
1033
-						esc_attr( $op ),
1034
-						esc_attr( $salesforce_mapping['wordpress_object'] )
1032
+					$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
1033
+						esc_attr($op),
1034
+						esc_attr($salesforce_mapping['wordpress_object'])
1035 1035
 					);
1036 1036
 
1037
-					if ( null !== $salesforce_id ) {
1037
+					if (null !== $salesforce_id) {
1038 1038
 						$title .= ' ' . $salesforce_id;
1039 1039
 					}
1040 1040
 
1041 1041
 					// translators: placeholders are: 1) the name of the Salesforce object, and 2) Id of the Salesforce object
1042
-					$title .= sprintf( esc_html__( ' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce' ),
1042
+					$title .= sprintf(esc_html__(' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce'),
1043 1043
 						$salesforce_mapping['salesforce_object'],
1044 1044
 						$object['Id']
1045 1045
 					);
1046 1046
 
1047
-					if ( isset( $this->logging ) ) {
1047
+					if (isset($this->logging)) {
1048 1048
 						$logging = $this->logging;
1049
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1050
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1049
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1050
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1051 1051
 					}
1052 1052
 
1053 1053
 					// if we know the WordPress object id we can put it in there
1054
-					if ( null !== $wordpress_id ) {
1054
+					if (null !== $wordpress_id) {
1055 1055
 						$parent = $wordpress_id;
1056 1056
 					} else {
1057 1057
 						$parent = 0;
@@ -1065,26 +1065,26 @@  discard block
 block discarded – undo
1065 1065
 						$status
1066 1066
 					);
1067 1067
 
1068
-					if ( false === $hold_exceptions ) {
1068
+					if (false === $hold_exceptions) {
1069 1069
 						throw $e;
1070 1070
 					}
1071
-					if ( empty( $exception ) ) {
1071
+					if (empty($exception)) {
1072 1072
 						$exception = $e;
1073 1073
 					} else {
1074
-						$my_class  = get_class( $e );
1075
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1074
+						$my_class  = get_class($e);
1075
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1076 1076
 					}
1077 1077
 
1078 1078
 					// hook for pull fail
1079
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1079
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1080 1080
 
1081 1081
 					return;
1082 1082
 				} // End try().
1083 1083
 
1084 1084
 				// set $wordpress_data to the query result
1085 1085
 				$wordpress_data = $result['data'];
1086
-				if ( isset( $wordpress_data[ "$object_id" ] ) ) {
1087
-					$wordpress_id = $wordpress_data[ "$object_id" ];
1086
+				if (isset($wordpress_data["$object_id"])) {
1087
+					$wordpress_id = $wordpress_data["$object_id"];
1088 1088
 				} else {
1089 1089
 					$wordpress_id = 0;
1090 1090
 				}
@@ -1093,23 +1093,23 @@  discard block
 block discarded – undo
1093 1093
 				// this means the object has already been created/updated in WordPress
1094 1094
 				// this is not redundant because this is where it creates the object mapping rows in WordPress if the object does not already have one (we are still inside $is_new === TRUE here)
1095 1095
 
1096
-				if ( empty( $result['errors'] ) ) {
1096
+				if (empty($result['errors'])) {
1097 1097
 					$status = 'success';
1098 1098
 
1099
-					if ( isset( $this->logging ) ) {
1099
+					if (isset($this->logging)) {
1100 1100
 						$logging = $this->logging;
1101
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1102
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1101
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1102
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1103 1103
 					}
1104 1104
 
1105 1105
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1106
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1107
-						esc_attr( $op ),
1108
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1109
-						esc_attr( $object_id ),
1110
-						esc_attr( $wordpress_id ),
1111
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1112
-						esc_attr( $object['Id'] )
1106
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1107
+						esc_attr($op),
1108
+						esc_attr($salesforce_mapping['wordpress_object']),
1109
+						esc_attr($object_id),
1110
+						esc_attr($wordpress_id),
1111
+						esc_attr($salesforce_mapping['salesforce_object']),
1112
+						esc_attr($object['Id'])
1113 1113
 					);
1114 1114
 
1115 1115
 					$logging->setup(
@@ -1122,40 +1122,40 @@  discard block
 block discarded – undo
1122 1122
 
1123 1123
 					// update that mapping object
1124 1124
 					$mapping_object['wordpress_id'] = $wordpress_id;
1125
-					$mapping_object                 = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1125
+					$mapping_object                 = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1126 1126
 
1127 1127
 					// hook for pull success
1128
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1128
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1129 1129
 				} else {
1130 1130
 
1131 1131
 					// create log entry for failed create or upsert
1132 1132
 					// this is part of the drupal module but i am failing to understand when it would ever fire, since the catch should catch the errors
1133 1133
 					// if we see this in the log entries, we can understand what it does, but probably not until then
1134 1134
 					$status = 'error';
1135
-					if ( isset( $this->logging ) ) {
1135
+					if (isset($this->logging)) {
1136 1136
 						$logging = $this->logging;
1137
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1138
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1137
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1138
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1139 1139
 					}
1140 1140
 
1141
-					if ( is_object( $wordpress_id ) ) {
1141
+					if (is_object($wordpress_id)) {
1142 1142
 						// print this array because if this happens, something weird has happened and we want to log whatever we have
1143
-						$wordpress_id = print_r( $wordpress_id, true );
1143
+						$wordpress_id = print_r($wordpress_id, true);
1144 1144
 					}
1145 1145
 
1146 1146
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object type, 3) the Salesforce object Id value
1147
-					$title = sprintf( esc_html__( 'Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce' ),
1148
-						esc_attr( $op ),
1149
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1150
-						esc_attr( $object['Id'] )
1147
+					$title = sprintf(esc_html__('Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce'),
1148
+						esc_attr($op),
1149
+						esc_attr($salesforce_mapping['salesforce_object']),
1150
+						esc_attr($object['Id'])
1151 1151
 					);
1152 1152
 
1153 1153
 					// translators: placeholders are: 1) the name of the WordPress object type, 2) the WordPress id field name, 3) the WordPress id field value, 4) the array of errors
1154
-					$body = sprintf( '<p>' . esc_html__( 'Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: ', 'object-sync-for-salesforce' ) . '%4$s',
1155
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1156
-						esc_attr( $object_id ),
1157
-						esc_attr( $wordpress_id ),
1158
-						print_r( $result['errors'], true ) // if we get this error, we need to know whatever we have
1154
+					$body = sprintf('<p>' . esc_html__('Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: ', 'object-sync-for-salesforce') . '%4$s',
1155
+						esc_attr($salesforce_mapping['wordpress_object']),
1156
+						esc_attr($object_id),
1157
+						esc_attr($wordpress_id),
1158
+						print_r($result['errors'], true) // if we get this error, we need to know whatever we have
1159 1159
 					);
1160 1160
 
1161 1161
 					$logging->setup(
@@ -1167,52 +1167,52 @@  discard block
 block discarded – undo
1167 1167
 					);
1168 1168
 
1169 1169
 					// hook for pull fail
1170
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1170
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1171 1171
 
1172 1172
 					return;
1173 1173
 				} // End if().
1174
-			} elseif ( false === $is_new ) {
1174
+			} elseif (false === $is_new) {
1175 1175
 
1176 1176
 				// right here we should set the pulling transient
1177
-				set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
1178
-				set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
1177
+				set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
1178
+				set_transient('salesforce_pulling_object_id', $mapping_object['id']);
1179 1179
 
1180 1180
 				// there is an existing object link
1181 1181
 				// if the last sync is greater than the last time this object was updated by Salesforce, skip it
1182 1182
 				// this keeps us from doing redundant syncs
1183 1183
 				// because SF stores all DateTimes in UTC.
1184
-				$mapping_object['object_updated'] = current_time( 'mysql' );
1184
+				$mapping_object['object_updated'] = current_time('mysql');
1185 1185
 
1186 1186
 				$pull_trigger_field = $salesforce_mapping['pull_trigger_field'];
1187
-				$pull_trigger_value = $object[ $pull_trigger_field ];
1187
+				$pull_trigger_value = $object[$pull_trigger_field];
1188 1188
 
1189 1189
 				try {
1190 1190
 
1191 1191
 					// hook to allow other plugins to do something right before WordPress data is saved
1192 1192
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
1193
-					do_action( 'object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params );
1193
+					do_action('object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params);
1194 1194
 
1195 1195
 					$op     = 'Update';
1196
-					$result = $this->wordpress->object_update( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params );
1196
+					$result = $this->wordpress->object_update($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params);
1197 1197
 
1198 1198
 					$mapping_object['last_sync_status']  = $this->mappings->status_success;
1199
-					$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
1199
+					$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
1200 1200
 
1201 1201
 					$status = 'success';
1202
-					if ( isset( $this->logging ) ) {
1202
+					if (isset($this->logging)) {
1203 1203
 						$logging = $this->logging;
1204
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1205
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1204
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1205
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1206 1206
 					}
1207 1207
 
1208 1208
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1209
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1210
-						esc_attr( $op ),
1211
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1212
-						esc_attr( $object_id ),
1213
-						esc_attr( $mapping_object['wordpress_id'] ),
1214
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1215
-						esc_attr( $object['Id'] )
1209
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1210
+						esc_attr($op),
1211
+						esc_attr($salesforce_mapping['wordpress_object']),
1212
+						esc_attr($object_id),
1213
+						esc_attr($mapping_object['wordpress_id']),
1214
+						esc_attr($salesforce_mapping['salesforce_object']),
1215
+						esc_attr($object['Id'])
1216 1216
 					);
1217 1217
 
1218 1218
 					$logging->setup(
@@ -1224,25 +1224,25 @@  discard block
 block discarded – undo
1224 1224
 					);
1225 1225
 
1226 1226
 					// hook for pull success
1227
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1227
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1228 1228
 
1229
-				} catch ( WordpressException $e ) {
1229
+				} catch (WordpressException $e) {
1230 1230
 					// create log entry for failed update
1231 1231
 					$status = 'error';
1232
-					if ( isset( $this->logging ) ) {
1232
+					if (isset($this->logging)) {
1233 1233
 						$logging = $this->logging;
1234
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1235
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1234
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1235
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1236 1236
 					}
1237 1237
 
1238 1238
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1239
-					$title .= sprintf( esc_html__( 'Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce' ),
1240
-						esc_attr( $op ),
1241
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1242
-						esc_attr( $object_id ),
1243
-						esc_attr( $mapping_object['wordpress_id'] ),
1244
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1245
-						esc_attr( $object['Id'] )
1239
+					$title .= sprintf(esc_html__('Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce'),
1240
+						esc_attr($op),
1241
+						esc_attr($salesforce_mapping['wordpress_object']),
1242
+						esc_attr($object_id),
1243
+						esc_attr($mapping_object['wordpress_id']),
1244
+						esc_attr($salesforce_mapping['salesforce_object']),
1245
+						esc_attr($object['Id'])
1246 1246
 					);
1247 1247
 
1248 1248
 					$logging->setup(
@@ -1256,18 +1256,18 @@  discard block
 block discarded – undo
1256 1256
 					$mapping_object['last_sync_status']  = $this->mappings->status_error;
1257 1257
 					$mapping_object['last_sync_message'] = $e->getMessage();
1258 1258
 
1259
-					if ( false === $hold_exceptions ) {
1259
+					if (false === $hold_exceptions) {
1260 1260
 						throw $e;
1261 1261
 					}
1262
-					if ( empty( $exception ) ) {
1262
+					if (empty($exception)) {
1263 1263
 						$exception = $e;
1264 1264
 					} else {
1265
-						$my_class  = get_class( $e );
1266
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1265
+						$my_class  = get_class($e);
1266
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1267 1267
 					}
1268 1268
 
1269 1269
 					// hook for pull fail
1270
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1270
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1271 1271
 
1272 1272
 				} // End try().
1273 1273
 
@@ -1276,26 +1276,26 @@  discard block
 block discarded – undo
1276 1276
 				// maybe can check to see if we actually updated anything in WordPress
1277 1277
 				// tell the mapping object - whether it is new or already existed - how we just used it
1278 1278
 				$mapping_object['last_sync_action'] = 'pull';
1279
-				$mapping_object['last_sync']        = current_time( 'mysql' );
1279
+				$mapping_object['last_sync']        = current_time('mysql');
1280 1280
 
1281 1281
 				// update that mapping object. the Salesforce data version will be set here as well because we set it earlier
1282
-				$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1282
+				$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1283 1283
 				// end of the if statement for is_new & update or create trigger
1284 1284
 				// this keeps stuff from running too many times, and also keeps it from using the wrong methods. we don't need a generic } else { here at this time.
1285 1285
 			} // End if().
1286 1286
 		} // End foreach().
1287 1287
 
1288 1288
 		// delete transients that we've already processed
1289
-		foreach ( $transients_to_delete as $mapping_object_id_transient ) {
1290
-			delete_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
1289
+		foreach ($transients_to_delete as $mapping_object_id_transient) {
1290
+			delete_transient('salesforce_pushing_' . $mapping_object_id_transient);
1291 1291
 		}
1292 1292
 
1293
-		$pushing_id = get_transient( 'salesforce_pushing_object_id' );
1294
-		if ( in_array( $pushing_id, $transients_to_delete, true ) ) {
1295
-			delete_transient( 'salesforce_pushing_object_id' );
1293
+		$pushing_id = get_transient('salesforce_pushing_object_id');
1294
+		if (in_array($pushing_id, $transients_to_delete, true)) {
1295
+			delete_transient('salesforce_pushing_object_id');
1296 1296
 		}
1297 1297
 
1298
-		if ( ! empty( $exception ) ) {
1298
+		if ( ! empty($exception)) {
1299 1299
 			throw $exception;
1300 1300
 		}
1301 1301
 
@@ -1315,17 +1315,17 @@  discard block
 block discarded – undo
1315 1315
 	*   This is the database row for the map object
1316 1316
 	*
1317 1317
 	*/
1318
-	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1318
+	private function create_object_map($salesforce_object, $wordpress_id, $field_mapping) {
1319 1319
 		// Create object map and save it
1320 1320
 		$mapping_object = $this->mappings->create_object_map(
1321 1321
 			array(
1322 1322
 				'wordpress_id'      => $wordpress_id, // wordpress unique id
1323 1323
 				'salesforce_id'     => $salesforce_object['Id'], // salesforce unique id. we don't care what kind of object it is at this point
1324 1324
 				'wordpress_object'  => $field_mapping['wordpress_object'], // keep track of what kind of wp object this is
1325
-				'last_sync'         => current_time( 'mysql' ),
1325
+				'last_sync'         => current_time('mysql'),
1326 1326
 				'last_sync_action'  => 'pull',
1327 1327
 				'last_sync_status'  => $this->mappings->status_success,
1328
-				'last_sync_message' => esc_html__( 'Mapping object created via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1328
+				'last_sync_message' => esc_html__('Mapping object created via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1329 1329
 				'action'            => 'created',
1330 1330
 			)
1331 1331
 		);
Please login to merge, or discard this patch.
classes/salesforce_push.php 1 patch
Spacing   +299 added lines, -299 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
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	* @param object $queue
45 45
 	* @throws \Object_Sync_Sf_Exception
46 46
 	*/
47
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
47
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
48 48
 		$this->wpdb                = $wpdb;
49 49
 		$this->version             = $version;
50 50
 		$this->login_credentials   = $login_credentials;
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 		$this->schedule_name = 'salesforce_push';
60 60
 
61 61
 		// Create action hooks for WordPress objects. We run this after plugins are loaded in case something depends on another plugin.
62
-		add_action( 'plugins_loaded', array( $this, 'add_actions' ) );
62
+		add_action('plugins_loaded', array($this, 'add_actions'));
63 63
 
64
-		$this->debug = get_option( 'object_sync_for_salesforce_debug_mode', false );
64
+		$this->debug = get_option('object_sync_for_salesforce_debug_mode', false);
65 65
 
66 66
 	}
67 67
 
@@ -71,41 +71,41 @@  discard block
 block discarded – undo
71 71
 	*
72 72
 	*/
73 73
 	public function add_actions() {
74
-		$db_version = get_option( 'object_sync_for_salesforce_db_version', false );
75
-		if ( $db_version === $this->version ) {
76
-			foreach ( $this->mappings->get_fieldmaps() as $mapping ) {
74
+		$db_version = get_option('object_sync_for_salesforce_db_version', false);
75
+		if ($db_version === $this->version) {
76
+			foreach ($this->mappings->get_fieldmaps() as $mapping) {
77 77
 				$object_type = $mapping['wordpress_object'];
78
-				if ( 'user' === $object_type ) {
79
-					if ( defined( 'ultimatemember_plugin_name' ) ) {
80
-						add_action( 'um_user_register', array( $this, 'um_add_user' ), 11, 2 );
78
+				if ('user' === $object_type) {
79
+					if (defined('ultimatemember_plugin_name')) {
80
+						add_action('um_user_register', array($this, 'um_add_user'), 11, 2);
81 81
 					} else {
82
-						add_action( 'user_register', array( $this, 'add_user' ), 11, 1 );
82
+						add_action('user_register', array($this, 'add_user'), 11, 1);
83 83
 					}
84
-					add_action( 'profile_update', array( $this, 'edit_user' ), 11, 2 );
85
-					add_action( 'delete_user', array( $this, 'delete_user' ) );
86
-				} elseif ( 'post' === $object_type ) {
87
-					add_action( 'save_post', array( $this, 'post_actions' ), 11, 2 );
88
-				} elseif ( 'attachment' === $object_type ) {
89
-					add_action( 'add_attachment', array( $this, 'add_attachment' ) );
90
-					add_action( 'edit_attachment', array( $this, 'edit_attachment' ) );
91
-					add_action( 'delete_attachment', array( $this, 'delete_attachment' ) );
92
-				} elseif ( 'category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type ) {
93
-					add_action( 'create_term', array( $this, 'add_term' ), 11, 3 );
94
-					add_action( 'edit_terms', array( $this, 'edit_term' ), 11, 2 );
95
-					add_action( 'delete_term', array( $this, 'delete_term' ), 10, 4 );
96
-				} elseif ( 'comment' === $object_type ) {
97
-					add_action( 'comment_post', array( $this, 'add_comment' ), 11, 3 );
98
-					add_action( 'edit_comment', array( $this, 'edit_comment' ) );
99
-					add_action( 'delete_comment', array( $this, 'delete_comment' ) ); // to be clear: this only runs when the comment gets deleted from the trash, either manually or automatically
84
+					add_action('profile_update', array($this, 'edit_user'), 11, 2);
85
+					add_action('delete_user', array($this, 'delete_user'));
86
+				} elseif ('post' === $object_type) {
87
+					add_action('save_post', array($this, 'post_actions'), 11, 2);
88
+				} elseif ('attachment' === $object_type) {
89
+					add_action('add_attachment', array($this, 'add_attachment'));
90
+					add_action('edit_attachment', array($this, 'edit_attachment'));
91
+					add_action('delete_attachment', array($this, 'delete_attachment'));
92
+				} elseif ('category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type) {
93
+					add_action('create_term', array($this, 'add_term'), 11, 3);
94
+					add_action('edit_terms', array($this, 'edit_term'), 11, 2);
95
+					add_action('delete_term', array($this, 'delete_term'), 10, 4);
96
+				} elseif ('comment' === $object_type) {
97
+					add_action('comment_post', array($this, 'add_comment'), 11, 3);
98
+					add_action('edit_comment', array($this, 'edit_comment'));
99
+					add_action('delete_comment', array($this, 'delete_comment')); // to be clear: this only runs when the comment gets deleted from the trash, either manually or automatically
100 100
 				} else { // this is for custom post types
101 101
 					// we still have to use save_post because save_post_type fails to pull in the metadata
102
-					add_action( 'save_post', array( $this, 'post_actions' ), 11, 2 );
102
+					add_action('save_post', array($this, 'post_actions'), 11, 2);
103 103
 				}
104 104
 			}
105 105
 		}
106 106
 
107 107
 		// hook that action-scheduler can call
108
-		add_action( 'object_sync_for_salesforce_push_record', array( $this, 'salesforce_push_sync_rest' ), 10, 4 );
108
+		add_action('object_sync_for_salesforce_push_record', array($this, 'salesforce_push_sync_rest'), 10, 4);
109 109
 
110 110
 	}
111 111
 
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 	* @param string $type
117 117
 	*
118 118
 	*/
119
-	public function manual_object_update( $object, $type ) {
120
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update, true );
119
+	public function manual_object_update($object, $type) {
120
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_update, true);
121 121
 	}
122 122
 
123 123
 	/**
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	*
126 126
 	* @param string $user_id
127 127
 	*/
128
-	public function add_user( $user_id ) {
129
-		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
130
-		$this->object_insert( $user, 'user' );
128
+	public function add_user($user_id) {
129
+		$user = $this->wordpress->get_wordpress_object_data('user', $user_id);
130
+		$this->object_insert($user, 'user');
131 131
 	}
132 132
 
133 133
 	/**
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	*
136 136
 	* @param string $user_id
137 137
 	*/
138
-	public function um_add_user( $user_id, $form_data = array() ) {
139
-		$this->object_insert( $form_data, 'user' );
138
+	public function um_add_user($user_id, $form_data = array()) {
139
+		$this->object_insert($form_data, 'user');
140 140
 	}
141 141
 
142 142
 	/**
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	* @param string $user_id
146 146
 	* @param object $old_user_data
147 147
 	*/
148
-	public function edit_user( $user_id, $old_user_data ) {
149
-		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
150
-		$this->object_update( $user, 'user' );
148
+	public function edit_user($user_id, $old_user_data) {
149
+		$user = $this->wordpress->get_wordpress_object_data('user', $user_id);
150
+		$this->object_update($user, 'user');
151 151
 	}
152 152
 
153 153
 	/**
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	*
156 156
 	* @param string $user_id
157 157
 	*/
158
-	public function delete_user( $user_id ) {
159
-		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
160
-		$this->object_delete( $user, 'user' );
158
+	public function delete_user($user_id) {
159
+		$user = $this->wordpress->get_wordpress_object_data('user', $user_id);
160
+		$this->object_delete($user, 'user');
161 161
 	}
162 162
 
163 163
 	/**
@@ -167,48 +167,48 @@  discard block
 block discarded – undo
167 167
 	* @param string $post_id
168 168
 	* @param object $post
169 169
 	*/
170
-	public function post_actions( $post_id, $post ) {
170
+	public function post_actions($post_id, $post) {
171 171
 
172 172
 		$post_type = $post->post_type;
173 173
 
174
-		if ( isset( $post->post_status ) && 'auto-draft' === $post->post_status ) {
174
+		if (isset($post->post_status) && 'auto-draft' === $post->post_status) {
175 175
 			return;
176 176
 		}
177 177
 		// this plugin does not sync log or revision posts with salesforce
178
-		if ( isset( $post->post_type ) && in_array( $post->post_type, array( 'wp_log', 'revision' ), true ) ) {
178
+		if (isset($post->post_type) && in_array($post->post_type, array('wp_log', 'revision'), true)) {
179 179
 			return;
180 180
 		}
181
-		if ( $post->post_modified_gmt === $post->post_date_gmt && 'trash' !== $post->post_status ) {
181
+		if ($post->post_modified_gmt === $post->post_date_gmt && 'trash' !== $post->post_status) {
182 182
 			$update = 0;
183 183
 			$delete = 0;
184
-		} elseif ( 'trash' !== $post->post_status ) {
184
+		} elseif ('trash' !== $post->post_status) {
185 185
 			$update = 1;
186 186
 			$delete = 0;
187
-		} elseif ( 'trash' === $post->post_status ) {
187
+		} elseif ('trash' === $post->post_status) {
188 188
 			$update = 0;
189 189
 			$delete = 1;
190 190
 		}
191 191
 
192 192
 		// add support for woocommerce if it is installed
193
-		if ( defined( 'WC_VERSION' ) ) {
193
+		if (defined('WC_VERSION')) {
194 194
 			// statuses to ignore
195
-			if ( isset( $post->post_status ) && in_array( $post->post_status, array( 'wc-pending' ), true ) ) {
195
+			if (isset($post->post_status) && in_array($post->post_status, array('wc-pending'), true)) {
196 196
 				return;
197 197
 			}
198 198
 			// statuses to count as new. note that the api will also check to see if it already has been mapped before saving.
199
-			if ( isset( $post->post_status ) && in_array( $post->post_status, array( 'wc-on-hold', 'wc-processing' ), true ) ) {
199
+			if (isset($post->post_status) && in_array($post->post_status, array('wc-on-hold', 'wc-processing'), true)) {
200 200
 				$update = 0;
201 201
 				$delete = 0;
202 202
 			}
203 203
 		}
204 204
 
205
-		$post = $this->wordpress->get_wordpress_object_data( $post->post_type, $post_id );
206
-		if ( 1 === $update ) {
207
-			$this->object_update( $post, $post_type );
208
-		} elseif ( 1 === $delete ) {
209
-			$this->object_delete( $post, $post_type );
205
+		$post = $this->wordpress->get_wordpress_object_data($post->post_type, $post_id);
206
+		if (1 === $update) {
207
+			$this->object_update($post, $post_type);
208
+		} elseif (1 === $delete) {
209
+			$this->object_delete($post, $post_type);
210 210
 		} else {
211
-			$this->object_insert( $post, $post_type );
211
+			$this->object_insert($post, $post_type);
212 212
 		}
213 213
 	}
214 214
 
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 	*
218 218
 	* @param string $post_id
219 219
 	*/
220
-	public function add_attachment( $post_id ) {
221
-		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
222
-		$this->object_insert( $attachment, 'attachment' );
220
+	public function add_attachment($post_id) {
221
+		$attachment = $this->wordpress->get_wordpress_object_data('attachment', $post_id);
222
+		$this->object_insert($attachment, 'attachment');
223 223
 	}
224 224
 
225 225
 	/**
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 	*
228 228
 	* @param string $post_id
229 229
 	*/
230
-	public function edit_attachment( $post_id ) {
231
-		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
232
-		$this->object_update( $attachment, 'attachment' );
230
+	public function edit_attachment($post_id) {
231
+		$attachment = $this->wordpress->get_wordpress_object_data('attachment', $post_id);
232
+		$this->object_update($attachment, 'attachment');
233 233
 	}
234 234
 
235 235
 	/**
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	*
238 238
 	* @param string $post_id
239 239
 	*/
240
-	public function delete_attachment( $post_id ) {
241
-		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
242
-		$this->object_delete( $attachment, 'attachment' );
240
+	public function delete_attachment($post_id) {
241
+		$attachment = $this->wordpress->get_wordpress_object_data('attachment', $post_id);
242
+		$this->object_delete($attachment, 'attachment');
243 243
 	}
244 244
 
245 245
 	/**
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 	* @param string $tt_id
250 250
 	* @param string $taxonomy
251 251
 	*/
252
-	public function add_term( $term_id, $tt_id, $taxonomy ) {
253
-		$term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id );
254
-		$this->object_insert( $term, $taxonomy );
252
+	public function add_term($term_id, $tt_id, $taxonomy) {
253
+		$term = $this->wordpress->get_wordpress_object_data($taxonomy, $term_id);
254
+		$this->object_insert($term, $taxonomy);
255 255
 	}
256 256
 
257 257
 	/**
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	* @param string $term_id
261 261
 	* @param string $taxonomy
262 262
 	*/
263
-	public function edit_term( $term_id, $taxonomy ) {
264
-		$term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id );
265
-		$this->object_update( $term, $taxonomy );
263
+	public function edit_term($term_id, $taxonomy) {
264
+		$term = $this->wordpress->get_wordpress_object_data($taxonomy, $term_id);
265
+		$this->object_update($term, $taxonomy);
266 266
 	}
267 267
 
268 268
 	/**
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 	* @param string $taxonomy (slug)
274 274
 	* @param object $deleted_term
275 275
 	*/
276
-	public function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) {
276
+	public function delete_term($term, $tt_id, $taxonomy, $deleted_term) {
277 277
 		$deleted_term = (array) $deleted_term;
278 278
 		$type         = $deleted_term['taxonomy'];
279
-		$this->object_delete( $deleted_term, $type );
279
+		$this->object_delete($deleted_term, $type);
280 280
 	}
281 281
 
282 282
 	/**
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 	* @param int|string comment_approved
287 287
 	* @param array $commentdata
288 288
 	*/
289
-	public function add_comment( $comment_id, $comment_approved, $commentdata = array() ) {
290
-		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
291
-		$this->object_insert( $comment, 'comment' );
289
+	public function add_comment($comment_id, $comment_approved, $commentdata = array()) {
290
+		$comment = $this->wordpress->get_wordpress_object_data('comment', $comment_id);
291
+		$this->object_insert($comment, 'comment');
292 292
 	}
293 293
 
294 294
 	/**
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 	*
297 297
 	* @param string $comment_id
298 298
 	*/
299
-	public function edit_comment( $comment_id ) {
300
-		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
301
-		$this->object_update( $comment, 'comment' );
299
+	public function edit_comment($comment_id) {
300
+		$comment = $this->wordpress->get_wordpress_object_data('comment', $comment_id);
301
+		$this->object_update($comment, 'comment');
302 302
 	}
303 303
 
304 304
 	/**
@@ -306,33 +306,33 @@  discard block
 block discarded – undo
306 306
 	*
307 307
 	* @param string $comment_id
308 308
 	*/
309
-	public function delete_comment( $comment_id ) {
310
-		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
311
-		$this->object_delete( $comment, 'comment' );
309
+	public function delete_comment($comment_id) {
310
+		$comment = $this->wordpress->get_wordpress_object_data('comment', $comment_id);
311
+		$this->object_delete($comment, 'comment');
312 312
 	}
313 313
 
314 314
 	/**
315 315
 	* Insert a new object
316 316
 	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
317 317
 	*/
318
-	private function object_insert( $object, $type ) {
319
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_create );
318
+	private function object_insert($object, $type) {
319
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_create);
320 320
 	}
321 321
 
322 322
 	/**
323 323
 	* Update an existing object
324 324
 	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
325 325
 	*/
326
-	private function object_update( $object, $type ) {
327
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update );
326
+	private function object_update($object, $type) {
327
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_update);
328 328
 	}
329 329
 
330 330
 	/**
331 331
 	* Delete an existing object
332 332
 	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
333 333
 	*/
334
-	private function object_delete( $object, $type ) {
335
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_delete );
334
+	private function object_delete($object, $type) {
335
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_delete);
336 336
 	}
337 337
 
338 338
 	/**
@@ -349,50 +349,50 @@  discard block
 block discarded – undo
349 349
 	*   Are we calling this manually?
350 350
 	*
351 351
 	*/
352
-	private function salesforce_push_object_crud( $object_type, $object, $sf_sync_trigger, $manual = false ) {
352
+	private function salesforce_push_object_crud($object_type, $object, $sf_sync_trigger, $manual = false) {
353 353
 
354
-		$structure       = $this->wordpress->get_wordpress_table_structure( $object_type );
354
+		$structure       = $this->wordpress->get_wordpress_table_structure($object_type);
355 355
 		$object_id_field = $structure['id_field'];
356 356
 
357 357
 		// there is a WordPress object to push
358
-		if ( isset( $object[ $object_id_field ] ) ) {
359
-			$mapping_object = $this->mappings->load_by_wordpress( $object_type, $object[ $object_id_field ] );
358
+		if (isset($object[$object_id_field])) {
359
+			$mapping_object = $this->mappings->load_by_wordpress($object_type, $object[$object_id_field]);
360 360
 
361 361
 			// there is already a mapping object for this WordPress object
362
-			if ( isset( $mapping_object['id'] ) ) {
362
+			if (isset($mapping_object['id'])) {
363 363
 				$mapping_object_id_transient = $mapping_object['id'];
364 364
 			} else {
365 365
 				// there is not a mapping object for this WordPress object id yet
366 366
 				// check for that transient with the currently pulling id
367
-				$mapping_object_id_transient = (int) get_transient( 'salesforce_pulling_object_id' );
367
+				$mapping_object_id_transient = (int) get_transient('salesforce_pulling_object_id');
368 368
 			}
369 369
 
370
-			$salesforce_pulling = (int) get_transient( 'salesforce_pulling_' . $mapping_object_id_transient );
371
-			if ( 1 === $salesforce_pulling ) {
372
-				delete_transient( 'salesforce_pulling_' . $mapping_object_id_transient );
373
-				$pulling_id = get_transient( 'salesforce_pulling_object_id' );
374
-				if ( $pulling_id === $mapping_object_id_transient ) {
375
-					delete_transient( 'salesforce_pulling_object_id' );
370
+			$salesforce_pulling = (int) get_transient('salesforce_pulling_' . $mapping_object_id_transient);
371
+			if (1 === $salesforce_pulling) {
372
+				delete_transient('salesforce_pulling_' . $mapping_object_id_transient);
373
+				$pulling_id = get_transient('salesforce_pulling_object_id');
374
+				if ($pulling_id === $mapping_object_id_transient) {
375
+					delete_transient('salesforce_pulling_object_id');
376 376
 				}
377 377
 				return false;
378 378
 			}
379 379
 		} else {
380 380
 			// if we don't have a WordPress object id, we've got no business doing stuff in Salesforce
381 381
 			$status = 'error';
382
-			if ( isset( $this->logging ) ) {
382
+			if (isset($this->logging)) {
383 383
 				$logging = $this->logging;
384
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
385
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
384
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
385
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
386 386
 			}
387 387
 
388 388
 			// translators: placeholder is the name of the WordPress id field
389
-			$title = sprintf( esc_html__( 'Error: Salesforce Push: unable to process queue item because it has no WordPress %1$s.', 'object-sync-for-salesforce' ),
390
-				esc_attr( $object_id_field )
389
+			$title = sprintf(esc_html__('Error: Salesforce Push: unable to process queue item because it has no WordPress %1$s.', 'object-sync-for-salesforce'),
390
+				esc_attr($object_id_field)
391 391
 			);
392 392
 
393 393
 			$logging->setup(
394 394
 				$title,
395
-				print_r( $object, true ), // print this array because if this happens, something weird has happened and we want to log whatever we have
395
+				print_r($object, true), // print this array because if this happens, something weird has happened and we want to log whatever we have
396 396
 				$sf_sync_trigger,
397 397
 				0, // parent id goes here but we don't have one, so make it 0
398 398
 				$status
@@ -409,14 +409,14 @@  discard block
 block discarded – undo
409 409
 			)
410 410
 		);
411 411
 
412
-		foreach ( $sf_mappings as $mapping ) { // for each mapping of this object
412
+		foreach ($sf_mappings as $mapping) { // for each mapping of this object
413 413
 			$map_sync_triggers = $mapping['sync_triggers'];
414 414
 
415 415
 			// these are bit operators, so we leave out the strict
416
-			if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
416
+			if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
417 417
 
418 418
 				// hook to allow other plugins to prevent a push per-mapping.
419
-				$push_allowed = apply_filters( 'object_sync_for_salesforce_push_object_allowed', true, $object_type, $object, $sf_sync_trigger, $mapping );
419
+				$push_allowed = apply_filters('object_sync_for_salesforce_push_object_allowed', true, $object_type, $object, $sf_sync_trigger, $mapping);
420 420
 
421 421
 				// example to keep from pushing the user with id of 1
422 422
 				/*
@@ -429,18 +429,18 @@  discard block
 block discarded – undo
429 429
 				}
430 430
 				*/
431 431
 
432
-				if ( false === $push_allowed ) {
432
+				if (false === $push_allowed) {
433 433
 					continue;
434 434
 				}
435 435
 
436 436
 				// push drafts if the setting says so
437 437
 				// post status is draft, or post status is inherit and post type is not attachment
438
-				if ( ( ! isset( $mapping['push_drafts'] ) || '1' !== $mapping['push_drafts'] ) && isset( $object['post_status'] ) && ( 'draft' === $object['post_status'] || ( 'inherit' === $object['post_status'] && 'attachment' !== $object['post_type'] ) ) ) {
438
+				if (( ! isset($mapping['push_drafts']) || '1' !== $mapping['push_drafts']) && isset($object['post_status']) && ('draft' === $object['post_status'] || ('inherit' === $object['post_status'] && 'attachment' !== $object['post_type']))) {
439 439
 					// skip this object if it is a draft and the fieldmap settings told us to ignore it
440 440
 					continue;
441 441
 				}
442 442
 
443
-				if ( isset( $mapping['push_async'] ) && ( '1' === $mapping['push_async'] ) && false === $manual ) {
443
+				if (isset($mapping['push_async']) && ('1' === $mapping['push_async']) && false === $manual) {
444 444
 					// this item is async and we want to save it to the queue
445 445
 
446 446
 					// if we determine that the above does not perform well, worst case scenario is we could save $data to a custom table, and pass the id to the callback method.
@@ -454,18 +454,18 @@  discard block
 block discarded – undo
454 454
 					// add a queue action to push data to salesforce
455 455
 					// this means we don't need the frequency for this method anymore, i think
456 456
 					$this->queue->add(
457
-						$this->schedulable_classes[ $this->schedule_name ]['callback'],
457
+						$this->schedulable_classes[$this->schedule_name]['callback'],
458 458
 						array(
459 459
 							'object_type'     => $object_type,
460
-							'object'          => filter_var( $object[ $object_id_field ], FILTER_VALIDATE_INT ),
461
-							'mapping'         => filter_var( $mapping['id'], FILTER_VALIDATE_INT ),
460
+							'object'          => filter_var($object[$object_id_field], FILTER_VALIDATE_INT),
461
+							'mapping'         => filter_var($mapping['id'], FILTER_VALIDATE_INT),
462 462
 							'sf_sync_trigger' => $sf_sync_trigger,
463 463
 						),
464 464
 						$this->schedule_name
465 465
 					);
466 466
 				} else {
467 467
 					// this one is not async. do it immediately.
468
-					$push = $this->salesforce_push_sync_rest( $object_type, $object, $mapping, $sf_sync_trigger );
468
+					$push = $this->salesforce_push_sync_rest($object_type, $object, $mapping, $sf_sync_trigger);
469 469
 				} // End if().
470 470
 			} // End if(). if the trigger does not match our requirements, skip it
471 471
 		} // End foreach().
@@ -486,35 +486,35 @@  discard block
 block discarded – undo
486 486
 	* @return true or exit the method
487 487
 	*
488 488
 	*/
489
-	public function salesforce_push_sync_rest( $object_type, $object, $mapping, $sf_sync_trigger ) {
489
+	public function salesforce_push_sync_rest($object_type, $object, $mapping, $sf_sync_trigger) {
490 490
 
491
-		if ( is_int( $object ) ) {
491
+		if (is_int($object)) {
492 492
 			$object_id = $object;
493
-			$object    = $this->wordpress->get_wordpress_object_data( $object_type, $object_id );
493
+			$object    = $this->wordpress->get_wordpress_object_data($object_type, $object_id);
494 494
 		}
495 495
 
496
-		if ( is_int( $mapping ) ) {
496
+		if (is_int($mapping)) {
497 497
 			$mapping_id = $mapping;
498
-			$mapping    = $this->mappings->get_fieldmaps( $mapping_id );
498
+			$mapping    = $this->mappings->get_fieldmaps($mapping_id);
499 499
 		}
500 500
 
501 501
 		// If Salesforce is not authorized, don't do anything.
502 502
 		// it's unclear to me if we need to do something else here or if this is sufficient. This is all Drupal does.
503
-		if ( true !== $this->salesforce['is_authorized'] ) {
503
+		if (true !== $this->salesforce['is_authorized']) {
504 504
 			return;
505 505
 		}
506 506
 
507 507
 		$sfapi = $this->salesforce['sfapi'];
508 508
 
509 509
 		// we need to get the WordPress id here so we can check to see if the object already has a map
510
-		$structure = $this->wordpress->get_wordpress_table_structure( $object_type );
510
+		$structure = $this->wordpress->get_wordpress_table_structure($object_type);
511 511
 		$object_id = $structure['id_field'];
512 512
 
513 513
 		// this returns the row that maps the individual WordPress row to the individual Salesfoce row
514
-		$mapping_object = $this->mappings->load_by_wordpress( $object_type, $object[ "$object_id" ] );
514
+		$mapping_object = $this->mappings->load_by_wordpress($object_type, $object["$object_id"]);
515 515
 
516 516
 		// hook to allow other plugins to define or alter the mapping object
517
-		$mapping_object = apply_filters( 'object_sync_for_salesforce_push_mapping_object', $mapping_object, $object, $mapping );
517
+		$mapping_object = apply_filters('object_sync_for_salesforce_push_mapping_object', $mapping_object, $object, $mapping);
518 518
 
519 519
 		// we already have the data from WordPress at this point; we just need to work with it in Salesforce
520 520
 		$synced_object = array(
@@ -528,84 +528,84 @@  discard block
 block discarded – undo
528 528
 
529 529
 		// deleting mapped objects
530 530
 		// these are bit operators, so we leave out the strict
531
-		if ( $sf_sync_trigger == $this->mappings->sync_wordpress_delete ) {
532
-			if ( isset( $mapping_object['id'] ) ) {
531
+		if ($sf_sync_trigger == $this->mappings->sync_wordpress_delete) {
532
+			if (isset($mapping_object['id'])) {
533 533
 				$op = 'Delete';
534 534
 
535
-				$salesforce_check = $this->mappings->load_by_salesforce( $mapping_object['salesforce_id'] );
535
+				$salesforce_check = $this->mappings->load_by_salesforce($mapping_object['salesforce_id']);
536 536
 
537
-				if ( count( $salesforce_check ) === count( $salesforce_check, COUNT_RECURSIVE ) ) {
537
+				if (count($salesforce_check) === count($salesforce_check, COUNT_RECURSIVE)) {
538 538
 					try {
539
-						$result = $sfapi->object_delete( $mapping['salesforce_object'], $mapping_object['salesforce_id'] );
540
-					} catch ( Object_Sync_Sf_Exception $e ) {
539
+						$result = $sfapi->object_delete($mapping['salesforce_object'], $mapping_object['salesforce_id']);
540
+					} catch (Object_Sync_Sf_Exception $e) {
541 541
 						$status = 'error';
542 542
 						// create log entry for failed delete
543
-						if ( isset( $this->logging ) ) {
543
+						if (isset($this->logging)) {
544 544
 							$logging = $this->logging;
545
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
546
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
545
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
546
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
547 547
 						}
548 548
 
549 549
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
550
-						$title = sprintf( esc_html__( 'Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
551
-							esc_attr( $op ),
552
-							esc_attr( $mapping['salesforce_object'] ),
553
-							esc_attr( $mapping_object['salesforce_id'] ),
554
-							esc_attr( $mapping['wordpress_object'] ),
555
-							esc_attr( $object_id ),
556
-							esc_attr( $object[ "$object_id" ] )
550
+						$title = sprintf(esc_html__('Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
551
+							esc_attr($op),
552
+							esc_attr($mapping['salesforce_object']),
553
+							esc_attr($mapping_object['salesforce_id']),
554
+							esc_attr($mapping['wordpress_object']),
555
+							esc_attr($object_id),
556
+							esc_attr($object["$object_id"])
557 557
 						);
558 558
 
559 559
 						$logging->setup(
560 560
 							$title,
561 561
 							$e->getMessage(),
562 562
 							$sf_sync_trigger,
563
-							$object[ "$object_id" ],
563
+							$object["$object_id"],
564 564
 							$status
565 565
 						);
566 566
 
567 567
 						// hook for push fail
568
-						do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object, $object_id );
568
+						do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object, $object_id);
569 569
 
570 570
 					}
571 571
 
572
-					if ( ! isset( $e ) ) {
572
+					if ( ! isset($e)) {
573 573
 						// create log entry for successful delete if the result had no errors
574 574
 						$status = 'success';
575
-						if ( isset( $this->logging ) ) {
575
+						if (isset($this->logging)) {
576 576
 							$logging = $this->logging;
577
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
578
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
577
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
578
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
579 579
 						}
580 580
 
581 581
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
582
-						$title = sprintf( esc_html__( 'Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
583
-							esc_attr( $op ),
584
-							esc_attr( $mapping['salesforce_object'] ),
585
-							esc_attr( $mapping_object['salesforce_id'] ),
586
-							esc_attr( $mapping['wordpress_object'] ),
587
-							esc_attr( $object_id ),
588
-							esc_attr( $object[ "$object_id" ] )
582
+						$title = sprintf(esc_html__('Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
583
+							esc_attr($op),
584
+							esc_attr($mapping['salesforce_object']),
585
+							esc_attr($mapping_object['salesforce_id']),
586
+							esc_attr($mapping['wordpress_object']),
587
+							esc_attr($object_id),
588
+							esc_attr($object["$object_id"])
589 589
 						);
590 590
 
591 591
 						$logging->setup(
592 592
 							$title,
593 593
 							'',
594 594
 							$sf_sync_trigger,
595
-							$object[ "$object_id" ],
595
+							$object["$object_id"],
596 596
 							$status
597 597
 						);
598 598
 
599 599
 						// hook for push success
600
-						do_action( 'object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id );
600
+						do_action('object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id);
601 601
 					}
602 602
 				} else {
603 603
 					$more_ids = '<p>The Salesforce record was not deleted because there are multiple WordPress IDs that match this Salesforce ID. They are: ';
604 604
 					$i        = 0;
605
-					foreach ( $salesforce_check as $match ) {
605
+					foreach ($salesforce_check as $match) {
606 606
 						$i++;
607 607
 						$more_ids .= $match['wordpress_id'];
608
-						if ( count( $salesforce_check ) !== $i ) {
608
+						if (count($salesforce_check) !== $i) {
609 609
 							$more_ids .= ', ';
610 610
 						} else {
611 611
 							$more_ids .= '.</p>';
@@ -615,34 +615,34 @@  discard block
 block discarded – undo
615 615
 					$more_ids .= '<p>The map row between this WordPress object and the Salesforce object, as stored in the WordPress database, will be deleted, and this WordPress object has been deleted, but Salesforce will remain untouched.</p>';
616 616
 
617 617
 					$status = 'notice';
618
-					if ( isset( $this->logging ) ) {
618
+					if (isset($this->logging)) {
619 619
 						$logging = $this->logging;
620
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
621
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
620
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
621
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
622 622
 					}
623 623
 
624 624
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
625
-					$title = sprintf( esc_html__( 'Notice: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s did not delete the Salesforce item.)', 'object-sync-for-salesforce' ),
626
-						esc_attr( $op ),
627
-						esc_attr( $mapping['salesforce_object'] ),
628
-						esc_attr( $mapping_object['salesforce_id'] ),
629
-						esc_attr( $mapping['wordpress_object'] ),
630
-						esc_attr( $object_id ),
631
-						esc_attr( $object[ "$object_id" ] )
625
+					$title = sprintf(esc_html__('Notice: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s did not delete the Salesforce item.)', 'object-sync-for-salesforce'),
626
+						esc_attr($op),
627
+						esc_attr($mapping['salesforce_object']),
628
+						esc_attr($mapping_object['salesforce_id']),
629
+						esc_attr($mapping['wordpress_object']),
630
+						esc_attr($object_id),
631
+						esc_attr($object["$object_id"])
632 632
 					);
633 633
 
634 634
 					$logging->setup(
635 635
 						$title,
636 636
 						$more_ids,
637 637
 						$sf_sync_trigger,
638
-						$object[ "$object_id" ],
638
+						$object["$object_id"],
639 639
 						$status
640 640
 					);
641 641
 				} // End if().
642 642
 
643 643
 				// delete the map row from WordPress after the Salesforce row has been deleted
644 644
 				// we delete the map row even if the Salesforce delete failed, because the WordPress object is gone
645
-				$this->mappings->delete_object_map( $mapping_object['id'] );
645
+				$this->mappings->delete_object_map($mapping_object['id']);
646 646
 
647 647
 			} // End if(). there is no map row
648 648
 
@@ -650,52 +650,52 @@  discard block
 block discarded – undo
650 650
 		} // End if().
651 651
 
652 652
 		// are these objects already connected in WordPress?
653
-		if ( isset( $mapping_object['id'] ) ) {
653
+		if (isset($mapping_object['id'])) {
654 654
 			$is_new = false;
655 655
 		} else {
656 656
 			$is_new = true;
657 657
 		}
658 658
 
659 659
 		// map the WordPress values to salesforce fields
660
-		$params = $this->mappings->map_params( $mapping, $object, $sf_sync_trigger, false, $is_new );
660
+		$params = $this->mappings->map_params($mapping, $object, $sf_sync_trigger, false, $is_new);
661 661
 
662 662
 		// hook to allow other plugins to modify the $params array
663 663
 		// use hook to map fields between the WordPress and Salesforce objects
664 664
 		// returns $params.
665
-		$params = apply_filters( 'object_sync_for_salesforce_push_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new );
665
+		$params = apply_filters('object_sync_for_salesforce_push_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new);
666 666
 
667 667
 		// if we don't get any params, there are no fields that should be sent to Salesforce
668
-		if ( empty( $params ) ) {
668
+		if (empty($params)) {
669 669
 			return;
670 670
 		}
671 671
 
672 672
 		// if there is a prematch WordPress field - ie email - on the fieldmap object
673
-		if ( isset( $params['prematch'] ) && is_array( $params['prematch'] ) ) {
673
+		if (isset($params['prematch']) && is_array($params['prematch'])) {
674 674
 			$prematch_field_wordpress  = $params['prematch']['wordpress_field'];
675 675
 			$prematch_field_salesforce = $params['prematch']['salesforce_field'];
676 676
 			$prematch_value            = $params['prematch']['value'];
677
-			unset( $params['prematch'] );
677
+			unset($params['prematch']);
678 678
 		}
679 679
 
680 680
 		// if there is an external key field in Salesforce - ie mailchimp user id - on the fieldmap object
681
-		if ( isset( $params['key'] ) && is_array( $params['key'] ) ) {
681
+		if (isset($params['key']) && is_array($params['key'])) {
682 682
 			$key_field_wordpress  = $params['key']['wordpress_field'];
683 683
 			$key_field_salesforce = $params['key']['salesforce_field'];
684 684
 			$key_value            = $params['key']['value'];
685
-			unset( $params['key'] );
685
+			unset($params['key']);
686 686
 		}
687 687
 
688 688
 		$frequencies = $this->queue->get_frequencies();
689
-		$seconds     = reset( $frequencies )['frequency'] + 60;
689
+		$seconds     = reset($frequencies)['frequency'] + 60;
690 690
 
691
-		if ( true === $is_new ) {
691
+		if (true === $is_new) {
692 692
 
693 693
 			// right here we should set the pushing transient
694 694
 			// this means we have to create the mapping object here as well, and update it with the correct IDs after successful response
695 695
 			// create the mapping object between the rows
696
-			$mapping_object_id = $this->create_object_map( $object, $object_id, $this->mappings->generate_temporary_id( 'push' ), $mapping, true );
697
-			set_transient( 'salesforce_pushing_' . $mapping_object_id, 1, $seconds );
698
-			set_transient( 'salesforce_pushing_object_id', $mapping_object_id );
696
+			$mapping_object_id = $this->create_object_map($object, $object_id, $this->mappings->generate_temporary_id('push'), $mapping, true);
697
+			set_transient('salesforce_pushing_' . $mapping_object_id, 1, $seconds);
698
+			set_transient('salesforce_pushing_object_id', $mapping_object_id);
699 699
 			$mapping_object = $this->mappings->get_object_maps(
700 700
 				array(
701 701
 					'id' => $mapping_object_id,
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 
705 705
 			// setup SF record type. CampaignMember objects get their Campaign's type
706 706
 			// i am still a bit confused about this
707
-			if ( $mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty( $params['RecordTypeId'] ) && ( 'CampaignMember' !== $mapping['salesforce_object'] ) ) {
707
+			if ($mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty($params['RecordTypeId']) && ('CampaignMember' !== $mapping['salesforce_object'])) {
708 708
 				$params['RecordTypeId'] = $mapping['salesforce_record_type_default'];
709 709
 			}
710 710
 
@@ -716,61 +716,61 @@  discard block
 block discarded – undo
716 716
 				// returns a $salesforce_id.
717 717
 				// it should keep NULL if there is no match
718 718
 				// the function that calls this hook needs to check the mapping to make sure the WordPress object is the right type
719
-				$salesforce_id = apply_filters( 'object_sync_for_salesforce_find_sf_object_match', null, $object, $mapping, 'push' );
719
+				$salesforce_id = apply_filters('object_sync_for_salesforce_find_sf_object_match', null, $object, $mapping, 'push');
720 720
 
721 721
 				// hook to allow other plugins to do something right before Salesforce data is saved
722 722
 				// ex: run WordPress methods on an object if it exists, or do something in preparation for it if it doesn't
723
-				do_action( 'object_sync_for_salesforce_pre_push', $salesforce_id, $mapping, $object, $object_id, $params );
723
+				do_action('object_sync_for_salesforce_pre_push', $salesforce_id, $mapping, $object, $object_id, $params);
724 724
 
725 725
 				// hook to allow other plugins to change params on update actions only
726 726
 				// use hook to map fields between the WordPress and Salesforce objects
727 727
 				// returns $params.
728
-				$params = apply_filters( 'object_sync_for_salesforce_push_update_params_modify', $params, $salesforce_id, $mapping, $object );
728
+				$params = apply_filters('object_sync_for_salesforce_push_update_params_modify', $params, $salesforce_id, $mapping, $object);
729 729
 
730
-				if ( isset( $prematch_field_wordpress ) || isset( $key_field_wordpress ) || null !== $salesforce_id ) {
730
+				if (isset($prematch_field_wordpress) || isset($key_field_wordpress) || null !== $salesforce_id) {
731 731
 
732 732
 					// if either prematch criteria exists, make the values queryable
733 733
 
734
-					if ( isset( $prematch_field_wordpress ) ) {
734
+					if (isset($prematch_field_wordpress)) {
735 735
 						// a prematch has been specified, attempt an upsert().
736 736
 						// prematch values with punctuation need to be escaped
737
-						$encoded_prematch_value = rawurlencode( $prematch_value );
737
+						$encoded_prematch_value = rawurlencode($prematch_value);
738 738
 						// for at least 'email' fields, periods also need to be escaped:
739 739
 						// https://developer.salesforce.com/forums?id=906F000000099xPIAQ
740
-						$encoded_prematch_value = str_replace( '.', '%2E', $encoded_prematch_value );
740
+						$encoded_prematch_value = str_replace('.', '%2E', $encoded_prematch_value);
741 741
 					}
742 742
 
743
-					if ( isset( $key_field_wordpress ) ) {
743
+					if (isset($key_field_wordpress)) {
744 744
 						// an external key has been specified, attempt an upsert().
745 745
 						// external key values with punctuation need to be escaped
746
-						$encoded_key_value = rawurlencode( $key_value );
746
+						$encoded_key_value = rawurlencode($key_value);
747 747
 						// for at least 'email' fields, periods also need to be escaped:
748 748
 						// https://developer.salesforce.com/forums?id=906F000000099xPIAQ
749
-						$encoded_key_value = str_replace( '.', '%2E', $encoded_key_value );
749
+						$encoded_key_value = str_replace('.', '%2E', $encoded_key_value);
750 750
 					}
751 751
 
752
-					if ( isset( $prematch_field_wordpress ) ) {
752
+					if (isset($prematch_field_wordpress)) {
753 753
 						$upsert_key   = $prematch_field_salesforce;
754 754
 						$upsert_value = $encoded_prematch_value;
755
-					} elseif ( isset( $key_field_wordpress ) ) {
755
+					} elseif (isset($key_field_wordpress)) {
756 756
 						$upsert_key   = $key_field_salesforce;
757 757
 						$upsert_value = $encoded_key_value;
758 758
 					}
759 759
 
760
-					if ( null !== $salesforce_id ) {
760
+					if (null !== $salesforce_id) {
761 761
 						$upsert_key   = 'Id';
762 762
 						$upsert_value = $salesforce_id;
763 763
 					}
764 764
 
765 765
 					$op = 'Upsert';
766 766
 
767
-					$result = $sfapi->object_upsert( $mapping['salesforce_object'], $upsert_key, $upsert_value, $params );
767
+					$result = $sfapi->object_upsert($mapping['salesforce_object'], $upsert_key, $upsert_value, $params);
768 768
 
769 769
 					// Handle upsert responses.
770
-					switch ( $sfapi->response['code'] ) {
770
+					switch ($sfapi->response['code']) {
771 771
 						// On Upsert:update retrieved object.
772 772
 						case '204':
773
-							$sf_object             = $sfapi->object_readby_external_id( $mapping['salesforce_object'], $upsert_key, $upsert_value );
773
+							$sf_object             = $sfapi->object_readby_external_id($mapping['salesforce_object'], $upsert_key, $upsert_value);
774 774
 							$salesforce_data['id'] = $sf_object['data']['Id'];
775 775
 							break;
776 776
 						// Handle duplicate records.
@@ -781,43 +781,43 @@  discard block
 block discarded – undo
781 781
 				} else {
782 782
 					// No key or prematch field exists on this field map object, create a new object in Salesforce.
783 783
 					$op     = 'Create';
784
-					$result = $sfapi->object_create( $mapping['salesforce_object'], $params );
784
+					$result = $sfapi->object_create($mapping['salesforce_object'], $params);
785 785
 				} // End if().
786
-			} catch ( Object_Sync_Sf_Exception $e ) {
786
+			} catch (Object_Sync_Sf_Exception $e) {
787 787
 				// create log entry for failed create or upsert
788 788
 				$status = 'error';
789 789
 
790
-				if ( isset( $this->logging ) ) {
790
+				if (isset($this->logging)) {
791 791
 					$logging = $this->logging;
792
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
793
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
792
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
793
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
794 794
 				}
795 795
 
796 796
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value if there is one, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
797
-				$title = sprintf( esc_html__( 'Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
798
-					esc_attr( $op ),
799
-					esc_attr( $mapping['salesforce_object'] ),
800
-					isset( $salesforce_id ) ? ' ' . esc_attr( $salesforce_id ) : '',
801
-					esc_attr( $mapping['wordpress_object'] ),
802
-					esc_attr( $object_id ),
803
-					esc_attr( $object[ "$object_id" ] )
797
+				$title = sprintf(esc_html__('Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
798
+					esc_attr($op),
799
+					esc_attr($mapping['salesforce_object']),
800
+					isset($salesforce_id) ? ' ' . esc_attr($salesforce_id) : '',
801
+					esc_attr($mapping['wordpress_object']),
802
+					esc_attr($object_id),
803
+					esc_attr($object["$object_id"])
804 804
 				);
805 805
 
806 806
 				$logging->setup(
807 807
 					$title,
808 808
 					$e->getMessage(),
809 809
 					$sf_sync_trigger,
810
-					$object[ "$object_id" ],
810
+					$object["$object_id"],
811 811
 					$status
812 812
 				);
813 813
 
814 814
 				// hook for push fail
815
-				do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object );
815
+				do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object);
816 816
 
817 817
 				return;
818 818
 			} // End try().
819 819
 
820
-			if ( ! isset( $salesforce_data ) ) {
820
+			if ( ! isset($salesforce_data)) {
821 821
 				// if we didn't set $salesforce_data already, set it now to api call result
822 822
 				$salesforce_data = $result['data'];
823 823
 			}
@@ -826,78 +826,78 @@  discard block
 block discarded – undo
826 826
 			// this means the object has already been created/updated in Salesforce
827 827
 			// this is not redundant because this is where it creates the object mapping rows in WordPress if the object does not already have one (we are still inside $is_new === TRUE here)
828 828
 
829
-			if ( empty( $result['errorCode'] ) ) {
829
+			if (empty($result['errorCode'])) {
830 830
 				$salesforce_id = $salesforce_data['id'];
831 831
 				$status        = 'success';
832 832
 
833
-				if ( isset( $this->logging ) ) {
833
+				if (isset($this->logging)) {
834 834
 					$logging = $this->logging;
835
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
836
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
835
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
836
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
837 837
 				}
838 838
 
839 839
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
840
-				$title = sprintf( esc_html__( 'Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
841
-					esc_attr( $op ),
842
-					esc_attr( $mapping['salesforce_object'] ),
843
-					esc_attr( $salesforce_id ),
844
-					esc_attr( $mapping['wordpress_object'] ),
845
-					esc_attr( $object_id ),
846
-					esc_attr( $object[ "$object_id" ] )
840
+				$title = sprintf(esc_html__('Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
841
+					esc_attr($op),
842
+					esc_attr($mapping['salesforce_object']),
843
+					esc_attr($salesforce_id),
844
+					esc_attr($mapping['wordpress_object']),
845
+					esc_attr($object_id),
846
+					esc_attr($object["$object_id"])
847 847
 				);
848 848
 
849 849
 				$logging->setup(
850 850
 					$title,
851 851
 					'',
852 852
 					$sf_sync_trigger,
853
-					$object[ "$object_id" ],
853
+					$object["$object_id"],
854 854
 					$status
855 855
 				);
856 856
 
857 857
 				// update that mapping object
858 858
 				$mapping_object['salesforce_id']     = $salesforce_id;
859
-				$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
860
-				$mapping_object                      = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
859
+				$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
860
+				$mapping_object                      = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
861 861
 
862 862
 				// hook for push success
863
-				do_action( 'object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id );
863
+				do_action('object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id);
864 864
 			} else {
865 865
 
866 866
 				// create log entry for failed create or upsert
867 867
 				// this is part of the drupal module but i am failing to understand when it would ever fire, since the catch should catch the errors
868 868
 				// if we see this in the log entries, we can understand what it does, but probably not until then
869 869
 				$status = 'error';
870
-				if ( isset( $this->logging ) ) {
870
+				if (isset($this->logging)) {
871 871
 					$logging = $this->logging;
872
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
873
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
872
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
873
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
874 874
 				}
875 875
 
876 876
 				// translators: placeholders are: 1) error code the Salesforce API returned, 2) what operation is happening, 3) the name of the WordPress object type, 4) the WordPress id field name, 5) the WordPress object id value
877
-				$title = sprintf( esc_html__( '%1$s error syncing: %2$s to Salesforce (WordPress %3$s with %4$s of %5$s)', 'object-sync-for-salesforce' ),
878
-					absint( $salesforce_data['errorCode'] ),
879
-					esc_attr( $op ),
880
-					esc_attr( $mapping['wordpress_object'] ),
881
-					esc_attr( $object_id ),
882
-					esc_attr( $object[ "$object_id" ] )
877
+				$title = sprintf(esc_html__('%1$s error syncing: %2$s to Salesforce (WordPress %3$s with %4$s of %5$s)', 'object-sync-for-salesforce'),
878
+					absint($salesforce_data['errorCode']),
879
+					esc_attr($op),
880
+					esc_attr($mapping['wordpress_object']),
881
+					esc_attr($object_id),
882
+					esc_attr($object["$object_id"])
883 883
 				);
884 884
 
885 885
 				// translators: placeholders are 1) the name of the Salesforce object type, 2) the error message returned from the Salesforce APIs
886
-				$body = sprintf( '<p>' . esc_html__( 'Object: %1$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: %2$s', 'object-sync-for-salesforce' ) . '</p>',
887
-					esc_attr( $mapping['salesforce_object'] ),
888
-					esc_html( $salesforce_data['message'] )
886
+				$body = sprintf('<p>' . esc_html__('Object: %1$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: %2$s', 'object-sync-for-salesforce') . '</p>',
887
+					esc_attr($mapping['salesforce_object']),
888
+					esc_html($salesforce_data['message'])
889 889
 				);
890 890
 
891 891
 				$logging->setup(
892 892
 					$title,
893 893
 					$body,
894 894
 					$sf_sync_trigger,
895
-					$object[ "$object_id" ],
895
+					$object["$object_id"],
896 896
 					$status
897 897
 				);
898 898
 
899 899
 				// hook for push fail
900
-				do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object );
900
+				do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object);
901 901
 
902 902
 				return;
903 903
 			} // End if().
@@ -905,41 +905,41 @@  discard block
 block discarded – undo
905 905
 			// $is_new is false here; we are updating an already mapped object
906 906
 
907 907
 			// right here we should set the pushing transient
908
-			set_transient( 'salesforce_pushing_' . $mapping_object['id'], 1, $seconds );
909
-			set_transient( 'salesforce_pushing_object_id', $mapping_object['id'] );
908
+			set_transient('salesforce_pushing_' . $mapping_object['id'], 1, $seconds);
909
+			set_transient('salesforce_pushing_object_id', $mapping_object['id']);
910 910
 
911 911
 			// there is an existing object link
912 912
 			// if the last sync is greater than the last time this object was updated, skip it
913 913
 			// this keeps us from doing redundant syncs
914
-			$mapping_object['object_updated'] = current_time( 'mysql' );
915
-			if ( $mapping_object['last_sync'] > $mapping_object['object_updated'] ) {
914
+			$mapping_object['object_updated'] = current_time('mysql');
915
+			if ($mapping_object['last_sync'] > $mapping_object['object_updated']) {
916 916
 				$status = 'notice';
917
-				if ( isset( $this->logging ) ) {
917
+				if (isset($this->logging)) {
918 918
 					$logging = $this->logging;
919
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
920
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
919
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
920
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
921 921
 				}
922 922
 
923 923
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the Salesforce Id value
924
-				$title = sprintf( esc_html__( 'Notice: %1$s: Did not sync WordPress %2$s with %3$s of %4$s with Salesforce Id %5$s because the last sync timestamp was greater than the object updated timestamp.', 'object-sync-for-salesforce' ),
925
-					esc_attr( $op ),
926
-					esc_attr( $mapping['wordpress_object'] ),
927
-					esc_attr( $object_id ),
928
-					esc_attr( $object[ "$object_id" ] ),
929
-					esc_attr( $mapping_object['salesforce_id'] )
924
+				$title = sprintf(esc_html__('Notice: %1$s: Did not sync WordPress %2$s with %3$s of %4$s with Salesforce Id %5$s because the last sync timestamp was greater than the object updated timestamp.', 'object-sync-for-salesforce'),
925
+					esc_attr($op),
926
+					esc_attr($mapping['wordpress_object']),
927
+					esc_attr($object_id),
928
+					esc_attr($object["$object_id"]),
929
+					esc_attr($mapping_object['salesforce_id'])
930 930
 				);
931 931
 
932 932
 				// translators: placeholders are 1) when a sync on this mapping last occured, 2) when the object was last updated
933
-				$body = sprintf( '<p>' . esc_html__( 'Last sync time: %1$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Object updated time: %2$s', 'object-sync-for-salesforce' ) . '</p>',
934
-					esc_attr( $mapping_object['last_sync'] ),
935
-					esc_html( $mapping_object['object_updated'] )
933
+				$body = sprintf('<p>' . esc_html__('Last sync time: %1$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Object updated time: %2$s', 'object-sync-for-salesforce') . '</p>',
934
+					esc_attr($mapping_object['last_sync']),
935
+					esc_html($mapping_object['object_updated'])
936 936
 				);
937 937
 
938 938
 				$logging->setup(
939 939
 					$title,
940 940
 					$body,
941 941
 					$sf_sync_trigger,
942
-					$object[ "$object_id" ],
942
+					$object["$object_id"],
943 943
 					$status
944 944
 				);
945 945
 				return;
@@ -950,71 +950,71 @@  discard block
 block discarded – undo
950 950
 
951 951
 				// hook to allow other plugins to do something right before Salesforce data is saved
952 952
 				// ex: run WordPress methods on an object if it exists, or do something in preparation for it if it doesn't
953
-				do_action( 'object_sync_for_salesforce_pre_push', $mapping_object['salesforce_id'], $mapping, $object, $object_id, $params );
953
+				do_action('object_sync_for_salesforce_pre_push', $mapping_object['salesforce_id'], $mapping, $object, $object_id, $params);
954 954
 
955 955
 				// hook to allow other plugins to change params on update actions only
956 956
 				// use hook to map fields between the WordPress and Salesforce objects
957 957
 				// returns $params.
958
-				$params = apply_filters( 'object_sync_for_salesforce_push_update_params_modify', $params, $mapping_object['salesforce_id'], $mapping, $object );
958
+				$params = apply_filters('object_sync_for_salesforce_push_update_params_modify', $params, $mapping_object['salesforce_id'], $mapping, $object);
959 959
 
960 960
 				$op     = 'Update';
961
-				$result = $sfapi->object_update( $mapping['salesforce_object'], $mapping_object['salesforce_id'], $params );
961
+				$result = $sfapi->object_update($mapping['salesforce_object'], $mapping_object['salesforce_id'], $params);
962 962
 
963 963
 				$mapping_object['last_sync_status']  = $this->mappings->status_success;
964
-				$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
964
+				$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
965 965
 
966 966
 				$status = 'success';
967
-				if ( isset( $this->logging ) ) {
967
+				if (isset($this->logging)) {
968 968
 					$logging = $this->logging;
969
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
970
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
969
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
970
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
971 971
 				}
972 972
 
973 973
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
974
-				$title = sprintf( esc_html__( 'Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
975
-					esc_attr( $op ),
976
-					esc_attr( $mapping['salesforce_object'] ),
977
-					esc_attr( $mapping_object['salesforce_id'] ),
978
-					esc_attr( $mapping['wordpress_object'] ),
979
-					esc_attr( $object_id ),
980
-					esc_attr( $object[ "$object_id" ] )
974
+				$title = sprintf(esc_html__('Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
975
+					esc_attr($op),
976
+					esc_attr($mapping['salesforce_object']),
977
+					esc_attr($mapping_object['salesforce_id']),
978
+					esc_attr($mapping['wordpress_object']),
979
+					esc_attr($object_id),
980
+					esc_attr($object["$object_id"])
981 981
 				);
982 982
 
983 983
 				$logging->setup(
984 984
 					$title,
985 985
 					'',
986 986
 					$sf_sync_trigger,
987
-					$object[ "$object_id" ],
987
+					$object["$object_id"],
988 988
 					$status
989 989
 				);
990 990
 
991 991
 				// hook for push success
992
-				do_action( 'object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id );
992
+				do_action('object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id);
993 993
 
994
-			} catch ( Object_Sync_Sf_Exception $e ) {
994
+			} catch (Object_Sync_Sf_Exception $e) {
995 995
 				// create log entry for failed update
996 996
 				$status = 'error';
997
-				if ( isset( $this->logging ) ) {
997
+				if (isset($this->logging)) {
998 998
 					$logging = $this->logging;
999
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1000
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
999
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
1000
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1001 1001
 				}
1002 1002
 
1003 1003
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
1004
-				$title = sprintf( esc_html__( 'Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
1005
-					esc_attr( $op ),
1006
-					esc_attr( $mapping['salesforce_object'] ),
1007
-					esc_attr( $mapping_object['salesforce_id'] ),
1008
-					esc_attr( $mapping['wordpress_object'] ),
1009
-					esc_attr( $object_id ),
1010
-					esc_attr( $object[ "$object_id" ] )
1004
+				$title = sprintf(esc_html__('Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
1005
+					esc_attr($op),
1006
+					esc_attr($mapping['salesforce_object']),
1007
+					esc_attr($mapping_object['salesforce_id']),
1008
+					esc_attr($mapping['wordpress_object']),
1009
+					esc_attr($object_id),
1010
+					esc_attr($object["$object_id"])
1011 1011
 				);
1012 1012
 
1013 1013
 				$logging->setup(
1014 1014
 					$title,
1015 1015
 					$e->getMessage(),
1016 1016
 					$sf_sync_trigger,
1017
-					$object[ "$object_id" ],
1017
+					$object["$object_id"],
1018 1018
 					$status
1019 1019
 				);
1020 1020
 
@@ -1022,16 +1022,16 @@  discard block
 block discarded – undo
1022 1022
 				$mapping_object['last_sync_message'] = $e->getMessage();
1023 1023
 
1024 1024
 				// hook for push fail
1025
-				do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object );
1025
+				do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object);
1026 1026
 
1027 1027
 			} // End try().
1028 1028
 
1029 1029
 			// tell the mapping object - whether it is new or already existed - how we just used it
1030 1030
 			$mapping_object['last_sync_action'] = 'push';
1031
-			$mapping_object['last_sync']        = current_time( 'mysql' );
1031
+			$mapping_object['last_sync']        = current_time('mysql');
1032 1032
 
1033 1033
 			// update that mapping object
1034
-			$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1034
+			$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1035 1035
 
1036 1036
 		} // End if(). this is the end of the if is_new stuff
1037 1037
 
@@ -1053,9 +1053,9 @@  discard block
 block discarded – undo
1053 1053
 	*   This is the database row for the map object
1054 1054
 	*
1055 1055
 	*/
1056
-	private function create_object_map( $wordpress_object, $id_field_name, $salesforce_id, $field_mapping, $pending = false ) {
1056
+	private function create_object_map($wordpress_object, $id_field_name, $salesforce_id, $field_mapping, $pending = false) {
1057 1057
 
1058
-		if ( true === $pending ) {
1058
+		if (true === $pending) {
1059 1059
 			$action = 'pending';
1060 1060
 		} else {
1061 1061
 			$action = 'created';
@@ -1064,15 +1064,15 @@  discard block
 block discarded – undo
1064 1064
 		// Create object map and save it
1065 1065
 		$mapping_object = $this->mappings->create_object_map(
1066 1066
 			array(
1067
-				'wordpress_id'      => $wordpress_object[ $id_field_name ], // wordpress unique id
1067
+				'wordpress_id'      => $wordpress_object[$id_field_name], // wordpress unique id
1068 1068
 				'salesforce_id'     => $salesforce_id, // salesforce unique id. we don't care what kind of object it is at this point
1069 1069
 				'wordpress_object'  => $field_mapping['wordpress_object'], // keep track of what kind of wp object this is
1070
-				'last_sync'         => current_time( 'mysql' ),
1070
+				'last_sync'         => current_time('mysql'),
1071 1071
 				'last_sync_action'  => 'push',
1072 1072
 				'last_sync_status'  => $this->mappings->status_success,
1073 1073
 				// translators: placeholder is for the action that occurred on the mapping object (pending or created)
1074
-				'last_sync_message' => sprintf( esc_html__( 'Mapping object %1$s via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1075
-					esc_attr( $action )
1074
+				'last_sync_message' => sprintf(esc_html__('Mapping object %1$s via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1075
+					esc_attr($action)
1076 1076
 				),
1077 1077
 				'action'            => $action,
1078 1078
 			)
Please login to merge, or discard this patch.
object-sync-for-salesforce.php 1 patch
Spacing   +69 added lines, -69 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,25 +167,25 @@  discard block
 block discarded – undo
167 167
 		 * }
168 168
 		*/
169 169
 
170
-		$this->load = $this->load( $this->wpdb, $this->version, $this->slug );
170
+		$this->load = $this->load($this->wpdb, $this->version, $this->slug);
171 171
 
172
-		$this->queue = $this->queue( $this->wpdb, $this->version, $this->slug, $this->schedulable_classes );
172
+		$this->queue = $this->queue($this->wpdb, $this->version, $this->slug, $this->schedulable_classes);
173 173
 
174
-		$this->activated = $this->activate( $this->wpdb, $this->version, $this->slug );
175
-		$this->deactivate( $this->wpdb, $this->version, $this->slug, $this->schedulable_classes );
174
+		$this->activated = $this->activate($this->wpdb, $this->version, $this->slug);
175
+		$this->deactivate($this->wpdb, $this->version, $this->slug, $this->schedulable_classes);
176 176
 
177
-		$this->logging = $this->logging( $this->wpdb, $this->version );
177
+		$this->logging = $this->logging($this->wpdb, $this->version);
178 178
 
179
-		$this->mappings = $this->mappings( $this->wpdb, $this->version, $this->slug, $this->logging );
179
+		$this->mappings = $this->mappings($this->wpdb, $this->version, $this->slug, $this->logging);
180 180
 
181
-		$this->wordpress  = $this->wordpress( $this->wpdb, $this->version, $this->slug, $this->mappings, $this->logging );
181
+		$this->wordpress  = $this->wordpress($this->wpdb, $this->version, $this->slug, $this->mappings, $this->logging);
182 182
 		$this->salesforce = $this->salesforce_get_api();
183 183
 
184
-		$this->push = $this->push( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue );
184
+		$this->push = $this->push($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue);
185 185
 
186
-		$this->pull = $this->pull( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue );
186
+		$this->pull = $this->pull($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue);
187 187
 
188
-		$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, $this->queue );
188
+		$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, $this->queue);
189 189
 
190 190
 	}
191 191
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param string $slug
198 198
 	 *
199 199
 	 */
200
-	private function load( $wpdb, $version, $slug ) {
201
-		require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
200
+	private function load($wpdb, $version, $slug) {
201
+		require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';
202 202
 	}
203 203
 
204 204
 	/**
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 * @param array $schedulable_classes
211 211
 	 * @return Object_Sync_Sf_Queue
212 212
 	 */
213
-	public function queue( $wpdb, $version, $slug, $schedulable_classes ) {
214
-		require_once plugin_dir_path( __FILE__ ) . 'classes/class-object-sync-sf-queue.php';
215
-		$queue = new Object_Sync_Sf_Queue( $wpdb, $version, $slug, $schedulable_classes );
213
+	public function queue($wpdb, $version, $slug, $schedulable_classes) {
214
+		require_once plugin_dir_path(__FILE__) . 'classes/class-object-sync-sf-queue.php';
215
+		$queue = new Object_Sync_Sf_Queue($wpdb, $version, $slug, $schedulable_classes);
216 216
 		return $queue;
217 217
 	}
218 218
 
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 	 * @return object
227 227
 	 *   Instance of Object_Sync_Sf_Logging
228 228
 	 */
229
-	private function logging( $wpdb, $version ) {
230
-		require_once plugin_dir_path( __FILE__ ) . 'classes/logging.php';
231
-		$logging = new Object_Sync_Sf_Logging( $wpdb, $version );
229
+	private function logging($wpdb, $version) {
230
+		require_once plugin_dir_path(__FILE__) . 'classes/logging.php';
231
+		$logging = new Object_Sync_Sf_Logging($wpdb, $version);
232 232
 		return $logging;
233 233
 	}
234 234
 
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 	 * @return object
244 244
 	 *   Instance of Object_Sync_Sf_Mapping
245 245
 	 */
246
-	private function mappings( $wpdb, $version, $slug, $logging ) {
247
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_mapping.php' );
248
-		$mappings = new Object_Sync_Sf_Mapping( $wpdb, $version, $slug, $logging );
246
+	private function mappings($wpdb, $version, $slug, $logging) {
247
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce_mapping.php');
248
+		$mappings = new Object_Sync_Sf_Mapping($wpdb, $version, $slug, $logging);
249 249
 		return $mappings;
250 250
 	}
251 251
 
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 	* @return object
262 262
 	*   Instance of Object_Sync_Sf_WordPress
263 263
 	*/
264
-	private function wordpress( $wpdb, $version, $slug, $mappings, $logging ) {
265
-		require_once plugin_dir_path( __FILE__ ) . 'classes/wordpress.php';
266
-		$wordpress = new Object_Sync_Sf_WordPress( $wpdb, $version, $slug, $mappings, $logging );
264
+	private function wordpress($wpdb, $version, $slug, $mappings, $logging) {
265
+		require_once plugin_dir_path(__FILE__) . 'classes/wordpress.php';
266
+		$wordpress = new Object_Sync_Sf_WordPress($wpdb, $version, $slug, $mappings, $logging);
267 267
 		return $wordpress;
268 268
 	}
269 269
 
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
 	*   The sfapi object if it is authenticated (empty, otherwise)
277 277
 	*/
278 278
 	public function salesforce_get_api() {
279
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce.php' );
280
-		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
279
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce.php');
280
+		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
281 281
 		$consumer_key        = $this->login_credentials['consumer_key'];
282 282
 		$consumer_secret     = $this->login_credentials['consumer_secret'];
283 283
 		$login_url           = $this->login_credentials['login_url'];
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 		$schedulable_classes = $this->schedulable_classes;
292 292
 		$is_authorized       = false;
293 293
 		$sfapi               = '';
294
-		if ( $consumer_key && $consumer_secret ) {
295
-			$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 );
296
-			if ( $sfapi->is_authorized() === true ) {
294
+		if ($consumer_key && $consumer_secret) {
295
+			$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);
296
+			if ($sfapi->is_authorized() === true) {
297 297
 				$is_authorized = true;
298 298
 			}
299 299
 		}
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
 	 * @return object
314 314
 	 *   Instance of Object_Sync_Sf_Activate
315 315
 	 */
316
-	private function activate( $wpdb, $version, $slug ) {
317
-		require_once plugin_dir_path( __FILE__ ) . 'classes/activate.php';
318
-		$activate = new Object_Sync_Sf_Activate( $wpdb, $version, $slug );
316
+	private function activate($wpdb, $version, $slug) {
317
+		require_once plugin_dir_path(__FILE__) . 'classes/activate.php';
318
+		$activate = new Object_Sync_Sf_Activate($wpdb, $version, $slug);
319 319
 		return $activate;
320 320
 	}
321 321
 
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 	 * @return object
331 331
 	 *   Instance of Object_Sync_Sf_Deactivate
332 332
 	 */
333
-	private function deactivate( $wpdb, $version, $slug, $schedulable_classes ) {
334
-		require_once plugin_dir_path( __FILE__ ) . 'classes/deactivate.php';
335
-		$deactivate = new Object_Sync_Sf_Deactivate( $wpdb, $version, $slug, $schedulable_classes );
333
+	private function deactivate($wpdb, $version, $slug, $schedulable_classes) {
334
+		require_once plugin_dir_path(__FILE__) . 'classes/deactivate.php';
335
+		$deactivate = new Object_Sync_Sf_Deactivate($wpdb, $version, $slug, $schedulable_classes);
336 336
 	}
337 337
 
338 338
 
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 	 * @return object
353 353
 	 *   Instance of Object_Sync_Sf_Salesforce_Push
354 354
 	 */
355
-	private function push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
356
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_push.php';
357
-		$push = new Object_Sync_Sf_Salesforce_Push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue );
355
+	private function push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
356
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_push.php';
357
+		$push = new Object_Sync_Sf_Salesforce_Push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue);
358 358
 		return $push;
359 359
 	}
360 360
 
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 	 * @return object
374 374
 	 *   Instance of Object_Sync_Sf_Salesforce_Pull
375 375
 	 */
376
-	private function pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
377
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_pull.php';
378
-		$pull = new Object_Sync_Sf_Salesforce_Pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue );
376
+	private function pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
377
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_pull.php';
378
+		$pull = new Object_Sync_Sf_Salesforce_Pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue);
379 379
 		return $pull;
380 380
 	}
381 381
 
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 	*   Instance of Object_Sync_Sf_Admin
400 400
 	*
401 401
 	*/
402
-	private function load_admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) {
403
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/admin.php' );
404
-		$admin = new Object_Sync_Sf_Admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue );
405
-		add_action( 'admin_menu', array( $admin, 'create_admin_menu' ) );
406
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_and_styles' ) );
407
-		add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
408
-		add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 5 );
402
+	private function load_admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue) {
403
+		require_once(plugin_dir_path(__FILE__) . 'classes/admin.php');
404
+		$admin = new Object_Sync_Sf_Admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue);
405
+		add_action('admin_menu', array($admin, 'create_admin_menu'));
406
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts_and_styles'));
407
+		add_action('plugins_loaded', array($this, 'textdomain'));
408
+		add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 5);
409 409
 		return $admin;
410 410
 	}
411 411
 
@@ -417,11 +417,11 @@  discard block
 block discarded – undo
417 417
 	* @return array $links
418 418
 	*   These are the links that go with this plugin's entry
419 419
 	*/
420
-	public function plugin_action_links( $links, $file ) {
421
-		if ( plugin_basename( __FILE__ ) === $file ) {
422
-			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __( 'Settings', 'object-sync-for-salesforce' ) . '</a>';
420
+	public function plugin_action_links($links, $file) {
421
+		if (plugin_basename(__FILE__) === $file) {
422
+			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __('Settings', 'object-sync-for-salesforce') . '</a>';
423 423
 			// make the 'Settings' link appear first
424
-			array_unshift( $links, $settings );
424
+			array_unshift($links, $settings);
425 425
 		}
426 426
 		return $links;
427 427
 	}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	public function admin_scripts_and_styles() {
436 436
 
437 437
 		// I think some developers might not want to bother with select2 or selectwoo, so let's allow that to be changeable
438
-		$select_library = apply_filters( 'object_sync_for_salesforce_select_library', 'selectwoo' );
438
+		$select_library = apply_filters('object_sync_for_salesforce_select_library', 'selectwoo');
439 439
 
440 440
 		/*
441 441
 		 * example to modify the select library
@@ -447,19 +447,19 @@  discard block
 block discarded – undo
447 447
 		 * }
448 448
 		*/
449 449
 
450
-		$javascript_dependencies = array( 'jquery' );
450
+		$javascript_dependencies = array('jquery');
451 451
 		$css_dependencies        = array();
452
-		if ( '' !== $select_library ) {
453
-			wp_enqueue_script( $select_library . 'js', plugins_url( 'assets/js/' . $select_library . '.min.js', __FILE__ ), array( 'jquery' ), filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/' . $select_library . '.min.js' ), true );
452
+		if ('' !== $select_library) {
453
+			wp_enqueue_script($select_library . 'js', plugins_url('assets/js/' . $select_library . '.min.js', __FILE__), array('jquery'), filemtime(plugin_dir_path(__FILE__) . 'assets/js/' . $select_library . '.min.js'), true);
454 454
 			$javascript_dependencies[] = $select_library . 'js';
455 455
 
456
-			wp_enqueue_style( $select_library . 'css', plugins_url( 'assets/css/' . $select_library . '.min.css', __FILE__ ), array(), filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/' . $select_library . '.min.css' ), 'all' );
456
+			wp_enqueue_style($select_library . 'css', plugins_url('assets/css/' . $select_library . '.min.css', __FILE__), array(), filemtime(plugin_dir_path(__FILE__) . 'assets/css/' . $select_library . '.min.css'), 'all');
457 457
 			$css_dependencies[] = $select_library . 'css';
458 458
 		}
459 459
 
460
-		wp_enqueue_script( $this->slug . '-admin', plugins_url( 'assets/js/object-sync-for-salesforce-admin.min.js', __FILE__ ), $javascript_dependencies, filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/object-sync-for-salesforce-admin.min.js' ), true );
460
+		wp_enqueue_script($this->slug . '-admin', plugins_url('assets/js/object-sync-for-salesforce-admin.min.js', __FILE__), $javascript_dependencies, filemtime(plugin_dir_path(__FILE__) . 'assets/js/object-sync-for-salesforce-admin.min.js'), true);
461 461
 
462
-		wp_enqueue_style( $this->slug . '-admin', plugins_url( 'assets/css/object-sync-for-salesforce-admin.min.css', __FILE__ ), $css_dependencies, filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/object-sync-for-salesforce-admin.min.css' ), 'all' );
462
+		wp_enqueue_style($this->slug . '-admin', plugins_url('assets/css/object-sync-for-salesforce-admin.min.css', __FILE__), $css_dependencies, filemtime(plugin_dir_path(__FILE__) . 'assets/css/object-sync-for-salesforce-admin.min.css'), 'all');
463 463
 	}
464 464
 
465 465
 	/**
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @return void
469 469
 	 */
470 470
 	public function textdomain() {
471
-		load_plugin_textdomain( 'object-sync-for-salesforce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
471
+		load_plugin_textdomain('object-sync-for-salesforce', false, dirname(plugin_basename(__FILE__)) . '/languages/');
472 472
 	}
473 473
 
474 474
 	/**
@@ -481,13 +481,13 @@  discard block
 block discarded – undo
481 481
 	*/
482 482
 	private function get_login_credentials() {
483 483
 
484
-		$consumer_key       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( 'object_sync_for_salesforce_consumer_key', '' );
485
-		$consumer_secret    = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option( 'object_sync_for_salesforce_consumer_secret', '' );
486
-		$callback_url       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option( 'object_sync_for_salesforce_callback_url', '' );
487
-		$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', '' );
488
-		$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', '' );
489
-		$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', '' );
490
-		$api_version        = defined( 'OBJECT_SYNC_SF_SALESFORCE_API_VERSION' ) ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option( 'object_sync_for_salesforce_api_version', '' );
484
+		$consumer_key       = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option('object_sync_for_salesforce_consumer_key', '');
485
+		$consumer_secret    = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option('object_sync_for_salesforce_consumer_secret', '');
486
+		$callback_url       = defined('OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL') ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option('object_sync_for_salesforce_callback_url', '');
487
+		$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', '');
488
+		$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', '');
489
+		$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', '');
490
+		$api_version        = defined('OBJECT_SYNC_SF_SALESFORCE_API_VERSION') ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option('object_sync_for_salesforce_api_version', '');
491 491
 
492 492
 		$login_credentials = array(
493 493
 			'consumer_key'     => $consumer_key,
Please login to merge, or discard this patch.