Passed
Pull Request — master (#195)
by Jonathan
03:37
created
classes/schedule.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 	protected $logging;
26 26
 
27 27
 	/**
28
-	* Constructor which sets up schedule and handler for when schedule runs
29
-	*
30
-	* @param object $wpdb
31
-	* @param string $version
32
-	* @param array $login_credentials
33
-	* @param string $slug
34
-	* @param object $wordpress
35
-	* @param object $salesforce
36
-	* @param object $mappings
37
-	* @param string $schedule_name
38
-	* @throws \Exception
39
-	*/
28
+	 * Constructor which sets up schedule and handler for when schedule runs
29
+	 *
30
+	 * @param object $wpdb
31
+	 * @param string $version
32
+	 * @param array $login_credentials
33
+	 * @param string $slug
34
+	 * @param object $wordpress
35
+	 * @param object $salesforce
36
+	 * @param object $mappings
37
+	 * @param string $schedule_name
38
+	 * @throws \Exception
39
+	 */
40 40
 
41 41
 	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $schedule_name, $logging, $schedulable_classes ) {
42 42
 
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Create the actions to run
64
-	*
65
-	*/
63
+	 * Create the actions to run
64
+	 *
65
+	 */
66 66
 	public function add_actions() {
67 67
 
68 68
 		// create a recurring action for each schedulable item
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 	}
104 104
 
105 105
 	/**
106
-	* Convert the schedule frequency from the admin settings into an array
107
-	* interval must be in seconds for the class to use it
108
-	*
109
-	*/
106
+	 * Convert the schedule frequency from the admin settings into an array
107
+	 * interval must be in seconds for the class to use it
108
+	 *
109
+	 */
110 110
 	public function set_schedule_frequency( $schedules ) {
111 111
 
112 112
 		// create an option in the core schedules array for each one the plugin defines
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 
146 146
 	/**
147
-	* Convert the schedule frequency from the admin settings into an array
148
-	* interval must be in seconds for the class to use it
149
-	*
150
-	*/
147
+	 * Convert the schedule frequency from the admin settings into an array
148
+	 * interval must be in seconds for the class to use it
149
+	 *
150
+	 */
151 151
 	public function get_schedule_frequency_key( $name = '' ) {
152 152
 
153 153
 		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Convert the schedule frequency from the admin settings into seconds
178
-	*
179
-	*/
177
+	 * Convert the schedule frequency from the admin settings into seconds
178
+	 *
179
+	 */
180 180
 	public function get_schedule_frequency_seconds( $name = '' ) {
181 181
 
182 182
 		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	* @throws \Exception
39 39
 	*/
40 40
 
41
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $schedule_name, $logging, $schedulable_classes ) {
41
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $schedule_name, $logging, $schedulable_classes) {
42 42
 
43 43
 		$this->wpdb                = $wpdb;
44 44
 		$this->version             = $version;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 		//$this->add_actions();
57 57
 		//add_action( $this->schedule_name, array( $this, 'maybe_handle' ) ); // run the handle method
58
-		add_action( 'init', array( $this, 'add_actions' ) );
58
+		add_action('init', array($this, 'add_actions'));
59 59
 
60 60
 	}
61 61
 
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 	public function add_actions() {
67 67
 
68 68
 		// create a recurring action for each schedulable item
69
-		foreach ( $this->schedulable_classes as $key => $value ) {
69
+		foreach ($this->schedulable_classes as $key => $value) {
70 70
 
71
-			$schedule_number = absint( get_option( 'object_sync_for_salesforce_' . $key . '_schedule_number', '' ) );
72
-			$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $key . '_schedule_unit', '' );
71
+			$schedule_number = absint(get_option('object_sync_for_salesforce_' . $key . '_schedule_number', ''));
72
+			$schedule_unit   = get_option('object_sync_for_salesforce_' . $key . '_schedule_unit', '');
73 73
 
74
-			switch ( $schedule_unit ) {
74
+			switch ($schedule_unit) {
75 75
 				case 'minutes':
76 76
 					$seconds = 60;
77 77
 					break;
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 
88 88
 			$key = $schedule_unit . '_' . $schedule_number;
89 89
 
90
-			if ( isset( $value['initializer'] ) ) {
90
+			if (isset($value['initializer'])) {
91 91
 
92
-				$time      = current_time( 'timestamp' );
92
+				$time = current_time('timestamp');
93 93
 				//$hook      = $value['class']->$value['initializer'];
94 94
 				$hook = $value['class'] . '->' . $value['initializer'];
95 95
 				//echo 'hook is ' . $hook;
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 	* interval must be in seconds for the class to use it
108 108
 	*
109 109
 	*/
110
-	public function set_schedule_frequency( $schedules ) {
110
+	public function set_schedule_frequency($schedules) {
111 111
 
112 112
 		// create an option in the core schedules array for each one the plugin defines
113
-		foreach ( $this->schedulable_classes as $key => $value ) {
114
-			$schedule_number = absint( get_option( 'object_sync_for_salesforce_' . $key . '_schedule_number', '' ) );
115
-			$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $key . '_schedule_unit', '' );
113
+		foreach ($this->schedulable_classes as $key => $value) {
114
+			$schedule_number = absint(get_option('object_sync_for_salesforce_' . $key . '_schedule_number', ''));
115
+			$schedule_unit   = get_option('object_sync_for_salesforce_' . $key . '_schedule_unit', '');
116 116
 
117
-			switch ( $schedule_unit ) {
117
+			switch ($schedule_unit) {
118 118
 				case 'minutes':
119 119
 					$seconds = 60;
120 120
 					break;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 			$key = $schedule_unit . '_' . $schedule_number;
132 132
 
133
-			$schedules[ $key ] = array(
133
+			$schedules[$key] = array(
134 134
 				'interval' => $seconds * $schedule_number,
135 135
 				'display'  => 'Every ' . $schedule_number . ' ' . $schedule_unit,
136 136
 			);
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	* interval must be in seconds for the class to use it
149 149
 	*
150 150
 	*/
151
-	public function get_schedule_frequency_key( $name = '' ) {
151
+	public function get_schedule_frequency_key($name = '') {
152 152
 
153
-		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
154
-		$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_unit', '' );
153
+		$schedule_number = get_option('object_sync_for_salesforce_' . $name . '_schedule_number', '');
154
+		$schedule_unit   = get_option('object_sync_for_salesforce_' . $name . '_schedule_unit', '');
155 155
 
156
-		switch ( $schedule_unit ) {
156
+		switch ($schedule_unit) {
157 157
 			case 'minutes':
158 158
 				$seconds = 60;
159 159
 				break;
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
 	* Convert the schedule frequency from the admin settings into seconds
178 178
 	*
179 179
 	*/
180
-	public function get_schedule_frequency_seconds( $name = '' ) {
180
+	public function get_schedule_frequency_seconds($name = '') {
181 181
 
182
-		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
183
-		$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_unit', '' );
182
+		$schedule_number = get_option('object_sync_for_salesforce_' . $name . '_schedule_number', '');
183
+		$schedule_unit   = get_option('object_sync_for_salesforce_' . $name . '_schedule_unit', '');
184 184
 
185
-		switch ( $schedule_unit ) {
185
+		switch ($schedule_unit) {
186 186
 			case 'minutes':
187 187
 				$seconds = 60;
188 188
 				break;
@@ -208,18 +208,18 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @return void
210 210
 	 */
211
-	public function use_schedule( $name = '' ) {
211
+	public function use_schedule($name = '') {
212 212
 
213
-		if ( '' !== $name ) {
213
+		if ('' !== $name) {
214 214
 			$schedule_name = $name;
215 215
 		} else {
216 216
 			$schedule_name = $this->schedule_name;
217 217
 		}
218 218
 
219
-		$schedule_frequency = $this->get_schedule_frequency_key( $name );
219
+		$schedule_frequency = $this->get_schedule_frequency_key($name);
220 220
 
221
-		if ( ! wp_next_scheduled( $schedule_name ) ) {
222
-			wp_schedule_event( time(), $schedule_frequency, $schedule_name );
221
+		if ( ! wp_next_scheduled($schedule_name)) {
222
+			wp_schedule_event(time(), $schedule_frequency, $schedule_name);
223 223
 		}
224 224
 
225 225
 	}
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @return mixed
238 238
 	 */
239
-	protected function task( $data ) {
240
-		if ( is_array( $this->schedulable_classes[ $this->schedule_name ] ) ) {
241
-			$schedule = $this->schedulable_classes[ $this->schedule_name ];
242
-			if ( isset( $schedule['class'] ) ) {
243
-				$class  = new $schedule['class']( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes );
239
+	protected function task($data) {
240
+		if (is_array($this->schedulable_classes[$this->schedule_name])) {
241
+			$schedule = $this->schedulable_classes[$this->schedule_name];
242
+			if (isset($schedule['class'])) {
243
+				$class  = new $schedule['class']($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes);
244 244
 				$method = $schedule['callback'];
245
-				$task   = $class->$method( $data['object_type'], $data['object'], $data['mapping'], $data['sf_sync_trigger'] );
245
+				$task   = $class->$method($data['object_type'], $data['object'], $data['mapping'], $data['sf_sync_trigger']);
246 246
 			}
247 247
 		}
248 248
 		return false;
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 	 * @return $data
259 259
 	 */
260 260
 	protected function check_for_data() {
261
-		if ( is_array( $this->schedulable_classes[ $this->schedule_name ] ) ) {
262
-			$schedule = $this->schedulable_classes[ $this->schedule_name ];
263
-			if ( isset( $schedule['class'] ) ) {
264
-				$class  = new $schedule['class']( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes );
261
+		if (is_array($this->schedulable_classes[$this->schedule_name])) {
262
+			$schedule = $this->schedulable_classes[$this->schedule_name];
263
+			if (isset($schedule['class'])) {
264
+				$class  = new $schedule['class']($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes);
265 265
 				$method = $schedule['initializer'];
266 266
 				$task   = $class->$method();
267 267
 			}
268 268
 		}
269 269
 		// we have checked for data and it's in the queue if it exists
270 270
 		// now run maybe_handle again to see if it nees to be processed
271
-		$this->maybe_handle( true );
271
+		$this->maybe_handle(true);
272 272
 	}
273 273
 
274 274
 	/**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * Checks whether data exists within the queue and that
278 278
 	 * the process is not already running.
279 279
 	 */
280
-	public function maybe_handle( $already_checked = false, $ajax = false ) {
281
-		if ( $this->is_process_running() ) {
280
+	public function maybe_handle($already_checked = false, $ajax = false) {
281
+		if ($this->is_process_running()) {
282 282
 			// Background process already running.
283 283
 			wp_die();
284 284
 		}
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
 		// it should call its corresponding class method that saves data to the queue
288 288
 		// it should then run maybe_handle() again
289 289
 
290
-		$check_for_data_first = isset( $this->schedulable_classes[ $this->schedule_name ]['initializer'] ) ? true : false;
290
+		$check_for_data_first = isset($this->schedulable_classes[$this->schedule_name]['initializer']) ? true : false;
291 291
 
292
-		if ( false === $already_checked && true === $check_for_data_first ) {
292
+		if (false === $already_checked && true === $check_for_data_first) {
293 293
 			$this->check_for_data();
294 294
 		}
295 295
 
296
-		if ( $this->is_queue_empty() ) {
296
+		if ($this->is_queue_empty()) {
297 297
 			// No data to process.
298 298
 			wp_die();
299 299
 		}
300 300
 
301
-		if ( true === $ajax ) {
302
-			check_ajax_referer( $this->identifier, 'nonce' );
301
+		if (true === $ajax) {
302
+			check_ajax_referer($this->identifier, 'nonce');
303 303
 		}
304 304
 
305 305
 		$this->handle();
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * This is modeled off the cancel_process method in wp-background-process but that one doesn't seem to work when we need to specify the queue name
313 313
 	 */
314
-	public function cancel_by_name( $name ) {
315
-		if ( ! isset( $name ) ) {
314
+	public function cancel_by_name($name) {
315
+		if ( ! isset($name)) {
316 316
 			$name = $this->identifier . '_cron';
317 317
 		}
318
-		if ( ! $this->is_queue_empty() ) {
319
-			while ( $this->count_queue_items() > 0 ) {
318
+		if ( ! $this->is_queue_empty()) {
319
+			while ($this->count_queue_items() > 0) {
320 320
 				$batch = $this->get_batch();
321
-				$this->delete( $batch->key );
322
-				wp_clear_scheduled_hook( $name );
321
+				$this->delete($batch->key);
322
+				wp_clear_scheduled_hook($name);
323 323
 			}
324 324
 		}
325 325
 	}
@@ -330,28 +330,28 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return bool
332 332
 	 */
333
-	public function count_queue_items( $schedule_name = '' ) {
333
+	public function count_queue_items($schedule_name = '') {
334 334
 		$wpdb = $this->wpdb;
335 335
 
336 336
 		$table  = $wpdb->options;
337 337
 		$column = 'option_name';
338 338
 
339
-		if ( is_multisite() ) {
339
+		if (is_multisite()) {
340 340
 			$table  = $wpdb->sitemeta;
341 341
 			$column = 'meta_key';
342 342
 		}
343 343
 
344
-		if ( '' === $schedule_name ) {
344
+		if ('' === $schedule_name) {
345 345
 			$key = $this->identifier . '_batch_%';
346 346
 		} else {
347 347
 			$key = $schedule_name . '_batch_%';
348 348
 		}
349 349
 
350
-		$count = $wpdb->get_var( $wpdb->prepare( "
350
+		$count = $wpdb->get_var($wpdb->prepare("
351 351
 			SELECT COUNT(*)
352 352
 			FROM {$table}
353 353
 			WHERE {$column} LIKE %s
354
-		", $key ) );
354
+		", $key));
355 355
 
356 356
 		return $count;
357 357
 	}
Please login to merge, or discard this patch.
classes/salesforce_mapping.php 1 patch
Spacing   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param object $logging Object_Sync_Sf_Logging.
61 61
 	 * @throws \Exception
62 62
 	 */
63
-	public function __construct( $wpdb, $version, $slug, $logging ) {
63
+	public function __construct($wpdb, $version, $slug, $logging) {
64 64
 		$this->wpdb    = $wpdb;
65 65
 		$this->version = $version;
66 66
 		$this->slug    = $slug;
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 		$this->sync_sf_delete        = 0x0020;
84 84
 
85 85
 		// Define which events are initialized by which system.
86
-		$this->wordpress_events  = array( $this->sync_wordpress_create, $this->sync_wordpress_update, $this->sync_wordpress_delete );
87
-		$this->salesforce_events = array( $this->sync_sf_create, $this->sync_sf_update, $this->sync_sf_delete );
86
+		$this->wordpress_events  = array($this->sync_wordpress_create, $this->sync_wordpress_update, $this->sync_wordpress_delete);
87
+		$this->salesforce_events = array($this->sync_sf_create, $this->sync_sf_update, $this->sync_sf_delete);
88 88
 
89 89
 		// Constants for the directions to map things.
90 90
 		$this->direction_wordpress_sf = 'wp_sf';
91 91
 		$this->direction_sf_wordpress = 'sf_wp';
92 92
 		$this->direction_sync         = 'sync';
93 93
 
94
-		$this->direction_wordpress  = array( $this->direction_wordpress_sf, $this->direction_sync );
95
-		$this->direction_salesforce = array( $this->direction_sf_wordpress, $this->direction_sync );
94
+		$this->direction_wordpress  = array($this->direction_wordpress_sf, $this->direction_sync);
95
+		$this->direction_salesforce = array($this->direction_sf_wordpress, $this->direction_sync);
96 96
 
97 97
 		// This is used when we map a record with default or Master.
98 98
 		$this->salesforce_default_record_type = 'default';
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 		// Salesforce has multipicklists and they have a delimiter.
101 101
 		$this->array_delimiter = ';';
102 102
 		// What data types in Salesforce should be an array?
103
-		$this->array_types_from_salesforce = array( 'multipicklist' );
103
+		$this->array_types_from_salesforce = array('multipicklist');
104 104
 		// What data types in Salesforce should be a date field?
105
-		$this->date_types_from_salesforce = array( 'date', 'datetime' );
105
+		$this->date_types_from_salesforce = array('date', 'datetime');
106 106
 		// What data types in Salesforce should be an integer?
107
-		$this->int_types_from_salesforce = array( 'integer', 'boolean' );
107
+		$this->int_types_from_salesforce = array('integer', 'boolean');
108 108
 
109 109
 		// Max length for a mapping field.
110 110
 		$this->name_length = 128;
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 	 * @param array $salesforce_fields The fields for the Salesforce side of the mapping.
124 124
 	 * @throws \Exception
125 125
 	 */
126
-	public function create_fieldmap( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
127
-		$data = $this->setup_fieldmap_data( $posted, $wordpress_fields, $salesforce_fields );
128
-		if ( version_compare( $this->version, '1.2.5', '>=' ) ) {
126
+	public function create_fieldmap($posted = array(), $wordpress_fields = array(), $salesforce_fields = array()) {
127
+		$data = $this->setup_fieldmap_data($posted, $wordpress_fields, $salesforce_fields);
128
+		if (version_compare($this->version, '1.2.5', '>=')) {
129 129
 			$data['version'] = $this->version;
130 130
 		}
131
-		$insert = $this->wpdb->insert( $this->fieldmap_table, $data );
132
-		if ( 1 === $insert ) {
131
+		$insert = $this->wpdb->insert($this->fieldmap_table, $data);
132
+		if (1 === $insert) {
133 133
 			return $this->wpdb->insert_id;
134 134
 		} else {
135 135
 			return false;
@@ -145,29 +145,29 @@  discard block
 block discarded – undo
145 145
 	 * @return Array $map a single mapping or $mappings, an array of mappings.
146 146
 	 * @throws \Exception
147 147
 	 */
148
-	public function get_fieldmaps( $id = null, $conditions = array(), $reset = false ) {
148
+	public function get_fieldmaps($id = null, $conditions = array(), $reset = false) {
149 149
 		$table = $this->fieldmap_table;
150
-		if ( null !== $id ) { // get one fieldmap.
151
-			$map                                    = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );
152
-			$map['salesforce_record_types_allowed'] = maybe_unserialize( $map['salesforce_record_types_allowed'] );
150
+		if (null !== $id) { // get one fieldmap.
151
+			$map                                    = $this->wpdb->get_row('SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A);
152
+			$map['salesforce_record_types_allowed'] = maybe_unserialize($map['salesforce_record_types_allowed']);
153 153
 
154
-			$map['fields']        = maybe_unserialize( $map['fields'] );
155
-			$map['sync_triggers'] = maybe_unserialize( $map['sync_triggers'] );
154
+			$map['fields']        = maybe_unserialize($map['fields']);
155
+			$map['sync_triggers'] = maybe_unserialize($map['sync_triggers']);
156 156
 			return $map;
157
-		} elseif ( ! empty( $conditions ) ) { // get multiple but with a limitation.
157
+		} elseif ( ! empty($conditions)) { // get multiple but with a limitation.
158 158
 			$mappings    = array();
159 159
 			$record_type = '';
160 160
 
161 161
 			// Assemble the SQL.
162
-			if ( ! empty( $conditions ) ) {
162
+			if ( ! empty($conditions)) {
163 163
 				$where = ' WHERE ';
164 164
 				$i     = 0;
165
-				foreach ( $conditions as $key => $value ) {
166
-					if ( 'salesforce_record_type' === $key ) {
167
-						$record_type = sanitize_text_field( $value );
165
+				foreach ($conditions as $key => $value) {
166
+					if ('salesforce_record_type' === $key) {
167
+						$record_type = sanitize_text_field($value);
168 168
 					} else {
169 169
 						$i++;
170
-						if ( $i > 1 ) {
170
+						if ($i > 1) {
171 171
 							$where .= ' AND ';
172 172
 						}
173 173
 						$where .= '`' . $key . '` = "' . $value . '"';
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 				$where = '';
178 178
 			}
179 179
 
180
-			$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . ' ORDER BY `weight`', ARRAY_A );
180
+			$mappings = $this->wpdb->get_results('SELECT * FROM ' . $table . $where . ' ORDER BY `weight`', ARRAY_A);
181 181
 
182
-			if ( ! empty( $mappings ) ) {
183
-				$mappings = $this->prepare_fieldmap_data( $mappings, $record_type );
182
+			if ( ! empty($mappings)) {
183
+				$mappings = $this->prepare_fieldmap_data($mappings, $record_type);
184 184
 			}
185 185
 
186 186
 			return $mappings;
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 		} else { // get all of the mappings. ALL THE MAPPINGS.
189 189
 
190 190
 			// if the version is greater than or equal to 1.2.5, the fieldmap table has a version column
191
-			if ( version_compare( $this->version, '1.2.5', '>=' ) ) {
192
-				$mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight`, `version` FROM $table", ARRAY_A );
191
+			if (version_compare($this->version, '1.2.5', '>=')) {
192
+				$mappings = $this->wpdb->get_results("SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight`, `version` FROM $table", ARRAY_A);
193 193
 			} else {
194
-				$mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight` FROM $table", ARRAY_A );
194
+				$mappings = $this->wpdb->get_results("SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight` FROM $table", ARRAY_A);
195 195
 			}
196 196
 
197
-			if ( ! empty( $mappings ) ) {
198
-				$mappings = $this->prepare_fieldmap_data( $mappings );
197
+			if ( ! empty($mappings)) {
198
+				$mappings = $this->prepare_fieldmap_data($mappings);
199 199
 			}
200 200
 
201 201
 			return $mappings;
@@ -211,29 +211,29 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return Array of mapped fields
213 213
 	 */
214
-	public function get_mapped_fields( $mapping, $directions = array() ) {
214
+	public function get_mapped_fields($mapping, $directions = array()) {
215 215
 		$mapped_fields = array();
216
-		foreach ( $mapping['fields'] as $fields ) {
217
-			if ( empty( $directions ) || in_array( $fields['direction'], $directions, true ) ) {
216
+		foreach ($mapping['fields'] as $fields) {
217
+			if (empty($directions) || in_array($fields['direction'], $directions, true)) {
218 218
 
219
-				if ( version_compare( $this->version, '1.2.0', '>=' ) && isset( $fields['salesforce_field']['name'] ) ) {
219
+				if (version_compare($this->version, '1.2.0', '>=') && isset($fields['salesforce_field']['name'])) {
220 220
 					$array_key = 'name';
221 221
 				} else {
222 222
 					$array_key = 'label';
223 223
 				}
224 224
 
225 225
 				// Some field map types (Relation) store a collection of SF objects.
226
-				if ( is_array( $fields['salesforce_field'] ) && ! isset( $fields['salesforce_field'][ $array_key ] ) ) {
227
-					foreach ( $fields['salesforce_field'] as $sf_field ) {
228
-						$mapped_fields[ $sf_field[ $array_key ] ] = $sf_field[ $array_key ];
226
+				if (is_array($fields['salesforce_field']) && ! isset($fields['salesforce_field'][$array_key])) {
227
+					foreach ($fields['salesforce_field'] as $sf_field) {
228
+						$mapped_fields[$sf_field[$array_key]] = $sf_field[$array_key];
229 229
 					}
230 230
 				} else { // The rest are just a name/value pair.
231
-					$mapped_fields[ $fields['salesforce_field'][ $array_key ] ] = $fields['salesforce_field'][ $array_key ];
231
+					$mapped_fields[$fields['salesforce_field'][$array_key]] = $fields['salesforce_field'][$array_key];
232 232
 				}
233 233
 			}
234 234
 		}
235 235
 
236
-		if ( ! empty( $this->get_mapped_record_types ) ) {
236
+		if ( ! empty($this->get_mapped_record_types)) {
237 237
 			$mapped_fields['RecordTypeId'] = 'RecordTypeId';
238 238
 		}
239 239
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @param Array $mapping A mapping from which we wish to estract the record type.
247 247
 	 * @return Array of mappings. Empty if the mapping's record type is default, else full of the record types.
248 248
 	 */
249
-	public function get_mapped_record_types( $mapping ) {
250
-		return $mapping['salesforce_record_type_default'] === $this->salesforce_default_record_type ? array() : array_filter( maybe_unserialize( $mapping['salesforce_record_types_allowed'] ) );
249
+	public function get_mapped_record_types($mapping) {
250
+		return $mapping['salesforce_record_type_default'] === $this->salesforce_default_record_type ? array() : array_filter(maybe_unserialize($mapping['salesforce_record_types_allowed']));
251 251
 	}
252 252
 
253 253
 	/**
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	 * @return $map
261 261
 	 * @throws \Exception
262 262
 	 */
263
-	public function update_fieldmap( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array(), $id = '' ) {
264
-		$data = $this->setup_fieldmap_data( $posted, $wordpress_fields, $salesforce_fields );
265
-		if ( version_compare( $this->version, '1.2.5', '>=' ) && ! isset( $data['updated'] ) ) {
263
+	public function update_fieldmap($posted = array(), $wordpress_fields = array(), $salesforce_fields = array(), $id = '') {
264
+		$data = $this->setup_fieldmap_data($posted, $wordpress_fields, $salesforce_fields);
265
+		if (version_compare($this->version, '1.2.5', '>=') && ! isset($data['updated'])) {
266 266
 			$data['version'] = $this->version;
267 267
 		}
268 268
 		$update = $this->wpdb->update(
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				'id' => $id,
273 273
 			)
274 274
 		);
275
-		if ( false === $update ) {
275
+		if (false === $update) {
276 276
 			return false;
277 277
 		} else {
278 278
 			return true;
@@ -288,76 +288,76 @@  discard block
 block discarded – undo
288 288
 	 * @param array $salesforce_fields The fields for the Salesforce side of the mapping.
289 289
 	 * @return $data
290 290
 	 */
291
-	private function setup_fieldmap_data( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
291
+	private function setup_fieldmap_data($posted = array(), $wordpress_fields = array(), $salesforce_fields = array()) {
292 292
 		$data = array(
293 293
 			'label'             => $posted['label'],
294
-			'name'              => sanitize_title( $posted['label'] ),
294
+			'name'              => sanitize_title($posted['label']),
295 295
 			'salesforce_object' => $posted['salesforce_object'],
296 296
 			'wordpress_object'  => $posted['wordpress_object'],
297 297
 		);
298
-		if ( isset( $posted['wordpress_field'] ) && is_array( $posted['wordpress_field'] ) && isset( $posted['salesforce_field'] ) && is_array( $posted['salesforce_field'] ) ) {
298
+		if (isset($posted['wordpress_field']) && is_array($posted['wordpress_field']) && isset($posted['salesforce_field']) && is_array($posted['salesforce_field'])) {
299 299
 			$setup['fields'] = array();
300
-			foreach ( $posted['wordpress_field'] as $key => $value ) {
301
-				$method_key = array_search( $value, array_column( $wordpress_fields, 'key' ), true );
302
-				if ( ! isset( $posted['direction'][ $key ] ) ) {
303
-					$posted['direction'][ $key ] = 'sync';
300
+			foreach ($posted['wordpress_field'] as $key => $value) {
301
+				$method_key = array_search($value, array_column($wordpress_fields, 'key'), true);
302
+				if ( ! isset($posted['direction'][$key])) {
303
+					$posted['direction'][$key] = 'sync';
304 304
 				}
305
-				if ( ! isset( $posted['is_prematch'][ $key ] ) ) {
306
-					$posted['is_prematch'][ $key ] = false;
305
+				if ( ! isset($posted['is_prematch'][$key])) {
306
+					$posted['is_prematch'][$key] = false;
307 307
 				}
308
-				if ( ! isset( $posted['is_key'][ $key ] ) ) {
309
-					$posted['is_key'][ $key ] = false;
308
+				if ( ! isset($posted['is_key'][$key])) {
309
+					$posted['is_key'][$key] = false;
310 310
 				}
311
-				if ( ! isset( $posted['is_delete'][ $key ] ) ) {
312
-					$posted['is_delete'][ $key ] = false;
311
+				if ( ! isset($posted['is_delete'][$key])) {
312
+					$posted['is_delete'][$key] = false;
313 313
 				}
314
-				if ( false === $posted['is_delete'][ $key ] ) {
314
+				if (false === $posted['is_delete'][$key]) {
315 315
 					// I think it's good to over-mention that updateable is really how the Salesforce api spells it.
316
-					$updateable_key = array_search( $posted['salesforce_field'][ $key ], array_column( $salesforce_fields, 'name' ), true );
316
+					$updateable_key = array_search($posted['salesforce_field'][$key], array_column($salesforce_fields, 'name'), true);
317 317
 
318 318
 					$salesforce_field_attributes = array();
319
-					foreach ( $salesforce_fields[ $updateable_key ] as $sf_key => $sf_value ) {
320
-						if ( isset( $sf_value ) && ! is_array( $sf_value ) ) {
321
-							$salesforce_field_attributes[ $sf_key ] = esc_attr( $sf_value );
322
-						} elseif ( ! empty( $sf_value ) && is_array( $sf_value ) ) {
323
-							$salesforce_field_attributes[ $sf_key ] = maybe_unserialize( $sf_value );
319
+					foreach ($salesforce_fields[$updateable_key] as $sf_key => $sf_value) {
320
+						if (isset($sf_value) && ! is_array($sf_value)) {
321
+							$salesforce_field_attributes[$sf_key] = esc_attr($sf_value);
322
+						} elseif ( ! empty($sf_value) && is_array($sf_value)) {
323
+							$salesforce_field_attributes[$sf_key] = maybe_unserialize($sf_value);
324 324
 						} else {
325
-							$salesforce_field_attributes[ $sf_key ] = '';
325
+							$salesforce_field_attributes[$sf_key] = '';
326 326
 						}
327 327
 					}
328 328
 
329
-					$setup['fields'][ $key ] = array(
329
+					$setup['fields'][$key] = array(
330 330
 						'wordpress_field'  => array(
331
-							'label'   => sanitize_text_field( $posted['wordpress_field'][ $key ] ),
332
-							'methods' => maybe_unserialize( $wordpress_fields[ $method_key ]['methods'] ),
333
-							'type'    => isset( $wordpress_fields[ $method_key ]['type'] ) ? sanitize_text_field( $wordpress_fields[ $method_key ]['type'] ) : 'text',
331
+							'label'   => sanitize_text_field($posted['wordpress_field'][$key]),
332
+							'methods' => maybe_unserialize($wordpress_fields[$method_key]['methods']),
333
+							'type'    => isset($wordpress_fields[$method_key]['type']) ? sanitize_text_field($wordpress_fields[$method_key]['type']) : 'text',
334 334
 						),
335 335
 						'salesforce_field' => $salesforce_field_attributes,
336
-						'is_prematch'      => sanitize_text_field( $posted['is_prematch'][ $key ] ),
337
-						'is_key'           => sanitize_text_field( $posted['is_key'][ $key ] ),
338
-						'direction'        => sanitize_text_field( $posted['direction'][ $key ] ),
339
-						'is_delete'        => sanitize_text_field( $posted['is_delete'][ $key ] ),
336
+						'is_prematch'      => sanitize_text_field($posted['is_prematch'][$key]),
337
+						'is_key'           => sanitize_text_field($posted['is_key'][$key]),
338
+						'direction'        => sanitize_text_field($posted['direction'][$key]),
339
+						'is_delete'        => sanitize_text_field($posted['is_delete'][$key]),
340 340
 					);
341 341
 
342 342
 					// If the WordPress key or the Salesforce key are blank, remove this incomplete mapping.
343 343
 					// This prevents https://github.com/MinnPost/object-sync-for-salesforce/issues/82 .
344 344
 					if (
345
-						empty( $setup['fields'][ $key ]['wordpress_field']['label'] )
345
+						empty($setup['fields'][$key]['wordpress_field']['label'])
346 346
 						||
347
-						empty( $setup['fields'][ $key ]['salesforce_field']['name'] )
347
+						empty($setup['fields'][$key]['salesforce_field']['name'])
348 348
 					) {
349
-						unset( $setup['fields'][ $key ] );
349
+						unset($setup['fields'][$key]);
350 350
 					}
351 351
 				}
352 352
 			} // End foreach() on WordPress fields.
353
-			$data['fields'] = maybe_serialize( $setup['fields'] );
354
-		} elseif ( isset( $posted['fields'] ) && is_array( $posted['fields'] ) ) {
353
+			$data['fields'] = maybe_serialize($setup['fields']);
354
+		} elseif (isset($posted['fields']) && is_array($posted['fields'])) {
355 355
 			// if $posted['fields'] is already set, use that
356
-			$data['fields'] = maybe_serialize( $posted['fields'] );
356
+			$data['fields'] = maybe_serialize($posted['fields']);
357 357
 		} // End if() WordPress fields are present.
358 358
 
359
-		if ( isset( $posted['salesforce_record_types_allowed'] ) ) {
360
-			$data['salesforce_record_types_allowed'] = maybe_serialize( $posted['salesforce_record_types_allowed'] );
359
+		if (isset($posted['salesforce_record_types_allowed'])) {
360
+			$data['salesforce_record_types_allowed'] = maybe_serialize($posted['salesforce_record_types_allowed']);
361 361
 		} else {
362 362
 			$data['salesforce_record_types_allowed'] = maybe_serialize(
363 363
 				array(
@@ -365,29 +365,29 @@  discard block
 block discarded – undo
365 365
 				)
366 366
 			);
367 367
 		}
368
-		if ( isset( $posted['salesforce_record_type_default'] ) ) {
368
+		if (isset($posted['salesforce_record_type_default'])) {
369 369
 			$data['salesforce_record_type_default'] = $posted['salesforce_record_type_default'];
370 370
 		} else {
371
-			$data['salesforce_record_type_default'] = maybe_serialize( $this->salesforce_default_record_type );
371
+			$data['salesforce_record_type_default'] = maybe_serialize($this->salesforce_default_record_type);
372 372
 		}
373
-		if ( isset( $posted['pull_trigger_field'] ) ) {
373
+		if (isset($posted['pull_trigger_field'])) {
374 374
 			$data['pull_trigger_field'] = $posted['pull_trigger_field'];
375 375
 		}
376
-		if ( isset( $posted['sync_triggers'] ) && is_array( $posted['sync_triggers'] ) ) {
376
+		if (isset($posted['sync_triggers']) && is_array($posted['sync_triggers'])) {
377 377
 			$setup['sync_triggers'] = array();
378
-			foreach ( $posted['sync_triggers'] as $key => $value ) {
379
-				$setup['sync_triggers'][ $key ] = esc_html( $posted['sync_triggers'][ $key ] );
378
+			foreach ($posted['sync_triggers'] as $key => $value) {
379
+				$setup['sync_triggers'][$key] = esc_html($posted['sync_triggers'][$key]);
380 380
 			}
381 381
 		} else {
382 382
 			$setup['sync_triggers'] = array();
383 383
 		}
384
-		$data['sync_triggers'] = maybe_serialize( $setup['sync_triggers'] );
385
-		if ( isset( $posted['pull_trigger_field'] ) ) {
384
+		$data['sync_triggers'] = maybe_serialize($setup['sync_triggers']);
385
+		if (isset($posted['pull_trigger_field'])) {
386 386
 			$data['pull_trigger_field'] = $posted['pull_trigger_field'];
387 387
 		}
388
-		$data['push_async']  = isset( $posted['push_async'] ) ? $posted['push_async'] : '';
389
-		$data['push_drafts'] = isset( $posted['push_drafts'] ) ? $posted['push_drafts'] : '';
390
-		$data['weight']      = isset( $posted['weight'] ) ? $posted['weight'] : '';
388
+		$data['push_async']  = isset($posted['push_async']) ? $posted['push_async'] : '';
389
+		$data['push_drafts'] = isset($posted['push_drafts']) ? $posted['push_drafts'] : '';
390
+		$data['weight']      = isset($posted['weight']) ? $posted['weight'] : '';
391 391
 		return $data;
392 392
 	}
393 393
 
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 	 * @return Boolean
399 399
 	 * @throws \Exception
400 400
 	 */
401
-	public function delete_fieldmap( $id = '' ) {
401
+	public function delete_fieldmap($id = '') {
402 402
 		$data   = array(
403 403
 			'id' => $id,
404 404
 		);
405
-		$delete = $this->wpdb->delete( $this->fieldmap_table, $data );
406
-		if ( 1 === $delete ) {
405
+		$delete = $this->wpdb->delete($this->fieldmap_table, $data);
406
+		if (1 === $delete) {
407 407
 			return true;
408 408
 		} else {
409 409
 			return false;
@@ -417,27 +417,27 @@  discard block
 block discarded – undo
417 417
 	 * @return false|Int of field mapping between WordPress and Salesforce objects
418 418
 	 * @throws \Exception
419 419
 	 */
420
-	public function create_object_map( $posted = array() ) {
421
-		$data            = $this->setup_object_map_data( $posted );
422
-		$data['created'] = current_time( 'mysql' );
420
+	public function create_object_map($posted = array()) {
421
+		$data            = $this->setup_object_map_data($posted);
422
+		$data['created'] = current_time('mysql');
423 423
 		// Check to see if we don't know the salesforce id and it is not a temporary id, or if this is pending.
424 424
 		// If it is using a temporary id, the map will get updated after it finishes running; it won't call this method unless there's an error, which we should log.
425
-		if ( substr( $data['salesforce_id'], 0, 7 ) !== 'tmp_sf_' || 'pending' === $data['action'] ) {
426
-			unset( $data['action'] );
427
-			$insert = $this->wpdb->insert( $this->object_map_table, $data );
425
+		if (substr($data['salesforce_id'], 0, 7) !== 'tmp_sf_' || 'pending' === $data['action']) {
426
+			unset($data['action']);
427
+			$insert = $this->wpdb->insert($this->object_map_table, $data);
428 428
 		} else {
429 429
 			$status = 'error';
430
-			if ( isset( $this->logging ) ) {
430
+			if (isset($this->logging)) {
431 431
 				$logging = $this->logging;
432
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
433
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
432
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
433
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
434 434
 			}
435 435
 			$logging->setup(
436 436
 				sprintf(
437 437
 					// translators: %1$s is the name of a WordPress object. %2$s is the id of that object.
438
-					esc_html__( 'Error Mapping: error caused by trying to map the WordPress %1$s with ID of %2$s to Salesforce ID starting with "tmp_sf_", which is invalid.', 'object-sync-for-salesforce' ),
439
-					esc_attr( $data['wordpress_object'] ),
440
-					absint( $data['wordpress_id'] )
438
+					esc_html__('Error Mapping: error caused by trying to map the WordPress %1$s with ID of %2$s to Salesforce ID starting with "tmp_sf_", which is invalid.', 'object-sync-for-salesforce'),
439
+					esc_attr($data['wordpress_object']),
440
+					absint($data['wordpress_id'])
441 441
 				),
442 442
 				'',
443 443
 				0,
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 			);
447 447
 			return false;
448 448
 		}
449
-		if ( 1 === $insert ) {
449
+		if (1 === $insert) {
450 450
 			return $this->wpdb->insert_id;
451
-		} elseif ( false !== strpos( $this->wpdb->last_error, 'Duplicate entry' ) ) {
452
-			$mapping = $this->load_by_salesforce( $data['salesforce_id'] );
451
+		} elseif (false !== strpos($this->wpdb->last_error, 'Duplicate entry')) {
452
+			$mapping = $this->load_by_salesforce($data['salesforce_id']);
453 453
 			$id      = $mapping['id'];
454 454
 			$status  = 'error';
455
-			if ( isset( $this->logging ) ) {
455
+			if (isset($this->logging)) {
456 456
 				$logging = $this->logging;
457
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
458
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
457
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
458
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
459 459
 			}
460 460
 			$logging->setup(
461 461
 				sprintf(
462 462
 					// translators: %1$s is the status word "Error". %1$s is the Id of a Salesforce object. %2$s is the ID of a mapping object.
463
-					esc_html__( 'Error: Mapping: there is already a WordPress object mapped to the Salesforce object %1$s and the mapping object ID is %2$s', 'object-sync-for-salesforce' ),
464
-					esc_attr( $data['salesforce_id'] ),
465
-					absint( $id )
463
+					esc_html__('Error: Mapping: there is already a WordPress object mapped to the Salesforce object %1$s and the mapping object ID is %2$s', 'object-sync-for-salesforce'),
464
+					esc_attr($data['salesforce_id']),
465
+					absint($id)
466 466
 				),
467 467
 				'',
468 468
 				0,
@@ -483,18 +483,18 @@  discard block
 block discarded – undo
483 483
 	 * @return $map or $mappings
484 484
 	 * @throws \Exception
485 485
 	 */
486
-	public function get_object_maps( $conditions = array(), $reset = false ) {
486
+	public function get_object_maps($conditions = array(), $reset = false) {
487 487
 		$table = $this->object_map_table;
488 488
 		$order = ' ORDER BY object_updated, created';
489
-		if ( ! empty( $conditions ) ) { // get multiple but with a limitation.
489
+		if ( ! empty($conditions)) { // get multiple but with a limitation.
490 490
 			$mappings = array();
491 491
 
492
-			if ( ! empty( $conditions ) ) {
492
+			if ( ! empty($conditions)) {
493 493
 				$where = ' WHERE ';
494 494
 				$i     = 0;
495
-				foreach ( $conditions as $key => $value ) {
495
+				foreach ($conditions as $key => $value) {
496 496
 					$i++;
497
-					if ( $i > 1 ) {
497
+					if ($i > 1) {
498 498
 						$where .= ' AND ';
499 499
 					}
500 500
 					$where .= '`' . $key . '` = "' . $value . '"';
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 				$where = '';
504 504
 			}
505 505
 
506
-			$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
507
-			if ( ! empty( $mappings ) && 1 === $this->wpdb->num_rows ) {
506
+			$mappings = $this->wpdb->get_results('SELECT * FROM ' . $table . $where . $order, ARRAY_A);
507
+			if ( ! empty($mappings) && 1 === $this->wpdb->num_rows) {
508 508
 				$mappings = $mappings[0];
509 509
 			}
510 510
 		} else { // get all of the mappings. ALL THE MAPPINGS.
511
-			$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $order, ARRAY_A );
512
-			if ( ! empty( $mappings ) && 1 === $this->wpdb->num_rows ) {
511
+			$mappings = $this->wpdb->get_results('SELECT * FROM ' . $table . $order, ARRAY_A);
512
+			if ( ! empty($mappings) && 1 === $this->wpdb->num_rows) {
513 513
 				$mappings = $mappings[0];
514 514
 			}
515 515
 		}
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 	 * @return $map
527 527
 	 * @throws \Exception
528 528
 	 */
529
-	public function update_object_map( $posted = array(), $id = '' ) {
530
-		$data = $this->setup_object_map_data( $posted );
531
-		if ( ! isset( $data['object_updated'] ) ) {
532
-			$data['object_updated'] = current_time( 'mysql' );
529
+	public function update_object_map($posted = array(), $id = '') {
530
+		$data = $this->setup_object_map_data($posted);
531
+		if ( ! isset($data['object_updated'])) {
532
+			$data['object_updated'] = current_time('mysql');
533 533
 		}
534 534
 		$update = $this->wpdb->update(
535 535
 			$this->object_map_table,
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 				'id' => $id,
539 539
 			)
540 540
 		);
541
-		if ( false === $update ) {
541
+		if (false === $update) {
542 542
 			return false;
543 543
 		} else {
544 544
 			return true;
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
 	 * @param array $posted It's $_POST.
552 552
 	 * @return $data Filtered array with only the keys that are in the object map database table. Strips out things from WordPress form if they're present.
553 553
 	 */
554
-	private function setup_object_map_data( $posted = array() ) {
555
-		$allowed_fields   = $this->wpdb->get_col( "DESC {$this->object_map_table}", 0 );
554
+	private function setup_object_map_data($posted = array()) {
555
+		$allowed_fields   = $this->wpdb->get_col("DESC {$this->object_map_table}", 0);
556 556
 		$allowed_fields[] = 'action'; // we use this in both directions even though it isn't in the database; we remove it from the array later if it is present
557 557
 
558
-		$data = array_intersect_key( $posted, array_flip( $allowed_fields ) );
558
+		$data = array_intersect_key($posted, array_flip($allowed_fields));
559 559
 		return $data;
560 560
 	}
561 561
 
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
 	 * @param array $id The ID of the object map row.
566 566
 	 * @throws \Exception
567 567
 	 */
568
-	public function delete_object_map( $id = '' ) {
568
+	public function delete_object_map($id = '') {
569 569
 		$data   = array(
570 570
 			'id' => $id,
571 571
 		);
572
-		$delete = $this->wpdb->delete( $this->object_map_table, $data );
573
-		if ( 1 === $delete ) {
572
+		$delete = $this->wpdb->delete($this->object_map_table, $data);
573
+		if (1 === $delete) {
574 574
 			return true;
575 575
 		} else {
576 576
 			return false;
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 	 * @param string $direction Whether this is part of a push or pull action
584 584
 	 * @return $id is a temporary string that will be replaced if the modification is successful
585 585
 	 */
586
-	public function generate_temporary_id( $direction ) {
587
-		if ( 'push' === $direction ) {
586
+	public function generate_temporary_id($direction) {
587
+		if ('push' === $direction) {
588 588
 			$prefix = 'tmp_sf_';
589
-		} elseif ( 'pull' === $direction ) {
589
+		} elseif ('pull' === $direction) {
590 590
 			$prefix = 'tmp_wp_';
591 591
 		}
592
-		$id = uniqid( $prefix, true );
592
+		$id = uniqid($prefix, true);
593 593
 		return $id;
594 594
 	}
595 595
 
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
 	 * @return SalesforceMappingObject
604 604
 	 *   The requested SalesforceMappingObject or FALSE if none was found.
605 605
 	 */
606
-	public function load_by_wordpress( $object_type, $object_id, $reset = false ) {
606
+	public function load_by_wordpress($object_type, $object_id, $reset = false) {
607 607
 		$conditions = array(
608 608
 			'wordpress_id'     => $object_id,
609 609
 			'wordpress_object' => $object_type,
610 610
 		);
611
-		return $this->get_object_maps( $conditions, $reset );
611
+		return $this->get_object_maps($conditions, $reset);
612 612
 	}
613 613
 
614 614
 	/**
@@ -620,24 +620,24 @@  discard block
 block discarded – undo
620 620
 	 * @return array $map
621 621
 	 *   The most recent fieldmap
622 622
 	 */
623
-	public function load_by_salesforce( $salesforce_id, $reset = false ) {
623
+	public function load_by_salesforce($salesforce_id, $reset = false) {
624 624
 		$conditions = array(
625 625
 			'salesforce_id' => $salesforce_id,
626 626
 		);
627 627
 
628
-		$map = $this->get_object_maps( $conditions, $reset );
628
+		$map = $this->get_object_maps($conditions, $reset);
629 629
 
630
-		if ( isset( $map[0] ) && is_array( $map[0] ) && count( $map ) > 1 ) {
630
+		if (isset($map[0]) && is_array($map[0]) && count($map) > 1) {
631 631
 			$status = 'notice';
632 632
 			$log    = '';
633 633
 			$log   .= 'Mapping: there is more than one mapped WordPress object for the Salesforce object ' . $salesforce_id . '. These WordPress IDs are: ';
634 634
 			$i      = 0;
635
-			foreach ( $map as $mapping ) {
635
+			foreach ($map as $mapping) {
636 636
 				$i++;
637
-				if ( isset( $mapping['wordpress_id'] ) ) {
637
+				if (isset($mapping['wordpress_id'])) {
638 638
 					$log .= 'object type: ' . $mapping['wordpress_object'] . ', id: ' . $mapping['wordpress_id'];
639 639
 				}
640
-				if ( count( $map ) !== $i ) {
640
+				if (count($map) !== $i) {
641 641
 					$log .= '; ';
642 642
 				} else {
643 643
 					$log .= '.';
@@ -645,16 +645,16 @@  discard block
 block discarded – undo
645 645
 			}
646 646
 			$map = $map[0];
647 647
 			// Create log entry for multiple maps.
648
-			if ( isset( $this->logging ) ) {
648
+			if (isset($this->logging)) {
649 649
 				$logging = $this->logging;
650
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
651
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
650
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
651
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
652 652
 			}
653 653
 			$logging->setup(
654 654
 				sprintf(
655 655
 					// translators: %1$s is the Id of a Salesforce object.
656
-					esc_html__( 'Notice: Mapping: there is more than one mapped WordPress object for the Salesforce object %2$s', 'object-sync-for-salesforce' ),
657
-					esc_attr( $salesforce_id )
656
+					esc_html__('Notice: Mapping: there is more than one mapped WordPress object for the Salesforce object %2$s', 'object-sync-for-salesforce'),
657
+					esc_attr($salesforce_id)
658 658
 				),
659 659
 				$log,
660 660
 				0,
@@ -677,20 +677,20 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return array Associative array of key value pairs.
679 679
 	 */
680
-	public function map_params( $mapping, $object, $trigger, $use_soap = false, $is_new = true ) {
680
+	public function map_params($mapping, $object, $trigger, $use_soap = false, $is_new = true) {
681 681
 
682 682
 		$params = array();
683 683
 
684
-		foreach ( $mapping['fields'] as $fieldmap ) {
684
+		foreach ($mapping['fields'] as $fieldmap) {
685 685
 
686
-			$wordpress_haystack  = array_values( $this->wordpress_events );
687
-			$salesforce_haystack = array_values( $this->salesforce_events );
686
+			$wordpress_haystack  = array_values($this->wordpress_events);
687
+			$salesforce_haystack = array_values($this->salesforce_events);
688 688
 
689
-			$fieldmap['wordpress_field']['methods'] = maybe_unserialize( $fieldmap['wordpress_field']['methods'] );
689
+			$fieldmap['wordpress_field']['methods'] = maybe_unserialize($fieldmap['wordpress_field']['methods']);
690 690
 
691 691
 			$wordpress_field = $fieldmap['wordpress_field']['label'];
692 692
 
693
-			if ( version_compare( $this->version, '1.2.0', '>=' ) && isset( $fieldmap['salesforce_field']['name'] ) ) {
693
+			if (version_compare($this->version, '1.2.0', '>=') && isset($fieldmap['salesforce_field']['name'])) {
694 694
 				$salesforce_field = $fieldmap['salesforce_field']['name'];
695 695
 				// Load the type of the Salesforce field. We can use this to handle Salesforce field value issues that come up based on what the field sends into WordPress or expects from WordPress.
696 696
 				$salesforce_field_type = $fieldmap['salesforce_field']['type'];
@@ -699,113 +699,113 @@  discard block
 block discarded – undo
699 699
 			}
700 700
 
701 701
 			// A WordPress event caused this.
702
-			if ( in_array( $trigger, array_values( $wordpress_haystack ), true ) ) {
702
+			if (in_array($trigger, array_values($wordpress_haystack), true)) {
703 703
 
704 704
 				// Is the field in WordPress an array, if we unserialize it? Salesforce wants it to be an imploded string.
705
-				if ( is_array( maybe_unserialize( $object[ $wordpress_field ] ) ) ) {
706
-					$object[ $wordpress_field ] = implode( $this->array_delimiter, $object[ $wordpress_field ] );
705
+				if (is_array(maybe_unserialize($object[$wordpress_field]))) {
706
+					$object[$wordpress_field] = implode($this->array_delimiter, $object[$wordpress_field]);
707 707
 				}
708 708
 
709
-				if ( isset( $salesforce_field_type ) ) {
709
+				if (isset($salesforce_field_type)) {
710 710
 					// Is the Salesforce field a date, and is the WordPress value a valid date?
711 711
 					// According to https://salesforce.stackexchange.com/questions/57032/date-format-with-salesforce-rest-api
712
-					if ( in_array( $salesforce_field_type, $this->date_types_from_salesforce ) ) {
713
-						if ( '' === $object[ $wordpress_field ] ) {
714
-							$object[ $wordpress_field ] = null;
712
+					if (in_array($salesforce_field_type, $this->date_types_from_salesforce)) {
713
+						if ('' === $object[$wordpress_field]) {
714
+							$object[$wordpress_field] = null;
715 715
 						} else {
716
-							if ( false !== strtotime( $object[ $wordpress_field ] ) ) {
717
-								$timestamp = strtotime( $object[ $wordpress_field ] );
716
+							if (false !== strtotime($object[$wordpress_field])) {
717
+								$timestamp = strtotime($object[$wordpress_field]);
718 718
 							} else {
719
-								$timestamp = $object[ $wordpress_field ];
719
+								$timestamp = $object[$wordpress_field];
720 720
 							}
721
-							if ( 'datetime' === $salesforce_field_type ) {
722
-								$object[ $wordpress_field ] = date_i18n( 'c', $timestamp );
721
+							if ('datetime' === $salesforce_field_type) {
722
+								$object[$wordpress_field] = date_i18n('c', $timestamp);
723 723
 							} else {
724
-								$object[ $wordpress_field ] = date_i18n( 'Y-m-d', $timestamp );
724
+								$object[$wordpress_field] = date_i18n('Y-m-d', $timestamp);
725 725
 							}
726 726
 						}
727 727
 					}
728 728
 
729 729
 					// Boolean SF fields only want real boolean values. NULL is also not allowed.
730
-					if ( 'boolean' === $salesforce_field_type ) {
731
-						$object[ $wordpress_field ] = (bool) $object[ $wordpress_field ];
730
+					if ('boolean' === $salesforce_field_type) {
731
+						$object[$wordpress_field] = (bool) $object[$wordpress_field];
732 732
 					}
733 733
 				}
734 734
 
735
-				$params[ $salesforce_field ] = $object[ $wordpress_field ];
735
+				$params[$salesforce_field] = $object[$wordpress_field];
736 736
 
737 737
 				// If the field is a key in Salesforce, remove it from $params to avoid upsert errors from Salesforce,
738 738
 				// but still put its name in the params array so we can check for it later.
739
-				if ( '1' === $fieldmap['is_key'] ) {
740
-					if ( ! $use_soap ) {
741
-						unset( $params[ $salesforce_field ] );
739
+				if ('1' === $fieldmap['is_key']) {
740
+					if ( ! $use_soap) {
741
+						unset($params[$salesforce_field]);
742 742
 					}
743 743
 					$params['key'] = array(
744 744
 						'salesforce_field' => $salesforce_field,
745 745
 						'wordpress_field'  => $wordpress_field,
746
-						'value'            => $object[ $wordpress_field ],
746
+						'value'            => $object[$wordpress_field],
747 747
 					);
748 748
 				}
749 749
 
750 750
 				// If the field is a prematch in Salesforce, put its name in the params array so we can check for it later.
751
-				if ( '1' === $fieldmap['is_prematch'] ) {
751
+				if ('1' === $fieldmap['is_prematch']) {
752 752
 					$params['prematch'] = array(
753 753
 						'salesforce_field' => $salesforce_field,
754 754
 						'wordpress_field'  => $wordpress_field,
755
-						'value'            => $object[ $wordpress_field ],
755
+						'value'            => $object[$wordpress_field],
756 756
 					);
757 757
 				}
758 758
 
759 759
 				// Skip fields that aren't being pushed to Salesforce.
760
-				if ( ! in_array( $fieldmap['direction'], array_values( $this->direction_wordpress ), true ) ) {
760
+				if ( ! in_array($fieldmap['direction'], array_values($this->direction_wordpress), true)) {
761 761
 					// The trigger is a WordPress trigger, but the fieldmap direction is not a WordPress direction.
762
-					unset( $params[ $salesforce_field ] );
762
+					unset($params[$salesforce_field]);
763 763
 				}
764 764
 
765 765
 				// I think it's good to over-mention that updateable is really how the Salesforce api spells it.
766 766
 				// Skip fields that aren't updateable when mapping params because Salesforce will error otherwise.
767 767
 				// This happens after dealing with the field types because key and prematch should still be available to the plugin, even if the values are not updateable in Salesforce.
768
-				if ( 1 !== (int) $fieldmap['salesforce_field']['updateable'] ) {
769
-					unset( $params[ $salesforce_field ] );
768
+				if (1 !== (int) $fieldmap['salesforce_field']['updateable']) {
769
+					unset($params[$salesforce_field]);
770 770
 				}
771 771
 
772 772
 				// we don't need a continue with the unset methods because there's no array being created down here
773
-			} elseif ( in_array( $trigger, $salesforce_haystack, true ) ) {
773
+			} elseif (in_array($trigger, $salesforce_haystack, true)) {
774 774
 
775 775
 				// A Salesforce event caused this.
776 776
 
777
-				if ( isset( $salesforce_field_type ) && ! is_null( $object[ $salesforce_field ] ) ) {
777
+				if (isset($salesforce_field_type) && ! is_null($object[$salesforce_field])) {
778 778
 					// Salesforce provides multipicklist values as a delimited string. If the
779 779
 					// destination field in WordPress accepts multiple values, explode the string into an array and then serialize it.
780
-					if ( in_array( $salesforce_field_type, $this->array_types_from_salesforce ) ) {
781
-						$object[ $salesforce_field ] = explode( $this->array_delimiter, $object[ $salesforce_field ] );
780
+					if (in_array($salesforce_field_type, $this->array_types_from_salesforce)) {
781
+						$object[$salesforce_field] = explode($this->array_delimiter, $object[$salesforce_field]);
782 782
 					}
783 783
 
784 784
 					// Handle specific data types from Salesforce.
785
-					switch ( $salesforce_field_type ) {
786
-						case ( in_array( $salesforce_field_type, $this->date_types_from_salesforce ) ):
787
-							$format = get_option( 'date_format', 'U' );
788
-							if ( isset( $fieldmap['wordpress_field']['type'] ) && 'datetime' === $fieldmap['wordpress_field']['type'] ) {
785
+					switch ($salesforce_field_type) {
786
+						case (in_array($salesforce_field_type, $this->date_types_from_salesforce)):
787
+							$format = get_option('date_format', 'U');
788
+							if (isset($fieldmap['wordpress_field']['type']) && 'datetime' === $fieldmap['wordpress_field']['type']) {
789 789
 								$format = 'Y-m-d H:i:s';
790 790
 							}
791
-							$object[ $salesforce_field ] = date_i18n( $format, strtotime( $object[ $salesforce_field ] ) );
791
+							$object[$salesforce_field] = date_i18n($format, strtotime($object[$salesforce_field]));
792 792
 							break;
793
-						case ( in_array( $salesforce_field_type, $this->int_types_from_salesforce ) ):
794
-							$object[ $salesforce_field ] = isset( $object[ $salesforce_field ] ) ? (int) $object[ $salesforce_field ] : 0;
793
+						case (in_array($salesforce_field_type, $this->int_types_from_salesforce)):
794
+							$object[$salesforce_field] = isset($object[$salesforce_field]) ? (int) $object[$salesforce_field] : 0;
795 795
 							break;
796 796
 						case 'text':
797
-							$object[ $salesforce_field ] = (string) $object[ $salesforce_field ];
797
+							$object[$salesforce_field] = (string) $object[$salesforce_field];
798 798
 							break;
799 799
 						case 'url':
800
-							$object[ $salesforce_field ] = esc_url_raw( $object[ $salesforce_field ] );
800
+							$object[$salesforce_field] = esc_url_raw($object[$salesforce_field]);
801 801
 							break;
802 802
 					}
803 803
 				}
804 804
 
805 805
 				// Make an array because we need to store the methods for each field as well.
806
-				if ( '' !== $object[ $salesforce_field ] ) {
807
-					$params[ $wordpress_field ]          = array();
808
-					$params[ $wordpress_field ]['value'] = $object[ $salesforce_field ];
806
+				if ('' !== $object[$salesforce_field]) {
807
+					$params[$wordpress_field]          = array();
808
+					$params[$wordpress_field]['value'] = $object[$salesforce_field];
809 809
 				} else {
810 810
 					// If we try to save certain fields with empty values, WordPress will silently start skipping stuff. This keeps that from happening.
811 811
 					continue;
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
 				// If the field is a key in Salesforce, disregard since this is caused by a Salesforce event. We're setting up data to be stored in WordPress here, and WordPress is not concerned with external key designations in Salesforce.
815 815
 
816 816
 				// If the field is a prematch in Salesforce, put its name in the params array so we can check for it later.
817
-				if ( '1' === $fieldmap['is_prematch'] ) {
817
+				if ('1' === $fieldmap['is_prematch']) {
818 818
 					$params['prematch'] = array(
819 819
 						'salesforce_field' => $salesforce_field,
820 820
 						'wordpress_field'  => $wordpress_field,
821
-						'value'            => $object[ $salesforce_field ],
821
+						'value'            => $object[$salesforce_field],
822 822
 						'method_read'      => $fieldmap['wordpress_field']['methods']['read'],
823 823
 						'method_create'    => $fieldmap['wordpress_field']['methods']['create'],
824 824
 						'method_update'    => $fieldmap['wordpress_field']['methods']['update'],
@@ -826,26 +826,26 @@  discard block
 block discarded – undo
826 826
 				}
827 827
 
828 828
 				// Skip fields that aren't being pulled from Salesforce.
829
-				if ( ! in_array( $fieldmap['direction'], array_values( $this->direction_salesforce ), true ) ) {
829
+				if ( ! in_array($fieldmap['direction'], array_values($this->direction_salesforce), true)) {
830 830
 					// The trigger is a Salesforce trigger, but the fieldmap direction is not a Salesforce direction.
831
-					unset( $params[ $wordpress_field ] );
831
+					unset($params[$wordpress_field]);
832 832
 					// we also need to continue here, so it doesn't create an empty array below for fields that are WordPress -> Salesforce only
833 833
 					continue;
834 834
 				}
835 835
 
836
-				switch ( $trigger ) {
836
+				switch ($trigger) {
837 837
 					case $this->sync_sf_create:
838
-						$params[ $wordpress_field ]['method_modify'] = $fieldmap['wordpress_field']['methods']['create'];
838
+						$params[$wordpress_field]['method_modify'] = $fieldmap['wordpress_field']['methods']['create'];
839 839
 						break;
840 840
 					case $this->sync_sf_update:
841
-						$params[ $wordpress_field ]['method_modify'] = $fieldmap['wordpress_field']['methods']['update'];
841
+						$params[$wordpress_field]['method_modify'] = $fieldmap['wordpress_field']['methods']['update'];
842 842
 						break;
843 843
 					case $this->sync_sf_delete:
844
-						$params[ $wordpress_field ]['method_modify'] = $fieldmap['wordpress_field']['methods']['delete'];
844
+						$params[$wordpress_field]['method_modify'] = $fieldmap['wordpress_field']['methods']['delete'];
845 845
 						break;
846 846
 				}
847 847
 
848
-				$params[ $wordpress_field ]['method_read'] = $fieldmap['wordpress_field']['methods']['read'];
848
+				$params[$wordpress_field]['method_read'] = $fieldmap['wordpress_field']['methods']['read'];
849 849
 
850 850
 			} // End if().
851 851
 		} // End foreach().
@@ -862,14 +862,14 @@  discard block
 block discarded – undo
862 862
 	 *
863 863
 	 * @return array $mappings Associative array of field maps ready to use
864 864
 	 */
865
-	private function prepare_fieldmap_data( $mappings, $record_type = '' ) {
866
-
867
-		foreach ( $mappings as $id => $mapping ) {
868
-			$mappings[ $id ]['salesforce_record_types_allowed'] = maybe_unserialize( $mapping['salesforce_record_types_allowed'] );
869
-			$mappings[ $id ]['fields']                          = maybe_unserialize( $mapping['fields'] );
870
-			$mappings[ $id ]['sync_triggers']                   = maybe_unserialize( $mapping['sync_triggers'] );
871
-			if ( '' !== $record_type && ! in_array( $record_type, $mappings[ $id ]['salesforce_record_types_allowed'], true ) ) {
872
-				unset( $mappings[ $id ] );
865
+	private function prepare_fieldmap_data($mappings, $record_type = '') {
866
+
867
+		foreach ($mappings as $id => $mapping) {
868
+			$mappings[$id]['salesforce_record_types_allowed'] = maybe_unserialize($mapping['salesforce_record_types_allowed']);
869
+			$mappings[$id]['fields']                          = maybe_unserialize($mapping['fields']);
870
+			$mappings[$id]['sync_triggers']                   = maybe_unserialize($mapping['sync_triggers']);
871
+			if ('' !== $record_type && ! in_array($record_type, $mappings[$id]['salesforce_record_types_allowed'], true)) {
872
+				unset($mappings[$id]);
873 873
 			}
874 874
 		}
875 875
 
@@ -885,12 +885,12 @@  discard block
 block discarded – undo
885 885
 	public function get_failed_object_maps() {
886 886
 		$table       = $this->object_map_table;
887 887
 		$errors      = array();
888
-		$push_errors = $this->wpdb->get_results( 'SELECT * FROM ' . $table . ' WHERE salesforce_id LIKE "tmp_sf_%"', ARRAY_A );
889
-		$pull_errors = $this->wpdb->get_results( 'SELECT * FROM ' . $table . ' WHERE wordpress_id LIKE "tmp_wp_%"', ARRAY_A );
890
-		if ( ! empty( $push_errors ) ) {
888
+		$push_errors = $this->wpdb->get_results('SELECT * FROM ' . $table . ' WHERE salesforce_id LIKE "tmp_sf_%"', ARRAY_A);
889
+		$pull_errors = $this->wpdb->get_results('SELECT * FROM ' . $table . ' WHERE wordpress_id LIKE "tmp_wp_%"', ARRAY_A);
890
+		if ( ! empty($push_errors)) {
891 891
 			$errors['push_errors'] = $push_errors;
892 892
 		}
893
-		if ( ! empty( $pull_errors ) ) {
893
+		if ( ! empty($pull_errors)) {
894 894
 			$errors['pull_errors'] = $pull_errors;
895 895
 		}
896 896
 		return $errors;
@@ -903,11 +903,11 @@  discard block
 block discarded – undo
903 903
 	 *
904 904
 	 * @return array $error Associative array of single row that failed to finish based on id
905 905
 	 */
906
-	public function get_failed_object_map( $id ) {
906
+	public function get_failed_object_map($id) {
907 907
 		$table     = $this->object_map_table;
908 908
 		$error     = array();
909
-		$error_row = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = "' . $id . '"', ARRAY_A );
910
-		if ( ! empty( $error_row ) ) {
909
+		$error_row = $this->wpdb->get_row('SELECT * FROM ' . $table . ' WHERE id = "' . $id . '"', ARRAY_A);
910
+		if ( ! empty($error_row)) {
911 911
 			$error = $error_row;
912 912
 		}
913 913
 		return $error;
Please login to merge, or discard this patch.
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,59 +573,59 @@  discard block
 block discarded – undo
573 573
 	* @return true or exit the method
574 574
 	*
575 575
 	*/
576
-	public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) {
576
+	public function salesforce_pull_process_records($object_type, $object, $mapping, $sf_sync_trigger) {
577 577
 
578 578
 		$sfapi = $this->salesforce['sfapi'];
579 579
 
580
-		if ( is_string( $object ) ) {
580
+		if (is_string($object)) {
581 581
 			$object_id = $object;
582
-			$object    = $sfapi->object_read( $object_type, $object_id )['data'];
582
+			$object    = $sfapi->object_read($object_type, $object_id)['data'];
583 583
 		}
584 584
 
585
-		if ( is_int( $mapping ) ) {
585
+		if (is_int($mapping)) {
586 586
 			$mapping_id = $mapping;
587
-			$mapping    = $this->mappings->get_fieldmaps( $mapping_id );
587
+			$mapping    = $this->mappings->get_fieldmaps($mapping_id);
588 588
 		}
589 589
 
590 590
 		$mapping_conditions = array(
591 591
 			'salesforce_object' => $object_type,
592 592
 		);
593 593
 
594
-		if ( isset( $object['RecordTypeId'] ) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type ) {
594
+		if (isset($object['RecordTypeId']) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type) {
595 595
 			// use this condition to filter the mappings, at that time
596 596
 			$mapping_conditions['salesforce_record_type'] = $object['RecordTypeId'];
597 597
 		}
598 598
 
599
-		$salesforce_mappings = $this->mappings->get_fieldmaps( null, $mapping_conditions );
599
+		$salesforce_mappings = $this->mappings->get_fieldmaps(null, $mapping_conditions);
600 600
 
601 601
 		// from drupal: if there is more than one mapping, don't throw exceptions
602
-		$hold_exceptions = count( $salesforce_mappings ) > 1;
602
+		$hold_exceptions = count($salesforce_mappings) > 1;
603 603
 		$exception       = false;
604 604
 
605 605
 		$frequencies = $this->queue->get_frequencies();
606
-		$seconds     = reset( $frequencies )['frequency'] + 60;
606
+		$seconds     = reset($frequencies)['frequency'] + 60;
607 607
 
608 608
 		$transients_to_delete = array();
609 609
 
610
-		foreach ( $salesforce_mappings as $salesforce_mapping ) {
610
+		foreach ($salesforce_mappings as $salesforce_mapping) {
611 611
 
612 612
 			// this returns the row that maps the individual Salesforce row to the individual WordPress row
613
-			if ( isset( $object['Id'] ) ) {
614
-				$mapping_object = $this->mappings->load_by_salesforce( $object['Id'] );
613
+			if (isset($object['Id'])) {
614
+				$mapping_object = $this->mappings->load_by_salesforce($object['Id']);
615 615
 			} else {
616 616
 				// if we don't have a Salesforce object id, we've got no business doing stuff in WordPress
617 617
 				$status = 'error';
618
-				if ( isset( $this->logging ) ) {
618
+				if (isset($this->logging)) {
619 619
 					$logging = $this->logging;
620
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
621
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
620
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
621
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
622 622
 				}
623 623
 
624
-				$title = sprintf( esc_html__( 'Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce' ) );
624
+				$title = sprintf(esc_html__('Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce'));
625 625
 
626 626
 				$logging->setup(
627 627
 					$title,
628
-					print_r( $object, true ), // log whatever we have in the event of this error, so print the array
628
+					print_r($object, true), // log whatever we have in the event of this error, so print the array
629 629
 					$sf_sync_trigger,
630 630
 					0, // parent id goes here but we don't have one, so make it 0
631 631
 					$status
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			// if it's not already connected (ie on create), the array will be empty
638 638
 
639 639
 			// hook to allow other plugins to define or alter the mapping object
640
-			$mapping_object = apply_filters( 'object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping );
640
+			$mapping_object = apply_filters('object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping);
641 641
 
642 642
 			// we already have the data from Salesforce at this point; we just need to work with it in WordPress
643 643
 			$synced_object = array(
@@ -646,58 +646,58 @@  discard block
 block discarded – undo
646 646
 				'mapping'           => $mapping,
647 647
 			);
648 648
 
649
-			$structure = $this->wordpress->get_wordpress_table_structure( $salesforce_mapping['wordpress_object'] );
649
+			$structure = $this->wordpress->get_wordpress_table_structure($salesforce_mapping['wordpress_object']);
650 650
 			$object_id = $structure['id_field'];
651 651
 
652 652
 			$op = '';
653 653
 
654 654
 			// are these objects already connected in WordPress?
655
-			if ( isset( $mapping_object['id'] ) ) {
655
+			if (isset($mapping_object['id'])) {
656 656
 				$is_new                      = false;
657 657
 				$mapping_object_id_transient = $mapping_object['id'];
658 658
 			} else {
659 659
 				// there is not a mapping object for this WordPress object id yet
660 660
 				// check for that transient with the currently pushing id
661 661
 				$is_new                      = true;
662
-				$mapping_object_id_transient = get_transient( 'salesforce_pushing_object_id' );
662
+				$mapping_object_id_transient = get_transient('salesforce_pushing_object_id');
663 663
 			}
664 664
 
665 665
 			// Drupal only does a salesforce_pull flag, but we might as well do push and pull because WordPress
666
-			$salesforce_pushing = (int) get_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
667
-			if ( 1 === $salesforce_pushing ) {
666
+			$salesforce_pushing = (int) get_transient('salesforce_pushing_' . $mapping_object_id_transient);
667
+			if (1 === $salesforce_pushing) {
668 668
 				$transients_to_delete[] = $mapping_object_id_transient;
669 669
 				continue;
670 670
 			}
671 671
 
672 672
 			// deleting mapped objects
673
-			if ( $sf_sync_trigger == $this->mappings->sync_sf_delete ) { // trigger is a bit operator
674
-				if ( isset( $mapping_object['id'] ) ) {
673
+			if ($sf_sync_trigger == $this->mappings->sync_sf_delete) { // trigger is a bit operator
674
+				if (isset($mapping_object['id'])) {
675 675
 
676
-					set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
677
-					set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
676
+					set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
677
+					set_transient('salesforce_pulling_object_id', $mapping_object['id']);
678 678
 
679 679
 					$op              = 'Delete';
680
-					$wordpress_check = $this->mappings->load_by_wordpress( $mapping_object['wordpress_object'], $mapping_object['wordpress_id'] );
681
-					if ( count( $wordpress_check ) === count( $wordpress_check, COUNT_RECURSIVE ) ) {
680
+					$wordpress_check = $this->mappings->load_by_wordpress($mapping_object['wordpress_object'], $mapping_object['wordpress_id']);
681
+					if (count($wordpress_check) === count($wordpress_check, COUNT_RECURSIVE)) {
682 682
 						try {
683
-							$result = $this->wordpress->object_delete( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'] );
684
-						} catch ( WordpressException $e ) {
683
+							$result = $this->wordpress->object_delete($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id']);
684
+						} catch (WordpressException $e) {
685 685
 							$status = 'error';
686 686
 							// create log entry for failed delete
687
-							if ( isset( $this->logging ) ) {
687
+							if (isset($this->logging)) {
688 688
 								$logging = $this->logging;
689
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
690
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
689
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
690
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
691 691
 							}
692 692
 
693 693
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
694
-							$title = sprintf( esc_html__( 'Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
695
-								esc_attr( $op ),
696
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
697
-								esc_attr( $object_id ),
698
-								esc_attr( $mapping_object['wordpress_id'] ),
699
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
700
-								esc_attr( $mapping_object['salesforce_id'] )
694
+							$title = sprintf(esc_html__('Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
695
+								esc_attr($op),
696
+								esc_attr($salesforce_mapping['wordpress_object']),
697
+								esc_attr($object_id),
698
+								esc_attr($mapping_object['wordpress_id']),
699
+								esc_attr($salesforce_mapping['salesforce_object']),
700
+								esc_attr($mapping_object['salesforce_id'])
701 701
 							);
702 702
 
703 703
 							$logging->setup(
@@ -708,38 +708,38 @@  discard block
 block discarded – undo
708 708
 								$status
709 709
 							);
710 710
 
711
-							if ( false === $hold_exceptions ) {
711
+							if (false === $hold_exceptions) {
712 712
 								throw $e;
713 713
 							}
714
-							if ( empty( $exception ) ) {
714
+							if (empty($exception)) {
715 715
 								$exception = $e;
716 716
 							} else {
717
-								$my_class  = get_class( $e );
718
-								$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
717
+								$my_class  = get_class($e);
718
+								$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
719 719
 							}
720 720
 
721 721
 							// hook for pull fail
722
-							do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
722
+							do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
723 723
 
724 724
 						} // End try().
725 725
 
726
-						if ( ! isset( $e ) ) {
726
+						if ( ! isset($e)) {
727 727
 							// create log entry for successful delete if the result had no errors
728 728
 							$status = 'success';
729
-							if ( isset( $this->logging ) ) {
729
+							if (isset($this->logging)) {
730 730
 								$logging = $this->logging;
731
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
732
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
731
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
732
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
733 733
 							}
734 734
 
735 735
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
736
-							$title = sprintf( esc_html__( 'Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
737
-								esc_attr( $op ),
738
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
739
-								esc_attr( $object_id ),
740
-								esc_attr( $mapping_object['wordpress_id'] ),
741
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
742
-								esc_attr( $mapping_object['salesforce_id'] )
736
+							$title = sprintf(esc_html__('Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
737
+								esc_attr($op),
738
+								esc_attr($salesforce_mapping['wordpress_object']),
739
+								esc_attr($object_id),
740
+								esc_attr($mapping_object['wordpress_id']),
741
+								esc_attr($salesforce_mapping['salesforce_object']),
742
+								esc_attr($mapping_object['salesforce_id'])
743 743
 							);
744 744
 
745 745
 							$logging->setup(
@@ -751,38 +751,38 @@  discard block
 block discarded – undo
751 751
 							);
752 752
 
753 753
 							// hook for pull success
754
-							do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
754
+							do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
755 755
 						}
756 756
 					} else {
757
-						$more_ids = sprintf( '<p>' . esc_html__( 'The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce' ) );
757
+						$more_ids = sprintf('<p>' . esc_html__('The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce'));
758 758
 						$i        = 0;
759
-						foreach ( $wordpress_check as $match ) {
759
+						foreach ($wordpress_check as $match) {
760 760
 							$i++;
761
-							$more_ids .= sprintf( $match['salesforce_id'] );
762
-							if ( count( $wordpress_check ) !== $i ) {
763
-								$more_ids .= sprintf( ', ' );
761
+							$more_ids .= sprintf($match['salesforce_id']);
762
+							if (count($wordpress_check) !== $i) {
763
+								$more_ids .= sprintf(', ');
764 764
 							} else {
765
-								$more_ids .= sprintf( '.</p>' );
765
+								$more_ids .= sprintf('.</p>');
766 766
 							}
767 767
 						}
768 768
 
769
-						$more_ids .= sprintf( '<p>' . esc_html__( 'The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce' ) . '</p>' );
769
+						$more_ids .= sprintf('<p>' . esc_html__('The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce') . '</p>');
770 770
 
771 771
 						$status = 'notice';
772
-						if ( isset( $this->logging ) ) {
772
+						if (isset($this->logging)) {
773 773
 							$logging = $this->logging;
774
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
775
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
774
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
775
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
776 776
 						}
777 777
 
778 778
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
779
-						$title = sprintf( esc_html__( 'Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce' ),
780
-							esc_attr( $op ),
781
-							esc_attr( $salesforce_mapping['wordpress_object'] ),
782
-							esc_attr( $object_id ),
783
-							esc_attr( $mapping_object['wordpress_id'] ),
784
-							esc_attr( $salesforce_mapping['salesforce_object'] ),
785
-							esc_attr( $mapping_object['salesforce_id'] )
779
+						$title = sprintf(esc_html__('Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce'),
780
+							esc_attr($op),
781
+							esc_attr($salesforce_mapping['wordpress_object']),
782
+							esc_attr($object_id),
783
+							esc_attr($mapping_object['wordpress_id']),
784
+							esc_attr($salesforce_mapping['salesforce_object']),
785
+							esc_attr($mapping_object['salesforce_id'])
786 786
 						);
787 787
 
788 788
 						$logging->setup(
@@ -796,27 +796,27 @@  discard block
 block discarded – undo
796 796
 
797 797
 					// delete the map row from WordPress after the WordPress row has been deleted
798 798
 					// we delete the map row even if the WordPress delete failed, because the Salesforce object is gone
799
-					$this->mappings->delete_object_map( $mapping_object['id'] );
799
+					$this->mappings->delete_object_map($mapping_object['id']);
800 800
 					// there is no map row if we end this if statement
801 801
 				} // End if().
802 802
 				return;
803 803
 			} // End if().
804 804
 
805 805
 			// map the Salesforce values to WordPress fields
806
-			$params = $this->mappings->map_params( $mapping, $object, $sf_sync_trigger, false, $is_new );
806
+			$params = $this->mappings->map_params($mapping, $object, $sf_sync_trigger, false, $is_new);
807 807
 
808 808
 			// hook to allow other plugins to modify the $params array
809 809
 			// use hook to map fields between the WordPress and Salesforce objects
810 810
 			// returns $params.
811
-			$params = apply_filters( 'object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new );
811
+			$params = apply_filters('object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new);
812 812
 
813 813
 			// if we don't get any params, there are no fields that should be sent to WordPress
814
-			if ( empty( $params ) ) {
814
+			if (empty($params)) {
815 815
 				return;
816 816
 			}
817 817
 
818 818
 			// if there is a prematch WordPress field - ie email - on the fieldmap object
819
-			if ( isset( $params['prematch'] ) && is_array( $params['prematch'] ) ) {
819
+			if (isset($params['prematch']) && is_array($params['prematch'])) {
820 820
 				$prematch_field_wordpress  = $params['prematch']['wordpress_field'];
821 821
 				$prematch_field_salesforce = $params['prematch']['salesforce_field'];
822 822
 				$prematch_value            = $params['prematch']['value'];
@@ -826,22 +826,22 @@  discard block
 block discarded – undo
826 826
 					'method_update' => $params['prematch']['method_update'],
827 827
 					'method_read'   => $params['prematch']['method_read'],
828 828
 				);
829
-				unset( $params['prematch'] );
829
+				unset($params['prematch']);
830 830
 			}
831 831
 
832 832
 			// if there is an external key field in Salesforce - ie a Mailchimp user id - on the fieldmap object, this should not affect how WordPress handles it so we have removed it from the pull parameters.
833 833
 
834 834
 			// methods to run the wp create or update operations
835 835
 
836
-			if ( true === $is_new ) {
836
+			if (true === $is_new) {
837 837
 
838 838
 				// setup SF record type. CampaignMember objects get their Campaign's type
839 839
 				// i am still a bit confused about this
840 840
 				// we should store this as a meta field on each object, if it meets these criteria
841 841
 				// we need to store the read/modify attributes because the field doesn't exist in the mapping
842
-				if ( $salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty( $params['RecordTypeId'] ) && ( 'CampaignMember' !== $salesforce_mapping['salesforce_object'] ) ) {
842
+				if ($salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty($params['RecordTypeId']) && ('CampaignMember' !== $salesforce_mapping['salesforce_object'])) {
843 843
 					$type = $salesforce_mapping['wordpress_object'];
844
-					if ( 'category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object'] ) {
844
+					if ('category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object']) {
845 845
 						$type = 'term';
846 846
 					}
847 847
 					$params['RecordTypeId'] = array(
@@ -859,24 +859,24 @@  discard block
 block discarded – undo
859 859
 					// returns a $salesforce_id.
860 860
 					// it should keep NULL if there is no match
861 861
 					// the function that calls this hook needs to check the mapping to make sure the WordPress object is the right type
862
-					$wordpress_id = apply_filters( 'object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull' );
862
+					$wordpress_id = apply_filters('object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull');
863 863
 
864 864
 					// hook to allow other plugins to do something right before WordPress data is saved
865 865
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
866
-					do_action( 'object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params );
866
+					do_action('object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params);
867 867
 
868
-					if ( isset( $prematch_field_salesforce ) || null !== $wordpress_id ) {
868
+					if (isset($prematch_field_salesforce) || null !== $wordpress_id) {
869 869
 
870 870
 						$op = 'Upsert';
871 871
 
872 872
 						// if either prematch criteria exists, make the values queryable
873
-						if ( isset( $prematch_field_salesforce ) ) {
873
+						if (isset($prematch_field_salesforce)) {
874 874
 							$upsert_key     = $prematch_field_wordpress;
875 875
 							$upsert_value   = $prematch_value;
876 876
 							$upsert_methods = $prematch_methods;
877 877
 						}
878 878
 
879
-						if ( null !== $wordpress_id ) {
879
+						if (null !== $wordpress_id) {
880 880
 							$upsert_key     = $object_id;
881 881
 							$upsert_value   = $wordpress_id;
882 882
 							$upsert_methods = array();
@@ -885,13 +885,13 @@  discard block
 block discarded – undo
885 885
 						// with the flag at the end, upsert returns a $wordpress_id only
886 886
 						// we can then check to see if it has a mapping object
887 887
 						// we should only do this if the above hook didn't already set the $wordpress_id
888
-						if ( null === $wordpress_id ) {
889
-							$wordpress_id = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true );
888
+						if (null === $wordpress_id) {
889
+							$wordpress_id = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true);
890 890
 						}
891 891
 
892 892
 						// find out if there is a mapping object for this WordPress object already
893 893
 						// don't do it if the WordPress id is 0.
894
-						if ( 0 !== $wordpress_id ) {
894
+						if (0 !== $wordpress_id) {
895 895
 							$mapping_object = $this->mappings->get_object_maps(
896 896
 								array(
897 897
 									'wordpress_id'     => $wordpress_id,
@@ -906,35 +906,35 @@  discard block
 block discarded – undo
906 906
 								)
907 907
 							);
908 908
 
909
-							if ( array() !== $mapping_object_debug ) {
909
+							if (array() !== $mapping_object_debug) {
910 910
 								// create log entry to warn about at least one id of 0
911 911
 								$status = 'error';
912
-								$title  = sprintf( esc_html__( 'Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce' ) );
912
+								$title  = sprintf(esc_html__('Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce'));
913 913
 
914
-								if ( 1 === count( $mapping_object_debug ) ) {
914
+								if (1 === count($mapping_object_debug)) {
915 915
 									// translators: placeholders are: 1) the mapping object row ID, 2) the name of the WordPress object, 3) the ID of the Salesforce object it was trying to map
916
-									$body = sprintf( esc_html__( 'There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce' ),
917
-										absint( $mapping_object_debug['id'] ),
918
-										esc_attr( $salesforce_mapping['wordpress_object'] ),
919
-										esc_attr( $mapping_object_debug['salesforce_id'] )
916
+									$body = sprintf(esc_html__('There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce'),
917
+										absint($mapping_object_debug['id']),
918
+										esc_attr($salesforce_mapping['wordpress_object']),
919
+										esc_attr($mapping_object_debug['salesforce_id'])
920 920
 									);
921 921
 								} else {
922
-									$body = sprintf( esc_html__( 'There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce' ) . '<ul>' );
923
-									foreach ( $mapping_object_debug as $mapping_object ) {
922
+									$body = sprintf(esc_html__('There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce') . '<ul>');
923
+									foreach ($mapping_object_debug as $mapping_object) {
924 924
 										// translators: placeholders are: 1) the mapping object row ID, 2) the ID of the Salesforce object, 3) the WordPress object type
925
-										$body .= sprintf( '<li>' . esc_html__( 'Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
926
-											absint( $mapping_object['id'] ),
927
-											esc_attr( $mapping_object['salesforce_id'] ),
928
-											esc_attr( $salesforce_mapping['wordpress_object'] )
925
+										$body .= sprintf('<li>' . esc_html__('Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce') . '</li>',
926
+											absint($mapping_object['id']),
927
+											esc_attr($mapping_object['salesforce_id']),
928
+											esc_attr($salesforce_mapping['wordpress_object'])
929 929
 										);
930 930
 									}
931
-									$body .= sprintf( '</ul>' );
931
+									$body .= sprintf('</ul>');
932 932
 								}
933 933
 
934
-								if ( isset( $this->logging ) ) {
934
+								if (isset($this->logging)) {
935 935
 									$logging = $this->logging;
936
-								} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
937
-									$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
936
+								} elseif (class_exists('Object_Sync_Sf_Logging')) {
937
+									$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
938 938
 								}
939 939
 								$parent = 0;
940 940
 								$logging->setup(
@@ -948,37 +948,37 @@  discard block
 block discarded – undo
948 948
 						} // End if().
949 949
 
950 950
 						// there is already a mapping object. don't change the WordPress data to match this new Salesforce record, but log it
951
-						if ( isset( $mapping_object['id'] ) ) {
951
+						if (isset($mapping_object['id'])) {
952 952
 							// set the transient so that salesforce_push doesn't start doing stuff, then return out of here
953
-							set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
954
-							set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
953
+							set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
954
+							set_transient('salesforce_pulling_object_id', $mapping_object['id']);
955 955
 							// create log entry to indicate that nothing happened
956 956
 							$status = 'notice';
957 957
 							// translators: placeholders are: 1) mapping object row id, 2) WordPress object tyoe, 3) individual WordPress item ID, 4) individual Salesforce item ID
958
-							$title = sprintf( esc_html__( 'Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce' ),
959
-								absint( $mapping_object['id'] ),
960
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
961
-								absint( $wordpress_id ),
962
-								esc_attr( $object['Id'] )
958
+							$title = sprintf(esc_html__('Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce'),
959
+								absint($mapping_object['id']),
960
+								esc_attr($salesforce_mapping['wordpress_object']),
961
+								absint($wordpress_id),
962
+								esc_attr($object['Id'])
963 963
 							);
964 964
 
965 965
 							// translators: placeholders are 1) WordPress object type, 2) field name for the WordPress id, 3) the WordPress id value, 4) the Salesforce object type, 5) the Salesforce object Id that was modified, 6) the mapping object row id
966
-							$body = sprintf( esc_html__( 'The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce' ),
967
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
968
-								esc_attr( $structure['id_field'] ),
969
-								absint( $wordpress_id ),
970
-								esc_attr( $mapping_object['salesforce_object'] ),
971
-								esc_attr( $object['Id'] ),
972
-								absint( $mapping_object['id'] )
966
+							$body = sprintf(esc_html__('The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce'),
967
+								esc_attr($salesforce_mapping['wordpress_object']),
968
+								esc_attr($structure['id_field']),
969
+								absint($wordpress_id),
970
+								esc_attr($mapping_object['salesforce_object']),
971
+								esc_attr($object['Id']),
972
+								absint($mapping_object['id'])
973 973
 							);
974 974
 
975
-							if ( isset( $this->logging ) ) {
975
+							if (isset($this->logging)) {
976 976
 								$logging = $this->logging;
977
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
978
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
977
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
978
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
979 979
 							}
980 980
 							// if we know the WordPress object id we can put it in there
981
-							if ( null !== $wordpress_id ) {
981
+							if (null !== $wordpress_id) {
982 982
 								$parent = $wordpress_id;
983 983
 							} else {
984 984
 								$parent = 0;
@@ -997,9 +997,9 @@  discard block
 block discarded – undo
997 997
 						// right here we should set the pulling transient
998 998
 						// this means we have to create the mapping object here as well, and update it with the correct IDs after successful response
999 999
 						// create the mapping object between the rows
1000
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
1001
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
1002
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
1000
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
1001
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
1002
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
1003 1003
 						$mapping_object = $this->mappings->get_object_maps(
1004 1004
 							array(
1005 1005
 								'id' => $mapping_object_id,
@@ -1008,50 +1008,50 @@  discard block
 block discarded – undo
1008 1008
 
1009 1009
 						// now we can upsert the object in wp if we've gotten to this point
1010 1010
 						// this command will either create or update the object
1011
-						$result = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'] );
1011
+						$result = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts']);
1012 1012
 
1013 1013
 					} else {
1014 1014
 						// No key or prematch field exists on this field map object, create a new object in WordPress.
1015 1015
 						$op                = 'Create';
1016
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
1017
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
1018
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
1016
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
1017
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
1018
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
1019 1019
 						$mapping_object = $this->mappings->get_object_maps(
1020 1020
 							array(
1021 1021
 								'id' => $mapping_object_id,
1022 1022
 							)
1023 1023
 						);
1024 1024
 
1025
-						$result = $this->wordpress->object_create( $salesforce_mapping['wordpress_object'], $params );
1025
+						$result = $this->wordpress->object_create($salesforce_mapping['wordpress_object'], $params);
1026 1026
 					} // End if().
1027
-				} catch ( WordpressException $e ) {
1027
+				} catch (WordpressException $e) {
1028 1028
 					// create log entry for failed create or upsert
1029 1029
 					$status = 'error';
1030 1030
 
1031 1031
 					// translators: placeholders are: 1) what operation is happening, and 2) the name of the WordPress object
1032
-					$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
1033
-						esc_attr( $op ),
1034
-						esc_attr( $salesforce_mapping['wordpress_object'] )
1032
+					$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
1033
+						esc_attr($op),
1034
+						esc_attr($salesforce_mapping['wordpress_object'])
1035 1035
 					);
1036 1036
 
1037
-					if ( null !== $salesforce_id ) {
1037
+					if (null !== $salesforce_id) {
1038 1038
 						$title .= ' ' . $salesforce_id;
1039 1039
 					}
1040 1040
 
1041 1041
 					// translators: placeholders are: 1) the name of the Salesforce object, and 2) Id of the Salesforce object
1042
-					$title .= sprintf( esc_html__( ' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce' ),
1042
+					$title .= sprintf(esc_html__(' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce'),
1043 1043
 						$salesforce_mapping['salesforce_object'],
1044 1044
 						$object['Id']
1045 1045
 					);
1046 1046
 
1047
-					if ( isset( $this->logging ) ) {
1047
+					if (isset($this->logging)) {
1048 1048
 						$logging = $this->logging;
1049
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1050
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1049
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1050
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1051 1051
 					}
1052 1052
 
1053 1053
 					// if we know the WordPress object id we can put it in there
1054
-					if ( null !== $wordpress_id ) {
1054
+					if (null !== $wordpress_id) {
1055 1055
 						$parent = $wordpress_id;
1056 1056
 					} else {
1057 1057
 						$parent = 0;
@@ -1065,26 +1065,26 @@  discard block
 block discarded – undo
1065 1065
 						$status
1066 1066
 					);
1067 1067
 
1068
-					if ( false === $hold_exceptions ) {
1068
+					if (false === $hold_exceptions) {
1069 1069
 						throw $e;
1070 1070
 					}
1071
-					if ( empty( $exception ) ) {
1071
+					if (empty($exception)) {
1072 1072
 						$exception = $e;
1073 1073
 					} else {
1074
-						$my_class  = get_class( $e );
1075
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1074
+						$my_class  = get_class($e);
1075
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1076 1076
 					}
1077 1077
 
1078 1078
 					// hook for pull fail
1079
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1079
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1080 1080
 
1081 1081
 					return;
1082 1082
 				} // End try().
1083 1083
 
1084 1084
 				// set $wordpress_data to the query result
1085 1085
 				$wordpress_data = $result['data'];
1086
-				if ( isset( $wordpress_data[ "$object_id" ] ) ) {
1087
-					$wordpress_id = $wordpress_data[ "$object_id" ];
1086
+				if (isset($wordpress_data["$object_id"])) {
1087
+					$wordpress_id = $wordpress_data["$object_id"];
1088 1088
 				} else {
1089 1089
 					$wordpress_id = 0;
1090 1090
 				}
@@ -1093,23 +1093,23 @@  discard block
 block discarded – undo
1093 1093
 				// this means the object has already been created/updated in WordPress
1094 1094
 				// this is not redundant because this is where it creates the object mapping rows in WordPress if the object does not already have one (we are still inside $is_new === TRUE here)
1095 1095
 
1096
-				if ( empty( $result['errors'] ) ) {
1096
+				if (empty($result['errors'])) {
1097 1097
 					$status = 'success';
1098 1098
 
1099
-					if ( isset( $this->logging ) ) {
1099
+					if (isset($this->logging)) {
1100 1100
 						$logging = $this->logging;
1101
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1102
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1101
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1102
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1103 1103
 					}
1104 1104
 
1105 1105
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1106
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1107
-						esc_attr( $op ),
1108
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1109
-						esc_attr( $object_id ),
1110
-						esc_attr( $wordpress_id ),
1111
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1112
-						esc_attr( $object['Id'] )
1106
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1107
+						esc_attr($op),
1108
+						esc_attr($salesforce_mapping['wordpress_object']),
1109
+						esc_attr($object_id),
1110
+						esc_attr($wordpress_id),
1111
+						esc_attr($salesforce_mapping['salesforce_object']),
1112
+						esc_attr($object['Id'])
1113 1113
 					);
1114 1114
 
1115 1115
 					$logging->setup(
@@ -1122,40 +1122,40 @@  discard block
 block discarded – undo
1122 1122
 
1123 1123
 					// update that mapping object
1124 1124
 					$mapping_object['wordpress_id'] = $wordpress_id;
1125
-					$mapping_object                 = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1125
+					$mapping_object                 = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1126 1126
 
1127 1127
 					// hook for pull success
1128
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1128
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1129 1129
 				} else {
1130 1130
 
1131 1131
 					// create log entry for failed create or upsert
1132 1132
 					// this is part of the drupal module but i am failing to understand when it would ever fire, since the catch should catch the errors
1133 1133
 					// if we see this in the log entries, we can understand what it does, but probably not until then
1134 1134
 					$status = 'error';
1135
-					if ( isset( $this->logging ) ) {
1135
+					if (isset($this->logging)) {
1136 1136
 						$logging = $this->logging;
1137
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1138
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1137
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1138
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1139 1139
 					}
1140 1140
 
1141
-					if ( is_object( $wordpress_id ) ) {
1141
+					if (is_object($wordpress_id)) {
1142 1142
 						// print this array because if this happens, something weird has happened and we want to log whatever we have
1143
-						$wordpress_id = print_r( $wordpress_id, true );
1143
+						$wordpress_id = print_r($wordpress_id, true);
1144 1144
 					}
1145 1145
 
1146 1146
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object type, 3) the Salesforce object Id value
1147
-					$title = sprintf( esc_html__( 'Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce' ),
1148
-						esc_attr( $op ),
1149
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1150
-						esc_attr( $object['Id'] )
1147
+					$title = sprintf(esc_html__('Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce'),
1148
+						esc_attr($op),
1149
+						esc_attr($salesforce_mapping['salesforce_object']),
1150
+						esc_attr($object['Id'])
1151 1151
 					);
1152 1152
 
1153 1153
 					// translators: placeholders are: 1) the name of the WordPress object type, 2) the WordPress id field name, 3) the WordPress id field value, 4) the array of errors
1154
-					$body = sprintf( '<p>' . esc_html__( 'Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: ', 'object-sync-for-salesforce' ) . '%4$s',
1155
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1156
-						esc_attr( $object_id ),
1157
-						esc_attr( $wordpress_id ),
1158
-						print_r( $result['errors'], true ) // if we get this error, we need to know whatever we have
1154
+					$body = sprintf('<p>' . esc_html__('Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: ', 'object-sync-for-salesforce') . '%4$s',
1155
+						esc_attr($salesforce_mapping['wordpress_object']),
1156
+						esc_attr($object_id),
1157
+						esc_attr($wordpress_id),
1158
+						print_r($result['errors'], true) // if we get this error, we need to know whatever we have
1159 1159
 					);
1160 1160
 
1161 1161
 					$logging->setup(
@@ -1167,52 +1167,52 @@  discard block
 block discarded – undo
1167 1167
 					);
1168 1168
 
1169 1169
 					// hook for pull fail
1170
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1170
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1171 1171
 
1172 1172
 					return;
1173 1173
 				} // End if().
1174
-			} elseif ( false === $is_new ) {
1174
+			} elseif (false === $is_new) {
1175 1175
 
1176 1176
 				// right here we should set the pulling transient
1177
-				set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
1178
-				set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
1177
+				set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
1178
+				set_transient('salesforce_pulling_object_id', $mapping_object['id']);
1179 1179
 
1180 1180
 				// there is an existing object link
1181 1181
 				// if the last sync is greater than the last time this object was updated by Salesforce, skip it
1182 1182
 				// this keeps us from doing redundant syncs
1183 1183
 				// because SF stores all DateTimes in UTC.
1184
-				$mapping_object['object_updated'] = current_time( 'mysql' );
1184
+				$mapping_object['object_updated'] = current_time('mysql');
1185 1185
 
1186 1186
 				$pull_trigger_field = $salesforce_mapping['pull_trigger_field'];
1187
-				$pull_trigger_value = $object[ $pull_trigger_field ];
1187
+				$pull_trigger_value = $object[$pull_trigger_field];
1188 1188
 
1189 1189
 				try {
1190 1190
 
1191 1191
 					// hook to allow other plugins to do something right before WordPress data is saved
1192 1192
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
1193
-					do_action( 'object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params );
1193
+					do_action('object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params);
1194 1194
 
1195 1195
 					$op     = 'Update';
1196
-					$result = $this->wordpress->object_update( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params );
1196
+					$result = $this->wordpress->object_update($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params);
1197 1197
 
1198 1198
 					$mapping_object['last_sync_status']  = $this->mappings->status_success;
1199
-					$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
1199
+					$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
1200 1200
 
1201 1201
 					$status = 'success';
1202
-					if ( isset( $this->logging ) ) {
1202
+					if (isset($this->logging)) {
1203 1203
 						$logging = $this->logging;
1204
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1205
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1204
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1205
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1206 1206
 					}
1207 1207
 
1208 1208
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1209
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1210
-						esc_attr( $op ),
1211
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1212
-						esc_attr( $object_id ),
1213
-						esc_attr( $mapping_object['wordpress_id'] ),
1214
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1215
-						esc_attr( $object['Id'] )
1209
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1210
+						esc_attr($op),
1211
+						esc_attr($salesforce_mapping['wordpress_object']),
1212
+						esc_attr($object_id),
1213
+						esc_attr($mapping_object['wordpress_id']),
1214
+						esc_attr($salesforce_mapping['salesforce_object']),
1215
+						esc_attr($object['Id'])
1216 1216
 					);
1217 1217
 
1218 1218
 					$logging->setup(
@@ -1224,25 +1224,25 @@  discard block
 block discarded – undo
1224 1224
 					);
1225 1225
 
1226 1226
 					// hook for pull success
1227
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1227
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1228 1228
 
1229
-				} catch ( WordpressException $e ) {
1229
+				} catch (WordpressException $e) {
1230 1230
 					// create log entry for failed update
1231 1231
 					$status = 'error';
1232
-					if ( isset( $this->logging ) ) {
1232
+					if (isset($this->logging)) {
1233 1233
 						$logging = $this->logging;
1234
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1235
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1234
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1235
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1236 1236
 					}
1237 1237
 
1238 1238
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1239
-					$title .= sprintf( esc_html__( 'Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce' ),
1240
-						esc_attr( $op ),
1241
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1242
-						esc_attr( $object_id ),
1243
-						esc_attr( $mapping_object['wordpress_id'] ),
1244
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1245
-						esc_attr( $object['Id'] )
1239
+					$title .= sprintf(esc_html__('Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce'),
1240
+						esc_attr($op),
1241
+						esc_attr($salesforce_mapping['wordpress_object']),
1242
+						esc_attr($object_id),
1243
+						esc_attr($mapping_object['wordpress_id']),
1244
+						esc_attr($salesforce_mapping['salesforce_object']),
1245
+						esc_attr($object['Id'])
1246 1246
 					);
1247 1247
 
1248 1248
 					$logging->setup(
@@ -1256,18 +1256,18 @@  discard block
 block discarded – undo
1256 1256
 					$mapping_object['last_sync_status']  = $this->mappings->status_error;
1257 1257
 					$mapping_object['last_sync_message'] = $e->getMessage();
1258 1258
 
1259
-					if ( false === $hold_exceptions ) {
1259
+					if (false === $hold_exceptions) {
1260 1260
 						throw $e;
1261 1261
 					}
1262
-					if ( empty( $exception ) ) {
1262
+					if (empty($exception)) {
1263 1263
 						$exception = $e;
1264 1264
 					} else {
1265
-						$my_class  = get_class( $e );
1266
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1265
+						$my_class  = get_class($e);
1266
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1267 1267
 					}
1268 1268
 
1269 1269
 					// hook for pull fail
1270
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1270
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1271 1271
 
1272 1272
 				} // End try().
1273 1273
 
@@ -1276,26 +1276,26 @@  discard block
 block discarded – undo
1276 1276
 				// maybe can check to see if we actually updated anything in WordPress
1277 1277
 				// tell the mapping object - whether it is new or already existed - how we just used it
1278 1278
 				$mapping_object['last_sync_action'] = 'pull';
1279
-				$mapping_object['last_sync']        = current_time( 'mysql' );
1279
+				$mapping_object['last_sync']        = current_time('mysql');
1280 1280
 
1281 1281
 				// update that mapping object. the Salesforce data version will be set here as well because we set it earlier
1282
-				$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1282
+				$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1283 1283
 				// end of the if statement for is_new & update or create trigger
1284 1284
 				// this keeps stuff from running too many times, and also keeps it from using the wrong methods. we don't need a generic } else { here at this time.
1285 1285
 			} // End if().
1286 1286
 		} // End foreach().
1287 1287
 
1288 1288
 		// delete transients that we've already processed
1289
-		foreach ( $transients_to_delete as $mapping_object_id_transient ) {
1290
-			delete_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
1289
+		foreach ($transients_to_delete as $mapping_object_id_transient) {
1290
+			delete_transient('salesforce_pushing_' . $mapping_object_id_transient);
1291 1291
 		}
1292 1292
 
1293
-		$pushing_id = get_transient( 'salesforce_pushing_object_id' );
1294
-		if ( in_array( $pushing_id, $transients_to_delete, true ) ) {
1295
-			delete_transient( 'salesforce_pushing_object_id' );
1293
+		$pushing_id = get_transient('salesforce_pushing_object_id');
1294
+		if (in_array($pushing_id, $transients_to_delete, true)) {
1295
+			delete_transient('salesforce_pushing_object_id');
1296 1296
 		}
1297 1297
 
1298
-		if ( ! empty( $exception ) ) {
1298
+		if ( ! empty($exception)) {
1299 1299
 			throw $exception;
1300 1300
 		}
1301 1301
 
@@ -1315,17 +1315,17 @@  discard block
 block discarded – undo
1315 1315
 	*   This is the database row for the map object
1316 1316
 	*
1317 1317
 	*/
1318
-	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1318
+	private function create_object_map($salesforce_object, $wordpress_id, $field_mapping) {
1319 1319
 		// Create object map and save it
1320 1320
 		$mapping_object = $this->mappings->create_object_map(
1321 1321
 			array(
1322 1322
 				'wordpress_id'      => $wordpress_id, // wordpress unique id
1323 1323
 				'salesforce_id'     => $salesforce_object['Id'], // salesforce unique id. we don't care what kind of object it is at this point
1324 1324
 				'wordpress_object'  => $field_mapping['wordpress_object'], // keep track of what kind of wp object this is
1325
-				'last_sync'         => current_time( 'mysql' ),
1325
+				'last_sync'         => current_time('mysql'),
1326 1326
 				'last_sync_action'  => 'pull',
1327 1327
 				'last_sync_status'  => $this->mappings->status_success,
1328
-				'last_sync_message' => esc_html__( 'Mapping object created via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1328
+				'last_sync_message' => esc_html__('Mapping object created via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1329 1329
 				'action'            => 'created',
1330 1330
 			)
1331 1331
 		);
Please login to merge, or discard this patch.
classes/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, $this->schedulable_classes );
172
+		$this->queue = $this->queue($this->wpdb, $this->version, $this->slug, $this->schedulable_classes);
173 173
 
174
-		$this->activated = $this->activate( $this->wpdb, $this->version, $this->slug );
175
-		$this->deactivate( $this->wpdb, $this->version, $this->slug, $this->schedulable_classes );
174
+		$this->activated = $this->activate($this->wpdb, $this->version, $this->slug);
175
+		$this->deactivate($this->wpdb, $this->version, $this->slug, $this->schedulable_classes);
176 176
 
177
-		$this->logging = $this->logging( $this->wpdb, $this->version );
177
+		$this->logging = $this->logging($this->wpdb, $this->version);
178 178
 
179
-		$this->mappings = $this->mappings( $this->wpdb, $this->version, $this->slug, $this->logging );
179
+		$this->mappings = $this->mappings($this->wpdb, $this->version, $this->slug, $this->logging);
180 180
 
181
-		$this->wordpress  = $this->wordpress( $this->wpdb, $this->version, $this->slug, $this->mappings, $this->logging );
181
+		$this->wordpress  = $this->wordpress($this->wpdb, $this->version, $this->slug, $this->mappings, $this->logging);
182 182
 		$this->salesforce = $this->salesforce_get_api();
183 183
 
184
-		$this->push = $this->push( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue );
184
+		$this->push = $this->push($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue);
185 185
 
186
-		$this->pull = $this->pull( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue );
186
+		$this->pull = $this->pull($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->logging, $this->schedulable_classes, $this->queue);
187 187
 
188
-		$this->load_admin( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->push, $this->pull, $this->logging, $this->schedulable_classes, $this->queue );
188
+		$this->load_admin($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->push, $this->pull, $this->logging, $this->schedulable_classes, $this->queue);
189 189
 
190 190
 	}
191 191
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param string $slug
198 198
 	 *
199 199
 	 */
200
-	private function load( $wpdb, $version, $slug ) {
201
-		require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
200
+	private function load($wpdb, $version, $slug) {
201
+		require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';
202 202
 	}
203 203
 
204 204
 	/**
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 * @param array $schedulable_classes
211 211
 	 * @return Object_Sync_Sf_Queue
212 212
 	 */
213
-	public function queue( $wpdb, $version, $slug, $schedulable_classes ) {
214
-		require_once plugin_dir_path( __FILE__ ) . 'classes/class-object-sync-sf-queue.php';
215
-		$queue = new Object_Sync_Sf_Queue( $wpdb, $version, $slug, $schedulable_classes );
213
+	public function queue($wpdb, $version, $slug, $schedulable_classes) {
214
+		require_once plugin_dir_path(__FILE__) . 'classes/class-object-sync-sf-queue.php';
215
+		$queue = new Object_Sync_Sf_Queue($wpdb, $version, $slug, $schedulable_classes);
216 216
 		return $queue;
217 217
 	}
218 218
 
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 	 * @return object
227 227
 	 *   Instance of Object_Sync_Sf_Logging
228 228
 	 */
229
-	private function logging( $wpdb, $version ) {
230
-		require_once plugin_dir_path( __FILE__ ) . 'classes/logging.php';
231
-		$logging = new Object_Sync_Sf_Logging( $wpdb, $version );
229
+	private function logging($wpdb, $version) {
230
+		require_once plugin_dir_path(__FILE__) . 'classes/logging.php';
231
+		$logging = new Object_Sync_Sf_Logging($wpdb, $version);
232 232
 		return $logging;
233 233
 	}
234 234
 
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 	 * @return object
244 244
 	 *   Instance of Object_Sync_Sf_Mapping
245 245
 	 */
246
-	private function mappings( $wpdb, $version, $slug, $logging ) {
247
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_mapping.php' );
248
-		$mappings = new Object_Sync_Sf_Mapping( $wpdb, $version, $slug, $logging );
246
+	private function mappings($wpdb, $version, $slug, $logging) {
247
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce_mapping.php');
248
+		$mappings = new Object_Sync_Sf_Mapping($wpdb, $version, $slug, $logging);
249 249
 		return $mappings;
250 250
 	}
251 251
 
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 	* @return object
262 262
 	*   Instance of Object_Sync_Sf_WordPress
263 263
 	*/
264
-	private function wordpress( $wpdb, $version, $slug, $mappings, $logging ) {
265
-		require_once plugin_dir_path( __FILE__ ) . 'classes/wordpress.php';
266
-		$wordpress = new Object_Sync_Sf_WordPress( $wpdb, $version, $slug, $mappings, $logging );
264
+	private function wordpress($wpdb, $version, $slug, $mappings, $logging) {
265
+		require_once plugin_dir_path(__FILE__) . 'classes/wordpress.php';
266
+		$wordpress = new Object_Sync_Sf_WordPress($wpdb, $version, $slug, $mappings, $logging);
267 267
 		return $wordpress;
268 268
 	}
269 269
 
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
 	*   The sfapi object if it is authenticated (empty, otherwise)
277 277
 	*/
278 278
 	public function salesforce_get_api() {
279
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce.php' );
280
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_query.php' ); // this can be used to generate soql queries, but we don't often need it so it gets initialized whenever it's needed
279
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce.php');
280
+		require_once(plugin_dir_path(__FILE__) . 'classes/salesforce_query.php'); // this can be used to generate soql queries, but we don't often need it so it gets initialized whenever it's needed
281 281
 		$consumer_key        = $this->login_credentials['consumer_key'];
282 282
 		$consumer_secret     = $this->login_credentials['consumer_secret'];
283 283
 		$login_url           = $this->login_credentials['login_url'];
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 		$schedulable_classes = $this->schedulable_classes;
292 292
 		$is_authorized       = false;
293 293
 		$sfapi               = '';
294
-		if ( $consumer_key && $consumer_secret ) {
295
-			$sfapi = new Object_Sync_Sf_Salesforce( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes );
296
-			if ( $sfapi->is_authorized() === true ) {
294
+		if ($consumer_key && $consumer_secret) {
295
+			$sfapi = new Object_Sync_Sf_Salesforce($consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes);
296
+			if ($sfapi->is_authorized() === true) {
297 297
 				$is_authorized = true;
298 298
 			}
299 299
 		}
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
 	 * @return object
314 314
 	 *   Instance of Object_Sync_Sf_Activate
315 315
 	 */
316
-	private function activate( $wpdb, $version, $slug ) {
317
-		require_once plugin_dir_path( __FILE__ ) . 'classes/activate.php';
318
-		$activate = new Object_Sync_Sf_Activate( $wpdb, $version, $slug );
316
+	private function activate($wpdb, $version, $slug) {
317
+		require_once plugin_dir_path(__FILE__) . 'classes/activate.php';
318
+		$activate = new Object_Sync_Sf_Activate($wpdb, $version, $slug);
319 319
 		return $activate;
320 320
 	}
321 321
 
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 	 * @return object
331 331
 	 *   Instance of Object_Sync_Sf_Deactivate
332 332
 	 */
333
-	private function deactivate( $wpdb, $version, $slug, $schedulable_classes ) {
334
-		require_once plugin_dir_path( __FILE__ ) . 'classes/deactivate.php';
335
-		$deactivate = new Object_Sync_Sf_Deactivate( $wpdb, $version, $slug, $schedulable_classes );
333
+	private function deactivate($wpdb, $version, $slug, $schedulable_classes) {
334
+		require_once plugin_dir_path(__FILE__) . 'classes/deactivate.php';
335
+		$deactivate = new Object_Sync_Sf_Deactivate($wpdb, $version, $slug, $schedulable_classes);
336 336
 	}
337 337
 
338 338
 
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 	 * @return object
353 353
 	 *   Instance of Object_Sync_Sf_Salesforce_Push
354 354
 	 */
355
-	private function push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
356
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_push.php';
357
-		$push = new Object_Sync_Sf_Salesforce_Push( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue );
355
+	private function push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
356
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_push.php';
357
+		$push = new Object_Sync_Sf_Salesforce_Push($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue);
358 358
 		return $push;
359 359
 	}
360 360
 
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 	 * @return object
374 374
 	 *   Instance of Object_Sync_Sf_Salesforce_Pull
375 375
 	 */
376
-	private function pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) {
377
-		require_once plugin_dir_path( __FILE__ ) . 'classes/salesforce_pull.php';
378
-		$pull = new Object_Sync_Sf_Salesforce_Pull( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue );
376
+	private function pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue) {
377
+		require_once plugin_dir_path(__FILE__) . 'classes/salesforce_pull.php';
378
+		$pull = new Object_Sync_Sf_Salesforce_Pull($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue);
379 379
 		return $pull;
380 380
 	}
381 381
 
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 	*   Instance of Object_Sync_Sf_Admin
400 400
 	*
401 401
 	*/
402
-	private function load_admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) {
403
-		require_once( plugin_dir_path( __FILE__ ) . 'classes/admin.php' );
404
-		$admin = new Object_Sync_Sf_Admin( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue );
405
-		add_action( 'admin_menu', array( $admin, 'create_admin_menu' ) );
406
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_and_styles' ) );
407
-		add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
408
-		add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 5 );
402
+	private function load_admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue) {
403
+		require_once(plugin_dir_path(__FILE__) . 'classes/admin.php');
404
+		$admin = new Object_Sync_Sf_Admin($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue);
405
+		add_action('admin_menu', array($admin, 'create_admin_menu'));
406
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts_and_styles'));
407
+		add_action('plugins_loaded', array($this, 'textdomain'));
408
+		add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 5);
409 409
 		return $admin;
410 410
 	}
411 411
 
@@ -417,11 +417,11 @@  discard block
 block discarded – undo
417 417
 	* @return array $links
418 418
 	*   These are the links that go with this plugin's entry
419 419
 	*/
420
-	public function plugin_action_links( $links, $file ) {
421
-		if ( plugin_basename( __FILE__ ) === $file ) {
422
-			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __( 'Settings', 'object-sync-for-salesforce' ) . '</a>';
420
+	public function plugin_action_links($links, $file) {
421
+		if (plugin_basename(__FILE__) === $file) {
422
+			$settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __('Settings', 'object-sync-for-salesforce') . '</a>';
423 423
 			// make the 'Settings' link appear first
424
-			array_unshift( $links, $settings );
424
+			array_unshift($links, $settings);
425 425
 		}
426 426
 		return $links;
427 427
 	}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	public function admin_scripts_and_styles() {
436 436
 
437 437
 		// I think some developers might not want to bother with select2 or selectwoo, so let's allow that to be changeable
438
-		$select_library = apply_filters( 'object_sync_for_salesforce_select_library', 'selectwoo' );
438
+		$select_library = apply_filters('object_sync_for_salesforce_select_library', 'selectwoo');
439 439
 
440 440
 		/*
441 441
 		 * example to modify the select library
@@ -447,19 +447,19 @@  discard block
 block discarded – undo
447 447
 		 * }
448 448
 		*/
449 449
 
450
-		$javascript_dependencies = array( 'jquery' );
450
+		$javascript_dependencies = array('jquery');
451 451
 		$css_dependencies        = array();
452
-		if ( '' !== $select_library ) {
453
-			wp_enqueue_script( $select_library . 'js', plugins_url( 'assets/js/' . $select_library . '.min.js', __FILE__ ), array( 'jquery' ), filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/' . $select_library . '.min.js' ), true );
452
+		if ('' !== $select_library) {
453
+			wp_enqueue_script($select_library . 'js', plugins_url('assets/js/' . $select_library . '.min.js', __FILE__), array('jquery'), filemtime(plugin_dir_path(__FILE__) . 'assets/js/' . $select_library . '.min.js'), true);
454 454
 			$javascript_dependencies[] = $select_library . 'js';
455 455
 
456
-			wp_enqueue_style( $select_library . 'css', plugins_url( 'assets/css/' . $select_library . '.min.css', __FILE__ ), array(), filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/' . $select_library . '.min.css' ), 'all' );
456
+			wp_enqueue_style($select_library . 'css', plugins_url('assets/css/' . $select_library . '.min.css', __FILE__), array(), filemtime(plugin_dir_path(__FILE__) . 'assets/css/' . $select_library . '.min.css'), 'all');
457 457
 			$css_dependencies[] = $select_library . 'css';
458 458
 		}
459 459
 
460
-		wp_enqueue_script( $this->slug . '-admin', plugins_url( 'assets/js/object-sync-for-salesforce-admin.min.js', __FILE__ ), $javascript_dependencies, filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/object-sync-for-salesforce-admin.min.js' ), true );
460
+		wp_enqueue_script($this->slug . '-admin', plugins_url('assets/js/object-sync-for-salesforce-admin.min.js', __FILE__), $javascript_dependencies, filemtime(plugin_dir_path(__FILE__) . 'assets/js/object-sync-for-salesforce-admin.min.js'), true);
461 461
 
462
-		wp_enqueue_style( $this->slug . '-admin', plugins_url( 'assets/css/object-sync-for-salesforce-admin.min.css', __FILE__ ), $css_dependencies, filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/object-sync-for-salesforce-admin.min.css' ), 'all' );
462
+		wp_enqueue_style($this->slug . '-admin', plugins_url('assets/css/object-sync-for-salesforce-admin.min.css', __FILE__), $css_dependencies, filemtime(plugin_dir_path(__FILE__) . 'assets/css/object-sync-for-salesforce-admin.min.css'), 'all');
463 463
 	}
464 464
 
465 465
 	/**
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @return void
469 469
 	 */
470 470
 	public function textdomain() {
471
-		load_plugin_textdomain( 'object-sync-for-salesforce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
471
+		load_plugin_textdomain('object-sync-for-salesforce', false, dirname(plugin_basename(__FILE__)) . '/languages/');
472 472
 	}
473 473
 
474 474
 	/**
@@ -481,13 +481,13 @@  discard block
 block discarded – undo
481 481
 	*/
482 482
 	private function get_login_credentials() {
483 483
 
484
-		$consumer_key       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( 'object_sync_for_salesforce_consumer_key', '' );
485
-		$consumer_secret    = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option( 'object_sync_for_salesforce_consumer_secret', '' );
486
-		$callback_url       = defined( 'OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option( 'object_sync_for_salesforce_callback_url', '' );
487
-		$login_base_url     = defined( 'OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL' ) ? OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL : get_option( 'object_sync_for_salesforce_login_base_url', '' );
488
-		$authorize_url_path = defined( 'OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH' ) ? OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH : get_option( 'object_sync_for_salesforce_authorize_url_path', '' );
489
-		$token_url_path     = defined( 'OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH' ) ? OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH : get_option( 'object_sync_for_salesforce_token_url_path', '' );
490
-		$api_version        = defined( 'OBJECT_SYNC_SF_SALESFORCE_API_VERSION' ) ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option( 'object_sync_for_salesforce_api_version', '' );
484
+		$consumer_key       = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option('object_sync_for_salesforce_consumer_key', '');
485
+		$consumer_secret    = defined('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET') ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET : get_option('object_sync_for_salesforce_consumer_secret', '');
486
+		$callback_url       = defined('OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL') ? OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL : get_option('object_sync_for_salesforce_callback_url', '');
487
+		$login_base_url     = defined('OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL') ? OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL : get_option('object_sync_for_salesforce_login_base_url', '');
488
+		$authorize_url_path = defined('OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH') ? OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH : get_option('object_sync_for_salesforce_authorize_url_path', '');
489
+		$token_url_path     = defined('OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH') ? OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH : get_option('object_sync_for_salesforce_token_url_path', '');
490
+		$api_version        = defined('OBJECT_SYNC_SF_SALESFORCE_API_VERSION') ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : get_option('object_sync_for_salesforce_api_version', '');
491 491
 
492 492
 		$login_credentials = array(
493 493
 			'consumer_key'     => $consumer_key,
Please login to merge, or discard this patch.
classes/class-object-sync-sf-queue.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Object Sync for Salesforce Queue
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if ( ! defined('ABSPATH')) {
7 7
 	exit; // Exit if accessed directly.
8 8
 }
9 9
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	protected $slug;
21 21
 	protected $schedulable_classes;
22 22
 
23
-	public function __construct( $wpdb, $version, $slug, $schedulable_classes ) {
23
+	public function __construct($wpdb, $version, $slug, $schedulable_classes) {
24 24
 		$this->wpdb                = $wpdb;
25 25
 		$this->version             = $version;
26 26
 		$this->slug                = $slug;
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
 	 * @param string  $sort Which direction to sort
35 35
 	 * @return array $this->schedulable_classes
36 36
 	 */
37
-	public function get_frequencies( $unit = 'seconds', $sort = 'asc' ) {
37
+	public function get_frequencies($unit = 'seconds', $sort = 'asc') {
38 38
 
39
-		foreach ( $this->schedulable_classes as $key => $schedule ) {
40
-			$this->schedulable_classes[ $key ]['frequency'] = $this->get_frequency( $key, 'seconds' );
39
+		foreach ($this->schedulable_classes as $key => $schedule) {
40
+			$this->schedulable_classes[$key]['frequency'] = $this->get_frequency($key, 'seconds');
41 41
 		}
42 42
 
43
-		if ( 'asc' === $sort ) {
44
-			uasort( $this->schedulable_classes, function( $a, $b ) {
43
+		if ('asc' === $sort) {
44
+			uasort($this->schedulable_classes, function($a, $b) {
45 45
 				return $a['frequency'] - $b['frequency'];
46 46
 			});
47 47
 		} else {
48
-			uasort( $this->schedulable_classes, function( $a, $b ) {
48
+			uasort($this->schedulable_classes, function($a, $b) {
49 49
 				return $b['frequency'] - $a['frequency'];
50 50
 			});
51 51
 		}
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	 * @param string  $unit The unit of time
62 62
 	 * @return int How often it runs in that unit of time
63 63
 	 */
64
-	public function get_frequency( $name, $unit ) {
65
-		$schedule_number = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_number', '' );
66
-		$schedule_unit   = get_option( 'object_sync_for_salesforce_' . $name . '_schedule_unit', '' );
64
+	public function get_frequency($name, $unit) {
65
+		$schedule_number = get_option('object_sync_for_salesforce_' . $name . '_schedule_number', '');
66
+		$schedule_unit   = get_option('object_sync_for_salesforce_' . $name . '_schedule_unit', '');
67 67
 
68
-		switch ( $schedule_unit ) {
68
+		switch ($schedule_unit) {
69 69
 			case 'minutes':
70 70
 				$seconds = 60;
71 71
 				$minutes = 1;
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @param string $group The group to assign this job to.
97 97
 	 * @return string The action ID.
98 98
 	 */
99
-	public function add( $hook, $args = array(), $group = '' ) {
100
-		return $this->schedule_single( time(), $hook, $args, $group );
99
+	public function add($hook, $args = array(), $group = '') {
100
+		return $this->schedule_single(time(), $hook, $args, $group);
101 101
 	}
102 102
 
103 103
 	/**
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param string $group The group to assign this job to.
110 110
 	 * @return string The action ID.
111 111
 	 */
112
-	public function schedule_single( $timestamp, $hook, $args = array(), $group = '' ) {
113
-		return as_schedule_single_action( $timestamp, $hook, $args, $group );
112
+	public function schedule_single($timestamp, $hook, $args = array(), $group = '') {
113
+		return as_schedule_single_action($timestamp, $hook, $args, $group);
114 114
 	}
115 115
 
116 116
 	/**
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * @param string $group The group to assign this job to.
124 124
 	 * @return string The action ID.
125 125
 	 */
126
-	public function schedule_recurring( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
127
-		return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
126
+	public function schedule_recurring($timestamp, $interval_in_seconds, $hook, $args = array(), $group = '') {
127
+		return as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, $group);
128 128
 	}
129 129
 
130 130
 	/**
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	 * @param string $group The group to assign this job to.
148 148
 	 * @return string The action ID
149 149
 	 */
150
-	public function schedule_cron( $timestamp, $cron_schedule, $hook, $args = array(), $group = '' ) {
151
-		return as_schedule_cron_action( $timestamp, $cron_schedule, $hook, $args, $group );
150
+	public function schedule_cron($timestamp, $cron_schedule, $hook, $args = array(), $group = '') {
151
+		return as_schedule_cron_action($timestamp, $cron_schedule, $hook, $args, $group);
152 152
 	}
153 153
 
154 154
 	/**
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param array  $args Args that would have been passed to the job.
165 165
 	 * @param string $group Group name.
166 166
 	 */
167
-	public function cancel( $hook, $args = array(), $group = '' ) {
168
-		as_unschedule_action( $hook, $args, $group );
167
+	public function cancel($hook, $args = array(), $group = '') {
168
+		as_unschedule_action($hook, $args, $group);
169 169
 	}
170 170
 
171 171
 	/**
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * @param string $group Group name.
178 178
 	 * @return time|null The date and time for the next occurrence, or null if there is no pending, scheduled action for the given hook.
179 179
 	 */
180
-	public function get_next( $hook, $args = null, $group = '' ) {
180
+	public function get_next($hook, $args = null, $group = '') {
181 181
 
182
-		$next_timestamp = as_next_scheduled_action( $hook, $args, $group );
182
+		$next_timestamp = as_next_scheduled_action($hook, $args, $group);
183 183
 
184
-		if ( $next_timestamp ) {
184
+		if ($next_timestamp) {
185 185
 			return $next_timestamp;
186 186
 		}
187 187
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @param string $return_format OBJECT, ARRAY_A, or ids.
210 210
 	 * @return array
211 211
 	 */
212
-	public function search( $args = array(), $return_format = OBJECT ) {
213
-		return as_get_scheduled_actions( $args, $return_format );
212
+	public function search($args = array(), $return_format = OBJECT) {
213
+		return as_get_scheduled_actions($args, $return_format);
214 214
 	}
215 215
 }
Please login to merge, or discard this patch.
force.com-toolkit-for-php/unit_test/Lib/Test/Partner/LogoutTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	 */
26 26
 	protected function _validateSoapFault($rs)
27 27
 	{
28
-		if(strpos($rs, 'INVALID_SESSION_ID') === FALSE) {
28
+		if (strpos($rs, 'INVALID_SESSION_ID') === FALSE) {
29 29
 			throw new Lib_Exception_InvalidResponse();
30 30
 		}
31 31
 	}
Please login to merge, or discard this patch.
unit_test/Lib/Test/Partner/DescribeDataCategoryGroupStructuresTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		$pairs[] = new SoapVar($pair, SOAP_ENC_OBJECT, 'DataCategoryGroupSobjectTypePair', SforcePartnerClient::PARTNER_NAMESPACE);
25 25
 		$response = $this->_mySforceConnection->describeDataCategoryGroupStructures($pairs, true);
26 26
 
27
-		echo "***** ".$this->getTestName()." Get information only about top categories *****\n";
27
+		echo "***** " . $this->getTestName() . " Get information only about top categories *****\n";
28 28
 		print_r($response);
29 29
 
30 30
 		/*
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$pairs[] = new SoapVar($pair, SOAP_ENC_OBJECT, 'DataCategoryGroupSobjectTypePair', SforcePartnerClient::PARTNER_NAMESPACE);
46 46
 		$response = $this->_mySforceConnection->describeDataCategoryGroupStructures($pairs, false);
47 47
 
48
-		echo "\n\n***** ".$this->getTestName()." Get information about two categories *****\n";
48
+		echo "\n\n***** " . $this->getTestName() . " Get information about two categories *****\n";
49 49
 		print_r($response);
50 50
 	}
51 51
 }
Please login to merge, or discard this patch.
force.com-toolkit-for-php/unit_test/Lib/Test/Partner/LocaleOptionsTest.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
 	
9 9
 	protected function _run()
10 10
 	{
11
-	    $header = new LocaleOptions('en_US');
12
-	    $this->_mySforceConnection->setLocaleOptions($header);
11
+		$header = new LocaleOptions('en_US');
12
+		$this->_mySforceConnection->setLocaleOptions($header);
13 13
 	    
14
-	    print "**** DescribeSObject result: \r\n";
15
-	    print_r(
14
+		print "**** DescribeSObject result: \r\n";
15
+		print_r(
16 16
 				$this->_mySforceConnection->describeSObject('Account')
17
-	    );
17
+		);
18 18
 	    
19
-	    print "**** LastRequestHeaders:\r\n";
20
-	    print_r($this->_mySforceConnection->getLastRequestHeaders());
21
-	    print "**** LastRequest:\r\n";
22
-	    print_r($this->_mySforceConnection->getLastRequest());
19
+		print "**** LastRequestHeaders:\r\n";
20
+		print_r($this->_mySforceConnection->getLastRequestHeaders());
21
+		print "**** LastRequest:\r\n";
22
+		print_r($this->_mySforceConnection->getLastRequest());
23 23
 	    
24 24
 	}
25 25
 }
Please login to merge, or discard this patch.