Passed
Pull Request — master (#195)
by Jonathan
03:31
created
templates/admin/user-profile-salesforce-change.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <input type="hidden" name="salesforce_update_mapped_user" value="1" />
2
-<h2><?php echo esc_html__( 'Salesforce', 'object-sync-for-salesforce' ); ?></h2>
3
-<p><?php echo esc_html__( 'You can change the Salesforce object that this WordPress user maps to by changing the ID and updating this user.', 'object-sync-for-salesforce' ); ?></p>
2
+<h2><?php echo esc_html__('Salesforce', 'object-sync-for-salesforce'); ?></h2>
3
+<p><?php echo esc_html__('You can change the Salesforce object that this WordPress user maps to by changing the ID and updating this user.', 'object-sync-for-salesforce'); ?></p>
4 4
 <table class="form-table">
5 5
 	<tr>
6
-		<th><label for="salesforce_id"><?php echo esc_html__( 'Salesforce ID', 'object-sync-for-salesforce' ); ?></label></th>
6
+		<th><label for="salesforce_id"><?php echo esc_html__('Salesforce ID', 'object-sync-for-salesforce'); ?></label></th>
7 7
 		<td>
8
-			<input type="text" name="salesforce_id" id="salesforce_id" value="<?php if ( isset( $mapping['id'] ) ) { echo esc_html( $mapping['salesforce_id'] ); } ?>" class="regular-text" /><br />
9
-			<span class="description"><?php echo esc_html__( 'Enter a Salesforce object ID.', 'object-sync-for-salesforce' ); ?></span>
8
+			<input type="text" name="salesforce_id" id="salesforce_id" value="<?php if (isset($mapping['id'])) { echo esc_html($mapping['salesforce_id']); } ?>" class="regular-text" /><br />
9
+			<span class="description"><?php echo esc_html__('Enter a Salesforce object ID.', 'object-sync-for-salesforce'); ?></span>
10 10
 		</td>
11 11
 	</tr>
12 12
 </table>
Please login to merge, or discard this patch.
templates/admin/authorized.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,2 +1,2 @@
 block discarded – undo
1
-<div class="success"><h2><?php echo esc_html__( 'Salesforce is successfully authenticated.' ); ?></h2></div>
2
-<p><a class="button button-primary" href="<?php echo esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=logout' ) ); ?>"><?php echo esc_html__( 'Disconnect from Salesforce', 'object-sync-for-salesforce' ); ?></a></p>
1
+<div class="success"><h2><?php echo esc_html__('Salesforce is successfully authenticated.'); ?></h2></div>
2
+<p><a class="button button-primary" href="<?php echo esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=logout')); ?>"><?php echo esc_html__('Disconnect from Salesforce', 'object-sync-for-salesforce'); ?></a></p>
Please login to merge, or discard this patch.
templates/admin/user-profile-salesforce-map.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <input type="hidden" name="salesforce_create_mapped_user" value="1" />
2
-<h2><?php echo esc_html__( 'Salesforce', 'object-sync-for-salesforce' ); ?></h2>
3
-<p><?php echo esc_html__( "This user is not mapped to an object in Salesforce. You can run a push to send this object to Salesforce, which will cause it to follow the plugin's normal mapping conventions, or you can create a manual link to a Salesforce object.", 'object-sync-for-salesforce' ); ?></p>
2
+<h2><?php echo esc_html__('Salesforce', 'object-sync-for-salesforce'); ?></h2>
3
+<p><?php echo esc_html__("This user is not mapped to an object in Salesforce. You can run a push to send this object to Salesforce, which will cause it to follow the plugin's normal mapping conventions, or you can create a manual link to a Salesforce object.", 'object-sync-for-salesforce'); ?></p>
4 4
 <table class="form-table">
5 5
 	<tr>
6
-		<th><label for="salesforce_id"><?php echo esc_html__( 'Salesforce ID', 'object-sync-for-salesforce' ); ?></label></th>
6
+		<th><label for="salesforce_id"><?php echo esc_html__('Salesforce ID', 'object-sync-for-salesforce'); ?></label></th>
7 7
 		<td>
8 8
 			<input type="text" name="salesforce_id" id="salesforce_id" value="" class="regular-text" /><br />
9
-			<span class="description"><?php echo esc_html__( 'Enter a Salesforce object ID.', 'object-sync-for-salesforce' ); ?></span>
9
+			<span class="description"><?php echo esc_html__('Enter a Salesforce object ID.', 'object-sync-for-salesforce'); ?></span>
10 10
 			<p><strong>or</strong></p>
11
-			<p><button type="submit" class="button button-secondary push_to_salesforce_button" name="push_new_user_to_salesforce"><?php echo esc_html__( 'Push to Salesforce as new record', 'object-sync-for-salesforce' ); ?></button></p>
11
+			<p><button type="submit" class="button button-secondary push_to_salesforce_button" name="push_new_user_to_salesforce"><?php echo esc_html__('Push to Salesforce as new record', 'object-sync-for-salesforce'); ?></button></p>
12 12
 		</td>
13 13
 	</tr>
14 14
 </table>
Please login to merge, or discard this patch.
classes/salesforce_query.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
 	public $conditions = array();
23 23
 
24 24
 	/**
25
-	* Constructor which sets the query object type.
26
-	*
27
-	* @param string $object_type
28
-	*   Salesforce object type to query.
29
-	*/
25
+	 * Constructor which sets the query object type.
26
+	 *
27
+	 * @param string $object_type
28
+	 *   Salesforce object type to query.
29
+	 */
30 30
 	public function __construct( $object_type = '' ) {
31 31
 		$this->object_type = $object_type;
32 32
 	}
33 33
 
34 34
 	/**
35
-	* Add a condition to the query.
36
-	*
37
-	* @param string $field
38
-	*   Field name.
39
-	* @param mixed $value
40
-	*   Condition value. If an array, it will be split into quote enclosed
41
-	*   strings separated by commas inside of parenthesis. Note that the caller
42
-	*   must enclose the value in quotes as needed by the SF API.
43
-	* @param string $operator
44
-	*   Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'.
45
-	*/
35
+	 * Add a condition to the query.
36
+	 *
37
+	 * @param string $field
38
+	 *   Field name.
39
+	 * @param mixed $value
40
+	 *   Condition value. If an array, it will be split into quote enclosed
41
+	 *   strings separated by commas inside of parenthesis. Note that the caller
42
+	 *   must enclose the value in quotes as needed by the SF API.
43
+	 * @param string $operator
44
+	 *   Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'.
45
+	 */
46 46
 	public function add_condition( $field, $value, $operator = '=' ) {
47 47
 		if ( is_array( $value ) ) {
48 48
 			$value = "('" . implode( "','", $value ) . "')";
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Implements PHP's magic __toString().
64
-	*
65
-	* Function to convert the query to a string to pass to the SF API.
66
-	*
67
-	* @return string
68
-	*   SOQL query ready to be executed the SF API.
69
-	*/
63
+	 * Implements PHP's magic __toString().
64
+	 *
65
+	 * Function to convert the query to a string to pass to the SF API.
66
+	 *
67
+	 * @return string
68
+	 *   SOQL query ready to be executed the SF API.
69
+	 */
70 70
 	public function __toString() {
71 71
 
72 72
 		$query  = 'SELECT ';
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 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,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	* @param string $object_type
28 28
 	*   Salesforce object type to query.
29 29
 	*/
30
-	public function __construct( $object_type = '' ) {
30
+	public function __construct($object_type = '') {
31 31
 		$this->object_type = $object_type;
32 32
 	}
33 33
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 	* @param string $operator
44 44
 	*   Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'.
45 45
 	*/
46
-	public function add_condition( $field, $value, $operator = '=' ) {
47
-		if ( is_array( $value ) ) {
48
-			$value = "('" . implode( "','", $value ) . "')";
46
+	public function add_condition($field, $value, $operator = '=') {
47
+		if (is_array($value)) {
48
+			$value = "('" . implode("','", $value) . "')";
49 49
 
50 50
 			// Set operator to IN if wasn't already changed from the default.
51
-			if ( '=' === $operator ) {
51
+			if ('=' === $operator) {
52 52
 				$operator = 'IN';
53 53
 			}
54 54
 		}
@@ -70,31 +70,31 @@  discard block
 block discarded – undo
70 70
 	public function __toString() {
71 71
 
72 72
 		$query  = 'SELECT ';
73
-		$query .= implode( ', ', $this->fields );
73
+		$query .= implode(', ', $this->fields);
74 74
 		$query .= ' FROM ' . $this->object_type;
75 75
 
76
-		if ( count( $this->conditions ) > 0 ) {
76
+		if (count($this->conditions) > 0) {
77 77
 			$where = array();
78
-			foreach ( $this->conditions as $condition ) {
79
-				$where[] = implode( ' ', $condition );
78
+			foreach ($this->conditions as $condition) {
79
+				$where[] = implode(' ', $condition);
80 80
 			}
81
-			$query .= ' WHERE ' . implode( ' AND ', $where );
81
+			$query .= ' WHERE ' . implode(' AND ', $where);
82 82
 		}
83 83
 
84
-		if ( $this->order ) {
84
+		if ($this->order) {
85 85
 			$query .= ' ORDER BY ';
86 86
 			$fields = array();
87
-			foreach ( $this->order as $field => $direction ) {
87
+			foreach ($this->order as $field => $direction) {
88 88
 				$fields[] = $field . ' ' . $direction;
89 89
 			}
90
-			$query .= implode( ', ', $fields );
90
+			$query .= implode(', ', $fields);
91 91
 		}
92 92
 
93
-		if ( $this->limit ) {
93
+		if ($this->limit) {
94 94
 			$query .= ' LIMIT ' . (int) $this->limit;
95 95
 		}
96 96
 
97
-		if ( $this->offset ) {
97
+		if ($this->offset) {
98 98
 			$query .= ' OFFSET ' . (int) $this->offset;
99 99
 		}
100 100
 
Please login to merge, or discard this patch.
classes/admin-notice.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
 	protected $template;
22 22
 
23 23
 	/**
24
-	* Constructor which sets up the admin_notices hook for rendering
25
-	*
26
-	* @param mixed $condition
27
-	* @param string $message
28
-	* @param bool $dismissible
29
-	* @param string $type
30
-	* @param string $template
31
-	*
32
-	*/
24
+	 * Constructor which sets up the admin_notices hook for rendering
25
+	 *
26
+	 * @param mixed $condition
27
+	 * @param string $message
28
+	 * @param bool $dismissible
29
+	 * @param string $type
30
+	 * @param string $template
31
+	 *
32
+	 */
33 33
 	public function __construct( $condition, $message, $dismissible = false, $type = '', $template = '' ) {
34 34
 		$this->condition   = $condition;
35 35
 		$this->message     = $message;
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	}
43 43
 
44 44
 	/**
45
-	* Render an admin notice
46
-	*
47
-	*/
45
+	 * Render an admin notice
46
+	 *
47
+	 */
48 48
 	public function render() {
49 49
 
50 50
 		// class for the notice to use
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	* @param string $template
31 31
 	*
32 32
 	*/
33
-	public function __construct( $condition, $message, $dismissible = false, $type = '', $template = '' ) {
33
+	public function __construct($condition, $message, $dismissible = false, $type = '', $template = '') {
34 34
 		$this->condition   = $condition;
35 35
 		$this->message     = $message;
36 36
 		$this->dismissible = $dismissible;
37 37
 		$this->type        = $type;
38 38
 		$this->template    = $template;
39 39
 
40
-		add_action( 'admin_notices', array( $this, 'render' ) );
40
+		add_action('admin_notices', array($this, 'render'));
41 41
 
42 42
 	}
43 43
 
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
 
50 50
 		// class for the notice to use
51 51
 		$class = '';
52
-		if ( '' !== $this->type ) {
52
+		if ('' !== $this->type) {
53 53
 			$class = ' notice-' . $this->type;
54 54
 		}
55 55
 
56 56
 		$dismissible = '';
57
-		if ( true === $this->dismissible ) {
57
+		if (true === $this->dismissible) {
58 58
 			$dismissible = ' is-dismissible';
59 59
 		}
60 60
 
61 61
 		// template for notice has a default
62
-		if ( '' === $this->template ) {
63
-			$template = plugin_dir_path( __FILE__ ) . '/../templates/admin/notice.php';
62
+		if ('' === $this->template) {
63
+			$template = plugin_dir_path(__FILE__) . '/../templates/admin/notice.php';
64 64
 		} else {
65 65
 			$template = $this->template;
66 66
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$condition = $this->condition;
69 69
 		$message   = $this->message;
70 70
 
71
-		require_once( $template );
71
+		require_once($template);
72 72
 
73 73
 	}
74 74
 
Please login to merge, or discard this patch.
classes/logging.php 1 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
 
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 	 * @param string $version The version of this plugin.
29 29
 	 * @throws \Exception
30 30
 	 */
31
-	public function __construct( $wpdb, $version ) {
31
+	public function __construct($wpdb, $version) {
32 32
 		$this->wpdb    = $wpdb;
33 33
 		$this->version = $version;
34 34
 
35
-		$this->enabled         = get_option( 'object_sync_for_salesforce_enable_logging', false );
36
-		$this->statuses_to_log = get_option( 'object_sync_for_salesforce_statuses_to_log', array() );
35
+		$this->enabled         = get_option('object_sync_for_salesforce_enable_logging', false);
36
+		$this->statuses_to_log = get_option('object_sync_for_salesforce_statuses_to_log', array());
37 37
 
38 38
 		$this->schedule_name = 'wp_logging_prune_routine';
39 39
 
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
 	 * @throws \Exception
48 48
 	 */
49 49
 	private function init() {
50
-		if ( '1' === $this->enabled ) {
51
-			add_filter( 'cron_schedules', array( $this, 'add_prune_interval' ) );
52
-			add_filter( 'wp_log_types', array( $this, 'set_log_types' ), 10, 1 );
53
-			add_filter( 'wp_logging_should_we_prune', array( $this, 'set_prune_option' ), 10, 1 );
54
-			add_filter( 'wp_logging_prune_when', array( $this, 'set_prune_age' ), 10, 1 );
55
-			add_filter( 'wp_logging_prune_query_args', array( $this, 'set_prune_args' ), 10, 1 );
56
-			add_filter( 'wp_logging_post_type_args', array( $this, 'set_log_visibility' ), 10, 1 );
57
-
58
-			$schedule_unit = get_option( 'object_sync_for_salesforce_logs_how_often_unit', '' );
59
-			$schedule_number = get_option( 'object_sync_for_salesforce_logs_how_often_number', '' );
60
-			$frequency = $this->get_schedule_frequency( $schedule_unit, $schedule_number );
50
+		if ('1' === $this->enabled) {
51
+			add_filter('cron_schedules', array($this, 'add_prune_interval'));
52
+			add_filter('wp_log_types', array($this, 'set_log_types'), 10, 1);
53
+			add_filter('wp_logging_should_we_prune', array($this, 'set_prune_option'), 10, 1);
54
+			add_filter('wp_logging_prune_when', array($this, 'set_prune_age'), 10, 1);
55
+			add_filter('wp_logging_prune_query_args', array($this, 'set_prune_args'), 10, 1);
56
+			add_filter('wp_logging_post_type_args', array($this, 'set_log_visibility'), 10, 1);
57
+
58
+			$schedule_unit = get_option('object_sync_for_salesforce_logs_how_often_unit', '');
59
+			$schedule_number = get_option('object_sync_for_salesforce_logs_how_often_number', '');
60
+			$frequency = $this->get_schedule_frequency($schedule_unit, $schedule_number);
61 61
 			$key = $frequency['key'];
62 62
 
63
-			if ( ! wp_next_scheduled( $this->schedule_name ) ) {
64
-				wp_schedule_event( time(), $key, $this->schedule_name );
63
+			if ( ! wp_next_scheduled($this->schedule_name)) {
64
+				wp_schedule_event(time(), $key, $this->schedule_name);
65 65
 			}
66 66
 		}
67 67
 	}
68 68
 
69
-	public function set_log_visibility( $log_args ) {
69
+	public function set_log_visibility($log_args) {
70 70
 		// set public to true overrides the WP_DEBUG setting that is the default on the class
71 71
 		// capabilities makes it so (currently) only admin users can see the log posts in their admin view
72 72
 		// note: there is no actual "public" view for this post type
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			'read_private_posts' => 'configure_salesforce',
83 83
 		);
84 84
 
85
-		$log_args = apply_filters( 'object_sync_for_salesforce_logging_post_type_args', $log_args );
85
+		$log_args = apply_filters('object_sync_for_salesforce_logging_post_type_args', $log_args);
86 86
 
87 87
 		return $log_args;
88 88
 	}
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 	 * @param array $schedules An array of scheduled cron items.
94 94
 	 * @return array $frequency
95 95
 	 */
96
-	public function add_prune_interval( $schedules ) {
96
+	public function add_prune_interval($schedules) {
97 97
 
98
-		$schedule_unit   = get_option( 'object_sync_for_salesforce_logs_how_often_unit', '' );
99
-		$schedule_number = get_option( 'object_sync_for_salesforce_logs_how_often_number', '' );
100
-		$frequency       = $this->get_schedule_frequency( $schedule_unit, $schedule_number );
98
+		$schedule_unit   = get_option('object_sync_for_salesforce_logs_how_often_unit', '');
99
+		$schedule_number = get_option('object_sync_for_salesforce_logs_how_often_number', '');
100
+		$frequency       = $this->get_schedule_frequency($schedule_unit, $schedule_number);
101 101
 		$key             = $frequency['key'];
102 102
 		$seconds         = $frequency['seconds'];
103 103
 
104
-		$schedules[ $key ] = array(
104
+		$schedules[$key] = array(
105 105
 			'interval' => $seconds * $schedule_number,
106 106
 			'display'  => 'Every ' . $schedule_number . ' ' . $schedule_unit,
107 107
 		);
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 	 * @param number $number The number of those units.
119 119
 	 * @return array
120 120
 	 */
121
-	public function get_schedule_frequency( $unit, $number ) {
121
+	public function get_schedule_frequency($unit, $number) {
122 122
 
123
-		switch ( $unit ) {
123
+		switch ($unit) {
124 124
 			case 'minutes':
125 125
 				$seconds = 60;
126 126
 				break;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param array $terms An array of string log types in the WP_Logging class.
150 150
 	 * @return array $terms
151 151
 	 */
152
-	public function set_log_types( $terms ) {
152
+	public function set_log_types($terms) {
153 153
 		$terms[] = 'salesforce';
154 154
 		return $terms;
155 155
 	}
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	 * @param string $should_we_prune Whether to prune old log items.
161 161
 	 * @return string $should_we_prune Whether to prune old log items.
162 162
 	 */
163
-	public function set_prune_option( $should_we_prune ) {
164
-		$should_we_prune = get_option( 'object_sync_for_salesforce_prune_logs', $should_we_prune );
165
-		if ( '1' === $should_we_prune ) {
163
+	public function set_prune_option($should_we_prune) {
164
+		$should_we_prune = get_option('object_sync_for_salesforce_prune_logs', $should_we_prune);
165
+		if ('1' === $should_we_prune) {
166 166
 			$should_we_prune = true;
167 167
 		}
168 168
 		return $should_we_prune;
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	 * @param string $how_old How old the oldest non-pruned log items should be allowed to be.
175 175
 	 * @return string $how_old
176 176
 	 */
177
-	public function set_prune_age( $how_old ) {
178
-		$value = get_option( 'object_sync_for_salesforce_logs_how_old', '' ) . ' ago';
179
-		if ( '' !== $value ) {
177
+	public function set_prune_age($how_old) {
178
+		$value = get_option('object_sync_for_salesforce_logs_how_old', '') . ' ago';
179
+		if ('' !== $value) {
180 180
 			return $value;
181 181
 		} else {
182 182
 			return $how_old;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param array $args Argument array for get_posts determining what posts are eligible for pruning.
190 190
 	 * @return array $args
191 191
 	 */
192
-	public function set_prune_args( $args ) {
192
+	public function set_prune_args($args) {
193 193
 		$args['wp_log_type'] = 'salesforce';
194 194
 		return $args;
195 195
 	}
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return      void
215 215
 	 */
216
-	public function setup( $title, $message, $trigger = 0, $parent = 0, $status ) {
217
-		if ( '1' === $this->enabled && in_array( $status, maybe_unserialize( $this->statuses_to_log ), true ) ) {
218
-			$triggers_to_log = get_option( 'object_sync_for_salesforce_triggers_to_log', array() );
216
+	public function setup($title, $message, $trigger = 0, $parent = 0, $status) {
217
+		if ('1' === $this->enabled && in_array($status, maybe_unserialize($this->statuses_to_log), true)) {
218
+			$triggers_to_log = get_option('object_sync_for_salesforce_triggers_to_log', array());
219 219
 			// if we force strict on this in_array, it fails because the mapping triggers are bit operators, as indicated in Object_Sync_Sf_Mapping class's method __construct()
220
-			if ( in_array( $trigger, maybe_unserialize( $triggers_to_log ) ) || 0 === $trigger ) {
221
-				$this->add( $title, $message, $parent );
220
+			if (in_array($trigger, maybe_unserialize($triggers_to_log)) || 0 === $trigger) {
221
+				$this->add($title, $message, $parent);
222 222
 			}
223 223
 		}
224 224
 	}
@@ -241,16 +241,16 @@  discard block
 block discarded – undo
241 241
 	 *
242 242
 	 * @return      int The ID of the new log entry
243 243
 	 */
244
-	public static function add( $title = '', $message = '', $parent = 0, $type = 'salesforce' ) {
244
+	public static function add($title = '', $message = '', $parent = 0, $type = 'salesforce') {
245 245
 
246 246
 		$log_data = array(
247
-			'post_title'   => esc_html( $title ),
248
-			'post_content' => wp_kses_post( $message ),
249
-			'post_parent'  => absint( $parent ),
250
-			'log_type'     => esc_attr( $type ),
247
+			'post_title'   => esc_html($title),
248
+			'post_content' => wp_kses_post($message),
249
+			'post_parent'  => absint($parent),
250
+			'log_type'     => esc_attr($type),
251 251
 		);
252 252
 
253
-		return self::insert_log( $log_data );
253
+		return self::insert_log($log_data);
254 254
 
255 255
 	}
256 256
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @return      array
271 271
 	 */
272
-	public static function get_logs( $object_id = 0, $type = 'salesforce', $paged = null ) {
272
+	public static function get_logs($object_id = 0, $type = 'salesforce', $paged = null) {
273 273
 		return self::get_connected_logs(
274 274
 			array(
275 275
 				'post_parent' => (int) $object_id,
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return  array / false
299 299
 	 */
300
-	public static function get_connected_logs( $args = array() ) {
300
+	public static function get_connected_logs($args = array()) {
301 301
 
302 302
 		$defaults = array(
303 303
 			'post_parent'    => 0,
304 304
 			'post_type'      => 'wp_log',
305 305
 			'posts_per_page' => 10,
306 306
 			'post_status'    => 'publish',
307
-			'paged'          => get_query_var( 'paged' ),
307
+			'paged'          => get_query_var('paged'),
308 308
 			'log_type'       => 'salesforce',
309 309
 		);
310 310
 
311
-		$query_args = wp_parse_args( $args, $defaults );
311
+		$query_args = wp_parse_args($args, $defaults);
312 312
 
313
-		if ( $query_args['log_type'] && self::valid_type( $query_args['log_type'] ) ) {
313
+		if ($query_args['log_type'] && self::valid_type($query_args['log_type'])) {
314 314
 
315 315
 			$query_args['tax_query'] = array(
316 316
 				array(
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 
323 323
 		}
324 324
 
325
-		$logs = get_posts( $query_args );
325
+		$logs = get_posts($query_args);
326 326
 
327
-		if ( $logs ) {
327
+		if ($logs) {
328 328
 			return $logs;
329 329
 		}
330 330
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	 *
350 350
 	 * @return  int
351 351
 	 */
352
-	public static function get_log_count( $object_id = 0, $type = 'salesforce', $meta_query = null ) {
352
+	public static function get_log_count($object_id = 0, $type = 'salesforce', $meta_query = null) {
353 353
 
354 354
 		$query_args = array(
355 355
 			'post_parent'    => (int) $object_id,
@@ -358,23 +358,23 @@  discard block
 block discarded – undo
358 358
 			'post_status'    => 'publish',
359 359
 		);
360 360
 
361
-		if ( ! empty( $type ) && self::valid_type( $type ) ) {
361
+		if ( ! empty($type) && self::valid_type($type)) {
362 362
 
363 363
 			$query_args['tax_query'] = array(
364 364
 				array(
365 365
 					'taxonomy' => 'wp_log_type',
366 366
 					'field'    => 'slug',
367
-					'terms'    => sanitize_key( $type ),
367
+					'terms'    => sanitize_key($type),
368 368
 				),
369 369
 			);
370 370
 
371 371
 		}
372 372
 
373
-		if ( ! empty( $meta_query ) ) {
373
+		if ( ! empty($meta_query)) {
374 374
 			$query_args['meta_query'] = $meta_query;
375 375
 		}
376 376
 
377
-		$logs = new WP_Query( $query_args );
377
+		$logs = new WP_Query($query_args);
378 378
 
379 379
 		return (int) $logs->post_count;
380 380
 
Please login to merge, or discard this patch.
classes/salesforce_soap_partner.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
 	public $wsdl;
23 23
 
24 24
 	/**
25
-	* Constructor which loads the SOAP client
26
-	*
27
-	*/
25
+	 * Constructor which loads the SOAP client
26
+	 *
27
+	 */
28 28
 	public function __construct( Object_Sync_Sf_Salesforce $sfapi, $wsdl = null ) {
29 29
 		if ( ! class_exists( 'SforceBaseClient' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
30 30
 			require_once plugin_dir_path( __FILE__ ) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/SforcePartnerClient.php';
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -25,33 +25,33 @@  discard block
 block discarded – undo
25 25
 	* Constructor which loads the SOAP client
26 26
 	*
27 27
 	*/
28
-	public function __construct( Object_Sync_Sf_Salesforce $sfapi, $wsdl = null ) {
29
-		if ( ! class_exists( 'SforceBaseClient' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
30
-			require_once plugin_dir_path( __FILE__ ) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/SforcePartnerClient.php';
28
+	public function __construct(Object_Sync_Sf_Salesforce $sfapi, $wsdl = null) {
29
+		if ( ! class_exists('SforceBaseClient') && file_exists(plugin_dir_path(__FILE__) . '../vendor/autoload.php')) {
30
+			require_once plugin_dir_path(__FILE__) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/SforcePartnerClient.php';
31 31
 		}
32 32
 		parent::__construct();
33
-		if ( empty( $wsdl ) ) {
34
-			$wsdl = plugin_dir_path( __FILE__ ) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/partner.wsdl.xml';
33
+		if (empty($wsdl)) {
34
+			$wsdl = plugin_dir_path(__FILE__) . '../vendor/developerforce/force.com-toolkit-for-php/soapclient/partner.wsdl.xml';
35 35
 		}
36
-		$this->set_authorized( false );
37
-		$this->createConnection( $wsdl );
36
+		$this->set_authorized(false);
37
+		$this->createConnection($wsdl);
38 38
 		$this->salesforce_api = $sfapi;
39 39
 
40
-		if ( $this->salesforce_api->is_authorized() ) {
40
+		if ($this->salesforce_api->is_authorized()) {
41 41
 			$token = $this->salesforce_api->get_access_token();
42
-			if ( ! $token ) {
42
+			if ( ! $token) {
43 43
 				$token = $this->salesforce_api->refresh_token();
44 44
 			}
45
-			$this->setSessionHeader( $token );
46
-			$this->setEndPoint( $this->salesforce_api->get_api_endpoint( 'partner' ) );
47
-			$this->set_authorized( true );
45
+			$this->setSessionHeader($token);
46
+			$this->setEndPoint($this->salesforce_api->get_api_endpoint('partner'));
47
+			$this->set_authorized(true);
48 48
 		} else {
49
-			error_log( 'salesforce is not authorized so we cannot use soap' );
50
-			$this->set_authorized( false );
49
+			error_log('salesforce is not authorized so we cannot use soap');
50
+			$this->set_authorized(false);
51 51
 		}
52 52
 	}
53 53
 
54
-	protected function set_authorized( $is_authorized ) {
54
+	protected function set_authorized($is_authorized) {
55 55
 		$this->is_authorized = $is_authorized;
56 56
 	}
57 57
 
@@ -59,35 +59,35 @@  discard block
 block discarded – undo
59 59
 		return $this->is_authorized;
60 60
 	}
61 61
 
62
-	public function try_soap( $function ) {
62
+	public function try_soap($function) {
63 63
 		$args = func_get_args();
64
-		array_shift( $args );
64
+		array_shift($args);
65 65
 		try {
66
-			$results = call_user_func_array( array( $this, $function ), $args );
66
+			$results = call_user_func_array(array($this, $function), $args);
67 67
 			// If returned without exceptions, reset the refreshed flag.
68 68
 			$this->refreshed = false;
69 69
 			return $results;
70
-		} catch ( SoapFault $e ) {
70
+		} catch (SoapFault $e) {
71 71
 			// sf:INVALID_SESSION_ID is thrown on expired login (and other reasons).
72 72
 			// Our only recourse is to try refreshing our auth token. If we get any
73 73
 			// other exception, bubble it up.
74
-			if ( 'sf:INVALID_SESSION_ID' !== $e->faultcode ) {
74
+			if ('sf:INVALID_SESSION_ID' !== $e->faultcode) {
75 75
 				throw $e;
76 76
 			}
77 77
 
78
-			if ( ! $this->refreshed ) {
78
+			if ( ! $this->refreshed) {
79 79
 				// If we got an invalid session exception, try to refresh the auth
80 80
 				// token through REST API. The "refreshed" flag will make sure we retry
81 81
 				// only once.
82 82
 				$this->refreshed = true;
83 83
 				$this->salesforce_api->refresh_token();
84
-				return $this->trySoap( $function, $args );
84
+				return $this->trySoap($function, $args);
85 85
 			}
86 86
 
87 87
 			// If we've already tried a refresh, this refresh token is probably
88 88
 			// invalid. Kill it, log, and bubble the exception.
89
-			$this->set_authorized( false );
90
-			error_log( 'website is not authorized to connect to salesforce. visit authorize page.' );
89
+			$this->set_authorized(false);
90
+			error_log('website is not authorized to connect to salesforce. visit authorize page.');
91 91
 			throw $e;
92 92
 
93 93
 		}
Please login to merge, or discard this patch.
classes/salesforce.php 2 patches
Indentation   +406 added lines, -406 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@  discard block
 block discarded – undo
17 17
 	public $response;
18 18
 
19 19
 	/**
20
-	* Constructor which initializes the Salesforce APIs.
21
-	*
22
-	* @param string $consumer_key
23
-	*   Salesforce key to connect to your Salesforce instance.
24
-	* @param string $consumer_secret
25
-	*   Salesforce secret to connect to your Salesforce instance.
26
-	* @param string $login_url
27
-	*   Login URL for Salesforce auth requests - differs for production and sandbox
28
-	* @param string $callback_url
29
-	*   WordPress URL where Salesforce should send you after authentication
30
-	* @param string $authorize_path
31
-	*   Oauth path that Salesforce wants
32
-	* @param string $token_path
33
-	*   Path Salesforce uses to give you a token
34
-	* @param string $rest_api_version
35
-	*   What version of the Salesforce REST API to use
36
-	* @param object $wordpress
37
-	*   Object for doing things to WordPress - retrieving data, cache, etc.
38
-	* @param string $slug
39
-	*   Slug for this plugin. Can be used for file including, especially
40
-	* @param object $logging
41
-	*   Logging object for this plugin.
42
-	* @param array $schedulable_classes
43
-	*   array of classes that can have scheduled tasks specific to them
44
-	*/
20
+	 * Constructor which initializes the Salesforce APIs.
21
+	 *
22
+	 * @param string $consumer_key
23
+	 *   Salesforce key to connect to your Salesforce instance.
24
+	 * @param string $consumer_secret
25
+	 *   Salesforce secret to connect to your Salesforce instance.
26
+	 * @param string $login_url
27
+	 *   Login URL for Salesforce auth requests - differs for production and sandbox
28
+	 * @param string $callback_url
29
+	 *   WordPress URL where Salesforce should send you after authentication
30
+	 * @param string $authorize_path
31
+	 *   Oauth path that Salesforce wants
32
+	 * @param string $token_path
33
+	 *   Path Salesforce uses to give you a token
34
+	 * @param string $rest_api_version
35
+	 *   What version of the Salesforce REST API to use
36
+	 * @param object $wordpress
37
+	 *   Object for doing things to WordPress - retrieving data, cache, etc.
38
+	 * @param string $slug
39
+	 *   Slug for this plugin. Can be used for file including, especially
40
+	 * @param object $logging
41
+	 *   Logging object for this plugin.
42
+	 * @param array $schedulable_classes
43
+	 *   array of classes that can have scheduled tasks specific to them
44
+	 */
45 45
 	public function __construct( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes ) {
46 46
 		$this->consumer_key        = $consumer_key;
47 47
 		$this->consumer_secret     = $consumer_secret;
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	/**
73
-	* Converts a 15-character case-sensitive Salesforce ID to 18-character
74
-	* case-insensitive ID. If input is not 15-characters, return input unaltered.
75
-	*
76
-	* @param string $sf_id_15
77
-	*   15-character case-sensitive Salesforce ID
78
-	* @return string
79
-	*   18-character case-insensitive Salesforce ID
80
-	*/
73
+	 * Converts a 15-character case-sensitive Salesforce ID to 18-character
74
+	 * case-insensitive ID. If input is not 15-characters, return input unaltered.
75
+	 *
76
+	 * @param string $sf_id_15
77
+	 *   15-character case-sensitive Salesforce ID
78
+	 * @return string
79
+	 *   18-character case-insensitive Salesforce ID
80
+	 */
81 81
 	public static function convert_id( $sf_id_15 ) {
82 82
 		if ( strlen( $sf_id_15 ) !== 15 ) {
83 83
 			return $sf_id_15;
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	/**
100
-	* Given a Salesforce ID, return the corresponding SObject name. (Based on
101
-	*  keyPrefix from object definition, @see
102
-	*  https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ )
103
-	*
104
-	* @param string $sf_id
105
-	*   15- or 18-character Salesforce ID
106
-	* @return string
107
-	*   sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE
108
-	*   if no match could be found.
109
-	* @throws Object_Sync_Sf_Exception
110
-	*/
100
+	 * Given a Salesforce ID, return the corresponding SObject name. (Based on
101
+	 *  keyPrefix from object definition, @see
102
+	 *  https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ )
103
+	 *
104
+	 * @param string $sf_id
105
+	 *   15- or 18-character Salesforce ID
106
+	 * @return string
107
+	 *   sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE
108
+	 *   if no match could be found.
109
+	 * @throws Object_Sync_Sf_Exception
110
+	 */
111 111
 	public function get_sobject_type( $sf_id ) {
112 112
 		$objects = $this->objects(
113 113
 			array(
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	/**
127
-	* Determine if this SF instance is fully configured.
128
-	*
129
-	*/
127
+	 * Determine if this SF instance is fully configured.
128
+	 *
129
+	 */
130 130
 	public function is_authorized() {
131 131
 		return ! empty( $this->consumer_key ) && ! empty( $this->consumer_secret ) && $this->get_refresh_token();
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Get REST API versions available on this Salesforce organization
136
-	* This is not an authenticated call, so it would not be a helpful test
137
-	*/
135
+	 * Get REST API versions available on this Salesforce organization
136
+	 * This is not an authenticated call, so it would not be a helpful test
137
+	 */
138 138
 	public function get_api_versions() {
139 139
 		$options = array(
140 140
 			'authenticated' => false,
@@ -144,26 +144,26 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 
146 146
 	/**
147
-	* Make a call to the Salesforce REST API.
148
-	*
149
-	* @param string $path
150
-	*   Path to resource.
151
-	* @param array $params
152
-	*   Parameters to provide.
153
-	* @param string $method
154
-	*   Method to initiate the call, such as GET or POST. Defaults to GET.
155
-	* @param array $options
156
-	*   Any method can supply options for the API call, and they'll be preserved as far as the curl request
157
-	*   They get merged with the class options
158
-	* @param string $type
159
-	*   Type of call. Defaults to 'rest' - currently we don't support other types.
160
-	*   Other exammple in Drupal is 'apexrest'
161
-	*
162
-	* @return mixed
163
-	*   The requested response.
164
-	*
165
-	* @throws Object_Sync_Sf_Exception
166
-	*/
147
+	 * Make a call to the Salesforce REST API.
148
+	 *
149
+	 * @param string $path
150
+	 *   Path to resource.
151
+	 * @param array $params
152
+	 *   Parameters to provide.
153
+	 * @param string $method
154
+	 *   Method to initiate the call, such as GET or POST. Defaults to GET.
155
+	 * @param array $options
156
+	 *   Any method can supply options for the API call, and they'll be preserved as far as the curl request
157
+	 *   They get merged with the class options
158
+	 * @param string $type
159
+	 *   Type of call. Defaults to 'rest' - currently we don't support other types.
160
+	 *   Other exammple in Drupal is 'apexrest'
161
+	 *
162
+	 * @return mixed
163
+	 *   The requested response.
164
+	 *
165
+	 * @throws Object_Sync_Sf_Exception
166
+	 */
167 167
 	public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
168 168
 		if ( ! $this->get_access_token() ) {
169 169
 			$this->refresh_token();
@@ -214,25 +214,25 @@  discard block
 block discarded – undo
214 214
 	}
215 215
 
216 216
 	/**
217
-	* Private helper to issue an SF API request.
218
-	* This method is the only place where we read to or write from the cache
219
-	*
220
-	* @param string $path
221
-	*   Path to resource.
222
-	* @param array $params
223
-	*   Parameters to provide.
224
-	* @param string $method
225
-	*   Method to initiate the call, such as GET or POST.  Defaults to GET.
226
-	* @param array $options
227
-	*   This is the options array from the api_call method
228
-	*   This is where it gets merged with $this->options
229
-	* @param string $type
230
-	*   Type of call. Defaults to 'rest' - currently we don't support other types
231
-	*   Other exammple in Drupal is 'apexrest'
232
-	*
233
-	* @return array
234
-	*   The requested data.
235
-	*/
217
+	 * Private helper to issue an SF API request.
218
+	 * This method is the only place where we read to or write from the cache
219
+	 *
220
+	 * @param string $path
221
+	 *   Path to resource.
222
+	 * @param array $params
223
+	 *   Parameters to provide.
224
+	 * @param string $method
225
+	 *   Method to initiate the call, such as GET or POST.  Defaults to GET.
226
+	 * @param array $options
227
+	 *   This is the options array from the api_call method
228
+	 *   This is where it gets merged with $this->options
229
+	 * @param string $type
230
+	 *   Type of call. Defaults to 'rest' - currently we don't support other types
231
+	 *   Other exammple in Drupal is 'apexrest'
232
+	 *
233
+	 * @return array
234
+	 *   The requested data.
235
+	 */
236 236
 	protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
237 237
 		$options = array_merge( $this->options, $options ); // this will override a value in $this->options with the one in $options if there is a matching key
238 238
 		$url     = $this->get_api_endpoint( $type ) . $path;
@@ -310,22 +310,22 @@  discard block
 block discarded – undo
310 310
 	}
311 311
 
312 312
 	/**
313
-	* Make the HTTP request. Wrapper around curl().
314
-	*
315
-	* @param string $url
316
-	*   Path to make request from.
317
-	* @param array $data
318
-	*   The request body.
319
-	* @param array $headers
320
-	*   Request headers to send as name => value.
321
-	* @param string $method
322
-	*   Method to initiate the call, such as GET or POST. Defaults to GET.
323
-	* @param array $options
324
-	*   This is the options array from the api_http_request method
325
-	*
326
-	* @return array
327
-	*   Salesforce response object.
328
-	*/
313
+	 * Make the HTTP request. Wrapper around curl().
314
+	 *
315
+	 * @param string $url
316
+	 *   Path to make request from.
317
+	 * @param array $data
318
+	 *   The request body.
319
+	 * @param array $headers
320
+	 *   Request headers to send as name => value.
321
+	 * @param string $method
322
+	 *   Method to initiate the call, such as GET or POST. Defaults to GET.
323
+	 * @param array $options
324
+	 *   This is the options array from the api_http_request method
325
+	 *
326
+	 * @return array
327
+	 *   Salesforce response object.
328
+	 */
329 329
 	protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
330 330
 		// Build the request, including path and headers. Internal use.
331 331
 
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
 	}
461 461
 
462 462
 	/**
463
-	* Get the API end point for a given type of the API.
464
-	*
465
-	* @param string $api_type
466
-	*   E.g., rest, partner, enterprise.
467
-	*
468
-	* @return string
469
-	*   Complete URL endpoint for API access.
470
-	*/
463
+	 * Get the API end point for a given type of the API.
464
+	 *
465
+	 * @param string $api_type
466
+	 *   E.g., rest, partner, enterprise.
467
+	 *
468
+	 * @return string
469
+	 *   Complete URL endpoint for API access.
470
+	 */
471 471
 	public function get_api_endpoint( $api_type = 'rest' ) {
472 472
 		// Special handling for apexrest, since it's not in the identity object.
473 473
 		if ( 'apexrest' === $api_type ) {
@@ -483,67 +483,67 @@  discard block
 block discarded – undo
483 483
 	}
484 484
 
485 485
 	/**
486
-	* Get the SF instance URL. Useful for linking to objects.
487
-	*/
486
+	 * Get the SF instance URL. Useful for linking to objects.
487
+	 */
488 488
 	public function get_instance_url() {
489 489
 		return get_option( 'object_sync_for_salesforce_instance_url', '' );
490 490
 	}
491 491
 
492 492
 	/**
493
-	* Set the SF instanc URL.
494
-	*
495
-	* @param string $url
496
-	*   URL to set.
497
-	*/
493
+	 * Set the SF instanc URL.
494
+	 *
495
+	 * @param string $url
496
+	 *   URL to set.
497
+	 */
498 498
 	protected function set_instance_url( $url ) {
499 499
 		update_option( 'object_sync_for_salesforce_instance_url', $url );
500 500
 	}
501 501
 
502 502
 	/**
503
-	* Get the access token.
504
-	*/
503
+	 * Get the access token.
504
+	 */
505 505
 	public function get_access_token() {
506 506
 		return get_option( 'object_sync_for_salesforce_access_token', '' );
507 507
 	}
508 508
 
509 509
 	/**
510
-	* Set the access token.
511
-	*
512
-	* It is stored in session.
513
-	*
514
-	* @param string $token
515
-	*   Access token from Salesforce.
516
-	*/
510
+	 * Set the access token.
511
+	 *
512
+	 * It is stored in session.
513
+	 *
514
+	 * @param string $token
515
+	 *   Access token from Salesforce.
516
+	 */
517 517
 	protected function set_access_token( $token ) {
518 518
 		update_option( 'object_sync_for_salesforce_access_token', $token );
519 519
 	}
520 520
 
521 521
 	/**
522
-	* Get refresh token.
523
-	*/
522
+	 * Get refresh token.
523
+	 */
524 524
 	protected function get_refresh_token() {
525 525
 		return get_option( 'object_sync_for_salesforce_refresh_token', '' );
526 526
 	}
527 527
 
528 528
 	/**
529
-	* Set refresh token.
530
-	*
531
-	* @param string $token
532
-	*   Refresh token from Salesforce.
533
-	*/
529
+	 * Set refresh token.
530
+	 *
531
+	 * @param string $token
532
+	 *   Refresh token from Salesforce.
533
+	 */
534 534
 	protected function set_refresh_token( $token ) {
535 535
 		update_option( 'object_sync_for_salesforce_refresh_token', $token );
536 536
 	}
537 537
 
538 538
 	/**
539
-	* Refresh access token based on the refresh token. Updates session variable.
540
-	*
541
-	* todo: figure out how to do this as part of the schedule class
542
-	* this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to.
543
-	* but it could be a performance boost to do it at scheduleable intervals instead.
544
-	*
545
-	* @throws Object_Sync_Sf_Exception
546
-	*/
539
+	 * Refresh access token based on the refresh token. Updates session variable.
540
+	 *
541
+	 * todo: figure out how to do this as part of the schedule class
542
+	 * this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to.
543
+	 * but it could be a performance boost to do it at scheduleable intervals instead.
544
+	 *
545
+	 * @throws Object_Sync_Sf_Exception
546
+	 */
547 547
 	protected function refresh_token() {
548 548
 		$refresh_token = $this->get_refresh_token();
549 549
 		if ( empty( $refresh_token ) ) {
@@ -590,13 +590,13 @@  discard block
 block discarded – undo
590 590
 	}
591 591
 
592 592
 	/**
593
-	* Retrieve and store the Salesforce identity given an ID url.
594
-	*
595
-	* @param string $id
596
-	*   Identity URL.
597
-	*
598
-	* @throws Object_Sync_Sf_Exception
599
-	*/
593
+	 * Retrieve and store the Salesforce identity given an ID url.
594
+	 *
595
+	 * @param string $id
596
+	 *   Identity URL.
597
+	 *
598
+	 * @throws Object_Sync_Sf_Exception
599
+	 */
600 600
 	protected function set_identity( $id ) {
601 601
 		$headers  = array(
602 602
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
@@ -612,18 +612,18 @@  discard block
 block discarded – undo
612 612
 	}
613 613
 
614 614
 	/**
615
-	* Return the Salesforce identity, which is stored in a variable.
616
-	*
617
-	* @return array
618
-	*   Returns FALSE if no identity has been stored.
619
-	*/
615
+	 * Return the Salesforce identity, which is stored in a variable.
616
+	 *
617
+	 * @return array
618
+	 *   Returns FALSE if no identity has been stored.
619
+	 */
620 620
 	public function get_identity() {
621 621
 		return get_option( 'object_sync_for_salesforce_identity', false );
622 622
 	}
623 623
 
624 624
 	/**
625
-	* OAuth step 1: Redirect to Salesforce and request and authorization code.
626
-	*/
625
+	 * OAuth step 1: Redirect to Salesforce and request and authorization code.
626
+	 */
627 627
 	public function get_authorization_code() {
628 628
 		$url = add_query_arg(
629 629
 			array(
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
 	}
638 638
 
639 639
 	/**
640
-	* OAuth step 2: Exchange an authorization code for an access token.
641
-	*
642
-	* @param string $code
643
-	*   Code from Salesforce.
644
-	*/
640
+	 * OAuth step 2: Exchange an authorization code for an access token.
641
+	 *
642
+	 * @param string $code
643
+	 *   Code from Salesforce.
644
+	 */
645 645
 	public function request_token( $code ) {
646 646
 		$data = array(
647 647
 			'code'          => $code,
@@ -686,22 +686,22 @@  discard block
 block discarded – undo
686 686
 	/* Core API calls */
687 687
 
688 688
 	/**
689
-	* Available objects and their metadata for your organization's data.
690
-	*
691
-	* @param array $conditions
692
-	*   Associative array of filters to apply to the returned objects. Filters
693
-	*   are applied after the list is returned from Salesforce.
694
-	* @param bool $reset
695
-	*   Whether to reset the cache and retrieve a fresh version from Salesforce.
696
-	*
697
-	* @return array
698
-	*   Available objects and metadata.
699
-	*
700
-	* part of core API calls. this call does require authentication, and the basic url it becomes is like this:
701
-	* https://instance.salesforce.com/services/data/v#.0/sobjects
702
-	*
703
-	* updateable is really how the api spells it
704
-	*/
689
+	 * Available objects and their metadata for your organization's data.
690
+	 *
691
+	 * @param array $conditions
692
+	 *   Associative array of filters to apply to the returned objects. Filters
693
+	 *   are applied after the list is returned from Salesforce.
694
+	 * @param bool $reset
695
+	 *   Whether to reset the cache and retrieve a fresh version from Salesforce.
696
+	 *
697
+	 * @return array
698
+	 *   Available objects and metadata.
699
+	 *
700
+	 * part of core API calls. this call does require authentication, and the basic url it becomes is like this:
701
+	 * https://instance.salesforce.com/services/data/v#.0/sobjects
702
+	 *
703
+	 * updateable is really how the api spells it
704
+	 */
705 705
 	public function objects(
706 706
 		$conditions = array(
707 707
 			'updateable'  => true,
@@ -731,22 +731,22 @@  discard block
 block discarded – undo
731 731
 	}
732 732
 
733 733
 	/**
734
-	* Use SOQL to get objects based on query string.
735
-	*
736
-	* @param string $query
737
-	*   The SOQL query.
738
-	* @param array $options
739
-	*   Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc.
740
-	* @param boolean $all
741
-	*   Whether this should get all results for the query
742
-	* @param boolean $explain
743
-	*   If set, Salesforce will return feedback on the query performance
744
-	*
745
-	* @return array
746
-	*   Array of Salesforce objects that match the query.
747
-	*
748
-	* part of core API calls
749
-	*/
734
+	 * Use SOQL to get objects based on query string.
735
+	 *
736
+	 * @param string $query
737
+	 *   The SOQL query.
738
+	 * @param array $options
739
+	 *   Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc.
740
+	 * @param boolean $all
741
+	 *   Whether this should get all results for the query
742
+	 * @param boolean $explain
743
+	 *   If set, Salesforce will return feedback on the query performance
744
+	 *
745
+	 * @return array
746
+	 *   Array of Salesforce objects that match the query.
747
+	 *
748
+	 * part of core API calls
749
+	 */
750 750
 	public function query( $query, $options = array(), $all = false, $explain = false ) {
751 751
 		$search_data = [
752 752
 			'q' => (string) $query,
@@ -766,19 +766,19 @@  discard block
 block discarded – undo
766 766
 	}
767 767
 
768 768
 	/**
769
-	* Retrieve all the metadata for an object.
770
-	*
771
-	* @param string $name
772
-	*   Object type name, E.g., Contact, Account, etc.
773
-	* @param bool $reset
774
-	*   Whether to reset the cache and retrieve a fresh version from Salesforce.
775
-	*
776
-	* @return array
777
-	*   All the metadata for an object, including information about each field,
778
-	*   URLs, and child relationships.
779
-	*
780
-	* part of core API calls
781
-	*/
769
+	 * Retrieve all the metadata for an object.
770
+	 *
771
+	 * @param string $name
772
+	 *   Object type name, E.g., Contact, Account, etc.
773
+	 * @param bool $reset
774
+	 *   Whether to reset the cache and retrieve a fresh version from Salesforce.
775
+	 *
776
+	 * @return array
777
+	 *   All the metadata for an object, including information about each field,
778
+	 *   URLs, and child relationships.
779
+	 *
780
+	 * part of core API calls
781
+	 */
782 782
 	public function object_describe( $name, $reset = false ) {
783 783
 		if ( empty( $name ) ) {
784 784
 			return array();
@@ -806,26 +806,26 @@  discard block
 block discarded – undo
806 806
 	}
807 807
 
808 808
 	/**
809
-	* Create a new object of the given type.
810
-	*
811
-	* @param string $name
812
-	*   Object type name, E.g., Contact, Account, etc.
813
-	* @param array $params
814
-	*   Values of the fields to set for the object.
815
-	*
816
-	* @return array
817
-	*   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
818
-	*   code: 201
819
-	*   data:
820
-	*     "id" : "00190000001pPvHAAU",
821
-	*     "success" : true
822
-	*     "errors" : [ ],
823
-	*   from_cache:
824
-	*   cached:
825
-	*   is_redo:
826
-	*
827
-	* part of core API calls
828
-	*/
809
+	 * Create a new object of the given type.
810
+	 *
811
+	 * @param string $name
812
+	 *   Object type name, E.g., Contact, Account, etc.
813
+	 * @param array $params
814
+	 *   Values of the fields to set for the object.
815
+	 *
816
+	 * @return array
817
+	 *   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
818
+	 *   code: 201
819
+	 *   data:
820
+	 *     "id" : "00190000001pPvHAAU",
821
+	 *     "success" : true
822
+	 *     "errors" : [ ],
823
+	 *   from_cache:
824
+	 *   cached:
825
+	 *   is_redo:
826
+	 *
827
+	 * part of core API calls
828
+	 */
829 829
 	public function object_create( $name, $params ) {
830 830
 		$options = array(
831 831
 			'type' => 'write',
@@ -835,34 +835,34 @@  discard block
 block discarded – undo
835 835
 	}
836 836
 
837 837
 	/**
838
-	* Create new records or update existing records.
839
-	*
840
-	* The new records or updated records are based on the value of the specified
841
-	* field.  If the value is not unique, REST API returns a 300 response with
842
-	* the list of matching records.
843
-	*
844
-	* @param string $name
845
-	*   Object type name, E.g., Contact, Account.
846
-	* @param string $key
847
-	*   The field to check if this record should be created or updated.
848
-	* @param string $value
849
-	*   The value for this record of the field specified for $key.
850
-	* @param array $params
851
-	*   Values of the fields to set for the object.
852
-	*
853
-	* @return array
854
-	*   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
855
-	*   code: 201
856
-	*   data:
857
-	*     "id" : "00190000001pPvHAAU",
858
-	*     "success" : true
859
-	*     "errors" : [ ],
860
-	*   from_cache:
861
-	*   cached:
862
-	*   is_redo:
863
-	*
864
-	* part of core API calls
865
-	*/
838
+	 * Create new records or update existing records.
839
+	 *
840
+	 * The new records or updated records are based on the value of the specified
841
+	 * field.  If the value is not unique, REST API returns a 300 response with
842
+	 * the list of matching records.
843
+	 *
844
+	 * @param string $name
845
+	 *   Object type name, E.g., Contact, Account.
846
+	 * @param string $key
847
+	 *   The field to check if this record should be created or updated.
848
+	 * @param string $value
849
+	 *   The value for this record of the field specified for $key.
850
+	 * @param array $params
851
+	 *   Values of the fields to set for the object.
852
+	 *
853
+	 * @return array
854
+	 *   json: {"id":"00190000001pPvHAAU","success":true,"errors":[]}
855
+	 *   code: 201
856
+	 *   data:
857
+	 *     "id" : "00190000001pPvHAAU",
858
+	 *     "success" : true
859
+	 *     "errors" : [ ],
860
+	 *   from_cache:
861
+	 *   cached:
862
+	 *   is_redo:
863
+	 *
864
+	 * part of core API calls
865
+	 */
866 866
 	public function object_upsert( $name, $key, $value, $params ) {
867 867
 		$options = array(
868 868
 			'type' => 'write',
@@ -884,27 +884,27 @@  discard block
 block discarded – undo
884 884
 	}
885 885
 
886 886
 	/**
887
-	* Update an existing object.
888
-	*
889
-	* @param string $name
890
-	*   Object type name, E.g., Contact, Account.
891
-	* @param string $id
892
-	*   Salesforce id of the object.
893
-	* @param array $params
894
-	*   Values of the fields to set for the object.
895
-	*
896
-	* part of core API calls
897
-	*
898
-	* @return array
899
-	*   json: {"success":true,"body":""}
900
-	*   code: 204
901
-	*   data:
887
+	 * Update an existing object.
888
+	 *
889
+	 * @param string $name
890
+	 *   Object type name, E.g., Contact, Account.
891
+	 * @param string $id
892
+	 *   Salesforce id of the object.
893
+	 * @param array $params
894
+	 *   Values of the fields to set for the object.
895
+	 *
896
+	 * part of core API calls
897
+	 *
898
+	 * @return array
899
+	 *   json: {"success":true,"body":""}
900
+	 *   code: 204
901
+	 *   data:
902 902
 		success: 1
903 903
 		body:
904
-	*   from_cache:
905
-	*   cached:
906
-	*   is_redo:
907
-	*/
904
+	 *   from_cache:
905
+	 *   cached:
906
+	 *   is_redo:
907
+	 */
908 908
 	public function object_update( $name, $id, $params ) {
909 909
 		$options = array(
910 910
 			'type' => 'write',
@@ -914,62 +914,62 @@  discard block
 block discarded – undo
914 914
 	}
915 915
 
916 916
 	/**
917
-	* Return a full loaded Salesforce object.
918
-	*
919
-	* @param string $name
920
-	*   Object type name, E.g., Contact, Account.
921
-	* @param string $id
922
-	*   Salesforce id of the object.
923
-	*
924
-	* @return object
925
-	*   Object of the requested Salesforce object.
926
-	*
927
-	* part of core API calls
928
-	*/
917
+	 * Return a full loaded Salesforce object.
918
+	 *
919
+	 * @param string $name
920
+	 *   Object type name, E.g., Contact, Account.
921
+	 * @param string $id
922
+	 *   Salesforce id of the object.
923
+	 *
924
+	 * @return object
925
+	 *   Object of the requested Salesforce object.
926
+	 *
927
+	 * part of core API calls
928
+	 */
929 929
 	public function object_read( $name, $id ) {
930 930
 		return $this->api_call( "sobjects/{$name}/{$id}", array(), 'GET' );
931 931
 	}
932 932
 
933 933
 	/**
934
-	* Make a call to the Analytics API
935
-	*
936
-	* @param string $name
937
-	*   Object type name, E.g., Report
938
-	* @param string $id
939
-	*   Salesforce id of the object.
940
-	* @param string $route
941
-	*   What comes after the ID? E.g. instances, ?includeDetails=True
942
-	* @param array $params
943
-	*   Params to put with the request
944
-	* @param string $method
945
-	*   GET or POST
946
-	*
947
-	* @return object
948
-	*   Object of the requested Salesforce object.
949
-	*
950
-	* part of core API calls
951
-	*/
934
+	 * Make a call to the Analytics API
935
+	 *
936
+	 * @param string $name
937
+	 *   Object type name, E.g., Report
938
+	 * @param string $id
939
+	 *   Salesforce id of the object.
940
+	 * @param string $route
941
+	 *   What comes after the ID? E.g. instances, ?includeDetails=True
942
+	 * @param array $params
943
+	 *   Params to put with the request
944
+	 * @param string $method
945
+	 *   GET or POST
946
+	 *
947
+	 * @return object
948
+	 *   Object of the requested Salesforce object.
949
+	 *
950
+	 * part of core API calls
951
+	 */
952 952
 	public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
953 953
 		return $this->api_call( "analytics/{$name}/{$id}/{$route}", $params, $method );
954 954
 	}
955 955
 
956 956
 	/**
957
-	* Run a specific Analytics report
958
-	*
959
-	* @param string $id
960
-	*   Salesforce id of the object.
961
-	* @param bool $async
962
-	*   Whether the report is asynchronous
963
-	* @param array $params
964
-	*   Params to put with the request
965
-	* @param string $method
966
-	*   GET or POST
967
-	*
968
-	* @return object
969
-	*   Object of the requested Salesforce object.
970
-	*
971
-	* part of core API calls
972
-	*/
957
+	 * Run a specific Analytics report
958
+	 *
959
+	 * @param string $id
960
+	 *   Salesforce id of the object.
961
+	 * @param bool $async
962
+	 *   Whether the report is asynchronous
963
+	 * @param array $params
964
+	 *   Params to put with the request
965
+	 * @param string $method
966
+	 *   GET or POST
967
+	 *
968
+	 * @return object
969
+	 *   Object of the requested Salesforce object.
970
+	 *
971
+	 * part of core API calls
972
+	 */
973 973
 	public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
974 974
 
975 975
 		$id         = $this->convert_id( $id );
@@ -1055,36 +1055,36 @@  discard block
 block discarded – undo
1055 1055
 	}
1056 1056
 
1057 1057
 	/**
1058
-	* Return a full loaded Salesforce object from External ID.
1059
-	*
1060
-	* @param string $name
1061
-	*   Object type name, E.g., Contact, Account.
1062
-	* @param string $field
1063
-	*   Salesforce external id field name.
1064
-	* @param string $value
1065
-	*   Value of external id.
1066
-	*
1067
-	* @return object
1068
-	*   Object of the requested Salesforce object.
1069
-	*
1070
-	* part of core API calls
1071
-	*/
1058
+	 * Return a full loaded Salesforce object from External ID.
1059
+	 *
1060
+	 * @param string $name
1061
+	 *   Object type name, E.g., Contact, Account.
1062
+	 * @param string $field
1063
+	 *   Salesforce external id field name.
1064
+	 * @param string $value
1065
+	 *   Value of external id.
1066
+	 *
1067
+	 * @return object
1068
+	 *   Object of the requested Salesforce object.
1069
+	 *
1070
+	 * part of core API calls
1071
+	 */
1072 1072
 	public function object_readby_external_id( $name, $field, $value ) {
1073 1073
 		return $this->api_call( "sobjects/{$name}/{$field}/{$value}" );
1074 1074
 	}
1075 1075
 
1076 1076
 	/**
1077
-	* Delete a Salesforce object.
1078
-	*
1079
-	* @param string $name
1080
-	*   Object type name, E.g., Contact, Account.
1081
-	* @param string $id
1082
-	*   Salesforce id of the object.
1083
-	*
1084
-	* @return array
1085
-	*
1086
-	* part of core API calls
1087
-	*/
1077
+	 * Delete a Salesforce object.
1078
+	 *
1079
+	 * @param string $name
1080
+	 *   Object type name, E.g., Contact, Account.
1081
+	 * @param string $id
1082
+	 *   Salesforce id of the object.
1083
+	 *
1084
+	 * @return array
1085
+	 *
1086
+	 * part of core API calls
1087
+	 */
1088 1088
 	public function object_delete( $name, $id ) {
1089 1089
 		$options = array(
1090 1090
 			'type' => 'write',
@@ -1094,17 +1094,17 @@  discard block
 block discarded – undo
1094 1094
 	}
1095 1095
 
1096 1096
 	/**
1097
-	* Retrieves the list of individual objects that have been deleted within the
1098
-	* given timespan for a specified object type.
1099
-	*
1100
-	* @param string $type
1101
-	*   Object type name, E.g., Contact, Account.
1102
-	* @param string $startDate
1103
-	*   Start date to check for deleted objects (in ISO 8601 format).
1104
-	* @param string $endDate
1105
-	*   End date to check for deleted objects (in ISO 8601 format).
1106
-	* @return GetDeletedResult
1107
-	*/
1097
+	 * Retrieves the list of individual objects that have been deleted within the
1098
+	 * given timespan for a specified object type.
1099
+	 *
1100
+	 * @param string $type
1101
+	 *   Object type name, E.g., Contact, Account.
1102
+	 * @param string $startDate
1103
+	 *   Start date to check for deleted objects (in ISO 8601 format).
1104
+	 * @param string $endDate
1105
+	 *   End date to check for deleted objects (in ISO 8601 format).
1106
+	 * @return GetDeletedResult
1107
+	 */
1108 1108
 	public function get_deleted( $type, $start_date, $end_date ) {
1109 1109
 		$options = array(
1110 1110
 			'cache' => false,
@@ -1114,13 +1114,13 @@  discard block
 block discarded – undo
1114 1114
 
1115 1115
 
1116 1116
 	/**
1117
-	* Return a list of available resources for the configured API version.
1118
-	*
1119
-	* @return array
1120
-	*   Associative array keyed by name with a URI value.
1121
-	*
1122
-	* part of core API calls
1123
-	*/
1117
+	 * Return a list of available resources for the configured API version.
1118
+	 *
1119
+	 * @return array
1120
+	 *   Associative array keyed by name with a URI value.
1121
+	 *
1122
+	 * part of core API calls
1123
+	 */
1124 1124
 	public function list_resources() {
1125 1125
 		$resources = $this->api_call( '' );
1126 1126
 		foreach ( $resources as $key => $path ) {
@@ -1130,31 +1130,31 @@  discard block
 block discarded – undo
1130 1130
 	}
1131 1131
 
1132 1132
 	/**
1133
-	* Return a list of SFIDs for the given object, which have been created or
1134
-	* updated in the given timeframe.
1135
-	*
1136
-	* @param string $type
1137
-	*   Object type name, E.g., Contact, Account.
1138
-	*
1139
-	* @param int $start
1140
-	*   unix timestamp for older timeframe for updates.
1141
-	*   Defaults to "-29 days" if empty.
1142
-	*
1143
-	* @param int $end
1144
-	*   unix timestamp for end of timeframe for updates.
1145
-	*   Defaults to now if empty
1146
-	*
1147
-	* @return array
1148
-	*   return array has 2 indexes:
1149
-	*     "ids": a list of SFIDs of those records which have been created or
1150
-	*       updated in the given timeframe.
1151
-	*     "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date
1152
-	*       covered in the request.
1153
-	*
1154
-	* @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm
1155
-	*
1156
-	* part of core API calls
1157
-	*/
1133
+	 * Return a list of SFIDs for the given object, which have been created or
1134
+	 * updated in the given timeframe.
1135
+	 *
1136
+	 * @param string $type
1137
+	 *   Object type name, E.g., Contact, Account.
1138
+	 *
1139
+	 * @param int $start
1140
+	 *   unix timestamp for older timeframe for updates.
1141
+	 *   Defaults to "-29 days" if empty.
1142
+	 *
1143
+	 * @param int $end
1144
+	 *   unix timestamp for end of timeframe for updates.
1145
+	 *   Defaults to now if empty
1146
+	 *
1147
+	 * @return array
1148
+	 *   return array has 2 indexes:
1149
+	 *     "ids": a list of SFIDs of those records which have been created or
1150
+	 *       updated in the given timeframe.
1151
+	 *     "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date
1152
+	 *       covered in the request.
1153
+	 *
1154
+	 * @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm
1155
+	 *
1156
+	 * part of core API calls
1157
+	 */
1158 1158
 	public function get_updated( $type, $start = null, $end = null ) {
1159 1159
 		if ( empty( $start ) ) {
1160 1160
 			$start = strtotime( '-29 days' );
@@ -1173,19 +1173,19 @@  discard block
 block discarded – undo
1173 1173
 	}
1174 1174
 
1175 1175
 	/**
1176
-	* Given a DeveloperName and SObject Name, return the SFID of the
1177
-	* corresponding RecordType. DeveloperName doesn't change between Salesforce
1178
-	* environments, so it's safer to rely on compared to SFID.
1179
-	*
1180
-	* @param string $name
1181
-	*   Object type name, E.g., Contact, Account.
1182
-	*
1183
-	* @param string $devname
1184
-	*   RecordType DeveloperName, e.g. Donation, Membership, etc.
1185
-	*
1186
-	* @return string SFID
1187
-	*   The Salesforce ID of the given Record Type, or null.
1188
-	*/
1176
+	 * Given a DeveloperName and SObject Name, return the SFID of the
1177
+	 * corresponding RecordType. DeveloperName doesn't change between Salesforce
1178
+	 * environments, so it's safer to rely on compared to SFID.
1179
+	 *
1180
+	 * @param string $name
1181
+	 *   Object type name, E.g., Contact, Account.
1182
+	 *
1183
+	 * @param string $devname
1184
+	 *   RecordType DeveloperName, e.g. Donation, Membership, etc.
1185
+	 *
1186
+	 * @return string SFID
1187
+	 *   The Salesforce ID of the given Record Type, or null.
1188
+	 */
1189 1189
 
1190 1190
 	public function get_record_type_id_by_developer_name( $name, $devname, $reset = false ) {
1191 1191
 
@@ -1213,10 +1213,10 @@  discard block
 block discarded – undo
1213 1213
 	}
1214 1214
 
1215 1215
 	/**
1216
-	* If there is a WordPress setting for how long to keep the cache, return it and set the object property
1217
-	* Otherwise, return seconds in 24 hours
1218
-	*
1219
-	*/
1216
+	 * If there is a WordPress setting for how long to keep the cache, return it and set the object property
1217
+	 * Otherwise, return seconds in 24 hours
1218
+	 *
1219
+	 */
1220 1220
 	private function cache_expiration() {
1221 1221
 		$cache_expiration = $this->wordpress->cache_expiration( 'object_sync_for_salesforce_cache_expiration', 86400 );
1222 1222
 		return $cache_expiration;
Please login to merge, or discard this patch.
Spacing   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	* @param array $schedulable_classes
43 43
 	*   array of classes that can have scheduled tasks specific to them
44 44
 	*/
45
-	public function __construct( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes ) {
45
+	public function __construct($consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $logging, $schedulable_classes) {
46 46
 		$this->consumer_key        = $consumer_key;
47 47
 		$this->consumer_secret     = $consumer_secret;
48 48
 		$this->login_url           = $login_url;
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 			'type'             => 'read',
61 61
 		);
62 62
 
63
-		$this->success_codes              = array( 200, 201, 204 );
63
+		$this->success_codes              = array(200, 201, 204);
64 64
 		$this->refresh_code               = 401;
65 65
 		$this->success_or_refresh_codes   = $this->success_codes;
66 66
 		$this->success_or_refresh_codes[] = $this->refresh_code;
67 67
 
68
-		$this->debug = get_option( 'object_sync_for_salesforce_debug_mode', false );
68
+		$this->debug = get_option('object_sync_for_salesforce_debug_mode', false);
69 69
 
70 70
 	}
71 71
 
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 	* @return string
79 79
 	*   18-character case-insensitive Salesforce ID
80 80
 	*/
81
-	public static function convert_id( $sf_id_15 ) {
82
-		if ( strlen( $sf_id_15 ) !== 15 ) {
81
+	public static function convert_id($sf_id_15) {
82
+		if (strlen($sf_id_15) !== 15) {
83 83
 			return $sf_id_15;
84 84
 		}
85
-		$chunks = str_split( $sf_id_15, 5 );
85
+		$chunks = str_split($sf_id_15, 5);
86 86
 		$extra  = '';
87
-		foreach ( $chunks as $chunk ) {
88
-			$chars = str_split( $chunk, 1 );
87
+		foreach ($chunks as $chunk) {
88
+			$chars = str_split($chunk, 1);
89 89
 			$bits  = '';
90
-			foreach ( $chars as $char ) {
91
-				$bits .= ( ! is_numeric( $char ) && strtoupper( $char ) === $char ) ? '1' : '0';
90
+			foreach ($chars as $char) {
91
+				$bits .= ( ! is_numeric($char) && strtoupper($char) === $char) ? '1' : '0';
92 92
 			}
93 93
 			$map    = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345';
94
-			$extra .= substr( $map, base_convert( strrev( $bits ), 2, 10 ), 1 );
94
+			$extra .= substr($map, base_convert(strrev($bits), 2, 10), 1);
95 95
 		}
96 96
 		return $sf_id_15 . $extra;
97 97
 	}
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	*   if no match could be found.
109 109
 	* @throws Object_Sync_Sf_Exception
110 110
 	*/
111
-	public function get_sobject_type( $sf_id ) {
111
+	public function get_sobject_type($sf_id) {
112 112
 		$objects = $this->objects(
113 113
 			array(
114
-				'keyPrefix' => substr( $sf_id, 0, 3 ),
114
+				'keyPrefix' => substr($sf_id, 0, 3),
115 115
 			)
116 116
 		);
117
-		if ( 1 === count( $objects ) ) {
117
+		if (1 === count($objects)) {
118 118
 			// keyPrefix is unique across objects. If there is exactly one return value from objects(), then we have a match.
119
-			$object = reset( $objects );
119
+			$object = reset($objects);
120 120
 			return $object['name'];
121 121
 		}
122 122
 		// Otherwise, we did not find a match.
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	*
129 129
 	*/
130 130
 	public function is_authorized() {
131
-		return ! empty( $this->consumer_key ) && ! empty( $this->consumer_secret ) && $this->get_refresh_token();
131
+		return ! empty($this->consumer_key) && ! empty($this->consumer_secret) && $this->get_refresh_token();
132 132
 	}
133 133
 
134 134
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 			'authenticated' => false,
141 141
 			'full_url'      => true,
142 142
 		);
143
-		return $this->api_call( $this->get_instance_url() . '/services/data', [], 'GET', $options );
143
+		return $this->api_call($this->get_instance_url() . '/services/data', [], 'GET', $options);
144 144
 	}
145 145
 
146 146
 	/**
@@ -164,50 +164,50 @@  discard block
 block discarded – undo
164 164
 	*
165 165
 	* @throws Object_Sync_Sf_Exception
166 166
 	*/
167
-	public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
168
-		if ( ! $this->get_access_token() ) {
167
+	public function api_call($path, $params = array(), $method = 'GET', $options = array(), $type = 'rest') {
168
+		if ( ! $this->get_access_token()) {
169 169
 			$this->refresh_token();
170 170
 		}
171
-		$this->response = $this->api_http_request( $path, $params, $method, $options, $type );
171
+		$this->response = $this->api_http_request($path, $params, $method, $options, $type);
172 172
 
173 173
 		// analytic calls that are expired return 404s for some absurd reason
174
-		if ( $this->response['code'] && 'run_analytics_report' === debug_backtrace()[1]['function'] ) {
174
+		if ($this->response['code'] && 'run_analytics_report' === debug_backtrace()[1]['function']) {
175 175
 			return $this->response;
176 176
 		}
177 177
 
178
-		switch ( $this->response['code'] ) {
178
+		switch ($this->response['code']) {
179 179
 			// The session ID or OAuth token used has expired or is invalid.
180 180
 			case $this->response['code'] === $this->refresh_code:
181 181
 				// Refresh token.
182 182
 				$this->refresh_token();
183 183
 				// Rebuild our request and repeat request.
184 184
 				$options['is_redo'] = true;
185
-				$this->response     = $this->api_http_request( $path, $params, $method, $options, $type );
185
+				$this->response     = $this->api_http_request($path, $params, $method, $options, $type);
186 186
 				// Throw an error if we still have bad response.
187
-				if ( ! in_array( $this->response['code'], $this->success_codes, true ) ) {
188
-					throw new Object_Sync_Sf_Exception( $this->response['data'][0]['message'], $this->response['code'] );
187
+				if ( ! in_array($this->response['code'], $this->success_codes, true)) {
188
+					throw new Object_Sync_Sf_Exception($this->response['data'][0]['message'], $this->response['code']);
189 189
 				}
190 190
 				break;
191
-			case in_array( $this->response['code'], $this->success_codes, true ):
191
+			case in_array($this->response['code'], $this->success_codes, true):
192 192
 				// All clear.
193 193
 				break;
194 194
 			default:
195 195
 				// We have problem and no specific Salesforce error provided.
196
-				if ( empty( $this->response['data'] ) ) {
197
-					throw new Object_Sync_Sf_Exception( $this->response['error'], $this->response['code'] );
196
+				if (empty($this->response['data'])) {
197
+					throw new Object_Sync_Sf_Exception($this->response['error'], $this->response['code']);
198 198
 				}
199 199
 		}
200 200
 
201
-		if ( ! empty( $this->response['data'][0] ) && 1 === count( $this->response['data'] ) ) {
201
+		if ( ! empty($this->response['data'][0]) && 1 === count($this->response['data'])) {
202 202
 			$this->response['data'] = $this->response['data'][0];
203 203
 		}
204 204
 
205
-		if ( isset( $this->response['data']['error'] ) ) {
206
-			throw new Object_Sync_Sf_Exception( $this->response['data']['error_description'], $this->response['data']['error'] );
205
+		if (isset($this->response['data']['error'])) {
206
+			throw new Object_Sync_Sf_Exception($this->response['data']['error_description'], $this->response['data']['error']);
207 207
 		}
208 208
 
209
-		if ( ! empty( $this->response['data']['errorCode'] ) ) {
210
-			throw new Object_Sync_Sf_Exception( $this->response['data']['message'], $this->response['code'] );
209
+		if ( ! empty($this->response['data']['errorCode'])) {
210
+			throw new Object_Sync_Sf_Exception($this->response['data']['message'], $this->response['code']);
211 211
 		}
212 212
 
213 213
 		return $this->response;
@@ -233,73 +233,73 @@  discard block
 block discarded – undo
233 233
 	* @return array
234 234
 	*   The requested data.
235 235
 	*/
236
-	protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
237
-		$options = array_merge( $this->options, $options ); // this will override a value in $this->options with the one in $options if there is a matching key
238
-		$url     = $this->get_api_endpoint( $type ) . $path;
239
-		if ( isset( $options['full_url'] ) && true === $options['full_url'] ) {
236
+	protected function api_http_request($path, $params, $method, $options = array(), $type = 'rest') {
237
+		$options = array_merge($this->options, $options); // this will override a value in $this->options with the one in $options if there is a matching key
238
+		$url     = $this->get_api_endpoint($type) . $path;
239
+		if (isset($options['full_url']) && true === $options['full_url']) {
240 240
 			$url = $path;
241 241
 		}
242 242
 		$headers = array(
243 243
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
244 244
 			'Accept-Encoding' => 'Accept-Encoding: gzip, deflate',
245 245
 		);
246
-		if ( 'POST' === $method || 'PATCH' === $method ) {
246
+		if ('POST' === $method || 'PATCH' === $method) {
247 247
 			$headers['Content-Type'] = 'Content-Type: application/json';
248 248
 		}
249
-		if ( isset( $options['authenticated'] ) && true === $options['authenticated'] ) {
249
+		if (isset($options['authenticated']) && true === $options['authenticated']) {
250 250
 			$headers = false;
251 251
 		}
252 252
 		// if this request should be cached, see if it already exists
253 253
 		// if it is already cached, load it. if not, load it and then cache it if it should be cached
254 254
 		// add parameters to the array so we can tell if it was cached or not
255
-		if ( true === $options['cache'] && 'write' !== $options['type'] ) {
256
-			$cached = $this->wordpress->cache_get( $url, $params );
255
+		if (true === $options['cache'] && 'write' !== $options['type']) {
256
+			$cached = $this->wordpress->cache_get($url, $params);
257 257
 			// some api calls can send a reset option, in which case we should redo the request anyway
258
-			if ( is_array( $cached ) && ( ! isset( $options['reset'] ) || true !== $options['reset'] ) ) {
258
+			if (is_array($cached) && ( ! isset($options['reset']) || true !== $options['reset'])) {
259 259
 				$result               = $cached;
260 260
 				$result['from_cache'] = true;
261 261
 				$result['cached']     = true;
262 262
 			} else {
263
-				$data   = wp_json_encode( $params );
264
-				$result = $this->http_request( $url, $data, $headers, $method, $options );
265
-				if ( in_array( $result['code'], $this->success_codes, true ) ) {
266
-					$result['cached'] = $this->wordpress->cache_set( $url, $params, $result, $options['cache_expiration'] );
263
+				$data   = wp_json_encode($params);
264
+				$result = $this->http_request($url, $data, $headers, $method, $options);
265
+				if (in_array($result['code'], $this->success_codes, true)) {
266
+					$result['cached'] = $this->wordpress->cache_set($url, $params, $result, $options['cache_expiration']);
267 267
 				} else {
268 268
 					$result['cached'] = false;
269 269
 				}
270 270
 				$result['from_cache'] = false;
271 271
 			}
272 272
 		} else {
273
-			$data                 = wp_json_encode( $params );
274
-			$result               = $this->http_request( $url, $data, $headers, $method, $options );
273
+			$data                 = wp_json_encode($params);
274
+			$result               = $this->http_request($url, $data, $headers, $method, $options);
275 275
 			$result['from_cache'] = false;
276 276
 			$result['cached']     = false;
277 277
 		}
278 278
 
279
-		if ( isset( $options['is_redo'] ) && true === $options['is_redo'] ) {
279
+		if (isset($options['is_redo']) && true === $options['is_redo']) {
280 280
 			$result['is_redo'] = true;
281 281
 		} else {
282 282
 			$result['is_redo'] = false;
283 283
 		}
284 284
 
285 285
 		// it would be very unfortunate to ever have to do this in a production site
286
-		if ( 1 === (int) $this->debug ) {
286
+		if (1 === (int) $this->debug) {
287 287
 			// create log entry for the api call if debug is true
288 288
 			$status = 'debug';
289
-			if ( isset( $this->logging ) ) {
289
+			if (isset($this->logging)) {
290 290
 				$logging = $this->logging;
291
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
292
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
291
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
292
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
293 293
 			}
294 294
 
295 295
 			// translators: placeholder is the URL of the Salesforce API request
296
-			$title = sprintf( esc_html__( 'Debug: on Salesforce API HTTP Request to URL: %1$s.', 'object-sync-for-salesforce' ),
297
-				esc_url( $url )
296
+			$title = sprintf(esc_html__('Debug: on Salesforce API HTTP Request to URL: %1$s.', 'object-sync-for-salesforce'),
297
+				esc_url($url)
298 298
 			);
299 299
 
300 300
 			$logging->setup(
301 301
 				$title,
302
-				print_r( $result, true ), // log the result because we are debugging the whole api call
302
+				print_r($result, true), // log the result because we are debugging the whole api call
303 303
 				0,
304 304
 				0,
305 305
 				$status
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	* @return array
327 327
 	*   Salesforce response object.
328 328
 	*/
329
-	protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
329
+	protected function http_request($url, $data, $headers = array(), $method = 'GET', $options = array()) {
330 330
 		// Build the request, including path and headers. Internal use.
331 331
 
332 332
 		/*
@@ -335,60 +335,60 @@  discard block
 block discarded – undo
335 335
 		*/
336 336
 
337 337
 		$curl = curl_init();
338
-		curl_setopt( $curl, CURLOPT_URL, $url );
339
-		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
340
-		curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
341
-		if ( false !== $headers ) {
342
-			curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
338
+		curl_setopt($curl, CURLOPT_URL, $url);
339
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
340
+		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
341
+		if (false !== $headers) {
342
+			curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
343 343
 		} else {
344
-			curl_setopt( $curl, CURLOPT_HEADER, false );
344
+			curl_setopt($curl, CURLOPT_HEADER, false);
345 345
 		}
346 346
 
347
-		if ( 'POST' === $method ) {
348
-			curl_setopt( $curl, CURLOPT_POST, true );
349
-			curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
350
-		} elseif ( 'PATCH' === $method || 'DELETE' === $method ) {
351
-			curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, $method );
352
-			curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
347
+		if ('POST' === $method) {
348
+			curl_setopt($curl, CURLOPT_POST, true);
349
+			curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
350
+		} elseif ('PATCH' === $method || 'DELETE' === $method) {
351
+			curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
352
+			curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
353 353
 		}
354
-		$json_response = curl_exec( $curl ); // this is possibly gzipped json data
355
-		$code          = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
354
+		$json_response = curl_exec($curl); // this is possibly gzipped json data
355
+		$code          = curl_getinfo($curl, CURLINFO_HTTP_CODE);
356 356
 
357
-		if ( ( 'PATCH' === $method || 'DELETE' === $method ) && '' === $json_response && 204 === $code ) {
357
+		if (('PATCH' === $method || 'DELETE' === $method) && '' === $json_response && 204 === $code) {
358 358
 			// delete and patch requests return a 204 with an empty body upon success for whatever reason
359 359
 			$data = array(
360 360
 				'success' => true,
361 361
 				'body'    => '',
362 362
 			);
363
-			curl_close( $curl );
363
+			curl_close($curl);
364 364
 			return array(
365
-				'json' => wp_json_encode( $data ),
365
+				'json' => wp_json_encode($data),
366 366
 				'code' => $code,
367 367
 				'data' => $data,
368 368
 			);
369 369
 		}
370 370
 
371
-		if ( ( ord( $json_response[0] ) == 0x1f ) && ( ord( $json_response[1] ) == 0x8b ) ) {
371
+		if ((ord($json_response[0]) == 0x1f) && (ord($json_response[1]) == 0x8b)) {
372 372
 			// skip header and ungzip the data
373
-			$json_response = gzinflate( substr( $json_response, 10 ) );
373
+			$json_response = gzinflate(substr($json_response, 10));
374 374
 		}
375
-		$data = json_decode( $json_response, true ); // decode it into an array
375
+		$data = json_decode($json_response, true); // decode it into an array
376 376
 
377 377
 		// don't use the exception if the status is a success one, or if it just needs a refresh token (salesforce uses 401 for this)
378
-		if ( ! in_array( $code, $this->success_or_refresh_codes, true ) ) {
379
-			$curl_error = curl_error( $curl );
380
-			if ( '' !== $curl_error ) {
378
+		if ( ! in_array($code, $this->success_or_refresh_codes, true)) {
379
+			$curl_error = curl_error($curl);
380
+			if ('' !== $curl_error) {
381 381
 				// create log entry for failed curl
382 382
 				$status = 'error';
383
-				if ( isset( $this->logging ) ) {
383
+				if (isset($this->logging)) {
384 384
 					$logging = $this->logging;
385
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
386
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
385
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
386
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
387 387
 				}
388 388
 
389 389
 				// translators: placeholder is the URL of the Salesforce API request
390
-				$title = sprintf( esc_html__( 'Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce' ),
391
-					esc_attr( $code )
390
+				$title = sprintf(esc_html__('Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce'),
391
+					esc_attr($code)
392 392
 				);
393 393
 
394 394
 				$logging->setup(
@@ -398,25 +398,25 @@  discard block
 block discarded – undo
398 398
 					0,
399 399
 					$status
400 400
 				);
401
-			} elseif ( isset( $data[0]['errorCode'] ) && '' !== $data[0]['errorCode'] ) { // salesforce uses this structure to return errors
401
+			} elseif (isset($data[0]['errorCode']) && '' !== $data[0]['errorCode']) { // salesforce uses this structure to return errors
402 402
 				// create log entry for failed curl
403 403
 				$status = 'error';
404
-				if ( isset( $this->logging ) ) {
404
+				if (isset($this->logging)) {
405 405
 					$logging = $this->logging;
406
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
407
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
406
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
407
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
408 408
 				}
409 409
 
410 410
 				// translators: placeholder is the server code returned by the api
411
-				$title = sprintf( esc_html__( 'Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce' ),
412
-					absint( $code )
411
+				$title = sprintf(esc_html__('Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce'),
412
+					absint($code)
413 413
 				);
414 414
 
415 415
 				// translators: placeholders are: 1) the URL requested, 2) the message returned by the error, 3) the server code returned
416
-				$body = sprintf( '<p>' . esc_html__( 'URL: %1$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: %2$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Code: %3$s', 'object-sync-for-salesforce' ),
417
-					esc_attr( $url ),
418
-					esc_html( $data[0]['message'] ),
419
-					absint( $code )
416
+				$body = sprintf('<p>' . esc_html__('URL: %1$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: %2$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Code: %3$s', 'object-sync-for-salesforce'),
417
+					esc_attr($url),
418
+					esc_html($data[0]['message']),
419
+					absint($code)
420 420
 				);
421 421
 
422 422
 				$logging->setup(
@@ -429,20 +429,20 @@  discard block
 block discarded – undo
429 429
 			} else {
430 430
 				// create log entry for failed curl
431 431
 				$status = 'error';
432
-				if ( isset( $this->logging ) ) {
432
+				if (isset($this->logging)) {
433 433
 					$logging = $this->logging;
434
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
435
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
434
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
435
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
436 436
 				}
437 437
 
438 438
 				// translators: placeholder is the server code returned by Salesforce
439
-				$title = sprintf( esc_html__( 'Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce' ),
440
-					absint( $code )
439
+				$title = sprintf(esc_html__('Error: %1$s: on Salesforce http request', 'object-sync-for-salesforce'),
440
+					absint($code)
441 441
 				);
442 442
 
443 443
 				$logging->setup(
444 444
 					$title,
445
-					print_r( $data, true ), // log the result because we are debugging the whole api call
445
+					print_r($data, true), // log the result because we are debugging the whole api call
446 446
 					0,
447 447
 					0,
448 448
 					$status
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 			} // End if().
451 451
 		} // End if().
452 452
 
453
-		curl_close( $curl );
453
+		curl_close($curl);
454 454
 
455 455
 		return array(
456 456
 			'json' => $json_response,
@@ -468,14 +468,14 @@  discard block
 block discarded – undo
468 468
 	* @return string
469 469
 	*   Complete URL endpoint for API access.
470 470
 	*/
471
-	public function get_api_endpoint( $api_type = 'rest' ) {
471
+	public function get_api_endpoint($api_type = 'rest') {
472 472
 		// Special handling for apexrest, since it's not in the identity object.
473
-		if ( 'apexrest' === $api_type ) {
473
+		if ('apexrest' === $api_type) {
474 474
 			$url = $this->get_instance_url() . '/services/apexrest/';
475 475
 		} else {
476 476
 			$identity = $this->get_identity();
477
-			$url      = str_replace( '{version}', $this->rest_api_version, $identity['urls'][ $api_type ] );
478
-			if ( '' === $identity ) {
477
+			$url      = str_replace('{version}', $this->rest_api_version, $identity['urls'][$api_type]);
478
+			if ('' === $identity) {
479 479
 				$url = $this->get_instance_url() . '/services/data/v' . $this->rest_api_version . '/';
480 480
 			}
481 481
 		}
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 	* Get the SF instance URL. Useful for linking to objects.
487 487
 	*/
488 488
 	public function get_instance_url() {
489
-		return get_option( 'object_sync_for_salesforce_instance_url', '' );
489
+		return get_option('object_sync_for_salesforce_instance_url', '');
490 490
 	}
491 491
 
492 492
 	/**
@@ -495,15 +495,15 @@  discard block
 block discarded – undo
495 495
 	* @param string $url
496 496
 	*   URL to set.
497 497
 	*/
498
-	protected function set_instance_url( $url ) {
499
-		update_option( 'object_sync_for_salesforce_instance_url', $url );
498
+	protected function set_instance_url($url) {
499
+		update_option('object_sync_for_salesforce_instance_url', $url);
500 500
 	}
501 501
 
502 502
 	/**
503 503
 	* Get the access token.
504 504
 	*/
505 505
 	public function get_access_token() {
506
-		return get_option( 'object_sync_for_salesforce_access_token', '' );
506
+		return get_option('object_sync_for_salesforce_access_token', '');
507 507
 	}
508 508
 
509 509
 	/**
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
 	* @param string $token
515 515
 	*   Access token from Salesforce.
516 516
 	*/
517
-	protected function set_access_token( $token ) {
518
-		update_option( 'object_sync_for_salesforce_access_token', $token );
517
+	protected function set_access_token($token) {
518
+		update_option('object_sync_for_salesforce_access_token', $token);
519 519
 	}
520 520
 
521 521
 	/**
522 522
 	* Get refresh token.
523 523
 	*/
524 524
 	protected function get_refresh_token() {
525
-		return get_option( 'object_sync_for_salesforce_refresh_token', '' );
525
+		return get_option('object_sync_for_salesforce_refresh_token', '');
526 526
 	}
527 527
 
528 528
 	/**
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	* @param string $token
532 532
 	*   Refresh token from Salesforce.
533 533
 	*/
534
-	protected function set_refresh_token( $token ) {
535
-		update_option( 'object_sync_for_salesforce_refresh_token', $token );
534
+	protected function set_refresh_token($token) {
535
+		update_option('object_sync_for_salesforce_refresh_token', $token);
536 536
 	}
537 537
 
538 538
 	/**
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	*/
547 547
 	protected function refresh_token() {
548 548
 		$refresh_token = $this->get_refresh_token();
549
-		if ( empty( $refresh_token ) ) {
550
-			throw new Object_Sync_Sf_Exception( esc_html__( 'There is no refresh token.', 'object-sync-for-salesforce' ) );
549
+		if (empty($refresh_token)) {
550
+			throw new Object_Sync_Sf_Exception(esc_html__('There is no refresh token.', 'object-sync-for-salesforce'));
551 551
 		}
552 552
 
553 553
 		$data = array(
@@ -565,13 +565,13 @@  discard block
 block discarded – undo
565 565
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
566 566
 		);
567 567
 		$headers  = false;
568
-		$response = $this->http_request( $url, $data, $headers, 'POST' );
568
+		$response = $this->http_request($url, $data, $headers, 'POST');
569 569
 
570
-		if ( 200 !== $response['code'] ) {
570
+		if (200 !== $response['code']) {
571 571
 			throw new Object_Sync_Sf_Exception(
572 572
 				esc_html(
573 573
 					sprintf(
574
-						__( 'Unable to get a Salesforce access token. Salesforce returned the following errorCode: ', 'object-sync-for-salesforce' ) . $response['code']
574
+						__('Unable to get a Salesforce access token. Salesforce returned the following errorCode: ', 'object-sync-for-salesforce') . $response['code']
575 575
 					)
576 576
 				),
577 577
 				$response['code']
@@ -580,13 +580,13 @@  discard block
 block discarded – undo
580 580
 
581 581
 		$data = $response['data'];
582 582
 
583
-		if ( is_array( $data ) && isset( $data['error'] ) ) {
584
-			throw new Object_Sync_Sf_Exception( $data['error_description'], $data['error'] );
583
+		if (is_array($data) && isset($data['error'])) {
584
+			throw new Object_Sync_Sf_Exception($data['error_description'], $data['error']);
585 585
 		}
586 586
 
587
-		$this->set_access_token( $data['access_token'] );
588
-		$this->set_identity( $data['id'] );
589
-		$this->set_instance_url( $data['instance_url'] );
587
+		$this->set_access_token($data['access_token']);
588
+		$this->set_identity($data['id']);
589
+		$this->set_instance_url($data['instance_url']);
590 590
 	}
591 591
 
592 592
 	/**
@@ -597,18 +597,18 @@  discard block
 block discarded – undo
597 597
 	*
598 598
 	* @throws Object_Sync_Sf_Exception
599 599
 	*/
600
-	protected function set_identity( $id ) {
601
-		$headers  = array(
600
+	protected function set_identity($id) {
601
+		$headers = array(
602 602
 			'Authorization'   => 'Authorization: OAuth ' . $this->get_access_token(),
603 603
 			//'Content-type'  => 'application/json',
604 604
 			'Accept-Encoding' => 'Accept-Encoding: gzip, deflate',
605 605
 		);
606
-		$response = $this->http_request( $id, null, $headers );
607
-		if ( 200 !== $response['code'] ) {
608
-			throw new Object_Sync_Sf_Exception( esc_html__( 'Unable to access identity service.', 'object-sync-for-salesforce' ), $response['code'] );
606
+		$response = $this->http_request($id, null, $headers);
607
+		if (200 !== $response['code']) {
608
+			throw new Object_Sync_Sf_Exception(esc_html__('Unable to access identity service.', 'object-sync-for-salesforce'), $response['code']);
609 609
 		}
610 610
 		$data = $response['data'];
611
-		update_option( 'object_sync_for_salesforce_identity', $data );
611
+		update_option('object_sync_for_salesforce_identity', $data);
612 612
 	}
613 613
 
614 614
 	/**
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	*   Returns FALSE if no identity has been stored.
619 619
 	*/
620 620
 	public function get_identity() {
621
-		return get_option( 'object_sync_for_salesforce_identity', false );
621
+		return get_option('object_sync_for_salesforce_identity', false);
622 622
 	}
623 623
 
624 624
 	/**
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	* @param string $code
643 643
 	*   Code from Salesforce.
644 644
 	*/
645
-	public function request_token( $code ) {
645
+	public function request_token($code) {
646 646
 		$data = array(
647 647
 			'code'          => $code,
648 648
 			'grant_type'    => 'authorization_code',
@@ -657,28 +657,28 @@  discard block
 block discarded – undo
657 657
 			//'Content-Type'  => 'application/x-www-form-urlencoded',
658 658
 			'Accept-Encoding' => 'Accept-Encoding: gzip, deflate',
659 659
 		);
660
-		$response = $this->http_request( $url, $data, $headers, 'POST' );
660
+		$response = $this->http_request($url, $data, $headers, 'POST');
661 661
 
662 662
 		$data = $response['data'];
663 663
 
664
-		if ( 200 !== $response['code'] ) {
665
-			$error = isset( $data['error_description'] ) ? $data['error_description'] : $response['error'];
666
-			throw new Object_Sync_Sf_Exception( $error, $response['code'] );
664
+		if (200 !== $response['code']) {
665
+			$error = isset($data['error_description']) ? $data['error_description'] : $response['error'];
666
+			throw new Object_Sync_Sf_Exception($error, $response['code']);
667 667
 		}
668 668
 
669 669
 		// Ensure all required attributes are returned. They can be omitted if the
670 670
 		// OAUTH scope is inadequate.
671
-		$required = array( 'refresh_token', 'access_token', 'id', 'instance_url' );
672
-		foreach ( $required as $key ) {
673
-			if ( ! isset( $data[ $key ] ) ) {
671
+		$required = array('refresh_token', 'access_token', 'id', 'instance_url');
672
+		foreach ($required as $key) {
673
+			if ( ! isset($data[$key])) {
674 674
 				return false;
675 675
 			}
676 676
 		}
677 677
 
678
-		$this->set_refresh_token( $data['refresh_token'] );
679
-		$this->set_access_token( $data['access_token'] );
680
-		$this->set_identity( $data['id'] );
681
-		$this->set_instance_url( $data['instance_url'] );
678
+		$this->set_refresh_token($data['refresh_token']);
679
+		$this->set_access_token($data['access_token']);
680
+		$this->set_identity($data['id']);
681
+		$this->set_instance_url($data['instance_url']);
682 682
 
683 683
 		return true;
684 684
 	}
@@ -713,19 +713,19 @@  discard block
 block discarded – undo
713 713
 		$options = array(
714 714
 			'reset' => $reset,
715 715
 		);
716
-		$result  = $this->api_call( 'sobjects', array(), 'GET', $options );
716
+		$result  = $this->api_call('sobjects', array(), 'GET', $options);
717 717
 
718
-		if ( ! empty( $conditions ) ) {
719
-			foreach ( $result['data']['sobjects'] as $key => $object ) {
720
-				foreach ( $conditions as $condition => $value ) {
721
-					if ( $object[ $condition ] !== $value ) {
722
-						unset( $result['data']['sobjects'][ $key ] );
718
+		if ( ! empty($conditions)) {
719
+			foreach ($result['data']['sobjects'] as $key => $object) {
720
+				foreach ($conditions as $condition => $value) {
721
+					if ($object[$condition] !== $value) {
722
+						unset($result['data']['sobjects'][$key]);
723 723
 					}
724 724
 				}
725 725
 			}
726 726
 		}
727 727
 
728
-		ksort( $result['data']['sobjects'] );
728
+		ksort($result['data']['sobjects']);
729 729
 
730 730
 		return $result['data']['sobjects'];
731 731
 	}
@@ -747,21 +747,21 @@  discard block
 block discarded – undo
747 747
 	*
748 748
 	* part of core API calls
749 749
 	*/
750
-	public function query( $query, $options = array(), $all = false, $explain = false ) {
750
+	public function query($query, $options = array(), $all = false, $explain = false) {
751 751
 		$search_data = [
752 752
 			'q' => (string) $query,
753 753
 		];
754
-		if ( true === $explain ) {
754
+		if (true === $explain) {
755 755
 			$search_data['explain'] = $search_data['q'];
756
-			unset( $search_data['q'] );
756
+			unset($search_data['q']);
757 757
 		}
758 758
 		// all is a search through deleted and merged data as well
759
-		if ( true === $all ) {
759
+		if (true === $all) {
760 760
 			$path = 'queryAll';
761 761
 		} else {
762 762
 			$path = 'query';
763 763
 		}
764
-		$result = $this->api_call( $path . '?' . http_build_query( $search_data ), array(), 'GET', $options );
764
+		$result = $this->api_call($path . '?' . http_build_query($search_data), array(), 'GET', $options);
765 765
 		return $result;
766 766
 	}
767 767
 
@@ -779,28 +779,28 @@  discard block
 block discarded – undo
779 779
 	*
780 780
 	* part of core API calls
781 781
 	*/
782
-	public function object_describe( $name, $reset = false ) {
783
-		if ( empty( $name ) ) {
782
+	public function object_describe($name, $reset = false) {
783
+		if (empty($name)) {
784 784
 			return array();
785 785
 		}
786 786
 		$options = array(
787 787
 			'reset' => $reset,
788 788
 		);
789
-		$object  = $this->api_call( "sobjects/{$name}/describe", array(), 'GET', $options );
789
+		$object  = $this->api_call("sobjects/{$name}/describe", array(), 'GET', $options);
790 790
 		// Sort field properties, because salesforce API always provides them in a
791 791
 		// random order. We sort them so that stored and exported data are
792 792
 		// standardized and predictable.
793 793
 		$fields = array();
794
-		foreach ( $object['data']['fields'] as &$field ) {
795
-			ksort( $field );
796
-			if ( ! empty( $field['picklistValues'] ) ) {
797
-				foreach ( $field['picklistValues'] as &$picklist_value ) {
798
-					ksort( $picklist_value );
794
+		foreach ($object['data']['fields'] as &$field) {
795
+			ksort($field);
796
+			if ( ! empty($field['picklistValues'])) {
797
+				foreach ($field['picklistValues'] as &$picklist_value) {
798
+					ksort($picklist_value);
799 799
 				}
800 800
 			}
801
-			$fields[ $field['name'] ] = $field;
801
+			$fields[$field['name']] = $field;
802 802
 		}
803
-		ksort( $fields );
803
+		ksort($fields);
804 804
 		$object['fields'] = $fields;
805 805
 		return $object;
806 806
 	}
@@ -826,11 +826,11 @@  discard block
 block discarded – undo
826 826
 	*
827 827
 	* part of core API calls
828 828
 	*/
829
-	public function object_create( $name, $params ) {
829
+	public function object_create($name, $params) {
830 830
 		$options = array(
831 831
 			'type' => 'write',
832 832
 		);
833
-		$result  = $this->api_call( "sobjects/{$name}", $params, 'POST', $options );
833
+		$result  = $this->api_call("sobjects/{$name}", $params, 'POST', $options);
834 834
 		return $result;
835 835
 	}
836 836
 
@@ -863,22 +863,22 @@  discard block
 block discarded – undo
863 863
 	*
864 864
 	* part of core API calls
865 865
 	*/
866
-	public function object_upsert( $name, $key, $value, $params ) {
866
+	public function object_upsert($name, $key, $value, $params) {
867 867
 		$options = array(
868 868
 			'type' => 'write',
869 869
 		);
870 870
 		// If key is set, remove from $params to avoid UPSERT errors.
871
-		if ( isset( $params[ $key ] ) ) {
872
-			unset( $params[ $key ] );
871
+		if (isset($params[$key])) {
872
+			unset($params[$key]);
873 873
 		}
874 874
 
875 875
 		// allow developers to change both the key and value by which objects should be matched
876
-		$key   = apply_filters( 'object_sync_for_salesforce_modify_upsert_key', $key );
877
-		$value = apply_filters( 'object_sync_for_salesforce_modify_upsert_value', $value );
876
+		$key   = apply_filters('object_sync_for_salesforce_modify_upsert_key', $key);
877
+		$value = apply_filters('object_sync_for_salesforce_modify_upsert_value', $value);
878 878
 
879
-		$data = $this->api_call( "sobjects/{$name}/{$key}/{$value}", $params, 'PATCH', $options );
880
-		if ( 300 === $this->response['code'] ) {
881
-			$data['message'] = esc_html( 'The value provided is not unique.' );
879
+		$data = $this->api_call("sobjects/{$name}/{$key}/{$value}", $params, 'PATCH', $options);
880
+		if (300 === $this->response['code']) {
881
+			$data['message'] = esc_html('The value provided is not unique.');
882 882
 		}
883 883
 		return $data;
884 884
 	}
@@ -905,11 +905,11 @@  discard block
 block discarded – undo
905 905
 	*   cached:
906 906
 	*   is_redo:
907 907
 	*/
908
-	public function object_update( $name, $id, $params ) {
908
+	public function object_update($name, $id, $params) {
909 909
 		$options = array(
910 910
 			'type' => 'write',
911 911
 		);
912
-		$result  = $this->api_call( "sobjects/{$name}/{$id}", $params, 'PATCH', $options );
912
+		$result  = $this->api_call("sobjects/{$name}/{$id}", $params, 'PATCH', $options);
913 913
 		return $result;
914 914
 	}
915 915
 
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	*
927 927
 	* part of core API calls
928 928
 	*/
929
-	public function object_read( $name, $id ) {
930
-		return $this->api_call( "sobjects/{$name}/{$id}", array(), 'GET' );
929
+	public function object_read($name, $id) {
930
+		return $this->api_call("sobjects/{$name}/{$id}", array(), 'GET');
931 931
 	}
932 932
 
933 933
 	/**
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	*
950 950
 	* part of core API calls
951 951
 	*/
952
-	public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
953
-		return $this->api_call( "analytics/{$name}/{$id}/{$route}", $params, $method );
952
+	public function analytics_api($name, $id, $route = '', $params = array(), $method = 'GET') {
953
+		return $this->api_call("analytics/{$name}/{$id}/{$route}", $params, $method);
954 954
 	}
955 955
 
956 956
 	/**
@@ -970,19 +970,19 @@  discard block
 block discarded – undo
970 970
 	*
971 971
 	* part of core API calls
972 972
 	*/
973
-	public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
973
+	public function run_analytics_report($id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '') {
974 974
 
975
-		$id         = $this->convert_id( $id );
975
+		$id         = $this->convert_id($id);
976 976
 		$report_url = 'analytics/reports/' . $id . '/' . 'instances';
977 977
 
978
-		if ( true === $clear_cache ) {
979
-			delete_transient( $report_url );
978
+		if (true === $clear_cache) {
979
+			delete_transient($report_url);
980 980
 		}
981 981
 
982
-		$instance_id = $this->wordpress->cache_get( $report_url, '' );
982
+		$instance_id = $this->wordpress->cache_get($report_url, '');
983 983
 
984 984
 		// there is no stored instance id or this is synchronous; retrieve the results for that instance
985
-		if ( false === $async || false === $instance_id ) {
985
+		if (false === $async || false === $instance_id) {
986 986
 
987 987
 			$result = $this->analytics_api(
988 988
 				'reports',
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 				'GET'
993 993
 			);
994 994
 			// if we get a reportmetadata array out of this, continue
995
-			if ( is_array( $result['data']['reportMetadata'] ) ) {
995
+			if (is_array($result['data']['reportMetadata'])) {
996 996
 				$params = array(
997 997
 					'reportMetadata' => $result['data']['reportMetadata'],
998 998
 				);
@@ -1004,48 +1004,48 @@  discard block
 block discarded – undo
1004 1004
 					'POST'
1005 1005
 				);
1006 1006
 				// if we get an id from the post, that is the instance id
1007
-				if ( isset( $report['data']['id'] ) ) {
1007
+				if (isset($report['data']['id'])) {
1008 1008
 					$instance_id = $report['data']['id'];
1009 1009
 				} else {
1010 1010
 					// run the call again if we don't have an instance id
1011 1011
 					//error_log('run report again. we have no instance id.');
1012
-					$this->run_analytics_report( $id, true );
1012
+					$this->run_analytics_report($id, true);
1013 1013
 				}
1014 1014
 
1015 1015
 				// cache the instance id so we can get the report results if they are applicable
1016
-				if ( '' === $report_cache_expiration ) {
1016
+				if ('' === $report_cache_expiration) {
1017 1017
 					$report_cache_expiration = $this->cache_expiration();
1018 1018
 				}
1019
-				$this->wordpress->cache_set( $report_url, '', $instance_id, $report_cache_expiration );
1019
+				$this->wordpress->cache_set($report_url, '', $instance_id, $report_cache_expiration);
1020 1020
 			} else {
1021 1021
 				// run the call again if we don't have a reportMetadata array
1022 1022
 				//error_log('run report again. we have no reportmetadata.');
1023
-				$this->run_analytics_report( $id, true );
1023
+				$this->run_analytics_report($id, true);
1024 1024
 			}
1025 1025
 		} // End if().
1026 1026
 
1027
-		$result = $this->api_call( $report_url . "/{$instance_id}", array(), $method );
1027
+		$result = $this->api_call($report_url . "/{$instance_id}", array(), $method);
1028 1028
 
1029 1029
 		// the report instance is expired. rerun it.
1030
-		if ( 404 === $result['code'] ) {
1030
+		if (404 === $result['code']) {
1031 1031
 			//error_log('run report again. it expired.');
1032
-			$this->run_analytics_report( $id, true, true );
1032
+			$this->run_analytics_report($id, true, true);
1033 1033
 		}
1034 1034
 
1035 1035
 		// cache the instance results as a long fallback if the setting says so
1036 1036
 		// do this because salesforce will have errors if the instance has expired or is currently running
1037 1037
 		// remember: the result of the above api_call is already cached (or not) according to the plugin's generic settings
1038 1038
 		// this is fine I think, although it is a bit of redundancy in this case
1039
-		if ( true === $cache_instance ) {
1040
-			$cached = $this->wordpress->cache_get( $report_url . '_instance_cached', '' );
1041
-			if ( is_array( $cached ) ) {
1039
+		if (true === $cache_instance) {
1040
+			$cached = $this->wordpress->cache_get($report_url . '_instance_cached', '');
1041
+			if (is_array($cached)) {
1042 1042
 				$result = $cached;
1043 1043
 			} else {
1044
-				if ( 'Success' === $result['data']['attributes']['status'] ) {
1045
-					if ( '' === $instance_cache_expiration ) {
1044
+				if ('Success' === $result['data']['attributes']['status']) {
1045
+					if ('' === $instance_cache_expiration) {
1046 1046
 						$instance_cache_expiration = $this->cache_expiration();
1047 1047
 					}
1048
-					$this->wordpress->cache_set( $report_url . '_instance_cached', '', $result, $instance_cache_expiration );
1048
+					$this->wordpress->cache_set($report_url . '_instance_cached', '', $result, $instance_cache_expiration);
1049 1049
 				}
1050 1050
 			}
1051 1051
 		}
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 	*
1070 1070
 	* part of core API calls
1071 1071
 	*/
1072
-	public function object_readby_external_id( $name, $field, $value ) {
1073
-		return $this->api_call( "sobjects/{$name}/{$field}/{$value}" );
1072
+	public function object_readby_external_id($name, $field, $value) {
1073
+		return $this->api_call("sobjects/{$name}/{$field}/{$value}");
1074 1074
 	}
1075 1075
 
1076 1076
 	/**
@@ -1085,11 +1085,11 @@  discard block
 block discarded – undo
1085 1085
 	*
1086 1086
 	* part of core API calls
1087 1087
 	*/
1088
-	public function object_delete( $name, $id ) {
1088
+	public function object_delete($name, $id) {
1089 1089
 		$options = array(
1090 1090
 			'type' => 'write',
1091 1091
 		);
1092
-		$result  = $this->api_call( "sobjects/{$name}/{$id}", array(), 'DELETE', $options );
1092
+		$result  = $this->api_call("sobjects/{$name}/{$id}", array(), 'DELETE', $options);
1093 1093
 		return $result;
1094 1094
 	}
1095 1095
 
@@ -1105,11 +1105,11 @@  discard block
 block discarded – undo
1105 1105
 	*   End date to check for deleted objects (in ISO 8601 format).
1106 1106
 	* @return GetDeletedResult
1107 1107
 	*/
1108
-	public function get_deleted( $type, $start_date, $end_date ) {
1108
+	public function get_deleted($type, $start_date, $end_date) {
1109 1109
 		$options = array(
1110 1110
 			'cache' => false,
1111 1111
 		); // this is timestamp level specific; probably should not cache it
1112
-		return $this->api_call( "sobjects/{$type}/deleted/?start={$start_date}&end={$end_date}", array(), 'GET', $options );
1112
+		return $this->api_call("sobjects/{$type}/deleted/?start={$start_date}&end={$end_date}", array(), 'GET', $options);
1113 1113
 	}
1114 1114
 
1115 1115
 
@@ -1122,9 +1122,9 @@  discard block
 block discarded – undo
1122 1122
 	* part of core API calls
1123 1123
 	*/
1124 1124
 	public function list_resources() {
1125
-		$resources = $this->api_call( '' );
1126
-		foreach ( $resources as $key => $path ) {
1127
-			$items[ $key ] = $path;
1125
+		$resources = $this->api_call('');
1126
+		foreach ($resources as $key => $path) {
1127
+			$items[$key] = $path;
1128 1128
 		}
1129 1129
 		return $items;
1130 1130
 	}
@@ -1155,21 +1155,21 @@  discard block
 block discarded – undo
1155 1155
 	*
1156 1156
 	* part of core API calls
1157 1157
 	*/
1158
-	public function get_updated( $type, $start = null, $end = null ) {
1159
-		if ( empty( $start ) ) {
1160
-			$start = strtotime( '-29 days' );
1158
+	public function get_updated($type, $start = null, $end = null) {
1159
+		if (empty($start)) {
1160
+			$start = strtotime('-29 days');
1161 1161
 		}
1162
-		$start = rawurlencode( gmdate( DATE_ATOM, $start ) );
1162
+		$start = rawurlencode(gmdate(DATE_ATOM, $start));
1163 1163
 
1164
-		if ( empty( $end ) ) {
1164
+		if (empty($end)) {
1165 1165
 			$end = time();
1166 1166
 		}
1167
-		$end = rawurlencode( gmdate( DATE_ATOM, $end ) );
1167
+		$end = rawurlencode(gmdate(DATE_ATOM, $end));
1168 1168
 
1169 1169
 		$options = array(
1170 1170
 			'cache' => false,
1171 1171
 		); // this is timestamp level specific; probably should not cache it
1172
-		return $this->api_call( "sobjects/{$type}/updated/?start=$start&end=$end", array(), 'GET', $options );
1172
+		return $this->api_call("sobjects/{$type}/updated/?start=$start&end=$end", array(), 'GET', $options);
1173 1173
 	}
1174 1174
 
1175 1175
 	/**
@@ -1187,28 +1187,28 @@  discard block
 block discarded – undo
1187 1187
 	*   The Salesforce ID of the given Record Type, or null.
1188 1188
 	*/
1189 1189
 
1190
-	public function get_record_type_id_by_developer_name( $name, $devname, $reset = false ) {
1190
+	public function get_record_type_id_by_developer_name($name, $devname, $reset = false) {
1191 1191
 
1192 1192
 		// example of how this runs: $this->get_record_type_id_by_developer_name( 'Account', 'HH_Account' );
1193 1193
 
1194
-		$cached = $this->wordpress->cache_get( 'salesforce_record_types', '' );
1195
-		if ( is_array( $cached ) && ( ! isset( $reset ) || true !== $reset ) ) {
1196
-			return ! empty( $cached[ $name ][ $devname ] ) ? $cached[ $name ][ $devname ]['Id'] : null;
1194
+		$cached = $this->wordpress->cache_get('salesforce_record_types', '');
1195
+		if (is_array($cached) && ( ! isset($reset) || true !== $reset)) {
1196
+			return ! empty($cached[$name][$devname]) ? $cached[$name][$devname]['Id'] : null;
1197 1197
 		}
1198 1198
 
1199
-		$query         = new Object_Sync_Sf_Salesforce_Select_Query( 'RecordType' );
1200
-		$query->fields = array( 'Id', 'Name', 'DeveloperName', 'SobjectType' );
1199
+		$query         = new Object_Sync_Sf_Salesforce_Select_Query('RecordType');
1200
+		$query->fields = array('Id', 'Name', 'DeveloperName', 'SobjectType');
1201 1201
 
1202
-		$result       = $this->query( $query );
1202
+		$result       = $this->query($query);
1203 1203
 		$record_types = array();
1204 1204
 
1205
-		foreach ( $result['data']['records'] as $record_type ) {
1206
-			$record_types[ $record_type['SobjectType'] ][ $record_type['DeveloperName'] ] = $record_type;
1205
+		foreach ($result['data']['records'] as $record_type) {
1206
+			$record_types[$record_type['SobjectType']][$record_type['DeveloperName']] = $record_type;
1207 1207
 		}
1208 1208
 
1209
-		$cached = $this->wordpress->cache_set( 'salesforce_record_types', '', $record_types, $this->options['cache_expiration'] );
1209
+		$cached = $this->wordpress->cache_set('salesforce_record_types', '', $record_types, $this->options['cache_expiration']);
1210 1210
 
1211
-		return ! empty( $record_types[ $name ][ $devname ] ) ? $record_types[ $name ][ $devname ]['Id'] : null;
1211
+		return ! empty($record_types[$name][$devname]) ? $record_types[$name][$devname]['Id'] : null;
1212 1212
 
1213 1213
 	}
1214 1214
 
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 	*
1219 1219
 	*/
1220 1220
 	private function cache_expiration() {
1221
-		$cache_expiration = $this->wordpress->cache_expiration( 'object_sync_for_salesforce_cache_expiration', 86400 );
1221
+		$cache_expiration = $this->wordpress->cache_expiration('object_sync_for_salesforce_cache_expiration', 86400);
1222 1222
 		return $cache_expiration;
1223 1223
 	}
1224 1224
 
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
  * @package Object_Sync_Salesforce
6 6
  */
7 7
 
8
-$_tests_dir = getenv( 'WP_TESTS_DIR' );
9
-if ( ! $_tests_dir ) {
8
+$_tests_dir = getenv('WP_TESTS_DIR');
9
+if ( ! $_tests_dir) {
10 10
 	$_tests_dir = '/tmp/wordpress-tests-lib';
11 11
 }
12 12
 
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
  * Manually load the plugin being tested.
18 18
  */
19 19
 function _manually_load_plugin() {
20
-	require dirname( dirname( __FILE__ ) ) . '/object-sync-for-salesforce.php';
20
+	require dirname(dirname(__FILE__)) . '/object-sync-for-salesforce.php';
21 21
 }
22
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
22
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
23 23
 
24 24
 // Start up the WP testing environment.
25 25
 require $_tests_dir . '/includes/bootstrap.php';
Please login to merge, or discard this patch.