Passed
Pull Request — master (#195)
by Jonathan
03:30
created
classes/admin.php 2 patches
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -27,63 +27,63 @@  discard block
 block discarded – undo
27 27
 	protected $queue;
28 28
 
29 29
 	/**
30
-	* @var string
31
-	* Default path for the Salesforce authorize URL
32
-	*/
30
+	 * @var string
31
+	 * Default path for the Salesforce authorize URL
32
+	 */
33 33
 	public $default_authorize_url_path;
34 34
 
35 35
 	/**
36
-	* @var string
37
-	* Default path for the Salesforce token URL
38
-	*/
36
+	 * @var string
37
+	 * Default path for the Salesforce token URL
38
+	 */
39 39
 	public $default_token_url_path;
40 40
 
41 41
 	/**
42
-	* @var string
43
-	* What version of the Salesforce API should be the default on the settings screen.
44
-	* Users can edit this, but they won't see a correct list of all their available versions until WordPress has
45
-	* been authenticated with Salesforce.
46
-	*/
42
+	 * @var string
43
+	 * What version of the Salesforce API should be the default on the settings screen.
44
+	 * Users can edit this, but they won't see a correct list of all their available versions until WordPress has
45
+	 * been authenticated with Salesforce.
46
+	 */
47 47
 	public $default_api_version;
48 48
 
49 49
 	/**
50
-	* @var bool
51
-	* Default for whether to limit to triggerable items
52
-	* Users can edit this
53
-	*/
50
+	 * @var bool
51
+	 * Default for whether to limit to triggerable items
52
+	 * Users can edit this
53
+	 */
54 54
 	public $default_triggerable;
55 55
 
56 56
 	/**
57
-	* @var bool
58
-	* Default for whether to limit to updateable items
59
-	* Users can edit this
60
-	*/
57
+	 * @var bool
58
+	 * Default for whether to limit to updateable items
59
+	 * Users can edit this
60
+	 */
61 61
 	public $default_updateable;
62 62
 
63 63
 	/**
64
-	* @var int
65
-	* Default pull throttle for how often Salesforce can pull
66
-	* Users can edit this
67
-	*/
64
+	 * @var int
65
+	 * Default pull throttle for how often Salesforce can pull
66
+	 * Users can edit this
67
+	 */
68 68
 	public $default_pull_throttle;
69 69
 
70 70
 	/**
71
-	* Constructor which sets up admin pages
72
-	*
73
-	* @param object $wpdb
74
-	* @param string $version
75
-	* @param array $login_credentials
76
-	* @param string $slug
77
-	* @param object $wordpress
78
-	* @param object $salesforce
79
-	* @param object $mappings
80
-	* @param object $push
81
-	* @param object $pull
82
-	* @param object $logging
83
-	* @param array $schedulable_classes
84
-	* @param object $queue
85
-	* @throws \Exception
86
-	*/
71
+	 * Constructor which sets up admin pages
72
+	 *
73
+	 * @param object $wpdb
74
+	 * @param string $version
75
+	 * @param array $login_credentials
76
+	 * @param string $slug
77
+	 * @param object $wordpress
78
+	 * @param object $salesforce
79
+	 * @param object $mappings
80
+	 * @param object $push
81
+	 * @param object $pull
82
+	 * @param object $logging
83
+	 * @param array $schedulable_classes
84
+	 * @param object $queue
85
+	 * @throws \Exception
86
+	 */
87 87
 	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) {
88 88
 		$this->wpdb                = $wpdb;
89 89
 		$this->version             = $version;
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 
122 122
 	/**
123
-	* Create the action hooks to create the admin page(s)
124
-	*
125
-	*/
123
+	 * Create the action hooks to create the admin page(s)
124
+	 *
125
+	 */
126 126
 	public function add_actions() {
127 127
 		add_action( 'admin_init', array( $this, 'salesforce_settings_forms' ) );
128 128
 		add_action( 'admin_init', array( $this, 'notices' ) );
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	}
158 158
 
159 159
 	/**
160
-	* Recurring task to check Salesforce for data
161
-	*
162
-	*/
160
+	 * Recurring task to check Salesforce for data
161
+	 *
162
+	 */
163 163
 	public function change_action_schedule( $old_schedule, $new_schedule, $option_name ) {
164 164
 
165 165
 		// exit if nothing changed
@@ -195,21 +195,21 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 
197 197
 	/**
198
-	* Create WordPress admin options page
199
-	*
200
-	*/
198
+	 * Create WordPress admin options page
199
+	 *
200
+	 */
201 201
 	public function create_admin_menu() {
202 202
 		$title = __( 'Salesforce', 'object-sync-for-salesforce' );
203 203
 		add_options_page( $title, $title, 'configure_salesforce', 'object-sync-salesforce-admin', array( $this, 'show_admin_page' ) );
204 204
 	}
205 205
 
206 206
 	/**
207
-	* Render full admin pages in WordPress
208
-	* This allows other plugins to add tabs to the Salesforce settings screen
209
-	*
210
-	* todo: better front end: html, organization of html into templates, css, js
211
-	*
212
-	*/
207
+	 * Render full admin pages in WordPress
208
+	 * This allows other plugins to add tabs to the Salesforce settings screen
209
+	 *
210
+	 * todo: better front end: html, organization of html into templates, css, js
211
+	 *
212
+	 */
213 213
 	public function show_admin_page() {
214 214
 		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
215 215
 		echo '<div class="wrap">';
@@ -419,10 +419,10 @@  discard block
 block discarded – undo
419 419
 	}
420 420
 
421 421
 	/**
422
-	* Create default WordPress admin settings form for salesforce
423
-	* This is for the Settings page/tab
424
-	*
425
-	*/
422
+	 * Create default WordPress admin settings form for salesforce
423
+	 * This is for the Settings page/tab
424
+	 *
425
+	 */
426 426
 	public function salesforce_settings_forms() {
427 427
 		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
428 428
 		$page     = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
@@ -447,13 +447,13 @@  discard block
 block discarded – undo
447 447
 	}
448 448
 
449 449
 	/**
450
-	* Fields for the Settings tab
451
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
452
-	*
453
-	* @param string $page
454
-	* @param string $section
455
-	* @param string $input_callback
456
-	*/
450
+	 * Fields for the Settings tab
451
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
452
+	 *
453
+	 * @param string $page
454
+	 * @param string $section
455
+	 * @param string $input_callback
456
+	 */
457 457
 	private function fields_settings( $page, $section, $callbacks ) {
458 458
 		add_settings_section( $page, ucwords( $page ), null, $page );
459 459
 		$salesforce_settings = array(
@@ -687,25 +687,25 @@  discard block
 block discarded – undo
687 687
 	}
688 688
 
689 689
 	/**
690
-	* Fields for the Fieldmaps tab
691
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
692
-	*
693
-	* @param string $page
694
-	* @param string $section
695
-	* @param string $input_callback
696
-	*/
690
+	 * Fields for the Fieldmaps tab
691
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
692
+	 *
693
+	 * @param string $page
694
+	 * @param string $section
695
+	 * @param string $input_callback
696
+	 */
697 697
 	private function fields_fieldmaps( $page, $section, $input_callback = '' ) {
698 698
 		add_settings_section( $page, ucwords( $page ), null, $page );
699 699
 	}
700 700
 
701 701
 	/**
702
-	* Fields for the Scheduling tab
703
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
704
-	*
705
-	* @param string $page
706
-	* @param string $section
707
-	* @param string $input_callback
708
-	*/
702
+	 * Fields for the Scheduling tab
703
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
704
+	 *
705
+	 * @param string $page
706
+	 * @param string $section
707
+	 * @param string $input_callback
708
+	 */
709 709
 	private function fields_scheduling( $page, $section, $callbacks ) {
710 710
 		foreach ( $this->schedulable_classes as $key => $value ) {
711 711
 			add_settings_section( $key, $value['label'], null, $page );
@@ -798,13 +798,13 @@  discard block
 block discarded – undo
798 798
 	}
799 799
 
800 800
 	/**
801
-	* Fields for the Log Settings tab
802
-	* This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
803
-	*
804
-	* @param string $page
805
-	* @param string $section
806
-	* @param array $callbacks
807
-	*/
801
+	 * Fields for the Log Settings tab
802
+	 * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
803
+	 *
804
+	 * @param string $page
805
+	 * @param string $section
806
+	 * @param array $callbacks
807
+	 */
808 808
 	private function fields_log_settings( $page, $section, $callbacks ) {
809 809
 		add_settings_section( $page, ucwords( str_replace( '_', ' ', $page ) ), null, $page );
810 810
 		$log_settings = array(
@@ -982,9 +982,9 @@  discard block
 block discarded – undo
982 982
 	}
983 983
 
984 984
 	/**
985
-	* Create the notices, settings, and conditions by which admin notices should appear
986
-	*
987
-	*/
985
+	 * Create the notices, settings, and conditions by which admin notices should appear
986
+	 *
987
+	 */
988 988
 	public function notices() {
989 989
 
990 990
 		// before a notice is displayed, we should make sure we are on a page related to this plugin
@@ -1057,14 +1057,14 @@  discard block
 block discarded – undo
1057 1057
 	}
1058 1058
 
1059 1059
 	/**
1060
-	* Get all the Salesforce object settings for fieldmapping
1061
-	* This takes either the $_POST array via ajax, or can be directly called with a $data array
1062
-	*
1063
-	* @param array $data
1064
-	* data must contain a salesforce_object
1065
-	* can optionally contain a type
1066
-	* @return array $object_settings
1067
-	*/
1060
+	 * Get all the Salesforce object settings for fieldmapping
1061
+	 * This takes either the $_POST array via ajax, or can be directly called with a $data array
1062
+	 *
1063
+	 * @param array $data
1064
+	 * data must contain a salesforce_object
1065
+	 * can optionally contain a type
1066
+	 * @return array $object_settings
1067
+	 */
1068 1068
 	public function get_salesforce_object_description( $data = array() ) {
1069 1069
 		$ajax = false;
1070 1070
 		if ( empty( $data ) ) {
@@ -1112,13 +1112,13 @@  discard block
 block discarded – undo
1112 1112
 	}
1113 1113
 
1114 1114
 	/**
1115
-	* Get Salesforce object fields for fieldmapping
1116
-	*
1117
-	* @param array $data
1118
-	* data must contain a salesforce_object
1119
-	* can optionally contain a type for the field
1120
-	* @return array $object_fields
1121
-	*/
1115
+	 * Get Salesforce object fields for fieldmapping
1116
+	 *
1117
+	 * @param array $data
1118
+	 * data must contain a salesforce_object
1119
+	 * can optionally contain a type for the field
1120
+	 * @return array $object_fields
1121
+	 */
1122 1122
 	public function get_salesforce_object_fields( $data = array() ) {
1123 1123
 
1124 1124
 		if ( ! empty( $data['salesforce_object'] ) ) {
@@ -1146,12 +1146,12 @@  discard block
 block discarded – undo
1146 1146
 	}
1147 1147
 
1148 1148
 	/**
1149
-	* Get WordPress object fields for fieldmapping
1150
-	* This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field
1151
-	*
1152
-	* @param string $wordpress_object
1153
-	* @return array $object_fields
1154
-	*/
1149
+	 * Get WordPress object fields for fieldmapping
1150
+	 * This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field
1151
+	 *
1152
+	 * @param string $wordpress_object
1153
+	 * @return array $object_fields
1154
+	 */
1155 1155
 	public function get_wordpress_object_fields( $wordpress_object = '' ) {
1156 1156
 		$ajax      = false;
1157 1157
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
@@ -1170,13 +1170,13 @@  discard block
 block discarded – undo
1170 1170
 	}
1171 1171
 
1172 1172
 	/**
1173
-	* Get WordPress and Salesforce object fields together for fieldmapping
1174
-	* This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $salesforce_object fields
1175
-	*
1176
-	* @param string $wordpress_object
1177
-	* @param string $salesforce_object
1178
-	* @return array $object_fields
1179
-	*/
1173
+	 * Get WordPress and Salesforce object fields together for fieldmapping
1174
+	 * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $salesforce_object fields
1175
+	 *
1176
+	 * @param string $wordpress_object
1177
+	 * @param string $salesforce_object
1178
+	 * @return array $object_fields
1179
+	 */
1180 1180
 	public function get_wp_sf_object_fields( $wordpress_object = '', $salesforce = '' ) {
1181 1181
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1182 1182
 		if ( empty( $wordpress_object ) ) {
@@ -1201,12 +1201,12 @@  discard block
 block discarded – undo
1201 1201
 	}
1202 1202
 
1203 1203
 	/**
1204
-	* Manually push the WordPress object to Salesforce
1205
-	* This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields
1206
-	*
1207
-	* @param string $wordpress_object
1208
-	* @param int $wordpress_id
1209
-	*/
1204
+	 * Manually push the WordPress object to Salesforce
1205
+	 * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields
1206
+	 *
1207
+	 * @param string $wordpress_object
1208
+	 * @param int $wordpress_id
1209
+	 */
1210 1210
 	public function push_to_salesforce( $wordpress_object = '', $wordpress_id = '' ) {
1211 1211
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1212 1212
 		if ( empty( $wordpress_object ) && empty( $wordpress_id ) ) {
@@ -1225,12 +1225,12 @@  discard block
 block discarded – undo
1225 1225
 	}
1226 1226
 
1227 1227
 	/**
1228
-	* Manually pull the Salesforce object into WordPress
1229
-	* This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields
1230
-	*
1231
-	* @param string $salesforce_id
1232
-	* @param string $wordpress_object
1233
-	*/
1228
+	 * Manually pull the Salesforce object into WordPress
1229
+	 * This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields
1230
+	 *
1231
+	 * @param string $salesforce_id
1232
+	 * @param string $wordpress_object
1233
+	 */
1234 1234
 	public function pull_from_salesforce( $salesforce_id = '', $wordpress_object = '' ) {
1235 1235
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1236 1236
 		if ( empty( $wordpress_object ) && empty( $salesforce_id ) ) {
@@ -1247,11 +1247,11 @@  discard block
 block discarded – undo
1247 1247
 	}
1248 1248
 
1249 1249
 	/**
1250
-	* Manually pull the Salesforce object into WordPress
1251
-	* This takes an id for a mapping object row
1252
-	*
1253
-	* @param int $mapping_id
1254
-	*/
1250
+	 * Manually pull the Salesforce object into WordPress
1251
+	 * This takes an id for a mapping object row
1252
+	 *
1253
+	 * @param int $mapping_id
1254
+	 */
1255 1255
 	public function refresh_mapped_data( $mapping_id = '' ) {
1256 1256
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1257 1257
 		if ( empty( $mapping_id ) ) {
@@ -1270,13 +1270,13 @@  discard block
 block discarded – undo
1270 1270
 	}
1271 1271
 
1272 1272
 	/**
1273
-	* Prepare fieldmap data and redirect after processing
1274
-	* This runs when the create or update forms are submitted
1275
-	* It is public because it depends on an admin hook
1276
-	* It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1277
-	* This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1278
-	*
1279
-	*/
1273
+	 * Prepare fieldmap data and redirect after processing
1274
+	 * This runs when the create or update forms are submitted
1275
+	 * It is public because it depends on an admin hook
1276
+	 * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1277
+	 * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1278
+	 *
1279
+	 */
1280 1280
 	public function prepare_fieldmap_data() {
1281 1281
 		$error     = false;
1282 1282
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
@@ -1324,12 +1324,12 @@  discard block
 block discarded – undo
1324 1324
 	}
1325 1325
 
1326 1326
 	/**
1327
-	* Delete fieldmap data and redirect after processing
1328
-	* This runs when the delete link is clicked, after the user confirms
1329
-	* It is public because it depends on an admin hook
1330
-	* It then calls the Object_Sync_Sf_Mapping class and the delete method
1331
-	*
1332
-	*/
1327
+	 * Delete fieldmap data and redirect after processing
1328
+	 * This runs when the delete link is clicked, after the user confirms
1329
+	 * It is public because it depends on an admin hook
1330
+	 * It then calls the Object_Sync_Sf_Mapping class and the delete method
1331
+	 *
1332
+	 */
1333 1333
 	public function delete_fieldmap() {
1334 1334
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1335 1335
 		if ( $post_data['id'] ) {
@@ -1345,13 +1345,13 @@  discard block
 block discarded – undo
1345 1345
 	}
1346 1346
 
1347 1347
 	/**
1348
-	* Prepare object data and redirect after processing
1349
-	* This runs when the update form is submitted
1350
-	* It is public because it depends on an admin hook
1351
-	* It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1352
-	* This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1353
-	*
1354
-	*/
1348
+	 * Prepare object data and redirect after processing
1349
+	 * This runs when the update form is submitted
1350
+	 * It is public because it depends on an admin hook
1351
+	 * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page
1352
+	 * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
1353
+	 *
1354
+	 */
1355 1355
 	public function prepare_object_map_data() {
1356 1356
 		$error     = false;
1357 1357
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
@@ -1390,12 +1390,12 @@  discard block
 block discarded – undo
1390 1390
 	}
1391 1391
 
1392 1392
 	/**
1393
-	* Delete object map data and redirect after processing
1394
-	* This runs when the delete link is clicked on an error row, after the user confirms
1395
-	* It is public because it depends on an admin hook
1396
-	* It then calls the Object_Sync_Sf_Mapping class and the delete method
1397
-	*
1398
-	*/
1393
+	 * Delete object map data and redirect after processing
1394
+	 * This runs when the delete link is clicked on an error row, after the user confirms
1395
+	 * It is public because it depends on an admin hook
1396
+	 * It then calls the Object_Sync_Sf_Mapping class and the delete method
1397
+	 *
1398
+	 */
1399 1399
 	public function delete_object_map() {
1400 1400
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1401 1401
 		if ( $post_data['id'] ) {
@@ -1411,9 +1411,9 @@  discard block
 block discarded – undo
1411 1411
 	}
1412 1412
 
1413 1413
 	/**
1414
-	* Import a json file and use it for plugin data
1415
-	*
1416
-	*/
1414
+	 * Import a json file and use it for plugin data
1415
+	 *
1416
+	 */
1417 1417
 	public function import_json_file() {
1418 1418
 
1419 1419
 		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import' ) ) {
@@ -1511,9 +1511,9 @@  discard block
 block discarded – undo
1511 1511
 	}
1512 1512
 
1513 1513
 	/**
1514
-	* Create a json file for exporting
1515
-	*
1516
-	*/
1514
+	 * Create a json file for exporting
1515
+	 *
1516
+	 */
1517 1517
 	public function export_json_file() {
1518 1518
 
1519 1519
 		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_export'], 'object_sync_for_salesforce_nonce_export' ) ) {
@@ -1542,10 +1542,10 @@  discard block
 block discarded – undo
1542 1542
 	}
1543 1543
 
1544 1544
 	/**
1545
-	* Default display for <input> fields
1546
-	*
1547
-	* @param array $args
1548
-	*/
1545
+	 * Default display for <input> fields
1546
+	 *
1547
+	 * @param array $args
1548
+	 */
1549 1549
 	public function display_input_field( $args ) {
1550 1550
 		$type    = $args['type'];
1551 1551
 		$id      = $args['label_for'];
@@ -1592,11 +1592,11 @@  discard block
 block discarded – undo
1592 1592
 	}
1593 1593
 
1594 1594
 	/**
1595
-	* Display for multiple checkboxes
1596
-	* Above method can handle a single checkbox as it is
1597
-	*
1598
-	* @param array $args
1599
-	*/
1595
+	 * Display for multiple checkboxes
1596
+	 * Above method can handle a single checkbox as it is
1597
+	 *
1598
+	 * @param array $args
1599
+	 */
1600 1600
 	public function display_checkboxes( $args ) {
1601 1601
 		$type    = 'checkbox';
1602 1602
 		$name    = $args['name'];
@@ -1630,10 +1630,10 @@  discard block
 block discarded – undo
1630 1630
 	}
1631 1631
 
1632 1632
 	/**
1633
-	* Display for a dropdown
1634
-	*
1635
-	* @param array $args
1636
-	*/
1633
+	 * Display for a dropdown
1634
+	 *
1635
+	 * @param array $args
1636
+	 */
1637 1637
 	public function display_select( $args ) {
1638 1638
 		$type = $args['type'];
1639 1639
 		$id   = $args['label_for'];
@@ -1677,10 +1677,10 @@  discard block
 block discarded – undo
1677 1677
 	}
1678 1678
 
1679 1679
 	/**
1680
-	* Dropdown formatted list of Salesforce API versions
1681
-	*
1682
-	* @return array $args
1683
-	*/
1680
+	 * Dropdown formatted list of Salesforce API versions
1681
+	 *
1682
+	 * @return array $args
1683
+	 */
1684 1684
 	private function version_options() {
1685 1685
 		$versions = $this->salesforce['sfapi']->get_api_versions();
1686 1686
 		$args     = array();
@@ -1694,10 +1694,10 @@  discard block
 block discarded – undo
1694 1694
 	}
1695 1695
 
1696 1696
 	/**
1697
-	* Default display for <a href> links
1698
-	*
1699
-	* @param array $args
1700
-	*/
1697
+	 * Default display for <a href> links
1698
+	 *
1699
+	 * @param array $args
1700
+	 */
1701 1701
 	public function display_link( $args ) {
1702 1702
 		$label = $args['label'];
1703 1703
 		$desc  = $args['desc'];
@@ -1724,11 +1724,11 @@  discard block
 block discarded – undo
1724 1724
 	}
1725 1725
 
1726 1726
 	/**
1727
-	* Allow for a standard sanitize/validate method. We could use more specific ones if need be, but this one provides a baseline.
1728
-	*
1729
-	* @param string $option
1730
-	* @return string $option
1731
-	*/
1727
+	 * Allow for a standard sanitize/validate method. We could use more specific ones if need be, but this one provides a baseline.
1728
+	 *
1729
+	 * @param string $option
1730
+	 * @return string $option
1731
+	 */
1732 1732
 	public function sanitize_validate_text( $option ) {
1733 1733
 		if ( is_array( $option ) ) {
1734 1734
 			$options = array();
@@ -1742,10 +1742,10 @@  discard block
 block discarded – undo
1742 1742
 	}
1743 1743
 
1744 1744
 	/**
1745
-	* Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it
1746
-	*
1747
-	* @param object $sfapi
1748
-	*/
1745
+	 * Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it
1746
+	 *
1747
+	 * @param object $sfapi
1748
+	 */
1749 1749
 	private function status( $sfapi ) {
1750 1750
 
1751 1751
 		$versions = $sfapi->get_api_versions();
@@ -1804,10 +1804,10 @@  discard block
 block discarded – undo
1804 1804
 	}
1805 1805
 
1806 1806
 	/**
1807
-	* Deauthorize WordPress from Salesforce.
1808
-	* This deletes the tokens from the database; it does not currently do anything in Salesforce
1809
-	* For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce
1810
-	*/
1807
+	 * Deauthorize WordPress from Salesforce.
1808
+	 * This deletes the tokens from the database; it does not currently do anything in Salesforce
1809
+	 * For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce
1810
+	 */
1811 1811
 	private function logout() {
1812 1812
 		$this->access_token  = delete_option( $this->option_prefix . 'access_token' );
1813 1813
 		$this->instance_url  = delete_option( $this->option_prefix . 'instance_url' );
@@ -1819,8 +1819,8 @@  discard block
 block discarded – undo
1819 1819
 	}
1820 1820
 
1821 1821
 	/**
1822
-	* Ajax call to clear the plugin cache.
1823
-	*/
1822
+	 * Ajax call to clear the plugin cache.
1823
+	 */
1824 1824
 	public function clear_sfwp_cache() {
1825 1825
 		$result   = $this->clear_cache( true );
1826 1826
 		$response = array(
@@ -1831,9 +1831,9 @@  discard block
 block discarded – undo
1831 1831
 	}
1832 1832
 
1833 1833
 	/**
1834
-	* Clear the plugin's cache.
1835
-	* This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data.
1836
-	*/
1834
+	 * Clear the plugin's cache.
1835
+	 * This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data.
1836
+	 */
1837 1837
 	private function clear_cache( $ajax = false ) {
1838 1838
 		$result = (bool) $this->wordpress->sfwp_transients->flush();
1839 1839
 		if ( true === $result ) {
@@ -1853,9 +1853,9 @@  discard block
 block discarded – undo
1853 1853
 	}
1854 1854
 
1855 1855
 	/**
1856
-	* Check WordPress Admin permissions
1857
-	* Check if the current user is allowed to access the Salesforce plugin options
1858
-	*/
1856
+	 * Check WordPress Admin permissions
1857
+	 * Check if the current user is allowed to access the Salesforce plugin options
1858
+	 */
1859 1859
 	private function check_wordpress_admin_permissions() {
1860 1860
 
1861 1861
 		// one programmatic way to give this capability to additional user roles is the
@@ -1875,10 +1875,10 @@  discard block
 block discarded – undo
1875 1875
 	}
1876 1876
 
1877 1877
 	/**
1878
-	* Show what we know about this user's relationship to a Salesforce object, if any
1879
-	* @param object $user
1880
-	*
1881
-	*/
1878
+	 * Show what we know about this user's relationship to a Salesforce object, if any
1879
+	 * @param object $user
1880
+	 *
1881
+	 */
1882 1882
 	public function show_salesforce_user_fields( $user ) {
1883 1883
 		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
1884 1884
 		if ( true === $this->check_wordpress_admin_permissions() ) {
@@ -1902,10 +1902,10 @@  discard block
 block discarded – undo
1902 1902
 	}
1903 1903
 
1904 1904
 	/**
1905
-	* If the user profile has been mapped to Salesforce, do it
1906
-	* @param int $user_id
1907
-	*
1908
-	*/
1905
+	 * If the user profile has been mapped to Salesforce, do it
1906
+	 * @param int $user_id
1907
+	 *
1908
+	 */
1909 1909
 	public function save_salesforce_user_fields( $user_id ) {
1910 1910
 		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1911 1911
 		if ( isset( $post_data['salesforce_update_mapped_user'] ) && '1' === rawurlencode( $post_data['salesforce_update_mapped_user'] ) ) {
@@ -1930,10 +1930,10 @@  discard block
 block discarded – undo
1930 1930
 	}
1931 1931
 
1932 1932
 	/**
1933
-	* Render tabs for settings pages in admin
1934
-	* @param array $tabs
1935
-	* @param string $tab
1936
-	*/
1933
+	 * Render tabs for settings pages in admin
1934
+	 * @param array $tabs
1935
+	 * @param string $tab
1936
+	 */
1937 1937
 	private function tabs( $tabs, $tab = '' ) {
1938 1938
 
1939 1939
 		$get_data        = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
@@ -1963,10 +1963,10 @@  discard block
 block discarded – undo
1963 1963
 	}
1964 1964
 
1965 1965
 	/**
1966
-	* Clear schedule
1967
-	* This clears the schedule if the user clicks the button
1968
-	* @param string $schedule_name
1969
-	*/
1966
+	 * Clear schedule
1967
+	 * This clears the schedule if the user clicks the button
1968
+	 * @param string $schedule_name
1969
+	 */
1970 1970
 	private function clear_schedule( $schedule_name = '' ) {
1971 1971
 		if ( '' !== $schedule_name ) {
1972 1972
 			$this->queue->cancel( $schedule_name );
@@ -1978,10 +1978,10 @@  discard block
 block discarded – undo
1978 1978
 	}
1979 1979
 
1980 1980
 	/**
1981
-	* Get count of schedule items
1982
-	* @param string $schedule_name
1983
-	* @return int $count
1984
-	*/
1981
+	 * Get count of schedule items
1982
+	 * @param string $schedule_name
1983
+	 * @return int $count
1984
+	 */
1985 1985
 	private function get_schedule_count( $schedule_name = '' ) {
1986 1986
 		if ( '' !== $schedule_name ) {
1987 1987
 			$args  = array(
@@ -1996,21 +1996,21 @@  discard block
 block discarded – undo
1996 1996
 	}
1997 1997
 
1998 1998
 	/**
1999
-	* Create an object map between a WordPress object and a Salesforce object
2000
-	*
2001
-	* @param int $wordpress_id
2002
-	*   Unique identifier for the WordPress object
2003
-	* @param string $wordpress_object
2004
-	*   What kind of object is it?
2005
-	* @param string $salesforce_id
2006
-	*   Unique identifier for the Salesforce object
2007
-	* @param string $action
2008
-	*   Did we push or pull?
2009
-	*
2010
-	* @return int $wpdb->insert_id
2011
-	*   This is the database row for the map object
2012
-	*
2013
-	*/
1999
+	 * Create an object map between a WordPress object and a Salesforce object
2000
+	 *
2001
+	 * @param int $wordpress_id
2002
+	 *   Unique identifier for the WordPress object
2003
+	 * @param string $wordpress_object
2004
+	 *   What kind of object is it?
2005
+	 * @param string $salesforce_id
2006
+	 *   Unique identifier for the Salesforce object
2007
+	 * @param string $action
2008
+	 *   Did we push or pull?
2009
+	 *
2010
+	 * @return int $wpdb->insert_id
2011
+	 *   This is the database row for the map object
2012
+	 *
2013
+	 */
2014 2014
 	private function create_object_map( $wordpress_id, $wordpress_object, $salesforce_id, $action = '' ) {
2015 2015
 		// Create object map and save it
2016 2016
 		$mapping_object = $this->mappings->create_object_map(
Please login to merge, or discard this patch.
Spacing   +572 added lines, -572 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
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	* @param object $queue
85 85
 	* @throws \Exception
86 86
 	*/
87
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) {
87
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue) {
88 88
 		$this->wpdb                = $wpdb;
89 89
 		$this->version             = $version;
90 90
 		$this->login_credentials   = $login_credentials;
@@ -124,35 +124,35 @@  discard block
 block discarded – undo
124 124
 	*
125 125
 	*/
126 126
 	public function add_actions() {
127
-		add_action( 'admin_init', array( $this, 'salesforce_settings_forms' ) );
128
-		add_action( 'admin_init', array( $this, 'notices' ) );
129
-		add_action( 'admin_post_post_fieldmap', array( $this, 'prepare_fieldmap_data' ) );
130
-
131
-		add_action( 'admin_post_delete_fieldmap', array( $this, 'delete_fieldmap' ) );
132
-		add_action( 'wp_ajax_get_salesforce_object_description', array( $this, 'get_salesforce_object_description' ) );
133
-		add_action( 'wp_ajax_get_wordpress_object_description', array( $this, 'get_wordpress_object_fields' ) );
134
-		add_action( 'wp_ajax_get_wp_sf_object_fields', array( $this, 'get_wp_sf_object_fields' ) );
135
-		add_action( 'wp_ajax_push_to_salesforce', array( $this, 'push_to_salesforce' ) );
136
-		add_action( 'wp_ajax_pull_from_salesforce', array( $this, 'pull_from_salesforce' ) );
137
-		add_action( 'wp_ajax_refresh_mapped_data', array( $this, 'refresh_mapped_data' ) );
138
-		add_action( 'wp_ajax_clear_sfwp_cache', array( $this, 'clear_sfwp_cache' ) );
139
-
140
-		add_action( 'edit_user_profile', array( $this, 'show_salesforce_user_fields' ) );
141
-		add_action( 'personal_options_update', array( $this, 'save_salesforce_user_fields' ) );
142
-		add_action( 'edit_user_profile_update', array( $this, 'save_salesforce_user_fields' ) );
127
+		add_action('admin_init', array($this, 'salesforce_settings_forms'));
128
+		add_action('admin_init', array($this, 'notices'));
129
+		add_action('admin_post_post_fieldmap', array($this, 'prepare_fieldmap_data'));
130
+
131
+		add_action('admin_post_delete_fieldmap', array($this, 'delete_fieldmap'));
132
+		add_action('wp_ajax_get_salesforce_object_description', array($this, 'get_salesforce_object_description'));
133
+		add_action('wp_ajax_get_wordpress_object_description', array($this, 'get_wordpress_object_fields'));
134
+		add_action('wp_ajax_get_wp_sf_object_fields', array($this, 'get_wp_sf_object_fields'));
135
+		add_action('wp_ajax_push_to_salesforce', array($this, 'push_to_salesforce'));
136
+		add_action('wp_ajax_pull_from_salesforce', array($this, 'pull_from_salesforce'));
137
+		add_action('wp_ajax_refresh_mapped_data', array($this, 'refresh_mapped_data'));
138
+		add_action('wp_ajax_clear_sfwp_cache', array($this, 'clear_sfwp_cache'));
139
+
140
+		add_action('edit_user_profile', array($this, 'show_salesforce_user_fields'));
141
+		add_action('personal_options_update', array($this, 'save_salesforce_user_fields'));
142
+		add_action('edit_user_profile_update', array($this, 'save_salesforce_user_fields'));
143 143
 
144 144
 		// when either field for schedule settings changes
145
-		foreach ( $this->schedulable_classes as $key => $value ) {
146
-			add_filter( 'update_option_' . $this->option_prefix . $key . '_schedule_number', array( $this, 'change_action_schedule' ), 10, 3 );
147
-			add_filter( 'update_option_' . $this->option_prefix . $key . '_schedule_unit', array( $this, 'change_action_schedule' ), 10, 3 );
145
+		foreach ($this->schedulable_classes as $key => $value) {
146
+			add_filter('update_option_' . $this->option_prefix . $key . '_schedule_number', array($this, 'change_action_schedule'), 10, 3);
147
+			add_filter('update_option_' . $this->option_prefix . $key . '_schedule_unit', array($this, 'change_action_schedule'), 10, 3);
148 148
 		}
149 149
 
150
-		add_action( 'admin_post_delete_object_map', array( $this, 'delete_object_map' ) );
151
-		add_action( 'admin_post_post_object_map', array( $this, 'prepare_object_map_data' ) );
150
+		add_action('admin_post_delete_object_map', array($this, 'delete_object_map'));
151
+		add_action('admin_post_post_object_map', array($this, 'prepare_object_map_data'));
152 152
 
153 153
 		// import and export plugin data
154
-		add_action( 'admin_post_object_sync_for_salesforce_import', array( $this, 'import_json_file' ) );
155
-		add_action( 'admin_post_object_sync_for_salesforce_export', array( $this, 'export_json_file' ) );
154
+		add_action('admin_post_object_sync_for_salesforce_import', array($this, 'import_json_file'));
155
+		add_action('admin_post_object_sync_for_salesforce_export', array($this, 'export_json_file'));
156 156
 
157 157
 	}
158 158
 
@@ -160,35 +160,35 @@  discard block
 block discarded – undo
160 160
 	* Recurring task to check Salesforce for data
161 161
 	*
162 162
 	*/
163
-	public function change_action_schedule( $old_schedule, $new_schedule, $option_name ) {
163
+	public function change_action_schedule($old_schedule, $new_schedule, $option_name) {
164 164
 
165 165
 		// exit if nothing changed
166
-		if ( $old_schedule === $new_schedule ) {
166
+		if ($old_schedule === $new_schedule) {
167 167
 			return;
168 168
 		}
169 169
 
170 170
 		// get the current schedule name from the task, based on pattern in the foreach
171
-		preg_match( '/' . $this->option_prefix . '(.*)_schedule/', $option_name, $matches );
171
+		preg_match('/' . $this->option_prefix . '(.*)_schedule/', $option_name, $matches);
172 172
 		$schedule_name     = $matches[1];
173 173
 		$action_group_name = $schedule_name . '_check_records';
174 174
 
175 175
 		// exit if there is no initializer property on this schedule
176
-		if ( ! isset( $this->schedulable_classes[ $schedule_name ]['initializer'] ) ) {
176
+		if ( ! isset($this->schedulable_classes[$schedule_name]['initializer'])) {
177 177
 			return;
178 178
 		}
179 179
 
180 180
 		// cancel previous task
181 181
 		$this->queue->cancel(
182
-			$this->schedulable_classes[ $schedule_name ]['initializer'],
182
+			$this->schedulable_classes[$schedule_name]['initializer'],
183 183
 			array(),
184 184
 			$action_group_name
185 185
 		);
186 186
 
187 187
 		// create new recurring task for action-scheduler to check for data to pull from salesforce
188 188
 		$this->queue->schedule_recurring(
189
-			current_time( 'timestamp', true ), // plugin seems to expect UTC
190
-			$this->queue->get_frequency( $schedule_name, 'seconds' ),
191
-			$this->schedulable_classes[ $schedule_name ]['initializer'],
189
+			current_time('timestamp', true), // plugin seems to expect UTC
190
+			$this->queue->get_frequency($schedule_name, 'seconds'),
191
+			$this->schedulable_classes[$schedule_name]['initializer'],
192 192
 			array(),
193 193
 			$action_group_name
194 194
 		);
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	*
200 200
 	*/
201 201
 	public function create_admin_menu() {
202
-		$title = __( 'Salesforce', 'object-sync-for-salesforce' );
203
-		add_options_page( $title, $title, 'configure_salesforce', 'object-sync-salesforce-admin', array( $this, 'show_admin_page' ) );
202
+		$title = __('Salesforce', 'object-sync-for-salesforce');
203
+		add_options_page($title, $title, 'configure_salesforce', 'object-sync-salesforce-admin', array($this, 'show_admin_page'));
204 204
 	}
205 205
 
206 206
 	/**
@@ -211,114 +211,114 @@  discard block
 block discarded – undo
211 211
 	*
212 212
 	*/
213 213
 	public function show_admin_page() {
214
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
214
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
215 215
 		echo '<div class="wrap">';
216
-		echo '<h1>' . esc_html( get_admin_page_title() ) . '</h1>';
216
+		echo '<h1>' . esc_html(get_admin_page_title()) . '</h1>';
217 217
 		$allowed = $this->check_wordpress_admin_permissions();
218
-		if ( false === $allowed ) {
218
+		if (false === $allowed) {
219 219
 			return;
220 220
 		}
221 221
 		$tabs = array(
222
-			'settings'      => __( 'Settings', 'object-sync-for-salesforce' ),
223
-			'authorize'     => __( 'Authorize', 'object-sync-for-salesforce' ),
224
-			'fieldmaps'     => __( 'Fieldmaps', 'object-sync-for-salesforce' ),
225
-			'schedule'      => __( 'Scheduling', 'object-sync-for-salesforce' ),
226
-			'import-export' => __( 'Import &amp; Export', 'object-sync-for-salesforce' ),
222
+			'settings'      => __('Settings', 'object-sync-for-salesforce'),
223
+			'authorize'     => __('Authorize', 'object-sync-for-salesforce'),
224
+			'fieldmaps'     => __('Fieldmaps', 'object-sync-for-salesforce'),
225
+			'schedule'      => __('Scheduling', 'object-sync-for-salesforce'),
226
+			'import-export' => __('Import &amp; Export', 'object-sync-for-salesforce'),
227 227
 		); // this creates the tabs for the admin
228 228
 
229 229
 		// optionally make tab(s) for logging and log settings
230
-		$logging_enabled      = get_option( $this->option_prefix . 'enable_logging', false );
231
-		$tabs['log_settings'] = __( 'Log Settings', 'object-sync-for-salesforce' );
230
+		$logging_enabled      = get_option($this->option_prefix . 'enable_logging', false);
231
+		$tabs['log_settings'] = __('Log Settings', 'object-sync-for-salesforce');
232 232
 
233 233
 		$mapping_errors = $this->mappings->get_failed_object_maps();
234
-		if ( ! empty( $mapping_errors ) ) {
235
-			$tabs['mapping_errors'] = __( 'Mapping Errors', 'object-sync-for-salesforce' );
234
+		if ( ! empty($mapping_errors)) {
235
+			$tabs['mapping_errors'] = __('Mapping Errors', 'object-sync-for-salesforce');
236 236
 		}
237 237
 
238 238
 		// filter for extending the tabs available on the page
239 239
 		// currently it will go into the default switch case for $tab
240
-		$tabs = apply_filters( 'object_sync_for_salesforce_settings_tabs', $tabs );
240
+		$tabs = apply_filters('object_sync_for_salesforce_settings_tabs', $tabs);
241 241
 
242
-		$tab = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
243
-		$this->tabs( $tabs, $tab );
242
+		$tab = isset($get_data['tab']) ? sanitize_key($get_data['tab']) : 'settings';
243
+		$this->tabs($tabs, $tab);
244 244
 
245 245
 		$consumer_key    = $this->login_credentials['consumer_key'];
246 246
 		$consumer_secret = $this->login_credentials['consumer_secret'];
247 247
 		$callback_url    = $this->login_credentials['callback_url'];
248 248
 
249
-		if ( true !== $this->salesforce['is_authorized'] ) {
250
-			$url     = esc_url( $callback_url );
251
-			$anchor  = esc_html__( 'Authorize tab', 'object-sync-for-salesforce' );
252
-			$message = sprintf( 'Salesforce needs to be authorized to connect to this website. Use the <a href="%s">%s</a> to connect.', $url, $anchor );
253
-			require( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
249
+		if (true !== $this->salesforce['is_authorized']) {
250
+			$url     = esc_url($callback_url);
251
+			$anchor  = esc_html__('Authorize tab', 'object-sync-for-salesforce');
252
+			$message = sprintf('Salesforce needs to be authorized to connect to this website. Use the <a href="%s">%s</a> to connect.', $url, $anchor);
253
+			require(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
254 254
 		}
255 255
 
256
-		if ( 0 === count( $this->mappings->get_fieldmaps() ) ) {
257
-			$url     = esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps' ) );
258
-			$anchor  = esc_html__( 'Fieldmaps tab', 'object-sync-for-salesforce' );
259
-			$message = sprintf( 'No fieldmaps exist yet. Use the <a href="%s">%s</a> to map WordPress and Salesforce objects to each other.', $url, $anchor );
260
-			require( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
256
+		if (0 === count($this->mappings->get_fieldmaps())) {
257
+			$url     = esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps'));
258
+			$anchor  = esc_html__('Fieldmaps tab', 'object-sync-for-salesforce');
259
+			$message = sprintf('No fieldmaps exist yet. Use the <a href="%s">%s</a> to map WordPress and Salesforce objects to each other.', $url, $anchor);
260
+			require(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
261 261
 		}
262 262
 
263
-		$push_schedule_number = get_option( $this->option_prefix . 'salesforce_push_schedule_number', '' );
264
-		$push_schedule_unit   = get_option( $this->option_prefix . 'salesforce_push_schedule_unit', '' );
265
-		$pull_schedule_number = get_option( $this->option_prefix . 'salesforce_pull_schedule_number', '' );
266
-		$pull_schedule_unit   = get_option( $this->option_prefix . 'salesforce_pull_schedule_unit', '' );
263
+		$push_schedule_number = get_option($this->option_prefix . 'salesforce_push_schedule_number', '');
264
+		$push_schedule_unit   = get_option($this->option_prefix . 'salesforce_push_schedule_unit', '');
265
+		$pull_schedule_number = get_option($this->option_prefix . 'salesforce_pull_schedule_number', '');
266
+		$pull_schedule_unit   = get_option($this->option_prefix . 'salesforce_pull_schedule_unit', '');
267 267
 
268
-		if ( '' === $push_schedule_number && '' === $push_schedule_unit && '' === $pull_schedule_number && '' === $pull_schedule_unit ) {
269
-			$url     = esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=schedule' ) );
270
-			$anchor  = esc_html__( 'Scheduling tab', 'object-sync-for-salesforce' );
271
-			$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 );
272
-			require( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
268
+		if ('' === $push_schedule_number && '' === $push_schedule_unit && '' === $pull_schedule_number && '' === $pull_schedule_unit) {
269
+			$url     = esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=schedule'));
270
+			$anchor  = esc_html__('Scheduling tab', 'object-sync-for-salesforce');
271
+			$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);
272
+			require(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
273 273
 		}
274 274
 
275 275
 		try {
276
-			switch ( $tab ) {
276
+			switch ($tab) {
277 277
 				case 'authorize':
278
-					if ( isset( $get_data['code'] ) ) {
278
+					if (isset($get_data['code'])) {
279 279
 						// this string is an oauth token
280
-						$data          = esc_html( wp_unslash( $get_data['code'] ) );
281
-						$is_authorized = $this->salesforce['sfapi']->request_token( $data );
280
+						$data          = esc_html(wp_unslash($get_data['code']));
281
+						$is_authorized = $this->salesforce['sfapi']->request_token($data);
282 282
 						?>
283
-						<script>window.location = '<?php echo esc_url_raw( $callback_url ); ?>'</script>
283
+						<script>window.location = '<?php echo esc_url_raw($callback_url); ?>'</script>
284 284
 						<?php
285
-					} elseif ( true === $this->salesforce['is_authorized'] ) {
286
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/authorized.php' );
287
-							$this->status( $this->salesforce['sfapi'] );
288
-					} elseif ( true === is_object( $this->salesforce['sfapi'] ) && isset( $consumer_key ) && isset( $consumer_secret ) ) {
285
+					} elseif (true === $this->salesforce['is_authorized']) {
286
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/authorized.php');
287
+							$this->status($this->salesforce['sfapi']);
288
+					} elseif (true === is_object($this->salesforce['sfapi']) && isset($consumer_key) && isset($consumer_secret)) {
289 289
 						?>
290
-						<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>
290
+						<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>
291 291
 						<?php
292 292
 					} else {
293
-						$url    = esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=settings' ) );
294
-						$anchor = esc_html__( 'Settings', 'object-sync-for-salesforce' );
293
+						$url    = esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=settings'));
294
+						$anchor = esc_html__('Settings', 'object-sync-for-salesforce');
295 295
 						// translators: placeholders are for the settings tab link: 1) the url, and 2) the anchor text
296
-						$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 );
297
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/error.php' );
296
+						$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);
297
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/error.php');
298 298
 					}
299 299
 					break;
300 300
 				case 'fieldmaps':
301
-					if ( isset( $get_data['method'] ) ) {
301
+					if (isset($get_data['method'])) {
302 302
 
303
-						$method      = sanitize_key( $get_data['method'] );
304
-						$error_url   = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps&method=' . $method );
305
-						$success_url = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps' );
303
+						$method      = sanitize_key($get_data['method']);
304
+						$error_url   = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps&method=' . $method);
305
+						$success_url = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=fieldmaps');
306 306
 
307
-						if ( isset( $get_data['transient'] ) ) {
308
-							$transient = sanitize_key( $get_data['transient'] );
309
-							$posted    = $this->sfwp_transients->get( $transient );
307
+						if (isset($get_data['transient'])) {
308
+							$transient = sanitize_key($get_data['transient']);
309
+							$posted    = $this->sfwp_transients->get($transient);
310 310
 						}
311 311
 
312
-						if ( isset( $posted ) && is_array( $posted ) ) {
312
+						if (isset($posted) && is_array($posted)) {
313 313
 							$map = $posted;
314
-						} elseif ( 'edit' === $method || 'clone' === $method || 'delete' === $method ) {
315
-							$map = $this->mappings->get_fieldmaps( isset( $get_data['id'] ) ? sanitize_key( $get_data['id'] ) : '' );
314
+						} elseif ('edit' === $method || 'clone' === $method || 'delete' === $method) {
315
+							$map = $this->mappings->get_fieldmaps(isset($get_data['id']) ? sanitize_key($get_data['id']) : '');
316 316
 						}
317 317
 
318
-						if ( isset( $map ) && is_array( $map ) ) {
318
+						if (isset($map) && is_array($map)) {
319 319
 							$label                           = $map['label'];
320 320
 							$salesforce_object               = $map['salesforce_object'];
321
-							$salesforce_record_types_allowed = maybe_unserialize( $map['salesforce_record_types_allowed'] );
321
+							$salesforce_record_types_allowed = maybe_unserialize($map['salesforce_record_types_allowed']);
322 322
 							$salesforce_record_type_default  = $map['salesforce_record_type_default'];
323 323
 							$wordpress_object                = $map['wordpress_object'];
324 324
 							$pull_trigger_field              = $map['pull_trigger_field'];
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 							$weight                          = $map['weight'];
330 330
 						}
331 331
 
332
-						if ( 'add' === $method || 'edit' === $method || 'clone' === $method ) {
333
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/fieldmaps-add-edit-clone.php' );
334
-						} elseif ( 'delete' === $method ) {
335
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/fieldmaps-delete.php' );
332
+						if ('add' === $method || 'edit' === $method || 'clone' === $method) {
333
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/fieldmaps-add-edit-clone.php');
334
+						} elseif ('delete' === $method) {
335
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/fieldmaps-delete.php');
336 336
 						}
337 337
 					} else {
338 338
 						$fieldmaps = $this->mappings->get_fieldmaps();
339
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/fieldmaps-list.php' );
339
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/fieldmaps-list.php');
340 340
 					} // End if().
341 341
 					break;
342 342
 				case 'logout':
@@ -346,73 +346,73 @@  discard block
 block discarded – undo
346 346
 					$this->clear_cache();
347 347
 					break;
348 348
 				case 'clear_schedule':
349
-					if ( isset( $get_data['schedule_name'] ) ) {
350
-						$schedule_name = sanitize_key( $get_data['schedule_name'] );
349
+					if (isset($get_data['schedule_name'])) {
350
+						$schedule_name = sanitize_key($get_data['schedule_name']);
351 351
 					}
352
-					$this->clear_schedule( $schedule_name );
352
+					$this->clear_schedule($schedule_name);
353 353
 					break;
354 354
 				case 'settings':
355
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/settings.php' );
355
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/settings.php');
356 356
 					break;
357 357
 				case 'mapping_errors':
358
-					if ( isset( $get_data['method'] ) ) {
358
+					if (isset($get_data['method'])) {
359 359
 
360
-						$method      = sanitize_key( $get_data['method'] );
361
-						$error_url   = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors&method=' . $method );
362
-						$success_url = get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors' );
360
+						$method      = sanitize_key($get_data['method']);
361
+						$error_url   = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors&method=' . $method);
362
+						$success_url = get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=mapping_errors');
363 363
 
364
-						if ( isset( $get_data['map_transient'] ) ) {
365
-							$transient = sanitize_key( $get_data['map_transient'] );
366
-							$posted    = $this->sfwp_transients->get( $transient );
364
+						if (isset($get_data['map_transient'])) {
365
+							$transient = sanitize_key($get_data['map_transient']);
366
+							$posted    = $this->sfwp_transients->get($transient);
367 367
 						}
368 368
 
369
-						if ( isset( $posted ) && is_array( $posted ) ) {
369
+						if (isset($posted) && is_array($posted)) {
370 370
 							$map_row = $posted;
371
-						} elseif ( 'edit' === $method || 'delete' === $method ) {
372
-							$map_row = $this->mappings->get_failed_object_map( isset( $get_data['id'] ) ? sanitize_key( $get_data['id'] ) : '' );
371
+						} elseif ('edit' === $method || 'delete' === $method) {
372
+							$map_row = $this->mappings->get_failed_object_map(isset($get_data['id']) ? sanitize_key($get_data['id']) : '');
373 373
 						}
374 374
 
375
-						if ( isset( $map_row ) && is_array( $map_row ) ) {
375
+						if (isset($map_row) && is_array($map_row)) {
376 376
 							$salesforce_id = $map_row['salesforce_id'];
377 377
 							$wordpress_id  = $map_row['wordpress_id'];
378 378
 						}
379 379
 
380
-						if ( 'edit' === $method ) {
381
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/mapping-errors-edit.php' );
382
-						} elseif ( 'delete' === $method ) {
383
-							require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/mapping-errors-delete.php' );
380
+						if ('edit' === $method) {
381
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/mapping-errors-edit.php');
382
+						} elseif ('delete' === $method) {
383
+							require_once(plugin_dir_path(__FILE__) . '/../templates/admin/mapping-errors-delete.php');
384 384
 						}
385 385
 					} else {
386
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/mapping-errors.php' );
386
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/mapping-errors.php');
387 387
 					}
388 388
 					break;
389 389
 				case 'import-export':
390
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/import-export.php' );
390
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/import-export.php');
391 391
 					break;
392 392
 				default:
393
-					$include_settings = apply_filters( 'object_sync_for_salesforce_settings_tab_include_settings', true, $tab );
394
-					$content_before   = apply_filters( 'object_sync_for_salesforce_settings_tab_content_before', null, $tab );
395
-					$content_after    = apply_filters( 'object_sync_for_salesforce_settings_tab_content_after', null, $tab );
396
-					if ( null !== $content_before ) {
397
-						echo esc_html( $content_before );
393
+					$include_settings = apply_filters('object_sync_for_salesforce_settings_tab_include_settings', true, $tab);
394
+					$content_before   = apply_filters('object_sync_for_salesforce_settings_tab_content_before', null, $tab);
395
+					$content_after    = apply_filters('object_sync_for_salesforce_settings_tab_content_after', null, $tab);
396
+					if (null !== $content_before) {
397
+						echo esc_html($content_before);
398 398
 					}
399
-					if ( true === $include_settings ) {
400
-						require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/settings.php' );
399
+					if (true === $include_settings) {
400
+						require_once(plugin_dir_path(__FILE__) . '/../templates/admin/settings.php');
401 401
 					}
402
-					if ( null !== $content_after ) {
403
-						echo esc_html( $content_after );
402
+					if (null !== $content_after) {
403
+						echo esc_html($content_after);
404 404
 					}
405 405
 					break;
406 406
 			} // End switch().
407
-		} catch ( SalesforceApiException $ex ) {
408
-			echo sprintf( '<p>Error <strong>%1$s</strong>: %2$s</p>',
409
-				absint( $ex->getCode() ),
410
-				esc_html( $ex->getMessage() )
407
+		} catch (SalesforceApiException $ex) {
408
+			echo sprintf('<p>Error <strong>%1$s</strong>: %2$s</p>',
409
+				absint($ex->getCode()),
410
+				esc_html($ex->getMessage())
411 411
 			);
412
-		} catch ( Exception $ex ) {
413
-			echo sprintf( '<p>Error <strong>%1$s</strong>: %2$s</p>',
414
-				absint( $ex->getCode() ),
415
-				esc_html( $ex->getMessage() )
412
+		} catch (Exception $ex) {
413
+			echo sprintf('<p>Error <strong>%1$s</strong>: %2$s</p>',
414
+				absint($ex->getCode()),
415
+				esc_html($ex->getMessage())
416 416
 			);
417 417
 		} // End try().
418 418
 		echo '</div>';
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
 	*
425 425
 	*/
426 426
 	public function salesforce_settings_forms() {
427
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
428
-		$page     = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
429
-		$section  = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings';
427
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
428
+		$page     = isset($get_data['tab']) ? sanitize_key($get_data['tab']) : 'settings';
429
+		$section  = isset($get_data['tab']) ? sanitize_key($get_data['tab']) : 'settings';
430 430
 
431
-		$input_callback_default   = array( $this, 'display_input_field' );
432
-		$input_checkboxes_default = array( $this, 'display_checkboxes' );
433
-		$input_select_default     = array( $this, 'display_select' );
434
-		$link_default             = array( $this, 'display_link' );
431
+		$input_callback_default   = array($this, 'display_input_field');
432
+		$input_checkboxes_default = array($this, 'display_checkboxes');
433
+		$input_select_default     = array($this, 'display_select');
434
+		$link_default             = array($this, 'display_link');
435 435
 
436 436
 		$all_field_callbacks = array(
437 437
 			'text'       => $input_callback_default,
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 			'link'       => $link_default,
441 441
 		);
442 442
 
443
-		$this->fields_settings( 'settings', 'settings', $all_field_callbacks );
444
-		$this->fields_fieldmaps( 'fieldmaps', 'objects' );
445
-		$this->fields_scheduling( 'schedule', 'schedule', $all_field_callbacks );
446
-		$this->fields_log_settings( 'log_settings', 'log_settings', $all_field_callbacks );
443
+		$this->fields_settings('settings', 'settings', $all_field_callbacks);
444
+		$this->fields_fieldmaps('fieldmaps', 'objects');
445
+		$this->fields_scheduling('schedule', 'schedule', $all_field_callbacks);
446
+		$this->fields_log_settings('log_settings', 'log_settings', $all_field_callbacks);
447 447
 	}
448 448
 
449 449
 	/**
@@ -454,11 +454,11 @@  discard block
 block discarded – undo
454 454
 	* @param string $section
455 455
 	* @param string $input_callback
456 456
 	*/
457
-	private function fields_settings( $page, $section, $callbacks ) {
458
-		add_settings_section( $page, ucwords( $page ), null, $page );
457
+	private function fields_settings($page, $section, $callbacks) {
458
+		add_settings_section($page, ucwords($page), null, $page);
459 459
 		$salesforce_settings = array(
460 460
 			'consumer_key'                   => array(
461
-				'title'    => __( 'Consumer Key', 'object-sync-for-salesforce' ),
461
+				'title'    => __('Consumer Key', 'object-sync-for-salesforce'),
462 462
 				'callback' => $callbacks['text'],
463 463
 				'page'     => $page,
464 464
 				'section'  => $section,
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 
472 472
 			),
473 473
 			'consumer_secret'                => array(
474
-				'title'    => __( 'Consumer Secret', 'object-sync-for-salesforce' ),
474
+				'title'    => __('Consumer Secret', 'object-sync-for-salesforce'),
475 475
 				'callback' => $callbacks['text'],
476 476
 				'page'     => $page,
477 477
 				'section'  => $section,
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 				),
484 484
 			),
485 485
 			'callback_url'                   => array(
486
-				'title'    => __( 'Callback URL', 'object-sync-for-salesforce' ),
486
+				'title'    => __('Callback URL', 'object-sync-for-salesforce'),
487 487
 				'callback' => $callbacks['text'],
488 488
 				'page'     => $page,
489 489
 				'section'  => $section,
@@ -491,14 +491,14 @@  discard block
 block discarded – undo
491 491
 					'type'     => 'url',
492 492
 					'validate' => 'sanitize_validate_text',
493 493
 					// translators: %1$s is the admin URL for the Authorize tab
494
-					'desc'     => sprintf( __( 'In most cases, you will want to use %1$s for this value.', 'object-sync-for-salesforce' ),
495
-						get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize' )
494
+					'desc'     => sprintf(__('In most cases, you will want to use %1$s for this value.', 'object-sync-for-salesforce'),
495
+						get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize')
496 496
 					),
497 497
 					'constant' => 'OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL',
498 498
 				),
499 499
 			),
500 500
 			'login_base_url'                 => array(
501
-				'title'    => __( 'Login Base URL', 'object-sync-for-salesforce' ),
501
+				'title'    => __('Login Base URL', 'object-sync-for-salesforce'),
502 502
 				'callback' => $callbacks['text'],
503 503
 				'page'     => $page,
504 504
 				'section'  => $section,
@@ -506,22 +506,22 @@  discard block
 block discarded – undo
506 506
 					'type'     => 'url',
507 507
 					'validate' => 'sanitize_validate_text',
508 508
 					// translators: 1) production salesforce login, 2) sandbox salesforce login
509
-					'desc'     => sprintf( __( 'For most Salesforce setups, you should use %1$s for production and %2$s for sandbox.', 'object-sync-for-salesforce' ),
510
-						esc_url( 'https://login.salesforce.com' ),
511
-						esc_url( 'https://test.salesforce.com' )
509
+					'desc'     => sprintf(__('For most Salesforce setups, you should use %1$s for production and %2$s for sandbox.', 'object-sync-for-salesforce'),
510
+						esc_url('https://login.salesforce.com'),
511
+						esc_url('https://test.salesforce.com')
512 512
 					),
513 513
 					'constant' => 'OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL',
514 514
 				),
515 515
 			),
516 516
 			'authorize_url_path'             => array(
517
-				'title'    => __( 'Authorize URL Path', 'object-sync-for-salesforce' ),
517
+				'title'    => __('Authorize URL Path', 'object-sync-for-salesforce'),
518 518
 				'callback' => $callbacks['text'],
519 519
 				'page'     => $page,
520 520
 				'section'  => $section,
521 521
 				'args'     => array(
522 522
 					'type'     => 'text',
523 523
 					'validate' => 'sanitize_validate_text',
524
-					'desc'     => __( 'For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce' ),
524
+					'desc'     => __('For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce'),
525 525
 					'constant' => 'OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH',
526 526
 					'default'  => $this->default_authorize_url_path,
527 527
 				),
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				'args'     => array(
535 535
 					'type'     => 'text',
536 536
 					'validate' => 'sanitize_validate_text',
537
-					'desc'     => __( 'For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce' ),
537
+					'desc'     => __('For most Salesforce installs, this should not be changed.', 'object-sync-for-salesforce'),
538 538
 					'constant' => 'OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH',
539 539
 					'default'  => $this->default_token_url_path,
540 540
 				),
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 				'args'     => array(
561 561
 					'type'     => 'checkboxes',
562 562
 					'validate' => 'sanitize_validate_text',
563
-					'desc'     => __( 'Allows you to limit which Salesforce objects can be mapped', 'object-sync-for-salesforce' ),
563
+					'desc'     => __('Allows you to limit which Salesforce objects can be mapped', 'object-sync-for-salesforce'),
564 564
 					'items'    => array(
565 565
 						'triggerable' => array(
566 566
 							'text'    => 'Only Triggerable objects',
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 					'constant' => '',
590 590
 					'items'    => array(
591 591
 						'field_label' => array(
592
-							'text'  => __( 'Field Label', 'object-sync-for-salesforce' ),
592
+							'text'  => __('Field Label', 'object-sync-for-salesforce'),
593 593
 							'value' => 'field_label',
594 594
 						),
595 595
 						/*'field_name'  => array(
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 							'value' => 'field_name',
598 598
 						),*/
599 599
 						'api_name'    => array(
600
-							'text'  => __( 'API Name', 'object-sync-for-salesforce' ),
600
+							'text'  => __('API Name', 'object-sync-for-salesforce'),
601 601
 							'value' => 'api_name',
602 602
 						),
603 603
 					),
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 				'args'     => array(
612 612
 					'type'     => 'number',
613 613
 					'validate' => 'sanitize_validate_text',
614
-					'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' ),
614
+					'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'),
615 615
 					'constant' => '',
616 616
 					'default'  => $this->default_pull_throttle,
617 617
 				),
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 				'args'     => array(
625 625
 					'type'     => 'checkbox',
626 626
 					'validate' => 'sanitize_validate_text',
627
-					'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' ),
627
+					'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'),
628 628
 					'constant' => '',
629 629
 				),
630 630
 			),
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
 				'args'     => array(
637 637
 					'type'     => 'checkbox',
638 638
 					'validate' => 'sanitize_validate_text',
639
-					'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' ),
639
+					'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'),
640 640
 					'constant' => '',
641 641
 				),
642 642
 			),
643 643
 		);
644 644
 
645
-		if ( true === is_object( $this->salesforce['sfapi'] ) && true === $this->salesforce['sfapi']->is_authorized() ) {
645
+		if (true === is_object($this->salesforce['sfapi']) && true === $this->salesforce['sfapi']->is_authorized()) {
646 646
 			$salesforce_settings['api_version'] = array(
647 647
 				'title'    => 'Salesforce API Version',
648 648
 				'callback' => $callbacks['select'],
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 			);
659 659
 		}
660 660
 
661
-		foreach ( $salesforce_settings as $key => $attributes ) {
661
+		foreach ($salesforce_settings as $key => $attributes) {
662 662
 			$id       = $this->option_prefix . $key;
663 663
 			$name     = $this->option_prefix . $key;
664 664
 			$title    = $attributes['title'];
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 			);
678 678
 
679 679
 			// if there is a constant and it is defined, don't run a validate function
680
-			if ( isset( $attributes['args']['constant'] ) && defined( $attributes['args']['constant'] ) ) {
680
+			if (isset($attributes['args']['constant']) && defined($attributes['args']['constant'])) {
681 681
 				$validate = '';
682 682
 			}
683 683
 
684
-			add_settings_field( $id, $title, $callback, $page, $section, $args );
685
-			register_setting( $page, $id, array( $this, $validate ) );
684
+			add_settings_field($id, $title, $callback, $page, $section, $args);
685
+			register_setting($page, $id, array($this, $validate));
686 686
 		}
687 687
 	}
688 688
 
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
 	* @param string $section
695 695
 	* @param string $input_callback
696 696
 	*/
697
-	private function fields_fieldmaps( $page, $section, $input_callback = '' ) {
698
-		add_settings_section( $page, ucwords( $page ), null, $page );
697
+	private function fields_fieldmaps($page, $section, $input_callback = '') {
698
+		add_settings_section($page, ucwords($page), null, $page);
699 699
 	}
700 700
 
701 701
 	/**
@@ -706,13 +706,13 @@  discard block
 block discarded – undo
706 706
 	* @param string $section
707 707
 	* @param string $input_callback
708 708
 	*/
709
-	private function fields_scheduling( $page, $section, $callbacks ) {
710
-		foreach ( $this->schedulable_classes as $key => $value ) {
711
-			add_settings_section( $key, $value['label'], null, $page );
709
+	private function fields_scheduling($page, $section, $callbacks) {
710
+		foreach ($this->schedulable_classes as $key => $value) {
711
+			add_settings_section($key, $value['label'], null, $page);
712 712
 			$schedule_settings = array();
713
-			if ( isset( $value['initializer'] ) ) {
714
-				$schedule_settings[ $key . '_schedule_number' ] = array(
715
-					'title'    => __( 'Run schedule every', 'object-sync-for-salesforce' ),
713
+			if (isset($value['initializer'])) {
714
+				$schedule_settings[$key . '_schedule_number'] = array(
715
+					'title'    => __('Run schedule every', 'object-sync-for-salesforce'),
716 716
 					'callback' => $callbacks['text'],
717 717
 					'page'     => $page,
718 718
 					'section'  => $key,
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 						'constant' => '',
724 724
 					),
725 725
 				);
726
-				$schedule_settings[ $key . '_schedule_unit' ]   = array(
727
-					'title'    => __( 'Time unit', 'object-sync-for-salesforce' ),
726
+				$schedule_settings[$key . '_schedule_unit'] = array(
727
+					'title'    => __('Time unit', 'object-sync-for-salesforce'),
728 728
 					'callback' => $callbacks['select'],
729 729
 					'page'     => $page,
730 730
 					'section'  => $key,
@@ -734,48 +734,48 @@  discard block
 block discarded – undo
734 734
 						'desc'     => '',
735 735
 						'items'    => array(
736 736
 							'minutes' => array(
737
-								'text'  => __( 'Minutes', 'object-sync-for-salesforce' ),
737
+								'text'  => __('Minutes', 'object-sync-for-salesforce'),
738 738
 								'value' => 'minutes',
739 739
 							),
740 740
 							'hours'   => array(
741
-								'text'  => __( 'Hours', 'object-sync-for-salesforce' ),
741
+								'text'  => __('Hours', 'object-sync-for-salesforce'),
742 742
 								'value' => 'hours',
743 743
 							),
744 744
 							'days'    => array(
745
-								'text'  => __( 'Days', 'object-sync-for-salesforce' ),
745
+								'text'  => __('Days', 'object-sync-for-salesforce'),
746 746
 								'value' => 'days',
747 747
 							),
748 748
 						),
749 749
 					),
750 750
 				);
751
-				$schedule_settings[ $key . '_clear_button' ]    = array(
751
+				$schedule_settings[$key . '_clear_button'] = array(
752 752
 					// translators: $this->get_schedule_count is an integer showing how many items are in the current queue
753
-					'title'    => sprintf( 'This queue has ' . _n( '%s item', '%s items', $this->get_schedule_count( $key ), 'object-sync-for-salesforce' ), $this->get_schedule_count( $key ) ),
753
+					'title'    => sprintf('This queue has ' . _n('%s item', '%s items', $this->get_schedule_count($key), 'object-sync-for-salesforce'), $this->get_schedule_count($key)),
754 754
 					'callback' => $callbacks['link'],
755 755
 					'page'     => $page,
756 756
 					'section'  => $key,
757 757
 					'args'     => array(
758
-						'label'      => __( 'Clear this queue', 'object-sync-for-salesforce' ),
758
+						'label'      => __('Clear this queue', 'object-sync-for-salesforce'),
759 759
 						'desc'       => '',
760
-						'url'        => esc_url( '?page=object-sync-salesforce-admin&amp;tab=clear_schedule&amp;schedule_name=' . $key ),
760
+						'url'        => esc_url('?page=object-sync-salesforce-admin&amp;tab=clear_schedule&amp;schedule_name=' . $key),
761 761
 						'link_class' => 'button button-secondary',
762 762
 					),
763 763
 				);
764 764
 			}
765
-			$schedule_settings[ $key . '_clear_button' ] = array(
765
+			$schedule_settings[$key . '_clear_button'] = array(
766 766
 				// translators: $this->get_schedule_count is an integer showing how many items are in the current queue
767
-				'title'    => sprintf( 'This queue has ' . _n( '%s item', '%s items', $this->get_schedule_count( $key ), 'object-sync-for-salesforce' ), $this->get_schedule_count( $key ) ),
767
+				'title'    => sprintf('This queue has ' . _n('%s item', '%s items', $this->get_schedule_count($key), 'object-sync-for-salesforce'), $this->get_schedule_count($key)),
768 768
 				'callback' => $callbacks['link'],
769 769
 				'page'     => $page,
770 770
 				'section'  => $key,
771 771
 				'args'     => array(
772
-					'label'      => __( 'Clear this queue', 'object-sync-for-salesforce' ),
772
+					'label'      => __('Clear this queue', 'object-sync-for-salesforce'),
773 773
 					'desc'       => '',
774
-					'url'        => esc_url( '?page=object-sync-salesforce-admin&amp;tab=clear_schedule&amp;schedule_name=' . $key ),
774
+					'url'        => esc_url('?page=object-sync-salesforce-admin&amp;tab=clear_schedule&amp;schedule_name=' . $key),
775 775
 					'link_class' => 'button button-secondary',
776 776
 				),
777 777
 			);
778
-			foreach ( $schedule_settings as $key => $attributes ) {
778
+			foreach ($schedule_settings as $key => $attributes) {
779 779
 				$id       = $this->option_prefix . $key;
780 780
 				$name     = $this->option_prefix . $key;
781 781
 				$title    = $attributes['title'];
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
 						'name'      => $name,
792 792
 					)
793 793
 				);
794
-				add_settings_field( $id, $title, $callback, $page, $section, $args );
795
-				register_setting( $page, $id );
794
+				add_settings_field($id, $title, $callback, $page, $section, $args);
795
+				register_setting($page, $id);
796 796
 			}
797 797
 		} // End foreach().
798 798
 	}
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 	* @param string $section
806 806
 	* @param array $callbacks
807 807
 	*/
808
-	private function fields_log_settings( $page, $section, $callbacks ) {
809
-		add_settings_section( $page, ucwords( str_replace( '_', ' ', $page ) ), null, $page );
808
+	private function fields_log_settings($page, $section, $callbacks) {
809
+		add_settings_section($page, ucwords(str_replace('_', ' ', $page)), null, $page);
810 810
 		$log_settings = array(
811 811
 			'enable_logging'        => array(
812
-				'title'    => __( 'Enable Logging?', 'object-sync-for-salesforce' ),
812
+				'title'    => __('Enable Logging?', 'object-sync-for-salesforce'),
813 813
 				'callback' => $callbacks['text'],
814 814
 				'page'     => $page,
815 815
 				'section'  => $section,
@@ -821,32 +821,32 @@  discard block
 block discarded – undo
821 821
 				),
822 822
 			),
823 823
 			'statuses_to_log'       => array(
824
-				'title'    => __( 'Statuses to log', 'object-sync-for-salesforce' ),
824
+				'title'    => __('Statuses to log', 'object-sync-for-salesforce'),
825 825
 				'callback' => $callbacks['checkboxes'],
826 826
 				'page'     => $page,
827 827
 				'section'  => $section,
828 828
 				'args'     => array(
829 829
 					'type'     => 'checkboxes',
830 830
 					'validate' => 'sanitize_validate_text',
831
-					'desc'     => __( 'these are the statuses to log', 'object-sync-for-salesforce' ),
831
+					'desc'     => __('these are the statuses to log', 'object-sync-for-salesforce'),
832 832
 					'items'    => array(
833 833
 						'error'   => array(
834
-							'text' => __( 'Error', 'object-sync-for-salesforce' ),
834
+							'text' => __('Error', 'object-sync-for-salesforce'),
835 835
 							'id'   => 'error',
836 836
 							'desc' => '',
837 837
 						),
838 838
 						'success' => array(
839
-							'text' => __( 'Success', 'object-sync-for-salesforce' ),
839
+							'text' => __('Success', 'object-sync-for-salesforce'),
840 840
 							'id'   => 'success',
841 841
 							'desc' => '',
842 842
 						),
843 843
 						'notice'  => array(
844
-							'text' => __( 'Notice', 'object-sync-for-salesforce' ),
844
+							'text' => __('Notice', 'object-sync-for-salesforce'),
845 845
 							'id'   => 'notice',
846 846
 							'desc' => '',
847 847
 						),
848 848
 						'debug'   => array(
849
-							'text' => __( 'Debug', 'object-sync-for-salesforce' ),
849
+							'text' => __('Debug', 'object-sync-for-salesforce'),
850 850
 							'id'   => 'debug',
851 851
 							'desc' => '',
852 852
 						),
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 				),
855 855
 			),
856 856
 			'prune_logs'            => array(
857
-				'title'    => __( 'Automatically delete old log entries?', 'object-sync-for-salesforce' ),
857
+				'title'    => __('Automatically delete old log entries?', 'object-sync-for-salesforce'),
858 858
 				'callback' => $callbacks['text'],
859 859
 				'page'     => $page,
860 860
 				'section'  => $section,
@@ -866,20 +866,20 @@  discard block
 block discarded – undo
866 866
 				),
867 867
 			),
868 868
 			'logs_how_old'          => array(
869
-				'title'    => __( 'Age to delete log entries', 'object-sync-for-salesforce' ),
869
+				'title'    => __('Age to delete log entries', 'object-sync-for-salesforce'),
870 870
 				'callback' => $callbacks['text'],
871 871
 				'page'     => $page,
872 872
 				'section'  => $section,
873 873
 				'args'     => array(
874 874
 					'type'     => 'text',
875 875
 					'validate' => 'sanitize_validate_text',
876
-					'desc'     => __( 'If automatic deleting is enabled, it will affect logs this old.', 'object-sync-for-salesforce' ),
876
+					'desc'     => __('If automatic deleting is enabled, it will affect logs this old.', 'object-sync-for-salesforce'),
877 877
 					'default'  => '2 weeks',
878 878
 					'constant' => '',
879 879
 				),
880 880
 			),
881 881
 			'logs_how_often_number' => array(
882
-				'title'    => __( 'Check for old logs every', 'object-sync-for-salesforce' ),
882
+				'title'    => __('Check for old logs every', 'object-sync-for-salesforce'),
883 883
 				'callback' => $callbacks['text'],
884 884
 				'page'     => $page,
885 885
 				'section'  => $section,
@@ -892,67 +892,67 @@  discard block
 block discarded – undo
892 892
 				),
893 893
 			),
894 894
 			'logs_how_often_unit'   => array(
895
-				'title'    => __( 'Time unit', 'object-sync-for-salesforce' ),
895
+				'title'    => __('Time unit', 'object-sync-for-salesforce'),
896 896
 				'callback' => $callbacks['select'],
897 897
 				'page'     => $page,
898 898
 				'section'  => $section,
899 899
 				'args'     => array(
900 900
 					'type'     => 'select',
901 901
 					'validate' => 'sanitize_validate_text',
902
-					'desc'     => __( 'These two fields are how often the site will check for logs to delete.', 'object-sync-for-salesforce' ),
902
+					'desc'     => __('These two fields are how often the site will check for logs to delete.', 'object-sync-for-salesforce'),
903 903
 					'items'    => array(
904 904
 						'minutes' => array(
905
-							'text'  => __( 'Minutes', 'object-sync-for-salesforce' ),
905
+							'text'  => __('Minutes', 'object-sync-for-salesforce'),
906 906
 							'value' => 'minutes',
907 907
 						),
908 908
 						'hours'   => array(
909
-							'text'  => __( 'Hours', 'object-sync-for-salesforce' ),
909
+							'text'  => __('Hours', 'object-sync-for-salesforce'),
910 910
 							'value' => 'hours',
911 911
 						),
912 912
 						'days'    => array(
913
-							'text'  => __( 'Days', 'object-sync-for-salesforce' ),
913
+							'text'  => __('Days', 'object-sync-for-salesforce'),
914 914
 							'value' => 'days',
915 915
 						),
916 916
 					),
917 917
 				),
918 918
 			),
919 919
 			'triggers_to_log'       => array(
920
-				'title'    => __( 'Triggers to log', 'object-sync-for-salesforce' ),
920
+				'title'    => __('Triggers to log', 'object-sync-for-salesforce'),
921 921
 				'callback' => $callbacks['checkboxes'],
922 922
 				'page'     => $page,
923 923
 				'section'  => $section,
924 924
 				'args'     => array(
925 925
 					'type'     => 'checkboxes',
926 926
 					'validate' => 'sanitize_validate_text',
927
-					'desc'     => __( 'these are the triggers to log', 'object-sync-for-salesforce' ),
927
+					'desc'     => __('these are the triggers to log', 'object-sync-for-salesforce'),
928 928
 					'items'    => array(
929 929
 						$this->mappings->sync_wordpress_create => array(
930
-							'text' => __( 'WordPress create', 'object-sync-for-salesforce' ),
930
+							'text' => __('WordPress create', 'object-sync-for-salesforce'),
931 931
 							'id'   => 'wordpress_create',
932 932
 							'desc' => '',
933 933
 						),
934 934
 						$this->mappings->sync_wordpress_update => array(
935
-							'text' => __( 'WordPress update', 'object-sync-for-salesforce' ),
935
+							'text' => __('WordPress update', 'object-sync-for-salesforce'),
936 936
 							'id'   => 'wordpress_update',
937 937
 							'desc' => '',
938 938
 						),
939 939
 						$this->mappings->sync_wordpress_delete => array(
940
-							'text' => __( 'WordPress delete', 'object-sync-for-salesforce' ),
940
+							'text' => __('WordPress delete', 'object-sync-for-salesforce'),
941 941
 							'id'   => 'wordpress_delete',
942 942
 							'desc' => '',
943 943
 						),
944 944
 						$this->mappings->sync_sf_create => array(
945
-							'text' => __( 'Salesforce create', 'object-sync-for-salesforce' ),
945
+							'text' => __('Salesforce create', 'object-sync-for-salesforce'),
946 946
 							'id'   => 'sf_create',
947 947
 							'desc' => '',
948 948
 						),
949 949
 						$this->mappings->sync_sf_update => array(
950
-							'text' => __( 'Salesforce update', 'object-sync-for-salesforce' ),
950
+							'text' => __('Salesforce update', 'object-sync-for-salesforce'),
951 951
 							'id'   => 'sf_update',
952 952
 							'desc' => '',
953 953
 						),
954 954
 						$this->mappings->sync_sf_delete => array(
955
-							'text' => __( 'Salesforce delete', 'object-sync-for-salesforce' ),
955
+							'text' => __('Salesforce delete', 'object-sync-for-salesforce'),
956 956
 							'id'   => 'sf_delete',
957 957
 							'desc' => '',
958 958
 						),
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 				),
961 961
 			),
962 962
 		);
963
-		foreach ( $log_settings as $key => $attributes ) {
963
+		foreach ($log_settings as $key => $attributes) {
964 964
 			$id       = $this->option_prefix . $key;
965 965
 			$name     = $this->option_prefix . $key;
966 966
 			$title    = $attributes['title'];
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 					'name'      => $name,
977 977
 				)
978 978
 			);
979
-			add_settings_field( $id, $title, $callback, $page, $section, $args );
980
-			register_setting( $page, $id );
979
+			add_settings_field($id, $title, $callback, $page, $section, $args);
980
+			register_setting($page, $id);
981 981
 		}
982 982
 	}
983 983
 
@@ -988,69 +988,69 @@  discard block
 block discarded – undo
988 988
 	public function notices() {
989 989
 
990 990
 		// before a notice is displayed, we should make sure we are on a page related to this plugin
991
-		if ( ! isset( $_GET['page'] ) || 'object-sync-salesforce-admin' !== $_GET['page'] ) {
991
+		if ( ! isset($_GET['page']) || 'object-sync-salesforce-admin' !== $_GET['page']) {
992 992
 			return;
993 993
 		}
994 994
 
995
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
996
-		require_once plugin_dir_path( __FILE__ ) . '../classes/admin-notice.php';
995
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
996
+		require_once plugin_dir_path(__FILE__) . '../classes/admin-notice.php';
997 997
 
998 998
 		$notices = array(
999 999
 			'permission'      => array(
1000 1000
 				'condition'   => false === $this->check_wordpress_admin_permissions(),
1001
-				'message'     => __( "Your account does not have permission to edit the Salesforce REST API plugin's settings.", 'object-sync-for-salesforce' ),
1001
+				'message'     => __("Your account does not have permission to edit the Salesforce REST API plugin's settings.", 'object-sync-for-salesforce'),
1002 1002
 				'type'        => 'error',
1003 1003
 				'dismissible' => false,
1004 1004
 			),
1005 1005
 			'fieldmap'        => array(
1006
-				'condition'   => isset( $get_data['transient'] ),
1007
-				'message'     => __( 'Errors kept this fieldmap from being saved.', 'object-sync-for-salesforce' ),
1006
+				'condition'   => isset($get_data['transient']),
1007
+				'message'     => __('Errors kept this fieldmap from being saved.', 'object-sync-for-salesforce'),
1008 1008
 				'type'        => 'error',
1009 1009
 				'dismissible' => true,
1010 1010
 			),
1011 1011
 			'object_map'      => array(
1012
-				'condition'   => isset( $get_data['map_transient'] ),
1013
-				'message'     => __( 'Errors kept this object map from being saved.', 'object-sync-for-salesforce' ),
1012
+				'condition'   => isset($get_data['map_transient']),
1013
+				'message'     => __('Errors kept this object map from being saved.', 'object-sync-for-salesforce'),
1014 1014
 				'type'        => 'error',
1015 1015
 				'dismissible' => true,
1016 1016
 			),
1017 1017
 			'data_saved'      => array(
1018
-				'condition'   => isset( $get_data['data_saved'] ) && 'true' === $get_data['data_saved'],
1019
-				'message'     => __( 'This data was successfully saved.', 'object-sync-for-salesforce' ),
1018
+				'condition'   => isset($get_data['data_saved']) && 'true' === $get_data['data_saved'],
1019
+				'message'     => __('This data was successfully saved.', 'object-sync-for-salesforce'),
1020 1020
 				'type'        => 'success',
1021 1021
 				'dismissible' => true,
1022 1022
 			),
1023 1023
 			'data_save_error' => array(
1024
-				'condition'   => isset( $get_data['data_saved'] ) && 'false' === $get_data['data_saved'],
1025
-				'message'     => __( 'This data was not successfully saved. Try again.', 'object-sync-for-salesforce' ),
1024
+				'condition'   => isset($get_data['data_saved']) && 'false' === $get_data['data_saved'],
1025
+				'message'     => __('This data was not successfully saved. Try again.', 'object-sync-for-salesforce'),
1026 1026
 				'type'        => 'error',
1027 1027
 				'dismissible' => true,
1028 1028
 			),
1029 1029
 		);
1030 1030
 
1031
-		foreach ( $notices as $key => $value ) {
1031
+		foreach ($notices as $key => $value) {
1032 1032
 
1033 1033
 			$condition = $value['condition'];
1034 1034
 			$message   = $value['message'];
1035 1035
 
1036
-			if ( isset( $value['dismissible'] ) ) {
1036
+			if (isset($value['dismissible'])) {
1037 1037
 				$dismissible = $value['dismissible'];
1038 1038
 			} else {
1039 1039
 				$dismissible = false;
1040 1040
 			}
1041 1041
 
1042
-			if ( isset( $value['type'] ) ) {
1042
+			if (isset($value['type'])) {
1043 1043
 				$type = $value['type'];
1044 1044
 			} else {
1045 1045
 				$type = '';
1046 1046
 			}
1047 1047
 
1048
-			if ( ! isset( $value['template'] ) ) {
1048
+			if ( ! isset($value['template'])) {
1049 1049
 				$template = '';
1050 1050
 			}
1051 1051
 
1052
-			if ( $condition ) {
1053
-				new Object_Sync_Sf_Admin_Notice( $condition, $message, $dismissible, $type, $template );
1052
+			if ($condition) {
1053
+				new Object_Sync_Sf_Admin_Notice($condition, $message, $dismissible, $type, $template);
1054 1054
 			}
1055 1055
 		}
1056 1056
 
@@ -1065,47 +1065,47 @@  discard block
 block discarded – undo
1065 1065
 	* can optionally contain a type
1066 1066
 	* @return array $object_settings
1067 1067
 	*/
1068
-	public function get_salesforce_object_description( $data = array() ) {
1068
+	public function get_salesforce_object_description($data = array()) {
1069 1069
 		$ajax = false;
1070
-		if ( empty( $data ) ) {
1071
-			$data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1070
+		if (empty($data)) {
1071
+			$data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1072 1072
 			$ajax = true;
1073 1073
 		}
1074 1074
 
1075 1075
 		$object_description = array();
1076 1076
 
1077
-		if ( ! empty( $data['salesforce_object'] ) ) {
1078
-			$object = $this->salesforce['sfapi']->object_describe( esc_attr( $data['salesforce_object'] ) );
1077
+		if ( ! empty($data['salesforce_object'])) {
1078
+			$object = $this->salesforce['sfapi']->object_describe(esc_attr($data['salesforce_object']));
1079 1079
 
1080 1080
 			$object_fields        = array();
1081 1081
 			$include_record_types = array();
1082 1082
 
1083 1083
 			// these can come from ajax
1084
-			$include = isset( $data['include'] ) ? (array) $data['include'] : array();
1085
-			$include = array_map( 'esc_attr', $include );
1086
-
1087
-			if ( in_array( 'fields', $include, true ) || empty( $include ) ) {
1088
-				$type = isset( $data['field_type'] ) ? esc_attr( $data['field_type'] ) : ''; // can come from ajax
1089
-				foreach ( $object['data']['fields'] as $key => $value ) {
1090
-					if ( '' === $type || $type === $value['type'] ) {
1091
-						$object_fields[ $key ] = $value;
1084
+			$include = isset($data['include']) ? (array) $data['include'] : array();
1085
+			$include = array_map('esc_attr', $include);
1086
+
1087
+			if (in_array('fields', $include, true) || empty($include)) {
1088
+				$type = isset($data['field_type']) ? esc_attr($data['field_type']) : ''; // can come from ajax
1089
+				foreach ($object['data']['fields'] as $key => $value) {
1090
+					if ('' === $type || $type === $value['type']) {
1091
+						$object_fields[$key] = $value;
1092 1092
 					}
1093 1093
 				}
1094 1094
 				$object_description['fields'] = $object_fields;
1095 1095
 			}
1096 1096
 
1097
-			if ( in_array( 'recordTypeInfos', $include, true ) ) {
1098
-				if ( isset( $object['data']['recordTypeInfos'] ) && count( $object['data']['recordTypeInfos'] ) > 1 ) {
1099
-					foreach ( $object['data']['recordTypeInfos'] as $type ) {
1100
-						$object_record_types[ $type['recordTypeId'] ] = $type['name'];
1097
+			if (in_array('recordTypeInfos', $include, true)) {
1098
+				if (isset($object['data']['recordTypeInfos']) && count($object['data']['recordTypeInfos']) > 1) {
1099
+					foreach ($object['data']['recordTypeInfos'] as $type) {
1100
+						$object_record_types[$type['recordTypeId']] = $type['name'];
1101 1101
 					}
1102 1102
 					$object_description['recordTypeInfos'] = $object_record_types;
1103 1103
 				}
1104 1104
 			}
1105 1105
 		}
1106 1106
 
1107
-		if ( true === $ajax ) {
1108
-			wp_send_json_success( $object_description );
1107
+		if (true === $ajax) {
1108
+			wp_send_json_success($object_description);
1109 1109
 		} else {
1110 1110
 			return $object_description;
1111 1111
 		}
@@ -1119,23 +1119,23 @@  discard block
 block discarded – undo
1119 1119
 	* can optionally contain a type for the field
1120 1120
 	* @return array $object_fields
1121 1121
 	*/
1122
-	public function get_salesforce_object_fields( $data = array() ) {
1122
+	public function get_salesforce_object_fields($data = array()) {
1123 1123
 
1124
-		if ( ! empty( $data['salesforce_object'] ) ) {
1125
-			$object               = $this->salesforce['sfapi']->object_describe( esc_attr( $data['salesforce_object'] ) );
1124
+		if ( ! empty($data['salesforce_object'])) {
1125
+			$object               = $this->salesforce['sfapi']->object_describe(esc_attr($data['salesforce_object']));
1126 1126
 			$object_fields        = array();
1127
-			$type                 = isset( $data['type'] ) ? esc_attr( $data['type'] ) : '';
1128
-			$include_record_types = isset( $data['include_record_types'] ) ? esc_attr( $data['include_record_types'] ) : false;
1129
-			foreach ( $object['data']['fields'] as $key => $value ) {
1130
-				if ( '' === $type || $type === $value['type'] ) {
1131
-					$object_fields[ $key ] = $value;
1127
+			$type                 = isset($data['type']) ? esc_attr($data['type']) : '';
1128
+			$include_record_types = isset($data['include_record_types']) ? esc_attr($data['include_record_types']) : false;
1129
+			foreach ($object['data']['fields'] as $key => $value) {
1130
+				if ('' === $type || $type === $value['type']) {
1131
+					$object_fields[$key] = $value;
1132 1132
 				}
1133 1133
 			}
1134
-			if ( true === $include_record_types ) {
1134
+			if (true === $include_record_types) {
1135 1135
 				$object_record_types = array();
1136
-				if ( isset( $object['data']['recordTypeInfos'] ) && count( $object['data']['recordTypeInfos'] ) > 1 ) {
1137
-					foreach ( $object['data']['recordTypeInfos'] as $type ) {
1138
-						$object_record_types[ $type['recordTypeId'] ] = $type['name'];
1136
+				if (isset($object['data']['recordTypeInfos']) && count($object['data']['recordTypeInfos']) > 1) {
1137
+					foreach ($object['data']['recordTypeInfos'] as $type) {
1138
+						$object_record_types[$type['recordTypeId']] = $type['name'];
1139 1139
 					}
1140 1140
 				}
1141 1141
 			}
@@ -1152,18 +1152,18 @@  discard block
 block discarded – undo
1152 1152
 	* @param string $wordpress_object
1153 1153
 	* @return array $object_fields
1154 1154
 	*/
1155
-	public function get_wordpress_object_fields( $wordpress_object = '' ) {
1155
+	public function get_wordpress_object_fields($wordpress_object = '') {
1156 1156
 		$ajax      = false;
1157
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1158
-		if ( empty( $wordpress_object ) ) {
1159
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1157
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1158
+		if (empty($wordpress_object)) {
1159
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1160 1160
 			$ajax             = true;
1161 1161
 		}
1162 1162
 
1163
-		$object_fields = $this->wordpress->get_wordpress_object_fields( $wordpress_object );
1163
+		$object_fields = $this->wordpress->get_wordpress_object_fields($wordpress_object);
1164 1164
 
1165
-		if ( true === $ajax ) {
1166
-			wp_send_json_success( $object_fields );
1165
+		if (true === $ajax) {
1166
+			wp_send_json_success($object_fields);
1167 1167
 		} else {
1168 1168
 			return $object_fields;
1169 1169
 		}
@@ -1177,24 +1177,24 @@  discard block
 block discarded – undo
1177 1177
 	* @param string $salesforce_object
1178 1178
 	* @return array $object_fields
1179 1179
 	*/
1180
-	public function get_wp_sf_object_fields( $wordpress_object = '', $salesforce = '' ) {
1181
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1182
-		if ( empty( $wordpress_object ) ) {
1183
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1180
+	public function get_wp_sf_object_fields($wordpress_object = '', $salesforce = '') {
1181
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1182
+		if (empty($wordpress_object)) {
1183
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1184 1184
 		}
1185
-		if ( empty( $salesforce_object ) ) {
1186
-			$salesforce_object = isset( $post_data['salesforce_object'] ) ? sanitize_text_field( wp_unslash( $post_data['salesforce_object'] ) ) : '';
1185
+		if (empty($salesforce_object)) {
1186
+			$salesforce_object = isset($post_data['salesforce_object']) ? sanitize_text_field(wp_unslash($post_data['salesforce_object'])) : '';
1187 1187
 		}
1188 1188
 
1189
-		$object_fields['wordpress']  = $this->get_wordpress_object_fields( $wordpress_object );
1189
+		$object_fields['wordpress']  = $this->get_wordpress_object_fields($wordpress_object);
1190 1190
 		$object_fields['salesforce'] = $this->get_salesforce_object_fields(
1191 1191
 			array(
1192 1192
 				'salesforce_object' => $salesforce_object,
1193 1193
 			)
1194 1194
 		);
1195 1195
 
1196
-		if ( ! empty( $post_data ) ) {
1197
-			wp_send_json_success( $object_fields );
1196
+		if ( ! empty($post_data)) {
1197
+			wp_send_json_success($object_fields);
1198 1198
 		} else {
1199 1199
 			return $object_fields;
1200 1200
 		}
@@ -1207,17 +1207,17 @@  discard block
 block discarded – undo
1207 1207
 	* @param string $wordpress_object
1208 1208
 	* @param int $wordpress_id
1209 1209
 	*/
1210
-	public function push_to_salesforce( $wordpress_object = '', $wordpress_id = '' ) {
1211
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1212
-		if ( empty( $wordpress_object ) && empty( $wordpress_id ) ) {
1213
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1214
-			$wordpress_id     = isset( $post_data['wordpress_id'] ) ? absint( $post_data['wordpress_id'] ) : '';
1210
+	public function push_to_salesforce($wordpress_object = '', $wordpress_id = '') {
1211
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1212
+		if (empty($wordpress_object) && empty($wordpress_id)) {
1213
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1214
+			$wordpress_id     = isset($post_data['wordpress_id']) ? absint($post_data['wordpress_id']) : '';
1215 1215
 		}
1216
-		$data   = $this->wordpress->get_wordpress_object_data( $wordpress_object, $wordpress_id );
1217
-		$result = $this->push->manual_object_update( $data, $wordpress_object );
1216
+		$data   = $this->wordpress->get_wordpress_object_data($wordpress_object, $wordpress_id);
1217
+		$result = $this->push->manual_object_update($data, $wordpress_object);
1218 1218
 
1219
-		if ( ! empty( $post_data['wordpress_object'] ) && ! empty( $post_data['wordpress_id'] ) ) {
1220
-			wp_send_json_success( $result );
1219
+		if ( ! empty($post_data['wordpress_object']) && ! empty($post_data['wordpress_id'])) {
1220
+			wp_send_json_success($result);
1221 1221
 		} else {
1222 1222
 			return $result;
1223 1223
 		}
@@ -1231,16 +1231,16 @@  discard block
 block discarded – undo
1231 1231
 	* @param string $salesforce_id
1232 1232
 	* @param string $wordpress_object
1233 1233
 	*/
1234
-	public function pull_from_salesforce( $salesforce_id = '', $wordpress_object = '' ) {
1235
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1236
-		if ( empty( $wordpress_object ) && empty( $salesforce_id ) ) {
1237
-			$wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
1238
-			$salesforce_id    = isset( $post_data['salesforce_id'] ) ? sanitize_text_field( wp_unslash( $post_data['salesforce_id'] ) ) : '';
1239
-		}
1240
-		$type   = $this->salesforce['sfapi']->get_sobject_type( $salesforce_id );
1241
-		$result = $this->pull->manual_pull( $type, $salesforce_id, $wordpress_object ); // we want the wp object to make sure we get the right fieldmap
1242
-		if ( ! empty( $post_data ) ) {
1243
-			wp_send_json_success( $result );
1234
+	public function pull_from_salesforce($salesforce_id = '', $wordpress_object = '') {
1235
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1236
+		if (empty($wordpress_object) && empty($salesforce_id)) {
1237
+			$wordpress_object = isset($post_data['wordpress_object']) ? sanitize_text_field(wp_unslash($post_data['wordpress_object'])) : '';
1238
+			$salesforce_id    = isset($post_data['salesforce_id']) ? sanitize_text_field(wp_unslash($post_data['salesforce_id'])) : '';
1239
+		}
1240
+		$type   = $this->salesforce['sfapi']->get_sobject_type($salesforce_id);
1241
+		$result = $this->pull->manual_pull($type, $salesforce_id, $wordpress_object); // we want the wp object to make sure we get the right fieldmap
1242
+		if ( ! empty($post_data)) {
1243
+			wp_send_json_success($result);
1244 1244
 		} else {
1245 1245
 			return $result;
1246 1246
 		}
@@ -1252,18 +1252,18 @@  discard block
 block discarded – undo
1252 1252
 	*
1253 1253
 	* @param int $mapping_id
1254 1254
 	*/
1255
-	public function refresh_mapped_data( $mapping_id = '' ) {
1256
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1257
-		if ( empty( $mapping_id ) ) {
1258
-			$mapping_id = isset( $post_data['mapping_id'] ) ? absint( $post_data['mapping_id'] ) : '';
1255
+	public function refresh_mapped_data($mapping_id = '') {
1256
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1257
+		if (empty($mapping_id)) {
1258
+			$mapping_id = isset($post_data['mapping_id']) ? absint($post_data['mapping_id']) : '';
1259 1259
 		}
1260 1260
 		$result = $this->mappings->get_object_maps(
1261 1261
 			array(
1262 1262
 				'id' => $mapping_id,
1263 1263
 			)
1264 1264
 		);
1265
-		if ( ! empty( $post_data ) ) {
1266
-			wp_send_json_success( $result );
1265
+		if ( ! empty($post_data)) {
1266
+			wp_send_json_success($result);
1267 1267
 		} else {
1268 1268
 			return $result;
1269 1269
 		}
@@ -1279,47 +1279,47 @@  discard block
 block discarded – undo
1279 1279
 	*/
1280 1280
 	public function prepare_fieldmap_data() {
1281 1281
 		$error     = false;
1282
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1283
-		$cachekey  = md5( wp_json_encode( $post_data ) );
1282
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1283
+		$cachekey  = md5(wp_json_encode($post_data));
1284 1284
 
1285
-		if ( ! isset( $post_data['label'] ) || ! isset( $post_data['salesforce_object'] ) || ! isset( $post_data['wordpress_object'] ) ) {
1285
+		if ( ! isset($post_data['label']) || ! isset($post_data['salesforce_object']) || ! isset($post_data['wordpress_object'])) {
1286 1286
 			$error = true;
1287 1287
 		}
1288
-		if ( true === $error ) {
1289
-			$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1290
-			if ( '' !== $cachekey ) {
1291
-				$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&transient=' . $cachekey;
1288
+		if (true === $error) {
1289
+			$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1290
+			if ('' !== $cachekey) {
1291
+				$url = esc_url_raw($post_data['redirect_url_error']) . '&transient=' . $cachekey;
1292 1292
 			}
1293 1293
 		} else { // there are no errors
1294 1294
 			// send the row to the fieldmap class
1295 1295
 			// if it is add or clone, use the create method
1296
-			$method            = esc_attr( $post_data['method'] );
1296
+			$method            = esc_attr($post_data['method']);
1297 1297
 			$salesforce_fields = $this->get_salesforce_object_fields(
1298 1298
 				array(
1299 1299
 					'salesforce_object' => $post_data['salesforce_object'],
1300 1300
 				)
1301 1301
 			);
1302
-			$wordpress_fields  = $this->get_wordpress_object_fields( $post_data['wordpress_object'] );
1303
-			if ( 'add' === $method || 'clone' === $method ) {
1304
-				$result = $this->mappings->create_fieldmap( $post_data, $wordpress_fields, $salesforce_fields );
1305
-			} elseif ( 'edit' === $method ) { // if it is edit, use the update method
1306
-				$id     = esc_attr( $post_data['id'] );
1307
-				$result = $this->mappings->update_fieldmap( $post_data, $wordpress_fields, $salesforce_fields, $id );
1302
+			$wordpress_fields = $this->get_wordpress_object_fields($post_data['wordpress_object']);
1303
+			if ('add' === $method || 'clone' === $method) {
1304
+				$result = $this->mappings->create_fieldmap($post_data, $wordpress_fields, $salesforce_fields);
1305
+			} elseif ('edit' === $method) { // if it is edit, use the update method
1306
+				$id     = esc_attr($post_data['id']);
1307
+				$result = $this->mappings->update_fieldmap($post_data, $wordpress_fields, $salesforce_fields, $id);
1308 1308
 			}
1309
-			if ( false === $result ) { // if the database didn't save, it's still an error
1310
-				$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1311
-				if ( '' !== $cachekey ) {
1312
-					$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&transient=' . $cachekey;
1309
+			if (false === $result) { // if the database didn't save, it's still an error
1310
+				$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1311
+				if ('' !== $cachekey) {
1312
+					$url = esc_url_raw($post_data['redirect_url_error']) . '&transient=' . $cachekey;
1313 1313
 				}
1314 1314
 			} else {
1315
-				if ( isset( $post_data['transient'] ) ) { // there was previously an error saved. can delete it now.
1316
-					$this->sfwp_transients->delete( esc_attr( $post_data['map_transient'] ) );
1315
+				if (isset($post_data['transient'])) { // there was previously an error saved. can delete it now.
1316
+					$this->sfwp_transients->delete(esc_attr($post_data['map_transient']));
1317 1317
 				}
1318 1318
 				// then send the user to the list of fieldmaps
1319
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1319
+				$url = esc_url_raw($post_data['redirect_url_success']);
1320 1320
 			}
1321 1321
 		}
1322
-		wp_safe_redirect( $url );
1322
+		wp_safe_redirect($url);
1323 1323
 		exit();
1324 1324
 	}
1325 1325
 
@@ -1331,15 +1331,15 @@  discard block
 block discarded – undo
1331 1331
 	*
1332 1332
 	*/
1333 1333
 	public function delete_fieldmap() {
1334
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1335
-		if ( $post_data['id'] ) {
1336
-			$result = $this->mappings->delete_fieldmap( $post_data['id'] );
1337
-			if ( true === $result ) {
1338
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1334
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1335
+		if ($post_data['id']) {
1336
+			$result = $this->mappings->delete_fieldmap($post_data['id']);
1337
+			if (true === $result) {
1338
+				$url = esc_url_raw($post_data['redirect_url_success']);
1339 1339
 			} else {
1340
-				$url = esc_url_raw( $post_data['redirect_url_error'] . '&id=' . $post_data['id'] );
1340
+				$url = esc_url_raw($post_data['redirect_url_error'] . '&id=' . $post_data['id']);
1341 1341
 			}
1342
-			wp_safe_redirect( $url );
1342
+			wp_safe_redirect($url);
1343 1343
 			exit();
1344 1344
 		}
1345 1345
 	}
@@ -1354,38 +1354,38 @@  discard block
 block discarded – undo
1354 1354
 	*/
1355 1355
 	public function prepare_object_map_data() {
1356 1356
 		$error     = false;
1357
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1358
-		$cachekey  = md5( wp_json_encode( $post_data ) );
1357
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1358
+		$cachekey  = md5(wp_json_encode($post_data));
1359 1359
 
1360
-		if ( ! isset( $post_data['wordpress_id'] ) || ! isset( $post_data['salesforce_id'] ) ) {
1360
+		if ( ! isset($post_data['wordpress_id']) || ! isset($post_data['salesforce_id'])) {
1361 1361
 			$error = true;
1362 1362
 		}
1363
-		if ( true === $error ) {
1364
-			$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1365
-			if ( '' !== $cachekey ) {
1366
-				$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&map_transient=' . $cachekey;
1363
+		if (true === $error) {
1364
+			$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1365
+			if ('' !== $cachekey) {
1366
+				$url = esc_url_raw($post_data['redirect_url_error']) . '&map_transient=' . $cachekey;
1367 1367
 			}
1368 1368
 		} else { // there are no errors
1369 1369
 			// send the row to the object map class
1370
-			$method = esc_attr( $post_data['method'] );
1371
-			if ( 'edit' === $method ) { // if it is edit, use the update method
1372
-				$id     = esc_attr( $post_data['id'] );
1373
-				$result = $this->mappings->update_object_map( $post_data, $id );
1370
+			$method = esc_attr($post_data['method']);
1371
+			if ('edit' === $method) { // if it is edit, use the update method
1372
+				$id     = esc_attr($post_data['id']);
1373
+				$result = $this->mappings->update_object_map($post_data, $id);
1374 1374
 			}
1375
-			if ( false === $result ) { // if the database didn't save, it's still an error
1376
-				$this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
1377
-				if ( '' !== $cachekey ) {
1378
-					$url = esc_url_raw( $post_data['redirect_url_error'] ) . '&map_transient=' . $cachekey;
1375
+			if (false === $result) { // if the database didn't save, it's still an error
1376
+				$this->sfwp_transients->set($cachekey, $post_data, $this->wordpress->options['cache_expiration']);
1377
+				if ('' !== $cachekey) {
1378
+					$url = esc_url_raw($post_data['redirect_url_error']) . '&map_transient=' . $cachekey;
1379 1379
 				}
1380 1380
 			} else {
1381
-				if ( isset( $post_data['map_transient'] ) ) { // there was previously an error saved. can delete it now.
1382
-					$this->sfwp_transients->delete( esc_attr( $post_data['map_transient'] ) );
1381
+				if (isset($post_data['map_transient'])) { // there was previously an error saved. can delete it now.
1382
+					$this->sfwp_transients->delete(esc_attr($post_data['map_transient']));
1383 1383
 				}
1384 1384
 				// then send the user to the success redirect url
1385
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1385
+				$url = esc_url_raw($post_data['redirect_url_success']);
1386 1386
 			}
1387 1387
 		}
1388
-		wp_safe_redirect( $url );
1388
+		wp_safe_redirect($url);
1389 1389
 		exit();
1390 1390
 	}
1391 1391
 
@@ -1397,15 +1397,15 @@  discard block
 block discarded – undo
1397 1397
 	*
1398 1398
 	*/
1399 1399
 	public function delete_object_map() {
1400
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1401
-		if ( $post_data['id'] ) {
1402
-			$result = $this->mappings->delete_object_map( $post_data['id'] );
1403
-			if ( true === $result ) {
1404
-				$url = esc_url_raw( $post_data['redirect_url_success'] );
1400
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1401
+		if ($post_data['id']) {
1402
+			$result = $this->mappings->delete_object_map($post_data['id']);
1403
+			if (true === $result) {
1404
+				$url = esc_url_raw($post_data['redirect_url_success']);
1405 1405
 			} else {
1406
-				$url = esc_url_raw( $post_data['redirect_url_error'] . '&id=' . $post_data['id'] );
1406
+				$url = esc_url_raw($post_data['redirect_url_error'] . '&id=' . $post_data['id']);
1407 1407
 			}
1408
-			wp_safe_redirect( $url );
1408
+			wp_safe_redirect($url);
1409 1409
 			exit();
1410 1410
 		}
1411 1411
 	}
@@ -1416,95 +1416,95 @@  discard block
 block discarded – undo
1416 1416
 	*/
1417 1417
 	public function import_json_file() {
1418 1418
 
1419
-		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import' ) ) {
1419
+		if ( ! wp_verify_nonce($_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import')) {
1420 1420
 			return;
1421 1421
 		}
1422
-		if ( ! current_user_can( 'manage_options' ) ) {
1422
+		if ( ! current_user_can('manage_options')) {
1423 1423
 			return;
1424 1424
 		}
1425 1425
 		$path      = $_FILES['import_file']['name'];
1426
-		$extension = pathinfo( $path, PATHINFO_EXTENSION );
1427
-		if ( 'json' !== $extension ) {
1428
-			wp_die( __( 'Please upload a valid .json file' ) );
1426
+		$extension = pathinfo($path, PATHINFO_EXTENSION);
1427
+		if ('json' !== $extension) {
1428
+			wp_die(__('Please upload a valid .json file'));
1429 1429
 		}
1430 1430
 
1431 1431
 		$import_file = $_FILES['import_file']['tmp_name'];
1432
-		if ( empty( $import_file ) ) {
1433
-			wp_die( __( 'Please upload a file to import' ) );
1432
+		if (empty($import_file)) {
1433
+			wp_die(__('Please upload a file to import'));
1434 1434
 		}
1435 1435
 
1436 1436
 		// Retrieve the data from the file and convert the json object to an array.
1437
-		$data = (array) json_decode( file_get_contents( $import_file ), true );
1437
+		$data = (array) json_decode(file_get_contents($import_file), true);
1438 1438
 
1439 1439
 		// if there is only one object map, fix the array
1440
-		if ( isset( $data['object_maps'] ) ) {
1441
-			if ( count( $data['object_maps'] ) === count( $data['object_maps'], COUNT_RECURSIVE ) ) {
1442
-				$data['object_maps'] = array( 0 => $data['object_maps'] );
1440
+		if (isset($data['object_maps'])) {
1441
+			if (count($data['object_maps']) === count($data['object_maps'], COUNT_RECURSIVE)) {
1442
+				$data['object_maps'] = array(0 => $data['object_maps']);
1443 1443
 			}
1444 1444
 		}
1445 1445
 
1446
-		$overwrite = isset( $_POST['overwrite'] ) ? esc_attr( $_POST['overwrite'] ) : '';
1447
-		if ( '1' === $overwrite ) {
1448
-			if ( isset( $data['fieldmaps'] ) ) {
1446
+		$overwrite = isset($_POST['overwrite']) ? esc_attr($_POST['overwrite']) : '';
1447
+		if ('1' === $overwrite) {
1448
+			if (isset($data['fieldmaps'])) {
1449 1449
 				$fieldmaps = $this->mappings->get_fieldmaps();
1450
-				foreach ( $fieldmaps as $fieldmap ) {
1450
+				foreach ($fieldmaps as $fieldmap) {
1451 1451
 					$id     = $fieldmap['id'];
1452
-					$delete = $this->mappings->delete_fieldmap( $id );
1452
+					$delete = $this->mappings->delete_fieldmap($id);
1453 1453
 				}
1454 1454
 			}
1455
-			if ( isset( $data['object_maps'] ) ) {
1455
+			if (isset($data['object_maps'])) {
1456 1456
 				$object_maps = $this->mappings->get_object_maps();
1457 1457
 
1458 1458
 				// if there is only one existing object map, fix the array
1459
-				if ( count( $object_maps ) === count( $object_maps, COUNT_RECURSIVE ) ) {
1460
-					$object_maps = array( 0 => $object_maps );
1459
+				if (count($object_maps) === count($object_maps, COUNT_RECURSIVE)) {
1460
+					$object_maps = array(0 => $object_maps);
1461 1461
 				}
1462 1462
 
1463
-				foreach ( $object_maps as $object_map ) {
1463
+				foreach ($object_maps as $object_map) {
1464 1464
 					$id     = $object_map['id'];
1465
-					$delete = $this->mappings->delete_object_map( $id );
1465
+					$delete = $this->mappings->delete_object_map($id);
1466 1466
 				}
1467 1467
 			}
1468
-			if ( isset( $data['plugin_settings'] ) ) {
1469
-				foreach ( $data['plugin_settings'] as $key => $value ) {
1470
-					delete_option( $value['option_name'] );
1468
+			if (isset($data['plugin_settings'])) {
1469
+				foreach ($data['plugin_settings'] as $key => $value) {
1470
+					delete_option($value['option_name']);
1471 1471
 				}
1472 1472
 			}
1473 1473
 		}
1474 1474
 
1475 1475
 		$success = true;
1476 1476
 
1477
-		if ( isset( $data['fieldmaps'] ) ) {
1478
-			foreach ( $data['fieldmaps'] as $fieldmap ) {
1479
-				unset( $fieldmap['id'] );
1480
-				$create = $this->mappings->create_fieldmap( $fieldmap );
1481
-				if ( false === $create ) {
1477
+		if (isset($data['fieldmaps'])) {
1478
+			foreach ($data['fieldmaps'] as $fieldmap) {
1479
+				unset($fieldmap['id']);
1480
+				$create = $this->mappings->create_fieldmap($fieldmap);
1481
+				if (false === $create) {
1482 1482
 					$success = false;
1483 1483
 				}
1484 1484
 			}
1485 1485
 		}
1486 1486
 
1487
-		if ( isset( $data['object_maps'] ) ) {
1488
-			foreach ( $data['object_maps'] as $object_map ) {
1489
-				unset( $object_map['id'] );
1490
-				$create = $this->mappings->create_object_map( $object_map );
1491
-				if ( false === $create ) {
1487
+		if (isset($data['object_maps'])) {
1488
+			foreach ($data['object_maps'] as $object_map) {
1489
+				unset($object_map['id']);
1490
+				$create = $this->mappings->create_object_map($object_map);
1491
+				if (false === $create) {
1492 1492
 					$success = false;
1493 1493
 				}
1494 1494
 			}
1495 1495
 		}
1496 1496
 
1497
-		if ( isset( $data['plugin_settings'] ) ) {
1498
-			foreach ( $data['plugin_settings'] as $key => $value ) {
1499
-				update_option( $value['option_name'], maybe_unserialize( $value['option_value'] ), $value['autoload'] );
1497
+		if (isset($data['plugin_settings'])) {
1498
+			foreach ($data['plugin_settings'] as $key => $value) {
1499
+				update_option($value['option_name'], maybe_unserialize($value['option_value']), $value['autoload']);
1500 1500
 			}
1501 1501
 		}
1502 1502
 
1503
-		if ( true === $success ) {
1504
-			wp_safe_redirect( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=true' ) );
1503
+		if (true === $success) {
1504
+			wp_safe_redirect(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=true'));
1505 1505
 			exit;
1506 1506
 		} else {
1507
-			wp_safe_redirect( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=false' ) );
1507
+			wp_safe_redirect(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=import-export&data_saved=false'));
1508 1508
 			exit;
1509 1509
 		}
1510 1510
 
@@ -1516,28 +1516,28 @@  discard block
 block discarded – undo
1516 1516
 	*/
1517 1517
 	public function export_json_file() {
1518 1518
 
1519
-		if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_export'], 'object_sync_for_salesforce_nonce_export' ) ) {
1519
+		if ( ! wp_verify_nonce($_POST['object_sync_for_salesforce_nonce_export'], 'object_sync_for_salesforce_nonce_export')) {
1520 1520
 			return;
1521 1521
 		}
1522
-		if ( ! current_user_can( 'manage_options' ) ) {
1522
+		if ( ! current_user_can('manage_options')) {
1523 1523
 			return;
1524 1524
 		}
1525
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1525
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1526 1526
 		$export    = array();
1527
-		if ( in_array( 'fieldmaps', $post_data['export'] ) ) {
1527
+		if (in_array('fieldmaps', $post_data['export'])) {
1528 1528
 			$export['fieldmaps'] = $this->mappings->get_fieldmaps();
1529 1529
 		}
1530
-		if ( in_array( 'object_maps', $post_data['export'] ) ) {
1530
+		if (in_array('object_maps', $post_data['export'])) {
1531 1531
 			$export['object_maps'] = $this->mappings->get_object_maps();
1532 1532
 		}
1533
-		if ( in_array( 'plugin_settings', $post_data['export'] ) ) {
1534
-			$export['plugin_settings'] = $this->wpdb->get_results( 'SELECT * FROM ' . $this->wpdb->prefix . 'options' . ' WHERE option_name like "' . $this->option_prefix . '%"', ARRAY_A );
1533
+		if (in_array('plugin_settings', $post_data['export'])) {
1534
+			$export['plugin_settings'] = $this->wpdb->get_results('SELECT * FROM ' . $this->wpdb->prefix . 'options' . ' WHERE option_name like "' . $this->option_prefix . '%"', ARRAY_A);
1535 1535
 		}
1536 1536
 		nocache_headers();
1537
-		header( 'Content-Type: application/json; charset=utf-8' );
1538
-		header( 'Content-Disposition: attachment; filename=object-sync-for-salesforce-data-export-' . date( 'm-d-Y' ) . '.json' );
1539
-		header( 'Expires: 0' );
1540
-		echo wp_json_encode( $export );
1537
+		header('Content-Type: application/json; charset=utf-8');
1538
+		header('Content-Disposition: attachment; filename=object-sync-for-salesforce-data-export-' . date('m-d-Y') . '.json');
1539
+		header('Expires: 0');
1540
+		echo wp_json_encode($export);
1541 1541
 		exit;
1542 1542
 	}
1543 1543
 
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
 	*
1547 1547
 	* @param array $args
1548 1548
 	*/
1549
-	public function display_input_field( $args ) {
1549
+	public function display_input_field($args) {
1550 1550
 		$type    = $args['type'];
1551 1551
 		$id      = $args['label_for'];
1552 1552
 		$name    = $args['name'];
@@ -1555,38 +1555,38 @@  discard block
 block discarded – undo
1555 1555
 
1556 1556
 		$class = 'regular-text';
1557 1557
 
1558
-		if ( 'checkbox' === $type ) {
1558
+		if ('checkbox' === $type) {
1559 1559
 			$class = 'checkbox';
1560 1560
 		}
1561 1561
 
1562
-		if ( ! isset( $args['constant'] ) || ! defined( $args['constant'] ) ) {
1563
-			$value = esc_attr( get_option( $id, '' ) );
1564
-			if ( 'checkbox' === $type ) {
1565
-				if ( '1' === $value ) {
1562
+		if ( ! isset($args['constant']) || ! defined($args['constant'])) {
1563
+			$value = esc_attr(get_option($id, ''));
1564
+			if ('checkbox' === $type) {
1565
+				if ('1' === $value) {
1566 1566
 					$checked = 'checked ';
1567 1567
 				}
1568 1568
 				$value = 1;
1569 1569
 			}
1570
-			if ( '' === $value && isset( $args['default'] ) && '' !== $args['default'] ) {
1570
+			if ('' === $value && isset($args['default']) && '' !== $args['default']) {
1571 1571
 				$value = $args['default'];
1572 1572
 			}
1573 1573
 
1574
-			echo sprintf( '<input type="%1$s" value="%2$s" name="%3$s" id="%4$s" class="%5$s"%6$s>',
1575
-				esc_attr( $type ),
1576
-				esc_attr( $value ),
1577
-				esc_attr( $name ),
1578
-				esc_attr( $id ),
1579
-				sanitize_html_class( $class . esc_html( ' code' ) ),
1580
-				esc_html( $checked )
1574
+			echo sprintf('<input type="%1$s" value="%2$s" name="%3$s" id="%4$s" class="%5$s"%6$s>',
1575
+				esc_attr($type),
1576
+				esc_attr($value),
1577
+				esc_attr($name),
1578
+				esc_attr($id),
1579
+				sanitize_html_class($class . esc_html(' code')),
1580
+				esc_html($checked)
1581 1581
 			);
1582
-			if ( '' !== $desc ) {
1583
-				echo sprintf( '<p class="description">%1$s</p>',
1584
-					esc_html( $desc )
1582
+			if ('' !== $desc) {
1583
+				echo sprintf('<p class="description">%1$s</p>',
1584
+					esc_html($desc)
1585 1585
 				);
1586 1586
 			}
1587 1587
 		} else {
1588
-			echo sprintf( '<p><code>%1$s</code></p>',
1589
-				esc_html__( 'Defined in wp-config.php', 'object-sync-for-salesforce' )
1588
+			echo sprintf('<p><code>%1$s</code></p>',
1589
+				esc_html__('Defined in wp-config.php', 'object-sync-for-salesforce')
1590 1590
 			);
1591 1591
 		}
1592 1592
 	}
@@ -1597,33 +1597,33 @@  discard block
 block discarded – undo
1597 1597
 	*
1598 1598
 	* @param array $args
1599 1599
 	*/
1600
-	public function display_checkboxes( $args ) {
1600
+	public function display_checkboxes($args) {
1601 1601
 		$type    = 'checkbox';
1602 1602
 		$name    = $args['name'];
1603
-		$options = get_option( $name, array() );
1604
-		foreach ( $args['items'] as $key => $value ) {
1603
+		$options = get_option($name, array());
1604
+		foreach ($args['items'] as $key => $value) {
1605 1605
 			$text    = $value['text'];
1606 1606
 			$id      = $value['id'];
1607 1607
 			$desc    = $value['desc'];
1608 1608
 			$checked = '';
1609
-			if ( is_array( $options ) && in_array( (string) $key, $options, true ) ) {
1609
+			if (is_array($options) && in_array((string) $key, $options, true)) {
1610 1610
 				$checked = 'checked';
1611
-			} elseif ( is_array( $options ) && empty( $options ) ) {
1612
-				if ( isset( $value['default'] ) && true === $value['default'] ) {
1611
+			} elseif (is_array($options) && empty($options)) {
1612
+				if (isset($value['default']) && true === $value['default']) {
1613 1613
 					$checked = 'checked';
1614 1614
 				}
1615 1615
 			}
1616
-			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>',
1617
-				esc_attr( $type ),
1618
-				esc_attr( $key ),
1619
-				esc_attr( $name ),
1620
-				esc_attr( $id ),
1621
-				esc_html( $checked ),
1622
-				esc_html( $text )
1616
+			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>',
1617
+				esc_attr($type),
1618
+				esc_attr($key),
1619
+				esc_attr($name),
1620
+				esc_attr($id),
1621
+				esc_html($checked),
1622
+				esc_html($text)
1623 1623
 			);
1624
-			if ( '' !== $desc ) {
1625
-				echo sprintf( '<p class="description">%1$s</p>',
1626
-					esc_html( $desc )
1624
+			if ('' !== $desc) {
1625
+				echo sprintf('<p class="description">%1$s</p>',
1626
+					esc_html($desc)
1627 1627
 				);
1628 1628
 			}
1629 1629
 		}
@@ -1634,44 +1634,44 @@  discard block
 block discarded – undo
1634 1634
 	*
1635 1635
 	* @param array $args
1636 1636
 	*/
1637
-	public function display_select( $args ) {
1637
+	public function display_select($args) {
1638 1638
 		$type = $args['type'];
1639 1639
 		$id   = $args['label_for'];
1640 1640
 		$name = $args['name'];
1641 1641
 		$desc = $args['desc'];
1642
-		if ( ! isset( $args['constant'] ) || ! defined( $args['constant'] ) ) {
1643
-			$current_value = get_option( $name );
1642
+		if ( ! isset($args['constant']) || ! defined($args['constant'])) {
1643
+			$current_value = get_option($name);
1644 1644
 
1645
-			echo sprintf( '<div class="select"><select id="%1$s" name="%2$s"><option value="">- ' . __( 'Select one', 'object-sync-for-salesforce' ) . ' -</option>',
1646
-				esc_attr( $id ),
1647
-				esc_attr( $name )
1645
+			echo sprintf('<div class="select"><select id="%1$s" name="%2$s"><option value="">- ' . __('Select one', 'object-sync-for-salesforce') . ' -</option>',
1646
+				esc_attr($id),
1647
+				esc_attr($name)
1648 1648
 			);
1649 1649
 
1650
-			foreach ( $args['items'] as $key => $value ) {
1650
+			foreach ($args['items'] as $key => $value) {
1651 1651
 				$text     = $value['text'];
1652 1652
 				$value    = $value['value'];
1653 1653
 				$selected = '';
1654
-				if ( $key === $current_value || $value === $current_value ) {
1654
+				if ($key === $current_value || $value === $current_value) {
1655 1655
 					$selected = ' selected';
1656 1656
 				}
1657 1657
 
1658
-				echo sprintf( '<option value="%1$s"%2$s>%3$s</option>',
1659
-					esc_attr( $value ),
1660
-					esc_attr( $selected ),
1661
-					esc_html( $text )
1658
+				echo sprintf('<option value="%1$s"%2$s>%3$s</option>',
1659
+					esc_attr($value),
1660
+					esc_attr($selected),
1661
+					esc_html($text)
1662 1662
 				);
1663 1663
 
1664 1664
 			}
1665 1665
 			echo '</select>';
1666
-			if ( '' !== $desc ) {
1667
-				echo sprintf( '<p class="description">%1$s</p>',
1668
-					esc_html( $desc )
1666
+			if ('' !== $desc) {
1667
+				echo sprintf('<p class="description">%1$s</p>',
1668
+					esc_html($desc)
1669 1669
 				);
1670 1670
 			}
1671 1671
 			echo '</div>';
1672 1672
 		} else {
1673
-			echo sprintf( '<p><code>%1$s</code></p>',
1674
-				esc_html__( 'Defined in wp-config.php', 'object-sync-for-salesforce' )
1673
+			echo sprintf('<p><code>%1$s</code></p>',
1674
+				esc_html__('Defined in wp-config.php', 'object-sync-for-salesforce')
1675 1675
 			);
1676 1676
 		}
1677 1677
 	}
@@ -1684,7 +1684,7 @@  discard block
 block discarded – undo
1684 1684
 	private function version_options() {
1685 1685
 		$versions = $this->salesforce['sfapi']->get_api_versions();
1686 1686
 		$args     = array();
1687
-		foreach ( $versions['data'] as $key => $value ) {
1687
+		foreach ($versions['data'] as $key => $value) {
1688 1688
 			$args[] = array(
1689 1689
 				'value' => $value['version'],
1690 1690
 				'text'  => $value['label'] . ' (' . $value['version'] . ')',
@@ -1698,26 +1698,26 @@  discard block
 block discarded – undo
1698 1698
 	*
1699 1699
 	* @param array $args
1700 1700
 	*/
1701
-	public function display_link( $args ) {
1701
+	public function display_link($args) {
1702 1702
 		$label = $args['label'];
1703 1703
 		$desc  = $args['desc'];
1704 1704
 		$url   = $args['url'];
1705
-		if ( isset( $args['link_class'] ) ) {
1706
-			echo sprintf( '<p><a class="%1$s" href="%2$s">%3$s</a></p>',
1707
-				esc_attr( $args['link_class'] ),
1708
-				esc_url( $url ),
1709
-				esc_html( $label )
1705
+		if (isset($args['link_class'])) {
1706
+			echo sprintf('<p><a class="%1$s" href="%2$s">%3$s</a></p>',
1707
+				esc_attr($args['link_class']),
1708
+				esc_url($url),
1709
+				esc_html($label)
1710 1710
 			);
1711 1711
 		} else {
1712
-			echo sprintf( '<p><a href="%1$s">%2$s</a></p>',
1713
-				esc_url( $url ),
1714
-				esc_html( $label )
1712
+			echo sprintf('<p><a href="%1$s">%2$s</a></p>',
1713
+				esc_url($url),
1714
+				esc_html($label)
1715 1715
 			);
1716 1716
 		}
1717 1717
 
1718
-		if ( '' !== $desc ) {
1719
-			echo sprintf( '<p class="description">%1$s</p>',
1720
-				esc_html( $desc )
1718
+		if ('' !== $desc) {
1719
+			echo sprintf('<p class="description">%1$s</p>',
1720
+				esc_html($desc)
1721 1721
 			);
1722 1722
 		}
1723 1723
 
@@ -1729,15 +1729,15 @@  discard block
 block discarded – undo
1729 1729
 	* @param string $option
1730 1730
 	* @return string $option
1731 1731
 	*/
1732
-	public function sanitize_validate_text( $option ) {
1733
-		if ( is_array( $option ) ) {
1732
+	public function sanitize_validate_text($option) {
1733
+		if (is_array($option)) {
1734 1734
 			$options = array();
1735
-			foreach ( $option as $key => $value ) {
1736
-				$options[ $key ] = sanitize_text_field( $value );
1735
+			foreach ($option as $key => $value) {
1736
+				$options[$key] = sanitize_text_field($value);
1737 1737
 			}
1738 1738
 			return $options;
1739 1739
 		}
1740
-		$option = sanitize_text_field( $option );
1740
+		$option = sanitize_text_field($option);
1741 1741
 		return $option;
1742 1742
 	}
1743 1743
 
@@ -1746,60 +1746,60 @@  discard block
 block discarded – undo
1746 1746
 	*
1747 1747
 	* @param object $sfapi
1748 1748
 	*/
1749
-	private function status( $sfapi ) {
1749
+	private function status($sfapi) {
1750 1750
 
1751 1751
 		$versions = $sfapi->get_api_versions();
1752 1752
 
1753 1753
 		// format this array into text so users can see the versions
1754
-		if ( true === $versions['cached'] ) {
1755
-			$versions_is_cached = esc_html__( 'This list is cached, and', 'object-sync-salesforce' );
1754
+		if (true === $versions['cached']) {
1755
+			$versions_is_cached = esc_html__('This list is cached, and', 'object-sync-salesforce');
1756 1756
 		} else {
1757
-			$versions_is_cached = esc_html__( 'This list is not cached, but', 'object-sync-salesforce' );
1757
+			$versions_is_cached = esc_html__('This list is not cached, but', 'object-sync-salesforce');
1758 1758
 		}
1759 1759
 
1760
-		if ( true === $versions['from_cache'] ) {
1761
-			$versions_from_cache = esc_html__( 'items were loaded from the cache', 'object-sync-salesforce' );
1760
+		if (true === $versions['from_cache']) {
1761
+			$versions_from_cache = esc_html__('items were loaded from the cache', 'object-sync-salesforce');
1762 1762
 		} else {
1763
-			$versions_from_cache = esc_html__( 'items were not loaded from the cache', 'object-sync-salesforce' );
1763
+			$versions_from_cache = esc_html__('items were not loaded from the cache', 'object-sync-salesforce');
1764 1764
 		}
1765 1765
 
1766 1766
 		// 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
1767
-		$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' ),
1767
+		$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'),
1768 1768
 			$versions_is_cached,
1769 1769
 			$versions_from_cache
1770 1770
 		);
1771 1771
 
1772
-		$contacts = $sfapi->query( 'SELECT Name, Id from Contact LIMIT 100' );
1772
+		$contacts = $sfapi->query('SELECT Name, Id from Contact LIMIT 100');
1773 1773
 
1774 1774
 		// format this array into html so users can see the contacts
1775
-		if ( true === $contacts['cached'] ) {
1776
-			$contacts_is_cached = esc_html__( 'They are cached, and', 'object-sync-salesforce' );
1775
+		if (true === $contacts['cached']) {
1776
+			$contacts_is_cached = esc_html__('They are cached, and', 'object-sync-salesforce');
1777 1777
 		} else {
1778
-			$contacts_is_cached = esc_html__( 'They are not cached, but', 'object-sync-salesforce' );
1778
+			$contacts_is_cached = esc_html__('They are not cached, but', 'object-sync-salesforce');
1779 1779
 		}
1780 1780
 
1781
-		if ( true === $contacts['from_cache'] ) {
1782
-			$contacts_from_cache = esc_html__( 'they were loaded from the cache', 'object-sync-salesforce' );
1781
+		if (true === $contacts['from_cache']) {
1782
+			$contacts_from_cache = esc_html__('they were loaded from the cache', 'object-sync-salesforce');
1783 1783
 		} else {
1784
-			$contacts_from_cache = esc_html__( 'they were not loaded from the cache', 'object-sync-salesforce' );
1784
+			$contacts_from_cache = esc_html__('they were not loaded from the cache', 'object-sync-salesforce');
1785 1785
 		}
1786 1786
 
1787
-		if ( true === $contacts['is_redo'] ) {
1788
-			$contacts_refreshed_token = esc_html__( 'This request did require refreshing the Salesforce token', 'object-sync-salesforce' );
1787
+		if (true === $contacts['is_redo']) {
1788
+			$contacts_refreshed_token = esc_html__('This request did require refreshing the Salesforce token', 'object-sync-salesforce');
1789 1789
 		} else {
1790
-			$contacts_refreshed_token = esc_html__( 'This request did not require refreshing the Salesforce token', 'object-sync-salesforce' );
1790
+			$contacts_refreshed_token = esc_html__('This request did not require refreshing the Salesforce token', 'object-sync-salesforce');
1791 1791
 		}
1792 1792
 
1793 1793
 		// 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
1794
-		$contacts_apicall_summary = sprintf( esc_html__( 'Salesforce successfully returned %1$s %2$s records. %3$s %4$s. %5$s.', 'object-sync-for-salesforce' ),
1795
-			absint( $contacts['data']['totalSize'] ),
1796
-			esc_html( $contacts['data']['records'][0]['attributes']['type'] ),
1794
+		$contacts_apicall_summary = sprintf(esc_html__('Salesforce successfully returned %1$s %2$s records. %3$s %4$s. %5$s.', 'object-sync-for-salesforce'),
1795
+			absint($contacts['data']['totalSize']),
1796
+			esc_html($contacts['data']['records'][0]['attributes']['type']),
1797 1797
 			$contacts_is_cached,
1798 1798
 			$contacts_from_cache,
1799 1799
 			$contacts_refreshed_token
1800 1800
 		);
1801 1801
 
1802
-		require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/status.php' );
1802
+		require_once(plugin_dir_path(__FILE__) . '/../templates/admin/status.php');
1803 1803
 
1804 1804
 	}
1805 1805
 
@@ -1809,12 +1809,12 @@  discard block
 block discarded – undo
1809 1809
 	* For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce
1810 1810
 	*/
1811 1811
 	private function logout() {
1812
-		$this->access_token  = delete_option( $this->option_prefix . 'access_token' );
1813
-		$this->instance_url  = delete_option( $this->option_prefix . 'instance_url' );
1814
-		$this->refresh_token = delete_option( $this->option_prefix . 'refresh_token' );
1815
-		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>',
1816
-			esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize' ) ),
1817
-			esc_html__( 'Authorize', 'object-sync-for-salesforce' )
1812
+		$this->access_token  = delete_option($this->option_prefix . 'access_token');
1813
+		$this->instance_url  = delete_option($this->option_prefix . 'instance_url');
1814
+		$this->refresh_token = delete_option($this->option_prefix . 'refresh_token');
1815
+		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>',
1816
+			esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize')),
1817
+			esc_html__('Authorize', 'object-sync-for-salesforce')
1818 1818
 		);
1819 1819
 	}
1820 1820
 
@@ -1822,28 +1822,28 @@  discard block
 block discarded – undo
1822 1822
 	* Ajax call to clear the plugin cache.
1823 1823
 	*/
1824 1824
 	public function clear_sfwp_cache() {
1825
-		$result   = $this->clear_cache( true );
1825
+		$result   = $this->clear_cache(true);
1826 1826
 		$response = array(
1827 1827
 			'message' => $result['message'],
1828 1828
 			'success' => $result['success'],
1829 1829
 		);
1830
-		wp_send_json_success( $response );
1830
+		wp_send_json_success($response);
1831 1831
 	}
1832 1832
 
1833 1833
 	/**
1834 1834
 	* Clear the plugin's cache.
1835 1835
 	* This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data.
1836 1836
 	*/
1837
-	private function clear_cache( $ajax = false ) {
1837
+	private function clear_cache($ajax = false) {
1838 1838
 		$result = (bool) $this->wordpress->sfwp_transients->flush();
1839
-		if ( true === $result ) {
1840
-			$message = __( 'The plugin cache has been cleared.', 'object-sync-for-salesforce' );
1839
+		if (true === $result) {
1840
+			$message = __('The plugin cache has been cleared.', 'object-sync-for-salesforce');
1841 1841
 		} else {
1842
-			$message = __( 'There was an error clearing the plugin cache. Try refreshing this page.', 'object-sync-for-salesforce' );
1842
+			$message = __('There was an error clearing the plugin cache. Try refreshing this page.', 'object-sync-for-salesforce');
1843 1843
 		}
1844
-		if ( false === $ajax ) {
1844
+		if (false === $ajax) {
1845 1845
 			// translators: parameter 1 is the result message
1846
-			echo sprintf( '<p>%1$s</p>', $message );
1846
+			echo sprintf('<p>%1$s</p>', $message);
1847 1847
 		} else {
1848 1848
 			return array(
1849 1849
 				'message' => $message,
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 		// alternatively, other roles can get this capability in whatever other way you like
1867 1867
 		// point is: to administer this plugin, you need this capability
1868 1868
 
1869
-		if ( ! current_user_can( 'configure_salesforce' ) ) {
1869
+		if ( ! current_user_can('configure_salesforce')) {
1870 1870
 			return false;
1871 1871
 		} else {
1872 1872
 			return true;
@@ -1879,23 +1879,23 @@  discard block
 block discarded – undo
1879 1879
 	* @param object $user
1880 1880
 	*
1881 1881
 	*/
1882
-	public function show_salesforce_user_fields( $user ) {
1883
-		$get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
1884
-		if ( true === $this->check_wordpress_admin_permissions() ) {
1885
-			$mapping  = $this->mappings->load_by_wordpress( 'user', $user->ID );
1882
+	public function show_salesforce_user_fields($user) {
1883
+		$get_data = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
1884
+		if (true === $this->check_wordpress_admin_permissions()) {
1885
+			$mapping  = $this->mappings->load_by_wordpress('user', $user->ID);
1886 1886
 			$fieldmap = $this->mappings->get_fieldmaps(
1887 1887
 				null, // id field must be null for multiples
1888 1888
 				array(
1889 1889
 					'wordpress_object' => 'user',
1890 1890
 				)
1891 1891
 			);
1892
-			if ( isset( $mapping['id'] ) && ! isset( $get_data['edit_salesforce_mapping'] ) ) {
1893
-				require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/user-profile-salesforce.php' );
1894
-			} elseif ( ! empty( $fieldmap ) ) { // is the user mapped to something already?
1895
-				if ( isset( $get_data['edit_salesforce_mapping'] ) && 'true' === sanitize_key( $get_data['edit_salesforce_mapping'] ) ) {
1896
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/user-profile-salesforce-change.php' );
1892
+			if (isset($mapping['id']) && ! isset($get_data['edit_salesforce_mapping'])) {
1893
+				require_once(plugin_dir_path(__FILE__) . '/../templates/admin/user-profile-salesforce.php');
1894
+			} elseif ( ! empty($fieldmap)) { // is the user mapped to something already?
1895
+				if (isset($get_data['edit_salesforce_mapping']) && 'true' === sanitize_key($get_data['edit_salesforce_mapping'])) {
1896
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/user-profile-salesforce-change.php');
1897 1897
 				} else {
1898
-					require_once( plugin_dir_path( __FILE__ ) . '/../templates/admin/user-profile-salesforce-map.php' );
1898
+					require_once(plugin_dir_path(__FILE__) . '/../templates/admin/user-profile-salesforce-map.php');
1899 1899
 				}
1900 1900
 			}
1901 1901
 		}
@@ -1906,10 +1906,10 @@  discard block
 block discarded – undo
1906 1906
 	* @param int $user_id
1907 1907
 	*
1908 1908
 	*/
1909
-	public function save_salesforce_user_fields( $user_id ) {
1910
-		$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING );
1911
-		if ( isset( $post_data['salesforce_update_mapped_user'] ) && '1' === rawurlencode( $post_data['salesforce_update_mapped_user'] ) ) {
1912
-			$mapping_object                  = $this->mappings->get_object_maps(
1909
+	public function save_salesforce_user_fields($user_id) {
1910
+		$post_data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
1911
+		if (isset($post_data['salesforce_update_mapped_user']) && '1' === rawurlencode($post_data['salesforce_update_mapped_user'])) {
1912
+			$mapping_object = $this->mappings->get_object_maps(
1913 1913
 				array(
1914 1914
 					'wordpress_id'     => $user_id,
1915 1915
 					'wordpress_object' => 'user',
@@ -1917,14 +1917,14 @@  discard block
 block discarded – undo
1917 1917
 			);
1918 1918
 			$mapping_object['salesforce_id'] = $post_data['salesforce_id'];
1919 1919
 
1920
-			$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1921
-		} elseif ( isset( $post_data['salesforce_create_mapped_user'] ) && '1' === rawurlencode( $post_data['salesforce_create_mapped_user'] ) ) {
1920
+			$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1921
+		} elseif (isset($post_data['salesforce_create_mapped_user']) && '1' === rawurlencode($post_data['salesforce_create_mapped_user'])) {
1922 1922
 			// if a Salesforce ID was entered
1923
-			if ( isset( $post_data['salesforce_id'] ) && ! empty( $post_data['salesforce_id'] ) ) {
1924
-				$mapping_object = $this->create_object_map( $user_id, 'user', $post_data['salesforce_id'] );
1925
-			} elseif ( isset( $post_data['push_new_user_to_salesforce'] ) ) {
1923
+			if (isset($post_data['salesforce_id']) && ! empty($post_data['salesforce_id'])) {
1924
+				$mapping_object = $this->create_object_map($user_id, 'user', $post_data['salesforce_id']);
1925
+			} elseif (isset($post_data['push_new_user_to_salesforce'])) {
1926 1926
 				// otherwise, create a new record in Salesforce
1927
-				$result = $this->push_to_salesforce( 'user', $user_id );
1927
+				$result = $this->push_to_salesforce('user', $user_id);
1928 1928
 			}
1929 1929
 		}
1930 1930
 	}
@@ -1934,29 +1934,29 @@  discard block
 block discarded – undo
1934 1934
 	* @param array $tabs
1935 1935
 	* @param string $tab
1936 1936
 	*/
1937
-	private function tabs( $tabs, $tab = '' ) {
1937
+	private function tabs($tabs, $tab = '') {
1938 1938
 
1939
-		$get_data        = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
1939
+		$get_data        = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
1940 1940
 		$consumer_key    = $this->login_credentials['consumer_key'];
1941 1941
 		$consumer_secret = $this->login_credentials['consumer_secret'];
1942 1942
 		$callback_url    = $this->login_credentials['callback_url'];
1943 1943
 
1944 1944
 		$current_tab = $tab;
1945 1945
 		echo '<h2 class="nav-tab-wrapper">';
1946
-		foreach ( $tabs as $tab_key => $tab_caption ) {
1946
+		foreach ($tabs as $tab_key => $tab_caption) {
1947 1947
 			$active = $current_tab === $tab_key ? ' nav-tab-active' : '';
1948
-			if ( 'settings' === $tab_key || ( isset( $consumer_key ) && isset( $consumer_secret ) && ! empty( $consumer_key ) && ! empty( $consumer_secret ) ) ) {
1949
-				echo sprintf( '<a class="nav-tab%1$s" href="%2$s">%3$s</a>',
1950
-					esc_attr( $active ),
1951
-					esc_url( '?page=object-sync-salesforce-admin&tab=' . $tab_key ),
1952
-					esc_html( $tab_caption )
1948
+			if ('settings' === $tab_key || (isset($consumer_key) && isset($consumer_secret) && ! empty($consumer_key) && ! empty($consumer_secret))) {
1949
+				echo sprintf('<a class="nav-tab%1$s" href="%2$s">%3$s</a>',
1950
+					esc_attr($active),
1951
+					esc_url('?page=object-sync-salesforce-admin&tab=' . $tab_key),
1952
+					esc_html($tab_caption)
1953 1953
 				);
1954 1954
 			}
1955 1955
 		}
1956 1956
 		echo '</h2>';
1957 1957
 
1958
-		if ( isset( $get_data['tab'] ) ) {
1959
-			$tab = sanitize_key( $get_data['tab'] );
1958
+		if (isset($get_data['tab'])) {
1959
+			$tab = sanitize_key($get_data['tab']);
1960 1960
 		} else {
1961 1961
 			$tab = '';
1962 1962
 		}
@@ -1967,13 +1967,13 @@  discard block
 block discarded – undo
1967 1967
 	* This clears the schedule if the user clicks the button
1968 1968
 	* @param string $schedule_name
1969 1969
 	*/
1970
-	private function clear_schedule( $schedule_name = '' ) {
1971
-		if ( '' !== $schedule_name ) {
1972
-			$this->queue->cancel( $schedule_name );
1970
+	private function clear_schedule($schedule_name = '') {
1971
+		if ('' !== $schedule_name) {
1972
+			$this->queue->cancel($schedule_name);
1973 1973
 			// translators: $schedule_name is the name of the current queue. Defaults: salesforce_pull, salesforce_push, salesforce
1974
-			echo sprintf( esc_html__( 'You have cleared the %s schedule.', 'object-sync-for-salesforce' ), esc_html( $schedule_name ) );
1974
+			echo sprintf(esc_html__('You have cleared the %s schedule.', 'object-sync-for-salesforce'), esc_html($schedule_name));
1975 1975
 		} else {
1976
-			echo esc_html__( 'You need to specify the name of the schedule you want to clear.', 'object-sync-for-salesforce' );
1976
+			echo esc_html__('You need to specify the name of the schedule you want to clear.', 'object-sync-for-salesforce');
1977 1977
 		}
1978 1978
 	}
1979 1979
 
@@ -1982,13 +1982,13 @@  discard block
 block discarded – undo
1982 1982
 	* @param string $schedule_name
1983 1983
 	* @return int $count
1984 1984
 	*/
1985
-	private function get_schedule_count( $schedule_name = '' ) {
1986
-		if ( '' !== $schedule_name ) {
1987
-			$args  = array(
1985
+	private function get_schedule_count($schedule_name = '') {
1986
+		if ('' !== $schedule_name) {
1987
+			$args = array(
1988 1988
 				'group'  => $schedule_name,
1989 1989
 				'status' => ActionScheduler_Store::STATUS_PENDING,
1990 1990
 			);
1991
-			$count = count( $this->queue->search( $args, 'ARRAY_A' ) );
1991
+			$count = count($this->queue->search($args, 'ARRAY_A'));
1992 1992
 			return $count;
1993 1993
 		} else {
1994 1994
 			return 'unknown';
@@ -2011,17 +2011,17 @@  discard block
 block discarded – undo
2011 2011
 	*   This is the database row for the map object
2012 2012
 	*
2013 2013
 	*/
2014
-	private function create_object_map( $wordpress_id, $wordpress_object, $salesforce_id, $action = '' ) {
2014
+	private function create_object_map($wordpress_id, $wordpress_object, $salesforce_id, $action = '') {
2015 2015
 		// Create object map and save it
2016 2016
 		$mapping_object = $this->mappings->create_object_map(
2017 2017
 			array(
2018 2018
 				'wordpress_id'      => $wordpress_id, // wordpress unique id
2019 2019
 				'salesforce_id'     => $salesforce_id, // salesforce unique id. we don't care what kind of object it is at this point
2020 2020
 				'wordpress_object'  => $wordpress_object, // keep track of what kind of wp object this is
2021
-				'last_sync'         => current_time( 'mysql' ),
2021
+				'last_sync'         => current_time('mysql'),
2022 2022
 				'last_sync_action'  => $action,
2023 2023
 				'last_sync_status'  => $this->mappings->status_success,
2024
-				'last_sync_message' => __( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
2024
+				'last_sync_message' => __('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
2025 2025
 			)
2026 2026
 		);
2027 2027
 
Please login to merge, or discard this patch.