Passed
Push — master ( 535239...1e1091 )
by Jonathan
04:01
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.
templates/admin/fieldmaps-add-edit-clone.php 1 patch
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -1,35 +1,35 @@  discard block
 block discarded – undo
1
-<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="fieldmap">
2
-	<input type="hidden" name="redirect_url_error" value="<?php echo esc_url( $error_url ); ?>" />
3
-	<input type="hidden" name="redirect_url_success" value="<?php echo esc_url( $success_url ); ?>" />
4
-	<?php if ( isset( $transient ) ) { ?>
5
-	<input type="hidden" name="transient" value="<?php echo esc_html( $transient ); ?>" />
1
+<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" class="fieldmap">
2
+	<input type="hidden" name="redirect_url_error" value="<?php echo esc_url($error_url); ?>" />
3
+	<input type="hidden" name="redirect_url_success" value="<?php echo esc_url($success_url); ?>" />
4
+	<?php if (isset($transient)) { ?>
5
+	<input type="hidden" name="transient" value="<?php echo esc_html($transient); ?>" />
6 6
 	<?php } ?>
7 7
 	<input type="hidden" name="action" value="post_fieldmap" >
8
-	<input type="hidden" name="method" value="<?php echo esc_attr( $method ); ?>" />
9
-	<?php if ( 'edit' === $method ) { ?>
10
-	<input type="hidden" name="id" value="<?php echo absint( $map['id'] ); ?>" />
8
+	<input type="hidden" name="method" value="<?php echo esc_attr($method); ?>" />
9
+	<?php if ('edit' === $method) { ?>
10
+	<input type="hidden" name="id" value="<?php echo absint($map['id']); ?>" />
11 11
 	<?php } ?>
12 12
 	<div class="fieldmap_label">
13
-		<label for="label"><?php echo esc_html__( 'Label', 'object-sync-for-salesforce' ); ?>: </label>
14
-		<input type="text" id="label" name="label" required value="<?php echo isset( $label ) ? esc_html( $label ) : ''; ?>" />
13
+		<label for="label"><?php echo esc_html__('Label', 'object-sync-for-salesforce'); ?>: </label>
14
+		<input type="text" id="label" name="label" required value="<?php echo isset($label) ? esc_html($label) : ''; ?>" />
15 15
 	</div>
16 16
 	<fieldset class="wordpress_side">
17 17
 		<div class="wordpress_object">
18
-			<label for="wordpress_object"><?php echo esc_html__( 'WordPress Object', 'object-sync-for-salesforce' ); ?>: </label>
18
+			<label for="wordpress_object"><?php echo esc_html__('WordPress Object', 'object-sync-for-salesforce'); ?>: </label>
19 19
 			<select id="wordpress_object" name="wordpress_object" required>
20
-				<option value="">- <?php echo esc_html__( 'Select object type', 'object-sync-for-salesforce' ); ?> -</option>
20
+				<option value="">- <?php echo esc_html__('Select object type', 'object-sync-for-salesforce'); ?> -</option>
21 21
 				<?php
22 22
 				$wordpress_objects = $this->wordpress->wordpress_objects;
23
-				foreach ( $wordpress_objects as $object ) {
24
-					if ( isset( $wordpress_object ) && $wordpress_object === $object ) {
23
+				foreach ($wordpress_objects as $object) {
24
+					if (isset($wordpress_object) && $wordpress_object === $object) {
25 25
 						$selected = ' selected';
26 26
 					} else {
27 27
 						$selected = '';
28 28
 					}
29
-					echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
30
-						esc_html( $object ),
31
-						esc_attr( $selected ),
32
-						esc_html( $object )
29
+					echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
30
+						esc_html($object),
31
+						esc_attr($selected),
32
+						esc_html($object)
33 33
 					);
34 34
 				}
35 35
 				?>
@@ -38,31 +38,31 @@  discard block
 block discarded – undo
38 38
 	</fieldset>
39 39
 	<fieldset class="salesforce_side">
40 40
 		<div class="salesforce_object">
41
-			<label for="salesforce_object"><?php echo esc_html__( 'Salesforce Object', 'object-sync-for-salesforce' ); ?>: </label>
41
+			<label for="salesforce_object"><?php echo esc_html__('Salesforce Object', 'object-sync-for-salesforce'); ?>: </label>
42 42
 			<div class="spinner"></div>
43 43
 			<select id="salesforce_object" name="salesforce_object" required>
44
-				<option value="">- <?php echo esc_html__( 'Select object type', 'object-sync-for-salesforce' ); ?> -</option>
44
+				<option value="">- <?php echo esc_html__('Select object type', 'object-sync-for-salesforce'); ?> -</option>
45 45
 				<?php
46 46
 				$sfapi          = $this->salesforce['sfapi'];
47
-				$object_filters = maybe_unserialize( get_option( 'salesforce_api_object_filters' ), array() );
47
+				$object_filters = maybe_unserialize(get_option('salesforce_api_object_filters'), array());
48 48
 				$conditions     = array();
49
-				if ( is_array( $object_filters ) && in_array( 'updateable', $object_filters, true ) ) {
49
+				if (is_array($object_filters) && in_array('updateable', $object_filters, true)) {
50 50
 					$conditions['updateable'] = true;
51 51
 				}
52
-				if ( is_array( $object_filters ) && in_array( 'triggerable', $object_filters, true ) ) {
52
+				if (is_array($object_filters) && in_array('triggerable', $object_filters, true)) {
53 53
 					$conditions['triggerable'] = true;
54 54
 				}
55
-				$salesforce_objects = $sfapi->objects( $conditions );
56
-				foreach ( $salesforce_objects as $object ) {
57
-					if ( isset( $salesforce_object ) && $salesforce_object === $object['name'] ) {
55
+				$salesforce_objects = $sfapi->objects($conditions);
56
+				foreach ($salesforce_objects as $object) {
57
+					if (isset($salesforce_object) && $salesforce_object === $object['name']) {
58 58
 						$selected = ' selected';
59 59
 					} else {
60 60
 						$selected = '';
61 61
 					}
62
-					echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
63
-						esc_html( $object['name'] ),
64
-						esc_attr( $selected ),
65
-						esc_html( $object['label'] )
62
+					echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
63
+						esc_html($object['name']),
64
+						esc_attr($selected),
65
+						esc_html($object['label'])
66 66
 					);
67 67
 				}
68 68
 				?>
@@ -70,30 +70,30 @@  discard block
 block discarded – undo
70 70
 		</div>
71 71
 		<div class="salesforce_record_types_allowed">
72 72
 			<?php
73
-			if ( isset( $salesforce_record_types_allowed ) ) :
73
+			if (isset($salesforce_record_types_allowed)) :
74 74
 				$record_types = $this->get_salesforce_object_description(
75 75
 					array(
76 76
 						'salesforce_object' => $salesforce_object,
77 77
 						'include'           => 'recordTypeInfos',
78 78
 					)
79 79
 				);
80
-				if ( isset( $record_types['recordTypeInfos'] ) ) :
80
+				if (isset($record_types['recordTypeInfos'])) :
81 81
 					?>
82
-					<label for="salesforce_record_types_allowed"><?php echo __( 'Allowed Record Types', 'object-sync-for-salesforce' ); ?>:</label>
82
+					<label for="salesforce_record_types_allowed"><?php echo __('Allowed Record Types', 'object-sync-for-salesforce'); ?>:</label>
83 83
 					<div class="checkboxes">
84
-					<?php foreach ( $record_types['recordTypeInfos'] as $key => $value ) : ?>
84
+					<?php foreach ($record_types['recordTypeInfos'] as $key => $value) : ?>
85 85
 						<?php
86
-						if ( in_array( $key, $salesforce_record_types_allowed, true ) ) {
86
+						if (in_array($key, $salesforce_record_types_allowed, true)) {
87 87
 							$checked = ' checked';
88 88
 						} else {
89 89
 							$checked = '';
90 90
 						}
91
-						echo sprintf( '<label><input type="checkbox" class="form-checkbox" value="%1$s" name="%2$s" id="%3$s"%4$s>%5$s</label>',
92
-							esc_html( $key ),
93
-							esc_attr( 'salesforce_record_types_allowed[' . $key . ']' ),
94
-							esc_attr( 'salesforce_record_types_allowed-' . $key ),
95
-							esc_html( $checked ),
96
-							esc_html( $value )
91
+						echo sprintf('<label><input type="checkbox" class="form-checkbox" value="%1$s" name="%2$s" id="%3$s"%4$s>%5$s</label>',
92
+							esc_html($key),
93
+							esc_attr('salesforce_record_types_allowed[' . $key . ']'),
94
+							esc_attr('salesforce_record_types_allowed-' . $key),
95
+							esc_html($checked),
96
+							esc_html($value)
97 97
 						);
98 98
 						?>
99 99
 					<?php endforeach; ?>
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 		</div>
104 104
 		<div class="salesforce_record_type_default">
105 105
 			<?php
106
-			if ( isset( $salesforce_record_type_default ) ) :
106
+			if (isset($salesforce_record_type_default)) :
107 107
 				$record_types = $this->get_salesforce_object_description(
108 108
 					array(
109 109
 						'salesforce_object' => $salesforce_object,
110 110
 						'include'           => 'recordTypeInfos',
111 111
 					)
112 112
 				);
113
-				if ( isset( $record_types['recordTypeInfos'] ) ) :
113
+				if (isset($record_types['recordTypeInfos'])) :
114 114
 					?>
115
-					<label for="salesforce_record_type_default"><?php echo __( 'Default Record Type', 'object-sync-for-salesforce' ); ?>:</label>
116
-					<select id="salesforce_record_type_default" name="salesforce_record_type_default" required><option value="">- <?php echo __( 'Select record type', 'object-sync-for-salesforce' ); ?> -</option>
115
+					<label for="salesforce_record_type_default"><?php echo __('Default Record Type', 'object-sync-for-salesforce'); ?>:</label>
116
+					<select id="salesforce_record_type_default" name="salesforce_record_type_default" required><option value="">- <?php echo __('Select record type', 'object-sync-for-salesforce'); ?> -</option>
117 117
 					<?php
118
-					foreach ( $record_types['recordTypeInfos'] as $key => $value ) :
119
-						if ( isset( $salesforce_record_type_default ) && $salesforce_record_type_default === $key ) {
118
+					foreach ($record_types['recordTypeInfos'] as $key => $value) :
119
+						if (isset($salesforce_record_type_default) && $salesforce_record_type_default === $key) {
120 120
 							$selected = ' selected';
121 121
 						} else {
122 122
 							$selected = '';
123 123
 						}
124
-						if ( ! isset( $salesforce_record_types_allowed ) || in_array( $key, $salesforce_record_types_allowed, true ) ) {
125
-							echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
126
-								esc_attr( $key ),
127
-								esc_attr( $selected ),
128
-								esc_html( $value )
124
+						if ( ! isset($salesforce_record_types_allowed) || in_array($key, $salesforce_record_types_allowed, true)) {
125
+							echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
126
+								esc_attr($key),
127
+								esc_attr($selected),
128
+								esc_html($value)
129 129
 							);
130 130
 						}
131 131
 					endforeach;
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 			?>
138 138
 		</div>
139 139
 		<div class="pull_trigger_field">
140
-			<?php if ( isset( $pull_trigger_field ) ) : ?>
141
-				<label for="pull_trigger_field"><?php echo __( 'Date field to trigger pull', 'object-sync-for-salesforce' ); ?>:</label>
140
+			<?php if (isset($pull_trigger_field)) : ?>
141
+				<label for="pull_trigger_field"><?php echo __('Date field to trigger pull', 'object-sync-for-salesforce'); ?>:</label>
142 142
 				<?php
143 143
 				$object_fields = $this->get_salesforce_object_fields(
144 144
 					array(
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 				?>
150 150
 				<select name="pull_trigger_field" id="pull_trigger_field">
151 151
 				<?php
152
-				foreach ( $object_fields as $key => $value ) {
153
-					if ( $pull_trigger_field === $value['name'] ) {
152
+				foreach ($object_fields as $key => $value) {
153
+					if ($pull_trigger_field === $value['name']) {
154 154
 						$selected = ' selected';
155 155
 					} else {
156 156
 						$selected = '';
157 157
 					}
158
-					echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
159
-						esc_attr( $value['name'] ),
160
-						esc_attr( $selected ),
161
-						esc_html( $value['label'] )
158
+					echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
159
+						esc_attr($value['name']),
160
+						esc_attr($selected),
161
+						esc_html($value['label'])
162 162
 					);
163 163
 				}
164 164
 				?>
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 		</div>
168 168
 	</fieldset>
169 169
 	<fieldset class="fields">
170
-		<legend><?php echo esc_html__( 'Fieldmap', 'object-sync-for-salesforce' ); ?></legend>
170
+		<legend><?php echo esc_html__('Fieldmap', 'object-sync-for-salesforce'); ?></legend>
171 171
 		<table class="wp-list-table widefat striped fields">
172 172
 			<thead>
173 173
 				<tr>
174
-					<th class="column-wordpress_field"><?php echo esc_html__( 'WordPress Field', 'object-sync-for-salesforce' ); ?></th>
175
-					<th class="column-salesforce_field"><?php echo esc_html__( 'Salesforce Field', 'object-sync-for-salesforce' ); ?></th>
176
-					<th class="column-is_prematch"><?php echo esc_html__( 'Prematch', 'object-sync-for-salesforce' ); ?></th>
177
-					<th class="column-is_key"><?php echo esc_html__( 'Salesforce Key', 'object-sync-for-salesforce' ); ?></th>
178
-					<th class="column-direction"><?php echo esc_html__( 'Direction', 'object-sync-for-salesforce' ); ?></th>
179
-					<th class="column-is_delete"><?php echo esc_html__( 'Delete', 'object-sync-for-salesforce' ); ?></th>
174
+					<th class="column-wordpress_field"><?php echo esc_html__('WordPress Field', 'object-sync-for-salesforce'); ?></th>
175
+					<th class="column-salesforce_field"><?php echo esc_html__('Salesforce Field', 'object-sync-for-salesforce'); ?></th>
176
+					<th class="column-is_prematch"><?php echo esc_html__('Prematch', 'object-sync-for-salesforce'); ?></th>
177
+					<th class="column-is_key"><?php echo esc_html__('Salesforce Key', 'object-sync-for-salesforce'); ?></th>
178
+					<th class="column-direction"><?php echo esc_html__('Direction', 'object-sync-for-salesforce'); ?></th>
179
+					<th class="column-is_delete"><?php echo esc_html__('Delete', 'object-sync-for-salesforce'); ?></th>
180 180
 				</tr>
181 181
 			</thead>
182 182
 			<tfoot>
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
 						<p><small>
186 186
 							<?php
187 187
 							// translators: the placeholders refer to: 1) the cache clear link, 2) the cache clear link text
188
-							echo sprintf( '<strong>' . esc_html__( 'Note:', 'object-sync-for-salesforce' ) . '</strong>' . esc_html__( ' to map a custom meta field (such as wp_postmeta, wp_usermeta, wp_termmeta, etc.), WordPress must have at least one value for that field. If you add a new meta field and want to map it, make sure to add a value for it and ', 'object-sync-for-salesforce' ) . '<a href="%1$s" id="clear-sfwp-cache">%2$s</a>' . esc_html__( ' to see the field listed here', 'object-sync-for-salesforce' ),
189
-								esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=clear_cache' ) ),
190
-								esc_html__( 'clear the plugin cache', 'object-sync-for-salesforce' )
188
+							echo sprintf('<strong>' . esc_html__('Note:', 'object-sync-for-salesforce') . '</strong>' . esc_html__(' to map a custom meta field (such as wp_postmeta, wp_usermeta, wp_termmeta, etc.), WordPress must have at least one value for that field. If you add a new meta field and want to map it, make sure to add a value for it and ', 'object-sync-for-salesforce') . '<a href="%1$s" id="clear-sfwp-cache">%2$s</a>' . esc_html__(' to see the field listed here', 'object-sync-for-salesforce'),
189
+								esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=clear_cache')),
190
+								esc_html__('clear the plugin cache', 'object-sync-for-salesforce')
191 191
 							);
192 192
 							?>
193 193
 						</small></p>
@@ -196,26 +196,26 @@  discard block
 block discarded – undo
196 196
 			</tfoot>
197 197
 			<tbody>
198 198
 				<?php
199
-				if ( isset( $fieldmap_fields ) && null !== $fieldmap_fields && is_array( $fieldmap_fields ) ) {
200
-					foreach ( $fieldmap_fields as $key => $value ) {
201
-						$key = md5( $key . time() );
199
+				if (isset($fieldmap_fields) && null !== $fieldmap_fields && is_array($fieldmap_fields)) {
200
+					foreach ($fieldmap_fields as $key => $value) {
201
+						$key = md5($key . time());
202 202
 				?>
203 203
 				<tr>
204 204
 					<td class="column-wordpress_field">
205
-						<select name="wordpress_field[<?php echo esc_attr( $key ); ?>]" id="wordpress_field-<?php echo esc_attr( $key ); ?>">
206
-							<option value="">- <?php echo esc_html__( 'Select WordPress field', 'object-sync-for-salesforce' ); ?> -</option>
205
+						<select name="wordpress_field[<?php echo esc_attr($key); ?>]" id="wordpress_field-<?php echo esc_attr($key); ?>">
206
+							<option value="">- <?php echo esc_html__('Select WordPress field', 'object-sync-for-salesforce'); ?> -</option>
207 207
 							<?php
208
-							$wordpress_fields = $this->get_wordpress_object_fields( $wordpress_object );
209
-							foreach ( $wordpress_fields as $wordpress_field ) {
210
-								if ( isset( $value['wordpress_field']['label'] ) && $value['wordpress_field']['label'] === $wordpress_field['key'] ) {
208
+							$wordpress_fields = $this->get_wordpress_object_fields($wordpress_object);
209
+							foreach ($wordpress_fields as $wordpress_field) {
210
+								if (isset($value['wordpress_field']['label']) && $value['wordpress_field']['label'] === $wordpress_field['key']) {
211 211
 									$selected = ' selected';
212 212
 								} else {
213 213
 									$selected = '';
214 214
 								}
215
-								echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
216
-									esc_attr( $wordpress_field['key'] ),
217
-									esc_attr( $selected ),
218
-									esc_html( $wordpress_field['key'] )
215
+								echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
216
+									esc_attr($wordpress_field['key']),
217
+									esc_attr($selected),
218
+									esc_html($wordpress_field['key'])
219 219
 								);
220 220
 							}
221 221
 							?>
@@ -223,27 +223,27 @@  discard block
 block discarded – undo
223 223
 
224 224
 					</td>
225 225
 					<td class="column-salesforce_field">
226
-						<select name="salesforce_field[<?php echo esc_attr( $key ); ?>]" id="salesforce_field-<?php echo esc_attr( $key ); ?>">
227
-							<option value="">- <?php echo esc_html__( 'Select Salesforce field', 'object-sync-for-salesforce' ); ?> -</option>
226
+						<select name="salesforce_field[<?php echo esc_attr($key); ?>]" id="salesforce_field-<?php echo esc_attr($key); ?>">
227
+							<option value="">- <?php echo esc_html__('Select Salesforce field', 'object-sync-for-salesforce'); ?> -</option>
228 228
 							<?php
229 229
 							$salesforce_fields = $this->get_salesforce_object_fields(
230 230
 								array(
231 231
 									'salesforce_object' => $salesforce_object,
232 232
 								)
233 233
 							);
234
-							foreach ( $salesforce_fields as $salesforce_field ) {
235
-								if ( isset( $value['salesforce_field']['name'] ) && $value['salesforce_field']['name'] === $salesforce_field['name'] ) {
234
+							foreach ($salesforce_fields as $salesforce_field) {
235
+								if (isset($value['salesforce_field']['name']) && $value['salesforce_field']['name'] === $salesforce_field['name']) {
236 236
 									$selected = ' selected';
237
-								} elseif ( isset( $value['salesforce_field']['label'] ) && $value['salesforce_field']['label'] === $salesforce_field['name'] ) {
237
+								} elseif (isset($value['salesforce_field']['label']) && $value['salesforce_field']['label'] === $salesforce_field['name']) {
238 238
 									// this conditional is for versions up to 1.1.2, but i think it's fine to leave it for now. if we remove it, people's fieldmaps will not show correctly in the admin.
239 239
 									$selected = ' selected';
240 240
 								} else {
241 241
 									$selected = '';
242 242
 								}
243
-								echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
244
-									esc_attr( $salesforce_field['name'] ),
245
-									esc_attr( $selected ),
246
-									esc_html( $salesforce_field['label'] )
243
+								echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
244
+									esc_attr($salesforce_field['name']),
245
+									esc_attr($selected),
246
+									esc_html($salesforce_field['label'])
247 247
 								);
248 248
 							}
249 249
 							?>
@@ -252,32 +252,32 @@  discard block
 block discarded – undo
252 252
 					</td>
253 253
 					<td class="column-is_prematch">
254 254
 						<?php
255
-						if ( isset( $value['is_prematch'] ) && '1' === $value['is_prematch'] ) {
255
+						if (isset($value['is_prematch']) && '1' === $value['is_prematch']) {
256 256
 							$checked = ' checked';
257 257
 						} else {
258 258
 							$checked = '';
259 259
 						}
260 260
 						?>
261
-						<input type="checkbox" name="is_prematch[<?php echo esc_attr( $key ); ?>]" id="is_prematch-<?php echo esc_attr( $key ); ?>" value="1" <?php echo esc_attr( $checked ); ?> title="<?php echo esc_html__( 'This pair should be checked for existing matches in Salesforce before adding', 'object-sync-for-salesforce' ); ?>" />
261
+						<input type="checkbox" name="is_prematch[<?php echo esc_attr($key); ?>]" id="is_prematch-<?php echo esc_attr($key); ?>" value="1" <?php echo esc_attr($checked); ?> title="<?php echo esc_html__('This pair should be checked for existing matches in Salesforce before adding', 'object-sync-for-salesforce'); ?>" />
262 262
 					</td>
263 263
 					<td class="column-is_key">
264 264
 						<?php
265
-						if ( isset( $value['is_key'] ) && '1' === $value['is_key'] ) {
265
+						if (isset($value['is_key']) && '1' === $value['is_key']) {
266 266
 							$checked = ' checked';
267 267
 						} else {
268 268
 							$checked = '';
269 269
 						}
270 270
 						?>
271
-						<input type="checkbox" name="is_key[<?php echo esc_attr( $key ); ?>]" id="is_key-<?php echo esc_attr( $key ); ?>" value="1" <?php echo esc_attr( $checked ); ?> title="<?php echo esc_html__( 'This Salesforce field is an External ID in Salesforce', 'object-sync-for-salesforce' ); ?>" />
271
+						<input type="checkbox" name="is_key[<?php echo esc_attr($key); ?>]" id="is_key-<?php echo esc_attr($key); ?>" value="1" <?php echo esc_attr($checked); ?> title="<?php echo esc_html__('This Salesforce field is an External ID in Salesforce', 'object-sync-for-salesforce'); ?>" />
272 272
 					</td>
273 273
 					<td class="column-direction">
274 274
 						<?php
275
-						if ( isset( $value['direction'] ) ) {
276
-							if ( 'sf_wp' === $value['direction'] ) {
275
+						if (isset($value['direction'])) {
276
+							if ('sf_wp' === $value['direction']) {
277 277
 								$checked_sf_wp = ' checked';
278 278
 								$checked_wp_sf = '';
279 279
 								$checked_sync  = '';
280
-							} elseif ( 'wp_sf' === $value['direction'] ) {
280
+							} elseif ('wp_sf' === $value['direction']) {
281 281
 								$checked_sf_wp = '';
282 282
 								$checked_wp_sf = ' checked';
283 283
 								$checked_sync  = '';
@@ -293,29 +293,29 @@  discard block
 block discarded – undo
293 293
 						}
294 294
 						?>
295 295
 						<div class="radios">
296
-							<label><input type="radio" value="sf_wp" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-sf-wp" <?php echo esc_attr( $checked_sf_wp ); ?> required> <?php echo esc_html__( 'Salesforce to WordPress', 'object-sync-for-salesforce' ); ?></label>
297
-							<label><input type="radio" value="wp_sf" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-wp-sf" <?php echo esc_attr( $checked_wp_sf ); ?> required> <?php echo esc_html__( 'WordPress to Salesforce', 'object-sync-for-salesforce' ); ?></label>
298
-							<label><input type="radio" value="sync" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-sync" <?php echo esc_attr( $checked_sync ); ?> required> <?php echo esc_html__( 'Sync', 'object-sync-for-salesforce' ); ?></label>
296
+							<label><input type="radio" value="sf_wp" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-sf-wp" <?php echo esc_attr($checked_sf_wp); ?> required> <?php echo esc_html__('Salesforce to WordPress', 'object-sync-for-salesforce'); ?></label>
297
+							<label><input type="radio" value="wp_sf" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-wp-sf" <?php echo esc_attr($checked_wp_sf); ?> required> <?php echo esc_html__('WordPress to Salesforce', 'object-sync-for-salesforce'); ?></label>
298
+							<label><input type="radio" value="sync" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-sync" <?php echo esc_attr($checked_sync); ?> required> <?php echo esc_html__('Sync', 'object-sync-for-salesforce'); ?></label>
299 299
 						</div>
300 300
 					</td>
301 301
 					<td class="column-is_delete">
302
-						<input type="checkbox" name="is_delete[<?php echo esc_attr( $key ); ?>]" id="is_delete-<?php echo esc_attr( $key ); ?>" value="1" />
302
+						<input type="checkbox" name="is_delete[<?php echo esc_attr($key); ?>]" id="is_delete-<?php echo esc_attr($key); ?>" value="1" />
303 303
 					</td>
304 304
 				</tr>
305 305
 				<?php
306 306
 					} // End foreach().
307
-				} elseif ( isset( $wordpress_object ) && isset( $salesforce_object ) ) {
307
+				} elseif (isset($wordpress_object) && isset($salesforce_object)) {
308 308
 				?>
309 309
 				<tr>
310 310
 					<td class="column-wordpress_field">
311 311
 						<select name="wordpress_field[0]" id="wordpress_field-0">
312
-							<option value="">- <?php echo esc_html__( 'Select WordPress field', 'object-sync-for-salesforce' ); ?> -</option>
312
+							<option value="">- <?php echo esc_html__('Select WordPress field', 'object-sync-for-salesforce'); ?> -</option>
313 313
 							<?php
314
-							$wordpress_fields = $this->get_wordpress_object_fields( $wordpress_object );
315
-							foreach ( $wordpress_fields as $wordpress_field ) {
316
-								echo sprintf( '<option value="%1$s">%2$s</option>',
317
-									esc_attr( $wordpress_field['key'] ),
318
-									esc_html( $wordpress_field['key'] )
314
+							$wordpress_fields = $this->get_wordpress_object_fields($wordpress_object);
315
+							foreach ($wordpress_fields as $wordpress_field) {
316
+								echo sprintf('<option value="%1$s">%2$s</option>',
317
+									esc_attr($wordpress_field['key']),
318
+									esc_html($wordpress_field['key'])
319 319
 								);
320 320
 							}
321 321
 							?>
@@ -323,17 +323,17 @@  discard block
 block discarded – undo
323 323
 					</td>
324 324
 					<td class="column-salesforce_field">
325 325
 						<select name="salesforce_field[0]" id="salesforce_field-0">
326
-							<option value="">- <?php echo esc_html__( 'Select Salesforce field', 'object-sync-for-salesforce' ); ?> -</option>
326
+							<option value="">- <?php echo esc_html__('Select Salesforce field', 'object-sync-for-salesforce'); ?> -</option>
327 327
 							<?php
328 328
 							$salesforce_fields = $this->get_salesforce_object_fields(
329 329
 								array(
330 330
 									'salesforce_object' => $salesforce_object,
331 331
 								)
332 332
 							);
333
-							foreach ( $salesforce_fields as $salesforce_field ) {
334
-								echo sprintf( '<option value="%1$s">%2$s</option>',
335
-									esc_attr( $salesforce_field['name'] ),
336
-									esc_html( $salesforce_field['label'] )
333
+							foreach ($salesforce_fields as $salesforce_field) {
334
+								echo sprintf('<option value="%1$s">%2$s</option>',
335
+									esc_attr($salesforce_field['name']),
336
+									esc_html($salesforce_field['label'])
337 337
 								);
338 338
 							}
339 339
 							?>
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 					</td>
348 348
 					<td class="column-direction">
349 349
 						<div class="radios">
350
-							<label><input type="radio" value="sf_wp" name="direction[0]" id="direction-0-sf-wp" required> <?php echo esc_html__( 'Salesforce to WordPress', 'object-sync-for-salesforce' ); ?></label>
351
-							<label><input type="radio" value="wp_sf" name="direction[0]" id="direction-0-wp-sf" required> <?php echo esc_html__( 'WordPress to Salesforce', 'object-sync-for-salesforce' ); ?></label>
352
-							<label><input type="radio" value="sync" name="direction[0]" id="direction-0-sync" required checked> <?php echo esc_html__( 'Sync', 'object-sync-for-salesforce' ); ?></label>
350
+							<label><input type="radio" value="sf_wp" name="direction[0]" id="direction-0-sf-wp" required> <?php echo esc_html__('Salesforce to WordPress', 'object-sync-for-salesforce'); ?></label>
351
+							<label><input type="radio" value="wp_sf" name="direction[0]" id="direction-0-wp-sf" required> <?php echo esc_html__('WordPress to Salesforce', 'object-sync-for-salesforce'); ?></label>
352
+							<label><input type="radio" value="sync" name="direction[0]" id="direction-0-sync" required checked> <?php echo esc_html__('Sync', 'object-sync-for-salesforce'); ?></label>
353 353
 						</div>
354 354
 					</td>
355 355
 					<td class="column-is_delete">
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 		</table>
364 364
 		<!--<div class="spinner"></div>-->
365 365
 		<?php
366
-		if ( isset( $fieldmap_fields ) && null !== $fieldmap_fields ) {
367
-			$add_button_label = esc_html__( 'Add another field mapping', 'object-sync-for-salesforce' );
366
+		if (isset($fieldmap_fields) && null !== $fieldmap_fields) {
367
+			$add_button_label = esc_html__('Add another field mapping', 'object-sync-for-salesforce');
368 368
 		} else {
369
-			$add_button_label = esc_html__( 'Add field mapping', 'object-sync-for-salesforce' );
369
+			$add_button_label = esc_html__('Add field mapping', 'object-sync-for-salesforce');
370 370
 		}
371 371
 		?>
372 372
 		<p><button type="button" id="add-field-mapping" class="button button-secondary"><?php echo $add_button_label; ?></button></p>
373
-		<p class="description"><?php echo esc_html__( 'Prematch tells the plugin to match records that have the same value before sending data to Salesforce. Salesforce Key indicates the Salesforce field is an External ID. If either of these is checked, the plugin will do an UPSERT to avoid duplicate data when possible.', 'object-sync-for-salesforce' ); ?></p>
373
+		<p class="description"><?php echo esc_html__('Prematch tells the plugin to match records that have the same value before sending data to Salesforce. Salesforce Key indicates the Salesforce field is an External ID. If either of these is checked, the plugin will do an UPSERT to avoid duplicate data when possible.', 'object-sync-for-salesforce'); ?></p>
374 374
 	</fieldset>
375 375
 	<fieldset class="sync_triggers">
376
-		<legend><?php echo esc_html__( 'Action triggers', 'object-sync-for-salesforce' ); ?></legend>
376
+		<legend><?php echo esc_html__('Action triggers', 'object-sync-for-salesforce'); ?></legend>
377 377
 		<div class="checkboxes">
378 378
 			<?php
379 379
 			$wordpress_create_checked  = '';
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 			$salesforce_create_checked = '';
383 383
 			$salesforce_update_checked = '';
384 384
 			$salesforce_delete_checked = '';
385
-			if ( isset( $sync_triggers ) && is_array( $sync_triggers ) ) {
386
-				foreach ( $sync_triggers as $trigger ) {
387
-					switch ( $trigger ) {
385
+			if (isset($sync_triggers) && is_array($sync_triggers)) {
386
+				foreach ($sync_triggers as $trigger) {
387
+					switch ($trigger) {
388 388
 						case $this->mappings->sync_wordpress_create:
389 389
 							$wordpress_create_checked = ' checked';
390 390
 							break;
@@ -407,31 +407,31 @@  discard block
 block discarded – undo
407 407
 				}
408 408
 			}
409 409
 			?>
410
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_create ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-create" <?php echo esc_attr( $wordpress_create_checked ); ?>><?php echo esc_html__( 'WordPress create', 'object-sync-for-salesforce' ); ?></label>
411
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_update ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-update" <?php echo esc_attr( $wordpress_update_checked ); ?>><?php echo esc_html__( 'WordPress update', 'object-sync-for-salesforce' ); ?></label>
412
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_delete ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-delete" <?php echo esc_attr( $wordpress_delete_checked ); ?>><?php echo esc_html__( 'WordPress delete', 'object-sync-for-salesforce' ); ?></label>
413
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_create ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-create" <?php echo esc_attr( $salesforce_create_checked ); ?>><?php echo esc_html__( 'Salesforce create', 'object-sync-for-salesforce' ); ?></label>
414
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_update ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-update" <?php echo esc_attr( $salesforce_update_checked ); ?>><?php echo esc_html__( 'Salesforce update', 'object-sync-for-salesforce' ); ?></label>
415
-			<label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_delete ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-delete" <?php echo esc_attr( $salesforce_delete_checked ); ?>><?php echo esc_html__( 'Salesforce delete', 'object-sync-for-salesforce' ); ?></label>
410
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_create); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-create" <?php echo esc_attr($wordpress_create_checked); ?>><?php echo esc_html__('WordPress create', 'object-sync-for-salesforce'); ?></label>
411
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_update); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-update" <?php echo esc_attr($wordpress_update_checked); ?>><?php echo esc_html__('WordPress update', 'object-sync-for-salesforce'); ?></label>
412
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_delete); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-delete" <?php echo esc_attr($wordpress_delete_checked); ?>><?php echo esc_html__('WordPress delete', 'object-sync-for-salesforce'); ?></label>
413
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_create); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-create" <?php echo esc_attr($salesforce_create_checked); ?>><?php echo esc_html__('Salesforce create', 'object-sync-for-salesforce'); ?></label>
414
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_update); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-update" <?php echo esc_attr($salesforce_update_checked); ?>><?php echo esc_html__('Salesforce update', 'object-sync-for-salesforce'); ?></label>
415
+			<label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_delete); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-delete" <?php echo esc_attr($salesforce_delete_checked); ?>><?php echo esc_html__('Salesforce delete', 'object-sync-for-salesforce'); ?></label>
416 416
 			<p class="description">
417 417
 				<?php
418 418
 				// translators: placeholders are for the class names: salesforce_push and salesforce_pull
419
-				echo sprintf( esc_html__( 'Select which actions on WordPress objects and Salesforce objects should trigger a synchronization. These settings are used by the %1$s and %2$s classes respectively.', 'object-sync-for-salesforce' ), '<code>salesforce_push</code>', '<code>salesforce_pull</code>' );
419
+				echo sprintf(esc_html__('Select which actions on WordPress objects and Salesforce objects should trigger a synchronization. These settings are used by the %1$s and %2$s classes respectively.', 'object-sync-for-salesforce'), '<code>salesforce_push</code>', '<code>salesforce_pull</code>');
420 420
 				?>
421 421
 			</p>
422 422
 		</div>
423 423
 		<div class="checkboxes">
424
-			<label><input type="checkbox" name="push_async" id="process-async" value="1" <?php echo isset( $push_async ) && '1' === $push_async ? ' checked' : ''; ?>><?php echo esc_html__( 'Process asynchronously', 'object-sync-for-salesforce' ); ?></label>
424
+			<label><input type="checkbox" name="push_async" id="process-async" value="1" <?php echo isset($push_async) && '1' === $push_async ? ' checked' : ''; ?>><?php echo esc_html__('Process asynchronously', 'object-sync-for-salesforce'); ?></label>
425 425
 			<p class="description">
426 426
 				<?php
427 427
 				// translators: placeholder is for WordPress cron method name
428
-				echo sprintf( esc_html__( 'If selected, push data will be queued for processing and synchronized when %s is run. This may increase site performance, but changes will not be reflected in real time.', 'object-sync-for-salesforce' ), '<code>wp_cron</code>' );
428
+				echo sprintf(esc_html__('If selected, push data will be queued for processing and synchronized when %s is run. This may increase site performance, but changes will not be reflected in real time.', 'object-sync-for-salesforce'), '<code>wp_cron</code>');
429 429
 				?>
430 430
 			</p>
431 431
 		</div>
432 432
 		<div class="checkboxes">
433
-			<label><input type="checkbox" name="push_drafts" id="push-drafts" value="1" <?php echo isset( $push_drafts ) && '1' === $push_drafts ? ' checked' : ''; ?>><?php echo esc_html__( 'Push drafts', 'object-sync-for-salesforce' ); ?></label>
434
-			<p class="description"><?php echo esc_html__( 'If selected, WordPress will send drafts of this object type (if it creates drafts for it) to Salesforce.', 'object-sync-for-salesforce' ); ?></p>
433
+			<label><input type="checkbox" name="push_drafts" id="push-drafts" value="1" <?php echo isset($push_drafts) && '1' === $push_drafts ? ' checked' : ''; ?>><?php echo esc_html__('Push drafts', 'object-sync-for-salesforce'); ?></label>
434
+			<p class="description"><?php echo esc_html__('If selected, WordPress will send drafts of this object type (if it creates drafts for it) to Salesforce.', 'object-sync-for-salesforce'); ?></p>
435 435
 		</div>
436 436
 		<?php
437 437
 		/*
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	<?php
451 451
 		submit_button(
452 452
 			// translators: the placeholder refers to the currently selected method (add, edit, or clone)
453
-			sprintf( esc_html__( '%1$s fieldmap', 'object-sync-for-salesforce' ), ucfirst( $method ) )
453
+			sprintf(esc_html__('%1$s fieldmap', 'object-sync-for-salesforce'), ucfirst($method))
454 454
 		);
455 455
 	?>
456 456
 </form>
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/activate.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 	protected $installed_version;
20 20
 
21 21
 	/**
22
-	* Constructor which sets up activate hooks
23
-	*
24
-	* @param object $wpdb
25
-	* @param string $version
26
-	* @param string $slug
27
-	*
28
-	*/
22
+	 * Constructor which sets up activate hooks
23
+	 *
24
+	 * @param object $wpdb
25
+	 * @param string $version
26
+	 * @param string $slug
27
+	 *
28
+	 */
29 29
 	public function __construct( $wpdb, $version, $slug ) {
30 30
 		$this->wpdb              = $wpdb;
31 31
 		$this->version           = $version;
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-	* Check for the minimum required version of php
41
-	*/
40
+	 * Check for the minimum required version of php
41
+	 */
42 42
 	public function php_requirements() {
43 43
 		if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
44 44
 			deactivate_plugins( plugin_basename( __FILE__ ) );
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	/**
50
-	* Create database tables for Salesforce
51
-	* This creates tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
52
-	*
53
-	*/
50
+	 * Create database tables for Salesforce
51
+	 * This creates tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
52
+	 *
53
+	 */
54 54
 	public function wordpress_salesforce_tables() {
55 55
 
56 56
 		$charset_collate = $this->wpdb->get_charset_collate();
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	/**
114
-	* Check for database version on plugin upgrade
115
-	* When the plugin is upgraded, if the database version does not match the current version, perform these methods
116
-	*
117
-	*/
114
+	 * Check for database version on plugin upgrade
115
+	 * When the plugin is upgraded, if the database version does not match the current version, perform these methods
116
+	 *
117
+	 */
118 118
 	public function wordpress_salesforce_update_db_check() {
119 119
 		if ( get_site_option( 'object_sync_for_salesforce_db_version' ) !== $this->version ) {
120 120
 			$this->wordpress_salesforce_tables();
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 	}
123 123
 
124 124
 	/**
125
-	* Add roles and capabilities
126
-	* This adds the configure_salesforce capability to the admin role
127
-	*
128
-	* It also allows other plugins to add the capability to other roles
129
-	*
130
-	*/
125
+	 * Add roles and capabilities
126
+	 * This adds the configure_salesforce capability to the admin role
127
+	 *
128
+	 * It also allows other plugins to add the capability to other roles
129
+	 *
130
+	 */
131 131
 	public function add_roles_capabilities() {
132 132
 
133 133
 		// by default, only administrators can configure the plugin
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 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
 
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
 	* @param string $slug
27 27
 	*
28 28
 	*/
29
-	public function __construct( $wpdb, $version, $slug ) {
29
+	public function __construct($wpdb, $version, $slug) {
30 30
 		$this->wpdb              = $wpdb;
31 31
 		$this->version           = $version;
32
-		$this->installed_version = get_option( 'object_sync_for_salesforce_db_version', '' );
33
-		register_activation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'php_requirements' ) );
34
-		register_activation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'wordpress_salesforce_tables' ) );
35
-		register_activation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'add_roles_capabilities' ) );
36
-		add_action( 'plugins_loaded', array( $this, 'wordpress_salesforce_update_db_check' ) );
32
+		$this->installed_version = get_option('object_sync_for_salesforce_db_version', '');
33
+		register_activation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'php_requirements'));
34
+		register_activation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'wordpress_salesforce_tables'));
35
+		register_activation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'add_roles_capabilities'));
36
+		add_action('plugins_loaded', array($this, 'wordpress_salesforce_update_db_check'));
37 37
 	}
38 38
 
39 39
 	/**
40 40
 	* Check for the minimum required version of php
41 41
 	*/
42 42
 	public function php_requirements() {
43
-		if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
44
-			deactivate_plugins( plugin_basename( __FILE__ ) );
45
-			wp_die( '<strong>This plugin requires PHP Version 5.5</strong> <br />Please contact your host to upgrade PHP on your server, and then retry activating the plugin.' );
43
+		if (version_compare(PHP_VERSION, '5.5', '<')) {
44
+			deactivate_plugins(plugin_basename(__FILE__));
45
+			wp_die('<strong>This plugin requires PHP Version 5.5</strong> <br />Please contact your host to upgrade PHP on your server, and then retry activating the plugin.');
46 46
 		}
47 47
 	}
48 48
 
@@ -95,18 +95,18 @@  discard block
 block discarded – undo
95 95
 			KEY salesforce_object (salesforce_id)
96 96
 		) $charset_collate";
97 97
 
98
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
98
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
99 99
 
100 100
 		// Note: see https://wordpress.stackexchange.com/questions/67345/how-to-implement-wordpress-plugin-update-that-modifies-the-database
101 101
 		// When we run the dbDelta method below, "it checks if the table exists. What's more, it checks the column types. So if the table doesn't exist, it creates it, if it does, but some column types have changed it updates them, and if a column doesn't exists - it adds it."
102 102
 		// This does not remove columns if we remove columns, so we'll need to expand beyond this in the future if that happens, although I think the schema is pretty solid now.
103
-		dbDelta( $field_map_sql );
104
-		dbDelta( $object_map_sql );
103
+		dbDelta($field_map_sql);
104
+		dbDelta($object_map_sql);
105 105
 
106
-		update_option( 'object_sync_for_salesforce_db_version', $this->version );
106
+		update_option('object_sync_for_salesforce_db_version', $this->version);
107 107
 
108 108
 		// store right now as the time for the plugin's activation
109
-		update_option( 'object_sync_for_salesforce_activate_time', current_time( 'timestamp', true ) );
109
+		update_option('object_sync_for_salesforce_activate_time', current_time('timestamp', true));
110 110
 
111 111
 	}
112 112
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	*
117 117
 	*/
118 118
 	public function wordpress_salesforce_update_db_check() {
119
-		if ( get_site_option( 'object_sync_for_salesforce_db_version' ) !== $this->version ) {
119
+		if (get_site_option('object_sync_for_salesforce_db_version') !== $this->version) {
120 120
 			$this->wordpress_salesforce_tables();
121 121
 		}
122 122
 	}
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 	public function add_roles_capabilities() {
132 132
 
133 133
 		// by default, only administrators can configure the plugin
134
-		$role = get_role( 'administrator' );
135
-		$role->add_cap( 'configure_salesforce' );
134
+		$role = get_role('administrator');
135
+		$role->add_cap('configure_salesforce');
136 136
 
137 137
 		// hook that allows other roles to configure the plugin as well
138
-		$roles = apply_filters( 'object_sync_for_salesforce_roles_configure_salesforce', null );
138
+		$roles = apply_filters('object_sync_for_salesforce_roles_configure_salesforce', null);
139 139
 
140 140
 		// for each role that we have, give it the configure salesforce capability
141
-		if ( null !== $roles ) {
142
-			foreach ( $roles as $role ) {
143
-				$role = get_role( $role );
144
-				$role->add_cap( 'configure_salesforce' );
141
+		if (null !== $roles) {
142
+			foreach ($roles as $role) {
143
+				$role = get_role($role);
144
+				$role->add_cap('configure_salesforce');
145 145
 			}
146 146
 		}
147 147
 
Please login to merge, or discard this patch.
classes/salesforce_pull.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
 	protected $schedulable_classes;
25 25
 
26 26
 	/**
27
-	* @var string
28
-	*/
27
+	 * @var string
28
+	 */
29 29
 	public $schedule_name; // allow for naming the queue in case there are multiple queues
30 30
 
31 31
 	/**
32
-	* Constructor which sets up pull schedule
33
-	*
34
-	* @param object $wpdb
35
-	* @param string $version
36
-	* @param array $login_credentials
37
-	* @param string $slug
38
-	* @param object $wordpress
39
-	* @param object $salesforce
40
-	* @param object $mappings
41
-	* @param object $logging
42
-	* @param array $schedulable_classes
43
-	* @throws \Exception
44
-	*/
32
+	 * Constructor which sets up pull schedule
33
+	 *
34
+	 * @param object $wpdb
35
+	 * @param string $version
36
+	 * @param array $login_credentials
37
+	 * @param string $slug
38
+	 * @param object $wordpress
39
+	 * @param object $salesforce
40
+	 * @param object $mappings
41
+	 * @param object $logging
42
+	 * @param array $schedulable_classes
43
+	 * @throws \Exception
44
+	 */
45 45
 	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
46 46
 		$this->wpdb                = $wpdb;
47 47
 		$this->version             = $version;
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	/**
73
-	* Create the action hooks based on what object maps exist from the admin settings
74
-	*
75
-	*/
73
+	 * Create the action hooks based on what object maps exist from the admin settings
74
+	 *
75
+	 */
76 76
 	private function add_actions() {
77 77
 		add_action( 'wp_ajax_salesforce_pull_webhook', array( $this, 'salesforce_pull_webhook' ) );
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Ajax callback for salesforce pull. Returns status of 200 for successful
82
-	* attempt or 403 for a failed pull attempt (SF not authorized, threshhold
83
-	* reached, etc.
84
-	* this is the ajax callback; not a cron run
85
-	*/
81
+	 * Ajax callback for salesforce pull. Returns status of 200 for successful
82
+	 * attempt or 403 for a failed pull attempt (SF not authorized, threshhold
83
+	 * reached, etc.
84
+	 * this is the ajax callback; not a cron run
85
+	 */
86 86
 	public function salesforce_pull_webhook() {
87 87
 
88 88
 		if ( true === $this->salesforce_pull() ) {
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	/**
105
-	* Callback for the standard pull process used by webhooks and cron.
106
-	*/
105
+	 * Callback for the standard pull process used by webhooks and cron.
106
+	 */
107 107
 	public function salesforce_pull() {
108 108
 		$sfapi = $this->salesforce['sfapi'];
109 109
 
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	}
124 124
 
125 125
 	/**
126
-	* Load schedule
127
-	* This loads the schedule class
128
-	*/
126
+	 * Load schedule
127
+	 * This loads the schedule class
128
+	 */
129 129
 	private function schedule() {
130 130
 		if ( ! class_exists( 'Object_Sync_Sf_Schedule' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
131 131
 			require_once plugin_dir_path( __FILE__ ) . '../vendor/autoload.php';
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 	}
138 138
 
139 139
 	/**
140
-	* Determines if the Salesforce pull should be allowed, or throttled.
141
-	*
142
-	* Prevents too many pull processes from running at once.
143
-	*
144
-	* @return bool
145
-	*    Returns false if the time elapsed between recent pulls is too short.
146
-	*/
140
+	 * Determines if the Salesforce pull should be allowed, or throttled.
141
+	 *
142
+	 * Prevents too many pull processes from running at once.
143
+	 *
144
+	 * @return bool
145
+	 *    Returns false if the time elapsed between recent pulls is too short.
146
+	 */
147 147
 	private function check_throttle() {
148 148
 		$pull_throttle = get_option( 'object_sync_for_salesforce_pull_throttle', 5 );
149 149
 		$last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync', 0 );
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 
158 158
 	/**
159
-	* Pull updated records from Salesforce and place them in the queue.
160
-	*
161
-	* Executes a SOQL query based on defined mappings, loops through the results,
162
-	* and places each updated SF object into the queue for later processing.
163
-	*
164
-	* We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF
165
-	*
166
-	*/
159
+	 * Pull updated records from Salesforce and place them in the queue.
160
+	 *
161
+	 * Executes a SOQL query based on defined mappings, loops through the results,
162
+	 * and places each updated SF object into the queue for later processing.
163
+	 *
164
+	 * We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF
165
+	 *
166
+	 */
167 167
 	private function get_updated_records() {
168 168
 		$sfapi = $this->salesforce['sfapi'];
169 169
 		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
 	}
330 330
 
331 331
 	/**
332
-	* Given a SObject type name, build an SOQL query to include all fields for all
333
-	* SalesforceMappings mapped to that SObject.
334
-	*
335
-	* @param string $type
336
-	*   e.g. "Contact", "Account", etc.
337
-	*
338
-	* @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields
339
-	*   were found.
340
-	*
341
-	* @see Object_Sync_Sf_Mapping::get_mapped_fields
342
-	* @see Object_Sync_Sf_Mapping::get_mapped_record_types
343
-	*/
332
+	 * Given a SObject type name, build an SOQL query to include all fields for all
333
+	 * SalesforceMappings mapped to that SObject.
334
+	 *
335
+	 * @param string $type
336
+	 *   e.g. "Contact", "Account", etc.
337
+	 *
338
+	 * @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields
339
+	 *   were found.
340
+	 *
341
+	 * @see Object_Sync_Sf_Mapping::get_mapped_fields
342
+	 * @see Object_Sync_Sf_Mapping::get_mapped_record_types
343
+	 */
344 344
 	private function get_pull_query( $type, $salesforce_mapping = array() ) {
345 345
 		$mapped_fields       = array();
346 346
 		$mapped_record_types = array();
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
 	}
423 423
 
424 424
 	/**
425
-	* Get deleted records from salesforce.
426
-	* Note that deletions can only be queried via REST with an API version >= 29.0.
427
-	*
428
-	*/
425
+	 * Get deleted records from salesforce.
426
+	 * Note that deletions can only be queried via REST with an API version >= 29.0.
427
+	 *
428
+	 */
429 429
 	private function get_deleted_records() {
430 430
 
431 431
 		$sfapi = $this->salesforce['sfapi'];
@@ -517,13 +517,13 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	/**
520
-	* Method for ajax hooks to call for pulling manually
521
-	*
522
-	* @param string $object_type
523
-	* @param string $salesforce_id
524
-	* @param string $wordpress_object
525
-	*
526
-	*/
520
+	 * Method for ajax hooks to call for pulling manually
521
+	 *
522
+	 * @param string $object_type
523
+	 * @param string $salesforce_id
524
+	 * @param string $wordpress_object
525
+	 *
526
+	 */
527 527
 	public function manual_pull( $object_type, $salesforce_id, $wordpress_object ) {
528 528
 		$sfapi   = $this->salesforce['sfapi'];
529 529
 		$object  = $sfapi->api_call( 'sobjects/' . $object_type . '/' . $salesforce_id );
@@ -538,20 +538,20 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 	/**
541
-	* Sync WordPress objects and Salesforce objects from the queue using the REST API.
542
-	*
543
-	* @param string $object_type
544
-	*   Type of Salesforce object.
545
-	* @param object $object
546
-	*   The Salesforce object.
547
-	* @param object $mapping
548
-	*   Salesforce/WP mapping object.
549
-	* @param int $sf_sync_trigger
550
-	*   Trigger for this sync.
551
-	*
552
-	* @return true or exit the method
553
-	*
554
-	*/
541
+	 * Sync WordPress objects and Salesforce objects from the queue using the REST API.
542
+	 *
543
+	 * @param string $object_type
544
+	 *   Type of Salesforce object.
545
+	 * @param object $object
546
+	 *   The Salesforce object.
547
+	 * @param object $mapping
548
+	 *   Salesforce/WP mapping object.
549
+	 * @param int $sf_sync_trigger
550
+	 *   Trigger for this sync.
551
+	 *
552
+	 * @return true or exit the method
553
+	 *
554
+	 */
555 555
 	public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) {
556 556
 		$mapping_conditions = array(
557 557
 			'salesforce_object' => $object_type,
@@ -1282,19 +1282,19 @@  discard block
 block discarded – undo
1282 1282
 	}
1283 1283
 
1284 1284
 	/**
1285
-	* Create an object map between a Salesforce object and a WordPress object
1286
-	*
1287
-	* @param array $salesforce_object
1288
-	*   Array of the salesforce object's data
1289
-	* @param string $wordpress_id
1290
-	*   Unique identifier for the WordPress object
1291
-	* @param array $field_mapping
1292
-	*   The row that maps the object types together, including which fields match which other fields
1293
-	*
1294
-	* @return int $wpdb->insert_id
1295
-	*   This is the database row for the map object
1296
-	*
1297
-	*/
1285
+	 * Create an object map between a Salesforce object and a WordPress object
1286
+	 *
1287
+	 * @param array $salesforce_object
1288
+	 *   Array of the salesforce object's data
1289
+	 * @param string $wordpress_id
1290
+	 *   Unique identifier for the WordPress object
1291
+	 * @param array $field_mapping
1292
+	 *   The row that maps the object types together, including which fields match which other fields
1293
+	 *
1294
+	 * @return int $wpdb->insert_id
1295
+	 *   This is the database row for the map object
1296
+	 *
1297
+	 */
1298 1298
 	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1299 1299
 		// Create object map and save it
1300 1300
 		$mapping_object = $this->mappings->create_object_map(
Please login to merge, or discard this patch.
Spacing   +316 added lines, -316 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
 	* @throws \Exception
44 44
 	*/
45
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
45
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes) {
46 46
 		$this->wpdb                = $wpdb;
47 47
 		$this->version             = $version;
48 48
 		$this->login_credentials   = $login_credentials;
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 		$schedule = $this->schedule;
62 62
 		// create new schedule based on the options for this current class
63 63
 		// this will use the existing schedule if it already exists; otherwise it'll create one
64
-		$schedule->use_schedule( $this->schedule_name );
64
+		$schedule->use_schedule($this->schedule_name);
65 65
 
66 66
 		$this->add_actions();
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
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	*
75 75
 	*/
76 76
 	private function add_actions() {
77
-		add_action( 'wp_ajax_salesforce_pull_webhook', array( $this, 'salesforce_pull_webhook' ) );
77
+		add_action('wp_ajax_salesforce_pull_webhook', array($this, 'salesforce_pull_webhook'));
78 78
 	}
79 79
 
80 80
 	/**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	*/
86 86
 	public function salesforce_pull_webhook() {
87 87
 
88
-		if ( true === $this->salesforce_pull() ) {
88
+		if (true === $this->salesforce_pull()) {
89 89
 			$code = '200';
90 90
 			// check to see if anything is in the queue and handle it if it is
91 91
 			$this->schedule->maybe_handle();
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 			$code = '403';
94 94
 		}
95 95
 
96
-		if ( ! empty( $_POST ) ) { // linter flags this, but we're not doing anything with the array just checking to see if it is empty
97
-			wp_send_json_success( $code );
96
+		if ( ! empty($_POST)) { // linter flags this, but we're not doing anything with the array just checking to see if it is empty
97
+			wp_send_json_success($code);
98 98
 		} else {
99 99
 			return $code;
100 100
 		}
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	public function salesforce_pull() {
108 108
 		$sfapi = $this->salesforce['sfapi'];
109 109
 
110
-		if ( true === $this->salesforce['is_authorized'] && true === $this->check_throttle() ) {
110
+		if (true === $this->salesforce['is_authorized'] && true === $this->check_throttle()) {
111 111
 
112 112
 			$this->get_updated_records();
113 113
 			$this->get_deleted_records();
114 114
 
115 115
 			// Store this request time for the throttle check.
116
-			update_option( 'object_sync_for_salesforce_pull_last_sync', current_time( 'timestamp', true ) );
116
+			update_option('object_sync_for_salesforce_pull_last_sync', current_time('timestamp', true));
117 117
 			return true;
118 118
 
119 119
 		} else {
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 	* This loads the schedule class
128 128
 	*/
129 129
 	private function schedule() {
130
-		if ( ! class_exists( 'Object_Sync_Sf_Schedule' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
131
-			require_once plugin_dir_path( __FILE__ ) . '../vendor/autoload.php';
132
-			require_once plugin_dir_path( __FILE__ ) . '../classes/schedule.php';
130
+		if ( ! class_exists('Object_Sync_Sf_Schedule') && file_exists(plugin_dir_path(__FILE__) . '../vendor/autoload.php')) {
131
+			require_once plugin_dir_path(__FILE__) . '../vendor/autoload.php';
132
+			require_once plugin_dir_path(__FILE__) . '../classes/schedule.php';
133 133
 		}
134
-		$schedule       = new Object_Sync_Sf_Schedule( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->schedule_name, $this->logging, $this->schedulable_classes );
134
+		$schedule       = new Object_Sync_Sf_Schedule($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->schedule_name, $this->logging, $this->schedulable_classes);
135 135
 		$this->schedule = $schedule;
136 136
 		return $schedule;
137 137
 	}
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 	*    Returns false if the time elapsed between recent pulls is too short.
146 146
 	*/
147 147
 	private function check_throttle() {
148
-		$pull_throttle = get_option( 'object_sync_for_salesforce_pull_throttle', 5 );
149
-		$last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync', 0 );
148
+		$pull_throttle = get_option('object_sync_for_salesforce_pull_throttle', 5);
149
+		$last_sync     = get_option('object_sync_for_salesforce_pull_last_sync', 0);
150 150
 
151
-		if ( current_time( 'timestamp', true ) > ( $last_sync + $pull_throttle ) ) {
151
+		if (current_time('timestamp', true) > ($last_sync + $pull_throttle)) {
152 152
 			return true;
153 153
 		} else {
154 154
 			return false;
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	*/
167 167
 	private function get_updated_records() {
168 168
 		$sfapi = $this->salesforce['sfapi'];
169
-		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
169
+		foreach ($this->mappings->get_fieldmaps() as $salesforce_mapping) {
170 170
 			$map_sync_triggers = $salesforce_mapping['sync_triggers']; // this sets which Salesforce triggers are allowed for the mapping
171 171
 			$type              = $salesforce_mapping['salesforce_object']; // this sets the salesfore object type for the SOQL query
172 172
 
173
-			$soql = $this->get_pull_query( $type, $salesforce_mapping );
173
+			$soql = $this->get_pull_query($type, $salesforce_mapping);
174 174
 
175 175
 			// get_pull_query returns null if it has no matching fields
176
-			if ( null === $soql ) {
176
+			if (null === $soql) {
177 177
 				continue;
178 178
 			}
179 179
 
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 			);
189 189
 
190 190
 			$response     = $results['data'];
191
-			$version_path = wp_parse_url( $sfapi->get_api_endpoint(), PHP_URL_PATH );
191
+			$version_path = wp_parse_url($sfapi->get_api_endpoint(), PHP_URL_PATH);
192 192
 
193
-			$sf_last_sync = get_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, null );
194
-			$last_sync    = gmdate( 'Y-m-d\TH:i:s\Z', $sf_last_sync );
193
+			$sf_last_sync = get_option('object_sync_for_salesforce_pull_last_sync_' . $type, null);
194
+			$last_sync    = gmdate('Y-m-d\TH:i:s\Z', $sf_last_sync);
195 195
 
196
-			if ( ! isset( $response['errorCode'] ) ) {
196
+			if ( ! isset($response['errorCode'])) {
197 197
 				// Write items to the queue.
198
-				foreach ( $response['records'] as $result ) {
198
+				foreach ($response['records'] as $result) {
199 199
 
200 200
 					// if this record is new as of the last sync, use the create trigger
201
-					if ( isset( $result['CreatedDate'] ) && $result['CreatedDate'] > $last_sync ) {
201
+					if (isset($result['CreatedDate']) && $result['CreatedDate'] > $last_sync) {
202 202
 						$sf_sync_trigger = $this->mappings->sync_sf_create;
203 203
 					} else {
204 204
 						$sf_sync_trigger = $this->mappings->sync_sf_update;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 					// Only queue when the record's trigger is configured for the mapping
208 208
 					// these are bit operators, so we leave out the strict
209
-					if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
209
+					if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
210 210
 						$data = array(
211 211
 							'object_type'     => $type,
212 212
 							'object'          => $result,
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 						$pull_allowed = true;
219 219
 
220 220
 						// if the current fieldmap does not allow create, we need to check if there is a fieldmap for the Salesforce object Id. if not, set pull_allowed to false.
221
-						if ( isset( $map_sync_triggers ) && ! in_array( $this->mappings->sync_sf_create, $map_sync_triggers ) ) {
222
-							$object_map = $this->mappings->load_by_salesforce( $result['Id'] );
223
-							if ( empty( $object_map ) ) {
221
+						if (isset($map_sync_triggers) && ! in_array($this->mappings->sync_sf_create, $map_sync_triggers)) {
222
+							$object_map = $this->mappings->load_by_salesforce($result['Id']);
223
+							if (empty($object_map)) {
224 224
 								$pull_allowed = false;
225 225
 							}
226 226
 						}
227 227
 
228 228
 						// Hook to allow other plugins to prevent a pull per-mapping.
229 229
 						// Putting the pull_allowed hook here will keep the queue from storing data when it is not supposed to store it
230
-						$pull_allowed = apply_filters( 'object_sync_for_salesforce_pull_object_allowed', $pull_allowed, $type, $result, $sf_sync_trigger, $salesforce_mapping );
230
+						$pull_allowed = apply_filters('object_sync_for_salesforce_pull_object_allowed', $pull_allowed, $type, $result, $sf_sync_trigger, $salesforce_mapping);
231 231
 
232 232
 						// example to keep from pulling the Contact with id of abcdef
233 233
 						/*
@@ -240,26 +240,26 @@  discard block
 block discarded – undo
240 240
 						}
241 241
 						*/
242 242
 
243
-						if ( false === $pull_allowed ) {
244
-							update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, current_time( 'timestamp', true ) );
243
+						if (false === $pull_allowed) {
244
+							update_option('object_sync_for_salesforce_pull_last_sync_' . $type, current_time('timestamp', true));
245 245
 							continue;
246 246
 						}
247 247
 
248 248
 						// Initialize the queue with the data for this record and save
249
-						$this->schedule->data( array( $data ) );
249
+						$this->schedule->data(array($data));
250 250
 						$this->schedule->save()->dispatch();
251 251
 						// Update the last pull sync timestamp for this record type to avoid re-processing in case of error
252
-						$last_sync_pull_trigger = DateTime::createFromFormat( 'Y-m-d\TH:i:s+', $result[ $salesforce_mapping['pull_trigger_field'] ], new DateTimeZone( 'UTC' ) );
253
-						update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format( 'U' ) );
252
+						$last_sync_pull_trigger = DateTime::createFromFormat('Y-m-d\TH:i:s+', $result[$salesforce_mapping['pull_trigger_field']], new DateTimeZone('UTC'));
253
+						update_option('object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format('U'));
254 254
 					}
255 255
 				}
256 256
 
257 257
 				// Handle requests larger than the batch limit (usually 2000).
258
-				$next_records_url = isset( $response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $response['nextRecordsUrl'] ) : false;
258
+				$next_records_url = isset($response['nextRecordsUrl']) ? str_replace($version_path, '', $response['nextRecordsUrl']) : false;
259 259
 
260
-				while ( $next_records_url ) {
260
+				while ($next_records_url) {
261 261
 					// shouldn't cache this either. it's going into the queue if it exists anyway.
262
-					$new_results  = $sfapi->api_call(
262
+					$new_results = $sfapi->api_call(
263 263
 						$next_records_url,
264 264
 						array(),
265 265
 						'GET',
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 						)
269 269
 					);
270 270
 					$new_response = $new_results['data'];
271
-					if ( ! isset( $new_response['errorCode'] ) ) {
271
+					if ( ! isset($new_response['errorCode'])) {
272 272
 						// Write items to the queue.
273
-						foreach ( $new_response['records'] as $result ) {
273
+						foreach ($new_response['records'] as $result) {
274 274
 							// if this record is new as of the last sync, use the create trigger
275
-							if ( isset( $result['CreatedDate'] ) && $result['CreatedDate'] > $last_sync ) {
275
+							if (isset($result['CreatedDate']) && $result['CreatedDate'] > $last_sync) {
276 276
 								$sf_sync_trigger = $this->mappings->sync_sf_create;
277 277
 							} else {
278 278
 								$sf_sync_trigger = $this->mappings->sync_sf_update;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
 							// Only queue when the record's trigger is configured for the mapping
282 282
 							// these are bit operators, so we leave out the strict
283
-							if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
283
+							if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
284 284
 								$data = array(
285 285
 									'object_type'     => $type,
286 286
 									'object'          => $result,
@@ -289,31 +289,31 @@  discard block
 block discarded – undo
289 289
 								);
290 290
 
291 291
 								// Initialize the queue with the data for this record and save
292
-								$this->schedule->data( array( $data ) );
292
+								$this->schedule->data(array($data));
293 293
 								$this->schedule->save()->dispatch();
294 294
 								// Update the last pull sync timestamp for this record type to avoid re-processing in case of error
295
-								$last_sync_pull_trigger = DateTime::createFromFormat( 'Y-m-d\TH:i:s+', $result[ $salesforce_mapping['pull_trigger_field'] ], new DateTimeZone( 'UTC' ) );
296
-								update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format( 'U' ) );
295
+								$last_sync_pull_trigger = DateTime::createFromFormat('Y-m-d\TH:i:s+', $result[$salesforce_mapping['pull_trigger_field']], new DateTimeZone('UTC'));
296
+								update_option('object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format('U'));
297 297
 							}
298 298
 						}
299 299
 					}
300 300
 
301
-					$next_records_url = isset( $new_response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $new_response['nextRecordsUrl'] ) : false;
301
+					$next_records_url = isset($new_response['nextRecordsUrl']) ? str_replace($version_path, '', $new_response['nextRecordsUrl']) : false;
302 302
 				}
303 303
 			} else {
304 304
 
305 305
 				// create log entry for failed pull
306 306
 				$status = 'error';
307 307
 				// translators: placeholders are: 1) the server error code, and 2) the name of the Salesforce object
308
-				$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
309
-					absint( $response['errorCode'] ),
310
-					esc_attr( $salesforce_mapping['salesforce_object'] )
308
+				$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
309
+					absint($response['errorCode']),
310
+					esc_attr($salesforce_mapping['salesforce_object'])
311 311
 				);
312 312
 
313
-				if ( isset( $this->logging ) ) {
313
+				if (isset($this->logging)) {
314 314
 					$logging = $this->logging;
315
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
316
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
315
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
316
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
317 317
 				}
318 318
 
319 319
 				$logging->setup(
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	* @see Object_Sync_Sf_Mapping::get_mapped_fields
342 342
 	* @see Object_Sync_Sf_Mapping::get_mapped_record_types
343 343
 	*/
344
-	private function get_pull_query( $type, $salesforce_mapping = array() ) {
344
+	private function get_pull_query($type, $salesforce_mapping = array()) {
345 345
 		$mapped_fields       = array();
346 346
 		$mapped_record_types = array();
347 347
 
@@ -353,35 +353,35 @@  discard block
 block discarded – undo
353 353
 		);
354 354
 
355 355
 		// Iterate over each field mapping to determine our query parameters.
356
-		foreach ( $mappings as $mapping ) {
356
+		foreach ($mappings as $mapping) {
357 357
 
358 358
 			// only use fields that come from Salesforce to WordPress, or that sync
359 359
 			$mapped_fields = array_merge(
360 360
 				$mapped_fields,
361 361
 				$this->mappings->get_mapped_fields(
362 362
 					$mapping,
363
-					array( $this->mappings->direction_sync, $this->mappings->direction_sf_wordpress )
363
+					array($this->mappings->direction_sync, $this->mappings->direction_sf_wordpress)
364 364
 				)
365 365
 			);
366 366
 
367 367
 			// If Record Type is specified, restrict query.
368
-			$mapping_record_types = $this->mappings->get_mapped_record_types( $mapping );
368
+			$mapping_record_types = $this->mappings->get_mapped_record_types($mapping);
369 369
 
370 370
 			// If Record Type is not specified for a given mapping, ensure query is unrestricted.
371
-			if ( empty( $mapping_record_types ) ) {
371
+			if (empty($mapping_record_types)) {
372 372
 				$mapped_record_types = false;
373
-			} elseif ( is_array( $mapped_record_types ) ) {
374
-				$mapped_record_types = array_merge( $mapped_record_types, $mapping_record_types );
373
+			} elseif (is_array($mapped_record_types)) {
374
+				$mapped_record_types = array_merge($mapped_record_types, $mapping_record_types);
375 375
 			}
376 376
 		} // End foreach().
377 377
 
378 378
 		// There are no field mappings configured to pull data from Salesforce so
379 379
 		// move on to the next mapped object. Prevents querying unmapped data.
380
-		if ( empty( $mapped_fields ) ) {
380
+		if (empty($mapped_fields)) {
381 381
 			return null;
382 382
 		}
383 383
 
384
-		$soql = new Object_Sync_Sf_Salesforce_Select_Query( $type );
384
+		$soql = new Object_Sync_Sf_Salesforce_Select_Query($type);
385 385
 
386 386
 		// Convert field mappings to SOQL.
387 387
 		$soql->fields = array_merge(
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		);
394 394
 
395 395
 		// these are bit operators, so we leave out the strict
396
-		if ( in_array( $this->mappings->sync_sf_create, $salesforce_mapping['sync_triggers'] ) ) {
396
+		if (in_array($this->mappings->sync_sf_create, $salesforce_mapping['sync_triggers'])) {
397 397
 			$soql->fields['CreatedDate'] = 'CreatedDate';
398 398
 		}
399 399
 
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 		// this should be what keeps it from getting all the records, whether or not they've ever been updated
402 402
 		// we also use the option for when the plugin was installed, and don't go back further than that by default
403 403
 
404
-		$sf_activate_time = get_option( 'object_sync_for_salesforce_activate_time', '' );
405
-		$sf_last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, null );
406
-		if ( $sf_last_sync ) {
407
-			$last_sync = gmdate( 'Y-m-d\TH:i:s\Z', $sf_last_sync );
408
-			$soql->add_condition( $salesforce_mapping['pull_trigger_field'], $last_sync, '>' );
404
+		$sf_activate_time = get_option('object_sync_for_salesforce_activate_time', '');
405
+		$sf_last_sync     = get_option('object_sync_for_salesforce_pull_last_sync_' . $type, null);
406
+		if ($sf_last_sync) {
407
+			$last_sync = gmdate('Y-m-d\TH:i:s\Z', $sf_last_sync);
408
+			$soql->add_condition($salesforce_mapping['pull_trigger_field'], $last_sync, '>');
409 409
 		} else {
410
-			$activated = gmdate( 'Y-m-d\TH:i:s\Z', $sf_activate_time );
411
-			$soql->add_condition( $salesforce_mapping['pull_trigger_field'], $activated, '>' );
410
+			$activated = gmdate('Y-m-d\TH:i:s\Z', $sf_activate_time);
411
+			$soql->add_condition($salesforce_mapping['pull_trigger_field'], $activated, '>');
412 412
 			// put a hook in here to let devs go retroactive if they want, and sync data from before plugin was activated
413 413
 		}
414 414
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		// we are not incorporating that part of this branch at this time
435 435
 
436 436
 		// Load all unique SF record types that we have mappings for.
437
-		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
437
+		foreach ($this->mappings->get_fieldmaps() as $salesforce_mapping) {
438 438
 
439 439
 			$type = $salesforce_mapping['salesforce_object'];
440 440
 
@@ -446,37 +446,37 @@  discard block
 block discarded – undo
446 446
 			);
447 447
 
448 448
 			// Iterate over each field mapping to determine our query parameters.
449
-			foreach ( $mappings as $mapping ) {
449
+			foreach ($mappings as $mapping) {
450 450
 
451
-				$last_delete_sync = get_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, current_time( 'timestamp', true ) );
452
-				$now              = current_time( 'timestamp', true );
453
-				update_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, $now );
451
+				$last_delete_sync = get_option('object_sync_for_salesforce_pull_delete_last_' . $type, current_time('timestamp', true));
452
+				$now              = current_time('timestamp', true);
453
+				update_option('object_sync_for_salesforce_pull_delete_last_' . $type, $now);
454 454
 
455 455
 				// get_deleted() constraint: startDate cannot be more than 30 days ago
456 456
 				// (using an incompatible date may lead to exceptions).
457
-				$last_delete_sync = $last_delete_sync > ( current_time( 'timestamp', true ) - 2505600 ) ? $last_delete_sync : ( current_time( 'timestamp', true ) - 2505600 );
457
+				$last_delete_sync = $last_delete_sync > (current_time('timestamp', true) - 2505600) ? $last_delete_sync : (current_time('timestamp', true) - 2505600);
458 458
 
459 459
 				// get_deleted() constraint: startDate must be at least one minute greater
460 460
 				// than endDate.
461
-				$now = $now > ( $last_delete_sync + 60 ) ? $now : $now + 60;
461
+				$now = $now > ($last_delete_sync + 60) ? $now : $now + 60;
462 462
 
463 463
 				// need to be using gmdate for salesforce call
464
-				$last_delete_sync_sf = gmdate( 'Y-m-d\TH:i:s\Z', $last_delete_sync );
465
-				$now_sf              = gmdate( 'Y-m-d\TH:i:s\Z', $now );
464
+				$last_delete_sync_sf = gmdate('Y-m-d\TH:i:s\Z', $last_delete_sync);
465
+				$now_sf              = gmdate('Y-m-d\TH:i:s\Z', $now);
466 466
 
467 467
 				// salesforce call
468
-				$deleted = $sfapi->get_deleted( $type, $last_delete_sync_sf, $now_sf );
468
+				$deleted = $sfapi->get_deleted($type, $last_delete_sync_sf, $now_sf);
469 469
 
470
-				if ( empty( $deleted['data']['deletedRecords'] ) ) {
470
+				if (empty($deleted['data']['deletedRecords'])) {
471 471
 					continue;
472 472
 				}
473 473
 
474
-				foreach ( $deleted['data']['deletedRecords'] as $result ) {
474
+				foreach ($deleted['data']['deletedRecords'] as $result) {
475 475
 
476 476
 					$sf_sync_trigger = $this->mappings->sync_sf_delete;
477 477
 
478 478
 					// salesforce seriously returns Id for update requests and id for delete requests and this makes no sense but maybe one day they might change it somehow?
479
-					if ( ! isset( $result['Id'] ) && isset( $result['id'] ) ) {
479
+					if ( ! isset($result['Id']) && isset($result['id'])) {
480 480
 						$result['Id'] = $result['id'];
481 481
 					}
482 482
 					$data = array(
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 
489 489
 					// Hook to allow other plugins to prevent a pull per-mapping.
490 490
 					// Putting the pull_allowed hook here will keep the queue from storing data when it is not supposed to store it
491
-					$pull_allowed = apply_filters( 'object_sync_for_salesforce_pull_object_allowed', true, $type, $result, $sf_sync_trigger, $salesforce_mapping );
491
+					$pull_allowed = apply_filters('object_sync_for_salesforce_pull_object_allowed', true, $type, $result, $sf_sync_trigger, $salesforce_mapping);
492 492
 
493 493
 					// example to keep from pulling the Contact with id of abcdef
494 494
 					/*
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
 					}
502 502
 					*/
503 503
 
504
-					if ( false === $pull_allowed ) {
504
+					if (false === $pull_allowed) {
505 505
 						continue;
506 506
 					}
507 507
 
508
-					$this->schedule->push_to_queue( $data );
508
+					$this->schedule->push_to_queue($data);
509 509
 					$this->schedule->save()->dispatch();
510 510
 
511 511
 				}
512 512
 
513
-				update_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, current_time( 'timestamp', true ) );
513
+				update_option('object_sync_for_salesforce_pull_delete_last_' . $type, current_time('timestamp', true));
514 514
 
515 515
 			} // End foreach().
516 516
 		} // End foreach().
@@ -524,9 +524,9 @@  discard block
 block discarded – undo
524 524
 	* @param string $wordpress_object
525 525
 	*
526 526
 	*/
527
-	public function manual_pull( $object_type, $salesforce_id, $wordpress_object ) {
527
+	public function manual_pull($object_type, $salesforce_id, $wordpress_object) {
528 528
 		$sfapi   = $this->salesforce['sfapi'];
529
-		$object  = $sfapi->api_call( 'sobjects/' . $object_type . '/' . $salesforce_id );
529
+		$object  = $sfapi->api_call('sobjects/' . $object_type . '/' . $salesforce_id);
530 530
 		$mapping = $this->mappings->get_fieldmaps(
531 531
 			null,
532 532
 			array(
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				'wordpress_object'  => $wordpress_object,
535 535
 			)
536 536
 		);
537
-		$this->salesforce_pull_process_records( $object_type, $object['data'], $mapping[0], $this->mappings->sync_sf_update );
537
+		$this->salesforce_pull_process_records($object_type, $object['data'], $mapping[0], $this->mappings->sync_sf_update);
538 538
 	}
539 539
 
540 540
 	/**
@@ -552,45 +552,45 @@  discard block
 block discarded – undo
552 552
 	* @return true or exit the method
553 553
 	*
554 554
 	*/
555
-	public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) {
555
+	public function salesforce_pull_process_records($object_type, $object, $mapping, $sf_sync_trigger) {
556 556
 		$mapping_conditions = array(
557 557
 			'salesforce_object' => $object_type,
558 558
 		);
559 559
 
560
-		if ( isset( $object['RecordTypeId'] ) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type ) {
560
+		if (isset($object['RecordTypeId']) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type) {
561 561
 			// use this condition to filter the mappings, at that time
562 562
 			$mapping_conditions['salesforce_record_type'] = $object['RecordTypeId'];
563 563
 		}
564 564
 
565
-		$salesforce_mappings = $this->mappings->get_fieldmaps( null, $mapping_conditions );
565
+		$salesforce_mappings = $this->mappings->get_fieldmaps(null, $mapping_conditions);
566 566
 
567 567
 		// from drupal: if there is more than one mapping, don't throw exceptions
568
-		$hold_exceptions = count( $salesforce_mappings ) > 1;
568
+		$hold_exceptions = count($salesforce_mappings) > 1;
569 569
 		$exception       = false;
570 570
 
571
-		$seconds = $this->schedule->get_schedule_frequency_seconds( $this->schedule_name ) + 60;
571
+		$seconds = $this->schedule->get_schedule_frequency_seconds($this->schedule_name) + 60;
572 572
 
573 573
 		$transients_to_delete = array();
574 574
 
575
-		foreach ( $salesforce_mappings as $salesforce_mapping ) {
575
+		foreach ($salesforce_mappings as $salesforce_mapping) {
576 576
 
577 577
 			// this returns the row that maps the individual Salesforce row to the individual WordPress row
578
-			if ( isset( $object['Id'] ) ) {
579
-				$mapping_object = $this->mappings->load_by_salesforce( $object['Id'] );
578
+			if (isset($object['Id'])) {
579
+				$mapping_object = $this->mappings->load_by_salesforce($object['Id']);
580 580
 			} else {
581 581
 				// if we don't have a Salesforce object id, we've got no business doing stuff in WordPress
582 582
 				$status = 'error';
583
-				if ( isset( $this->logging ) ) {
583
+				if (isset($this->logging)) {
584 584
 					$logging = $this->logging;
585
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
586
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
585
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
586
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
587 587
 				}
588 588
 
589
-				$title = sprintf( esc_html__( 'Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce' ) );
589
+				$title = sprintf(esc_html__('Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce'));
590 590
 
591 591
 				$logging->setup(
592 592
 					$title,
593
-					print_r( $object, true ), // log whatever we have in the event of this error, so print the array
593
+					print_r($object, true), // log whatever we have in the event of this error, so print the array
594 594
 					$sf_sync_trigger,
595 595
 					$status
596 596
 				);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			// if it's not already connected (ie on create), the array will be empty
602 602
 
603 603
 			// hook to allow other plugins to define or alter the mapping object
604
-			$mapping_object = apply_filters( 'object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping );
604
+			$mapping_object = apply_filters('object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping);
605 605
 
606 606
 			// we already have the data from Salesforce at this point; we just need to work with it in WordPress
607 607
 			$synced_object = array(
@@ -610,58 +610,58 @@  discard block
 block discarded – undo
610 610
 				'mapping'           => $mapping,
611 611
 			);
612 612
 
613
-			$structure = $this->wordpress->get_wordpress_table_structure( $salesforce_mapping['wordpress_object'] );
613
+			$structure = $this->wordpress->get_wordpress_table_structure($salesforce_mapping['wordpress_object']);
614 614
 			$object_id = $structure['id_field'];
615 615
 
616 616
 			$op = '';
617 617
 
618 618
 			// are these objects already connected in WordPress?
619
-			if ( isset( $mapping_object['id'] ) ) {
619
+			if (isset($mapping_object['id'])) {
620 620
 				$is_new                      = false;
621 621
 				$mapping_object_id_transient = $mapping_object['id'];
622 622
 			} else {
623 623
 				// there is not a mapping object for this WordPress object id yet
624 624
 				// check for that transient with the currently pushing id
625 625
 				$is_new                      = true;
626
-				$mapping_object_id_transient = get_transient( 'salesforce_pushing_object_id' );
626
+				$mapping_object_id_transient = get_transient('salesforce_pushing_object_id');
627 627
 			}
628 628
 
629 629
 			// Drupal only does a salesforce_pull flag, but we might as well do push and pull because WordPress
630
-			$salesforce_pushing = (int) get_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
631
-			if ( 1 === $salesforce_pushing ) {
630
+			$salesforce_pushing = (int) get_transient('salesforce_pushing_' . $mapping_object_id_transient);
631
+			if (1 === $salesforce_pushing) {
632 632
 				$transients_to_delete[] = $mapping_object_id_transient;
633 633
 				continue;
634 634
 			}
635 635
 
636 636
 			// deleting mapped objects
637
-			if ( $sf_sync_trigger == $this->mappings->sync_sf_delete ) { // trigger is a bit operator
638
-				if ( isset( $mapping_object['id'] ) ) {
637
+			if ($sf_sync_trigger == $this->mappings->sync_sf_delete) { // trigger is a bit operator
638
+				if (isset($mapping_object['id'])) {
639 639
 
640
-					set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
641
-					set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
640
+					set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
641
+					set_transient('salesforce_pulling_object_id', $mapping_object['id']);
642 642
 
643 643
 					$op              = 'Delete';
644
-					$wordpress_check = $this->mappings->load_by_wordpress( $mapping_object['wordpress_object'], $mapping_object['wordpress_id'] );
645
-					if ( count( $wordpress_check ) === count( $wordpress_check, COUNT_RECURSIVE ) ) {
644
+					$wordpress_check = $this->mappings->load_by_wordpress($mapping_object['wordpress_object'], $mapping_object['wordpress_id']);
645
+					if (count($wordpress_check) === count($wordpress_check, COUNT_RECURSIVE)) {
646 646
 						try {
647
-							$result = $this->wordpress->object_delete( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'] );
648
-						} catch ( WordpressException $e ) {
647
+							$result = $this->wordpress->object_delete($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id']);
648
+						} catch (WordpressException $e) {
649 649
 							$status = 'error';
650 650
 							// create log entry for failed delete
651
-							if ( isset( $this->logging ) ) {
651
+							if (isset($this->logging)) {
652 652
 								$logging = $this->logging;
653
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
654
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
653
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
654
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
655 655
 							}
656 656
 
657 657
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
658
-							$title = sprintf( esc_html__( 'Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
659
-								esc_attr( $op ),
660
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
661
-								esc_attr( $object_id ),
662
-								esc_attr( $mapping_object['wordpress_id'] ),
663
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
664
-								esc_attr( $mapping_object['salesforce_id'] )
658
+							$title = sprintf(esc_html__('Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
659
+								esc_attr($op),
660
+								esc_attr($salesforce_mapping['wordpress_object']),
661
+								esc_attr($object_id),
662
+								esc_attr($mapping_object['wordpress_id']),
663
+								esc_attr($salesforce_mapping['salesforce_object']),
664
+								esc_attr($mapping_object['salesforce_id'])
665 665
 							);
666 666
 
667 667
 							$logging->setup(
@@ -672,38 +672,38 @@  discard block
 block discarded – undo
672 672
 								$status
673 673
 							);
674 674
 
675
-							if ( false === $hold_exceptions ) {
675
+							if (false === $hold_exceptions) {
676 676
 								throw $e;
677 677
 							}
678
-							if ( empty( $exception ) ) {
678
+							if (empty($exception)) {
679 679
 								$exception = $e;
680 680
 							} else {
681
-								$my_class  = get_class( $e );
682
-								$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
681
+								$my_class  = get_class($e);
682
+								$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
683 683
 							}
684 684
 
685 685
 							// hook for pull fail
686
-							do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
686
+							do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
687 687
 
688 688
 						} // End try().
689 689
 
690
-						if ( ! isset( $e ) ) {
690
+						if ( ! isset($e)) {
691 691
 							// create log entry for successful delete if the result had no errors
692 692
 							$status = 'success';
693
-							if ( isset( $this->logging ) ) {
693
+							if (isset($this->logging)) {
694 694
 								$logging = $this->logging;
695
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
696
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
695
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
696
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
697 697
 							}
698 698
 
699 699
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
700
-							$title = sprintf( esc_html__( 'Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
701
-								esc_attr( $op ),
702
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
703
-								esc_attr( $object_id ),
704
-								esc_attr( $mapping_object['wordpress_id'] ),
705
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
706
-								esc_attr( $mapping_object['salesforce_id'] )
700
+							$title = sprintf(esc_html__('Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
701
+								esc_attr($op),
702
+								esc_attr($salesforce_mapping['wordpress_object']),
703
+								esc_attr($object_id),
704
+								esc_attr($mapping_object['wordpress_id']),
705
+								esc_attr($salesforce_mapping['salesforce_object']),
706
+								esc_attr($mapping_object['salesforce_id'])
707 707
 							);
708 708
 
709 709
 							$logging->setup(
@@ -715,38 +715,38 @@  discard block
 block discarded – undo
715 715
 							);
716 716
 
717 717
 							// hook for pull success
718
-							do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
718
+							do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
719 719
 						}
720 720
 					} else {
721
-						$more_ids = sprintf( '<p>' . esc_html__( 'The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce' ) );
721
+						$more_ids = sprintf('<p>' . esc_html__('The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce'));
722 722
 						$i        = 0;
723
-						foreach ( $wordpress_check as $match ) {
723
+						foreach ($wordpress_check as $match) {
724 724
 							$i++;
725
-							$more_ids .= sprintf( $match['salesforce_id'] );
726
-							if ( count( $wordpress_check ) !== $i ) {
727
-								$more_ids .= sprintf( ', ' );
725
+							$more_ids .= sprintf($match['salesforce_id']);
726
+							if (count($wordpress_check) !== $i) {
727
+								$more_ids .= sprintf(', ');
728 728
 							} else {
729
-								$more_ids .= sprintf( '.</p>' );
729
+								$more_ids .= sprintf('.</p>');
730 730
 							}
731 731
 						}
732 732
 
733
-						$more_ids .= sprintf( '<p>' . esc_html__( 'The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce' ) . '</p>' );
733
+						$more_ids .= sprintf('<p>' . esc_html__('The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce') . '</p>');
734 734
 
735 735
 						$status = 'notice';
736
-						if ( isset( $this->logging ) ) {
736
+						if (isset($this->logging)) {
737 737
 							$logging = $this->logging;
738
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
739
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
738
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
739
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
740 740
 						}
741 741
 
742 742
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
743
-						$title = sprintf( esc_html__( 'Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce' ),
744
-							esc_attr( $op ),
745
-							esc_attr( $salesforce_mapping['wordpress_object'] ),
746
-							esc_attr( $object_id ),
747
-							esc_attr( $mapping_object['wordpress_id'] ),
748
-							esc_attr( $salesforce_mapping['salesforce_object'] ),
749
-							esc_attr( $mapping_object['salesforce_id'] )
743
+						$title = sprintf(esc_html__('Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce'),
744
+							esc_attr($op),
745
+							esc_attr($salesforce_mapping['wordpress_object']),
746
+							esc_attr($object_id),
747
+							esc_attr($mapping_object['wordpress_id']),
748
+							esc_attr($salesforce_mapping['salesforce_object']),
749
+							esc_attr($mapping_object['salesforce_id'])
750 750
 						);
751 751
 
752 752
 						$logging->setup(
@@ -760,27 +760,27 @@  discard block
 block discarded – undo
760 760
 
761 761
 					// delete the map row from WordPress after the WordPress row has been deleted
762 762
 					// we delete the map row even if the WordPress delete failed, because the Salesforce object is gone
763
-					$this->mappings->delete_object_map( $mapping_object['id'] );
763
+					$this->mappings->delete_object_map($mapping_object['id']);
764 764
 					// there is no map row if we end this if statement
765 765
 				} // End if().
766 766
 				return;
767 767
 			} // End if().
768 768
 
769 769
 			// map the Salesforce values to WordPress fields
770
-			$params = $this->mappings->map_params( $mapping, $object, $sf_sync_trigger, false, $is_new );
770
+			$params = $this->mappings->map_params($mapping, $object, $sf_sync_trigger, false, $is_new);
771 771
 
772 772
 			// hook to allow other plugins to modify the $params array
773 773
 			// use hook to map fields between the WordPress and Salesforce objects
774 774
 			// returns $params.
775
-			$params = apply_filters( 'object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new );
775
+			$params = apply_filters('object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new);
776 776
 
777 777
 			// if we don't get any params, there are no fields that should be sent to WordPress
778
-			if ( empty( $params ) ) {
778
+			if (empty($params)) {
779 779
 				return;
780 780
 			}
781 781
 
782 782
 			// if there is a prematch WordPress field - ie email - on the fieldmap object
783
-			if ( isset( $params['prematch'] ) && is_array( $params['prematch'] ) ) {
783
+			if (isset($params['prematch']) && is_array($params['prematch'])) {
784 784
 				$prematch_field_wordpress  = $params['prematch']['wordpress_field'];
785 785
 				$prematch_field_salesforce = $params['prematch']['salesforce_field'];
786 786
 				$prematch_value            = $params['prematch']['value'];
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
 					'method_update' => $params['prematch']['method_update'],
791 791
 					'method_read'   => $params['prematch']['method_read'],
792 792
 				);
793
-				unset( $params['prematch'] );
793
+				unset($params['prematch']);
794 794
 			}
795 795
 
796 796
 			// if there is an external key field in salesforce - ie mailchimp user id - on the fieldmap object
797
-			if ( isset( $params['key'] ) && is_array( $params['key'] ) ) {
797
+			if (isset($params['key']) && is_array($params['key'])) {
798 798
 				$key_field_wordpress  = $params['key']['wordpress_field'];
799 799
 				$key_field_salesforce = $params['key']['salesforce_field'];
800 800
 				$key_value            = $params['key']['value'];
@@ -804,20 +804,20 @@  discard block
 block discarded – undo
804 804
 					'method_update' => $params['prematch']['method_update'],
805 805
 					'method_read'   => $params['key']['method_read'],
806 806
 				);
807
-				unset( $params['key'] );
807
+				unset($params['key']);
808 808
 			}
809 809
 
810 810
 			// methods to run the wp create or update operations
811 811
 
812
-			if ( true === $is_new ) {
812
+			if (true === $is_new) {
813 813
 
814 814
 				// setup SF record type. CampaignMember objects get their Campaign's type
815 815
 				// i am still a bit confused about this
816 816
 				// we should store this as a meta field on each object, if it meets these criteria
817 817
 				// we need to store the read/modify attributes because the field doesn't exist in the mapping
818
-				if ( $salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty( $params['RecordTypeId'] ) && ( 'CampaignMember' !== $salesforce_mapping['salesforce_object'] ) ) {
818
+				if ($salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty($params['RecordTypeId']) && ('CampaignMember' !== $salesforce_mapping['salesforce_object'])) {
819 819
 					$type = $salesforce_mapping['wordpress_object'];
820
-					if ( 'category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object'] ) {
820
+					if ('category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object']) {
821 821
 						$type = 'term';
822 822
 					}
823 823
 					$params['RecordTypeId'] = array(
@@ -835,28 +835,28 @@  discard block
 block discarded – undo
835 835
 					// returns a $salesforce_id.
836 836
 					// it should keep NULL if there is no match
837 837
 					// the function that calls this hook needs to check the mapping to make sure the WordPress object is the right type
838
-					$wordpress_id = apply_filters( 'object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull' );
838
+					$wordpress_id = apply_filters('object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull');
839 839
 
840 840
 					// hook to allow other plugins to do something right before WordPress data is saved
841 841
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
842
-					do_action( 'object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params );
842
+					do_action('object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params);
843 843
 
844
-					if ( isset( $prematch_field_salesforce ) || isset( $key_field_salesforce ) || null !== $wordpress_id ) {
844
+					if (isset($prematch_field_salesforce) || isset($key_field_salesforce) || null !== $wordpress_id) {
845 845
 
846 846
 						$op = 'Upsert';
847 847
 
848 848
 						// if either prematch criteria exists, make the values queryable
849
-						if ( isset( $prematch_field_salesforce ) ) {
849
+						if (isset($prematch_field_salesforce)) {
850 850
 							$upsert_key     = $prematch_field_wordpress;
851 851
 							$upsert_value   = $prematch_value;
852 852
 							$upsert_methods = $prematch_methods;
853
-						} elseif ( isset( $key_field_salesforce ) ) {
853
+						} elseif (isset($key_field_salesforce)) {
854 854
 							$upsert_key     = $key_field_wordpress;
855 855
 							$upsert_value   = $key_value;
856 856
 							$upsert_methods = $key_methods;
857 857
 						}
858 858
 
859
-						if ( null !== $wordpress_id ) {
859
+						if (null !== $wordpress_id) {
860 860
 							$upsert_key     = $object_id;
861 861
 							$upsert_value   = $wordpress_id;
862 862
 							$upsert_methods = array();
@@ -865,13 +865,13 @@  discard block
 block discarded – undo
865 865
 						// with the flag at the end, upsert returns a $wordpress_id only
866 866
 						// we can then check to see if it has a mapping object
867 867
 						// we should only do this if the above hook didn't already set the $wordpress_id
868
-						if ( null === $wordpress_id ) {
869
-							$wordpress_id = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true );
868
+						if (null === $wordpress_id) {
869
+							$wordpress_id = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true);
870 870
 						}
871 871
 
872 872
 						// find out if there is a mapping object for this WordPress object already
873 873
 						// don't do it if the WordPress id is 0.
874
-						if ( 0 !== $wordpress_id ) {
874
+						if (0 !== $wordpress_id) {
875 875
 							$mapping_object = $this->mappings->get_object_maps(
876 876
 								array(
877 877
 									'wordpress_id'     => $wordpress_id,
@@ -886,35 +886,35 @@  discard block
 block discarded – undo
886 886
 								)
887 887
 							);
888 888
 
889
-							if ( array() !== $mapping_object_debug ) {
889
+							if (array() !== $mapping_object_debug) {
890 890
 								// create log entry to warn about at least one id of 0
891 891
 								$status = 'error';
892
-								$title  = sprintf( esc_html__( 'Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce' ) );
892
+								$title  = sprintf(esc_html__('Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce'));
893 893
 
894
-								if ( 1 === count( $mapping_object_debug ) ) {
894
+								if (1 === count($mapping_object_debug)) {
895 895
 									// translators: placeholders are: 1) the mapping object row ID, 2) the name of the WordPress object, 3) the ID of the Salesforce object it was trying to map
896
-									$body = sprintf( esc_html__( 'There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce' ),
897
-										absint( $mapping_object_debug['id'] ),
898
-										esc_attr( $salesforce_mapping['wordpress_object'] ),
899
-										esc_attr( $mapping_object_debug['salesforce_id'] )
896
+									$body = sprintf(esc_html__('There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce'),
897
+										absint($mapping_object_debug['id']),
898
+										esc_attr($salesforce_mapping['wordpress_object']),
899
+										esc_attr($mapping_object_debug['salesforce_id'])
900 900
 									);
901 901
 								} else {
902
-									$body = sprintf( esc_html__( 'There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce' ) . '<ul>' );
903
-									foreach ( $mapping_object_debug as $mapping_object ) {
902
+									$body = sprintf(esc_html__('There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce') . '<ul>');
903
+									foreach ($mapping_object_debug as $mapping_object) {
904 904
 										// translators: placeholders are: 1) the mapping object row ID, 2) the ID of the Salesforce object, 3) the WordPress object type
905
-										$body .= sprintf( '<li>' . esc_html__( 'Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
906
-											absint( $mapping_object['id'] ),
907
-											esc_attr( $mapping_object['salesforce_id'] ),
908
-											esc_attr( $salesforce_mapping['wordpress_object'] )
905
+										$body .= sprintf('<li>' . esc_html__('Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce') . '</li>',
906
+											absint($mapping_object['id']),
907
+											esc_attr($mapping_object['salesforce_id']),
908
+											esc_attr($salesforce_mapping['wordpress_object'])
909 909
 										);
910 910
 									}
911
-									$body .= sprintf( '</ul>' );
911
+									$body .= sprintf('</ul>');
912 912
 								}
913 913
 
914
-								if ( isset( $this->logging ) ) {
914
+								if (isset($this->logging)) {
915 915
 									$logging = $this->logging;
916
-								} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
917
-									$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
916
+								} elseif (class_exists('Object_Sync_Sf_Logging')) {
917
+									$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
918 918
 								}
919 919
 								$parent = 0;
920 920
 								$logging->setup(
@@ -928,37 +928,37 @@  discard block
 block discarded – undo
928 928
 						} // End if().
929 929
 
930 930
 						// there is already a mapping object. don't change the WordPress data to match this new Salesforce record, but log it
931
-						if ( isset( $mapping_object['id'] ) ) {
931
+						if (isset($mapping_object['id'])) {
932 932
 							// set the transient so that salesforce_push doesn't start doing stuff, then return out of here
933
-							set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
934
-							set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
933
+							set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
934
+							set_transient('salesforce_pulling_object_id', $mapping_object['id']);
935 935
 							// create log entry to indicate that nothing happened
936 936
 							$status = 'notice';
937 937
 							// translators: placeholders are: 1) mapping object row id, 2) WordPress object tyoe, 3) individual WordPress item ID, 4) individual Salesforce item ID
938
-							$title = sprintf( esc_html__( 'Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce' ),
939
-								absint( $mapping_object['id'] ),
940
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
941
-								absint( $wordpress_id ),
942
-								esc_attr( $object['Id'] )
938
+							$title = sprintf(esc_html__('Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce'),
939
+								absint($mapping_object['id']),
940
+								esc_attr($salesforce_mapping['wordpress_object']),
941
+								absint($wordpress_id),
942
+								esc_attr($object['Id'])
943 943
 							);
944 944
 
945 945
 							// translators: placeholders are 1) WordPress object type, 2) field name for the WordPress id, 3) the WordPress id value, 4) the Salesforce object type, 5) the Salesforce object Id that was modified, 6) the mapping object row id
946
-							$body = sprintf( esc_html__( 'The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce' ),
947
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
948
-								esc_attr( $structure['id_field'] ),
949
-								absint( $wordpress_id ),
950
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
951
-								esc_attr( $object['Id'] ),
952
-								absint( $mapping_object['id'] )
946
+							$body = sprintf(esc_html__('The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce'),
947
+								esc_attr($salesforce_mapping['wordpress_object']),
948
+								esc_attr($structure['id_field']),
949
+								absint($wordpress_id),
950
+								esc_attr($salesforce_mapping['salesforce_object']),
951
+								esc_attr($object['Id']),
952
+								absint($mapping_object['id'])
953 953
 							);
954 954
 
955
-							if ( isset( $this->logging ) ) {
955
+							if (isset($this->logging)) {
956 956
 								$logging = $this->logging;
957
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
958
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
957
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
958
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
959 959
 							}
960 960
 							// if we know the WordPress object id we can put it in there
961
-							if ( null !== $wordpress_id ) {
961
+							if (null !== $wordpress_id) {
962 962
 								$parent = $wordpress_id;
963 963
 							} else {
964 964
 								$parent = 0;
@@ -977,9 +977,9 @@  discard block
 block discarded – undo
977 977
 						// right here we should set the pulling transient
978 978
 						// this means we have to create the mapping object here as well, and update it with the correct IDs after successful response
979 979
 						// create the mapping object between the rows
980
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
981
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
982
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
980
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
981
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
982
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
983 983
 						$mapping_object = $this->mappings->get_object_maps(
984 984
 							array(
985 985
 								'id' => $mapping_object_id,
@@ -988,50 +988,50 @@  discard block
 block discarded – undo
988 988
 
989 989
 						// now we can upsert the object in wp if we've gotten to this point
990 990
 						// this command will either create or update the object
991
-						$result = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'] );
991
+						$result = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts']);
992 992
 
993 993
 					} else {
994 994
 						// No key or prematch field exists on this field map object, create a new object in WordPress.
995 995
 						$op                = 'Create';
996
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
997
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
998
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
996
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
997
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
998
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
999 999
 						$mapping_object = $this->mappings->get_object_maps(
1000 1000
 							array(
1001 1001
 								'id' => $mapping_object_id,
1002 1002
 							)
1003 1003
 						);
1004 1004
 
1005
-						$result = $this->wordpress->object_create( $salesforce_mapping['wordpress_object'], $params );
1005
+						$result = $this->wordpress->object_create($salesforce_mapping['wordpress_object'], $params);
1006 1006
 					} // End if().
1007
-				} catch ( WordpressException $e ) {
1007
+				} catch (WordpressException $e) {
1008 1008
 					// create log entry for failed create or upsert
1009 1009
 					$status = 'error';
1010 1010
 
1011 1011
 					// translators: placeholders are: 1) what operation is happening, and 2) the name of the WordPress object
1012
-					$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
1013
-						esc_attr( $op ),
1014
-						esc_attr( $salesforce_mapping['wordpress_object'] )
1012
+					$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
1013
+						esc_attr($op),
1014
+						esc_attr($salesforce_mapping['wordpress_object'])
1015 1015
 					);
1016 1016
 
1017
-					if ( null !== $salesforce_id ) {
1017
+					if (null !== $salesforce_id) {
1018 1018
 						$title .= ' ' . $salesforce_id;
1019 1019
 					}
1020 1020
 
1021 1021
 					// translators: placeholders are: 1) the name of the Salesforce object, and 2) Id of the Salesforce object
1022
-					$title .= sprintf( esc_html__( ' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce' ),
1022
+					$title .= sprintf(esc_html__(' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce'),
1023 1023
 						$salesforce_mapping['salesforce_object'],
1024 1024
 						$object['Id']
1025 1025
 					);
1026 1026
 
1027
-					if ( isset( $this->logging ) ) {
1027
+					if (isset($this->logging)) {
1028 1028
 						$logging = $this->logging;
1029
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1030
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1029
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1030
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1031 1031
 					}
1032 1032
 
1033 1033
 					// if we know the WordPress object id we can put it in there
1034
-					if ( null !== $wordpress_id ) {
1034
+					if (null !== $wordpress_id) {
1035 1035
 						$parent = $wordpress_id;
1036 1036
 					} else {
1037 1037
 						$parent = 0;
@@ -1045,26 +1045,26 @@  discard block
 block discarded – undo
1045 1045
 						$status
1046 1046
 					);
1047 1047
 
1048
-					if ( false === $hold_exceptions ) {
1048
+					if (false === $hold_exceptions) {
1049 1049
 						throw $e;
1050 1050
 					}
1051
-					if ( empty( $exception ) ) {
1051
+					if (empty($exception)) {
1052 1052
 						$exception = $e;
1053 1053
 					} else {
1054
-						$my_class  = get_class( $e );
1055
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1054
+						$my_class  = get_class($e);
1055
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1056 1056
 					}
1057 1057
 
1058 1058
 					// hook for pull fail
1059
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1059
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1060 1060
 
1061 1061
 					return;
1062 1062
 				} // End try().
1063 1063
 
1064 1064
 				// set $wordpress_data to the query result
1065 1065
 				$wordpress_data = $result['data'];
1066
-				if ( isset( $wordpress_data[ "$object_id" ] ) ) {
1067
-					$wordpress_id = $wordpress_data[ "$object_id" ];
1066
+				if (isset($wordpress_data["$object_id"])) {
1067
+					$wordpress_id = $wordpress_data["$object_id"];
1068 1068
 				} else {
1069 1069
 					$wordpress_id = 0;
1070 1070
 				}
@@ -1073,23 +1073,23 @@  discard block
 block discarded – undo
1073 1073
 				// this means the object has already been created/updated in WordPress
1074 1074
 				// this is not redundant because this is where it creates the object mapping rows in WordPress if the object does not already have one (we are still inside $is_new === TRUE here)
1075 1075
 
1076
-				if ( empty( $result['errors'] ) ) {
1076
+				if (empty($result['errors'])) {
1077 1077
 					$status = 'success';
1078 1078
 
1079
-					if ( isset( $this->logging ) ) {
1079
+					if (isset($this->logging)) {
1080 1080
 						$logging = $this->logging;
1081
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1082
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1081
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1082
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1083 1083
 					}
1084 1084
 
1085 1085
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1086
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1087
-						esc_attr( $op ),
1088
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1089
-						esc_attr( $object_id ),
1090
-						esc_attr( $wordpress_id ),
1091
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1092
-						esc_attr( $object['Id'] )
1086
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1087
+						esc_attr($op),
1088
+						esc_attr($salesforce_mapping['wordpress_object']),
1089
+						esc_attr($object_id),
1090
+						esc_attr($wordpress_id),
1091
+						esc_attr($salesforce_mapping['salesforce_object']),
1092
+						esc_attr($object['Id'])
1093 1093
 					);
1094 1094
 
1095 1095
 					$logging->setup(
@@ -1102,40 +1102,40 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
 					// update that mapping object
1104 1104
 					$mapping_object['wordpress_id'] = $wordpress_id;
1105
-					$mapping_object                 = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1105
+					$mapping_object                 = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1106 1106
 
1107 1107
 					// hook for pull success
1108
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1108
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1109 1109
 				} else {
1110 1110
 
1111 1111
 					// create log entry for failed create or upsert
1112 1112
 					// this is part of the drupal module but i am failing to understand when it would ever fire, since the catch should catch the errors
1113 1113
 					// if we see this in the log entries, we can understand what it does, but probably not until then
1114 1114
 					$status = 'error';
1115
-					if ( isset( $this->logging ) ) {
1115
+					if (isset($this->logging)) {
1116 1116
 						$logging = $this->logging;
1117
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1118
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1117
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1118
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1119 1119
 					}
1120 1120
 
1121
-					if ( is_object( $wordpress_id ) ) {
1121
+					if (is_object($wordpress_id)) {
1122 1122
 						// print this array because if this happens, something weird has happened and we want to log whatever we have
1123
-						$wordpress_id = print_r( $wordpress_id, true );
1123
+						$wordpress_id = print_r($wordpress_id, true);
1124 1124
 					}
1125 1125
 
1126 1126
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object type, 3) the Salesforce object Id value
1127
-					$title = sprintf( esc_html__( 'Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce' ),
1128
-						esc_attr( $op ),
1129
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1130
-						esc_attr( $object['Id'] )
1127
+					$title = sprintf(esc_html__('Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce'),
1128
+						esc_attr($op),
1129
+						esc_attr($salesforce_mapping['salesforce_object']),
1130
+						esc_attr($object['Id'])
1131 1131
 					);
1132 1132
 
1133 1133
 					// translators: placeholders are: 1) the name of the WordPress object type, 2) the WordPress id field name, 3) the WordPress id field value, 4) the array of errors
1134
-					$body = sprintf( '<p>' . esc_html__( 'Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: ', 'object-sync-for-salesforce' ) . '%4$s',
1135
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1136
-						esc_attr( $object_id ),
1137
-						esc_attr( $wordpress_id ),
1138
-						print_r( $result['errors'], true ) // if we get this error, we need to know whatever we have
1134
+					$body = sprintf('<p>' . esc_html__('Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: ', 'object-sync-for-salesforce') . '%4$s',
1135
+						esc_attr($salesforce_mapping['wordpress_object']),
1136
+						esc_attr($object_id),
1137
+						esc_attr($wordpress_id),
1138
+						print_r($result['errors'], true) // if we get this error, we need to know whatever we have
1139 1139
 					);
1140 1140
 
1141 1141
 					$logging->setup(
@@ -1147,52 +1147,52 @@  discard block
 block discarded – undo
1147 1147
 					);
1148 1148
 
1149 1149
 					// hook for pull fail
1150
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1150
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1151 1151
 
1152 1152
 					return;
1153 1153
 				} // End if().
1154
-			} elseif ( false === $is_new ) {
1154
+			} elseif (false === $is_new) {
1155 1155
 
1156 1156
 				// right here we should set the pulling transient
1157
-				set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
1158
-				set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
1157
+				set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
1158
+				set_transient('salesforce_pulling_object_id', $mapping_object['id']);
1159 1159
 
1160 1160
 				// there is an existing object link
1161 1161
 				// if the last sync is greater than the last time this object was updated by Salesforce, skip it
1162 1162
 				// this keeps us from doing redundant syncs
1163 1163
 				// because SF stores all DateTimes in UTC.
1164
-				$mapping_object['object_updated'] = current_time( 'mysql' );
1164
+				$mapping_object['object_updated'] = current_time('mysql');
1165 1165
 
1166 1166
 				$pull_trigger_field = $salesforce_mapping['pull_trigger_field'];
1167
-				$pull_trigger_value = $object[ $pull_trigger_field ];
1167
+				$pull_trigger_value = $object[$pull_trigger_field];
1168 1168
 
1169 1169
 				try {
1170 1170
 
1171 1171
 					// hook to allow other plugins to do something right before WordPress data is saved
1172 1172
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
1173
-					do_action( 'object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params );
1173
+					do_action('object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params);
1174 1174
 
1175 1175
 					$op     = 'Update';
1176
-					$result = $this->wordpress->object_update( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params );
1176
+					$result = $this->wordpress->object_update($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params);
1177 1177
 
1178 1178
 					$mapping_object['last_sync_status']  = $this->mappings->status_success;
1179
-					$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
1179
+					$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
1180 1180
 
1181 1181
 					$status = 'success';
1182
-					if ( isset( $this->logging ) ) {
1182
+					if (isset($this->logging)) {
1183 1183
 						$logging = $this->logging;
1184
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1185
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1184
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1185
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1186 1186
 					}
1187 1187
 
1188 1188
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1189
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1190
-						esc_attr( $op ),
1191
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1192
-						esc_attr( $object_id ),
1193
-						esc_attr( $mapping_object['wordpress_id'] ),
1194
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1195
-						esc_attr( $object['Id'] )
1189
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1190
+						esc_attr($op),
1191
+						esc_attr($salesforce_mapping['wordpress_object']),
1192
+						esc_attr($object_id),
1193
+						esc_attr($mapping_object['wordpress_id']),
1194
+						esc_attr($salesforce_mapping['salesforce_object']),
1195
+						esc_attr($object['Id'])
1196 1196
 					);
1197 1197
 
1198 1198
 					$logging->setup(
@@ -1204,25 +1204,25 @@  discard block
 block discarded – undo
1204 1204
 					);
1205 1205
 
1206 1206
 					// hook for pull success
1207
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1207
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1208 1208
 
1209
-				} catch ( WordpressException $e ) {
1209
+				} catch (WordpressException $e) {
1210 1210
 					// create log entry for failed update
1211 1211
 					$status = 'error';
1212
-					if ( isset( $this->logging ) ) {
1212
+					if (isset($this->logging)) {
1213 1213
 						$logging = $this->logging;
1214
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1215
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1214
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1215
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1216 1216
 					}
1217 1217
 
1218 1218
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1219
-					$title .= sprintf( esc_html__( 'Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce' ),
1220
-						esc_attr( $op ),
1221
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1222
-						esc_attr( $object_id ),
1223
-						esc_attr( $mapping_object['wordpress_id'] ),
1224
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1225
-						esc_attr( $object['Id'] )
1219
+					$title .= sprintf(esc_html__('Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce'),
1220
+						esc_attr($op),
1221
+						esc_attr($salesforce_mapping['wordpress_object']),
1222
+						esc_attr($object_id),
1223
+						esc_attr($mapping_object['wordpress_id']),
1224
+						esc_attr($salesforce_mapping['salesforce_object']),
1225
+						esc_attr($object['Id'])
1226 1226
 					);
1227 1227
 
1228 1228
 					$logging->setup(
@@ -1236,18 +1236,18 @@  discard block
 block discarded – undo
1236 1236
 					$mapping_object['last_sync_status']  = $this->mappings->status_error;
1237 1237
 					$mapping_object['last_sync_message'] = $e->getMessage();
1238 1238
 
1239
-					if ( false === $hold_exceptions ) {
1239
+					if (false === $hold_exceptions) {
1240 1240
 						throw $e;
1241 1241
 					}
1242
-					if ( empty( $exception ) ) {
1242
+					if (empty($exception)) {
1243 1243
 						$exception = $e;
1244 1244
 					} else {
1245
-						$my_class  = get_class( $e );
1246
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1245
+						$my_class  = get_class($e);
1246
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1247 1247
 					}
1248 1248
 
1249 1249
 					// hook for pull fail
1250
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1250
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1251 1251
 
1252 1252
 				} // End try().
1253 1253
 
@@ -1256,26 +1256,26 @@  discard block
 block discarded – undo
1256 1256
 				// maybe can check to see if we actually updated anything in WordPress
1257 1257
 				// tell the mapping object - whether it is new or already existed - how we just used it
1258 1258
 				$mapping_object['last_sync_action'] = 'pull';
1259
-				$mapping_object['last_sync']        = current_time( 'mysql' );
1259
+				$mapping_object['last_sync']        = current_time('mysql');
1260 1260
 
1261 1261
 				// update that mapping object. the Salesforce data version will be set here as well because we set it earlier
1262
-				$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1262
+				$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1263 1263
 				// end of the if statement for is_new & update or create trigger
1264 1264
 				// this keeps stuff from running too many times, and also keeps it from using the wrong methods. we don't need a generic } else { here at this time.
1265 1265
 			} // End if().
1266 1266
 		} // End foreach().
1267 1267
 
1268 1268
 		// delete transients that we've already processed
1269
-		foreach ( $transients_to_delete as $mapping_object_id_transient ) {
1270
-			delete_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
1269
+		foreach ($transients_to_delete as $mapping_object_id_transient) {
1270
+			delete_transient('salesforce_pushing_' . $mapping_object_id_transient);
1271 1271
 		}
1272 1272
 
1273
-		$pushing_id = get_transient( 'salesforce_pushing_object_id' );
1274
-		if ( in_array( $pushing_id, $transients_to_delete, true ) ) {
1275
-			delete_transient( 'salesforce_pushing_object_id' );
1273
+		$pushing_id = get_transient('salesforce_pushing_object_id');
1274
+		if (in_array($pushing_id, $transients_to_delete, true)) {
1275
+			delete_transient('salesforce_pushing_object_id');
1276 1276
 		}
1277 1277
 
1278
-		if ( ! empty( $exception ) ) {
1278
+		if ( ! empty($exception)) {
1279 1279
 			throw $exception;
1280 1280
 		}
1281 1281
 
@@ -1295,17 +1295,17 @@  discard block
 block discarded – undo
1295 1295
 	*   This is the database row for the map object
1296 1296
 	*
1297 1297
 	*/
1298
-	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1298
+	private function create_object_map($salesforce_object, $wordpress_id, $field_mapping) {
1299 1299
 		// Create object map and save it
1300 1300
 		$mapping_object = $this->mappings->create_object_map(
1301 1301
 			array(
1302 1302
 				'wordpress_id'      => $wordpress_id, // wordpress unique id
1303 1303
 				'salesforce_id'     => $salesforce_object['Id'], // salesforce unique id. we don't care what kind of object it is at this point
1304 1304
 				'wordpress_object'  => $field_mapping['wordpress_object'], // keep track of what kind of wp object this is
1305
-				'last_sync'         => current_time( 'mysql' ),
1305
+				'last_sync'         => current_time('mysql'),
1306 1306
 				'last_sync_action'  => 'pull',
1307 1307
 				'last_sync_status'  => $this->mappings->status_success,
1308
-				'last_sync_message' => esc_html__( 'Mapping object created via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1308
+				'last_sync_message' => esc_html__('Mapping object created via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1309 1309
 				'action'            => 'created',
1310 1310
 			)
1311 1311
 		);
Please login to merge, or discard this patch.
classes/admin.php 2 patches
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -26,62 +26,62 @@  discard block
 block discarded – undo
26 26
 	protected $schedulable_classes;
27 27
 
28 28
 	/**
29
-	* @var string
30
-	* Default path for the Salesforce authorize URL
31
-	*/
29
+	 * @var string
30
+	 * Default path for the Salesforce authorize URL
31
+	 */
32 32
 	public $default_authorize_url_path;
33 33
 
34 34
 	/**
35
-	* @var string
36
-	* Default path for the Salesforce token URL
37
-	*/
35
+	 * @var string
36
+	 * Default path for the Salesforce token URL
37
+	 */
38 38
 	public $default_token_url_path;
39 39
 
40 40
 	/**
41
-	* @var string
42
-	* What version of the Salesforce API should be the default on the settings screen.
43
-	* Users can edit this, but they won't see a correct list of all their available versions until WordPress has
44
-	* been authenticated with Salesforce.
45
-	*/
41
+	 * @var string
42
+	 * What version of the Salesforce API should be the default on the settings screen.
43
+	 * Users can edit this, but they won't see a correct list of all their available versions until WordPress has
44
+	 * been authenticated with Salesforce.
45
+	 */
46 46
 	public $default_api_version;
47 47
 
48 48
 	/**
49
-	* @var bool
50
-	* Default for whether to limit to triggerable items
51
-	* Users can edit this
52
-	*/
49
+	 * @var bool
50
+	 * Default for whether to limit to triggerable items
51
+	 * Users can edit this
52
+	 */
53 53
 	public $default_triggerable;
54 54
 
55 55
 	/**
56
-	* @var bool
57
-	* Default for whether to limit to updateable items
58
-	* Users can edit this
59
-	*/
56
+	 * @var bool
57
+	 * Default for whether to limit to updateable items
58
+	 * Users can edit this
59
+	 */
60 60
 	public $default_updateable;
61 61
 
62 62
 	/**
63
-	* @var int
64
-	* Default pull throttle for how often Salesforce can pull
65
-	* Users can edit this
66
-	*/
63
+	 * @var int
64
+	 * Default pull throttle for how often Salesforce can pull
65
+	 * Users can edit this
66
+	 */
67 67
 	public $default_pull_throttle;
68 68
 
69 69
 	/**
70
-	* Constructor which sets up admin pages
71
-	*
72
-	* @param object $wpdb
73
-	* @param string $version
74
-	* @param array $login_credentials
75
-	* @param string $slug
76
-	* @param object $wordpress
77
-	* @param object $salesforce
78
-	* @param object $mappings
79
-	* @param object $push
80
-	* @param object $pull
81
-	* @param object $logging
82
-	* @param array $schedulable_classes
83
-	* @throws \Exception
84
-	*/
70
+	 * Constructor which sets up admin pages
71
+	 *
72
+	 * @param object $wpdb
73
+	 * @param string $version
74
+	 * @param array $login_credentials
75
+	 * @param string $slug
76
+	 * @param object $wordpress
77
+	 * @param object $salesforce
78
+	 * @param object $mappings
79
+	 * @param object $push
80
+	 * @param object $pull
81
+	 * @param object $logging
82
+	 * @param array $schedulable_classes
83
+	 * @throws \Exception
84
+	 */
85 85
 	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes ) {
86 86
 		$this->wpdb                = $wpdb;
87 87
 		$this->version             = $version;
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	}
118 118
 
119 119
 	/**
120
-	* Create the action hooks to create the admin page(s)
121
-	*
122
-	*/
120
+	 * Create the action hooks to create the admin page(s)
121
+	 *
122
+	 */
123 123
 	public function add_actions() {
124 124
 		add_action( 'admin_init', array( $this, 'salesforce_settings_forms' ) );
125 125
 		add_action( 'admin_init', array( $this, 'notices' ) );
@@ -148,21 +148,21 @@  discard block
 block discarded – undo
148 148
 	}
149 149
 
150 150
 	/**
151
-	* Create WordPress admin options page
152
-	*
153
-	*/
151
+	 * Create WordPress admin options page
152
+	 *
153
+	 */
154 154
 	public function create_admin_menu() {
155 155
 		$title = __( 'Salesforce', 'object-sync-for-salesforce' );
156 156
 		add_options_page( $title, $title, 'configure_salesforce', 'object-sync-salesforce-admin', array( $this, 'show_admin_page' ) );
157 157
 	}
158 158
 
159 159
 	/**
160
-	* Render full admin pages in WordPress
161
-	* This allows other plugins to add tabs to the Salesforce settings screen
162
-	*
163
-	* todo: better front end: html, organization of html into templates, css, js
164
-	*
165
-	*/
160
+	 * Render full admin pages in WordPress
161
+	 * This allows other plugins to add tabs to the Salesforce settings screen
162
+	 *
163
+	 * todo: better front end: html, organization of html into templates, css, js
164
+	 *
165
+	 */
166 166
 	public function show_admin_page() {
167 167
 		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
168 168
 		echo '<div class="wrap">';
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	}
373 373
 
374 374
 	/**
375
-	* Create default WordPress admin settings form for salesforce
376
-	* This is for the Settings page/tab
377
-	*
378
-	*/
375
+	 * Create default WordPress admin settings form for salesforce
376
+	 * This is for the Settings page/tab
377
+	 *
378
+	 */
379 379
 	public function salesforce_settings_forms() {
380 380
 		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
381 381
 		$page     = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 
402 402
 	/**
403
-	* Fields for the Settings tab
404
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
405
-	*
406
-	* @param string $page
407
-	* @param string $section
408
-	* @param string $input_callback
409
-	*/
403
+	 * Fields for the Settings tab
404
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
405
+	 *
406
+	 * @param string $page
407
+	 * @param string $section
408
+	 * @param string $input_callback
409
+	 */
410 410
 	private function fields_settings( $page, $section, $callbacks ) {
411 411
 		add_settings_section( $page, ucwords( $page ), null, $page );
412 412
 		$salesforce_settings = array(
@@ -611,25 +611,25 @@  discard block
 block discarded – undo
611 611
 	}
612 612
 
613 613
 	/**
614
-	* Fields for the Fieldmaps tab
615
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
616
-	*
617
-	* @param string $page
618
-	* @param string $section
619
-	* @param string $input_callback
620
-	*/
614
+	 * Fields for the Fieldmaps tab
615
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
616
+	 *
617
+	 * @param string $page
618
+	 * @param string $section
619
+	 * @param string $input_callback
620
+	 */
621 621
 	private function fields_fieldmaps( $page, $section, $input_callback = '' ) {
622 622
 		add_settings_section( $page, ucwords( $page ), null, $page );
623 623
 	}
624 624
 
625 625
 	/**
626
-	* Fields for the Scheduling tab
627
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
628
-	*
629
-	* @param string $page
630
-	* @param string $section
631
-	* @param string $input_callback
632
-	*/
626
+	 * Fields for the Scheduling tab
627
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
628
+	 *
629
+	 * @param string $page
630
+	 * @param string $section
631
+	 * @param string $input_callback
632
+	 */
633 633
 	private function fields_scheduling( $page, $section, $callbacks ) {
634 634
 		foreach ( $this->schedulable_classes as $key => $value ) {
635 635
 			add_settings_section( $key, $value['label'], null, $page );
@@ -708,13 +708,13 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 
710 710
 	/**
711
-	* Fields for the Log Settings tab
712
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
713
-	*
714
-	* @param string $page
715
-	* @param string $section
716
-	* @param array $callbacks
717
-	*/
711
+	 * Fields for the Log Settings tab
712
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
713
+	 *
714
+	 * @param string $page
715
+	 * @param string $section
716
+	 * @param array $callbacks
717
+	 */
718 718
 	private function fields_log_settings( $page, $section, $callbacks ) {
719 719
 		add_settings_section( $page, ucwords( str_replace( '_', ' ', $page ) ), null, $page );
720 720
 		$log_settings = array(
@@ -892,9 +892,9 @@  discard block
 block discarded – undo
892 892
 	}
893 893
 
894 894
 	/**
895
-	* Create the notices, settings, and conditions by which admin notices should appear
896
-	*
897
-	*/
895
+	 * Create the notices, settings, and conditions by which admin notices should appear
896
+	 *
897
+	 */
898 898
 	public function notices() {
899 899
 
900 900
 		// before a notice is displayed, we should make sure we are on a page related to this plugin
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
 	}
968 968
 
969 969
 	/**
970
-	* Get all the Salesforce object settings for fieldmapping
971
-	* This takes either the $_POST array via ajax, or can be directly called with a $data array
972
-	*
973
-	* @param array $data
974
-	* data must contain a salesforce_object
975
-	* can optionally contain a type
976
-	* @return array $object_settings
977
-	*/
970
+	 * Get all the Salesforce object settings for fieldmapping
971
+	 * This takes either the $_POST array via ajax, or can be directly called with a $data array
972
+	 *
973
+	 * @param array $data
974
+	 * data must contain a salesforce_object
975
+	 * can optionally contain a type
976
+	 * @return array $object_settings
977
+	 */
978 978
 	public function get_salesforce_object_description( $data = array() ) {
979 979
 		$ajax = false;
980 980
 		if ( empty( $data ) ) {
@@ -1022,13 +1022,13 @@  discard block
 block discarded – undo
1022 1022
 	}
1023 1023
 
1024 1024
 	/**
1025
-	* Get Salesforce object fields for fieldmapping
1026
-	*
1027
-	* @param array $data
1028
-	* data must contain a salesforce_object
1029
-	* can optionally contain a type for the field
1030
-	* @return array $object_fields
1031
-	*/
1025
+	 * Get Salesforce object fields for fieldmapping
1026
+	 *
1027
+	 * @param array $data
1028
+	 * data must contain a salesforce_object
1029
+	 * can optionally contain a type for the field
1030
+	 * @return array $object_fields
1031
+	 */
1032 1032
 	public function get_salesforce_object_fields( $data = array() ) {
1033 1033
 
1034 1034
 		if ( ! empty( $data['salesforce_object'] ) ) {
@@ -1056,12 +1056,12 @@  discard block
 block discarded – undo
1056 1056
 	}
1057 1057
 
1058 1058
 	/**
1059
-	* Get WordPress object fields for fieldmapping
1060
-	* This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field
1061
-	*
1062
-	* @param string $wordpress_object
1063
-	* @return array $object_fields
1064
-	*/
1059
+	 * Get WordPress object fields for fieldmapping
1060
+	 * This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field
1061
+	 *
1062
+	 * @param string $wordpress_object
1063
+	 * @return array $object_fields
1064
+	 */
1065 1065
 	public function get_wordpress_object_fields( $wordpress_object = '' ) {
1066 1066
 		$ajax      = false;
1067 1067
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
@@ -1080,13 +1080,13 @@  discard block
 block discarded – undo
1080 1080
 	}
1081 1081
 
1082 1082
 	/**
1083
-	* Get WordPress and Salesforce object fields together for fieldmapping
1084
-	* This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $salesforce_object fields
1085
-	*
1086
-	* @param string $wordpress_object
1087
-	* @param string $salesforce_object
1088
-	* @return array $object_fields
1089
-	*/
1083
+	 * Get WordPress and Salesforce object fields together for fieldmapping
1084
+	 * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $salesforce_object fields
1085
+	 *
1086
+	 * @param string $wordpress_object
1087
+	 * @param string $salesforce_object
1088
+	 * @return array $object_fields
1089
+	 */
1090 1090
 	public function get_wp_sf_object_fields( $wordpress_object = '', $salesforce = '' ) {
1091 1091
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1092 1092
 		if ( empty( $wordpress_object ) ) {
@@ -1111,12 +1111,12 @@  discard block
 block discarded – undo
1111 1111
 	}
1112 1112
 
1113 1113
 	/**
1114
-	* Manually push the WordPress object to Salesforce
1115
-	* This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields
1116
-	*
1117
-	* @param string $wordpress_object
1118
-	* @param int $wordpress_id
1119
-	*/
1114
+	 * Manually push the WordPress object to Salesforce
1115
+	 * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields
1116
+	 *
1117
+	 * @param string $wordpress_object
1118
+	 * @param int $wordpress_id
1119
+	 */
1120 1120
 	public function push_to_salesforce( $wordpress_object = '', $wordpress_id = '' ) {
1121 1121
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1122 1122
 		if ( empty( $wordpress_object ) && empty( $wordpress_id ) ) {
@@ -1135,12 +1135,12 @@  discard block
 block discarded – undo
1135 1135
 	}
1136 1136
 
1137 1137
 	/**
1138
-	* Manually pull the Salesforce object into WordPress
1139
-	* This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields
1140
-	*
1141
-	* @param string $salesforce_id
1142
-	* @param string $wordpress_object
1143
-	*/
1138
+	 * Manually pull the Salesforce object into WordPress
1139
+	 * This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields
1140
+	 *
1141
+	 * @param string $salesforce_id
1142
+	 * @param string $wordpress_object
1143
+	 */
1144 1144
 	public function pull_from_salesforce( $salesforce_id = '', $wordpress_object = '' ) {
1145 1145
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1146 1146
 		if ( empty( $wordpress_object ) && empty( $salesforce_id ) ) {
@@ -1157,11 +1157,11 @@  discard block
 block discarded – undo
1157 1157
 	}
1158 1158
 
1159 1159
 	/**
1160
-	* Manually pull the Salesforce object into WordPress
1161
-	* This takes an id for a mapping object row
1162
-	*
1163
-	* @param int $mapping_id
1164
-	*/
1160
+	 * Manually pull the Salesforce object into WordPress
1161
+	 * This takes an id for a mapping object row
1162
+	 *
1163
+	 * @param int $mapping_id
1164
+	 */
1165 1165
 	public function refresh_mapped_data( $mapping_id = '' ) {
1166 1166
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1167 1167
 		if ( empty( $mapping_id ) ) {
@@ -1180,13 +1180,13 @@  discard block
 block discarded – undo
1180 1180
 	}
1181 1181
 
1182 1182
 	/**
1183
-	* Prepare fieldmap data and redirect after processing
1184
-	* This runs when the create or update forms are submitted
1185
-	* It is public because it depends on an admin hook
1186
-	* It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1187
-	* This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1188
-	*
1189
-	*/
1183
+	 * Prepare fieldmap data and redirect after processing
1184
+	 * This runs when the create or update forms are submitted
1185
+	 * It is public because it depends on an admin hook
1186
+	 * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1187
+	 * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1188
+	 *
1189
+	 */
1190 1190
 	public function prepare_fieldmap_data() {
1191 1191
 		$error     = false;
1192 1192
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
@@ -1234,12 +1234,12 @@  discard block
 block discarded – undo
1234 1234
 	}
1235 1235
 
1236 1236
 	/**
1237
-	* Delete fieldmap data and redirect after processing
1238
-	* This runs when the delete link is clicked, after the user confirms
1239
-	* It is public because it depends on an admin hook
1240
-	* It then calls the Object_Sync_Sf_Mapping class and the delete method
1241
-	*
1242
-	*/
1237
+	 * Delete fieldmap data and redirect after processing
1238
+	 * This runs when the delete link is clicked, after the user confirms
1239
+	 * It is public because it depends on an admin hook
1240
+	 * It then calls the Object_Sync_Sf_Mapping class and the delete method
1241
+	 *
1242
+	 */
1243 1243
 	public function delete_fieldmap() {
1244 1244
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1245 1245
 		if ( $post_data['id'] ) {
@@ -1255,13 +1255,13 @@  discard block
 block discarded – undo
1255 1255
 	}
1256 1256
 
1257 1257
 	/**
1258
-	* Prepare object data and redirect after processing
1259
-	* This runs when the update form is submitted
1260
-	* It is public because it depends on an admin hook
1261
-	* It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1262
-	* This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1263
-	*
1264
-	*/
1258
+	 * Prepare object data and redirect after processing
1259
+	 * This runs when the update form is submitted
1260
+	 * It is public because it depends on an admin hook
1261
+	 * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1262
+	 * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1263
+	 *
1264
+	 */
1265 1265
 	public function prepare_object_map_data() {
1266 1266
 		$error     = false;
1267 1267
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
@@ -1300,12 +1300,12 @@  discard block
 block discarded – undo
1300 1300
 	}
1301 1301
 
1302 1302
 	/**
1303
-	* Delete object map data and redirect after processing
1304
-	* This runs when the delete link is clicked on an error row, after the user confirms
1305
-	* It is public because it depends on an admin hook
1306
-	* It then calls the Object_Sync_Sf_Mapping class and the delete method
1307
-	*
1308
-	*/
1303
+	 * Delete object map data and redirect after processing
1304
+	 * This runs when the delete link is clicked on an error row, after the user confirms
1305
+	 * It is public because it depends on an admin hook
1306
+	 * It then calls the Object_Sync_Sf_Mapping class and the delete method
1307
+	 *
1308
+	 */
1309 1309
 	public function delete_object_map() {
1310 1310
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1311 1311
 		if ( $post_data['id'] ) {
@@ -1321,9 +1321,9 @@  discard block
 block discarded – undo
1321 1321
 	}
1322 1322
 
1323 1323
 	/**
1324
-	* Import a json file and use it for plugin data
1325
-	*
1326
-	*/
1324
+	 * Import a json file and use it for plugin data
1325
+	 *
1326
+	 */
1327 1327
 	public function import_json_file() {
1328 1328
 
1329 1329
 		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import' ) ) {
@@ -1421,9 +1421,9 @@  discard block
 block discarded – undo
1421 1421
 	}
1422 1422
 
1423 1423
 	/**
1424
-	* Create a json file for exporting
1425
-	*
1426
-	*/
1424
+	 * Create a json file for exporting
1425
+	 *
1426
+	 */
1427 1427
 	public function export_json_file() {
1428 1428
 
1429 1429
 		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_export'], 'object_sync_for_salesforce_nonce_export' ) ) {
@@ -1452,10 +1452,10 @@  discard block
 block discarded – undo
1452 1452
 	}
1453 1453
 
1454 1454
 	/**
1455
-	* Default display for <input> fields
1456
-	*
1457
-	* @param array $args
1458
-	*/
1455
+	 * Default display for <input> fields
1456
+	 *
1457
+	 * @param array $args
1458
+	 */
1459 1459
 	public function display_input_field( $args ) {
1460 1460
 		$type    = $args['type'];
1461 1461
 		$id      = $args['label_for'];
@@ -1502,11 +1502,11 @@  discard block
 block discarded – undo
1502 1502
 	}
1503 1503
 
1504 1504
 	/**
1505
-	* Display for multiple checkboxes
1506
-	* Above method can handle a single checkbox as it is
1507
-	*
1508
-	* @param array $args
1509
-	*/
1505
+	 * Display for multiple checkboxes
1506
+	 * Above method can handle a single checkbox as it is
1507
+	 *
1508
+	 * @param array $args
1509
+	 */
1510 1510
 	public function display_checkboxes( $args ) {
1511 1511
 		$type    = 'checkbox';
1512 1512
 		$name    = $args['name'];
@@ -1540,10 +1540,10 @@  discard block
 block discarded – undo
1540 1540
 	}
1541 1541
 
1542 1542
 	/**
1543
-	* Display for a dropdown
1544
-	*
1545
-	* @param array $args
1546
-	*/
1543
+	 * Display for a dropdown
1544
+	 *
1545
+	 * @param array $args
1546
+	 */
1547 1547
 	public function display_select( $args ) {
1548 1548
 		$type = $args['type'];
1549 1549
 		$id   = $args['label_for'];
@@ -1587,10 +1587,10 @@  discard block
 block discarded – undo
1587 1587
 	}
1588 1588
 
1589 1589
 	/**
1590
-	* Dropdown formatted list of Salesforce API versions
1591
-	*
1592
-	* @return array $args
1593
-	*/
1590
+	 * Dropdown formatted list of Salesforce API versions
1591
+	 *
1592
+	 * @return array $args
1593
+	 */
1594 1594
 	private function version_options() {
1595 1595
 		$versions = $this->salesforce['sfapi']->get_api_versions();
1596 1596
 		$args     = array();
@@ -1604,10 +1604,10 @@  discard block
 block discarded – undo
1604 1604
 	}
1605 1605
 
1606 1606
 	/**
1607
-	* Default display for <a href> links
1608
-	*
1609
-	* @param array $args
1610
-	*/
1607
+	 * Default display for <a href> links
1608
+	 *
1609
+	 * @param array $args
1610
+	 */
1611 1611
 	public function display_link( $args ) {
1612 1612
 		$label = $args['label'];
1613 1613
 		$desc  = $args['desc'];
@@ -1634,10 +1634,10 @@  discard block
 block discarded – undo
1634 1634
 	}
1635 1635
 
1636 1636
 	/**
1637
-	* Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it
1638
-	*
1639
-	* @param object $sfapi
1640
-	*/
1637
+	 * Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it
1638
+	 *
1639
+	 * @param object $sfapi
1640
+	 */
1641 1641
 	private function status( $sfapi ) {
1642 1642
 
1643 1643
 		$versions = $sfapi->get_api_versions();
@@ -1696,10 +1696,10 @@  discard block
 block discarded – undo
1696 1696
 	}
1697 1697
 
1698 1698
 	/**
1699
-	* Deauthorize WordPress from Salesforce.
1700
-	* This deletes the tokens from the database; it does not currently do anything in Salesforce
1701
-	* For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce
1702
-	*/
1699
+	 * Deauthorize WordPress from Salesforce.
1700
+	 * This deletes the tokens from the database; it does not currently do anything in Salesforce
1701
+	 * For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce
1702
+	 */
1703 1703
 	private function logout() {
1704 1704
 		$this->access_token  = delete_option( $this->option_prefix . 'access_token' );
1705 1705
 		$this->instance_url  = delete_option( $this->option_prefix . 'instance_url' );
@@ -1711,8 +1711,8 @@  discard block
 block discarded – undo
1711 1711
 	}
1712 1712
 
1713 1713
 	/**
1714
-	* Ajax call to clear the plugin cache.
1715
-	*/
1714
+	 * Ajax call to clear the plugin cache.
1715
+	 */
1716 1716
 	public function clear_sfwp_cache() {
1717 1717
 		$result   = $this->clear_cache( true );
1718 1718
 		$response = array(
@@ -1723,9 +1723,9 @@  discard block
 block discarded – undo
1723 1723
 	}
1724 1724
 
1725 1725
 	/**
1726
-	* Clear the plugin's cache.
1727
-	* This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data.
1728
-	*/
1726
+	 * Clear the plugin's cache.
1727
+	 * This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data.
1728
+	 */
1729 1729
 	private function clear_cache( $ajax = false ) {
1730 1730
 		$result = (bool) $this->wordpress->sfwp_transients->flush();
1731 1731
 		if ( true === $result ) {
@@ -1745,9 +1745,9 @@  discard block
 block discarded – undo
1745 1745
 	}
1746 1746
 
1747 1747
 	/**
1748
-	* Check WordPress Admin permissions
1749
-	* Check if the current user is allowed to access the Salesforce plugin options
1750
-	*/
1748
+	 * Check WordPress Admin permissions
1749
+	 * Check if the current user is allowed to access the Salesforce plugin options
1750
+	 */
1751 1751
 	private function check_wordpress_admin_permissions() {
1752 1752
 
1753 1753
 		// one programmatic way to give this capability to additional user roles is the
@@ -1767,10 +1767,10 @@  discard block
 block discarded – undo
1767 1767
 	}
1768 1768
 
1769 1769
 	/**
1770
-	* Show what we know about this user's relationship to a Salesforce object, if any
1771
-	* @param object $user
1772
-	*
1773
-	*/
1770
+	 * Show what we know about this user's relationship to a Salesforce object, if any
1771
+	 * @param object $user
1772
+	 *
1773
+	 */
1774 1774
 	public function show_salesforce_user_fields( $user ) {
1775 1775
 		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
1776 1776
 		if ( true === $this->check_wordpress_admin_permissions() ) {
@@ -1794,10 +1794,10 @@  discard block
 block discarded – undo
1794 1794
 	}
1795 1795
 
1796 1796
 	/**
1797
-	* If the user profile has been mapped to Salesforce, do it
1798
-	* @param int $user_id
1799
-	*
1800
-	*/
1797
+	 * If the user profile has been mapped to Salesforce, do it
1798
+	 * @param int $user_id
1799
+	 *
1800
+	 */
1801 1801
 	public function save_salesforce_user_fields( $user_id ) {
1802 1802
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1803 1803
 		if ( isset( $post_data['salesforce_update_mapped_user'] ) && '1' === rawurlencode( $post_data['salesforce_update_mapped_user'] ) ) {
@@ -1822,10 +1822,10 @@  discard block
 block discarded – undo
1822 1822
 	}
1823 1823
 
1824 1824
 	/**
1825
-	* Render tabs for settings pages in admin
1826
-	* @param array $tabs
1827
-	* @param string $tab
1828
-	*/
1825
+	 * Render tabs for settings pages in admin
1826
+	 * @param array $tabs
1827
+	 * @param string $tab
1828
+	 */
1829 1829
 	private function tabs( $tabs, $tab = '' ) {
1830 1830
 
1831 1831
 		$get_data        = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
@@ -1855,9 +1855,9 @@  discard block
 block discarded – undo
1855 1855
 	}
1856 1856
 
1857 1857
 	/**
1858
-	* Clear schedule
1859
-	* This clears the schedule if the user clicks the button
1860
-	*/
1858
+	 * Clear schedule
1859
+	 * This clears the schedule if the user clicks the button
1860
+	 */
1861 1861
 	private function clear_schedule( $schedule_name = '' ) {
1862 1862
 		if ( '' !== $schedule_name ) {
1863 1863
 			$schedule = $this->schedule( $schedule_name );
@@ -1879,8 +1879,8 @@  discard block
 block discarded – undo
1879 1879
 	}
1880 1880
 
1881 1881
 	/**
1882
-	* Load the schedule class
1883
-	*/
1882
+	 * Load the schedule class
1883
+	 */
1884 1884
 	private function schedule( $schedule_name ) {
1885 1885
 		if ( ! class_exists( 'Object_Sync_Sf_Schedule' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
1886 1886
 			require_once plugin_dir_path( __FILE__ ) . '../vendor/autoload.php';
@@ -1892,21 +1892,21 @@  discard block
 block discarded – undo
1892 1892
 	}
1893 1893
 
1894 1894
 	/**
1895
-	* Create an object map between a WordPress object and a Salesforce object
1896
-	*
1897
-	* @param int $wordpress_id
1898
-	*   Unique identifier for the WordPress object
1899
-	* @param string $wordpress_object
1900
-	*   What kind of object is it?
1901
-	* @param string $salesforce_id
1902
-	*   Unique identifier for the Salesforce object
1903
-	* @param string $action
1904
-	*   Did we push or pull?
1905
-	*
1906
-	* @return int $wpdb->insert_id
1907
-	*   This is the database row for the map object
1908
-	*
1909
-	*/
1895
+	 * Create an object map between a WordPress object and a Salesforce object
1896
+	 *
1897
+	 * @param int $wordpress_id
1898
+	 *   Unique identifier for the WordPress object
1899
+	 * @param string $wordpress_object
1900
+	 *   What kind of object is it?
1901
+	 * @param string $salesforce_id
1902
+	 *   Unique identifier for the Salesforce object
1903
+	 * @param string $action
1904
+	 *   Did we push or pull?
1905
+	 *
1906
+	 * @return int $wpdb->insert_id
1907
+	 *   This is the database row for the map object
1908
+	 *
1909
+	 */
1910 1910
 	private function create_object_map( $wordpress_id, $wordpress_object, $salesforce_id, $action = '' ) {
1911 1911
 		// Create object map and save it
1912 1912
 		$mapping_object = $this->mappings->create_object_map(
Please login to merge, or discard this patch.
Spacing   +547 added lines, -547 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
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	* @param array $schedulable_classes
83 83
 	* @throws \Exception
84 84
 	*/
85
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes ) {
85
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes) {
86 86
 		$this->wpdb                = $wpdb;
87 87
 		$this->version             = $version;
88 88
 		$this->login_credentials   = $login_credentials;
@@ -121,29 +121,29 @@  discard block
 block discarded – undo
121 121
 	*
122 122
 	*/
123 123
 	public function add_actions() {
124
-		add_action( 'admin_init', array( $this, 'salesforce_settings_forms' ) );
125
-		add_action( 'admin_init', array( $this, 'notices' ) );
126
-		add_action( 'admin_post_post_fieldmap', array( $this, 'prepare_fieldmap_data' ) );
127
-
128
-		add_action( 'admin_post_delete_fieldmap', array( $this, 'delete_fieldmap' ) );
129
-		add_action( 'wp_ajax_get_salesforce_object_description', array( $this, 'get_salesforce_object_description' ) );
130
-		add_action( 'wp_ajax_get_wordpress_object_description', array( $this, 'get_wordpress_object_fields' ) );
131
-		add_action( 'wp_ajax_get_wp_sf_object_fields', array( $this, 'get_wp_sf_object_fields' ) );
132
-		add_action( 'wp_ajax_push_to_salesforce', array( $this, 'push_to_salesforce' ) );
133
-		add_action( 'wp_ajax_pull_from_salesforce', array( $this, 'pull_from_salesforce' ) );
134
-		add_action( 'wp_ajax_refresh_mapped_data', array( $this, 'refresh_mapped_data' ) );
135
-		add_action( 'wp_ajax_clear_sfwp_cache', array( $this, 'clear_sfwp_cache' ) );
136
-
137
-		add_action( 'edit_user_profile', array( $this, 'show_salesforce_user_fields' ) );
138
-		add_action( 'personal_options_update', array( $this, 'save_salesforce_user_fields' ) );
139
-		add_action( 'edit_user_profile_update', array( $this, 'save_salesforce_user_fields' ) );
140
-
141
-		add_action( 'admin_post_delete_object_map', array( $this, 'delete_object_map' ) );
142
-		add_action( 'admin_post_post_object_map', array( $this, 'prepare_object_map_data' ) );
124
+		add_action('admin_init', array($this, 'salesforce_settings_forms'));
125
+		add_action('admin_init', array($this, 'notices'));
126
+		add_action('admin_post_post_fieldmap', array($this, 'prepare_fieldmap_data'));
127
+
128
+		add_action('admin_post_delete_fieldmap', array($this, 'delete_fieldmap'));
129
+		add_action('wp_ajax_get_salesforce_object_description', array($this, 'get_salesforce_object_description'));
130
+		add_action('wp_ajax_get_wordpress_object_description', array($this, 'get_wordpress_object_fields'));
131
+		add_action('wp_ajax_get_wp_sf_object_fields', array($this, 'get_wp_sf_object_fields'));
132
+		add_action('wp_ajax_push_to_salesforce', array($this, 'push_to_salesforce'));
133
+		add_action('wp_ajax_pull_from_salesforce', array($this, 'pull_from_salesforce'));
134
+		add_action('wp_ajax_refresh_mapped_data', array($this, 'refresh_mapped_data'));
135
+		add_action('wp_ajax_clear_sfwp_cache', array($this, 'clear_sfwp_cache'));
136
+
137
+		add_action('edit_user_profile', array($this, 'show_salesforce_user_fields'));
138
+		add_action('personal_options_update', array($this, 'save_salesforce_user_fields'));
139
+		add_action('edit_user_profile_update', array($this, 'save_salesforce_user_fields'));
140
+
141
+		add_action('admin_post_delete_object_map', array($this, 'delete_object_map'));
142
+		add_action('admin_post_post_object_map', array($this, 'prepare_object_map_data'));
143 143
 
144 144
 		// import and export plugin data
145
-		add_action( 'admin_post_object_sync_for_salesforce_import', array( $this, 'import_json_file' ) );
146
-		add_action( 'admin_post_object_sync_for_salesforce_export', array( $this, 'export_json_file' ) );
145
+		add_action('admin_post_object_sync_for_salesforce_import', array($this, 'import_json_file'));
146
+		add_action('admin_post_object_sync_for_salesforce_export', array($this, 'export_json_file'));
147 147
 
148 148
 	}
149 149
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	*
153 153
 	*/
154 154
 	public function create_admin_menu() {
155
-		$title = __( 'Salesforce', 'object-sync-for-salesforce' );
156
-		add_options_page( $title, $title, 'configure_salesforce', 'object-sync-salesforce-admin', array( $this, 'show_admin_page' ) );
155
+		$title = __('Salesforce', 'object-sync-for-salesforce');
156
+		add_options_page($title, $title, 'configure_salesforce', 'object-sync-salesforce-admin', array($this, 'show_admin_page'));
157 157
 	}
158 158
 
159 159
 	/**
@@ -164,114 +164,114 @@  discard block
 block discarded – undo
164 164
 	*
165 165
 	*/
166 166
 	public function show_admin_page() {
167
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
167
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
168 168
 		echo '<div class="wrap">';
169
-		echo '<h1>' . esc_html( get_admin_page_title() ) . '</h1>';
169
+		echo '<h1>' . esc_html(get_admin_page_title()) . '</h1>';
170 170
 		$allowed = $this->check_wordpress_admin_permissions();
171
-		if ( false === $allowed ) {
171
+		if (false === $allowed) {
172 172
 			return;
173 173
 		}
174 174
 		$tabs = array(
175
-			'settings'      => __( 'Settings', 'object-sync-for-salesforce' ),
176
-			'authorize'     => __( 'Authorize', 'object-sync-for-salesforce' ),
177
-			'fieldmaps'     => __( 'Fieldmaps', 'object-sync-for-salesforce' ),
178
-			'schedule'      => __( 'Scheduling', 'object-sync-for-salesforce' ),
179
-			'import-export' => __( 'Import &amp; Export', 'object-sync-for-salesforce' ),
175
+			'settings'      => __('Settings', 'object-sync-for-salesforce'),
176
+			'authorize'     => __('Authorize', 'object-sync-for-salesforce'),
177
+			'fieldmaps'     => __('Fieldmaps', 'object-sync-for-salesforce'),
178
+			'schedule'      => __('Scheduling', 'object-sync-for-salesforce'),
179
+			'import-export' => __('Import &amp; Export', 'object-sync-for-salesforce'),
180 180
 		); // this creates the tabs for the admin
181 181
 
182 182
 		// optionally make tab(s) for logging and log settings
183
-		$logging_enabled      = get_option( $this->option_prefix . 'enable_logging', false );
184
-		$tabs['log_settings'] = __( 'Log Settings', 'object-sync-for-salesforce' );
183
+		$logging_enabled      = get_option($this->option_prefix . 'enable_logging', false);
184
+		$tabs['log_settings'] = __('Log Settings', 'object-sync-for-salesforce');
185 185
 
186 186
 		$mapping_errors = $this->mappings->get_failed_object_maps();
187
-		if ( ! empty( $mapping_errors ) ) {
188
-			$tabs['mapping_errors'] = __( 'Mapping Errors', 'object-sync-for-salesforce' );
187
+		if ( ! empty($mapping_errors)) {
188
+			$tabs['mapping_errors'] = __('Mapping Errors', 'object-sync-for-salesforce');
189 189
 		}
190 190
 
191 191
 		// filter for extending the tabs available on the page
192 192
 		// currently it will go into the default switch case for $tab
193
-		$tabs = apply_filters( 'object_sync_for_salesforce_settings_tabs', $tabs );
193
+		$tabs = apply_filters('object_sync_for_salesforce_settings_tabs', $tabs);
194 194
 
195
-		$tab = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
196
-		$this->tabs( $tabs, $tab );
195
+		$tab = isset($get_data['tab']) ? sanitize_key($get_data['tab']) : 'settings';
196
+		$this->tabs($tabs, $tab);
197 197
 
198 198
 		$consumer_key    = $this->login_credentials['consumer_key'];
199 199
 		$consumer_secret = $this->login_credentials['consumer_secret'];
200 200
 		$callback_url    = $this->login_credentials['callback_url'];
201 201
 
202
-		if ( true !== $this->salesforce['is_authorized'] ) {
203
-			$url     = esc_url( $callback_url );
204
-			$anchor  = esc_html__( 'Authorize tab', 'object-sync-for-salesforce' );
205
-			$message = sprintf( 'Salesforce needs to be authorized to connect to this website. Use the <a href="%s">%s</a> to connect.', $url, $anchor );
206
-			require( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
202
+		if (true !== $this->salesforce['is_authorized']) {
203
+			$url     = esc_url($callback_url);
204
+			$anchor  = esc_html__('Authorize tab', 'object-sync-for-salesforce');
205
+			$message = sprintf('Salesforce needs to be authorized to connect to this website. Use the <a href="%s">%s</a> to connect.', $url, $anchor);
206
+			require(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
207 207
 		}
208 208
 
209
-		if ( 0 === count( $this->mappings->get_fieldmaps() ) ) {
210
-			$url     = esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps' ) );
211
-			$anchor  = esc_html__( 'Fieldmaps tab', 'object-sync-for-salesforce' );
212
-			$message = sprintf( 'No fieldmaps exist yet. Use the <a href="%s">%s</a> to map WordPress and Salesforce objects to each other.', $url, $anchor );
213
-			require( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
209
+		if (0 === count($this->mappings->get_fieldmaps())) {
210
+			$url     = esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps'));
211
+			$anchor  = esc_html__('Fieldmaps tab', 'object-sync-for-salesforce');
212
+			$message = sprintf('No fieldmaps exist yet. Use the <a href="%s">%s</a> to map WordPress and Salesforce objects to each other.', $url, $anchor);
213
+			require(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
214 214
 		}
215 215
 
216
-		$push_schedule_number = get_option( $this->option_prefix . 'salesforce_push_schedule_number', '' );
217
-		$push_schedule_unit   = get_option( $this->option_prefix . 'salesforce_push_schedule_unit', '' );
218
-		$pull_schedule_number = get_option( $this->option_prefix . 'salesforce_pull_schedule_number', '' );
219
-		$pull_schedule_unit   = get_option( $this->option_prefix . 'salesforce_pull_schedule_unit', '' );
216
+		$push_schedule_number = get_option($this->option_prefix . 'salesforce_push_schedule_number', '');
217
+		$push_schedule_unit   = get_option($this->option_prefix . 'salesforce_push_schedule_unit', '');
218
+		$pull_schedule_number = get_option($this->option_prefix . 'salesforce_pull_schedule_number', '');
219
+		$pull_schedule_unit   = get_option($this->option_prefix . 'salesforce_pull_schedule_unit', '');
220 220
 
221
-		if ( '' === $push_schedule_number && '' === $push_schedule_unit && '' === $pull_schedule_number && '' === $pull_schedule_unit ) {
222
-			$url     = esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=schedule' ) );
223
-			$anchor  = esc_html__( 'Scheduling tab', 'object-sync-for-salesforce' );
224
-			$message = sprintf( 'Because the plugin schedule has not been saved, the plugin cannot run automatic operations. Use the <a href="%s">%s</a> to create schedules to run.', $url, $anchor );
225
-			require( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
221
+		if ('' === $push_schedule_number && '' === $push_schedule_unit && '' === $pull_schedule_number && '' === $pull_schedule_unit) {
222
+			$url     = esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=schedule'));
223
+			$anchor  = esc_html__('Scheduling tab', 'object-sync-for-salesforce');
224
+			$message = sprintf('Because the plugin schedule has not been saved, the plugin cannot run automatic operations. Use the <a href="%s">%s</a> to create schedules to run.', $url, $anchor);
225
+			require(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
226 226
 		}
227 227
 
228 228
 		try {
229
-			switch ( $tab ) {
229
+			switch ($tab) {
230 230
 				case 'authorize':
231
-					if ( isset( $get_data['code'] ) ) {
231
+					if (isset($get_data['code'])) {
232 232
 						// this string is an oauth token
233
-						$data          = esc_html( wp_unslash( $get_data['code'] ) );
234
-						$is_authorized = $this->salesforce['sfapi']->request_token( $data );
233
+						$data          = esc_html(wp_unslash($get_data['code']));
234
+						$is_authorized = $this->salesforce['sfapi']->request_token($data);
235 235
 						?>
236
-						<script>window.location = '<?php echo esc_url_raw( $callback_url ); ?>'</script>
236
+						<script>window.location = '<?php echo esc_url_raw($callback_url); ?>'</script>
237 237
 						<?php
238
-					} elseif ( true === $this->salesforce['is_authorized'] ) {
239
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/authorized.php' );
240
-							$this->status( $this->salesforce['sfapi'] );
241
-					} elseif ( true === is_object( $this->salesforce['sfapi'] ) && isset( $consumer_key ) && isset( $consumer_secret ) ) {
238
+					} elseif (true === $this->salesforce['is_authorized']) {
239
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/authorized.php');
240
+							$this->status($this->salesforce['sfapi']);
241
+					} elseif (true === is_object($this->salesforce['sfapi']) && isset($consumer_key) && isset($consumer_secret)) {
242 242
 						?>
243
-						<p><a class="button button-primary" href="<?php echo esc_url( $this->salesforce['sfapi']->get_authorization_code() ); ?>"><?php echo esc_html__( 'Connect to Salesforce', 'object-sync-for-salesforce' ); ?></a></p>
243
+						<p><a class="button button-primary" href="<?php echo esc_url($this->salesforce['sfapi']->get_authorization_code()); ?>"><?php echo esc_html__('Connect to Salesforce', 'object-sync-for-salesforce'); ?></a></p>
244 244
 						<?php
245 245
 					} else {
246
-						$url    = esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=settings' ) );
247
-						$anchor = esc_html__( 'Settings', 'object-sync-for-salesforce' );
246
+						$url    = esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=settings'));
247
+						$anchor = esc_html__('Settings', 'object-sync-for-salesforce');
248 248
 						// translators: placeholders are for the settings tab link: 1) the url, and 2) the anchor text
249
-						$message = sprintf( esc_html__( 'Salesforce needs to be authorized to connect to this website but the credentials are missing. Use the <a href="%1$s">%2$s</a> tab to add them.', 'object-sync-salesforce' ), $url, $anchor );
250
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
249
+						$message = sprintf(esc_html__('Salesforce needs to be authorized to connect to this website but the credentials are missing. Use the <a href="%1$s">%2$s</a> tab to add them.', 'object-sync-salesforce'), $url, $anchor);
250
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
251 251
 					}
252 252
 					break;
253 253
 				case 'fieldmaps':
254
-					if ( isset( $get_data['method'] ) ) {
254
+					if (isset($get_data['method'])) {
255 255
 
256
-						$method      = sanitize_key( $get_data['method'] );
257
-						$error_url   = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps&method=' . $method );
258
-						$success_url = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps' );
256
+						$method      = sanitize_key($get_data['method']);
257
+						$error_url   = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps&method=' . $method);
258
+						$success_url = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps');
259 259
 
260
-						if ( isset( $get_data['transient'] ) ) {
261
-							$transient = sanitize_key( $get_data['transient'] );
262
-							$posted    = $this->sfwp_transients->get( $transient );
260
+						if (isset($get_data['transient'])) {
261
+							$transient = sanitize_key($get_data['transient']);
262
+							$posted    = $this->sfwp_transients->get($transient);
263 263
 						}
264 264
 
265
-						if ( isset( $posted ) && is_array( $posted ) ) {
265
+						if (isset($posted) && is_array($posted)) {
266 266
 							$map = $posted;
267
-						} elseif ( 'edit' === $method || 'clone' === $method || 'delete' === $method ) {
268
-							$map = $this->mappings->get_fieldmaps( isset( $get_data['id'] ) ? sanitize_key( $get_data['id'] ) : '' );
267
+						} elseif ('edit' === $method || 'clone' === $method || 'delete' === $method) {
268
+							$map = $this->mappings->get_fieldmaps(isset($get_data['id']) ? sanitize_key($get_data['id']) : '');
269 269
 						}
270 270
 
271
-						if ( isset( $map ) && is_array( $map ) ) {
271
+						if (isset($map) && is_array($map)) {
272 272
 							$label                           = $map['label'];
273 273
 							$salesforce_object               = $map['salesforce_object'];
274
-							$salesforce_record_types_allowed = maybe_unserialize( $map['salesforce_record_types_allowed'] );
274
+							$salesforce_record_types_allowed = maybe_unserialize($map['salesforce_record_types_allowed']);
275 275
 							$salesforce_record_type_default  = $map['salesforce_record_type_default'];
276 276
 							$wordpress_object                = $map['wordpress_object'];
277 277
 							$pull_trigger_field              = $map['pull_trigger_field'];
@@ -282,14 +282,14 @@  discard block
 block discarded – undo
282 282
 							$weight                          = $map['weight'];
283 283
 						}
284 284
 
285
-						if ( 'add' === $method || 'edit' === $method || 'clone' === $method ) {
286
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/fieldmaps-add-edit-clone.php' );
287
-						} elseif ( 'delete' === $method ) {
288
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/fieldmaps-delete.php' );
285
+						if ('add' === $method || 'edit' === $method || 'clone' === $method) {
286
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/fieldmaps-add-edit-clone.php');
287
+						} elseif ('delete' === $method) {
288
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/fieldmaps-delete.php');
289 289
 						}
290 290
 					} else {
291 291
 						$fieldmaps = $this->mappings->get_fieldmaps();
292
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/fieldmaps-list.php' );
292
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/fieldmaps-list.php');
293 293
 					} // End if().
294 294
 					break;
295 295
 				case 'logout':
@@ -299,73 +299,73 @@  discard block
 block discarded – undo
299 299
 					$this->clear_cache();
300 300
 					break;
301 301
 				case 'clear_schedule':
302
-					if ( isset( $get_data['schedule_name'] ) ) {
303
-						$schedule_name = sanitize_key( $get_data['schedule_name'] );
302
+					if (isset($get_data['schedule_name'])) {
303
+						$schedule_name = sanitize_key($get_data['schedule_name']);
304 304
 					}
305
-					$this->clear_schedule( $schedule_name );
305
+					$this->clear_schedule($schedule_name);
306 306
 					break;
307 307
 				case 'settings':
308
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/settings.php' );
308
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/settings.php');
309 309
 					break;
310 310
 				case 'mapping_errors':
311
-					if ( isset( $get_data['method'] ) ) {
311
+					if (isset($get_data['method'])) {
312 312
 
313
-						$method      = sanitize_key( $get_data['method'] );
314
-						$error_url   = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors&method=' . $method );
315
-						$success_url = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors' );
313
+						$method      = sanitize_key($get_data['method']);
314
+						$error_url   = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors&method=' . $method);
315
+						$success_url = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors');
316 316
 
317
-						if ( isset( $get_data['map_transient'] ) ) {
318
-							$transient = sanitize_key( $get_data['map_transient'] );
319
-							$posted    = $this->sfwp_transients->get( $transient );
317
+						if (isset($get_data['map_transient'])) {
318
+							$transient = sanitize_key($get_data['map_transient']);
319
+							$posted    = $this->sfwp_transients->get($transient);
320 320
 						}
321 321
 
322
-						if ( isset( $posted ) && is_array( $posted ) ) {
322
+						if (isset($posted) && is_array($posted)) {
323 323
 							$map_row = $posted;
324
-						} elseif ( 'edit' === $method || 'delete' === $method ) {
325
-							$map_row = $this->mappings->get_failed_object_map( isset( $get_data['id'] ) ? sanitize_key( $get_data['id'] ) : '' );
324
+						} elseif ('edit' === $method || 'delete' === $method) {
325
+							$map_row = $this->mappings->get_failed_object_map(isset($get_data['id']) ? sanitize_key($get_data['id']) : '');
326 326
 						}
327 327
 
328
-						if ( isset( $map_row ) && is_array( $map_row ) ) {
328
+						if (isset($map_row) && is_array($map_row)) {
329 329
 							$salesforce_id = $map_row['salesforce_id'];
330 330
 							$wordpress_id  = $map_row['wordpress_id'];
331 331
 						}
332 332
 
333
-						if ( 'edit' === $method ) {
334
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/mapping-errors-edit.php' );
335
-						} elseif ( 'delete' === $method ) {
336
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/mapping-errors-delete.php' );
333
+						if ('edit' === $method) {
334
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/mapping-errors-edit.php');
335
+						} elseif ('delete' === $method) {
336
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/mapping-errors-delete.php');
337 337
 						}
338 338
 					} else {
339
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/mapping-errors.php' );
339
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/mapping-errors.php');
340 340
 					}
341 341
 					break;
342 342
 				case 'import-export':
343
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/import-export.php' );
343
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/import-export.php');
344 344
 					break;
345 345
 				default:
346
-					$include_settings = apply_filters( 'object_sync_for_salesforce_settings_tab_include_settings', true, $tab );
347
-					$content_before   = apply_filters( 'object_sync_for_salesforce_settings_tab_content_before', null, $tab );
348
-					$content_after    = apply_filters( 'object_sync_for_salesforce_settings_tab_content_after', null, $tab );
349
-					if ( null !== $content_before ) {
350
-						echo esc_html( $content_before );
346
+					$include_settings = apply_filters('object_sync_for_salesforce_settings_tab_include_settings', true, $tab);
347
+					$content_before   = apply_filters('object_sync_for_salesforce_settings_tab_content_before', null, $tab);
348
+					$content_after    = apply_filters('object_sync_for_salesforce_settings_tab_content_after', null, $tab);
349
+					if (null !== $content_before) {
350
+						echo esc_html($content_before);
351 351
 					}
352
-					if ( true === $include_settings ) {
353
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/settings.php' );
352
+					if (true === $include_settings) {
353
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/settings.php');
354 354
 					}
355
-					if ( null !== $content_after ) {
356
-						echo esc_html( $content_after );
355
+					if (null !== $content_after) {
356
+						echo esc_html($content_after);
357 357
 					}
358 358
 					break;
359 359
 			} // End switch().
360
-		} catch ( SalesforceApiException $ex ) {
361
-			echo sprintf( '<p>Error <strong>%1$s</strong>: %2$s</p>',
362
-				absint( $ex->getCode() ),
363
-				esc_html( $ex->getMessage() )
360
+		} catch (SalesforceApiException $ex) {
361
+			echo sprintf('<p>Error <strong>%1$s</strong>: %2$s</p>',
362
+				absint($ex->getCode()),
363
+				esc_html($ex->getMessage())
364 364
 			);
365
-		} catch ( Exception $ex ) {
366
-			echo sprintf( '<p>Error <strong>%1$s</strong>: %2$s</p>',
367
-				absint( $ex->getCode() ),
368
-				esc_html( $ex->getMessage() )
365
+		} catch (Exception $ex) {
366
+			echo sprintf('<p>Error <strong>%1$s</strong>: %2$s</p>',
367
+				absint($ex->getCode()),
368
+				esc_html($ex->getMessage())
369 369
 			);
370 370
 		} // End try().
371 371
 		echo '</div>';
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 	*
378 378
 	*/
379 379
 	public function salesforce_settings_forms() {
380
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
381
-		$page     = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
382
-		$section  = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
380
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
381
+		$page     = isset($get_data['tab']) ? sanitize_key($get_data['tab']) : 'settings';
382
+		$section  = isset($get_data['tab']) ? sanitize_key($get_data['tab']) : 'settings';
383 383
 
384
-		$input_callback_default   = array( $this, 'display_input_field' );
385
-		$input_checkboxes_default = array( $this, 'display_checkboxes' );
386
-		$input_select_default     = array( $this, 'display_select' );
387
-		$link_default             = array( $this, 'display_link' );
384
+		$input_callback_default   = array($this, 'display_input_field');
385
+		$input_checkboxes_default = array($this, 'display_checkboxes');
386
+		$input_select_default     = array($this, 'display_select');
387
+		$link_default             = array($this, 'display_link');
388 388
 
389 389
 		$all_field_callbacks = array(
390 390
 			'text'       => $input_callback_default,
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 			'link'       => $link_default,
394 394
 		);
395 395
 
396
-		$this->fields_settings( 'settings', 'settings', $all_field_callbacks );
397
-		$this->fields_fieldmaps( 'fieldmaps', 'objects' );
398
-		$this->fields_scheduling( 'schedule', 'schedule', $all_field_callbacks );
399
-		$this->fields_log_settings( 'log_settings', 'log_settings', $all_field_callbacks );
396
+		$this->fields_settings('settings', 'settings', $all_field_callbacks);
397
+		$this->fields_fieldmaps('fieldmaps', 'objects');
398
+		$this->fields_scheduling('schedule', 'schedule', $all_field_callbacks);
399
+		$this->fields_log_settings('log_settings', 'log_settings', $all_field_callbacks);
400 400
 	}
401 401
 
402 402
 	/**
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 	* @param string $section
408 408
 	* @param string $input_callback
409 409
 	*/
410
-	private function fields_settings( $page, $section, $callbacks ) {
411
-		add_settings_section( $page, ucwords( $page ), null, $page );
410
+	private function fields_settings($page, $section, $callbacks) {
411
+		add_settings_section($page, ucwords($page), null, $page);
412 412
 		$salesforce_settings = array(
413 413
 			'consumer_key'             => array(
414
-				'title'    => __( 'Consumer Key', 'object-sync-for-salesforce' ),
414
+				'title'    => __('Consumer Key', 'object-sync-for-salesforce'),
415 415
 				'callback' => $callbacks['text'],
416 416
 				'page'     => $page,
417 417
 				'section'  => $section,
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
 			),
426 426
 			'consumer_secret'          => array(
427
-				'title'    => __( 'Consumer Secret', 'object-sync-for-salesforce' ),
427
+				'title'    => __('Consumer Secret', 'object-sync-for-salesforce'),
428 428
 				'callback' => $callbacks['text'],
429 429
 				'page'     => $page,
430 430
 				'section'  => $section,
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				),
437 437
 			),
438 438
 			'callback_url'             => array(
439
-				'title'    => __( 'Callback URL', 'object-sync-for-salesforce' ),
439
+				'title'    => __('Callback URL', 'object-sync-for-salesforce'),
440 440
 				'callback' => $callbacks['text'],
441 441
 				'page'     => $page,
442 442
 				'section'  => $section,
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 				),
449 449
 			),
450 450
 			'login_base_url'           => array(
451
-				'title'    => __( 'Login Base URL', 'object-sync-for-salesforce' ),
451
+				'title'    => __('Login Base URL', 'object-sync-for-salesforce'),
452 452
 				'callback' => $callbacks['text'],
453 453
 				'page'     => $page,
454 454
 				'section'  => $section,
@@ -456,22 +456,22 @@  discard block
 block discarded – undo
456 456
 					'type'     => 'url',
457 457
 					'validate' => 'sanitize_text_field',
458 458
 					// translators: 1) production salesforce login, 2) sandbox salesforce login
459
-					'desc'     => sprintf( __( 'For most Salesforce setups, you should use %1$s for production and %2$s for sandbox.', 'object-sync-for-salesforce' ),
460
-						esc_url( 'https://login.salesforce.com' ),
461
-						esc_url( 'https://test.salesforce.com' )
459
+					'desc'     => sprintf(__('For most Salesforce setups, you should use %1$s for production and %2$s for sandbox.', 'object-sync-for-salesforce'),
460
+						esc_url('https://login.salesforce.com'),
461
+						esc_url('https://test.salesforce.com')
462 462
 					),
463 463
 					'constant' => 'OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL',
464 464
 				),
465 465
 			),
466 466
 			'authorize_url_path'       => array(
467
-				'title'    => __( 'Authorize URL Path', 'object-sync-for-salesforce' ),
467
+				'title'    => __('Authorize URL Path', 'object-sync-for-salesforce'),
468 468
 				'callback' => $callbacks['text'],
469 469
 				'page'     => $page,
470 470
 				'section'  => $section,
471 471
 				'args'     => array(
472 472
 					'type'     => 'text',
473 473
 					'validate' => 'sanitize_text_field',
474
-					'desc'     => __( 'For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce' ),
474
+					'desc'     => __('For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce'),
475 475
 					'constant' => 'OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH',
476 476
 					'default'  => $this->default_authorize_url_path,
477 477
 				),
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 				'args'     => array(
485 485
 					'type'     => 'text',
486 486
 					'validate' => 'sanitize_text_field',
487
-					'desc'     => __( 'For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce' ),
487
+					'desc'     => __('For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce'),
488 488
 					'constant' => 'OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH',
489 489
 					'default'  => $this->default_token_url_path,
490 490
 				),
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 				'args'     => array(
511 511
 					'type'     => 'checkboxes',
512 512
 					'validate' => 'sanitize_text_field',
513
-					'desc'     => __( 'Allows you to limit which Salesforce objects can be mapped', 'object-sync-for-salesforce' ),
513
+					'desc'     => __('Allows you to limit which Salesforce objects can be mapped', 'object-sync-for-salesforce'),
514 514
 					'items'    => array(
515 515
 						'triggerable' => array(
516 516
 							'text'    => 'Only Triggerable objects',
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 				'args'     => array(
536 536
 					'type'     => 'number',
537 537
 					'validate' => 'sanitize_text_field',
538
-					'desc'     => __( 'Number of seconds to wait between repeated salesforce pulls. Prevents the webserver from becoming overloaded in case of too many cron runs, or webhook usage.', 'object-sync-for-salesforce' ),
538
+					'desc'     => __('Number of seconds to wait between repeated salesforce pulls. Prevents the webserver from becoming overloaded in case of too many cron runs, or webhook usage.', 'object-sync-for-salesforce'),
539 539
 					'constant' => '',
540 540
 					'default'  => $this->default_pull_throttle,
541 541
 				),
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 				'args'     => array(
549 549
 					'type'     => 'checkbox',
550 550
 					'validate' => 'sanitize_text_field',
551
-					'desc'     => __( 'Debug mode can, combined with the Log Settings, log things like Salesforce API requests. It can create a lot of entries if enabled; it is not recommended to use it in a production environment.', 'object-sync-for-salesforce' ),
551
+					'desc'     => __('Debug mode can, combined with the Log Settings, log things like Salesforce API requests. It can create a lot of entries if enabled; it is not recommended to use it in a production environment.', 'object-sync-for-salesforce'),
552 552
 					'constant' => '',
553 553
 				),
554 554
 			),
@@ -560,13 +560,13 @@  discard block
 block discarded – undo
560 560
 				'args'     => array(
561 561
 					'type'     => 'checkbox',
562 562
 					'validate' => 'sanitize_text_field',
563
-					'desc'     => __( 'If checked, the plugin will delete the tables and other data it creates when you uninstall it. Unchecking this field can be useful if you need to reactivate the plugin for any reason without losing data.', 'object-sync-for-salesforce' ),
563
+					'desc'     => __('If checked, the plugin will delete the tables and other data it creates when you uninstall it. Unchecking this field can be useful if you need to reactivate the plugin for any reason without losing data.', 'object-sync-for-salesforce'),
564 564
 					'constant' => '',
565 565
 				),
566 566
 			),
567 567
 		);
568 568
 
569
-		if ( true === is_object( $this->salesforce['sfapi'] ) && true === $this->salesforce['sfapi']->is_authorized() ) {
569
+		if (true === is_object($this->salesforce['sfapi']) && true === $this->salesforce['sfapi']->is_authorized()) {
570 570
 			$salesforce_settings['api_version'] = array(
571 571
 				'title'    => 'Salesforce API Version',
572 572
 				'callback' => $callbacks['select'],
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			);
583 583
 		}
584 584
 
585
-		foreach ( $salesforce_settings as $key => $attributes ) {
585
+		foreach ($salesforce_settings as $key => $attributes) {
586 586
 			$id       = $this->option_prefix . $key;
587 587
 			$name     = $this->option_prefix . $key;
588 588
 			$title    = $attributes['title'];
@@ -601,12 +601,12 @@  discard block
 block discarded – undo
601 601
 			);
602 602
 
603 603
 			// if there is a constant and it is defined, don't run a validate function
604
-			if ( isset( $attributes['args']['constant'] ) && defined( $attributes['args']['constant'] ) ) {
604
+			if (isset($attributes['args']['constant']) && defined($attributes['args']['constant'])) {
605 605
 				$validate = '';
606 606
 			}
607 607
 
608
-			add_settings_field( $id, $title, $callback, $page, $section, $args );
609
-			register_setting( $page, $id, array( $this, $validate ) );
608
+			add_settings_field($id, $title, $callback, $page, $section, $args);
609
+			register_setting($page, $id, array($this, $validate));
610 610
 		}
611 611
 	}
612 612
 
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
 	* @param string $section
619 619
 	* @param string $input_callback
620 620
 	*/
621
-	private function fields_fieldmaps( $page, $section, $input_callback = '' ) {
622
-		add_settings_section( $page, ucwords( $page ), null, $page );
621
+	private function fields_fieldmaps($page, $section, $input_callback = '') {
622
+		add_settings_section($page, ucwords($page), null, $page);
623 623
 	}
624 624
 
625 625
 	/**
@@ -630,12 +630,12 @@  discard block
 block discarded – undo
630 630
 	* @param string $section
631 631
 	* @param string $input_callback
632 632
 	*/
633
-	private function fields_scheduling( $page, $section, $callbacks ) {
634
-		foreach ( $this->schedulable_classes as $key => $value ) {
635
-			add_settings_section( $key, $value['label'], null, $page );
633
+	private function fields_scheduling($page, $section, $callbacks) {
634
+		foreach ($this->schedulable_classes as $key => $value) {
635
+			add_settings_section($key, $value['label'], null, $page);
636 636
 			$schedule_settings = array(
637 637
 				$key . '_schedule_number' => array(
638
-					'title'    => __( 'Run schedule every', 'object-sync-for-salesforce' ),
638
+					'title'    => __('Run schedule every', 'object-sync-for-salesforce'),
639 639
 					'callback' => $callbacks['text'],
640 640
 					'page'     => $page,
641 641
 					'section'  => $key,
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 					),
648 648
 				),
649 649
 				$key . '_schedule_unit'   => array(
650
-					'title'    => __( 'Time unit', 'object-sync-for-salesforce' ),
650
+					'title'    => __('Time unit', 'object-sync-for-salesforce'),
651 651
 					'callback' => $callbacks['select'],
652 652
 					'page'     => $page,
653 653
 					'section'  => $key,
@@ -673,19 +673,19 @@  discard block
 block discarded – undo
673 673
 				),
674 674
 				$key . '_clear_button'    => array(
675 675
 					// translators: $this->get_schedule_count is an integer showing how many items are in the current queue
676
-					'title'    => sprintf( 'This queue has ' . _n( '%s item', '%s items', $this->get_schedule_count( $key ), 'object-sync-for-salesforce' ), $this->get_schedule_count( $key ) ),
676
+					'title'    => sprintf('This queue has ' . _n('%s item', '%s items', $this->get_schedule_count($key), 'object-sync-for-salesforce'), $this->get_schedule_count($key)),
677 677
 					'callback' => $callbacks['link'],
678 678
 					'page'     => $page,
679 679
 					'section'  => $key,
680 680
 					'args'     => array(
681 681
 						'label'      => 'Clear this queue',
682 682
 						'desc'       => '',
683
-						'url'        => esc_url( '?page=object-sync-salesforce-admin&amp;tab=clear_schedule&amp;schedule_name=' . $key ),
683
+						'url'        => esc_url('?page=object-sync-salesforce-admin&amp;tab=clear_schedule&amp;schedule_name=' . $key),
684 684
 						'link_class' => 'button button-secondary',
685 685
 					),
686 686
 				),
687 687
 			);
688
-			foreach ( $schedule_settings as $key => $attributes ) {
688
+			foreach ($schedule_settings as $key => $attributes) {
689 689
 				$id       = $this->option_prefix . $key;
690 690
 				$name     = $this->option_prefix . $key;
691 691
 				$title    = $attributes['title'];
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
 						'name'      => $name,
702 702
 					)
703 703
 				);
704
-				add_settings_field( $id, $title, $callback, $page, $section, $args );
705
-				register_setting( $page, $id );
704
+				add_settings_field($id, $title, $callback, $page, $section, $args);
705
+				register_setting($page, $id);
706 706
 			}
707 707
 		} // End foreach().
708 708
 	}
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 	* @param string $section
716 716
 	* @param array $callbacks
717 717
 	*/
718
-	private function fields_log_settings( $page, $section, $callbacks ) {
719
-		add_settings_section( $page, ucwords( str_replace( '_', ' ', $page ) ), null, $page );
718
+	private function fields_log_settings($page, $section, $callbacks) {
719
+		add_settings_section($page, ucwords(str_replace('_', ' ', $page)), null, $page);
720 720
 		$log_settings = array(
721 721
 			'enable_logging'        => array(
722
-				'title'    => __( 'Enable Logging?', 'object-sync-for-salesforce' ),
722
+				'title'    => __('Enable Logging?', 'object-sync-for-salesforce'),
723 723
 				'callback' => $callbacks['text'],
724 724
 				'page'     => $page,
725 725
 				'section'  => $section,
@@ -731,32 +731,32 @@  discard block
 block discarded – undo
731 731
 				),
732 732
 			),
733 733
 			'statuses_to_log'       => array(
734
-				'title'    => __( 'Statuses to log', 'object-sync-for-salesforce' ),
734
+				'title'    => __('Statuses to log', 'object-sync-for-salesforce'),
735 735
 				'callback' => $callbacks['checkboxes'],
736 736
 				'page'     => $page,
737 737
 				'section'  => $section,
738 738
 				'args'     => array(
739 739
 					'type'     => 'checkboxes',
740 740
 					'validate' => 'sanitize_text_field',
741
-					'desc'     => __( 'these are the statuses to log', 'object-sync-for-salesforce' ),
741
+					'desc'     => __('these are the statuses to log', 'object-sync-for-salesforce'),
742 742
 					'items'    => array(
743 743
 						'error'   => array(
744
-							'text' => __( 'Error', 'object-sync-for-salesforce' ),
744
+							'text' => __('Error', 'object-sync-for-salesforce'),
745 745
 							'id'   => 'error',
746 746
 							'desc' => '',
747 747
 						),
748 748
 						'success' => array(
749
-							'text' => __( 'Success', 'object-sync-for-salesforce' ),
749
+							'text' => __('Success', 'object-sync-for-salesforce'),
750 750
 							'id'   => 'success',
751 751
 							'desc' => '',
752 752
 						),
753 753
 						'notice'  => array(
754
-							'text' => __( 'Notice', 'object-sync-for-salesforce' ),
754
+							'text' => __('Notice', 'object-sync-for-salesforce'),
755 755
 							'id'   => 'notice',
756 756
 							'desc' => '',
757 757
 						),
758 758
 						'debug'   => array(
759
-							'text' => __( 'Debug', 'object-sync-for-salesforce' ),
759
+							'text' => __('Debug', 'object-sync-for-salesforce'),
760 760
 							'id'   => 'debug',
761 761
 							'desc' => '',
762 762
 						),
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 				),
765 765
 			),
766 766
 			'prune_logs'            => array(
767
-				'title'    => __( 'Automatically delete old log entries?', 'object-sync-for-salesforce' ),
767
+				'title'    => __('Automatically delete old log entries?', 'object-sync-for-salesforce'),
768 768
 				'callback' => $callbacks['text'],
769 769
 				'page'     => $page,
770 770
 				'section'  => $section,
@@ -776,20 +776,20 @@  discard block
 block discarded – undo
776 776
 				),
777 777
 			),
778 778
 			'logs_how_old'          => array(
779
-				'title'    => __( 'Age to delete log entries', 'object-sync-for-salesforce' ),
779
+				'title'    => __('Age to delete log entries', 'object-sync-for-salesforce'),
780 780
 				'callback' => $callbacks['text'],
781 781
 				'page'     => $page,
782 782
 				'section'  => $section,
783 783
 				'args'     => array(
784 784
 					'type'     => 'text',
785 785
 					'validate' => 'sanitize_text_field',
786
-					'desc'     => __( 'If automatic deleting is enabled, it will affect logs this old.', 'object-sync-for-salesforce' ),
786
+					'desc'     => __('If automatic deleting is enabled, it will affect logs this old.', 'object-sync-for-salesforce'),
787 787
 					'default'  => '2 weeks',
788 788
 					'constant' => '',
789 789
 				),
790 790
 			),
791 791
 			'logs_how_often_number' => array(
792
-				'title'    => __( 'Check for old logs every', 'object-sync-for-salesforce' ),
792
+				'title'    => __('Check for old logs every', 'object-sync-for-salesforce'),
793 793
 				'callback' => $callbacks['text'],
794 794
 				'page'     => $page,
795 795
 				'section'  => $section,
@@ -802,67 +802,67 @@  discard block
 block discarded – undo
802 802
 				),
803 803
 			),
804 804
 			'logs_how_often_unit'   => array(
805
-				'title'    => __( 'Time unit', 'object-sync-for-salesforce' ),
805
+				'title'    => __('Time unit', 'object-sync-for-salesforce'),
806 806
 				'callback' => $callbacks['select'],
807 807
 				'page'     => $page,
808 808
 				'section'  => $section,
809 809
 				'args'     => array(
810 810
 					'type'     => 'select',
811 811
 					'validate' => 'sanitize_text_field',
812
-					'desc'     => __( 'These two fields are how often the site will check for logs to delete.', 'object-sync-for-salesforce' ),
812
+					'desc'     => __('These two fields are how often the site will check for logs to delete.', 'object-sync-for-salesforce'),
813 813
 					'items'    => array(
814 814
 						'minutes' => array(
815
-							'text'  => __( 'Minutes', 'object-sync-for-salesforce' ),
815
+							'text'  => __('Minutes', 'object-sync-for-salesforce'),
816 816
 							'value' => 'minutes',
817 817
 						),
818 818
 						'hours'   => array(
819
-							'text'  => __( 'Hours', 'object-sync-for-salesforce' ),
819
+							'text'  => __('Hours', 'object-sync-for-salesforce'),
820 820
 							'value' => 'hours',
821 821
 						),
822 822
 						'days'    => array(
823
-							'text'  => __( 'Days', 'object-sync-for-salesforce' ),
823
+							'text'  => __('Days', 'object-sync-for-salesforce'),
824 824
 							'value' => 'days',
825 825
 						),
826 826
 					),
827 827
 				),
828 828
 			),
829 829
 			'triggers_to_log'       => array(
830
-				'title'    => __( 'Triggers to log', 'object-sync-for-salesforce' ),
830
+				'title'    => __('Triggers to log', 'object-sync-for-salesforce'),
831 831
 				'callback' => $callbacks['checkboxes'],
832 832
 				'page'     => $page,
833 833
 				'section'  => $section,
834 834
 				'args'     => array(
835 835
 					'type'     => 'checkboxes',
836 836
 					'validate' => 'sanitize_text_field',
837
-					'desc'     => __( 'these are the triggers to log', 'object-sync-for-salesforce' ),
837
+					'desc'     => __('these are the triggers to log', 'object-sync-for-salesforce'),
838 838
 					'items'    => array(
839 839
 						$this->mappings->sync_wordpress_create => array(
840
-							'text' => __( 'WordPress create', 'object-sync-for-salesforce' ),
840
+							'text' => __('WordPress create', 'object-sync-for-salesforce'),
841 841
 							'id'   => 'wordpress_create',
842 842
 							'desc' => '',
843 843
 						),
844 844
 						$this->mappings->sync_wordpress_update => array(
845
-							'text' => __( 'WordPress update', 'object-sync-for-salesforce' ),
845
+							'text' => __('WordPress update', 'object-sync-for-salesforce'),
846 846
 							'id'   => 'wordpress_update',
847 847
 							'desc' => '',
848 848
 						),
849 849
 						$this->mappings->sync_wordpress_delete => array(
850
-							'text' => __( 'WordPress delete', 'object-sync-for-salesforce' ),
850
+							'text' => __('WordPress delete', 'object-sync-for-salesforce'),
851 851
 							'id'   => 'wordpress_delete',
852 852
 							'desc' => '',
853 853
 						),
854 854
 						$this->mappings->sync_sf_create => array(
855
-							'text' => __( 'Salesforce create', 'object-sync-for-salesforce' ),
855
+							'text' => __('Salesforce create', 'object-sync-for-salesforce'),
856 856
 							'id'   => 'sf_create',
857 857
 							'desc' => '',
858 858
 						),
859 859
 						$this->mappings->sync_sf_update => array(
860
-							'text' => __( 'Salesforce update', 'object-sync-for-salesforce' ),
860
+							'text' => __('Salesforce update', 'object-sync-for-salesforce'),
861 861
 							'id'   => 'sf_update',
862 862
 							'desc' => '',
863 863
 						),
864 864
 						$this->mappings->sync_sf_delete => array(
865
-							'text' => __( 'Salesforce delete', 'object-sync-for-salesforce' ),
865
+							'text' => __('Salesforce delete', 'object-sync-for-salesforce'),
866 866
 							'id'   => 'sf_delete',
867 867
 							'desc' => '',
868 868
 						),
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 				),
871 871
 			),
872 872
 		);
873
-		foreach ( $log_settings as $key => $attributes ) {
873
+		foreach ($log_settings as $key => $attributes) {
874 874
 			$id       = $this->option_prefix . $key;
875 875
 			$name     = $this->option_prefix . $key;
876 876
 			$title    = $attributes['title'];
@@ -886,8 +886,8 @@  discard block
 block discarded – undo
886 886
 					'name'      => $name,
887 887
 				)
888 888
 			);
889
-			add_settings_field( $id, $title, $callback, $page, $section, $args );
890
-			register_setting( $page, $id );
889
+			add_settings_field($id, $title, $callback, $page, $section, $args);
890
+			register_setting($page, $id);
891 891
 		}
892 892
 	}
893 893
 
@@ -898,69 +898,69 @@  discard block
 block discarded – undo
898 898
 	public function notices() {
899 899
 
900 900
 		// before a notice is displayed, we should make sure we are on a page related to this plugin
901
-		if ( ! isset( $_GET['page'] ) || 'object-sync-salesforce-admin' !== $_GET['page'] ) {
901
+		if ( ! isset($_GET['page']) || 'object-sync-salesforce-admin' !== $_GET['page']) {
902 902
 			return;
903 903
 		}
904 904
 
905
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
906
-		require_once plugin_dir_path( __FILE__ ) . '../classes/admin-notice.php';
905
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
906
+		require_once plugin_dir_path(__FILE__) . '../classes/admin-notice.php';
907 907
 
908 908
 		$notices = array(
909 909
 			'permission'      => array(
910 910
 				'condition'   => false === $this->check_wordpress_admin_permissions(),
911
-				'message'     => __( "Your account does not have permission to edit the Salesforce REST API plugin's settings.", 'object-sync-for-salesforce' ),
911
+				'message'     => __("Your account does not have permission to edit the Salesforce REST API plugin's settings.", 'object-sync-for-salesforce'),
912 912
 				'type'        => 'error',
913 913
 				'dismissible' => false,
914 914
 			),
915 915
 			'fieldmap'        => array(
916
-				'condition'   => isset( $get_data['transient'] ),
917
-				'message'     => __( 'Errors kept this fieldmap from being saved.', 'object-sync-for-salesforce' ),
916
+				'condition'   => isset($get_data['transient']),
917
+				'message'     => __('Errors kept this fieldmap from being saved.', 'object-sync-for-salesforce'),
918 918
 				'type'        => 'error',
919 919
 				'dismissible' => true,
920 920
 			),
921 921
 			'object_map'      => array(
922
-				'condition'   => isset( $get_data['map_transient'] ),
923
-				'message'     => __( 'Errors kept this object map from being saved.', 'object-sync-for-salesforce' ),
922
+				'condition'   => isset($get_data['map_transient']),
923
+				'message'     => __('Errors kept this object map from being saved.', 'object-sync-for-salesforce'),
924 924
 				'type'        => 'error',
925 925
 				'dismissible' => true,
926 926
 			),
927 927
 			'data_saved'      => array(
928
-				'condition'   => isset( $get_data['data_saved'] ) && 'true' === $get_data['data_saved'],
929
-				'message'     => __( 'This data was successfully saved.', 'object-sync-for-salesforce' ),
928
+				'condition'   => isset($get_data['data_saved']) && 'true' === $get_data['data_saved'],
929
+				'message'     => __('This data was successfully saved.', 'object-sync-for-salesforce'),
930 930
 				'type'        => 'success',
931 931
 				'dismissible' => true,
932 932
 			),
933 933
 			'data_save_error' => array(
934
-				'condition'   => isset( $get_data['data_saved'] ) && 'false' === $get_data['data_saved'],
935
-				'message'     => __( 'This data was not successfully saved. Try again.', 'object-sync-for-salesforce' ),
934
+				'condition'   => isset($get_data['data_saved']) && 'false' === $get_data['data_saved'],
935
+				'message'     => __('This data was not successfully saved. Try again.', 'object-sync-for-salesforce'),
936 936
 				'type'        => 'error',
937 937
 				'dismissible' => true,
938 938
 			),
939 939
 		);
940 940
 
941
-		foreach ( $notices as $key => $value ) {
941
+		foreach ($notices as $key => $value) {
942 942
 
943 943
 			$condition = $value['condition'];
944 944
 			$message   = $value['message'];
945 945
 
946
-			if ( isset( $value['dismissible'] ) ) {
946
+			if (isset($value['dismissible'])) {
947 947
 				$dismissible = $value['dismissible'];
948 948
 			} else {
949 949
 				$dismissible = false;
950 950
 			}
951 951
 
952
-			if ( isset( $value['type'] ) ) {
952
+			if (isset($value['type'])) {
953 953
 				$type = $value['type'];
954 954
 			} else {
955 955
 				$type = '';
956 956
 			}
957 957
 
958
-			if ( ! isset( $value['template'] ) ) {
958
+			if ( ! isset($value['template'])) {
959 959
 				$template = '';
960 960
 			}
961 961
 
962
-			if ( $condition ) {
963
-				new Object_Sync_Sf_Admin_Notice( $condition, $message, $dismissible, $type, $template );
962
+			if ($condition) {
963
+				new Object_Sync_Sf_Admin_Notice($condition, $message, $dismissible, $type, $template);
964 964
 			}
965 965
 		}
966 966
 
@@ -975,47 +975,47 @@  discard block
 block discarded – undo
975 975
 	* can optionally contain a type
976 976
 	* @return array $object_settings
977 977
 	*/
978
-	public function get_salesforce_object_description( $data = array() ) {
978
+	public function get_salesforce_object_description($data = array()) {
979 979
 		$ajax = false;
980
-		if ( empty( $data ) ) {
981
-			$data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
980
+		if (empty($data)) {
981
+			$data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
982 982
 			$ajax = true;
983 983
 		}
984 984
 
985 985
 		$object_description = array();
986 986
 
987
-		if ( ! empty( $data['salesforce_object'] ) ) {
988
-			$object = $this->salesforce['sfapi']->object_describe( esc_attr( $data['salesforce_object'] ) );
987
+		if ( ! empty($data['salesforce_object'])) {
988
+			$object = $this->salesforce['sfapi']->object_describe(esc_attr($data['salesforce_object']));
989 989
 
990 990
 			$object_fields        = array();
991 991
 			$include_record_types = array();
992 992
 
993 993
 			// these can come from ajax
994
-			$include = isset( $data['include'] ) ? (array) $data['include'] : array();
995
-			$include = array_map( 'esc_attr', $include );
996
-
997
-			if ( in_array( 'fields', $include, true ) || empty( $include ) ) {
998
-				$type = isset( $data['field_type'] ) ? esc_attr( $data['field_type'] ) : ''; // can come from ajax
999
-				foreach ( $object['data']['fields'] as $key => $value ) {
1000
-					if ( '' === $type || $type === $value['type'] ) {
1001
-						$object_fields[ $key ] = $value;
994
+			$include = isset($data['include']) ? (array) $data['include'] : array();
995
+			$include = array_map('esc_attr', $include);
996
+
997
+			if (in_array('fields', $include, true) || empty($include)) {
998
+				$type = isset($data['field_type']) ? esc_attr($data['field_type']) : ''; // can come from ajax
999
+				foreach ($object['data']['fields'] as $key => $value) {
1000
+					if ('' === $type || $type === $value['type']) {
1001
+						$object_fields[$key] = $value;
1002 1002
 					}
1003 1003
 				}
1004 1004
 				$object_description['fields'] = $object_fields;
1005 1005
 			}
1006 1006
 
1007
-			if ( in_array( 'recordTypeInfos', $include, true ) ) {
1008
-				if ( isset( $object['data']['recordTypeInfos'] ) && count( $object['data']['recordTypeInfos'] ) > 1 ) {
1009
-					foreach ( $object['data']['recordTypeInfos'] as $type ) {
1010
-						$object_record_types[ $type['recordTypeId'] ] = $type['name'];
1007
+			if (in_array('recordTypeInfos', $include, true)) {
1008
+				if (isset($object['data']['recordTypeInfos']) && count($object['data']['recordTypeInfos']) > 1) {
1009
+					foreach ($object['data']['recordTypeInfos'] as $type) {
1010
+						$object_record_types[$type['recordTypeId']] = $type['name'];
1011 1011
 					}
1012 1012
 					$object_description['recordTypeInfos'] = $object_record_types;
1013 1013
 				}
1014 1014
 			}
1015 1015
 		}
1016 1016
 
1017
-		if ( true === $ajax ) {
1018
-			wp_send_json_success( $object_description );
1017
+		if (true === $ajax) {
1018
+			wp_send_json_success($object_description);
1019 1019
 		} else {
1020 1020
 			return $object_description;
1021 1021
 		}
@@ -1029,23 +1029,23 @@  discard block
 block discarded – undo
1029 1029
 	* can optionally contain a type for the field
1030 1030
 	* @return array $object_fields
1031 1031
 	*/
1032
-	public function get_salesforce_object_fields( $data = array() ) {
1032
+	public function get_salesforce_object_fields($data = array()) {
1033 1033
 
1034
-		if ( ! empty( $data['salesforce_object'] ) ) {
1035
-			$object               = $this->salesforce['sfapi']->object_describe( esc_attr( $data['salesforce_object'] ) );
1034
+		if ( ! empty($data['salesforce_object'])) {
1035
+			$object               = $this->salesforce['sfapi']->object_describe(esc_attr($data['salesforce_object']));
1036 1036
 			$object_fields        = array();
1037
-			$type                 = isset( $data['type'] ) ? esc_attr( $data['type'] ) : '';
1038
-			$include_record_types = isset( $data['include_record_types'] ) ? esc_attr( $data['include_record_types'] ) : false;
1039
-			foreach ( $object['data']['fields'] as $key => $value ) {
1040
-				if ( '' === $type || $type === $value['type'] ) {
1041
-					$object_fields[ $key ] = $value;
1037
+			$type                 = isset($data['type']) ? esc_attr($data['type']) : '';
1038
+			$include_record_types = isset($data['include_record_types']) ? esc_attr($data['include_record_types']) : false;
1039
+			foreach ($object['data']['fields'] as $key => $value) {
1040
+				if ('' === $type || $type === $value['type']) {
1041
+					$object_fields[$key] = $value;
1042 1042
 				}
1043 1043
 			}
1044
-			if ( true === $include_record_types ) {
1044
+			if (true === $include_record_types) {
1045 1045
 				$object_record_types = array();
1046
-				if ( isset( $object['data']['recordTypeInfos'] ) && count( $object['data']['recordTypeInfos'] ) > 1 ) {
1047
-					foreach ( $object['data']['recordTypeInfos'] as $type ) {
1048
-						$object_record_types[ $type['recordTypeId'] ] = $type['name'];
1046
+				if (isset($object['data']['recordTypeInfos']) && count($object['data']['recordTypeInfos']) > 1) {
1047
+					foreach ($object['data']['recordTypeInfos'] as $type) {
1048
+						$object_record_types[$type['recordTypeId']] = $type['name'];
1049 1049
 					}
1050 1050
 				}
1051 1051
 			}
@@ -1062,18 +1062,18 @@  discard block
 block discarded – undo
1062 1062
 	* @param string $wordpress_object
1063 1063
 	* @return array $object_fields
1064 1064
 	*/
1065
-	public function get_wordpress_object_fields( $wordpress_object = '' ) {
1065
+	public function get_wordpress_object_fields($wordpress_object = '') {
1066 1066
 		$ajax      = false;
1067
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1068
-		if ( empty( $wordpress_object ) ) {
1069
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1067
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1068
+		if (empty($wordpress_object)) {
1069
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1070 1070
 			$ajax             = true;
1071 1071
 		}
1072 1072
 
1073
-		$object_fields = $this->wordpress->get_wordpress_object_fields( $wordpress_object );
1073
+		$object_fields = $this->wordpress->get_wordpress_object_fields($wordpress_object);
1074 1074
 
1075
-		if ( true === $ajax ) {
1076
-			wp_send_json_success( $object_fields );
1075
+		if (true === $ajax) {
1076
+			wp_send_json_success($object_fields);
1077 1077
 		} else {
1078 1078
 			return $object_fields;
1079 1079
 		}
@@ -1087,24 +1087,24 @@  discard block
 block discarded – undo
1087 1087
 	* @param string $salesforce_object
1088 1088
 	* @return array $object_fields
1089 1089
 	*/
1090
-	public function get_wp_sf_object_fields( $wordpress_object = '', $salesforce = '' ) {
1091
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1092
-		if ( empty( $wordpress_object ) ) {
1093
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1090
+	public function get_wp_sf_object_fields($wordpress_object = '', $salesforce = '') {
1091
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1092
+		if (empty($wordpress_object)) {
1093
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1094 1094
 		}
1095
-		if ( empty( $salesforce_object ) ) {
1096
-			$salesforce_object = isset( $post_data['salesforce_object'] ) ? sanitize_text_field( wp_unslash( $post_data['salesforce_object'] ) ) : '';
1095
+		if (empty($salesforce_object)) {
1096
+			$salesforce_object = isset($post_data['salesforce_object']) ? sanitize_text_field(wp_unslash($post_data['salesforce_object'])) : '';
1097 1097
 		}
1098 1098
 
1099
-		$object_fields['wordpress']  = $this->get_wordpress_object_fields( $wordpress_object );
1099
+		$object_fields['wordpress']  = $this->get_wordpress_object_fields($wordpress_object);
1100 1100
 		$object_fields['salesforce'] = $this->get_salesforce_object_fields(
1101 1101
 			array(
1102 1102
 				'salesforce_object' => $salesforce_object,
1103 1103
 			)
1104 1104
 		);
1105 1105
 
1106
-		if ( ! empty( $post_data ) ) {
1107
-			wp_send_json_success( $object_fields );
1106
+		if ( ! empty($post_data)) {
1107
+			wp_send_json_success($object_fields);
1108 1108
 		} else {
1109 1109
 			return $object_fields;
1110 1110
 		}
@@ -1117,17 +1117,17 @@  discard block
 block discarded – undo
1117 1117
 	* @param string $wordpress_object
1118 1118
 	* @param int $wordpress_id
1119 1119
 	*/
1120
-	public function push_to_salesforce( $wordpress_object = '', $wordpress_id = '' ) {
1121
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1122
-		if ( empty( $wordpress_object ) && empty( $wordpress_id ) ) {
1123
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1124
-			$wordpress_id     = isset( $post_data['wordpress_id'] ) ? absint( $post_data['wordpress_id'] ) : '';
1120
+	public function push_to_salesforce($wordpress_object = '', $wordpress_id = '') {
1121
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1122
+		if (empty($wordpress_object) && empty($wordpress_id)) {
1123
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1124
+			$wordpress_id     = isset($post_data['wordpress_id']) ? absint($post_data['wordpress_id']) : '';
1125 1125
 		}
1126
-		$data   = $this->wordpress->get_wordpress_object_data( $wordpress_object, $wordpress_id );
1127
-		$result = $this->push->manual_object_update( $data, $wordpress_object );
1126
+		$data   = $this->wordpress->get_wordpress_object_data($wordpress_object, $wordpress_id);
1127
+		$result = $this->push->manual_object_update($data, $wordpress_object);
1128 1128
 
1129
-		if ( ! empty( $post_data['wordpress_object'] ) && ! empty( $post_data['wordpress_id'] ) ) {
1130
-			wp_send_json_success( $result );
1129
+		if ( ! empty($post_data['wordpress_object']) && ! empty($post_data['wordpress_id'])) {
1130
+			wp_send_json_success($result);
1131 1131
 		} else {
1132 1132
 			return $result;
1133 1133
 		}
@@ -1141,16 +1141,16 @@  discard block
 block discarded – undo
1141 1141
 	* @param string $salesforce_id
1142 1142
 	* @param string $wordpress_object
1143 1143
 	*/
1144
-	public function pull_from_salesforce( $salesforce_id = '', $wordpress_object = '' ) {
1145
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1146
-		if ( empty( $wordpress_object ) && empty( $salesforce_id ) ) {
1147
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1148
-			$salesforce_id    = isset( $post_data['salesforce_id'] ) ? sanitize_text_field( wp_unslash( $post_data['salesforce_id'] ) ) : '';
1149
-		}
1150
-		$type   = $this->salesforce['sfapi']->get_sobject_type( $salesforce_id );
1151
-		$result = $this->pull->manual_pull( $type, $salesforce_id, $wordpress_object ); // we want the wp object to make sure we get the right fieldmap
1152
-		if ( ! empty( $post_data ) ) {
1153
-			wp_send_json_success( $result );
1144
+	public function pull_from_salesforce($salesforce_id = '', $wordpress_object = '') {
1145
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1146
+		if (empty($wordpress_object) && empty($salesforce_id)) {
1147
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1148
+			$salesforce_id    = isset($post_data['salesforce_id']) ? sanitize_text_field(wp_unslash($post_data['salesforce_id'])) : '';
1149
+		}
1150
+		$type   = $this->salesforce['sfapi']->get_sobject_type($salesforce_id);
1151
+		$result = $this->pull->manual_pull($type, $salesforce_id, $wordpress_object); // we want the wp object to make sure we get the right fieldmap
1152
+		if ( ! empty($post_data)) {
1153
+			wp_send_json_success($result);
1154 1154
 		} else {
1155 1155
 			return $result;
1156 1156
 		}
@@ -1162,18 +1162,18 @@  discard block
 block discarded – undo
1162 1162
 	*
1163 1163
 	* @param int $mapping_id
1164 1164
 	*/
1165
-	public function refresh_mapped_data( $mapping_id = '' ) {
1166
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1167
-		if ( empty( $mapping_id ) ) {
1168
-			$mapping_id = isset( $post_data['mapping_id'] ) ? absint( $post_data['mapping_id'] ) : '';
1165
+	public function refresh_mapped_data($mapping_id = '') {
1166
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1167
+		if (empty($mapping_id)) {
1168
+			$mapping_id = isset($post_data['mapping_id']) ? absint($post_data['mapping_id']) : '';
1169 1169
 		}
1170 1170
 		$result = $this->mappings->get_object_maps(
1171 1171
 			array(
1172 1172
 				'id' => $mapping_id,
1173 1173
 			)
1174 1174
 		);
1175
-		if ( ! empty( $post_data ) ) {
1176
-			wp_send_json_success( $result );
1175
+		if ( ! empty($post_data)) {
1176
+			wp_send_json_success($result);
1177 1177
 		} else {
1178 1178
 			return $result;
1179 1179
 		}
@@ -1189,47 +1189,47 @@  discard block
 block discarded – undo
1189 1189
 	*/
1190 1190
 	public function prepare_fieldmap_data() {
1191 1191
 		$error     = false;
1192
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1193
-		$cachekey  = md5( wp_json_encode( $post_data ) );
1192
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1193
+		$cachekey  = md5(wp_json_encode($post_data));
1194 1194
 
1195
-		if ( ! isset( $post_data['label'] ) || ! isset( $post_data['salesforce_object'] ) || ! isset( $post_data['wordpress_object'] ) ) {
1195
+		if ( ! isset($post_data['label']) || ! isset($post_data['salesforce_object']) || ! isset($post_data['wordpress_object'])) {
1196 1196
 			$error = true;
1197 1197
 		}
1198
-		if ( true === $error ) {
1199
-			$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1200
-			if ( '' !== $cachekey ) {
1201
-				$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&transient=' . $cachekey;
1198
+		if (true === $error) {
1199
+			$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1200
+			if ('' !== $cachekey) {
1201
+				$url = esc_url_raw($post_data['redirect_url_error']) . '&transient=' . $cachekey;
1202 1202
 			}
1203 1203
 		} else { // there are no errors
1204 1204
 			// send the row to the fieldmap class
1205 1205
 			// if it is add or clone, use the create method
1206
-			$method            = esc_attr( $post_data['method'] );
1206
+			$method            = esc_attr($post_data['method']);
1207 1207
 			$salesforce_fields = $this->get_salesforce_object_fields(
1208 1208
 				array(
1209 1209
 					'salesforce_object' => $post_data['salesforce_object'],
1210 1210
 				)
1211 1211
 			);
1212
-			$wordpress_fields  = $this->get_wordpress_object_fields( $post_data['wordpress_object'] );
1213
-			if ( 'add' === $method || 'clone' === $method ) {
1214
-				$result = $this->mappings->create_fieldmap( $post_data, $wordpress_fields, $salesforce_fields );
1215
-			} elseif ( 'edit' === $method ) { // if it is edit, use the update method
1216
-				$id     = esc_attr( $post_data['id'] );
1217
-				$result = $this->mappings->update_fieldmap( $post_data, $wordpress_fields, $salesforce_fields, $id );
1212
+			$wordpress_fields = $this->get_wordpress_object_fields($post_data['wordpress_object']);
1213
+			if ('add' === $method || 'clone' === $method) {
1214
+				$result = $this->mappings->create_fieldmap($post_data, $wordpress_fields, $salesforce_fields);
1215
+			} elseif ('edit' === $method) { // if it is edit, use the update method
1216
+				$id     = esc_attr($post_data['id']);
1217
+				$result = $this->mappings->update_fieldmap($post_data, $wordpress_fields, $salesforce_fields, $id);
1218 1218
 			}
1219
-			if ( false === $result ) { // if the database didn't save, it's still an error
1220
-				$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1221
-				if ( '' !== $cachekey ) {
1222
-					$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&transient=' . $cachekey;
1219
+			if (false === $result) { // if the database didn't save, it's still an error
1220
+				$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1221
+				if ('' !== $cachekey) {
1222
+					$url = esc_url_raw($post_data['redirect_url_error']) . '&transient=' . $cachekey;
1223 1223
 				}
1224 1224
 			} else {
1225
-				if ( isset( $post_data['transient'] ) ) { // there was previously an error saved. can delete it now.
1226
-					$this->sfwp_transients->delete( esc_attr( $post_data['map_transient'] ) );
1225
+				if (isset($post_data['transient'])) { // there was previously an error saved. can delete it now.
1226
+					$this->sfwp_transients->delete(esc_attr($post_data['map_transient']));
1227 1227
 				}
1228 1228
 				// then send the user to the list of fieldmaps
1229
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1229
+				$url = esc_url_raw($post_data['redirect_url_success']);
1230 1230
 			}
1231 1231
 		}
1232
-		wp_safe_redirect( $url );
1232
+		wp_safe_redirect($url);
1233 1233
 		exit();
1234 1234
 	}
1235 1235
 
@@ -1241,15 +1241,15 @@  discard block
 block discarded – undo
1241 1241
 	*
1242 1242
 	*/
1243 1243
 	public function delete_fieldmap() {
1244
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1245
-		if ( $post_data['id'] ) {
1246
-			$result = $this->mappings->delete_fieldmap( $post_data['id'] );
1247
-			if ( true === $result ) {
1248
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1244
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1245
+		if ($post_data['id']) {
1246
+			$result = $this->mappings->delete_fieldmap($post_data['id']);
1247
+			if (true === $result) {
1248
+				$url = esc_url_raw($post_data['redirect_url_success']);
1249 1249
 			} else {
1250
-				$url = esc_url_raw( $post_data['redirect_url_error'] . '&id=' . $post_data['id'] );
1250
+				$url = esc_url_raw($post_data['redirect_url_error'] . '&id=' . $post_data['id']);
1251 1251
 			}
1252
-			wp_safe_redirect( $url );
1252
+			wp_safe_redirect($url);
1253 1253
 			exit();
1254 1254
 		}
1255 1255
 	}
@@ -1264,38 +1264,38 @@  discard block
 block discarded – undo
1264 1264
 	*/
1265 1265
 	public function prepare_object_map_data() {
1266 1266
 		$error     = false;
1267
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1268
-		$cachekey  = md5( wp_json_encode( $post_data ) );
1267
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1268
+		$cachekey  = md5(wp_json_encode($post_data));
1269 1269
 
1270
-		if ( ! isset( $post_data['wordpress_id'] ) || ! isset( $post_data['salesforce_id'] ) ) {
1270
+		if ( ! isset($post_data['wordpress_id']) || ! isset($post_data['salesforce_id'])) {
1271 1271
 			$error = true;
1272 1272
 		}
1273
-		if ( true === $error ) {
1274
-			$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1275
-			if ( '' !== $cachekey ) {
1276
-				$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&map_transient=' . $cachekey;
1273
+		if (true === $error) {
1274
+			$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1275
+			if ('' !== $cachekey) {
1276
+				$url = esc_url_raw($post_data['redirect_url_error']) . '&map_transient=' . $cachekey;
1277 1277
 			}
1278 1278
 		} else { // there are no errors
1279 1279
 			// send the row to the object map class
1280
-			$method = esc_attr( $post_data['method'] );
1281
-			if ( 'edit' === $method ) { // if it is edit, use the update method
1282
-				$id     = esc_attr( $post_data['id'] );
1283
-				$result = $this->mappings->update_object_map( $post_data, $id );
1280
+			$method = esc_attr($post_data['method']);
1281
+			if ('edit' === $method) { // if it is edit, use the update method
1282
+				$id     = esc_attr($post_data['id']);
1283
+				$result = $this->mappings->update_object_map($post_data, $id);
1284 1284
 			}
1285
-			if ( false === $result ) { // if the database didn't save, it's still an error
1286
-				$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1287
-				if ( '' !== $cachekey ) {
1288
-					$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&map_transient=' . $cachekey;
1285
+			if (false === $result) { // if the database didn't save, it's still an error
1286
+				$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1287
+				if ('' !== $cachekey) {
1288
+					$url = esc_url_raw($post_data['redirect_url_error']) . '&map_transient=' . $cachekey;
1289 1289
 				}
1290 1290
 			} else {
1291
-				if ( isset( $post_data['map_transient'] ) ) { // there was previously an error saved. can delete it now.
1292
-					$this->sfwp_transients->delete( esc_attr( $post_data['map_transient'] ) );
1291
+				if (isset($post_data['map_transient'])) { // there was previously an error saved. can delete it now.
1292
+					$this->sfwp_transients->delete(esc_attr($post_data['map_transient']));
1293 1293
 				}
1294 1294
 				// then send the user to the success redirect url
1295
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1295
+				$url = esc_url_raw($post_data['redirect_url_success']);
1296 1296
 			}
1297 1297
 		}
1298
-		wp_safe_redirect( $url );
1298
+		wp_safe_redirect($url);
1299 1299
 		exit();
1300 1300
 	}
1301 1301
 
@@ -1307,15 +1307,15 @@  discard block
 block discarded – undo
1307 1307
 	*
1308 1308
 	*/
1309 1309
 	public function delete_object_map() {
1310
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1311
-		if ( $post_data['id'] ) {
1312
-			$result = $this->mappings->delete_object_map( $post_data['id'] );
1313
-			if ( true === $result ) {
1314
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1310
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1311
+		if ($post_data['id']) {
1312
+			$result = $this->mappings->delete_object_map($post_data['id']);
1313
+			if (true === $result) {
1314
+				$url = esc_url_raw($post_data['redirect_url_success']);
1315 1315
 			} else {
1316
-				$url = esc_url_raw( $post_data['redirect_url_error'] . '&id=' . $post_data['id'] );
1316
+				$url = esc_url_raw($post_data['redirect_url_error'] . '&id=' . $post_data['id']);
1317 1317
 			}
1318
-			wp_safe_redirect( $url );
1318
+			wp_safe_redirect($url);
1319 1319
 			exit();
1320 1320
 		}
1321 1321
 	}
@@ -1326,95 +1326,95 @@  discard block
 block discarded – undo
1326 1326
 	*/
1327 1327
 	public function import_json_file() {
1328 1328
 
1329
-		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import' ) ) {
1329
+		if ( ! wp_verify_nonce($_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import')) {
1330 1330
 			return;
1331 1331
 		}
1332
-		if ( ! current_user_can( 'manage_options' ) ) {
1332
+		if ( ! current_user_can('manage_options')) {
1333 1333
 			return;
1334 1334
 		}
1335 1335
 		$path      = $_FILES['import_file']['name'];
1336
-		$extension = pathinfo( $path, PATHINFO_EXTENSION );
1337
-		if ( 'json' !== $extension ) {
1338
-			wp_die( __( 'Please upload a valid .json file' ) );
1336
+		$extension = pathinfo($path, PATHINFO_EXTENSION);
1337
+		if ('json' !== $extension) {
1338
+			wp_die(__('Please upload a valid .json file'));
1339 1339
 		}
1340 1340
 
1341 1341
 		$import_file = $_FILES['import_file']['tmp_name'];
1342
-		if ( empty( $import_file ) ) {
1343
-			wp_die( __( 'Please upload a file to import' ) );
1342
+		if (empty($import_file)) {
1343
+			wp_die(__('Please upload a file to import'));
1344 1344
 		}
1345 1345
 
1346 1346
 		// Retrieve the data from the file and convert the json object to an array.
1347
-		$data = (array) json_decode( file_get_contents( $import_file ), true );
1347
+		$data = (array) json_decode(file_get_contents($import_file), true);
1348 1348
 
1349 1349
 		// if there is only one object map, fix the array
1350
-		if ( isset( $data['object_maps'] ) ) {
1351
-			if ( count( $data['object_maps'] ) === count( $data['object_maps'], COUNT_RECURSIVE ) ) {
1352
-				$data['object_maps'] = array( 0 => $data['object_maps'] );
1350
+		if (isset($data['object_maps'])) {
1351
+			if (count($data['object_maps']) === count($data['object_maps'], COUNT_RECURSIVE)) {
1352
+				$data['object_maps'] = array(0 => $data['object_maps']);
1353 1353
 			}
1354 1354
 		}
1355 1355
 
1356
-		$overwrite = isset( $_POST['overwrite'] ) ? esc_attr( $_POST['overwrite'] ) : '';
1357
-		if ( '1' === $overwrite ) {
1358
-			if ( isset( $data['fieldmaps'] ) ) {
1356
+		$overwrite = isset($_POST['overwrite']) ? esc_attr($_POST['overwrite']) : '';
1357
+		if ('1' === $overwrite) {
1358
+			if (isset($data['fieldmaps'])) {
1359 1359
 				$fieldmaps = $this->mappings->get_fieldmaps();
1360
-				foreach ( $fieldmaps as $fieldmap ) {
1360
+				foreach ($fieldmaps as $fieldmap) {
1361 1361
 					$id     = $fieldmap['id'];
1362
-					$delete = $this->mappings->delete_fieldmap( $id );
1362
+					$delete = $this->mappings->delete_fieldmap($id);
1363 1363
 				}
1364 1364
 			}
1365
-			if ( isset( $data['object_maps'] ) ) {
1365
+			if (isset($data['object_maps'])) {
1366 1366
 				$object_maps = $this->mappings->get_object_maps();
1367 1367
 
1368 1368
 				// if there is only one existing object map, fix the array
1369
-				if ( count( $object_maps ) === count( $object_maps, COUNT_RECURSIVE ) ) {
1370
-					$object_maps = array( 0 => $object_maps );
1369
+				if (count($object_maps) === count($object_maps, COUNT_RECURSIVE)) {
1370
+					$object_maps = array(0 => $object_maps);
1371 1371
 				}
1372 1372
 
1373
-				foreach ( $object_maps as $object_map ) {
1373
+				foreach ($object_maps as $object_map) {
1374 1374
 					$id     = $object_map['id'];
1375
-					$delete = $this->mappings->delete_object_map( $id );
1375
+					$delete = $this->mappings->delete_object_map($id);
1376 1376
 				}
1377 1377
 			}
1378
-			if ( isset( $data['plugin_settings'] ) ) {
1379
-				foreach ( $data['plugin_settings'] as $key => $value ) {
1380
-					delete_option( $value['option_name'] );
1378
+			if (isset($data['plugin_settings'])) {
1379
+				foreach ($data['plugin_settings'] as $key => $value) {
1380
+					delete_option($value['option_name']);
1381 1381
 				}
1382 1382
 			}
1383 1383
 		}
1384 1384
 
1385 1385
 		$success = true;
1386 1386
 
1387
-		if ( isset( $data['fieldmaps'] ) ) {
1388
-			foreach ( $data['fieldmaps'] as $fieldmap ) {
1389
-				unset( $fieldmap['id'] );
1390
-				$create = $this->mappings->create_fieldmap( $fieldmap );
1391
-				if ( false === $create ) {
1387
+		if (isset($data['fieldmaps'])) {
1388
+			foreach ($data['fieldmaps'] as $fieldmap) {
1389
+				unset($fieldmap['id']);
1390
+				$create = $this->mappings->create_fieldmap($fieldmap);
1391
+				if (false === $create) {
1392 1392
 					$success = false;
1393 1393
 				}
1394 1394
 			}
1395 1395
 		}
1396 1396
 
1397
-		if ( isset( $data['object_maps'] ) ) {
1398
-			foreach ( $data['object_maps'] as $object_map ) {
1399
-				unset( $object_map['id'] );
1400
-				$create = $this->mappings->create_object_map( $object_map );
1401
-				if ( false === $create ) {
1397
+		if (isset($data['object_maps'])) {
1398
+			foreach ($data['object_maps'] as $object_map) {
1399
+				unset($object_map['id']);
1400
+				$create = $this->mappings->create_object_map($object_map);
1401
+				if (false === $create) {
1402 1402
 					$success = false;
1403 1403
 				}
1404 1404
 			}
1405 1405
 		}
1406 1406
 
1407
-		if ( isset( $data['plugin_settings'] ) ) {
1408
-			foreach ( $data['plugin_settings'] as $key => $value ) {
1409
-				update_option( $value['option_name'], maybe_unserialize( $value['option_value'] ), $value['autoload'] );
1407
+		if (isset($data['plugin_settings'])) {
1408
+			foreach ($data['plugin_settings'] as $key => $value) {
1409
+				update_option($value['option_name'], maybe_unserialize($value['option_value']), $value['autoload']);
1410 1410
 			}
1411 1411
 		}
1412 1412
 
1413
-		if ( true === $success ) {
1414
-			wp_safe_redirect( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=true' ) );
1413
+		if (true === $success) {
1414
+			wp_safe_redirect(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=true'));
1415 1415
 			exit;
1416 1416
 		} else {
1417
-			wp_safe_redirect( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=false' ) );
1417
+			wp_safe_redirect(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=false'));
1418 1418
 			exit;
1419 1419
 		}
1420 1420
 
@@ -1426,28 +1426,28 @@  discard block
 block discarded – undo
1426 1426
 	*/
1427 1427
 	public function export_json_file() {
1428 1428
 
1429
-		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_export'], 'object_sync_for_salesforce_nonce_export' ) ) {
1429
+		if ( ! wp_verify_nonce($_POST['object_sync_for_salesforce_nonce_export'], 'object_sync_for_salesforce_nonce_export')) {
1430 1430
 			return;
1431 1431
 		}
1432
-		if ( ! current_user_can( 'manage_options' ) ) {
1432
+		if ( ! current_user_can('manage_options')) {
1433 1433
 			return;
1434 1434
 		}
1435
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1435
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1436 1436
 		$export    = array();
1437
-		if ( in_array( 'fieldmaps', $post_data['export'] ) ) {
1437
+		if (in_array('fieldmaps', $post_data['export'])) {
1438 1438
 			$export['fieldmaps'] = $this->mappings->get_fieldmaps();
1439 1439
 		}
1440
-		if ( in_array( 'object_maps', $post_data['export'] ) ) {
1440
+		if (in_array('object_maps', $post_data['export'])) {
1441 1441
 			$export['object_maps'] = $this->mappings->get_object_maps();
1442 1442
 		}
1443
-		if ( in_array( 'plugin_settings', $post_data['export'] ) ) {
1444
-			$export['plugin_settings'] = $this->wpdb->get_results( 'SELECT * FROM ' . $this->wpdb->prefix . 'options' . ' WHERE option_name like "' . $this->option_prefix . '%"', ARRAY_A );
1443
+		if (in_array('plugin_settings', $post_data['export'])) {
1444
+			$export['plugin_settings'] = $this->wpdb->get_results('SELECT * FROM ' . $this->wpdb->prefix . 'options' . ' WHERE option_name like "' . $this->option_prefix . '%"', ARRAY_A);
1445 1445
 		}
1446 1446
 		nocache_headers();
1447
-		header( 'Content-Type: application/json; charset=utf-8' );
1448
-		header( 'Content-Disposition: attachment; filename=object-sync-for-salesforce-data-export-' . date( 'm-d-Y' ) . '.json' );
1449
-		header( 'Expires: 0' );
1450
-		echo wp_json_encode( $export );
1447
+		header('Content-Type: application/json; charset=utf-8');
1448
+		header('Content-Disposition: attachment; filename=object-sync-for-salesforce-data-export-' . date('m-d-Y') . '.json');
1449
+		header('Expires: 0');
1450
+		echo wp_json_encode($export);
1451 1451
 		exit;
1452 1452
 	}
1453 1453
 
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 	*
1457 1457
 	* @param array $args
1458 1458
 	*/
1459
-	public function display_input_field( $args ) {
1459
+	public function display_input_field($args) {
1460 1460
 		$type    = $args['type'];
1461 1461
 		$id      = $args['label_for'];
1462 1462
 		$name    = $args['name'];
@@ -1465,38 +1465,38 @@  discard block
 block discarded – undo
1465 1465
 
1466 1466
 		$class = 'regular-text';
1467 1467
 
1468
-		if ( 'checkbox' === $type ) {
1468
+		if ('checkbox' === $type) {
1469 1469
 			$class = 'checkbox';
1470 1470
 		}
1471 1471
 
1472
-		if ( ! isset( $args['constant'] ) || ! defined( $args['constant'] ) ) {
1473
-			$value = esc_attr( get_option( $id, '' ) );
1474
-			if ( 'checkbox' === $type ) {
1475
-				if ( '1' === $value ) {
1472
+		if ( ! isset($args['constant']) || ! defined($args['constant'])) {
1473
+			$value = esc_attr(get_option($id, ''));
1474
+			if ('checkbox' === $type) {
1475
+				if ('1' === $value) {
1476 1476
 					$checked = 'checked ';
1477 1477
 				}
1478 1478
 				$value = 1;
1479 1479
 			}
1480
-			if ( '' === $value && isset( $args['default'] ) && '' !== $args['default'] ) {
1480
+			if ('' === $value && isset($args['default']) && '' !== $args['default']) {
1481 1481
 				$value = $args['default'];
1482 1482
 			}
1483 1483
 
1484
-			echo sprintf( '<input type="%1$s" value="%2$s" name="%3$s" id="%4$s" class="%5$s"%6$s>',
1485
-				esc_attr( $type ),
1486
-				esc_attr( $value ),
1487
-				esc_attr( $name ),
1488
-				esc_attr( $id ),
1489
-				sanitize_html_class( $class . esc_html( ' code' ) ),
1490
-				esc_html( $checked )
1484
+			echo sprintf('<input type="%1$s" value="%2$s" name="%3$s" id="%4$s" class="%5$s"%6$s>',
1485
+				esc_attr($type),
1486
+				esc_attr($value),
1487
+				esc_attr($name),
1488
+				esc_attr($id),
1489
+				sanitize_html_class($class . esc_html(' code')),
1490
+				esc_html($checked)
1491 1491
 			);
1492
-			if ( '' !== $desc ) {
1493
-				echo sprintf( '<p class="description">%1$s</p>',
1494
-					esc_html( $desc )
1492
+			if ('' !== $desc) {
1493
+				echo sprintf('<p class="description">%1$s</p>',
1494
+					esc_html($desc)
1495 1495
 				);
1496 1496
 			}
1497 1497
 		} else {
1498
-			echo sprintf( '<p><code>%1$s</code></p>',
1499
-				esc_html__( 'Defined in wp-config.php', 'object-sync-for-salesforce' )
1498
+			echo sprintf('<p><code>%1$s</code></p>',
1499
+				esc_html__('Defined in wp-config.php', 'object-sync-for-salesforce')
1500 1500
 			);
1501 1501
 		}
1502 1502
 	}
@@ -1507,33 +1507,33 @@  discard block
 block discarded – undo
1507 1507
 	*
1508 1508
 	* @param array $args
1509 1509
 	*/
1510
-	public function display_checkboxes( $args ) {
1510
+	public function display_checkboxes($args) {
1511 1511
 		$type    = 'checkbox';
1512 1512
 		$name    = $args['name'];
1513
-		$options = get_option( $name, array() );
1514
-		foreach ( $args['items'] as $key => $value ) {
1513
+		$options = get_option($name, array());
1514
+		foreach ($args['items'] as $key => $value) {
1515 1515
 			$text    = $value['text'];
1516 1516
 			$id      = $value['id'];
1517 1517
 			$desc    = $value['desc'];
1518 1518
 			$checked = '';
1519
-			if ( is_array( $options ) && in_array( (string) $key, $options, true ) ) {
1519
+			if (is_array($options) && in_array((string) $key, $options, true)) {
1520 1520
 				$checked = 'checked';
1521
-			} elseif ( is_array( $options ) && empty( $options ) ) {
1522
-				if ( isset( $value['default'] ) && true === $value['default'] ) {
1521
+			} elseif (is_array($options) && empty($options)) {
1522
+				if (isset($value['default']) && true === $value['default']) {
1523 1523
 					$checked = 'checked';
1524 1524
 				}
1525 1525
 			}
1526
-			echo sprintf( '<div class="checkbox"><label><input type="%1$s" value="%2$s" name="%3$s[]" id="%4$s"%5$s>%6$s</label></div>',
1527
-				esc_attr( $type ),
1528
-				esc_attr( $key ),
1529
-				esc_attr( $name ),
1530
-				esc_attr( $id ),
1531
-				esc_html( $checked ),
1532
-				esc_html( $text )
1526
+			echo sprintf('<div class="checkbox"><label><input type="%1$s" value="%2$s" name="%3$s[]" id="%4$s"%5$s>%6$s</label></div>',
1527
+				esc_attr($type),
1528
+				esc_attr($key),
1529
+				esc_attr($name),
1530
+				esc_attr($id),
1531
+				esc_html($checked),
1532
+				esc_html($text)
1533 1533
 			);
1534
-			if ( '' !== $desc ) {
1535
-				echo sprintf( '<p class="description">%1$s</p>',
1536
-					esc_html( $desc )
1534
+			if ('' !== $desc) {
1535
+				echo sprintf('<p class="description">%1$s</p>',
1536
+					esc_html($desc)
1537 1537
 				);
1538 1538
 			}
1539 1539
 		}
@@ -1544,44 +1544,44 @@  discard block
 block discarded – undo
1544 1544
 	*
1545 1545
 	* @param array $args
1546 1546
 	*/
1547
-	public function display_select( $args ) {
1547
+	public function display_select($args) {
1548 1548
 		$type = $args['type'];
1549 1549
 		$id   = $args['label_for'];
1550 1550
 		$name = $args['name'];
1551 1551
 		$desc = $args['desc'];
1552
-		if ( ! isset( $args['constant'] ) || ! defined( $args['constant'] ) ) {
1553
-			$current_value = get_option( $name );
1552
+		if ( ! isset($args['constant']) || ! defined($args['constant'])) {
1553
+			$current_value = get_option($name);
1554 1554
 
1555
-			echo sprintf( '<div class="select"><select id="%1$s" name="%2$s"><option value="">- ' . __( 'Select one', 'object-sync-for-salesforce' ) . ' -</option>',
1556
-				esc_attr( $id ),
1557
-				esc_attr( $name )
1555
+			echo sprintf('<div class="select"><select id="%1$s" name="%2$s"><option value="">- ' . __('Select one', 'object-sync-for-salesforce') . ' -</option>',
1556
+				esc_attr($id),
1557
+				esc_attr($name)
1558 1558
 			);
1559 1559
 
1560
-			foreach ( $args['items'] as $key => $value ) {
1560
+			foreach ($args['items'] as $key => $value) {
1561 1561
 				$text     = $value['text'];
1562 1562
 				$value    = $value['value'];
1563 1563
 				$selected = '';
1564
-				if ( $key === $current_value || $value === $current_value ) {
1564
+				if ($key === $current_value || $value === $current_value) {
1565 1565
 					$selected = ' selected';
1566 1566
 				}
1567 1567
 
1568
-				echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
1569
-					esc_attr( $value ),
1570
-					esc_attr( $selected ),
1571
-					esc_html( $text )
1568
+				echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
1569
+					esc_attr($value),
1570
+					esc_attr($selected),
1571
+					esc_html($text)
1572 1572
 				);
1573 1573
 
1574 1574
 			}
1575 1575
 			echo '</select>';
1576
-			if ( '' !== $desc ) {
1577
-				echo sprintf( '<p class="description">%1$s</p>',
1578
-					esc_html( $desc )
1576
+			if ('' !== $desc) {
1577
+				echo sprintf('<p class="description">%1$s</p>',
1578
+					esc_html($desc)
1579 1579
 				);
1580 1580
 			}
1581 1581
 			echo '</div>';
1582 1582
 		} else {
1583
-			echo sprintf( '<p><code>%1$s</code></p>',
1584
-				esc_html__( 'Defined in wp-config.php', 'object-sync-for-salesforce' )
1583
+			echo sprintf('<p><code>%1$s</code></p>',
1584
+				esc_html__('Defined in wp-config.php', 'object-sync-for-salesforce')
1585 1585
 			);
1586 1586
 		}
1587 1587
 	}
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
 	private function version_options() {
1595 1595
 		$versions = $this->salesforce['sfapi']->get_api_versions();
1596 1596
 		$args     = array();
1597
-		foreach ( $versions['data'] as $key => $value ) {
1597
+		foreach ($versions['data'] as $key => $value) {
1598 1598
 			$args[] = array(
1599 1599
 				'value' => $value['version'],
1600 1600
 				'text'  => $value['label'] . ' (' . $value['version'] . ')',
@@ -1608,26 +1608,26 @@  discard block
 block discarded – undo
1608 1608
 	*
1609 1609
 	* @param array $args
1610 1610
 	*/
1611
-	public function display_link( $args ) {
1611
+	public function display_link($args) {
1612 1612
 		$label = $args['label'];
1613 1613
 		$desc  = $args['desc'];
1614 1614
 		$url   = $args['url'];
1615
-		if ( isset( $args['link_class'] ) ) {
1616
-			echo sprintf( '<p><a class="%1$s" href="%2$s">%3$s</a></p>',
1617
-				esc_attr( $args['link_class'] ),
1618
-				esc_url( $url ),
1619
-				esc_html( $label )
1615
+		if (isset($args['link_class'])) {
1616
+			echo sprintf('<p><a class="%1$s" href="%2$s">%3$s</a></p>',
1617
+				esc_attr($args['link_class']),
1618
+				esc_url($url),
1619
+				esc_html($label)
1620 1620
 			);
1621 1621
 		} else {
1622
-			echo sprintf( '<p><a href="%1$s">%2$s</a></p>',
1623
-				esc_url( $url ),
1624
-				esc_html( $label )
1622
+			echo sprintf('<p><a href="%1$s">%2$s</a></p>',
1623
+				esc_url($url),
1624
+				esc_html($label)
1625 1625
 			);
1626 1626
 		}
1627 1627
 
1628
-		if ( '' !== $desc ) {
1629
-			echo sprintf( '<p class="description">%1$s</p>',
1630
-				esc_html( $desc )
1628
+		if ('' !== $desc) {
1629
+			echo sprintf('<p class="description">%1$s</p>',
1630
+				esc_html($desc)
1631 1631
 			);
1632 1632
 		}
1633 1633
 
@@ -1638,60 +1638,60 @@  discard block
 block discarded – undo
1638 1638
 	*
1639 1639
 	* @param object $sfapi
1640 1640
 	*/
1641
-	private function status( $sfapi ) {
1641
+	private function status($sfapi) {
1642 1642
 
1643 1643
 		$versions = $sfapi->get_api_versions();
1644 1644
 
1645 1645
 		// format this array into text so users can see the versions
1646
-		if ( true === $versions['cached'] ) {
1647
-			$versions_is_cached = esc_html__( 'This list is cached, and', 'object-sync-salesforce' );
1646
+		if (true === $versions['cached']) {
1647
+			$versions_is_cached = esc_html__('This list is cached, and', 'object-sync-salesforce');
1648 1648
 		} else {
1649
-			$versions_is_cached = esc_html__( 'This list is not cached, but', 'object-sync-salesforce' );
1649
+			$versions_is_cached = esc_html__('This list is not cached, but', 'object-sync-salesforce');
1650 1650
 		}
1651 1651
 
1652
-		if ( true === $versions['from_cache'] ) {
1653
-			$versions_from_cache = esc_html__( 'items were loaded from the cache', 'object-sync-salesforce' );
1652
+		if (true === $versions['from_cache']) {
1653
+			$versions_from_cache = esc_html__('items were loaded from the cache', 'object-sync-salesforce');
1654 1654
 		} else {
1655
-			$versions_from_cache = esc_html__( 'items were not loaded from the cache', 'object-sync-salesforce' );
1655
+			$versions_from_cache = esc_html__('items were not loaded from the cache', 'object-sync-salesforce');
1656 1656
 		}
1657 1657
 
1658 1658
 		// translators: 1) $versions_is_cached is the "This list is/is not cached, and/but" line, 2) $versions_from_cache is the "items were/were not loaded from the cache" line
1659
-		$versions_apicall_summary = sprintf( esc_html__( 'Available Salesforce API versions. %1$s %2$s. This is not an authenticated request, so it does not touch the Salesforce token.', 'object-sync-for-salesforce' ),
1659
+		$versions_apicall_summary = sprintf(esc_html__('Available Salesforce API versions. %1$s %2$s. This is not an authenticated request, so it does not touch the Salesforce token.', 'object-sync-for-salesforce'),
1660 1660
 			$versions_is_cached,
1661 1661
 			$versions_from_cache
1662 1662
 		);
1663 1663
 
1664
-		$contacts = $sfapi->query( 'SELECT Name, Id from Contact LIMIT 100' );
1664
+		$contacts = $sfapi->query('SELECT Name, Id from Contact LIMIT 100');
1665 1665
 
1666 1666
 		// format this array into html so users can see the contacts
1667
-		if ( true === $contacts['cached'] ) {
1668
-			$contacts_is_cached = esc_html__( 'They are cached, and', 'object-sync-salesforce' );
1667
+		if (true === $contacts['cached']) {
1668
+			$contacts_is_cached = esc_html__('They are cached, and', 'object-sync-salesforce');
1669 1669
 		} else {
1670
-			$contacts_is_cached = esc_html__( 'They are not cached, but', 'object-sync-salesforce' );
1670
+			$contacts_is_cached = esc_html__('They are not cached, but', 'object-sync-salesforce');
1671 1671
 		}
1672 1672
 
1673
-		if ( true === $contacts['from_cache'] ) {
1674
-			$contacts_from_cache = esc_html__( 'they were loaded from the cache', 'object-sync-salesforce' );
1673
+		if (true === $contacts['from_cache']) {
1674
+			$contacts_from_cache = esc_html__('they were loaded from the cache', 'object-sync-salesforce');
1675 1675
 		} else {
1676
-			$contacts_from_cache = esc_html__( 'they were not loaded from the cache', 'object-sync-salesforce' );
1676
+			$contacts_from_cache = esc_html__('they were not loaded from the cache', 'object-sync-salesforce');
1677 1677
 		}
1678 1678
 
1679
-		if ( true === $contacts['is_redo'] ) {
1680
-			$contacts_refreshed_token = esc_html__( 'This request did require refreshing the Salesforce token', 'object-sync-salesforce' );
1679
+		if (true === $contacts['is_redo']) {
1680
+			$contacts_refreshed_token = esc_html__('This request did require refreshing the Salesforce token', 'object-sync-salesforce');
1681 1681
 		} else {
1682
-			$contacts_refreshed_token = esc_html__( 'This request did not require refreshing the Salesforce token', 'object-sync-salesforce' );
1682
+			$contacts_refreshed_token = esc_html__('This request did not require refreshing the Salesforce token', 'object-sync-salesforce');
1683 1683
 		}
1684 1684
 
1685 1685
 		// translators: 1) $contacts['data']['totalSize'] is the number of items loaded, 2) $contacts['data']['records'][0]['attributes']['type'] is the name of the Salesforce object, 3) $contacts_is_cached is the "They are/are not cached, and/but" line, 4) $contacts_from_cache is the "they were/were not loaded from the cache" line, 5) is the "this request did/did not require refreshing the Salesforce token" line
1686
-		$contacts_apicall_summary = sprintf( esc_html__( 'Salesforce successfully returned %1$s %2$s records. %3$s %4$s. %5$s.', 'object-sync-for-salesforce' ),
1687
-			absint( $contacts['data']['totalSize'] ),
1688
-			esc_html( $contacts['data']['records'][0]['attributes']['type'] ),
1686
+		$contacts_apicall_summary = sprintf(esc_html__('Salesforce successfully returned %1$s %2$s records. %3$s %4$s. %5$s.', 'object-sync-for-salesforce'),
1687
+			absint($contacts['data']['totalSize']),
1688
+			esc_html($contacts['data']['records'][0]['attributes']['type']),
1689 1689
 			$contacts_is_cached,
1690 1690
 			$contacts_from_cache,
1691 1691
 			$contacts_refreshed_token
1692 1692
 		);
1693 1693
 
1694
-		require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/status.php' );
1694
+		require_once(plugin_dir_path(__FILE__) . '/../templates/admin/status.php');
1695 1695
 
1696 1696
 	}
1697 1697
 
@@ -1701,12 +1701,12 @@  discard block
 block discarded – undo
1701 1701
 	* For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce
1702 1702
 	*/
1703 1703
 	private function logout() {
1704
-		$this->access_token  = delete_option( $this->option_prefix . 'access_token' );
1705
-		$this->instance_url  = delete_option( $this->option_prefix . 'instance_url' );
1706
-		$this->refresh_token = delete_option( $this->option_prefix . 'refresh_token' );
1707
-		echo sprintf( '<p>You have been logged out. You can use the <a href="%1$s">%2$s</a> tab to log in again.</p>',
1708
-			esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize' ) ),
1709
-			esc_html__( 'Authorize', 'object-sync-for-salesforce' )
1704
+		$this->access_token  = delete_option($this->option_prefix . 'access_token');
1705
+		$this->instance_url  = delete_option($this->option_prefix . 'instance_url');
1706
+		$this->refresh_token = delete_option($this->option_prefix . 'refresh_token');
1707
+		echo sprintf('<p>You have been logged out. You can use the <a href="%1$s">%2$s</a> tab to log in again.</p>',
1708
+			esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize')),
1709
+			esc_html__('Authorize', 'object-sync-for-salesforce')
1710 1710
 		);
1711 1711
 	}
1712 1712
 
@@ -1714,28 +1714,28 @@  discard block
 block discarded – undo
1714 1714
 	* Ajax call to clear the plugin cache.
1715 1715
 	*/
1716 1716
 	public function clear_sfwp_cache() {
1717
-		$result   = $this->clear_cache( true );
1717
+		$result   = $this->clear_cache(true);
1718 1718
 		$response = array(
1719 1719
 			'message' => $result['message'],
1720 1720
 			'success' => $result['success'],
1721 1721
 		);
1722
-		wp_send_json_success( $response );
1722
+		wp_send_json_success($response);
1723 1723
 	}
1724 1724
 
1725 1725
 	/**
1726 1726
 	* Clear the plugin's cache.
1727 1727
 	* This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data.
1728 1728
 	*/
1729
-	private function clear_cache( $ajax = false ) {
1729
+	private function clear_cache($ajax = false) {
1730 1730
 		$result = (bool) $this->wordpress->sfwp_transients->flush();
1731
-		if ( true === $result ) {
1732
-			$message = __( 'The plugin cache has been cleared.', 'object-sync-for-salesforce' );
1731
+		if (true === $result) {
1732
+			$message = __('The plugin cache has been cleared.', 'object-sync-for-salesforce');
1733 1733
 		} else {
1734
-			$message = __( 'There was an error clearing the plugin cache. Try refreshing this page.', 'object-sync-for-salesforce' );
1734
+			$message = __('There was an error clearing the plugin cache. Try refreshing this page.', 'object-sync-for-salesforce');
1735 1735
 		}
1736
-		if ( false === $ajax ) {
1736
+		if (false === $ajax) {
1737 1737
 			// translators: parameter 1 is the result message
1738
-			echo sprintf( '<p>%1$s</p>', $message );
1738
+			echo sprintf('<p>%1$s</p>', $message);
1739 1739
 		} else {
1740 1740
 			return array(
1741 1741
 				'message' => $message,
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
 		// alternatively, other roles can get this capability in whatever other way you like
1759 1759
 		// point is: to administer this plugin, you need this capability
1760 1760
 
1761
-		if ( ! current_user_can( 'configure_salesforce' ) ) {
1761
+		if ( ! current_user_can('configure_salesforce')) {
1762 1762
 			return false;
1763 1763
 		} else {
1764 1764
 			return true;
@@ -1771,23 +1771,23 @@  discard block
 block discarded – undo
1771 1771
 	* @param object $user
1772 1772
 	*
1773 1773
 	*/
1774
-	public function show_salesforce_user_fields( $user ) {
1775
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
1776
-		if ( true === $this->check_wordpress_admin_permissions() ) {
1777
-			$mapping  = $this->mappings->load_by_wordpress( 'user', $user->ID );
1774
+	public function show_salesforce_user_fields($user) {
1775
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
1776
+		if (true === $this->check_wordpress_admin_permissions()) {
1777
+			$mapping  = $this->mappings->load_by_wordpress('user', $user->ID);
1778 1778
 			$fieldmap = $this->mappings->get_fieldmaps(
1779 1779
 				null, // id field must be null for multiples
1780 1780
 				array(
1781 1781
 					'wordpress_object' => 'user',
1782 1782
 				)
1783 1783
 			);
1784
-			if ( isset( $mapping['id'] ) && ! isset( $get_data['edit_salesforce_mapping'] ) ) {
1785
-				require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/user-profile-salesforce.php' );
1786
-			} elseif ( ! empty( $fieldmap ) ) { // is the user mapped to something already?
1787
-				if ( isset( $get_data['edit_salesforce_mapping'] ) && 'true' === sanitize_key( $get_data['edit_salesforce_mapping'] ) ) {
1788
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/user-profile-salesforce-change.php' );
1784
+			if (isset($mapping['id']) && ! isset($get_data['edit_salesforce_mapping'])) {
1785
+				require_once(plugin_dir_path(__FILE__) . '/../templates/admin/user-profile-salesforce.php');
1786
+			} elseif ( ! empty($fieldmap)) { // is the user mapped to something already?
1787
+				if (isset($get_data['edit_salesforce_mapping']) && 'true' === sanitize_key($get_data['edit_salesforce_mapping'])) {
1788
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/user-profile-salesforce-change.php');
1789 1789
 				} else {
1790
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/user-profile-salesforce-map.php' );
1790
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/user-profile-salesforce-map.php');
1791 1791
 				}
1792 1792
 			}
1793 1793
 		}
@@ -1798,10 +1798,10 @@  discard block
 block discarded – undo
1798 1798
 	* @param int $user_id
1799 1799
 	*
1800 1800
 	*/
1801
-	public function save_salesforce_user_fields( $user_id ) {
1802
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1803
-		if ( isset( $post_data['salesforce_update_mapped_user'] ) && '1' === rawurlencode( $post_data['salesforce_update_mapped_user'] ) ) {
1804
-			$mapping_object                  = $this->mappings->get_object_maps(
1801
+	public function save_salesforce_user_fields($user_id) {
1802
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1803
+		if (isset($post_data['salesforce_update_mapped_user']) && '1' === rawurlencode($post_data['salesforce_update_mapped_user'])) {
1804
+			$mapping_object = $this->mappings->get_object_maps(
1805 1805
 				array(
1806 1806
 					'wordpress_id'     => $user_id,
1807 1807
 					'wordpress_object' => 'user',
@@ -1809,14 +1809,14 @@  discard block
 block discarded – undo
1809 1809
 			);
1810 1810
 			$mapping_object['salesforce_id'] = $post_data['salesforce_id'];
1811 1811
 
1812
-			$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1813
-		} elseif ( isset( $post_data['salesforce_create_mapped_user'] ) && '1' === rawurlencode( $post_data['salesforce_create_mapped_user'] ) ) {
1812
+			$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1813
+		} elseif (isset($post_data['salesforce_create_mapped_user']) && '1' === rawurlencode($post_data['salesforce_create_mapped_user'])) {
1814 1814
 			// if a Salesforce ID was entered
1815
-			if ( isset( $post_data['salesforce_id'] ) && ! empty( $post_data['salesforce_id'] ) ) {
1816
-				$mapping_object = $this->create_object_map( $user_id, 'user', $post_data['salesforce_id'] );
1817
-			} elseif ( isset( $post_data['push_new_user_to_salesforce'] ) ) {
1815
+			if (isset($post_data['salesforce_id']) && ! empty($post_data['salesforce_id'])) {
1816
+				$mapping_object = $this->create_object_map($user_id, 'user', $post_data['salesforce_id']);
1817
+			} elseif (isset($post_data['push_new_user_to_salesforce'])) {
1818 1818
 				// otherwise, create a new record in Salesforce
1819
-				$result = $this->push_to_salesforce( 'user', $user_id );
1819
+				$result = $this->push_to_salesforce('user', $user_id);
1820 1820
 			}
1821 1821
 		}
1822 1822
 	}
@@ -1826,29 +1826,29 @@  discard block
 block discarded – undo
1826 1826
 	* @param array $tabs
1827 1827
 	* @param string $tab
1828 1828
 	*/
1829
-	private function tabs( $tabs, $tab = '' ) {
1829
+	private function tabs($tabs, $tab = '') {
1830 1830
 
1831
-		$get_data        = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
1831
+		$get_data        = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
1832 1832
 		$consumer_key    = $this->login_credentials['consumer_key'];
1833 1833
 		$consumer_secret = $this->login_credentials['consumer_secret'];
1834 1834
 		$callback_url    = $this->login_credentials['callback_url'];
1835 1835
 
1836 1836
 		$current_tab = $tab;
1837 1837
 		echo '<h2 class="nav-tab-wrapper">';
1838
-		foreach ( $tabs as $tab_key => $tab_caption ) {
1838
+		foreach ($tabs as $tab_key => $tab_caption) {
1839 1839
 			$active = $current_tab === $tab_key ? ' nav-tab-active' : '';
1840
-			if ( 'settings' === $tab_key || ( isset( $consumer_key ) && isset( $consumer_secret ) && ! empty( $consumer_key ) && ! empty( $consumer_secret ) ) ) {
1841
-				echo sprintf( '<a class="nav-tab%1$s" href="%2$s">%3$s</a>',
1842
-					esc_attr( $active ),
1843
-					esc_url( '?page=object-sync-salesforce-admin&tab=' . $tab_key ),
1844
-					esc_html( $tab_caption )
1840
+			if ('settings' === $tab_key || (isset($consumer_key) && isset($consumer_secret) && ! empty($consumer_key) && ! empty($consumer_secret))) {
1841
+				echo sprintf('<a class="nav-tab%1$s" href="%2$s">%3$s</a>',
1842
+					esc_attr($active),
1843
+					esc_url('?page=object-sync-salesforce-admin&tab=' . $tab_key),
1844
+					esc_html($tab_caption)
1845 1845
 				);
1846 1846
 			}
1847 1847
 		}
1848 1848
 		echo '</h2>';
1849 1849
 
1850
-		if ( isset( $get_data['tab'] ) ) {
1851
-			$tab = sanitize_key( $get_data['tab'] );
1850
+		if (isset($get_data['tab'])) {
1851
+			$tab = sanitize_key($get_data['tab']);
1852 1852
 		} else {
1853 1853
 			$tab = '';
1854 1854
 		}
@@ -1858,21 +1858,21 @@  discard block
 block discarded – undo
1858 1858
 	* Clear schedule
1859 1859
 	* This clears the schedule if the user clicks the button
1860 1860
 	*/
1861
-	private function clear_schedule( $schedule_name = '' ) {
1862
-		if ( '' !== $schedule_name ) {
1863
-			$schedule = $this->schedule( $schedule_name );
1864
-			$schedule->cancel_by_name( $schedule_name );
1861
+	private function clear_schedule($schedule_name = '') {
1862
+		if ('' !== $schedule_name) {
1863
+			$schedule = $this->schedule($schedule_name);
1864
+			$schedule->cancel_by_name($schedule_name);
1865 1865
 			// translators: $schedule_name is the name of the current queue. Defaults: salesforce_pull, salesforce_push, salesforce
1866
-			echo sprintf( esc_html__( 'You have cleared the %s schedule.', 'object-sync-for-salesforce' ), esc_html( $schedule_name ) );
1866
+			echo sprintf(esc_html__('You have cleared the %s schedule.', 'object-sync-for-salesforce'), esc_html($schedule_name));
1867 1867
 		} else {
1868
-			echo esc_html__( 'You need to specify the name of the schedule you want to clear.', 'object-sync-for-salesforce' );
1868
+			echo esc_html__('You need to specify the name of the schedule you want to clear.', 'object-sync-for-salesforce');
1869 1869
 		}
1870 1870
 	}
1871 1871
 
1872
-	private function get_schedule_count( $schedule_name = '' ) {
1873
-		if ( '' !== $schedule_name ) {
1874
-			$schedule = $this->schedule( $schedule_name );
1875
-			return $this->schedule->count_queue_items( $schedule_name );
1872
+	private function get_schedule_count($schedule_name = '') {
1873
+		if ('' !== $schedule_name) {
1874
+			$schedule = $this->schedule($schedule_name);
1875
+			return $this->schedule->count_queue_items($schedule_name);
1876 1876
 		} else {
1877 1877
 			return 'unknown';
1878 1878
 		}
@@ -1881,12 +1881,12 @@  discard block
 block discarded – undo
1881 1881
 	/**
1882 1882
 	* Load the schedule class
1883 1883
 	*/
1884
-	private function schedule( $schedule_name ) {
1885
-		if ( ! class_exists( 'Object_Sync_Sf_Schedule' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
1886
-			require_once plugin_dir_path( __FILE__ ) . '../vendor/autoload.php';
1887
-			require_once plugin_dir_path( __FILE__ ) . '../classes/schedule.php';
1884
+	private function schedule($schedule_name) {
1885
+		if ( ! class_exists('Object_Sync_Sf_Schedule') && file_exists(plugin_dir_path(__FILE__) . '../vendor/autoload.php')) {
1886
+			require_once plugin_dir_path(__FILE__) . '../vendor/autoload.php';
1887
+			require_once plugin_dir_path(__FILE__) . '../classes/schedule.php';
1888 1888
 		}
1889
-		$schedule       = new Object_Sync_Sf_Schedule( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $schedule_name, $this->logging, $this->schedulable_classes );
1889
+		$schedule       = new Object_Sync_Sf_Schedule($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $schedule_name, $this->logging, $this->schedulable_classes);
1890 1890
 		$this->schedule = $schedule;
1891 1891
 		return $schedule;
1892 1892
 	}
@@ -1907,17 +1907,17 @@  discard block
 block discarded – undo
1907 1907
 	*   This is the database row for the map object
1908 1908
 	*
1909 1909
 	*/
1910
-	private function create_object_map( $wordpress_id, $wordpress_object, $salesforce_id, $action = '' ) {
1910
+	private function create_object_map($wordpress_id, $wordpress_object, $salesforce_id, $action = '') {
1911 1911
 		// Create object map and save it
1912 1912
 		$mapping_object = $this->mappings->create_object_map(
1913 1913
 			array(
1914 1914
 				'wordpress_id'      => $wordpress_id, // wordpress unique id
1915 1915
 				'salesforce_id'     => $salesforce_id, // salesforce unique id. we don't care what kind of object it is at this point
1916 1916
 				'wordpress_object'  => $wordpress_object, // keep track of what kind of wp object this is
1917
-				'last_sync'         => current_time( 'mysql' ),
1917
+				'last_sync'         => current_time('mysql'),
1918 1918
 				'last_sync_action'  => $action,
1919 1919
 				'last_sync_status'  => $this->mappings->status_success,
1920
-				'last_sync_message' => __( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1920
+				'last_sync_message' => __('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1921 1921
 			)
1922 1922
 		);
1923 1923
 
Please login to merge, or discard this patch.