Passed
Pull Request — master (#195)
by Jonathan
06:35
created
classes/salesforce_pull.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
 	protected $queue;
26 26
 
27 27
 	/**
28
-	* @var string
29
-	*/
28
+	 * @var string
29
+	 */
30 30
 	public $schedule_name; // allow for naming the queue in case there are multiple queues
31 31
 
32 32
 	/**
33
-	* Constructor which sets up pull schedule
34
-	*
35
-	* @param object $wpdb
36
-	* @param string $version
37
-	* @param array $login_credentials
38
-	* @param string $slug
39
-	* @param object $wordpress
40
-	* @param object $salesforce
41
-	* @param object $mappings
42
-	* @param object $logging
43
-	* @param array $schedulable_classes
44
-	* @param object $queue
45
-	* @throws \Exception
46
-	*/
33
+	 * Constructor which sets up pull schedule
34
+	 *
35
+	 * @param object $wpdb
36
+	 * @param string $version
37
+	 * @param array $login_credentials
38
+	 * @param string $slug
39
+	 * @param object $wordpress
40
+	 * @param object $salesforce
41
+	 * @param object $mappings
42
+	 * @param object $logging
43
+	 * @param array $schedulable_classes
44
+	 * @param object $queue
45
+	 * @throws \Exception
46
+	 */
47 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;
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	/**
69
-	* Create the action hooks based on what object maps exist from the admin settings
70
-	*
71
-	*/
69
+	 * Create the action hooks based on what object maps exist from the admin settings
70
+	 *
71
+	 */
72 72
 	public function add_actions() {
73 73
 
74 74
 		// ajax hook
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	/**
83
-	* Ajax callback for salesforce pull. Returns status of 200 for successful
84
-	* attempt or 403 for a failed pull attempt (SF not authorized, threshhold
85
-	* reached, etc.
86
-	* this is the ajax callback; not a cron run
87
-	*/
83
+	 * Ajax callback for salesforce pull. Returns status of 200 for successful
84
+	 * attempt or 403 for a failed pull attempt (SF not authorized, threshhold
85
+	 * reached, etc.
86
+	 * this is the ajax callback; not a cron run
87
+	 */
88 88
 	public function salesforce_pull_webhook() {
89 89
 
90 90
 		if ( true === $this->salesforce_pull() ) {
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 	/**
113
-	* Callback for the standard pull process used by webhooks and cron.
114
-	*/
113
+	 * Callback for the standard pull process used by webhooks and cron.
114
+	 */
115 115
 	public function salesforce_pull() {
116 116
 		$sfapi = $this->salesforce['sfapi'];
117 117
 
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 	}
132 132
 
133 133
 	/**
134
-	* Determines if the Salesforce pull should be allowed, or throttled.
135
-	*
136
-	* Prevents too many pull processes from running at once.
137
-	*
138
-	* @return bool
139
-	*    Returns false if the time elapsed between recent pulls is too short.
140
-	*/
134
+	 * Determines if the Salesforce pull should be allowed, or throttled.
135
+	 *
136
+	 * Prevents too many pull processes from running at once.
137
+	 *
138
+	 * @return bool
139
+	 *    Returns false if the time elapsed between recent pulls is too short.
140
+	 */
141 141
 	private function check_throttle() {
142 142
 		$pull_throttle = get_option( 'object_sync_for_salesforce_pull_throttle', 5 );
143 143
 		$last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync', 0 );
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 
152 152
 	/**
153
-	* Pull updated records from Salesforce and place them in the queue.
154
-	*
155
-	* Executes a SOQL query based on defined mappings, loops through the results,
156
-	* and places each updated SF object into the queue for later processing.
157
-	*
158
-	* We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF
159
-	*
160
-	*/
153
+	 * Pull updated records from Salesforce and place them in the queue.
154
+	 *
155
+	 * Executes a SOQL query based on defined mappings, loops through the results,
156
+	 * and places each updated SF object into the queue for later processing.
157
+	 *
158
+	 * We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF
159
+	 *
160
+	 */
161 161
 	private function get_updated_records() {
162 162
 		$sfapi = $this->salesforce['sfapi'];
163 163
 		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
@@ -341,18 +341,18 @@  discard block
 block discarded – undo
341 341
 	}
342 342
 
343 343
 	/**
344
-	* Given a SObject type name, build an SOQL query to include all fields for all
345
-	* SalesforceMappings mapped to that SObject.
346
-	*
347
-	* @param string $type
348
-	*   e.g. "Contact", "Account", etc.
349
-	*
350
-	* @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields
351
-	*   were found.
352
-	*
353
-	* @see Object_Sync_Sf_Mapping::get_mapped_fields
354
-	* @see Object_Sync_Sf_Mapping::get_mapped_record_types
355
-	*/
344
+	 * Given a SObject type name, build an SOQL query to include all fields for all
345
+	 * SalesforceMappings mapped to that SObject.
346
+	 *
347
+	 * @param string $type
348
+	 *   e.g. "Contact", "Account", etc.
349
+	 *
350
+	 * @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields
351
+	 *   were found.
352
+	 *
353
+	 * @see Object_Sync_Sf_Mapping::get_mapped_fields
354
+	 * @see Object_Sync_Sf_Mapping::get_mapped_record_types
355
+	 */
356 356
 	private function get_pull_query( $type, $salesforce_mapping = array() ) {
357 357
 		$mapped_fields       = array();
358 358
 		$mapped_record_types = array();
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
 	}
435 435
 
436 436
 	/**
437
-	* Get deleted records from salesforce.
438
-	* Note that deletions can only be queried via REST with an API version >= 29.0.
439
-	*
440
-	*/
437
+	 * Get deleted records from salesforce.
438
+	 * Note that deletions can only be queried via REST with an API version >= 29.0.
439
+	 *
440
+	 */
441 441
 	private function get_deleted_records() {
442 442
 
443 443
 		$sfapi = $this->salesforce['sfapi'];
@@ -538,13 +538,13 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 	/**
541
-	* Method for ajax hooks to call for pulling manually
542
-	*
543
-	* @param string $object_type
544
-	* @param string $salesforce_id
545
-	* @param string $wordpress_object
546
-	*
547
-	*/
541
+	 * Method for ajax hooks to call for pulling manually
542
+	 *
543
+	 * @param string $object_type
544
+	 * @param string $salesforce_id
545
+	 * @param string $wordpress_object
546
+	 *
547
+	 */
548 548
 	public function manual_pull( $object_type, $salesforce_id, $wordpress_object ) {
549 549
 		$sfapi   = $this->salesforce['sfapi'];
550 550
 		$object  = $sfapi->api_call( 'sobjects/' . $object_type . '/' . $salesforce_id );
@@ -559,20 +559,20 @@  discard block
 block discarded – undo
559 559
 	}
560 560
 
561 561
 	/**
562
-	* Sync WordPress objects and Salesforce objects from the queue using the REST API.
563
-	*
564
-	* @param string $object_type
565
-	*   Type of Salesforce object.
566
-	* @param array|string $object
567
-	*   The Salesforce data or its Id value.
568
-	* @param array|int $mapping
569
-	*   Salesforce/WP mapping data or its id.
570
-	* @param int $sf_sync_trigger
571
-	*   Trigger for this sync.
572
-	*
573
-	* @return true or exit the method
574
-	*
575
-	*/
562
+	 * Sync WordPress objects and Salesforce objects from the queue using the REST API.
563
+	 *
564
+	 * @param string $object_type
565
+	 *   Type of Salesforce object.
566
+	 * @param array|string $object
567
+	 *   The Salesforce data or its Id value.
568
+	 * @param array|int $mapping
569
+	 *   Salesforce/WP mapping data or its id.
570
+	 * @param int $sf_sync_trigger
571
+	 *   Trigger for this sync.
572
+	 *
573
+	 * @return true or exit the method
574
+	 *
575
+	 */
576 576
 	public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) {
577 577
 
578 578
 		$sfapi = $this->salesforce['sfapi'];
@@ -1301,19 +1301,19 @@  discard block
 block discarded – undo
1301 1301
 	}
1302 1302
 
1303 1303
 	/**
1304
-	* Create an object map between a Salesforce object and a WordPress object
1305
-	*
1306
-	* @param array $salesforce_object
1307
-	*   Array of the salesforce object's data
1308
-	* @param string $wordpress_id
1309
-	*   Unique identifier for the WordPress object
1310
-	* @param array $field_mapping
1311
-	*   The row that maps the object types together, including which fields match which other fields
1312
-	*
1313
-	* @return int $wpdb->insert_id
1314
-	*   This is the database row for the map object
1315
-	*
1316
-	*/
1304
+	 * Create an object map between a Salesforce object and a WordPress object
1305
+	 *
1306
+	 * @param array $salesforce_object
1307
+	 *   Array of the salesforce object's data
1308
+	 * @param string $wordpress_id
1309
+	 *   Unique identifier for the WordPress object
1310
+	 * @param array $field_mapping
1311
+	 *   The row that maps the object types together, including which fields match which other fields
1312
+	 *
1313
+	 * @return int $wpdb->insert_id
1314
+	 *   This is the database row for the map object
1315
+	 *
1316
+	 */
1317 1317
 	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1318 1318
 		// Create object map and save it
1319 1319
 		$mapping_object = $this->mappings->create_object_map(
Please login to merge, or discard this 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,58 +573,58 @@  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
-		$seconds = $this->queue->get_frequency( $this->schedule_name, 'seconds' ) + 60;
605
+		$seconds = $this->queue->get_frequency($this->schedule_name, 'seconds') + 60;
606 606
 
607 607
 		$transients_to_delete = array();
608 608
 
609
-		foreach ( $salesforce_mappings as $salesforce_mapping ) {
609
+		foreach ($salesforce_mappings as $salesforce_mapping) {
610 610
 
611 611
 			// this returns the row that maps the individual Salesforce row to the individual WordPress row
612
-			if ( isset( $object['Id'] ) ) {
613
-				$mapping_object = $this->mappings->load_by_salesforce( $object['Id'] );
612
+			if (isset($object['Id'])) {
613
+				$mapping_object = $this->mappings->load_by_salesforce($object['Id']);
614 614
 			} else {
615 615
 				// if we don't have a Salesforce object id, we've got no business doing stuff in WordPress
616 616
 				$status = 'error';
617
-				if ( isset( $this->logging ) ) {
617
+				if (isset($this->logging)) {
618 618
 					$logging = $this->logging;
619
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
620
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
619
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
620
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
621 621
 				}
622 622
 
623
-				$title = sprintf( esc_html__( 'Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce' ) );
623
+				$title = sprintf(esc_html__('Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce'));
624 624
 
625 625
 				$logging->setup(
626 626
 					$title,
627
-					print_r( $object, true ), // log whatever we have in the event of this error, so print the array
627
+					print_r($object, true), // log whatever we have in the event of this error, so print the array
628 628
 					$sf_sync_trigger,
629 629
 					0, // parent id goes here but we don't have one, so make it 0
630 630
 					$status
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 			// if it's not already connected (ie on create), the array will be empty
637 637
 
638 638
 			// hook to allow other plugins to define or alter the mapping object
639
-			$mapping_object = apply_filters( 'object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping );
639
+			$mapping_object = apply_filters('object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping);
640 640
 
641 641
 			// we already have the data from Salesforce at this point; we just need to work with it in WordPress
642 642
 			$synced_object = array(
@@ -645,58 +645,58 @@  discard block
 block discarded – undo
645 645
 				'mapping'           => $mapping,
646 646
 			);
647 647
 
648
-			$structure = $this->wordpress->get_wordpress_table_structure( $salesforce_mapping['wordpress_object'] );
648
+			$structure = $this->wordpress->get_wordpress_table_structure($salesforce_mapping['wordpress_object']);
649 649
 			$object_id = $structure['id_field'];
650 650
 
651 651
 			$op = '';
652 652
 
653 653
 			// are these objects already connected in WordPress?
654
-			if ( isset( $mapping_object['id'] ) ) {
654
+			if (isset($mapping_object['id'])) {
655 655
 				$is_new                      = false;
656 656
 				$mapping_object_id_transient = $mapping_object['id'];
657 657
 			} else {
658 658
 				// there is not a mapping object for this WordPress object id yet
659 659
 				// check for that transient with the currently pushing id
660 660
 				$is_new                      = true;
661
-				$mapping_object_id_transient = get_transient( 'salesforce_pushing_object_id' );
661
+				$mapping_object_id_transient = get_transient('salesforce_pushing_object_id');
662 662
 			}
663 663
 
664 664
 			// Drupal only does a salesforce_pull flag, but we might as well do push and pull because WordPress
665
-			$salesforce_pushing = (int) get_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
666
-			if ( 1 === $salesforce_pushing ) {
665
+			$salesforce_pushing = (int) get_transient('salesforce_pushing_' . $mapping_object_id_transient);
666
+			if (1 === $salesforce_pushing) {
667 667
 				$transients_to_delete[] = $mapping_object_id_transient;
668 668
 				continue;
669 669
 			}
670 670
 
671 671
 			// deleting mapped objects
672
-			if ( $sf_sync_trigger == $this->mappings->sync_sf_delete ) { // trigger is a bit operator
673
-				if ( isset( $mapping_object['id'] ) ) {
672
+			if ($sf_sync_trigger == $this->mappings->sync_sf_delete) { // trigger is a bit operator
673
+				if (isset($mapping_object['id'])) {
674 674
 
675
-					set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
676
-					set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
675
+					set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
676
+					set_transient('salesforce_pulling_object_id', $mapping_object['id']);
677 677
 
678 678
 					$op              = 'Delete';
679
-					$wordpress_check = $this->mappings->load_by_wordpress( $mapping_object['wordpress_object'], $mapping_object['wordpress_id'] );
680
-					if ( count( $wordpress_check ) === count( $wordpress_check, COUNT_RECURSIVE ) ) {
679
+					$wordpress_check = $this->mappings->load_by_wordpress($mapping_object['wordpress_object'], $mapping_object['wordpress_id']);
680
+					if (count($wordpress_check) === count($wordpress_check, COUNT_RECURSIVE)) {
681 681
 						try {
682
-							$result = $this->wordpress->object_delete( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'] );
683
-						} catch ( WordpressException $e ) {
682
+							$result = $this->wordpress->object_delete($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id']);
683
+						} catch (WordpressException $e) {
684 684
 							$status = 'error';
685 685
 							// create log entry for failed delete
686
-							if ( isset( $this->logging ) ) {
686
+							if (isset($this->logging)) {
687 687
 								$logging = $this->logging;
688
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
689
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
688
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
689
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
690 690
 							}
691 691
 
692 692
 							// 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
693
-							$title = sprintf( esc_html__( 'Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
694
-								esc_attr( $op ),
695
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
696
-								esc_attr( $object_id ),
697
-								esc_attr( $mapping_object['wordpress_id'] ),
698
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
699
-								esc_attr( $mapping_object['salesforce_id'] )
693
+							$title = sprintf(esc_html__('Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
694
+								esc_attr($op),
695
+								esc_attr($salesforce_mapping['wordpress_object']),
696
+								esc_attr($object_id),
697
+								esc_attr($mapping_object['wordpress_id']),
698
+								esc_attr($salesforce_mapping['salesforce_object']),
699
+								esc_attr($mapping_object['salesforce_id'])
700 700
 							);
701 701
 
702 702
 							$logging->setup(
@@ -707,38 +707,38 @@  discard block
 block discarded – undo
707 707
 								$status
708 708
 							);
709 709
 
710
-							if ( false === $hold_exceptions ) {
710
+							if (false === $hold_exceptions) {
711 711
 								throw $e;
712 712
 							}
713
-							if ( empty( $exception ) ) {
713
+							if (empty($exception)) {
714 714
 								$exception = $e;
715 715
 							} else {
716
-								$my_class  = get_class( $e );
717
-								$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
716
+								$my_class  = get_class($e);
717
+								$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
718 718
 							}
719 719
 
720 720
 							// hook for pull fail
721
-							do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
721
+							do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
722 722
 
723 723
 						} // End try().
724 724
 
725
-						if ( ! isset( $e ) ) {
725
+						if ( ! isset($e)) {
726 726
 							// create log entry for successful delete if the result had no errors
727 727
 							$status = 'success';
728
-							if ( isset( $this->logging ) ) {
728
+							if (isset($this->logging)) {
729 729
 								$logging = $this->logging;
730
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
731
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
730
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
731
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
732 732
 							}
733 733
 
734 734
 							// 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
735
-							$title = sprintf( esc_html__( 'Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
736
-								esc_attr( $op ),
737
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
738
-								esc_attr( $object_id ),
739
-								esc_attr( $mapping_object['wordpress_id'] ),
740
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
741
-								esc_attr( $mapping_object['salesforce_id'] )
735
+							$title = sprintf(esc_html__('Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
736
+								esc_attr($op),
737
+								esc_attr($salesforce_mapping['wordpress_object']),
738
+								esc_attr($object_id),
739
+								esc_attr($mapping_object['wordpress_id']),
740
+								esc_attr($salesforce_mapping['salesforce_object']),
741
+								esc_attr($mapping_object['salesforce_id'])
742 742
 							);
743 743
 
744 744
 							$logging->setup(
@@ -750,38 +750,38 @@  discard block
 block discarded – undo
750 750
 							);
751 751
 
752 752
 							// hook for pull success
753
-							do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
753
+							do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
754 754
 						}
755 755
 					} else {
756
-						$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' ) );
756
+						$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 757
 						$i        = 0;
758
-						foreach ( $wordpress_check as $match ) {
758
+						foreach ($wordpress_check as $match) {
759 759
 							$i++;
760
-							$more_ids .= sprintf( $match['salesforce_id'] );
761
-							if ( count( $wordpress_check ) !== $i ) {
762
-								$more_ids .= sprintf( ', ' );
760
+							$more_ids .= sprintf($match['salesforce_id']);
761
+							if (count($wordpress_check) !== $i) {
762
+								$more_ids .= sprintf(', ');
763 763
 							} else {
764
-								$more_ids .= sprintf( '.</p>' );
764
+								$more_ids .= sprintf('.</p>');
765 765
 							}
766 766
 						}
767 767
 
768
-						$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>' );
768
+						$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 769
 
770 770
 						$status = 'notice';
771
-						if ( isset( $this->logging ) ) {
771
+						if (isset($this->logging)) {
772 772
 							$logging = $this->logging;
773
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
774
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
773
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
774
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
775 775
 						}
776 776
 
777 777
 						// 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
778
-						$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' ),
779
-							esc_attr( $op ),
780
-							esc_attr( $salesforce_mapping['wordpress_object'] ),
781
-							esc_attr( $object_id ),
782
-							esc_attr( $mapping_object['wordpress_id'] ),
783
-							esc_attr( $salesforce_mapping['salesforce_object'] ),
784
-							esc_attr( $mapping_object['salesforce_id'] )
778
+						$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'),
779
+							esc_attr($op),
780
+							esc_attr($salesforce_mapping['wordpress_object']),
781
+							esc_attr($object_id),
782
+							esc_attr($mapping_object['wordpress_id']),
783
+							esc_attr($salesforce_mapping['salesforce_object']),
784
+							esc_attr($mapping_object['salesforce_id'])
785 785
 						);
786 786
 
787 787
 						$logging->setup(
@@ -795,27 +795,27 @@  discard block
 block discarded – undo
795 795
 
796 796
 					// delete the map row from WordPress after the WordPress row has been deleted
797 797
 					// we delete the map row even if the WordPress delete failed, because the Salesforce object is gone
798
-					$this->mappings->delete_object_map( $mapping_object['id'] );
798
+					$this->mappings->delete_object_map($mapping_object['id']);
799 799
 					// there is no map row if we end this if statement
800 800
 				} // End if().
801 801
 				return;
802 802
 			} // End if().
803 803
 
804 804
 			// map the Salesforce values to WordPress fields
805
-			$params = $this->mappings->map_params( $mapping, $object, $sf_sync_trigger, false, $is_new );
805
+			$params = $this->mappings->map_params($mapping, $object, $sf_sync_trigger, false, $is_new);
806 806
 
807 807
 			// hook to allow other plugins to modify the $params array
808 808
 			// use hook to map fields between the WordPress and Salesforce objects
809 809
 			// returns $params.
810
-			$params = apply_filters( 'object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new );
810
+			$params = apply_filters('object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new);
811 811
 
812 812
 			// if we don't get any params, there are no fields that should be sent to WordPress
813
-			if ( empty( $params ) ) {
813
+			if (empty($params)) {
814 814
 				return;
815 815
 			}
816 816
 
817 817
 			// if there is a prematch WordPress field - ie email - on the fieldmap object
818
-			if ( isset( $params['prematch'] ) && is_array( $params['prematch'] ) ) {
818
+			if (isset($params['prematch']) && is_array($params['prematch'])) {
819 819
 				$prematch_field_wordpress  = $params['prematch']['wordpress_field'];
820 820
 				$prematch_field_salesforce = $params['prematch']['salesforce_field'];
821 821
 				$prematch_value            = $params['prematch']['value'];
@@ -825,22 +825,22 @@  discard block
 block discarded – undo
825 825
 					'method_update' => $params['prematch']['method_update'],
826 826
 					'method_read'   => $params['prematch']['method_read'],
827 827
 				);
828
-				unset( $params['prematch'] );
828
+				unset($params['prematch']);
829 829
 			}
830 830
 
831 831
 			// 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.
832 832
 
833 833
 			// methods to run the wp create or update operations
834 834
 
835
-			if ( true === $is_new ) {
835
+			if (true === $is_new) {
836 836
 
837 837
 				// setup SF record type. CampaignMember objects get their Campaign's type
838 838
 				// i am still a bit confused about this
839 839
 				// we should store this as a meta field on each object, if it meets these criteria
840 840
 				// we need to store the read/modify attributes because the field doesn't exist in the mapping
841
-				if ( $salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty( $params['RecordTypeId'] ) && ( 'CampaignMember' !== $salesforce_mapping['salesforce_object'] ) ) {
841
+				if ($salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty($params['RecordTypeId']) && ('CampaignMember' !== $salesforce_mapping['salesforce_object'])) {
842 842
 					$type = $salesforce_mapping['wordpress_object'];
843
-					if ( 'category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object'] ) {
843
+					if ('category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object']) {
844 844
 						$type = 'term';
845 845
 					}
846 846
 					$params['RecordTypeId'] = array(
@@ -858,24 +858,24 @@  discard block
 block discarded – undo
858 858
 					// returns a $salesforce_id.
859 859
 					// it should keep NULL if there is no match
860 860
 					// the function that calls this hook needs to check the mapping to make sure the WordPress object is the right type
861
-					$wordpress_id = apply_filters( 'object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull' );
861
+					$wordpress_id = apply_filters('object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull');
862 862
 
863 863
 					// hook to allow other plugins to do something right before WordPress data is saved
864 864
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
865
-					do_action( 'object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params );
865
+					do_action('object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params);
866 866
 
867
-					if ( isset( $prematch_field_salesforce ) || null !== $wordpress_id ) {
867
+					if (isset($prematch_field_salesforce) || null !== $wordpress_id) {
868 868
 
869 869
 						$op = 'Upsert';
870 870
 
871 871
 						// if either prematch criteria exists, make the values queryable
872
-						if ( isset( $prematch_field_salesforce ) ) {
872
+						if (isset($prematch_field_salesforce)) {
873 873
 							$upsert_key     = $prematch_field_wordpress;
874 874
 							$upsert_value   = $prematch_value;
875 875
 							$upsert_methods = $prematch_methods;
876 876
 						}
877 877
 
878
-						if ( null !== $wordpress_id ) {
878
+						if (null !== $wordpress_id) {
879 879
 							$upsert_key     = $object_id;
880 880
 							$upsert_value   = $wordpress_id;
881 881
 							$upsert_methods = array();
@@ -884,13 +884,13 @@  discard block
 block discarded – undo
884 884
 						// with the flag at the end, upsert returns a $wordpress_id only
885 885
 						// we can then check to see if it has a mapping object
886 886
 						// we should only do this if the above hook didn't already set the $wordpress_id
887
-						if ( null === $wordpress_id ) {
888
-							$wordpress_id = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true );
887
+						if (null === $wordpress_id) {
888
+							$wordpress_id = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true);
889 889
 						}
890 890
 
891 891
 						// find out if there is a mapping object for this WordPress object already
892 892
 						// don't do it if the WordPress id is 0.
893
-						if ( 0 !== $wordpress_id ) {
893
+						if (0 !== $wordpress_id) {
894 894
 							$mapping_object = $this->mappings->get_object_maps(
895 895
 								array(
896 896
 									'wordpress_id'     => $wordpress_id,
@@ -905,35 +905,35 @@  discard block
 block discarded – undo
905 905
 								)
906 906
 							);
907 907
 
908
-							if ( array() !== $mapping_object_debug ) {
908
+							if (array() !== $mapping_object_debug) {
909 909
 								// create log entry to warn about at least one id of 0
910 910
 								$status = 'error';
911
-								$title  = sprintf( esc_html__( 'Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce' ) );
911
+								$title  = sprintf(esc_html__('Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce'));
912 912
 
913
-								if ( 1 === count( $mapping_object_debug ) ) {
913
+								if (1 === count($mapping_object_debug)) {
914 914
 									// 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
915
-									$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' ),
916
-										absint( $mapping_object_debug['id'] ),
917
-										esc_attr( $salesforce_mapping['wordpress_object'] ),
918
-										esc_attr( $mapping_object_debug['salesforce_id'] )
915
+									$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'),
916
+										absint($mapping_object_debug['id']),
917
+										esc_attr($salesforce_mapping['wordpress_object']),
918
+										esc_attr($mapping_object_debug['salesforce_id'])
919 919
 									);
920 920
 								} else {
921
-									$body = sprintf( esc_html__( 'There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce' ) . '<ul>' );
922
-									foreach ( $mapping_object_debug as $mapping_object ) {
921
+									$body = sprintf(esc_html__('There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce') . '<ul>');
922
+									foreach ($mapping_object_debug as $mapping_object) {
923 923
 										// translators: placeholders are: 1) the mapping object row ID, 2) the ID of the Salesforce object, 3) the WordPress object type
924
-										$body .= sprintf( '<li>' . esc_html__( 'Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
925
-											absint( $mapping_object['id'] ),
926
-											esc_attr( $mapping_object['salesforce_id'] ),
927
-											esc_attr( $salesforce_mapping['wordpress_object'] )
924
+										$body .= sprintf('<li>' . esc_html__('Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce') . '</li>',
925
+											absint($mapping_object['id']),
926
+											esc_attr($mapping_object['salesforce_id']),
927
+											esc_attr($salesforce_mapping['wordpress_object'])
928 928
 										);
929 929
 									}
930
-									$body .= sprintf( '</ul>' );
930
+									$body .= sprintf('</ul>');
931 931
 								}
932 932
 
933
-								if ( isset( $this->logging ) ) {
933
+								if (isset($this->logging)) {
934 934
 									$logging = $this->logging;
935
-								} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
936
-									$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
935
+								} elseif (class_exists('Object_Sync_Sf_Logging')) {
936
+									$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
937 937
 								}
938 938
 								$parent = 0;
939 939
 								$logging->setup(
@@ -947,37 +947,37 @@  discard block
 block discarded – undo
947 947
 						} // End if().
948 948
 
949 949
 						// there is already a mapping object. don't change the WordPress data to match this new Salesforce record, but log it
950
-						if ( isset( $mapping_object['id'] ) ) {
950
+						if (isset($mapping_object['id'])) {
951 951
 							// set the transient so that salesforce_push doesn't start doing stuff, then return out of here
952
-							set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
953
-							set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
952
+							set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
953
+							set_transient('salesforce_pulling_object_id', $mapping_object['id']);
954 954
 							// create log entry to indicate that nothing happened
955 955
 							$status = 'notice';
956 956
 							// translators: placeholders are: 1) mapping object row id, 2) WordPress object tyoe, 3) individual WordPress item ID, 4) individual Salesforce item ID
957
-							$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' ),
958
-								absint( $mapping_object['id'] ),
959
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
960
-								absint( $wordpress_id ),
961
-								esc_attr( $object['Id'] )
957
+							$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'),
958
+								absint($mapping_object['id']),
959
+								esc_attr($salesforce_mapping['wordpress_object']),
960
+								absint($wordpress_id),
961
+								esc_attr($object['Id'])
962 962
 							);
963 963
 
964 964
 							// 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
965
-							$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' ),
966
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
967
-								esc_attr( $structure['id_field'] ),
968
-								absint( $wordpress_id ),
969
-								esc_attr( $mapping_object['salesforce_object'] ),
970
-								esc_attr( $object['Id'] ),
971
-								absint( $mapping_object['id'] )
965
+							$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'),
966
+								esc_attr($salesforce_mapping['wordpress_object']),
967
+								esc_attr($structure['id_field']),
968
+								absint($wordpress_id),
969
+								esc_attr($mapping_object['salesforce_object']),
970
+								esc_attr($object['Id']),
971
+								absint($mapping_object['id'])
972 972
 							);
973 973
 
974
-							if ( isset( $this->logging ) ) {
974
+							if (isset($this->logging)) {
975 975
 								$logging = $this->logging;
976
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
977
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
976
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
977
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
978 978
 							}
979 979
 							// if we know the WordPress object id we can put it in there
980
-							if ( null !== $wordpress_id ) {
980
+							if (null !== $wordpress_id) {
981 981
 								$parent = $wordpress_id;
982 982
 							} else {
983 983
 								$parent = 0;
@@ -996,9 +996,9 @@  discard block
 block discarded – undo
996 996
 						// right here we should set the pulling transient
997 997
 						// this means we have to create the mapping object here as well, and update it with the correct IDs after successful response
998 998
 						// create the mapping object between the rows
999
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
1000
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
1001
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
999
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
1000
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
1001
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
1002 1002
 						$mapping_object = $this->mappings->get_object_maps(
1003 1003
 							array(
1004 1004
 								'id' => $mapping_object_id,
@@ -1007,50 +1007,50 @@  discard block
 block discarded – undo
1007 1007
 
1008 1008
 						// now we can upsert the object in wp if we've gotten to this point
1009 1009
 						// this command will either create or update the object
1010
-						$result = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'] );
1010
+						$result = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts']);
1011 1011
 
1012 1012
 					} else {
1013 1013
 						// No key or prematch field exists on this field map object, create a new object in WordPress.
1014 1014
 						$op                = 'Create';
1015
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
1016
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
1017
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
1015
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
1016
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
1017
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
1018 1018
 						$mapping_object = $this->mappings->get_object_maps(
1019 1019
 							array(
1020 1020
 								'id' => $mapping_object_id,
1021 1021
 							)
1022 1022
 						);
1023 1023
 
1024
-						$result = $this->wordpress->object_create( $salesforce_mapping['wordpress_object'], $params );
1024
+						$result = $this->wordpress->object_create($salesforce_mapping['wordpress_object'], $params);
1025 1025
 					} // End if().
1026
-				} catch ( WordpressException $e ) {
1026
+				} catch (WordpressException $e) {
1027 1027
 					// create log entry for failed create or upsert
1028 1028
 					$status = 'error';
1029 1029
 
1030 1030
 					// translators: placeholders are: 1) what operation is happening, and 2) the name of the WordPress object
1031
-					$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
1032
-						esc_attr( $op ),
1033
-						esc_attr( $salesforce_mapping['wordpress_object'] )
1031
+					$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
1032
+						esc_attr($op),
1033
+						esc_attr($salesforce_mapping['wordpress_object'])
1034 1034
 					);
1035 1035
 
1036
-					if ( null !== $salesforce_id ) {
1036
+					if (null !== $salesforce_id) {
1037 1037
 						$title .= ' ' . $salesforce_id;
1038 1038
 					}
1039 1039
 
1040 1040
 					// translators: placeholders are: 1) the name of the Salesforce object, and 2) Id of the Salesforce object
1041
-					$title .= sprintf( esc_html__( ' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce' ),
1041
+					$title .= sprintf(esc_html__(' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce'),
1042 1042
 						$salesforce_mapping['salesforce_object'],
1043 1043
 						$object['Id']
1044 1044
 					);
1045 1045
 
1046
-					if ( isset( $this->logging ) ) {
1046
+					if (isset($this->logging)) {
1047 1047
 						$logging = $this->logging;
1048
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1049
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1048
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1049
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1050 1050
 					}
1051 1051
 
1052 1052
 					// if we know the WordPress object id we can put it in there
1053
-					if ( null !== $wordpress_id ) {
1053
+					if (null !== $wordpress_id) {
1054 1054
 						$parent = $wordpress_id;
1055 1055
 					} else {
1056 1056
 						$parent = 0;
@@ -1064,26 +1064,26 @@  discard block
 block discarded – undo
1064 1064
 						$status
1065 1065
 					);
1066 1066
 
1067
-					if ( false === $hold_exceptions ) {
1067
+					if (false === $hold_exceptions) {
1068 1068
 						throw $e;
1069 1069
 					}
1070
-					if ( empty( $exception ) ) {
1070
+					if (empty($exception)) {
1071 1071
 						$exception = $e;
1072 1072
 					} else {
1073
-						$my_class  = get_class( $e );
1074
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1073
+						$my_class  = get_class($e);
1074
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1075 1075
 					}
1076 1076
 
1077 1077
 					// hook for pull fail
1078
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1078
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1079 1079
 
1080 1080
 					return;
1081 1081
 				} // End try().
1082 1082
 
1083 1083
 				// set $wordpress_data to the query result
1084 1084
 				$wordpress_data = $result['data'];
1085
-				if ( isset( $wordpress_data[ "$object_id" ] ) ) {
1086
-					$wordpress_id = $wordpress_data[ "$object_id" ];
1085
+				if (isset($wordpress_data["$object_id"])) {
1086
+					$wordpress_id = $wordpress_data["$object_id"];
1087 1087
 				} else {
1088 1088
 					$wordpress_id = 0;
1089 1089
 				}
@@ -1092,23 +1092,23 @@  discard block
 block discarded – undo
1092 1092
 				// this means the object has already been created/updated in WordPress
1093 1093
 				// 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)
1094 1094
 
1095
-				if ( empty( $result['errors'] ) ) {
1095
+				if (empty($result['errors'])) {
1096 1096
 					$status = 'success';
1097 1097
 
1098
-					if ( isset( $this->logging ) ) {
1098
+					if (isset($this->logging)) {
1099 1099
 						$logging = $this->logging;
1100
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1101
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1100
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1101
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1102 1102
 					}
1103 1103
 
1104 1104
 					// 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
1105
-					$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' ),
1106
-						esc_attr( $op ),
1107
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1108
-						esc_attr( $object_id ),
1109
-						esc_attr( $wordpress_id ),
1110
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1111
-						esc_attr( $object['Id'] )
1105
+					$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'),
1106
+						esc_attr($op),
1107
+						esc_attr($salesforce_mapping['wordpress_object']),
1108
+						esc_attr($object_id),
1109
+						esc_attr($wordpress_id),
1110
+						esc_attr($salesforce_mapping['salesforce_object']),
1111
+						esc_attr($object['Id'])
1112 1112
 					);
1113 1113
 
1114 1114
 					$logging->setup(
@@ -1121,40 +1121,40 @@  discard block
 block discarded – undo
1121 1121
 
1122 1122
 					// update that mapping object
1123 1123
 					$mapping_object['wordpress_id'] = $wordpress_id;
1124
-					$mapping_object                 = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1124
+					$mapping_object                 = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1125 1125
 
1126 1126
 					// hook for pull success
1127
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1127
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1128 1128
 				} else {
1129 1129
 
1130 1130
 					// create log entry for failed create or upsert
1131 1131
 					// 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
1132 1132
 					// if we see this in the log entries, we can understand what it does, but probably not until then
1133 1133
 					$status = 'error';
1134
-					if ( isset( $this->logging ) ) {
1134
+					if (isset($this->logging)) {
1135 1135
 						$logging = $this->logging;
1136
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1137
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1136
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1137
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1138 1138
 					}
1139 1139
 
1140
-					if ( is_object( $wordpress_id ) ) {
1140
+					if (is_object($wordpress_id)) {
1141 1141
 						// print this array because if this happens, something weird has happened and we want to log whatever we have
1142
-						$wordpress_id = print_r( $wordpress_id, true );
1142
+						$wordpress_id = print_r($wordpress_id, true);
1143 1143
 					}
1144 1144
 
1145 1145
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object type, 3) the Salesforce object Id value
1146
-					$title = sprintf( esc_html__( 'Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce' ),
1147
-						esc_attr( $op ),
1148
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1149
-						esc_attr( $object['Id'] )
1146
+					$title = sprintf(esc_html__('Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce'),
1147
+						esc_attr($op),
1148
+						esc_attr($salesforce_mapping['salesforce_object']),
1149
+						esc_attr($object['Id'])
1150 1150
 					);
1151 1151
 
1152 1152
 					// 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
1153
-					$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',
1154
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1155
-						esc_attr( $object_id ),
1156
-						esc_attr( $wordpress_id ),
1157
-						print_r( $result['errors'], true ) // if we get this error, we need to know whatever we have
1153
+					$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',
1154
+						esc_attr($salesforce_mapping['wordpress_object']),
1155
+						esc_attr($object_id),
1156
+						esc_attr($wordpress_id),
1157
+						print_r($result['errors'], true) // if we get this error, we need to know whatever we have
1158 1158
 					);
1159 1159
 
1160 1160
 					$logging->setup(
@@ -1166,52 +1166,52 @@  discard block
 block discarded – undo
1166 1166
 					);
1167 1167
 
1168 1168
 					// hook for pull fail
1169
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1169
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1170 1170
 
1171 1171
 					return;
1172 1172
 				} // End if().
1173
-			} elseif ( false === $is_new ) {
1173
+			} elseif (false === $is_new) {
1174 1174
 
1175 1175
 				// right here we should set the pulling transient
1176
-				set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
1177
-				set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
1176
+				set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
1177
+				set_transient('salesforce_pulling_object_id', $mapping_object['id']);
1178 1178
 
1179 1179
 				// there is an existing object link
1180 1180
 				// if the last sync is greater than the last time this object was updated by Salesforce, skip it
1181 1181
 				// this keeps us from doing redundant syncs
1182 1182
 				// because SF stores all DateTimes in UTC.
1183
-				$mapping_object['object_updated'] = current_time( 'mysql' );
1183
+				$mapping_object['object_updated'] = current_time('mysql');
1184 1184
 
1185 1185
 				$pull_trigger_field = $salesforce_mapping['pull_trigger_field'];
1186
-				$pull_trigger_value = $object[ $pull_trigger_field ];
1186
+				$pull_trigger_value = $object[$pull_trigger_field];
1187 1187
 
1188 1188
 				try {
1189 1189
 
1190 1190
 					// hook to allow other plugins to do something right before WordPress data is saved
1191 1191
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
1192
-					do_action( 'object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params );
1192
+					do_action('object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params);
1193 1193
 
1194 1194
 					$op     = 'Update';
1195
-					$result = $this->wordpress->object_update( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params );
1195
+					$result = $this->wordpress->object_update($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params);
1196 1196
 
1197 1197
 					$mapping_object['last_sync_status']  = $this->mappings->status_success;
1198
-					$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
1198
+					$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
1199 1199
 
1200 1200
 					$status = 'success';
1201
-					if ( isset( $this->logging ) ) {
1201
+					if (isset($this->logging)) {
1202 1202
 						$logging = $this->logging;
1203
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1204
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1203
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1204
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1205 1205
 					}
1206 1206
 
1207 1207
 					// 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
1208
-					$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' ),
1209
-						esc_attr( $op ),
1210
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1211
-						esc_attr( $object_id ),
1212
-						esc_attr( $mapping_object['wordpress_id'] ),
1213
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1214
-						esc_attr( $object['Id'] )
1208
+					$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'),
1209
+						esc_attr($op),
1210
+						esc_attr($salesforce_mapping['wordpress_object']),
1211
+						esc_attr($object_id),
1212
+						esc_attr($mapping_object['wordpress_id']),
1213
+						esc_attr($salesforce_mapping['salesforce_object']),
1214
+						esc_attr($object['Id'])
1215 1215
 					);
1216 1216
 
1217 1217
 					$logging->setup(
@@ -1223,25 +1223,25 @@  discard block
 block discarded – undo
1223 1223
 					);
1224 1224
 
1225 1225
 					// hook for pull success
1226
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1226
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1227 1227
 
1228
-				} catch ( WordpressException $e ) {
1228
+				} catch (WordpressException $e) {
1229 1229
 					// create log entry for failed update
1230 1230
 					$status = 'error';
1231
-					if ( isset( $this->logging ) ) {
1231
+					if (isset($this->logging)) {
1232 1232
 						$logging = $this->logging;
1233
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1234
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1233
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1234
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1235 1235
 					}
1236 1236
 
1237 1237
 					// 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
1238
-					$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' ),
1239
-						esc_attr( $op ),
1240
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1241
-						esc_attr( $object_id ),
1242
-						esc_attr( $mapping_object['wordpress_id'] ),
1243
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1244
-						esc_attr( $object['Id'] )
1238
+					$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'),
1239
+						esc_attr($op),
1240
+						esc_attr($salesforce_mapping['wordpress_object']),
1241
+						esc_attr($object_id),
1242
+						esc_attr($mapping_object['wordpress_id']),
1243
+						esc_attr($salesforce_mapping['salesforce_object']),
1244
+						esc_attr($object['Id'])
1245 1245
 					);
1246 1246
 
1247 1247
 					$logging->setup(
@@ -1255,18 +1255,18 @@  discard block
 block discarded – undo
1255 1255
 					$mapping_object['last_sync_status']  = $this->mappings->status_error;
1256 1256
 					$mapping_object['last_sync_message'] = $e->getMessage();
1257 1257
 
1258
-					if ( false === $hold_exceptions ) {
1258
+					if (false === $hold_exceptions) {
1259 1259
 						throw $e;
1260 1260
 					}
1261
-					if ( empty( $exception ) ) {
1261
+					if (empty($exception)) {
1262 1262
 						$exception = $e;
1263 1263
 					} else {
1264
-						$my_class  = get_class( $e );
1265
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1264
+						$my_class  = get_class($e);
1265
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1266 1266
 					}
1267 1267
 
1268 1268
 					// hook for pull fail
1269
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1269
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1270 1270
 
1271 1271
 				} // End try().
1272 1272
 
@@ -1275,26 +1275,26 @@  discard block
 block discarded – undo
1275 1275
 				// maybe can check to see if we actually updated anything in WordPress
1276 1276
 				// tell the mapping object - whether it is new or already existed - how we just used it
1277 1277
 				$mapping_object['last_sync_action'] = 'pull';
1278
-				$mapping_object['last_sync']        = current_time( 'mysql' );
1278
+				$mapping_object['last_sync']        = current_time('mysql');
1279 1279
 
1280 1280
 				// update that mapping object. the Salesforce data version will be set here as well because we set it earlier
1281
-				$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1281
+				$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1282 1282
 				// end of the if statement for is_new & update or create trigger
1283 1283
 				// 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.
1284 1284
 			} // End if().
1285 1285
 		} // End foreach().
1286 1286
 
1287 1287
 		// delete transients that we've already processed
1288
-		foreach ( $transients_to_delete as $mapping_object_id_transient ) {
1289
-			delete_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
1288
+		foreach ($transients_to_delete as $mapping_object_id_transient) {
1289
+			delete_transient('salesforce_pushing_' . $mapping_object_id_transient);
1290 1290
 		}
1291 1291
 
1292
-		$pushing_id = get_transient( 'salesforce_pushing_object_id' );
1293
-		if ( in_array( $pushing_id, $transients_to_delete, true ) ) {
1294
-			delete_transient( 'salesforce_pushing_object_id' );
1292
+		$pushing_id = get_transient('salesforce_pushing_object_id');
1293
+		if (in_array($pushing_id, $transients_to_delete, true)) {
1294
+			delete_transient('salesforce_pushing_object_id');
1295 1295
 		}
1296 1296
 
1297
-		if ( ! empty( $exception ) ) {
1297
+		if ( ! empty($exception)) {
1298 1298
 			throw $exception;
1299 1299
 		}
1300 1300
 
@@ -1314,17 +1314,17 @@  discard block
 block discarded – undo
1314 1314
 	*   This is the database row for the map object
1315 1315
 	*
1316 1316
 	*/
1317
-	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1317
+	private function create_object_map($salesforce_object, $wordpress_id, $field_mapping) {
1318 1318
 		// Create object map and save it
1319 1319
 		$mapping_object = $this->mappings->create_object_map(
1320 1320
 			array(
1321 1321
 				'wordpress_id'      => $wordpress_id, // wordpress unique id
1322 1322
 				'salesforce_id'     => $salesforce_object['Id'], // salesforce unique id. we don't care what kind of object it is at this point
1323 1323
 				'wordpress_object'  => $field_mapping['wordpress_object'], // keep track of what kind of wp object this is
1324
-				'last_sync'         => current_time( 'mysql' ),
1324
+				'last_sync'         => current_time('mysql'),
1325 1325
 				'last_sync_action'  => 'pull',
1326 1326
 				'last_sync_status'  => $this->mappings->status_success,
1327
-				'last_sync_message' => esc_html__( 'Mapping object created via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1327
+				'last_sync_message' => esc_html__('Mapping object created via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1328 1328
 				'action'            => 'created',
1329 1329
 			)
1330 1330
 		);
Please login to merge, or discard this patch.
classes/deactivate.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	protected $schedulable_classes;
21 21
 
22 22
 	/**
23
-	* Constructor which sets up deactivate hooks
24
-	* @param object $wpdb
25
-	* @param string $version
26
-	* @param string $slug
27
-	* @param array $schedulable_classes
28
-	*
29
-	*/
23
+	 * Constructor which sets up deactivate hooks
24
+	 * @param object $wpdb
25
+	 * @param string $version
26
+	 * @param string $slug
27
+	 * @param array $schedulable_classes
28
+	 *
29
+	 */
30 30
 	public function __construct( $wpdb, $version, $slug, $schedulable_classes ) {
31 31
 		$this->wpdb                = $wpdb;
32 32
 		$this->version             = $version;
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	/**
48
-	* Drop database tables for Salesforce
49
-	* This removes the tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
50
-	*
51
-	*/
48
+	 * Drop database tables for Salesforce
49
+	 * This removes the tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
50
+	 *
51
+	 */
52 52
 	public function wordpress_salesforce_drop_tables() {
53 53
 		$field_map_table  = $this->wpdb->prefix . 'object_sync_sf_field_map';
54 54
 		$object_map_table = $this->wpdb->prefix . 'object_sync_sf_object_map';
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 	}
59 59
 
60 60
 	/**
61
-	* Clear the scheduled tasks
62
-	* This removes all the scheduled tasks that are included in the plugin's $schedulable_classes array
61
+	 * Clear the scheduled tasks
62
+	 * This removes all the scheduled tasks that are included in the plugin's $schedulable_classes array
63 63
 	// todo: fix this so it uses action scheduler's scheduled tasks instead
64
-	*
65
-	*/
64
+	 *
65
+	 */
66 66
 	public function clear_schedule() {
67 67
 		foreach ( $this->schedulable_classes as $key => $value ) {
68 68
 			wp_clear_scheduled_hook( $key );
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	/**
73
-	* Delete the log post type
74
-	* This removes the log post type
75
-	*
76
-	*/
73
+	 * Delete the log post type
74
+	 * This removes the log post type
75
+	 *
76
+	 */
77 77
 	public function delete_log_post_type() {
78 78
 		unregister_post_type( 'wp_log' );
79 79
 	}
80 80
 
81 81
 	/**
82
-	* Remove roles and capabilities
83
-	* This removes the configure_salesforce capability from the admin role
84
-	*
85
-	* It also allows other plugins to remove the capability from other roles
86
-	*
87
-	*/
82
+	 * Remove roles and capabilities
83
+	 * This removes the configure_salesforce capability from the admin role
84
+	 *
85
+	 * It also allows other plugins to remove the capability from other roles
86
+	 *
87
+	 */
88 88
 	public function remove_roles_capabilities() {
89 89
 
90 90
 		// by default, only administrators can configure the plugin
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	/**
107
-	* Flush the plugin cache
108
-	*
109
-	*/
107
+	 * Flush the plugin cache
108
+	 *
109
+	 */
110 110
 	public function flush_plugin_cache() {
111 111
 		$sfwp_transients = new Object_Sync_Sf_WordPress_Transient( 'sfwp_transients' );
112 112
 		$sfwp_transients->flush();
113 113
 	}
114 114
 
115 115
 	/**
116
-	* Clear the plugin options
117
-	*
118
-	*/
116
+	 * Clear the plugin options
117
+	 *
118
+	 */
119 119
 	public function delete_plugin_options() {
120 120
 		$table          = $this->wpdb->prefix . 'options';
121 121
 		$plugin_options = $this->wpdb->get_results( 'SELECT option_name FROM ' . $table . ' WHERE option_name LIKE "object_sync_for_salesforce_%"', ARRAY_A );
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 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
 
@@ -27,20 +27,20 @@  discard block
 block discarded – undo
27 27
 	* @param array $schedulable_classes
28 28
 	*
29 29
 	*/
30
-	public function __construct( $wpdb, $version, $slug, $schedulable_classes ) {
30
+	public function __construct($wpdb, $version, $slug, $schedulable_classes) {
31 31
 		$this->wpdb                = $wpdb;
32 32
 		$this->version             = $version;
33 33
 		$this->slug                = $slug;
34 34
 		$this->schedulable_classes = $schedulable_classes;
35
-		$delete_data               = (int) get_option( 'object_sync_for_salesforce_delete_data_on_uninstall', 0 );
36
-		if ( 1 === $delete_data ) {
37
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'wordpress_salesforce_drop_tables' ) );
38
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'clear_schedule' ) );
39
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'delete_log_post_type' ) );
40
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'remove_roles_capabilities' ) );
41
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'flush_plugin_cache' )
35
+		$delete_data               = (int) get_option('object_sync_for_salesforce_delete_data_on_uninstall', 0);
36
+		if (1 === $delete_data) {
37
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'wordpress_salesforce_drop_tables'));
38
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'clear_schedule'));
39
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'delete_log_post_type'));
40
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'remove_roles_capabilities'));
41
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'flush_plugin_cache')
42 42
 			);
43
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'delete_plugin_options' ) );
43
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'delete_plugin_options'));
44 44
 		}
45 45
 	}
46 46
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	public function wordpress_salesforce_drop_tables() {
53 53
 		$field_map_table  = $this->wpdb->prefix . 'object_sync_sf_field_map';
54 54
 		$object_map_table = $this->wpdb->prefix . 'object_sync_sf_object_map';
55
-		$this->wpdb->query( 'DROP TABLE IF EXISTS ' . $field_map_table );
56
-		$this->wpdb->query( 'DROP TABLE IF EXISTS ' . $object_map_table );
57
-		delete_option( 'object_sync_for_salesforce_db_version' );
55
+		$this->wpdb->query('DROP TABLE IF EXISTS ' . $field_map_table);
56
+		$this->wpdb->query('DROP TABLE IF EXISTS ' . $object_map_table);
57
+		delete_option('object_sync_for_salesforce_db_version');
58 58
 	}
59 59
 
60 60
 	/**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	*
65 65
 	*/
66 66
 	public function clear_schedule() {
67
-		foreach ( $this->schedulable_classes as $key => $value ) {
68
-			wp_clear_scheduled_hook( $key );
67
+		foreach ($this->schedulable_classes as $key => $value) {
68
+			wp_clear_scheduled_hook($key);
69 69
 		}
70 70
 	}
71 71
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	*
76 76
 	*/
77 77
 	public function delete_log_post_type() {
78
-		unregister_post_type( 'wp_log' );
78
+		unregister_post_type('wp_log');
79 79
 	}
80 80
 
81 81
 	/**
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 	public function remove_roles_capabilities() {
89 89
 
90 90
 		// by default, only administrators can configure the plugin
91
-		$role = get_role( 'administrator' );
92
-		$role->remove_cap( 'configure_salesforce' );
91
+		$role = get_role('administrator');
92
+		$role->remove_cap('configure_salesforce');
93 93
 
94 94
 		// hook that allows other roles to configure the plugin as well
95
-		$roles = apply_filters( 'object_sync_for_salesforce_roles_configure_salesforce', null );
95
+		$roles = apply_filters('object_sync_for_salesforce_roles_configure_salesforce', null);
96 96
 
97 97
 		// for each role that we have, remove the configure salesforce capability
98
-		if ( null !== $roles ) {
99
-			foreach ( $roles as $role ) {
100
-				$role->remove_cap( 'configure_salesforce' );
98
+		if (null !== $roles) {
99
+			foreach ($roles as $role) {
100
+				$role->remove_cap('configure_salesforce');
101 101
 			}
102 102
 		}
103 103
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	*
109 109
 	*/
110 110
 	public function flush_plugin_cache() {
111
-		$sfwp_transients = new Object_Sync_Sf_WordPress_Transient( 'sfwp_transients' );
111
+		$sfwp_transients = new Object_Sync_Sf_WordPress_Transient('sfwp_transients');
112 112
 		$sfwp_transients->flush();
113 113
 	}
114 114
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 	*/
119 119
 	public function delete_plugin_options() {
120 120
 		$table          = $this->wpdb->prefix . 'options';
121
-		$plugin_options = $this->wpdb->get_results( 'SELECT option_name FROM ' . $table . ' WHERE option_name LIKE "object_sync_for_salesforce_%"', ARRAY_A );
122
-		foreach ( $plugin_options as $option ) {
123
-			delete_option( $option['option_name'] );
121
+		$plugin_options = $this->wpdb->get_results('SELECT option_name FROM ' . $table . ' WHERE option_name LIKE "object_sync_for_salesforce_%"', ARRAY_A);
122
+		foreach ($plugin_options as $option) {
123
+			delete_option($option['option_name']);
124 124
 		}
125 125
 	}
126 126
 
Please login to merge, or discard this patch.
object-sync-for-salesforce.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -16,75 +16,75 @@  discard block
 block discarded – undo
16 16
 class Object_Sync_Salesforce {
17 17
 
18 18
 	/**
19
-	* @var object
20
-	* Global object of `$wpdb`, the WordPress database
21
-	*/
19
+	 * @var object
20
+	 * Global object of `$wpdb`, the WordPress database
21
+	 */
22 22
 	private $wpdb;
23 23
 
24 24
 	/**
25
-	* @var array
26
-	* Login credentials for the Salesforce API; comes from wp-config or from the plugin settings
27
-	*/
25
+	 * @var array
26
+	 * Login credentials for the Salesforce API; comes from wp-config or from the plugin settings
27
+	 */
28 28
 	private $login_credentials;
29 29
 
30 30
 	/**
31
-	* @var string
32
-	* The plugin's slug so we can include it when necessary
33
-	*/
31
+	 * @var string
32
+	 * The plugin's slug so we can include it when necessary
33
+	 */
34 34
 	private $slug;
35 35
 
36 36
 	/**
37
-	* @var array
38
-	* Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
39
-	*/
37
+	 * @var array
38
+	 * Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
39
+	 */
40 40
 	public $schedulable_classes;
41 41
 
42 42
 	/**
43
-	* @var string
44
-	* Current version of the plugin
45
-	*/
43
+	 * @var string
44
+	 * Current version of the plugin
45
+	 */
46 46
 	private $version;
47 47
 
48 48
 	/**
49
-	* @var object
50
-	*/
49
+	 * @var object
50
+	 */
51 51
 	private $activated;
52 52
 
53 53
 	/**
54
-	* @var object
55
-	* Load and initialize the Object_Sync_Sf_Logging class
56
-	*/
54
+	 * @var object
55
+	 * Load and initialize the Object_Sync_Sf_Logging class
56
+	 */
57 57
 	private $logging;
58 58
 
59 59
 	/**
60
-	* @var object
61
-	* Load and initialize the Object_Sync_Sf_Mapping class
62
-	*/
60
+	 * @var object
61
+	 * Load and initialize the Object_Sync_Sf_Mapping class
62
+	 */
63 63
 	private $mappings;
64 64
 
65 65
 	/**
66
-	* @var object
67
-	* Load and initialize the Object_Sync_Sf_WordPress class
68
-	*/
66
+	 * @var object
67
+	 * Load and initialize the Object_Sync_Sf_WordPress class
68
+	 */
69 69
 	private $wordpress;
70 70
 
71 71
 	/**
72
-	* @var object
73
-	* Load and initialize the Object_Sync_Sf_Salesforce class.
74
-	* This contains the Salesforce API methods
75
-	*/
72
+	 * @var object
73
+	 * Load and initialize the Object_Sync_Sf_Salesforce class.
74
+	 * This contains the Salesforce API methods
75
+	 */
76 76
 	public $salesforce;
77 77
 
78 78
 	/**
79
-	* @var object
80
-	* Load and initialize the Object_Sync_Sf_Salesforce_Push class
81
-	*/
79
+	 * @var object
80
+	 * Load and initialize the Object_Sync_Sf_Salesforce_Push class
81
+	 */
82 82
 	private $push;
83 83
 
84 84
 	/**
85
-	* @var object
86
-	* Load and initialize the Object_Sync_Sf_Salesforce_Pull class
87
-	*/
85
+	 * @var object
86
+	 * Load and initialize the Object_Sync_Sf_Salesforce_Pull class
87
+	 */
88 88
 	private $pull;
89 89
 
90 90
 	/**
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	static $instance = null;
96 96
 
97 97
 	/**
98
-	* Load the static $instance property that holds the instance of the class.
99
-	* This instance makes the class reusable by other plugins
100
-	*
101
-	* @return object
102
-	*   The sfapi object if it is authenticated (empty, otherwise)
103
-	*
104
-	*/
98
+	 * Load the static $instance property that holds the instance of the class.
99
+	 * This instance makes the class reusable by other plugins
100
+	 *
101
+	 * @return object
102
+	 *   The sfapi object if it is authenticated (empty, otherwise)
103
+	 *
104
+	 */
105 105
 	static public function get_instance() {
106 106
 		if ( null === self::$instance ) {
107 107
 			self::$instance = new Object_Sync_Salesforce();
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
 	/**
252
-	* Private helper to load methods for manipulating core WordPress data across the plugin
253
-	*
254
-	* @param object $wpdb
255
-	* @param string $version
256
-	* @param string $slug
257
-	* @param object $mappings
258
-	* @param object $logging
259
-	*
260
-	* @return object
261
-	*   Instance of Object_Sync_Sf_WordPress
262
-	*/
252
+	 * Private helper to load methods for manipulating core WordPress data across the plugin
253
+	 *
254
+	 * @param object $wpdb
255
+	 * @param string $version
256
+	 * @param string $slug
257
+	 * @param object $mappings
258
+	 * @param object $logging
259
+	 *
260
+	 * @return object
261
+	 *   Instance of Object_Sync_Sf_WordPress
262
+	 */
263 263
 	private function wordpress( $wpdb, $version, $slug, $mappings, $logging ) {
264 264
 		require_once plugin_dir_path( __FILE__ ) . 'classes/wordpress.php';
265 265
 		$wordpress = new Object_Sync_Sf_WordPress( $wpdb, $version, $slug, $mappings, $logging );
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 	}
268 268
 
269 269
 	/**
270
-	* Public helper to load the Salesforce API and see if it is authenticated.
271
-	* This is public so other plugins can access the same SF API instance
272
-	*
273
-	* @return array
274
-	*   Whether Salesforce is authenticated (boolean)
275
-	*   The sfapi object if it is authenticated (empty, otherwise)
276
-	*/
270
+	 * Public helper to load the Salesforce API and see if it is authenticated.
271
+	 * This is public so other plugins can access the same SF API instance
272
+	 *
273
+	 * @return array
274
+	 *   Whether Salesforce is authenticated (boolean)
275
+	 *   The sfapi object if it is authenticated (empty, otherwise)
276
+	 */
277 277
 	public function salesforce_get_api() {
278 278
 		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce.php' );
279 279
 		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
@@ -379,25 +379,25 @@  discard block
 block discarded – undo
379 379
 	}
380 380
 
381 381
 	/**
382
-	* Load the admin class.
383
-	* This also creates admin menu, unless the plugin that calls this library has indicated that it has its own menu
384
-	*
385
-	* @param object $wpdb
386
-	* @param string $version
387
-	* @param array $login_credentials
388
-	* @param string $slug
389
-	* @param object $wordpress
390
-	* @param object $salesforce
391
-	* @param object $mappings
392
-	* @param object $push
393
-	* @param object $pull
394
-	* @param object $logging
395
-	* @param array $schedulable_classes
396
-	* @param object $queue
397
-	* @return object $admin
398
-	*   Instance of Object_Sync_Sf_Admin
399
-	*
400
-	*/
382
+	 * Load the admin class.
383
+	 * This also creates admin menu, unless the plugin that calls this library has indicated that it has its own menu
384
+	 *
385
+	 * @param object $wpdb
386
+	 * @param string $version
387
+	 * @param array $login_credentials
388
+	 * @param string $slug
389
+	 * @param object $wordpress
390
+	 * @param object $salesforce
391
+	 * @param object $mappings
392
+	 * @param object $push
393
+	 * @param object $pull
394
+	 * @param object $logging
395
+	 * @param array $schedulable_classes
396
+	 * @param object $queue
397
+	 * @return object $admin
398
+	 *   Instance of Object_Sync_Sf_Admin
399
+	 *
400
+	 */
401 401
 	private function load_admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) {
402 402
 		require_once( plugin_dir_path( __FILE__ ) . 'classes/admin.php' );
403 403
 		$admin = new Object_Sync_Sf_Admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue );
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 	}
410 410
 
411 411
 	/**
412
-	* Display a Settings link on the main Plugins page
413
-	*
414
-	* @param array $links
415
-	* @param string $file
416
-	* @return array $links
417
-	*   These are the links that go with this plugin's entry
418
-	*/
412
+	 * Display a Settings link on the main Plugins page
413
+	 *
414
+	 * @param array $links
415
+	 * @param string $file
416
+	 * @return array $links
417
+	 *   These are the links that go with this plugin's entry
418
+	 */
419 419
 	public function plugin_action_links( $links, $file ) {
420 420
 		if ( plugin_basename( __FILE__ ) === $file ) {
421 421
 			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __( 'Settings', 'object-sync-for-salesforce' ) . '</a>';
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 
428 428
 
429 429
 	/**
430
-	* Admin styles. Load the CSS and JavaScript for the plugin's settings
431
-	*
432
-	* @return void
433
-	*/
430
+	 * Admin styles. Load the CSS and JavaScript for the plugin's settings
431
+	 *
432
+	 * @return void
433
+	 */
434 434
 	public function admin_scripts_and_styles() {
435 435
 
436 436
 		// I think some developers might not want to bother with select2 or selectwoo, so let's allow that to be changeable
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 	}
472 472
 
473 473
 	/**
474
-	* Get the pre-login Salesforce credentials.
475
-	* These depend on the plugin's settings or constants defined in wp-config.php.
476
-	*
477
-	* @return array $login_credentials
478
-	*   Includes all settings necessary to log into the Salesforce API.
479
-	*   Replaces settings options with wp-config.php values if they exist.
480
-	*/
474
+	 * Get the pre-login Salesforce credentials.
475
+	 * These depend on the plugin's settings or constants defined in wp-config.php.
476
+	 *
477
+	 * @return array $login_credentials
478
+	 *   Includes all settings necessary to log into the Salesforce API.
479
+	 *   Replaces settings options with wp-config.php values if they exist.
480
+	 */
481 481
 	private function get_login_credentials() {
482 482
 
483 483
 		$consumer_key       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( 'object_sync_for_salesforce_consumer_key', '' );
Please login to merge, or discard this patch.
Spacing   +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 );
172
+		$this->queue = $this->queue($this->wpdb, $this->version, $this->slug);
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
 	/**
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 	 * @param string $slug
210 210
 	 * @return Object_Sync_Sf_Queue
211 211
 	 */
212
-	public function queue( $wpdb, $version, $slug ) {
213
-		require_once plugin_dir_path( __FILE__ ) . 'classes/class-object-sync-sf-queue.php';
214
-		$queue = new Object_Sync_Sf_Queue( $wpdb, $version, $slug );
212
+	public function queue($wpdb, $version, $slug) {
213
+		require_once plugin_dir_path(__FILE__) . 'classes/class-object-sync-sf-queue.php';
214
+		$queue = new Object_Sync_Sf_Queue($wpdb, $version, $slug);
215 215
 		return $queue;
216 216
 	}
217 217
 
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 	 * @return object
226 226
 	 *   Instance of Object_Sync_Sf_Logging
227 227
 	 */
228
-	private function logging( $wpdb, $version ) {
229
-		require_once plugin_dir_path( __FILE__ ) . 'classes/logging.php';
230
-		$logging = new Object_Sync_Sf_Logging( $wpdb, $version );
228
+	private function logging($wpdb, $version) {
229
+		require_once plugin_dir_path(__FILE__) . 'classes/logging.php';
230
+		$logging = new Object_Sync_Sf_Logging($wpdb, $version);
231 231
 		return $logging;
232 232
 	}
233 233
 
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 	 * @return object
243 243
 	 *   Instance of Object_Sync_Sf_Mapping
244 244
 	 */
245
-	private function mappings( $wpdb, $version, $slug, $logging ) {
246
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_mapping.php' );
247
-		$mappings = new Object_Sync_Sf_Mapping( $wpdb, $version, $slug, $logging );
245
+	private function mappings($wpdb, $version, $slug, $logging) {
246
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce_mapping.php');
247
+		$mappings = new Object_Sync_Sf_Mapping($wpdb, $version, $slug, $logging);
248 248
 		return $mappings;
249 249
 	}
250 250
 
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	* @return object
261 261
 	*   Instance of Object_Sync_Sf_WordPress
262 262
 	*/
263
-	private function wordpress( $wpdb, $version, $slug, $mappings, $logging ) {
264
-		require_once plugin_dir_path( __FILE__ ) . 'classes/wordpress.php';
265
-		$wordpress = new Object_Sync_Sf_WordPress( $wpdb, $version, $slug, $mappings, $logging );
263
+	private function wordpress($wpdb, $version, $slug, $mappings, $logging) {
264
+		require_once plugin_dir_path(__FILE__) . 'classes/wordpress.php';
265
+		$wordpress = new Object_Sync_Sf_WordPress($wpdb, $version, $slug, $mappings, $logging);
266 266
 		return $wordpress;
267 267
 	}
268 268
 
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 	*   The sfapi object if it is authenticated (empty, otherwise)
276 276
 	*/
277 277
 	public function salesforce_get_api() {
278
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce.php' );
279
-		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
278
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce.php');
279
+		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
280 280
 		$consumer_key        = $this->login_credentials['consumer_key'];
281 281
 		$consumer_secret     = $this->login_credentials['consumer_secret'];
282 282
 		$login_url           = $this->login_credentials['login_url'];
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 		$schedulable_classes = $this->schedulable_classes;
291 291
 		$is_authorized       = false;
292 292
 		$sfapi               = '';
293
-		if ( $consumer_key && $consumer_secret ) {
294
-			$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 );
295
-			if ( $sfapi->is_authorized() === true ) {
293
+		if ($consumer_key && $consumer_secret) {
294
+			$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);
295
+			if ($sfapi->is_authorized() === true) {
296 296
 				$is_authorized = true;
297 297
 			}
298 298
 		}
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 	 * @return object
313 313
 	 *   Instance of Object_Sync_Sf_Activate
314 314
 	 */
315
-	private function activate( $wpdb, $version, $slug ) {
316
-		require_once plugin_dir_path( __FILE__ ) . 'classes/activate.php';
317
-		$activate = new Object_Sync_Sf_Activate( $wpdb, $version, $slug );
315
+	private function activate($wpdb, $version, $slug) {
316
+		require_once plugin_dir_path(__FILE__) . 'classes/activate.php';
317
+		$activate = new Object_Sync_Sf_Activate($wpdb, $version, $slug);
318 318
 		return $activate;
319 319
 	}
320 320
 
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 	 * @return object
330 330
 	 *   Instance of Object_Sync_Sf_Deactivate
331 331
 	 */
332
-	private function deactivate( $wpdb, $version, $slug, $schedulable_classes ) {
333
-		require_once plugin_dir_path( __FILE__ ) . 'classes/deactivate.php';
334
-		$deactivate = new Object_Sync_Sf_Deactivate( $wpdb, $version, $slug, $schedulable_classes );
332
+	private function deactivate($wpdb, $version, $slug, $schedulable_classes) {
333
+		require_once plugin_dir_path(__FILE__) . 'classes/deactivate.php';
334
+		$deactivate = new Object_Sync_Sf_Deactivate($wpdb, $version, $slug, $schedulable_classes);
335 335
 	}
336 336
 
337 337
 
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 	 * @return object
352 352
 	 *   Instance of Object_Sync_Sf_Salesforce_Push
353 353
 	 */
354
-	private function push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
355
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_push.php';
356
-		$push = new Object_Sync_Sf_Salesforce_Push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue );
354
+	private function push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
355
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_push.php';
356
+		$push = new Object_Sync_Sf_Salesforce_Push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue);
357 357
 		return $push;
358 358
 	}
359 359
 
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 	 * @return object
373 373
 	 *   Instance of Object_Sync_Sf_Salesforce_Pull
374 374
 	 */
375
-	private function pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
376
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_pull.php';
377
-		$pull = new Object_Sync_Sf_Salesforce_Pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue );
375
+	private function pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
376
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_pull.php';
377
+		$pull = new Object_Sync_Sf_Salesforce_Pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue);
378 378
 		return $pull;
379 379
 	}
380 380
 
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
 	*   Instance of Object_Sync_Sf_Admin
399 399
 	*
400 400
 	*/
401
-	private function load_admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) {
402
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/admin.php' );
403
-		$admin = new Object_Sync_Sf_Admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue );
404
-		add_action( 'admin_menu', array( $admin, 'create_admin_menu' ) );
405
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_and_styles' ) );
406
-		add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
407
-		add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 5 );
401
+	private function load_admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue) {
402
+		require_once(plugin_dir_path(__FILE__) . 'classes/admin.php');
403
+		$admin = new Object_Sync_Sf_Admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue);
404
+		add_action('admin_menu', array($admin, 'create_admin_menu'));
405
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts_and_styles'));
406
+		add_action('plugins_loaded', array($this, 'textdomain'));
407
+		add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 5);
408 408
 		return $admin;
409 409
 	}
410 410
 
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 	* @return array $links
417 417
 	*   These are the links that go with this plugin's entry
418 418
 	*/
419
-	public function plugin_action_links( $links, $file ) {
420
-		if ( plugin_basename( __FILE__ ) === $file ) {
421
-			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __( 'Settings', 'object-sync-for-salesforce' ) . '</a>';
419
+	public function plugin_action_links($links, $file) {
420
+		if (plugin_basename(__FILE__) === $file) {
421
+			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __('Settings', 'object-sync-for-salesforce') . '</a>';
422 422
 			// make the 'Settings' link appear first
423
-			array_unshift( $links, $settings );
423
+			array_unshift($links, $settings);
424 424
 		}
425 425
 		return $links;
426 426
 	}
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	public function admin_scripts_and_styles() {
435 435
 
436 436
 		// I think some developers might not want to bother with select2 or selectwoo, so let's allow that to be changeable
437
-		$select_library = apply_filters( 'object_sync_for_salesforce_select_library', 'selectwoo' );
437
+		$select_library = apply_filters('object_sync_for_salesforce_select_library', 'selectwoo');
438 438
 
439 439
 		/*
440 440
 		 * example to modify the select library
@@ -446,19 +446,19 @@  discard block
 block discarded – undo
446 446
 		 * }
447 447
 		*/
448 448
 
449
-		$javascript_dependencies = array( 'jquery' );
449
+		$javascript_dependencies = array('jquery');
450 450
 		$css_dependencies        = array();
451
-		if ( '' !== $select_library ) {
452
-			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 );
451
+		if ('' !== $select_library) {
452
+			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);
453 453
 			$javascript_dependencies[] = $select_library . 'js';
454 454
 
455
-			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' );
455
+			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 456
 			$css_dependencies[] = $select_library . 'css';
457 457
 		}
458 458
 
459
-		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 );
459
+		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 460
 
461
-		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' );
461
+		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 462
 	}
463 463
 
464 464
 	/**
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @return void
468 468
 	 */
469 469
 	public function textdomain() {
470
-		load_plugin_textdomain( 'object-sync-for-salesforce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
470
+		load_plugin_textdomain('object-sync-for-salesforce', false, dirname(plugin_basename(__FILE__)) . '/languages/');
471 471
 	}
472 472
 
473 473
 	/**
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 	*/
481 481
 	private function get_login_credentials() {
482 482
 
483
-		$consumer_key       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( 'object_sync_for_salesforce_consumer_key', '' );
484
-		$consumer_secret    = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option( 'object_sync_for_salesforce_consumer_secret', '' );
485
-		$callback_url       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option( 'object_sync_for_salesforce_callback_url', '' );
486
-		$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', '' );
487
-		$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', '' );
488
-		$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', '' );
489
-		$api_version        = defined( 'OBJECT_SYNC_SF_SALESFORCE_API_VERSION' ) ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option( 'object_sync_for_salesforce_api_version', '' );
483
+		$consumer_key       = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option('object_sync_for_salesforce_consumer_key', '');
484
+		$consumer_secret    = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option('object_sync_for_salesforce_consumer_secret', '');
485
+		$callback_url       = defined('OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL') ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option('object_sync_for_salesforce_callback_url', '');
486
+		$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', '');
487
+		$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', '');
488
+		$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', '');
489
+		$api_version        = defined('OBJECT_SYNC_SF_SALESFORCE_API_VERSION') ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option('object_sync_for_salesforce_api_version', '');
490 490
 
491 491
 		$login_credentials = array(
492 492
 			'consumer_key'     => $consumer_key,
Please login to merge, or discard this patch.