Test Setup Failed
Pull Request — master (#174)
by Jonathan
05:10
created
templates/admin/user-profile-salesforce-change.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <input type="hidden" name="salesforce_update_mapped_user" value="1" />
2
-<h2><?php echo esc_html__( 'Salesforce', 'object-sync-for-salesforce' ); ?></h2>
3
-<p><?php echo esc_html__( 'You can change the Salesforce object that this WordPress user maps to by changing the ID and updating this user.', 'object-sync-for-salesforce' ); ?></p>
2
+<h2><?php echo esc_html__('Salesforce', 'object-sync-for-salesforce'); ?></h2>
3
+<p><?php echo esc_html__('You can change the Salesforce object that this WordPress user maps to by changing the ID and updating this user.', 'object-sync-for-salesforce'); ?></p>
4 4
 <table class="form-table">
5 5
 	<tr>
6
-		<th><label for="salesforce_id"><?php echo esc_html__( 'Salesforce ID', 'object-sync-for-salesforce' ); ?></label></th>
6
+		<th><label for="salesforce_id"><?php echo esc_html__('Salesforce ID', 'object-sync-for-salesforce'); ?></label></th>
7 7
 		<td>
8
-			<input type="text" name="salesforce_id" id="salesforce_id" value="<?php if ( isset( $mapping['id'] ) ) { echo esc_html( $mapping['salesforce_id'] ); } ?>" class="regular-text" /><br />
9
-			<span class="description"><?php echo esc_html__( 'Enter a Salesforce object ID.', 'object-sync-for-salesforce' ); ?></span>
8
+			<input type="text" name="salesforce_id" id="salesforce_id" value="<?php if (isset($mapping['id'])) { echo esc_html($mapping['salesforce_id']); } ?>" class="regular-text" /><br />
9
+			<span class="description"><?php echo esc_html__('Enter a Salesforce object ID.', 'object-sync-for-salesforce'); ?></span>
10 10
 		</td>
11 11
 	</tr>
12 12
 </table>
Please login to merge, or discard this patch.
templates/admin/authorized.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,2 +1,2 @@
 block discarded – undo
1
-<div class="success"><h2><?php echo esc_html__( 'Salesforce is successfully authenticated.' ); ?></h2></div>
2
-<p><a class="button button-primary" href="<?php echo esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=logout' ) ); ?>"><?php echo esc_html__( 'Disconnect from Salesforce', 'object-sync-for-salesforce' ); ?></a></p>
1
+<div class="success"><h2><?php echo esc_html__('Salesforce is successfully authenticated.'); ?></h2></div>
2
+<p><a class="button button-primary" href="<?php echo esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=logout')); ?>"><?php echo esc_html__('Disconnect from Salesforce', 'object-sync-for-salesforce'); ?></a></p>
Please login to merge, or discard this patch.
templates/admin/user-profile-salesforce-map.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <input type="hidden" name="salesforce_create_mapped_user" value="1" />
2
-<h2><?php echo esc_html__( 'Salesforce', 'object-sync-for-salesforce' ); ?></h2>
3
-<p><?php echo esc_html__( "This user is not mapped to an object in Salesforce. You can run a push to send this object to Salesforce, which will cause it to follow the plugin's normal mapping conventions, or you can create a manual link to a Salesforce object.", 'object-sync-for-salesforce' ); ?></p>
2
+<h2><?php echo esc_html__('Salesforce', 'object-sync-for-salesforce'); ?></h2>
3
+<p><?php echo esc_html__("This user is not mapped to an object in Salesforce. You can run a push to send this object to Salesforce, which will cause it to follow the plugin's normal mapping conventions, or you can create a manual link to a Salesforce object.", 'object-sync-for-salesforce'); ?></p>
4 4
 <table class="form-table">
5 5
 	<tr>
6
-		<th><label for="salesforce_id"><?php echo esc_html__( 'Salesforce ID', 'object-sync-for-salesforce' ); ?></label></th>
6
+		<th><label for="salesforce_id"><?php echo esc_html__('Salesforce ID', 'object-sync-for-salesforce'); ?></label></th>
7 7
 		<td>
8 8
 			<input type="text" name="salesforce_id" id="salesforce_id" value="" class="regular-text" /><br />
9
-			<span class="description"><?php echo esc_html__( 'Enter a Salesforce object ID.', 'object-sync-for-salesforce' ); ?></span>
9
+			<span class="description"><?php echo esc_html__('Enter a Salesforce object ID.', 'object-sync-for-salesforce'); ?></span>
10 10
 			<p><strong>or</strong></p>
11
-			<p><button type="submit" class="button button-secondary push_to_salesforce_button" name="push_new_user_to_salesforce"><?php echo esc_html__( 'Push to Salesforce as new record', 'object-sync-for-salesforce' ); ?></button></p>
11
+			<p><button type="submit" class="button button-secondary push_to_salesforce_button" name="push_new_user_to_salesforce"><?php echo esc_html__('Push to Salesforce as new record', 'object-sync-for-salesforce'); ?></button></p>
12 12
 		</td>
13 13
 	</tr>
14 14
 </table>
Please login to merge, or discard this patch.
classes/salesforce_query.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
 	public $conditions = array();
23 23
 
24 24
 	/**
25
-	* Constructor which sets the query object type.
26
-	*
27
-	* @param string $object_type
28
-	*   Salesforce object type to query.
29
-	*/
25
+	 * Constructor which sets the query object type.
26
+	 *
27
+	 * @param string $object_type
28
+	 *   Salesforce object type to query.
29
+	 */
30 30
 	public function __construct( $object_type = '' ) {
31 31
 		$this->object_type = $object_type;
32 32
 	}
33 33
 
34 34
 	/**
35
-	* Add a condition to the query.
36
-	*
37
-	* @param string $field
38
-	*   Field name.
39
-	* @param mixed $value
40
-	*   Condition value. If an array, it will be split into quote enclosed
41
-	*   strings separated by commas inside of parenthesis. Note that the caller
42
-	*   must enclose the value in quotes as needed by the SF API.
43
-	* @param string $operator
44
-	*   Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'.
45
-	*/
35
+	 * Add a condition to the query.
36
+	 *
37
+	 * @param string $field
38
+	 *   Field name.
39
+	 * @param mixed $value
40
+	 *   Condition value. If an array, it will be split into quote enclosed
41
+	 *   strings separated by commas inside of parenthesis. Note that the caller
42
+	 *   must enclose the value in quotes as needed by the SF API.
43
+	 * @param string $operator
44
+	 *   Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'.
45
+	 */
46 46
 	public function add_condition( $field, $value, $operator = '=' ) {
47 47
 		if ( is_array( $value ) ) {
48 48
 			$value = "('" . implode( "','", $value ) . "')";
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Implements PHP's magic __toString().
64
-	*
65
-	* Function to convert the query to a string to pass to the SF API.
66
-	*
67
-	* @return string
68
-	*   SOQL query ready to be executed the SF API.
69
-	*/
63
+	 * Implements PHP's magic __toString().
64
+	 *
65
+	 * Function to convert the query to a string to pass to the SF API.
66
+	 *
67
+	 * @return string
68
+	 *   SOQL query ready to be executed the SF API.
69
+	 */
70 70
 	public function __toString() {
71 71
 
72 72
 		$query  = 'SELECT ';
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	* @param string $object_type
28 28
 	*   Salesforce object type to query.
29 29
 	*/
30
-	public function __construct( $object_type = '' ) {
30
+	public function __construct($object_type = '') {
31 31
 		$this->object_type = $object_type;
32 32
 	}
33 33
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 	* @param string $operator
44 44
 	*   Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'.
45 45
 	*/
46
-	public function add_condition( $field, $value, $operator = '=' ) {
47
-		if ( is_array( $value ) ) {
48
-			$value = "('" . implode( "','", $value ) . "')";
46
+	public function add_condition($field, $value, $operator = '=') {
47
+		if (is_array($value)) {
48
+			$value = "('" . implode("','", $value) . "')";
49 49
 
50 50
 			// Set operator to IN if wasn't already changed from the default.
51
-			if ( '=' === $operator ) {
51
+			if ('=' === $operator) {
52 52
 				$operator = 'IN';
53 53
 			}
54 54
 		}
@@ -70,31 +70,31 @@  discard block
 block discarded – undo
70 70
 	public function __toString() {
71 71
 
72 72
 		$query  = 'SELECT ';
73
-		$query .= implode( ', ', $this->fields );
73
+		$query .= implode(', ', $this->fields);
74 74
 		$query .= ' FROM ' . $this->object_type;
75 75
 
76
-		if ( count( $this->conditions ) > 0 ) {
76
+		if (count($this->conditions) > 0) {
77 77
 			$where = array();
78
-			foreach ( $this->conditions as $condition ) {
79
-				$where[] = implode( ' ', $condition );
78
+			foreach ($this->conditions as $condition) {
79
+				$where[] = implode(' ', $condition);
80 80
 			}
81
-			$query .= ' WHERE ' . implode( ' AND ', $where );
81
+			$query .= ' WHERE ' . implode(' AND ', $where);
82 82
 		}
83 83
 
84
-		if ( $this->order ) {
84
+		if ($this->order) {
85 85
 			$query .= ' ORDER BY ';
86 86
 			$fields = array();
87
-			foreach ( $this->order as $field => $direction ) {
87
+			foreach ($this->order as $field => $direction) {
88 88
 				$fields[] = $field . ' ' . $direction;
89 89
 			}
90
-			$query .= implode( ', ', $fields );
90
+			$query .= implode(', ', $fields);
91 91
 		}
92 92
 
93
-		if ( $this->limit ) {
93
+		if ($this->limit) {
94 94
 			$query .= ' LIMIT ' . (int) $this->limit;
95 95
 		}
96 96
 
97
-		if ( $this->offset ) {
97
+		if ($this->offset) {
98 98
 			$query .= ' OFFSET ' . (int) $this->offset;
99 99
 		}
100 100
 
Please login to merge, or discard this patch.
classes/admin-notice.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
 	protected $template;
22 22
 
23 23
 	/**
24
-	* Constructor which sets up the admin_notices hook for rendering
25
-	*
26
-	* @param mixed $condition
27
-	* @param string $message
28
-	* @param bool $dismissible
29
-	* @param string $type
30
-	* @param string $template
31
-	*
32
-	*/
24
+	 * Constructor which sets up the admin_notices hook for rendering
25
+	 *
26
+	 * @param mixed $condition
27
+	 * @param string $message
28
+	 * @param bool $dismissible
29
+	 * @param string $type
30
+	 * @param string $template
31
+	 *
32
+	 */
33 33
 	public function __construct( $condition, $message, $dismissible = false, $type = '', $template = '' ) {
34 34
 		$this->condition   = $condition;
35 35
 		$this->message     = $message;
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	}
43 43
 
44 44
 	/**
45
-	* Render an admin notice
46
-	*
47
-	*/
45
+	 * Render an admin notice
46
+	 *
47
+	 */
48 48
 	public function render() {
49 49
 
50 50
 		// class for the notice to use
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	* @param string $template
31 31
 	*
32 32
 	*/
33
-	public function __construct( $condition, $message, $dismissible = false, $type = '', $template = '' ) {
33
+	public function __construct($condition, $message, $dismissible = false, $type = '', $template = '') {
34 34
 		$this->condition   = $condition;
35 35
 		$this->message     = $message;
36 36
 		$this->dismissible = $dismissible;
37 37
 		$this->type        = $type;
38 38
 		$this->template    = $template;
39 39
 
40
-		add_action( 'admin_notices', array( $this, 'render' ) );
40
+		add_action('admin_notices', array($this, 'render'));
41 41
 
42 42
 	}
43 43
 
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
 
50 50
 		// class for the notice to use
51 51
 		$class = '';
52
-		if ( '' !== $this->type ) {
52
+		if ('' !== $this->type) {
53 53
 			$class = ' notice-' . $this->type;
54 54
 		}
55 55
 
56 56
 		$dismissible = '';
57
-		if ( true === $this->dismissible ) {
57
+		if (true === $this->dismissible) {
58 58
 			$dismissible = ' is-dismissible';
59 59
 		}
60 60
 
61 61
 		// template for notice has a default
62
-		if ( '' === $this->template ) {
63
-			$template = plugin_dir_path( __FILE__ ) . '/../templates/admin/notice.php';
62
+		if ('' === $this->template) {
63
+			$template = plugin_dir_path(__FILE__) . '/../templates/admin/notice.php';
64 64
 		} else {
65 65
 			$template = $this->template;
66 66
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$condition = $this->condition;
69 69
 		$message   = $this->message;
70 70
 
71
-		require_once( $template );
71
+		require_once($template);
72 72
 
73 73
 	}
74 74
 
Please login to merge, or discard this patch.
classes/activate.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 	protected $installed_version;
20 20
 
21 21
 	/**
22
-	* Constructor which sets up activate hooks
23
-	*
24
-	* @param object $wpdb
25
-	* @param string $version
26
-	* @param string $slug
27
-	*
28
-	*/
22
+	 * Constructor which sets up activate hooks
23
+	 *
24
+	 * @param object $wpdb
25
+	 * @param string $version
26
+	 * @param string $slug
27
+	 *
28
+	 */
29 29
 	public function __construct( $wpdb, $version, $slug ) {
30 30
 		$this->wpdb              = $wpdb;
31 31
 		$this->version           = $version;
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-	* Check for the minimum required version of php
41
-	*/
40
+	 * Check for the minimum required version of php
41
+	 */
42 42
 	public function php_requirements() {
43 43
 		if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
44 44
 			deactivate_plugins( plugin_basename( __FILE__ ) );
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	/**
50
-	* Create database tables for Salesforce
51
-	* This creates tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
52
-	*
53
-	*/
50
+	 * Create database tables for Salesforce
51
+	 * This creates tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
52
+	 *
53
+	 */
54 54
 	public function wordpress_salesforce_tables() {
55 55
 
56 56
 		$charset_collate = $this->wpdb->get_charset_collate();
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	/**
114
-	* Check for database version on plugin upgrade
115
-	* When the plugin is upgraded, if the database version does not match the current version, perform these methods
116
-	*
117
-	*/
114
+	 * Check for database version on plugin upgrade
115
+	 * When the plugin is upgraded, if the database version does not match the current version, perform these methods
116
+	 *
117
+	 */
118 118
 	public function wordpress_salesforce_update_db_check() {
119 119
 		if ( get_site_option( 'object_sync_for_salesforce_db_version' ) !== $this->version ) {
120 120
 			$this->wordpress_salesforce_tables();
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 	}
123 123
 
124 124
 	/**
125
-	* Add roles and capabilities
126
-	* This adds the configure_salesforce capability to the admin role
127
-	*
128
-	* It also allows other plugins to add the capability to other roles
129
-	*
130
-	*/
125
+	 * Add roles and capabilities
126
+	 * This adds the configure_salesforce capability to the admin role
127
+	 *
128
+	 * It also allows other plugins to add the capability to other roles
129
+	 *
130
+	 */
131 131
 	public function add_roles_capabilities() {
132 132
 
133 133
 		// by default, only administrators can configure the plugin
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
 	* @param string $slug
27 27
 	*
28 28
 	*/
29
-	public function __construct( $wpdb, $version, $slug ) {
29
+	public function __construct($wpdb, $version, $slug) {
30 30
 		$this->wpdb              = $wpdb;
31 31
 		$this->version           = $version;
32
-		$this->installed_version = get_option( 'object_sync_for_salesforce_db_version', '' );
33
-		register_activation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'php_requirements' ) );
34
-		register_activation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'wordpress_salesforce_tables' ) );
35
-		register_activation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'add_roles_capabilities' ) );
36
-		add_action( 'plugins_loaded', array( $this, 'wordpress_salesforce_update_db_check' ) );
32
+		$this->installed_version = get_option('object_sync_for_salesforce_db_version', '');
33
+		register_activation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'php_requirements'));
34
+		register_activation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'wordpress_salesforce_tables'));
35
+		register_activation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'add_roles_capabilities'));
36
+		add_action('plugins_loaded', array($this, 'wordpress_salesforce_update_db_check'));
37 37
 	}
38 38
 
39 39
 	/**
40 40
 	* Check for the minimum required version of php
41 41
 	*/
42 42
 	public function php_requirements() {
43
-		if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
44
-			deactivate_plugins( plugin_basename( __FILE__ ) );
45
-			wp_die( '<strong>This plugin requires PHP Version 5.5</strong> <br />Please contact your host to upgrade PHP on your server, and then retry activating the plugin.' );
43
+		if (version_compare(PHP_VERSION, '5.5', '<')) {
44
+			deactivate_plugins(plugin_basename(__FILE__));
45
+			wp_die('<strong>This plugin requires PHP Version 5.5</strong> <br />Please contact your host to upgrade PHP on your server, and then retry activating the plugin.');
46 46
 		}
47 47
 	}
48 48
 
@@ -95,18 +95,18 @@  discard block
 block discarded – undo
95 95
 			KEY salesforce_object (salesforce_id)
96 96
 		) $charset_collate";
97 97
 
98
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
98
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
99 99
 
100 100
 		// Note: see https://wordpress.stackexchange.com/questions/67345/how-to-implement-wordpress-plugin-update-that-modifies-the-database
101 101
 		// When we run the dbDelta method below, "it checks if the table exists. What's more, it checks the column types. So if the table doesn't exist, it creates it, if it does, but some column types have changed it updates them, and if a column doesn't exists - it adds it."
102 102
 		// This does not remove columns if we remove columns, so we'll need to expand beyond this in the future if that happens, although I think the schema is pretty solid now.
103
-		dbDelta( $field_map_sql );
104
-		dbDelta( $object_map_sql );
103
+		dbDelta($field_map_sql);
104
+		dbDelta($object_map_sql);
105 105
 
106
-		update_option( 'object_sync_for_salesforce_db_version', $this->version );
106
+		update_option('object_sync_for_salesforce_db_version', $this->version);
107 107
 
108 108
 		// store right now as the time for the plugin's activation
109
-		update_option( 'object_sync_for_salesforce_activate_time', current_time( 'timestamp', true ) );
109
+		update_option('object_sync_for_salesforce_activate_time', current_time('timestamp', true));
110 110
 
111 111
 	}
112 112
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	*
117 117
 	*/
118 118
 	public function wordpress_salesforce_update_db_check() {
119
-		if ( get_site_option( 'object_sync_for_salesforce_db_version' ) !== $this->version ) {
119
+		if (get_site_option('object_sync_for_salesforce_db_version') !== $this->version) {
120 120
 			$this->wordpress_salesforce_tables();
121 121
 		}
122 122
 	}
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 	public function add_roles_capabilities() {
132 132
 
133 133
 		// by default, only administrators can configure the plugin
134
-		$role = get_role( 'administrator' );
135
-		$role->add_cap( 'configure_salesforce' );
134
+		$role = get_role('administrator');
135
+		$role->add_cap('configure_salesforce');
136 136
 
137 137
 		// hook that allows other roles to configure the plugin as well
138
-		$roles = apply_filters( 'object_sync_for_salesforce_roles_configure_salesforce', null );
138
+		$roles = apply_filters('object_sync_for_salesforce_roles_configure_salesforce', null);
139 139
 
140 140
 		// for each role that we have, give it the configure salesforce capability
141
-		if ( null !== $roles ) {
142
-			foreach ( $roles as $role ) {
143
-				$role = get_role( $role );
144
-				$role->add_cap( 'configure_salesforce' );
141
+		if (null !== $roles) {
142
+			foreach ($roles as $role) {
143
+				$role = get_role($role);
144
+				$role->add_cap('configure_salesforce');
145 145
 			}
146 146
 		}
147 147
 
Please login to merge, or discard this patch.
classes/salesforce_pull.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
 	protected $schedulable_classes;
25 25
 
26 26
 	/**
27
-	* @var string
28
-	*/
27
+	 * @var string
28
+	 */
29 29
 	public $schedule_name; // allow for naming the queue in case there are multiple queues
30 30
 
31 31
 	/**
32
-	* Constructor which sets up pull schedule
33
-	*
34
-	* @param object $wpdb
35
-	* @param string $version
36
-	* @param array $login_credentials
37
-	* @param string $slug
38
-	* @param object $wordpress
39
-	* @param object $salesforce
40
-	* @param object $mappings
41
-	* @param object $logging
42
-	* @param array $schedulable_classes
43
-	* @throws \Exception
44
-	*/
32
+	 * Constructor which sets up pull schedule
33
+	 *
34
+	 * @param object $wpdb
35
+	 * @param string $version
36
+	 * @param array $login_credentials
37
+	 * @param string $slug
38
+	 * @param object $wordpress
39
+	 * @param object $salesforce
40
+	 * @param object $mappings
41
+	 * @param object $logging
42
+	 * @param array $schedulable_classes
43
+	 * @throws \Exception
44
+	 */
45 45
 	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
46 46
 		$this->wpdb                = $wpdb;
47 47
 		$this->version             = $version;
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	/**
73
-	* Create the action hooks based on what object maps exist from the admin settings
74
-	*
75
-	*/
73
+	 * Create the action hooks based on what object maps exist from the admin settings
74
+	 *
75
+	 */
76 76
 	private function add_actions() {
77 77
 		add_action( 'wp_ajax_salesforce_pull_webhook', array( $this, 'salesforce_pull_webhook' ) );
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Ajax callback for salesforce pull. Returns status of 200 for successful
82
-	* attempt or 403 for a failed pull attempt (SF not authorized, threshhold
83
-	* reached, etc.
84
-	* this is the ajax callback; not a cron run
85
-	*/
81
+	 * Ajax callback for salesforce pull. Returns status of 200 for successful
82
+	 * attempt or 403 for a failed pull attempt (SF not authorized, threshhold
83
+	 * reached, etc.
84
+	 * this is the ajax callback; not a cron run
85
+	 */
86 86
 	public function salesforce_pull_webhook() {
87 87
 
88 88
 		if ( true === $this->salesforce_pull() ) {
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	/**
105
-	* Callback for the standard pull process used by webhooks and cron.
106
-	*/
105
+	 * Callback for the standard pull process used by webhooks and cron.
106
+	 */
107 107
 	public function salesforce_pull() {
108 108
 		$sfapi = $this->salesforce['sfapi'];
109 109
 
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	}
124 124
 
125 125
 	/**
126
-	* Load schedule
127
-	* This loads the schedule class
128
-	*/
126
+	 * Load schedule
127
+	 * This loads the schedule class
128
+	 */
129 129
 	private function schedule() {
130 130
 		if ( ! class_exists( 'Object_Sync_Sf_Schedule' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
131 131
 			require_once plugin_dir_path( __FILE__ ) . '../vendor/autoload.php';
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 	}
138 138
 
139 139
 	/**
140
-	* Determines if the Salesforce pull should be allowed, or throttled.
141
-	*
142
-	* Prevents too many pull processes from running at once.
143
-	*
144
-	* @return bool
145
-	*    Returns false if the time elapsed between recent pulls is too short.
146
-	*/
140
+	 * Determines if the Salesforce pull should be allowed, or throttled.
141
+	 *
142
+	 * Prevents too many pull processes from running at once.
143
+	 *
144
+	 * @return bool
145
+	 *    Returns false if the time elapsed between recent pulls is too short.
146
+	 */
147 147
 	private function check_throttle() {
148 148
 		$pull_throttle = get_option( 'object_sync_for_salesforce_pull_throttle', 5 );
149 149
 		$last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync', 0 );
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 
158 158
 	/**
159
-	* Pull updated records from Salesforce and place them in the queue.
160
-	*
161
-	* Executes a SOQL query based on defined mappings, loops through the results,
162
-	* and places each updated SF object into the queue for later processing.
163
-	*
164
-	* We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF
165
-	*
166
-	*/
159
+	 * Pull updated records from Salesforce and place them in the queue.
160
+	 *
161
+	 * Executes a SOQL query based on defined mappings, loops through the results,
162
+	 * and places each updated SF object into the queue for later processing.
163
+	 *
164
+	 * We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF
165
+	 *
166
+	 */
167 167
 	private function get_updated_records() {
168 168
 		$sfapi = $this->salesforce['sfapi'];
169 169
 		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
 	}
330 330
 
331 331
 	/**
332
-	* Given a SObject type name, build an SOQL query to include all fields for all
333
-	* SalesforceMappings mapped to that SObject.
334
-	*
335
-	* @param string $type
336
-	*   e.g. "Contact", "Account", etc.
337
-	*
338
-	* @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields
339
-	*   were found.
340
-	*
341
-	* @see Object_Sync_Sf_Mapping::get_mapped_fields
342
-	* @see Object_Sync_Sf_Mapping::get_mapped_record_types
343
-	*/
332
+	 * Given a SObject type name, build an SOQL query to include all fields for all
333
+	 * SalesforceMappings mapped to that SObject.
334
+	 *
335
+	 * @param string $type
336
+	 *   e.g. "Contact", "Account", etc.
337
+	 *
338
+	 * @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields
339
+	 *   were found.
340
+	 *
341
+	 * @see Object_Sync_Sf_Mapping::get_mapped_fields
342
+	 * @see Object_Sync_Sf_Mapping::get_mapped_record_types
343
+	 */
344 344
 	private function get_pull_query( $type, $salesforce_mapping = array() ) {
345 345
 		$mapped_fields       = array();
346 346
 		$mapped_record_types = array();
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
 	}
423 423
 
424 424
 	/**
425
-	* Get deleted records from salesforce.
426
-	* Note that deletions can only be queried via REST with an API version >= 29.0.
427
-	*
428
-	*/
425
+	 * Get deleted records from salesforce.
426
+	 * Note that deletions can only be queried via REST with an API version >= 29.0.
427
+	 *
428
+	 */
429 429
 	private function get_deleted_records() {
430 430
 
431 431
 		$sfapi = $this->salesforce['sfapi'];
@@ -517,13 +517,13 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	/**
520
-	* Method for ajax hooks to call for pulling manually
521
-	*
522
-	* @param string $object_type
523
-	* @param string $salesforce_id
524
-	* @param string $wordpress_object
525
-	*
526
-	*/
520
+	 * Method for ajax hooks to call for pulling manually
521
+	 *
522
+	 * @param string $object_type
523
+	 * @param string $salesforce_id
524
+	 * @param string $wordpress_object
525
+	 *
526
+	 */
527 527
 	public function manual_pull( $object_type, $salesforce_id, $wordpress_object ) {
528 528
 		$sfapi   = $this->salesforce['sfapi'];
529 529
 		$object  = $sfapi->api_call( 'sobjects/' . $object_type . '/' . $salesforce_id );
@@ -538,20 +538,20 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 	/**
541
-	* Sync WordPress objects and Salesforce objects from the queue using the REST API.
542
-	*
543
-	* @param string $object_type
544
-	*   Type of Salesforce object.
545
-	* @param object $object
546
-	*   The Salesforce object.
547
-	* @param object $mapping
548
-	*   Salesforce/WP mapping object.
549
-	* @param int $sf_sync_trigger
550
-	*   Trigger for this sync.
551
-	*
552
-	* @return true or exit the method
553
-	*
554
-	*/
541
+	 * Sync WordPress objects and Salesforce objects from the queue using the REST API.
542
+	 *
543
+	 * @param string $object_type
544
+	 *   Type of Salesforce object.
545
+	 * @param object $object
546
+	 *   The Salesforce object.
547
+	 * @param object $mapping
548
+	 *   Salesforce/WP mapping object.
549
+	 * @param int $sf_sync_trigger
550
+	 *   Trigger for this sync.
551
+	 *
552
+	 * @return true or exit the method
553
+	 *
554
+	 */
555 555
 	public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) {
556 556
 		$mapping_conditions = array(
557 557
 			'salesforce_object' => $object_type,
@@ -1282,19 +1282,19 @@  discard block
 block discarded – undo
1282 1282
 	}
1283 1283
 
1284 1284
 	/**
1285
-	* Create an object map between a Salesforce object and a WordPress object
1286
-	*
1287
-	* @param array $salesforce_object
1288
-	*   Array of the salesforce object's data
1289
-	* @param string $wordpress_id
1290
-	*   Unique identifier for the WordPress object
1291
-	* @param array $field_mapping
1292
-	*   The row that maps the object types together, including which fields match which other fields
1293
-	*
1294
-	* @return int $wpdb->insert_id
1295
-	*   This is the database row for the map object
1296
-	*
1297
-	*/
1285
+	 * Create an object map between a Salesforce object and a WordPress object
1286
+	 *
1287
+	 * @param array $salesforce_object
1288
+	 *   Array of the salesforce object's data
1289
+	 * @param string $wordpress_id
1290
+	 *   Unique identifier for the WordPress object
1291
+	 * @param array $field_mapping
1292
+	 *   The row that maps the object types together, including which fields match which other fields
1293
+	 *
1294
+	 * @return int $wpdb->insert_id
1295
+	 *   This is the database row for the map object
1296
+	 *
1297
+	 */
1298 1298
 	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1299 1299
 		// Create object map and save it
1300 1300
 		$mapping_object = $this->mappings->create_object_map(
Please login to merge, or discard this patch.
Spacing   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	* @param array $schedulable_classes
43 43
 	* @throws \Exception
44 44
 	*/
45
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
45
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes) {
46 46
 		$this->wpdb                = $wpdb;
47 47
 		$this->version             = $version;
48 48
 		$this->login_credentials   = $login_credentials;
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 		$schedule = $this->schedule;
62 62
 		// create new schedule based on the options for this current class
63 63
 		// this will use the existing schedule if it already exists; otherwise it'll create one
64
-		$schedule->use_schedule( $this->schedule_name );
64
+		$schedule->use_schedule($this->schedule_name);
65 65
 
66 66
 		$this->add_actions();
67 67
 
68
-		$this->debug = get_option( 'object_sync_for_salesforce_debug_mode', false );
68
+		$this->debug = get_option('object_sync_for_salesforce_debug_mode', false);
69 69
 
70 70
 	}
71 71
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	*
75 75
 	*/
76 76
 	private function add_actions() {
77
-		add_action( 'wp_ajax_salesforce_pull_webhook', array( $this, 'salesforce_pull_webhook' ) );
77
+		add_action('wp_ajax_salesforce_pull_webhook', array($this, 'salesforce_pull_webhook'));
78 78
 	}
79 79
 
80 80
 	/**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	*/
86 86
 	public function salesforce_pull_webhook() {
87 87
 
88
-		if ( true === $this->salesforce_pull() ) {
88
+		if (true === $this->salesforce_pull()) {
89 89
 			$code = '200';
90 90
 			// check to see if anything is in the queue and handle it if it is
91 91
 			$this->schedule->maybe_handle();
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 			$code = '403';
94 94
 		}
95 95
 
96
-		if ( ! empty( $_POST ) ) { // linter flags this, but we're not doing anything with the array just checking to see if it is empty
97
-			wp_send_json_success( $code );
96
+		if ( ! empty($_POST)) { // linter flags this, but we're not doing anything with the array just checking to see if it is empty
97
+			wp_send_json_success($code);
98 98
 		} else {
99 99
 			return $code;
100 100
 		}
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	public function salesforce_pull() {
108 108
 		$sfapi = $this->salesforce['sfapi'];
109 109
 
110
-		if ( true === $this->salesforce['is_authorized'] && true === $this->check_throttle() ) {
110
+		if (true === $this->salesforce['is_authorized'] && true === $this->check_throttle()) {
111 111
 
112 112
 			$this->get_updated_records();
113 113
 			$this->get_deleted_records();
114 114
 
115 115
 			// Store this request time for the throttle check.
116
-			update_option( 'object_sync_for_salesforce_pull_last_sync', current_time( 'timestamp', true ) );
116
+			update_option('object_sync_for_salesforce_pull_last_sync', current_time('timestamp', true));
117 117
 			return true;
118 118
 
119 119
 		} else {
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 	* This loads the schedule class
128 128
 	*/
129 129
 	private function schedule() {
130
-		if ( ! class_exists( 'Object_Sync_Sf_Schedule' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
131
-			require_once plugin_dir_path( __FILE__ ) . '../vendor/autoload.php';
132
-			require_once plugin_dir_path( __FILE__ ) . '../classes/schedule.php';
130
+		if ( ! class_exists('Object_Sync_Sf_Schedule') && file_exists(plugin_dir_path(__FILE__) . '../vendor/autoload.php')) {
131
+			require_once plugin_dir_path(__FILE__) . '../vendor/autoload.php';
132
+			require_once plugin_dir_path(__FILE__) . '../classes/schedule.php';
133 133
 		}
134
-		$schedule       = new Object_Sync_Sf_Schedule( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->schedule_name, $this->logging, $this->schedulable_classes );
134
+		$schedule       = new Object_Sync_Sf_Schedule($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->schedule_name, $this->logging, $this->schedulable_classes);
135 135
 		$this->schedule = $schedule;
136 136
 		return $schedule;
137 137
 	}
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 	*    Returns false if the time elapsed between recent pulls is too short.
146 146
 	*/
147 147
 	private function check_throttle() {
148
-		$pull_throttle = get_option( 'object_sync_for_salesforce_pull_throttle', 5 );
149
-		$last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync', 0 );
148
+		$pull_throttle = get_option('object_sync_for_salesforce_pull_throttle', 5);
149
+		$last_sync     = get_option('object_sync_for_salesforce_pull_last_sync', 0);
150 150
 
151
-		if ( current_time( 'timestamp', true ) > ( $last_sync + $pull_throttle ) ) {
151
+		if (current_time('timestamp', true) > ($last_sync + $pull_throttle)) {
152 152
 			return true;
153 153
 		} else {
154 154
 			return false;
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	*/
167 167
 	private function get_updated_records() {
168 168
 		$sfapi = $this->salesforce['sfapi'];
169
-		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
169
+		foreach ($this->mappings->get_fieldmaps() as $salesforce_mapping) {
170 170
 			$map_sync_triggers = $salesforce_mapping['sync_triggers']; // this sets which Salesforce triggers are allowed for the mapping
171 171
 			$type              = $salesforce_mapping['salesforce_object']; // this sets the salesfore object type for the SOQL query
172 172
 
173
-			$soql = $this->get_pull_query( $type, $salesforce_mapping );
173
+			$soql = $this->get_pull_query($type, $salesforce_mapping);
174 174
 
175 175
 			// get_pull_query returns null if it has no matching fields
176
-			if ( null === $soql ) {
176
+			if (null === $soql) {
177 177
 				continue;
178 178
 			}
179 179
 
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 			);
189 189
 
190 190
 			$response     = $results['data'];
191
-			$version_path = wp_parse_url( $sfapi->get_api_endpoint(), PHP_URL_PATH );
191
+			$version_path = wp_parse_url($sfapi->get_api_endpoint(), PHP_URL_PATH);
192 192
 
193
-			$sf_last_sync = get_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, null );
194
-			$last_sync    = gmdate( 'Y-m-d\TH:i:s\Z', $sf_last_sync );
193
+			$sf_last_sync = get_option('object_sync_for_salesforce_pull_last_sync_' . $type, null);
194
+			$last_sync    = gmdate('Y-m-d\TH:i:s\Z', $sf_last_sync);
195 195
 
196
-			if ( ! isset( $response['errorCode'] ) ) {
196
+			if ( ! isset($response['errorCode'])) {
197 197
 				// Write items to the queue.
198
-				foreach ( $response['records'] as $result ) {
198
+				foreach ($response['records'] as $result) {
199 199
 
200 200
 					// if this record is new as of the last sync, use the create trigger
201
-					if ( isset( $result['CreatedDate'] ) && $result['CreatedDate'] > $last_sync ) {
201
+					if (isset($result['CreatedDate']) && $result['CreatedDate'] > $last_sync) {
202 202
 						$sf_sync_trigger = $this->mappings->sync_sf_create;
203 203
 					} else {
204 204
 						$sf_sync_trigger = $this->mappings->sync_sf_update;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 					// Only queue when the record's trigger is configured for the mapping
208 208
 					// these are bit operators, so we leave out the strict
209
-					if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
209
+					if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
210 210
 						$data = array(
211 211
 							'object_type'     => $type,
212 212
 							'object'          => $result,
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 						$pull_allowed = true;
219 219
 
220 220
 						// if the current fieldmap does not allow create, we need to check if there is a fieldmap for the Salesforce object Id. if not, set pull_allowed to false.
221
-						if ( isset( $map_sync_triggers ) && ! in_array( $this->mappings->sync_sf_create, $map_sync_triggers ) ) {
222
-							$object_map = $this->mappings->load_by_salesforce( $result['Id'] );
223
-							if ( empty( $object_map ) ) {
221
+						if (isset($map_sync_triggers) && ! in_array($this->mappings->sync_sf_create, $map_sync_triggers)) {
222
+							$object_map = $this->mappings->load_by_salesforce($result['Id']);
223
+							if (empty($object_map)) {
224 224
 								$pull_allowed = false;
225 225
 							}
226 226
 						}
227 227
 
228 228
 						// Hook to allow other plugins to prevent a pull per-mapping.
229 229
 						// Putting the pull_allowed hook here will keep the queue from storing data when it is not supposed to store it
230
-						$pull_allowed = apply_filters( 'object_sync_for_salesforce_pull_object_allowed', $pull_allowed, $type, $result, $sf_sync_trigger, $salesforce_mapping );
230
+						$pull_allowed = apply_filters('object_sync_for_salesforce_pull_object_allowed', $pull_allowed, $type, $result, $sf_sync_trigger, $salesforce_mapping);
231 231
 
232 232
 						// example to keep from pulling the Contact with id of abcdef
233 233
 						/*
@@ -240,26 +240,26 @@  discard block
 block discarded – undo
240 240
 						}
241 241
 						*/
242 242
 
243
-						if ( false === $pull_allowed ) {
244
-							update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, current_time( 'timestamp', true ) );
243
+						if (false === $pull_allowed) {
244
+							update_option('object_sync_for_salesforce_pull_last_sync_' . $type, current_time('timestamp', true));
245 245
 							continue;
246 246
 						}
247 247
 
248 248
 						// Initialize the queue with the data for this record and save
249
-						$this->schedule->data( array( $data ) );
249
+						$this->schedule->data(array($data));
250 250
 						$this->schedule->save()->dispatch();
251 251
 						// Update the last pull sync timestamp for this record type to avoid re-processing in case of error
252
-						$last_sync_pull_trigger = DateTime::createFromFormat( 'Y-m-d\TH:i:s+', $result[ $salesforce_mapping['pull_trigger_field'] ], new DateTimeZone( 'UTC' ) );
253
-						update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format( 'U' ) );
252
+						$last_sync_pull_trigger = DateTime::createFromFormat('Y-m-d\TH:i:s+', $result[$salesforce_mapping['pull_trigger_field']], new DateTimeZone('UTC'));
253
+						update_option('object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format('U'));
254 254
 					}
255 255
 				}
256 256
 
257 257
 				// Handle requests larger than the batch limit (usually 2000).
258
-				$next_records_url = isset( $response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $response['nextRecordsUrl'] ) : false;
258
+				$next_records_url = isset($response['nextRecordsUrl']) ? str_replace($version_path, '', $response['nextRecordsUrl']) : false;
259 259
 
260
-				while ( $next_records_url ) {
260
+				while ($next_records_url) {
261 261
 					// shouldn't cache this either. it's going into the queue if it exists anyway.
262
-					$new_results  = $sfapi->api_call(
262
+					$new_results = $sfapi->api_call(
263 263
 						$next_records_url,
264 264
 						array(),
265 265
 						'GET',
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 						)
269 269
 					);
270 270
 					$new_response = $new_results['data'];
271
-					if ( ! isset( $new_response['errorCode'] ) ) {
271
+					if ( ! isset($new_response['errorCode'])) {
272 272
 						// Write items to the queue.
273
-						foreach ( $new_response['records'] as $result ) {
273
+						foreach ($new_response['records'] as $result) {
274 274
 							// if this record is new as of the last sync, use the create trigger
275
-							if ( isset( $result['CreatedDate'] ) && $result['CreatedDate'] > $last_sync ) {
275
+							if (isset($result['CreatedDate']) && $result['CreatedDate'] > $last_sync) {
276 276
 								$sf_sync_trigger = $this->mappings->sync_sf_create;
277 277
 							} else {
278 278
 								$sf_sync_trigger = $this->mappings->sync_sf_update;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
 							// Only queue when the record's trigger is configured for the mapping
282 282
 							// these are bit operators, so we leave out the strict
283
-							if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
283
+							if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
284 284
 								$data = array(
285 285
 									'object_type'     => $type,
286 286
 									'object'          => $result,
@@ -289,31 +289,31 @@  discard block
 block discarded – undo
289 289
 								);
290 290
 
291 291
 								// Initialize the queue with the data for this record and save
292
-								$this->schedule->data( array( $data ) );
292
+								$this->schedule->data(array($data));
293 293
 								$this->schedule->save()->dispatch();
294 294
 								// Update the last pull sync timestamp for this record type to avoid re-processing in case of error
295
-								$last_sync_pull_trigger = DateTime::createFromFormat( 'Y-m-d\TH:i:s+', $result[ $salesforce_mapping['pull_trigger_field'] ], new DateTimeZone( 'UTC' ) );
296
-								update_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format( 'U' ) );
295
+								$last_sync_pull_trigger = DateTime::createFromFormat('Y-m-d\TH:i:s+', $result[$salesforce_mapping['pull_trigger_field']], new DateTimeZone('UTC'));
296
+								update_option('object_sync_for_salesforce_pull_last_sync_' . $type, $last_sync_pull_trigger->format('U'));
297 297
 							}
298 298
 						}
299 299
 					}
300 300
 
301
-					$next_records_url = isset( $new_response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $new_response['nextRecordsUrl'] ) : false;
301
+					$next_records_url = isset($new_response['nextRecordsUrl']) ? str_replace($version_path, '', $new_response['nextRecordsUrl']) : false;
302 302
 				}
303 303
 			} else {
304 304
 
305 305
 				// create log entry for failed pull
306 306
 				$status = 'error';
307 307
 				// translators: placeholders are: 1) the server error code, and 2) the name of the Salesforce object
308
-				$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
309
-					absint( $response['errorCode'] ),
310
-					esc_attr( $salesforce_mapping['salesforce_object'] )
308
+				$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
309
+					absint($response['errorCode']),
310
+					esc_attr($salesforce_mapping['salesforce_object'])
311 311
 				);
312 312
 
313
-				if ( isset( $this->logging ) ) {
313
+				if (isset($this->logging)) {
314 314
 					$logging = $this->logging;
315
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
316
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
315
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
316
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
317 317
 				}
318 318
 
319 319
 				$logging->setup(
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	* @see Object_Sync_Sf_Mapping::get_mapped_fields
342 342
 	* @see Object_Sync_Sf_Mapping::get_mapped_record_types
343 343
 	*/
344
-	private function get_pull_query( $type, $salesforce_mapping = array() ) {
344
+	private function get_pull_query($type, $salesforce_mapping = array()) {
345 345
 		$mapped_fields       = array();
346 346
 		$mapped_record_types = array();
347 347
 
@@ -353,35 +353,35 @@  discard block
 block discarded – undo
353 353
 		);
354 354
 
355 355
 		// Iterate over each field mapping to determine our query parameters.
356
-		foreach ( $mappings as $mapping ) {
356
+		foreach ($mappings as $mapping) {
357 357
 
358 358
 			// only use fields that come from Salesforce to WordPress, or that sync
359 359
 			$mapped_fields = array_merge(
360 360
 				$mapped_fields,
361 361
 				$this->mappings->get_mapped_fields(
362 362
 					$mapping,
363
-					array( $this->mappings->direction_sync, $this->mappings->direction_sf_wordpress )
363
+					array($this->mappings->direction_sync, $this->mappings->direction_sf_wordpress)
364 364
 				)
365 365
 			);
366 366
 
367 367
 			// If Record Type is specified, restrict query.
368
-			$mapping_record_types = $this->mappings->get_mapped_record_types( $mapping );
368
+			$mapping_record_types = $this->mappings->get_mapped_record_types($mapping);
369 369
 
370 370
 			// If Record Type is not specified for a given mapping, ensure query is unrestricted.
371
-			if ( empty( $mapping_record_types ) ) {
371
+			if (empty($mapping_record_types)) {
372 372
 				$mapped_record_types = false;
373
-			} elseif ( is_array( $mapped_record_types ) ) {
374
-				$mapped_record_types = array_merge( $mapped_record_types, $mapping_record_types );
373
+			} elseif (is_array($mapped_record_types)) {
374
+				$mapped_record_types = array_merge($mapped_record_types, $mapping_record_types);
375 375
 			}
376 376
 		} // End foreach().
377 377
 
378 378
 		// There are no field mappings configured to pull data from Salesforce so
379 379
 		// move on to the next mapped object. Prevents querying unmapped data.
380
-		if ( empty( $mapped_fields ) ) {
380
+		if (empty($mapped_fields)) {
381 381
 			return null;
382 382
 		}
383 383
 
384
-		$soql = new Object_Sync_Sf_Salesforce_Select_Query( $type );
384
+		$soql = new Object_Sync_Sf_Salesforce_Select_Query($type);
385 385
 
386 386
 		// Convert field mappings to SOQL.
387 387
 		$soql->fields = array_merge(
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		);
394 394
 
395 395
 		// these are bit operators, so we leave out the strict
396
-		if ( in_array( $this->mappings->sync_sf_create, $salesforce_mapping['sync_triggers'] ) ) {
396
+		if (in_array($this->mappings->sync_sf_create, $salesforce_mapping['sync_triggers'])) {
397 397
 			$soql->fields['CreatedDate'] = 'CreatedDate';
398 398
 		}
399 399
 
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 		// this should be what keeps it from getting all the records, whether or not they've ever been updated
402 402
 		// we also use the option for when the plugin was installed, and don't go back further than that by default
403 403
 
404
-		$sf_activate_time = get_option( 'object_sync_for_salesforce_activate_time', '' );
405
-		$sf_last_sync     = get_option( 'object_sync_for_salesforce_pull_last_sync_' . $type, null );
406
-		if ( $sf_last_sync ) {
407
-			$last_sync = gmdate( 'Y-m-d\TH:i:s\Z', $sf_last_sync );
408
-			$soql->add_condition( $salesforce_mapping['pull_trigger_field'], $last_sync, '>' );
404
+		$sf_activate_time = get_option('object_sync_for_salesforce_activate_time', '');
405
+		$sf_last_sync     = get_option('object_sync_for_salesforce_pull_last_sync_' . $type, null);
406
+		if ($sf_last_sync) {
407
+			$last_sync = gmdate('Y-m-d\TH:i:s\Z', $sf_last_sync);
408
+			$soql->add_condition($salesforce_mapping['pull_trigger_field'], $last_sync, '>');
409 409
 		} else {
410
-			$activated = gmdate( 'Y-m-d\TH:i:s\Z', $sf_activate_time );
411
-			$soql->add_condition( $salesforce_mapping['pull_trigger_field'], $activated, '>' );
410
+			$activated = gmdate('Y-m-d\TH:i:s\Z', $sf_activate_time);
411
+			$soql->add_condition($salesforce_mapping['pull_trigger_field'], $activated, '>');
412 412
 			// put a hook in here to let devs go retroactive if they want, and sync data from before plugin was activated
413 413
 		}
414 414
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		// we are not incorporating that part of this branch at this time
435 435
 
436 436
 		// Load all unique SF record types that we have mappings for.
437
-		foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) {
437
+		foreach ($this->mappings->get_fieldmaps() as $salesforce_mapping) {
438 438
 
439 439
 			$type = $salesforce_mapping['salesforce_object'];
440 440
 
@@ -446,37 +446,37 @@  discard block
 block discarded – undo
446 446
 			);
447 447
 
448 448
 			// Iterate over each field mapping to determine our query parameters.
449
-			foreach ( $mappings as $mapping ) {
449
+			foreach ($mappings as $mapping) {
450 450
 
451
-				$last_delete_sync = get_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, current_time( 'timestamp', true ) );
452
-				$now              = current_time( 'timestamp', true );
453
-				update_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, $now );
451
+				$last_delete_sync = get_option('object_sync_for_salesforce_pull_delete_last_' . $type, current_time('timestamp', true));
452
+				$now              = current_time('timestamp', true);
453
+				update_option('object_sync_for_salesforce_pull_delete_last_' . $type, $now);
454 454
 
455 455
 				// get_deleted() constraint: startDate cannot be more than 30 days ago
456 456
 				// (using an incompatible date may lead to exceptions).
457
-				$last_delete_sync = $last_delete_sync > ( current_time( 'timestamp', true ) - 2505600 ) ? $last_delete_sync : ( current_time( 'timestamp', true ) - 2505600 );
457
+				$last_delete_sync = $last_delete_sync > (current_time('timestamp', true) - 2505600) ? $last_delete_sync : (current_time('timestamp', true) - 2505600);
458 458
 
459 459
 				// get_deleted() constraint: startDate must be at least one minute greater
460 460
 				// than endDate.
461
-				$now = $now > ( $last_delete_sync + 60 ) ? $now : $now + 60;
461
+				$now = $now > ($last_delete_sync + 60) ? $now : $now + 60;
462 462
 
463 463
 				// need to be using gmdate for salesforce call
464
-				$last_delete_sync_sf = gmdate( 'Y-m-d\TH:i:s\Z', $last_delete_sync );
465
-				$now_sf              = gmdate( 'Y-m-d\TH:i:s\Z', $now );
464
+				$last_delete_sync_sf = gmdate('Y-m-d\TH:i:s\Z', $last_delete_sync);
465
+				$now_sf              = gmdate('Y-m-d\TH:i:s\Z', $now);
466 466
 
467 467
 				// salesforce call
468
-				$deleted = $sfapi->get_deleted( $type, $last_delete_sync_sf, $now_sf );
468
+				$deleted = $sfapi->get_deleted($type, $last_delete_sync_sf, $now_sf);
469 469
 
470
-				if ( empty( $deleted['data']['deletedRecords'] ) ) {
470
+				if (empty($deleted['data']['deletedRecords'])) {
471 471
 					continue;
472 472
 				}
473 473
 
474
-				foreach ( $deleted['data']['deletedRecords'] as $result ) {
474
+				foreach ($deleted['data']['deletedRecords'] as $result) {
475 475
 
476 476
 					$sf_sync_trigger = $this->mappings->sync_sf_delete;
477 477
 
478 478
 					// salesforce seriously returns Id for update requests and id for delete requests and this makes no sense but maybe one day they might change it somehow?
479
-					if ( ! isset( $result['Id'] ) && isset( $result['id'] ) ) {
479
+					if ( ! isset($result['Id']) && isset($result['id'])) {
480 480
 						$result['Id'] = $result['id'];
481 481
 					}
482 482
 					$data = array(
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 
489 489
 					// Hook to allow other plugins to prevent a pull per-mapping.
490 490
 					// Putting the pull_allowed hook here will keep the queue from storing data when it is not supposed to store it
491
-					$pull_allowed = apply_filters( 'object_sync_for_salesforce_pull_object_allowed', true, $type, $result, $sf_sync_trigger, $salesforce_mapping );
491
+					$pull_allowed = apply_filters('object_sync_for_salesforce_pull_object_allowed', true, $type, $result, $sf_sync_trigger, $salesforce_mapping);
492 492
 
493 493
 					// example to keep from pulling the Contact with id of abcdef
494 494
 					/*
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
 					}
502 502
 					*/
503 503
 
504
-					if ( false === $pull_allowed ) {
504
+					if (false === $pull_allowed) {
505 505
 						continue;
506 506
 					}
507 507
 
508
-					$this->schedule->push_to_queue( $data );
508
+					$this->schedule->push_to_queue($data);
509 509
 					$this->schedule->save()->dispatch();
510 510
 
511 511
 				}
512 512
 
513
-				update_option( 'object_sync_for_salesforce_pull_delete_last_' . $type, current_time( 'timestamp', true ) );
513
+				update_option('object_sync_for_salesforce_pull_delete_last_' . $type, current_time('timestamp', true));
514 514
 
515 515
 			} // End foreach().
516 516
 		} // End foreach().
@@ -524,9 +524,9 @@  discard block
 block discarded – undo
524 524
 	* @param string $wordpress_object
525 525
 	*
526 526
 	*/
527
-	public function manual_pull( $object_type, $salesforce_id, $wordpress_object ) {
527
+	public function manual_pull($object_type, $salesforce_id, $wordpress_object) {
528 528
 		$sfapi   = $this->salesforce['sfapi'];
529
-		$object  = $sfapi->api_call( 'sobjects/' . $object_type . '/' . $salesforce_id );
529
+		$object  = $sfapi->api_call('sobjects/' . $object_type . '/' . $salesforce_id);
530 530
 		$mapping = $this->mappings->get_fieldmaps(
531 531
 			null,
532 532
 			array(
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				'wordpress_object'  => $wordpress_object,
535 535
 			)
536 536
 		);
537
-		$this->salesforce_pull_process_records( $object_type, $object['data'], $mapping[0], $this->mappings->sync_sf_update );
537
+		$this->salesforce_pull_process_records($object_type, $object['data'], $mapping[0], $this->mappings->sync_sf_update);
538 538
 	}
539 539
 
540 540
 	/**
@@ -552,45 +552,45 @@  discard block
 block discarded – undo
552 552
 	* @return true or exit the method
553 553
 	*
554 554
 	*/
555
-	public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) {
555
+	public function salesforce_pull_process_records($object_type, $object, $mapping, $sf_sync_trigger) {
556 556
 		$mapping_conditions = array(
557 557
 			'salesforce_object' => $object_type,
558 558
 		);
559 559
 
560
-		if ( isset( $object['RecordTypeId'] ) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type ) {
560
+		if (isset($object['RecordTypeId']) && $object['RecordTypeId'] !== $this->mappings->salesforce_default_record_type) {
561 561
 			// use this condition to filter the mappings, at that time
562 562
 			$mapping_conditions['salesforce_record_type'] = $object['RecordTypeId'];
563 563
 		}
564 564
 
565
-		$salesforce_mappings = $this->mappings->get_fieldmaps( null, $mapping_conditions );
565
+		$salesforce_mappings = $this->mappings->get_fieldmaps(null, $mapping_conditions);
566 566
 
567 567
 		// from drupal: if there is more than one mapping, don't throw exceptions
568
-		$hold_exceptions = count( $salesforce_mappings ) > 1;
568
+		$hold_exceptions = count($salesforce_mappings) > 1;
569 569
 		$exception       = false;
570 570
 
571
-		$seconds = $this->schedule->get_schedule_frequency_seconds( $this->schedule_name ) + 60;
571
+		$seconds = $this->schedule->get_schedule_frequency_seconds($this->schedule_name) + 60;
572 572
 
573 573
 		$transients_to_delete = array();
574 574
 
575
-		foreach ( $salesforce_mappings as $salesforce_mapping ) {
575
+		foreach ($salesforce_mappings as $salesforce_mapping) {
576 576
 
577 577
 			// this returns the row that maps the individual Salesforce row to the individual WordPress row
578
-			if ( isset( $object['Id'] ) ) {
579
-				$mapping_object = $this->mappings->load_by_salesforce( $object['Id'] );
578
+			if (isset($object['Id'])) {
579
+				$mapping_object = $this->mappings->load_by_salesforce($object['Id']);
580 580
 			} else {
581 581
 				// if we don't have a Salesforce object id, we've got no business doing stuff in WordPress
582 582
 				$status = 'error';
583
-				if ( isset( $this->logging ) ) {
583
+				if (isset($this->logging)) {
584 584
 					$logging = $this->logging;
585
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
586
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
585
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
586
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
587 587
 				}
588 588
 
589
-				$title = sprintf( esc_html__( 'Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce' ) );
589
+				$title = sprintf(esc_html__('Error: Salesforce Pull: unable to process queue item because it has no Salesforce Id.', 'object-sync-for-salesforce'));
590 590
 
591 591
 				$logging->setup(
592 592
 					$title,
593
-					print_r( $object, true ), // log whatever we have in the event of this error, so print the array
593
+					print_r($object, true), // log whatever we have in the event of this error, so print the array
594 594
 					$sf_sync_trigger,
595 595
 					$status
596 596
 				);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			// if it's not already connected (ie on create), the array will be empty
602 602
 
603 603
 			// hook to allow other plugins to define or alter the mapping object
604
-			$mapping_object = apply_filters( 'object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping );
604
+			$mapping_object = apply_filters('object_sync_for_salesforce_pull_mapping_object', $mapping_object, $object, $mapping);
605 605
 
606 606
 			// we already have the data from Salesforce at this point; we just need to work with it in WordPress
607 607
 			$synced_object = array(
@@ -610,58 +610,58 @@  discard block
 block discarded – undo
610 610
 				'mapping'           => $mapping,
611 611
 			);
612 612
 
613
-			$structure = $this->wordpress->get_wordpress_table_structure( $salesforce_mapping['wordpress_object'] );
613
+			$structure = $this->wordpress->get_wordpress_table_structure($salesforce_mapping['wordpress_object']);
614 614
 			$object_id = $structure['id_field'];
615 615
 
616 616
 			$op = '';
617 617
 
618 618
 			// are these objects already connected in WordPress?
619
-			if ( isset( $mapping_object['id'] ) ) {
619
+			if (isset($mapping_object['id'])) {
620 620
 				$is_new                      = false;
621 621
 				$mapping_object_id_transient = $mapping_object['id'];
622 622
 			} else {
623 623
 				// there is not a mapping object for this WordPress object id yet
624 624
 				// check for that transient with the currently pushing id
625 625
 				$is_new                      = true;
626
-				$mapping_object_id_transient = get_transient( 'salesforce_pushing_object_id' );
626
+				$mapping_object_id_transient = get_transient('salesforce_pushing_object_id');
627 627
 			}
628 628
 
629 629
 			// Drupal only does a salesforce_pull flag, but we might as well do push and pull because WordPress
630
-			$salesforce_pushing = (int) get_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
631
-			if ( 1 === $salesforce_pushing ) {
630
+			$salesforce_pushing = (int) get_transient('salesforce_pushing_' . $mapping_object_id_transient);
631
+			if (1 === $salesforce_pushing) {
632 632
 				$transients_to_delete[] = $mapping_object_id_transient;
633 633
 				continue;
634 634
 			}
635 635
 
636 636
 			// deleting mapped objects
637
-			if ( $sf_sync_trigger == $this->mappings->sync_sf_delete ) { // trigger is a bit operator
638
-				if ( isset( $mapping_object['id'] ) ) {
637
+			if ($sf_sync_trigger == $this->mappings->sync_sf_delete) { // trigger is a bit operator
638
+				if (isset($mapping_object['id'])) {
639 639
 
640
-					set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
641
-					set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
640
+					set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
641
+					set_transient('salesforce_pulling_object_id', $mapping_object['id']);
642 642
 
643 643
 					$op              = 'Delete';
644
-					$wordpress_check = $this->mappings->load_by_wordpress( $mapping_object['wordpress_object'], $mapping_object['wordpress_id'] );
645
-					if ( count( $wordpress_check ) === count( $wordpress_check, COUNT_RECURSIVE ) ) {
644
+					$wordpress_check = $this->mappings->load_by_wordpress($mapping_object['wordpress_object'], $mapping_object['wordpress_id']);
645
+					if (count($wordpress_check) === count($wordpress_check, COUNT_RECURSIVE)) {
646 646
 						try {
647
-							$result = $this->wordpress->object_delete( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'] );
648
-						} catch ( WordpressException $e ) {
647
+							$result = $this->wordpress->object_delete($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id']);
648
+						} catch (WordpressException $e) {
649 649
 							$status = 'error';
650 650
 							// create log entry for failed delete
651
-							if ( isset( $this->logging ) ) {
651
+							if (isset($this->logging)) {
652 652
 								$logging = $this->logging;
653
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
654
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
653
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
654
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
655 655
 							}
656 656
 
657 657
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
658
-							$title = sprintf( esc_html__( 'Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
659
-								esc_attr( $op ),
660
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
661
-								esc_attr( $object_id ),
662
-								esc_attr( $mapping_object['wordpress_id'] ),
663
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
664
-								esc_attr( $mapping_object['salesforce_id'] )
658
+							$title = sprintf(esc_html__('Error: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
659
+								esc_attr($op),
660
+								esc_attr($salesforce_mapping['wordpress_object']),
661
+								esc_attr($object_id),
662
+								esc_attr($mapping_object['wordpress_id']),
663
+								esc_attr($salesforce_mapping['salesforce_object']),
664
+								esc_attr($mapping_object['salesforce_id'])
665 665
 							);
666 666
 
667 667
 							$logging->setup(
@@ -672,38 +672,38 @@  discard block
 block discarded – undo
672 672
 								$status
673 673
 							);
674 674
 
675
-							if ( false === $hold_exceptions ) {
675
+							if (false === $hold_exceptions) {
676 676
 								throw $e;
677 677
 							}
678
-							if ( empty( $exception ) ) {
678
+							if (empty($exception)) {
679 679
 								$exception = $e;
680 680
 							} else {
681
-								$my_class  = get_class( $e );
682
-								$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
681
+								$my_class  = get_class($e);
682
+								$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
683 683
 							}
684 684
 
685 685
 							// hook for pull fail
686
-							do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
686
+							do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
687 687
 
688 688
 						} // End try().
689 689
 
690
-						if ( ! isset( $e ) ) {
690
+						if ( ! isset($e)) {
691 691
 							// create log entry for successful delete if the result had no errors
692 692
 							$status = 'success';
693
-							if ( isset( $this->logging ) ) {
693
+							if (isset($this->logging)) {
694 694
 								$logging = $this->logging;
695
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
696
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
695
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
696
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
697 697
 							}
698 698
 
699 699
 							// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
700
-							$title = sprintf( esc_html__( 'Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce' ),
701
-								esc_attr( $op ),
702
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
703
-								esc_attr( $object_id ),
704
-								esc_attr( $mapping_object['wordpress_id'] ),
705
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
706
-								esc_attr( $mapping_object['salesforce_id'] )
700
+							$title = sprintf(esc_html__('Success: %1$s WordPress %2$s with %3$s of %4$s (%5$s %6$s)', 'object-sync-for-salesforce'),
701
+								esc_attr($op),
702
+								esc_attr($salesforce_mapping['wordpress_object']),
703
+								esc_attr($object_id),
704
+								esc_attr($mapping_object['wordpress_id']),
705
+								esc_attr($salesforce_mapping['salesforce_object']),
706
+								esc_attr($mapping_object['salesforce_id'])
707 707
 							);
708 708
 
709 709
 							$logging->setup(
@@ -715,38 +715,38 @@  discard block
 block discarded – undo
715 715
 							);
716 716
 
717 717
 							// hook for pull success
718
-							do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
718
+							do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
719 719
 						}
720 720
 					} else {
721
-						$more_ids = sprintf( '<p>' . esc_html__( 'The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce' ) );
721
+						$more_ids = sprintf('<p>' . esc_html__('The WordPress record was not deleted because there are multiple Salesforce IDs that match this WordPress ID. They are:', 'object-sync-for-salesforce'));
722 722
 						$i        = 0;
723
-						foreach ( $wordpress_check as $match ) {
723
+						foreach ($wordpress_check as $match) {
724 724
 							$i++;
725
-							$more_ids .= sprintf( $match['salesforce_id'] );
726
-							if ( count( $wordpress_check ) !== $i ) {
727
-								$more_ids .= sprintf( ', ' );
725
+							$more_ids .= sprintf($match['salesforce_id']);
726
+							if (count($wordpress_check) !== $i) {
727
+								$more_ids .= sprintf(', ');
728 728
 							} else {
729
-								$more_ids .= sprintf( '.</p>' );
729
+								$more_ids .= sprintf('.</p>');
730 730
 							}
731 731
 						}
732 732
 
733
-						$more_ids .= sprintf( '<p>' . esc_html__( 'The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce' ) . '</p>' );
733
+						$more_ids .= sprintf('<p>' . esc_html__('The map row between this Salesforce object and the WordPress object, as stored in the WordPress database, will be deleted, and this Salesforce object has been deleted, but the WordPress object row will remain untouched.', 'object-sync-for-salesforce') . '</p>');
734 734
 
735 735
 						$status = 'notice';
736
-						if ( isset( $this->logging ) ) {
736
+						if (isset($this->logging)) {
737 737
 							$logging = $this->logging;
738
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
739
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
738
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
739
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
740 740
 						}
741 741
 
742 742
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
743
-						$title = sprintf( esc_html__( 'Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce' ),
744
-							esc_attr( $op ),
745
-							esc_attr( $salesforce_mapping['wordpress_object'] ),
746
-							esc_attr( $object_id ),
747
-							esc_attr( $mapping_object['wordpress_id'] ),
748
-							esc_attr( $salesforce_mapping['salesforce_object'] ),
749
-							esc_attr( $mapping_object['salesforce_id'] )
743
+						$title = sprintf(esc_html__('Notice: %1$s %2$s with %3$s of %4$s (%5$s %6$s) did not delete the WordPress item.', 'object-sync-for-salesforce'),
744
+							esc_attr($op),
745
+							esc_attr($salesforce_mapping['wordpress_object']),
746
+							esc_attr($object_id),
747
+							esc_attr($mapping_object['wordpress_id']),
748
+							esc_attr($salesforce_mapping['salesforce_object']),
749
+							esc_attr($mapping_object['salesforce_id'])
750 750
 						);
751 751
 
752 752
 						$logging->setup(
@@ -760,27 +760,27 @@  discard block
 block discarded – undo
760 760
 
761 761
 					// delete the map row from WordPress after the WordPress row has been deleted
762 762
 					// we delete the map row even if the WordPress delete failed, because the Salesforce object is gone
763
-					$this->mappings->delete_object_map( $mapping_object['id'] );
763
+					$this->mappings->delete_object_map($mapping_object['id']);
764 764
 					// there is no map row if we end this if statement
765 765
 				} // End if().
766 766
 				return;
767 767
 			} // End if().
768 768
 
769 769
 			// map the Salesforce values to WordPress fields
770
-			$params = $this->mappings->map_params( $mapping, $object, $sf_sync_trigger, false, $is_new );
770
+			$params = $this->mappings->map_params($mapping, $object, $sf_sync_trigger, false, $is_new);
771 771
 
772 772
 			// hook to allow other plugins to modify the $params array
773 773
 			// use hook to map fields between the WordPress and Salesforce objects
774 774
 			// returns $params.
775
-			$params = apply_filters( 'object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new );
775
+			$params = apply_filters('object_sync_for_salesforce_pull_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new);
776 776
 
777 777
 			// if we don't get any params, there are no fields that should be sent to WordPress
778
-			if ( empty( $params ) ) {
778
+			if (empty($params)) {
779 779
 				return;
780 780
 			}
781 781
 
782 782
 			// if there is a prematch WordPress field - ie email - on the fieldmap object
783
-			if ( isset( $params['prematch'] ) && is_array( $params['prematch'] ) ) {
783
+			if (isset($params['prematch']) && is_array($params['prematch'])) {
784 784
 				$prematch_field_wordpress  = $params['prematch']['wordpress_field'];
785 785
 				$prematch_field_salesforce = $params['prematch']['salesforce_field'];
786 786
 				$prematch_value            = $params['prematch']['value'];
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
 					'method_update' => $params['prematch']['method_update'],
791 791
 					'method_read'   => $params['prematch']['method_read'],
792 792
 				);
793
-				unset( $params['prematch'] );
793
+				unset($params['prematch']);
794 794
 			}
795 795
 
796 796
 			// if there is an external key field in salesforce - ie mailchimp user id - on the fieldmap object
797
-			if ( isset( $params['key'] ) && is_array( $params['key'] ) ) {
797
+			if (isset($params['key']) && is_array($params['key'])) {
798 798
 				$key_field_wordpress  = $params['key']['wordpress_field'];
799 799
 				$key_field_salesforce = $params['key']['salesforce_field'];
800 800
 				$key_value            = $params['key']['value'];
@@ -804,20 +804,20 @@  discard block
 block discarded – undo
804 804
 					'method_update' => $params['prematch']['method_update'],
805 805
 					'method_read'   => $params['key']['method_read'],
806 806
 				);
807
-				unset( $params['key'] );
807
+				unset($params['key']);
808 808
 			}
809 809
 
810 810
 			// methods to run the wp create or update operations
811 811
 
812
-			if ( true === $is_new ) {
812
+			if (true === $is_new) {
813 813
 
814 814
 				// setup SF record type. CampaignMember objects get their Campaign's type
815 815
 				// i am still a bit confused about this
816 816
 				// we should store this as a meta field on each object, if it meets these criteria
817 817
 				// we need to store the read/modify attributes because the field doesn't exist in the mapping
818
-				if ( $salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty( $params['RecordTypeId'] ) && ( 'CampaignMember' !== $salesforce_mapping['salesforce_object'] ) ) {
818
+				if ($salesforce_mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty($params['RecordTypeId']) && ('CampaignMember' !== $salesforce_mapping['salesforce_object'])) {
819 819
 					$type = $salesforce_mapping['wordpress_object'];
820
-					if ( 'category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object'] ) {
820
+					if ('category' === $salesforce_mapping['wordpress_object'] || 'tag' === $salesforce_mapping['wordpress_object'] || 'post_tag' === $salesforce_mapping['wordpress_object']) {
821 821
 						$type = 'term';
822 822
 					}
823 823
 					$params['RecordTypeId'] = array(
@@ -835,28 +835,28 @@  discard block
 block discarded – undo
835 835
 					// returns a $salesforce_id.
836 836
 					// it should keep NULL if there is no match
837 837
 					// the function that calls this hook needs to check the mapping to make sure the WordPress object is the right type
838
-					$wordpress_id = apply_filters( 'object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull' );
838
+					$wordpress_id = apply_filters('object_sync_for_salesforce_find_wp_object_match', null, $object, $mapping, 'pull');
839 839
 
840 840
 					// hook to allow other plugins to do something right before WordPress data is saved
841 841
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
842
-					do_action( 'object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params );
842
+					do_action('object_sync_for_salesforce_pre_pull', $wordpress_id, $mapping, $object, $object_id, $params);
843 843
 
844
-					if ( isset( $prematch_field_salesforce ) || isset( $key_field_salesforce ) || null !== $wordpress_id ) {
844
+					if (isset($prematch_field_salesforce) || isset($key_field_salesforce) || null !== $wordpress_id) {
845 845
 
846 846
 						$op = 'Upsert';
847 847
 
848 848
 						// if either prematch criteria exists, make the values queryable
849
-						if ( isset( $prematch_field_salesforce ) ) {
849
+						if (isset($prematch_field_salesforce)) {
850 850
 							$upsert_key     = $prematch_field_wordpress;
851 851
 							$upsert_value   = $prematch_value;
852 852
 							$upsert_methods = $prematch_methods;
853
-						} elseif ( isset( $key_field_salesforce ) ) {
853
+						} elseif (isset($key_field_salesforce)) {
854 854
 							$upsert_key     = $key_field_wordpress;
855 855
 							$upsert_value   = $key_value;
856 856
 							$upsert_methods = $key_methods;
857 857
 						}
858 858
 
859
-						if ( null !== $wordpress_id ) {
859
+						if (null !== $wordpress_id) {
860 860
 							$upsert_key     = $object_id;
861 861
 							$upsert_value   = $wordpress_id;
862 862
 							$upsert_methods = array();
@@ -865,13 +865,13 @@  discard block
 block discarded – undo
865 865
 						// with the flag at the end, upsert returns a $wordpress_id only
866 866
 						// we can then check to see if it has a mapping object
867 867
 						// we should only do this if the above hook didn't already set the $wordpress_id
868
-						if ( null === $wordpress_id ) {
869
-							$wordpress_id = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true );
868
+						if (null === $wordpress_id) {
869
+							$wordpress_id = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'], true);
870 870
 						}
871 871
 
872 872
 						// find out if there is a mapping object for this WordPress object already
873 873
 						// don't do it if the WordPress id is 0.
874
-						if ( 0 !== $wordpress_id ) {
874
+						if (0 !== $wordpress_id) {
875 875
 							$mapping_object = $this->mappings->get_object_maps(
876 876
 								array(
877 877
 									'wordpress_id'     => $wordpress_id,
@@ -886,35 +886,35 @@  discard block
 block discarded – undo
886 886
 								)
887 887
 							);
888 888
 
889
-							if ( array() !== $mapping_object_debug ) {
889
+							if (array() !== $mapping_object_debug) {
890 890
 								// create log entry to warn about at least one id of 0
891 891
 								$status = 'error';
892
-								$title  = sprintf( esc_html__( 'Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce' ) );
892
+								$title  = sprintf(esc_html__('Error: There is at least one object map with a WordPress ID of 0.', 'object-sync-for-salesforce'));
893 893
 
894
-								if ( 1 === count( $mapping_object_debug ) ) {
894
+								if (1 === count($mapping_object_debug)) {
895 895
 									// translators: placeholders are: 1) the mapping object row ID, 2) the name of the WordPress object, 3) the ID of the Salesforce object it was trying to map
896
-									$body = sprintf( esc_html__( 'There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce' ),
897
-										absint( $mapping_object_debug['id'] ),
898
-										esc_attr( $salesforce_mapping['wordpress_object'] ),
899
-										esc_attr( $mapping_object_debug['salesforce_id'] )
896
+									$body = sprintf(esc_html__('There is an object map with ID of %1$s and it is mapped to the WordPress %2$s with ID of 0 and the Salesforce object with ID of %3$s', 'object-sync-for-salesforce'),
897
+										absint($mapping_object_debug['id']),
898
+										esc_attr($salesforce_mapping['wordpress_object']),
899
+										esc_attr($mapping_object_debug['salesforce_id'])
900 900
 									);
901 901
 								} else {
902
-									$body = sprintf( esc_html__( 'There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce' ) . '<ul>' );
903
-									foreach ( $mapping_object_debug as $mapping_object ) {
902
+									$body = sprintf(esc_html__('There are multiple object maps with WordPress ID of 0. Their IDs are: ', 'object-sync-for-salesforce') . '<ul>');
903
+									foreach ($mapping_object_debug as $mapping_object) {
904 904
 										// translators: placeholders are: 1) the mapping object row ID, 2) the ID of the Salesforce object, 3) the WordPress object type
905
-										$body .= sprintf( '<li>' . esc_html__( 'Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
906
-											absint( $mapping_object['id'] ),
907
-											esc_attr( $mapping_object['salesforce_id'] ),
908
-											esc_attr( $salesforce_mapping['wordpress_object'] )
905
+										$body .= sprintf('<li>' . esc_html__('Mapping object id: %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce') . '</li>',
906
+											absint($mapping_object['id']),
907
+											esc_attr($mapping_object['salesforce_id']),
908
+											esc_attr($salesforce_mapping['wordpress_object'])
909 909
 										);
910 910
 									}
911
-									$body .= sprintf( '</ul>' );
911
+									$body .= sprintf('</ul>');
912 912
 								}
913 913
 
914
-								if ( isset( $this->logging ) ) {
914
+								if (isset($this->logging)) {
915 915
 									$logging = $this->logging;
916
-								} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
917
-									$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
916
+								} elseif (class_exists('Object_Sync_Sf_Logging')) {
917
+									$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
918 918
 								}
919 919
 								$parent = 0;
920 920
 								$logging->setup(
@@ -928,37 +928,37 @@  discard block
 block discarded – undo
928 928
 						} // End if().
929 929
 
930 930
 						// there is already a mapping object. don't change the WordPress data to match this new Salesforce record, but log it
931
-						if ( isset( $mapping_object['id'] ) ) {
931
+						if (isset($mapping_object['id'])) {
932 932
 							// set the transient so that salesforce_push doesn't start doing stuff, then return out of here
933
-							set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
934
-							set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
933
+							set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
934
+							set_transient('salesforce_pulling_object_id', $mapping_object['id']);
935 935
 							// create log entry to indicate that nothing happened
936 936
 							$status = 'notice';
937 937
 							// translators: placeholders are: 1) mapping object row id, 2) WordPress object tyoe, 3) individual WordPress item ID, 4) individual Salesforce item ID
938
-							$title = sprintf( esc_html__( 'Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce' ),
939
-								absint( $mapping_object['id'] ),
940
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
941
-								absint( $wordpress_id ),
942
-								esc_attr( $object['Id'] )
938
+							$title = sprintf(esc_html__('Notice: Because object map %1$s already exists, WordPress %2$s %3$s was not mapped to Salesforce Id %4$s', 'object-sync-for-salesforce'),
939
+								absint($mapping_object['id']),
940
+								esc_attr($salesforce_mapping['wordpress_object']),
941
+								absint($wordpress_id),
942
+								esc_attr($object['Id'])
943 943
 							);
944 944
 
945 945
 							// translators: placeholders are 1) WordPress object type, 2) field name for the WordPress id, 3) the WordPress id value, 4) the Salesforce object type, 5) the Salesforce object Id that was modified, 6) the mapping object row id
946
-							$body = sprintf( esc_html__( 'The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce' ),
947
-								esc_attr( $salesforce_mapping['wordpress_object'] ),
948
-								esc_attr( $structure['id_field'] ),
949
-								absint( $wordpress_id ),
950
-								esc_attr( $salesforce_mapping['salesforce_object'] ),
951
-								esc_attr( $object['Id'] ),
952
-								absint( $mapping_object['id'] )
946
+							$body = sprintf(esc_html__('The WordPress %1$s with %2$s of %3$s is already mapped to the Salesforce %4$s with Id of %5$s in the mapping object with id of %6$s. The Salesforce %4$s with Id of %5$s was created or modified in Salesforce, and would otherwise have been mapped to this WordPress record. No WordPress data has been changed to prevent changing data unintentionally.', 'object-sync-for-salesforce'),
947
+								esc_attr($salesforce_mapping['wordpress_object']),
948
+								esc_attr($structure['id_field']),
949
+								absint($wordpress_id),
950
+								esc_attr($salesforce_mapping['salesforce_object']),
951
+								esc_attr($object['Id']),
952
+								absint($mapping_object['id'])
953 953
 							);
954 954
 
955
-							if ( isset( $this->logging ) ) {
955
+							if (isset($this->logging)) {
956 956
 								$logging = $this->logging;
957
-							} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
958
-								$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
957
+							} elseif (class_exists('Object_Sync_Sf_Logging')) {
958
+								$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
959 959
 							}
960 960
 							// if we know the WordPress object id we can put it in there
961
-							if ( null !== $wordpress_id ) {
961
+							if (null !== $wordpress_id) {
962 962
 								$parent = $wordpress_id;
963 963
 							} else {
964 964
 								$parent = 0;
@@ -977,9 +977,9 @@  discard block
 block discarded – undo
977 977
 						// right here we should set the pulling transient
978 978
 						// this means we have to create the mapping object here as well, and update it with the correct IDs after successful response
979 979
 						// create the mapping object between the rows
980
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
981
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
982
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
980
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
981
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
982
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
983 983
 						$mapping_object = $this->mappings->get_object_maps(
984 984
 							array(
985 985
 								'id' => $mapping_object_id,
@@ -988,50 +988,50 @@  discard block
 block discarded – undo
988 988
 
989 989
 						// now we can upsert the object in wp if we've gotten to this point
990 990
 						// this command will either create or update the object
991
-						$result = $this->wordpress->object_upsert( $salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts'] );
991
+						$result = $this->wordpress->object_upsert($salesforce_mapping['wordpress_object'], $upsert_key, $upsert_value, $upsert_methods, $params, $salesforce_mapping['push_drafts']);
992 992
 
993 993
 					} else {
994 994
 						// No key or prematch field exists on this field map object, create a new object in WordPress.
995 995
 						$op                = 'Create';
996
-						$mapping_object_id = $this->create_object_map( $object, $this->mappings->generate_temporary_id( 'pull' ), $mapping );
997
-						set_transient( 'salesforce_pulling_' . $mapping_object_id, 1, $seconds );
998
-						set_transient( 'salesforce_pulling_object_id', $mapping_object_id );
996
+						$mapping_object_id = $this->create_object_map($object, $this->mappings->generate_temporary_id('pull'), $mapping);
997
+						set_transient('salesforce_pulling_' . $mapping_object_id, 1, $seconds);
998
+						set_transient('salesforce_pulling_object_id', $mapping_object_id);
999 999
 						$mapping_object = $this->mappings->get_object_maps(
1000 1000
 							array(
1001 1001
 								'id' => $mapping_object_id,
1002 1002
 							)
1003 1003
 						);
1004 1004
 
1005
-						$result = $this->wordpress->object_create( $salesforce_mapping['wordpress_object'], $params );
1005
+						$result = $this->wordpress->object_create($salesforce_mapping['wordpress_object'], $params);
1006 1006
 					} // End if().
1007
-				} catch ( WordpressException $e ) {
1007
+				} catch (WordpressException $e) {
1008 1008
 					// create log entry for failed create or upsert
1009 1009
 					$status = 'error';
1010 1010
 
1011 1011
 					// translators: placeholders are: 1) what operation is happening, and 2) the name of the WordPress object
1012
-					$title = sprintf( esc_html__( 'Error: %1$s %2$s', 'object-sync-for-salesforce' ),
1013
-						esc_attr( $op ),
1014
-						esc_attr( $salesforce_mapping['wordpress_object'] )
1012
+					$title = sprintf(esc_html__('Error: %1$s %2$s', 'object-sync-for-salesforce'),
1013
+						esc_attr($op),
1014
+						esc_attr($salesforce_mapping['wordpress_object'])
1015 1015
 					);
1016 1016
 
1017
-					if ( null !== $salesforce_id ) {
1017
+					if (null !== $salesforce_id) {
1018 1018
 						$title .= ' ' . $salesforce_id;
1019 1019
 					}
1020 1020
 
1021 1021
 					// translators: placeholders are: 1) the name of the Salesforce object, and 2) Id of the Salesforce object
1022
-					$title .= sprintf( esc_html__( ' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce' ),
1022
+					$title .= sprintf(esc_html__(' (Salesforce %1$s with Id of %2$s)', 'object-sync-for-salesforce'),
1023 1023
 						$salesforce_mapping['salesforce_object'],
1024 1024
 						$object['Id']
1025 1025
 					);
1026 1026
 
1027
-					if ( isset( $this->logging ) ) {
1027
+					if (isset($this->logging)) {
1028 1028
 						$logging = $this->logging;
1029
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1030
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1029
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1030
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1031 1031
 					}
1032 1032
 
1033 1033
 					// if we know the WordPress object id we can put it in there
1034
-					if ( null !== $wordpress_id ) {
1034
+					if (null !== $wordpress_id) {
1035 1035
 						$parent = $wordpress_id;
1036 1036
 					} else {
1037 1037
 						$parent = 0;
@@ -1045,26 +1045,26 @@  discard block
 block discarded – undo
1045 1045
 						$status
1046 1046
 					);
1047 1047
 
1048
-					if ( false === $hold_exceptions ) {
1048
+					if (false === $hold_exceptions) {
1049 1049
 						throw $e;
1050 1050
 					}
1051
-					if ( empty( $exception ) ) {
1051
+					if (empty($exception)) {
1052 1052
 						$exception = $e;
1053 1053
 					} else {
1054
-						$my_class  = get_class( $e );
1055
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1054
+						$my_class  = get_class($e);
1055
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1056 1056
 					}
1057 1057
 
1058 1058
 					// hook for pull fail
1059
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1059
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1060 1060
 
1061 1061
 					return;
1062 1062
 				} // End try().
1063 1063
 
1064 1064
 				// set $wordpress_data to the query result
1065 1065
 				$wordpress_data = $result['data'];
1066
-				if ( isset( $wordpress_data[ "$object_id" ] ) ) {
1067
-					$wordpress_id = $wordpress_data[ "$object_id" ];
1066
+				if (isset($wordpress_data["$object_id"])) {
1067
+					$wordpress_id = $wordpress_data["$object_id"];
1068 1068
 				} else {
1069 1069
 					$wordpress_id = 0;
1070 1070
 				}
@@ -1073,23 +1073,23 @@  discard block
 block discarded – undo
1073 1073
 				// this means the object has already been created/updated in WordPress
1074 1074
 				// this is not redundant because this is where it creates the object mapping rows in WordPress if the object does not already have one (we are still inside $is_new === TRUE here)
1075 1075
 
1076
-				if ( empty( $result['errors'] ) ) {
1076
+				if (empty($result['errors'])) {
1077 1077
 					$status = 'success';
1078 1078
 
1079
-					if ( isset( $this->logging ) ) {
1079
+					if (isset($this->logging)) {
1080 1080
 						$logging = $this->logging;
1081
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1082
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1081
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1082
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1083 1083
 					}
1084 1084
 
1085 1085
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1086
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1087
-						esc_attr( $op ),
1088
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1089
-						esc_attr( $object_id ),
1090
-						esc_attr( $wordpress_id ),
1091
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1092
-						esc_attr( $object['Id'] )
1086
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1087
+						esc_attr($op),
1088
+						esc_attr($salesforce_mapping['wordpress_object']),
1089
+						esc_attr($object_id),
1090
+						esc_attr($wordpress_id),
1091
+						esc_attr($salesforce_mapping['salesforce_object']),
1092
+						esc_attr($object['Id'])
1093 1093
 					);
1094 1094
 
1095 1095
 					$logging->setup(
@@ -1102,40 +1102,40 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
 					// update that mapping object
1104 1104
 					$mapping_object['wordpress_id'] = $wordpress_id;
1105
-					$mapping_object                 = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1105
+					$mapping_object                 = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1106 1106
 
1107 1107
 					// hook for pull success
1108
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1108
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1109 1109
 				} else {
1110 1110
 
1111 1111
 					// create log entry for failed create or upsert
1112 1112
 					// this is part of the drupal module but i am failing to understand when it would ever fire, since the catch should catch the errors
1113 1113
 					// if we see this in the log entries, we can understand what it does, but probably not until then
1114 1114
 					$status = 'error';
1115
-					if ( isset( $this->logging ) ) {
1115
+					if (isset($this->logging)) {
1116 1116
 						$logging = $this->logging;
1117
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1118
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1117
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1118
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1119 1119
 					}
1120 1120
 
1121
-					if ( is_object( $wordpress_id ) ) {
1121
+					if (is_object($wordpress_id)) {
1122 1122
 						// print this array because if this happens, something weird has happened and we want to log whatever we have
1123
-						$wordpress_id = print_r( $wordpress_id, true );
1123
+						$wordpress_id = print_r($wordpress_id, true);
1124 1124
 					}
1125 1125
 
1126 1126
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object type, 3) the Salesforce object Id value
1127
-					$title = sprintf( esc_html__( 'Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce' ),
1128
-						esc_attr( $op ),
1129
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1130
-						esc_attr( $object['Id'] )
1127
+					$title = sprintf(esc_html__('Error syncing: %1$s to WordPress (Salesforce %2$s Id %3$s)', 'object-sync-for-salesforce'),
1128
+						esc_attr($op),
1129
+						esc_attr($salesforce_mapping['salesforce_object']),
1130
+						esc_attr($object['Id'])
1131 1131
 					);
1132 1132
 
1133 1133
 					// translators: placeholders are: 1) the name of the WordPress object type, 2) the WordPress id field name, 3) the WordPress id field value, 4) the array of errors
1134
-					$body = sprintf( '<p>' . esc_html__( 'Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: ', 'object-sync-for-salesforce' ) . '%4$s',
1135
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1136
-						esc_attr( $object_id ),
1137
-						esc_attr( $wordpress_id ),
1138
-						print_r( $result['errors'], true ) // if we get this error, we need to know whatever we have
1134
+					$body = sprintf('<p>' . esc_html__('Object: %1$s with %2$s of %3$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: ', 'object-sync-for-salesforce') . '%4$s',
1135
+						esc_attr($salesforce_mapping['wordpress_object']),
1136
+						esc_attr($object_id),
1137
+						esc_attr($wordpress_id),
1138
+						print_r($result['errors'], true) // if we get this error, we need to know whatever we have
1139 1139
 					);
1140 1140
 
1141 1141
 					$logging->setup(
@@ -1147,52 +1147,52 @@  discard block
 block discarded – undo
1147 1147
 					);
1148 1148
 
1149 1149
 					// hook for pull fail
1150
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1150
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1151 1151
 
1152 1152
 					return;
1153 1153
 				} // End if().
1154
-			} elseif ( false === $is_new ) {
1154
+			} elseif (false === $is_new) {
1155 1155
 
1156 1156
 				// right here we should set the pulling transient
1157
-				set_transient( 'salesforce_pulling_' . $mapping_object['id'], 1, $seconds );
1158
-				set_transient( 'salesforce_pulling_object_id', $mapping_object['id'] );
1157
+				set_transient('salesforce_pulling_' . $mapping_object['id'], 1, $seconds);
1158
+				set_transient('salesforce_pulling_object_id', $mapping_object['id']);
1159 1159
 
1160 1160
 				// there is an existing object link
1161 1161
 				// if the last sync is greater than the last time this object was updated by Salesforce, skip it
1162 1162
 				// this keeps us from doing redundant syncs
1163 1163
 				// because SF stores all DateTimes in UTC.
1164
-				$mapping_object['object_updated'] = current_time( 'mysql' );
1164
+				$mapping_object['object_updated'] = current_time('mysql');
1165 1165
 
1166 1166
 				$pull_trigger_field = $salesforce_mapping['pull_trigger_field'];
1167
-				$pull_trigger_value = $object[ $pull_trigger_field ];
1167
+				$pull_trigger_value = $object[$pull_trigger_field];
1168 1168
 
1169 1169
 				try {
1170 1170
 
1171 1171
 					// hook to allow other plugins to do something right before WordPress data is saved
1172 1172
 					// ex: run outside methods on an object if it exists, or do something in preparation for it if it doesn't
1173
-					do_action( 'object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params );
1173
+					do_action('object_sync_for_salesforce_pre_pull', $mapping_object['wordpress_id'], $mapping, $object, $object_id, $params);
1174 1174
 
1175 1175
 					$op     = 'Update';
1176
-					$result = $this->wordpress->object_update( $salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params );
1176
+					$result = $this->wordpress->object_update($salesforce_mapping['wordpress_object'], $mapping_object['wordpress_id'], $params);
1177 1177
 
1178 1178
 					$mapping_object['last_sync_status']  = $this->mappings->status_success;
1179
-					$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
1179
+					$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
1180 1180
 
1181 1181
 					$status = 'success';
1182
-					if ( isset( $this->logging ) ) {
1182
+					if (isset($this->logging)) {
1183 1183
 						$logging = $this->logging;
1184
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1185
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1184
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1185
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1186 1186
 					}
1187 1187
 
1188 1188
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1189
-					$title = sprintf( esc_html__( 'Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce' ),
1190
-						esc_attr( $op ),
1191
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1192
-						esc_attr( $object_id ),
1193
-						esc_attr( $mapping_object['wordpress_id'] ),
1194
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1195
-						esc_attr( $object['Id'] )
1189
+					$title = sprintf(esc_html__('Success: %1$s %2$s with %3$s of %4$s (Salesforce %5$s Id of %6$s)', 'object-sync-for-salesforce'),
1190
+						esc_attr($op),
1191
+						esc_attr($salesforce_mapping['wordpress_object']),
1192
+						esc_attr($object_id),
1193
+						esc_attr($mapping_object['wordpress_id']),
1194
+						esc_attr($salesforce_mapping['salesforce_object']),
1195
+						esc_attr($object['Id'])
1196 1196
 					);
1197 1197
 
1198 1198
 					$logging->setup(
@@ -1204,25 +1204,25 @@  discard block
 block discarded – undo
1204 1204
 					);
1205 1205
 
1206 1206
 					// hook for pull success
1207
-					do_action( 'object_sync_for_salesforce_pull_success', $op, $result, $synced_object );
1207
+					do_action('object_sync_for_salesforce_pull_success', $op, $result, $synced_object);
1208 1208
 
1209
-				} catch ( WordpressException $e ) {
1209
+				} catch (WordpressException $e) {
1210 1210
 					// create log entry for failed update
1211 1211
 					$status = 'error';
1212
-					if ( isset( $this->logging ) ) {
1212
+					if (isset($this->logging)) {
1213 1213
 						$logging = $this->logging;
1214
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
1215
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
1214
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
1215
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
1216 1216
 					}
1217 1217
 
1218 1218
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object, 3) the WordPress id field name, 4) the WordPress object id value, 5) the name of the Salesforce object, 6) the Salesforce Id value
1219
-					$title .= sprintf( esc_html__( 'Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce' ),
1220
-						esc_attr( $op ),
1221
-						esc_attr( $salesforce_mapping['wordpress_object'] ),
1222
-						esc_attr( $object_id ),
1223
-						esc_attr( $mapping_object['wordpress_id'] ),
1224
-						esc_attr( $salesforce_mapping['salesforce_object'] ),
1225
-						esc_attr( $object['Id'] )
1219
+					$title .= sprintf(esc_html__('Error: %1$s %2$s with %3$s of %4$s (Salesforce %5$s with Id of %6$s)', 'object-sync-for-salesforce'),
1220
+						esc_attr($op),
1221
+						esc_attr($salesforce_mapping['wordpress_object']),
1222
+						esc_attr($object_id),
1223
+						esc_attr($mapping_object['wordpress_id']),
1224
+						esc_attr($salesforce_mapping['salesforce_object']),
1225
+						esc_attr($object['Id'])
1226 1226
 					);
1227 1227
 
1228 1228
 					$logging->setup(
@@ -1236,18 +1236,18 @@  discard block
 block discarded – undo
1236 1236
 					$mapping_object['last_sync_status']  = $this->mappings->status_error;
1237 1237
 					$mapping_object['last_sync_message'] = $e->getMessage();
1238 1238
 
1239
-					if ( false === $hold_exceptions ) {
1239
+					if (false === $hold_exceptions) {
1240 1240
 						throw $e;
1241 1241
 					}
1242
-					if ( empty( $exception ) ) {
1242
+					if (empty($exception)) {
1243 1243
 						$exception = $e;
1244 1244
 					} else {
1245
-						$my_class  = get_class( $e );
1246
-						$exception = new $my_class( $e->getMessage(), $e->getCode(), $exception );
1245
+						$my_class  = get_class($e);
1246
+						$exception = new $my_class($e->getMessage(), $e->getCode(), $exception);
1247 1247
 					}
1248 1248
 
1249 1249
 					// hook for pull fail
1250
-					do_action( 'object_sync_for_salesforce_pull_fail', $op, $result, $synced_object );
1250
+					do_action('object_sync_for_salesforce_pull_fail', $op, $result, $synced_object);
1251 1251
 
1252 1252
 				} // End try().
1253 1253
 
@@ -1256,26 +1256,26 @@  discard block
 block discarded – undo
1256 1256
 				// maybe can check to see if we actually updated anything in WordPress
1257 1257
 				// tell the mapping object - whether it is new or already existed - how we just used it
1258 1258
 				$mapping_object['last_sync_action'] = 'pull';
1259
-				$mapping_object['last_sync']        = current_time( 'mysql' );
1259
+				$mapping_object['last_sync']        = current_time('mysql');
1260 1260
 
1261 1261
 				// update that mapping object. the Salesforce data version will be set here as well because we set it earlier
1262
-				$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1262
+				$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1263 1263
 				// end of the if statement for is_new & update or create trigger
1264 1264
 				// this keeps stuff from running too many times, and also keeps it from using the wrong methods. we don't need a generic } else { here at this time.
1265 1265
 			} // End if().
1266 1266
 		} // End foreach().
1267 1267
 
1268 1268
 		// delete transients that we've already processed
1269
-		foreach ( $transients_to_delete as $mapping_object_id_transient ) {
1270
-			delete_transient( 'salesforce_pushing_' . $mapping_object_id_transient );
1269
+		foreach ($transients_to_delete as $mapping_object_id_transient) {
1270
+			delete_transient('salesforce_pushing_' . $mapping_object_id_transient);
1271 1271
 		}
1272 1272
 
1273
-		$pushing_id = get_transient( 'salesforce_pushing_object_id' );
1274
-		if ( in_array( $pushing_id, $transients_to_delete, true ) ) {
1275
-			delete_transient( 'salesforce_pushing_object_id' );
1273
+		$pushing_id = get_transient('salesforce_pushing_object_id');
1274
+		if (in_array($pushing_id, $transients_to_delete, true)) {
1275
+			delete_transient('salesforce_pushing_object_id');
1276 1276
 		}
1277 1277
 
1278
-		if ( ! empty( $exception ) ) {
1278
+		if ( ! empty($exception)) {
1279 1279
 			throw $exception;
1280 1280
 		}
1281 1281
 
@@ -1295,17 +1295,17 @@  discard block
 block discarded – undo
1295 1295
 	*   This is the database row for the map object
1296 1296
 	*
1297 1297
 	*/
1298
-	private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) {
1298
+	private function create_object_map($salesforce_object, $wordpress_id, $field_mapping) {
1299 1299
 		// Create object map and save it
1300 1300
 		$mapping_object = $this->mappings->create_object_map(
1301 1301
 			array(
1302 1302
 				'wordpress_id'      => $wordpress_id, // wordpress unique id
1303 1303
 				'salesforce_id'     => $salesforce_object['Id'], // salesforce unique id. we don't care what kind of object it is at this point
1304 1304
 				'wordpress_object'  => $field_mapping['wordpress_object'], // keep track of what kind of wp object this is
1305
-				'last_sync'         => current_time( 'mysql' ),
1305
+				'last_sync'         => current_time('mysql'),
1306 1306
 				'last_sync_action'  => 'pull',
1307 1307
 				'last_sync_status'  => $this->mappings->status_success,
1308
-				'last_sync_message' => esc_html__( 'Mapping object created via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1308
+				'last_sync_message' => esc_html__('Mapping object created via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1309 1309
 				'action'            => 'created',
1310 1310
 			)
1311 1311
 		);
Please login to merge, or discard this patch.
classes/salesforce_push.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
 	protected $schedulable_classes;
25 25
 
26 26
 	/**
27
-	* @var string
28
-	*/
27
+	 * @var string
28
+	 */
29 29
 	public $schedule_name; // allow for naming the queue in case there are multiple queues
30 30
 
31 31
 	/**
32
-	* Constructor which sets up push schedule
33
-	*
34
-	* @param object $wpdb
35
-	* @param string $version
36
-	* @param array $login_credentials
37
-	* @param string $slug
38
-	* @param object $wordpress
39
-	* @param object $salesforce
40
-	* @param object $mappings
41
-	* @param object $logging
42
-	* @param array $schedulable_classes
43
-	* @throws \Object_Sync_Sf_Exception
44
-	*/
32
+	 * Constructor which sets up push schedule
33
+	 *
34
+	 * @param object $wpdb
35
+	 * @param string $version
36
+	 * @param array $login_credentials
37
+	 * @param string $slug
38
+	 * @param object $wordpress
39
+	 * @param object $salesforce
40
+	 * @param object $mappings
41
+	 * @param object $logging
42
+	 * @param array $schedulable_classes
43
+	 * @throws \Object_Sync_Sf_Exception
44
+	 */
45 45
 	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
46 46
 		$this->wpdb                = $wpdb;
47 47
 		$this->version             = $version;
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	}
63 63
 
64 64
 	/**
65
-	* Create the action hooks based on what object maps exist from the admin settings.
66
-	* We do not have any actions for blogroll at this time.
67
-	*
68
-	*/
65
+	 * Create the action hooks based on what object maps exist from the admin settings.
66
+	 * We do not have any actions for blogroll at this time.
67
+	 *
68
+	 */
69 69
 	private function add_actions() {
70 70
 		$db_version = get_option( 'object_sync_for_salesforce_db_version', false );
71 71
 		if ( $db_version === $this->version ) {
@@ -97,54 +97,54 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	/**
100
-	* Method for ajax hooks to call for pushing manually
101
-	*
102
-	* @param array $object
103
-	* @param string $type
104
-	*
105
-	*/
100
+	 * Method for ajax hooks to call for pushing manually
101
+	 *
102
+	 * @param array $object
103
+	 * @param string $type
104
+	 *
105
+	 */
106 106
 	public function manual_object_update( $object, $type ) {
107 107
 		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update, true );
108 108
 	}
109 109
 
110 110
 	/**
111
-	* Callback method for adding a user
112
-	*
113
-	* @param string $user_id
114
-	*/
111
+	 * Callback method for adding a user
112
+	 *
113
+	 * @param string $user_id
114
+	 */
115 115
 	public function add_user( $user_id ) {
116 116
 		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
117 117
 		$this->object_insert( $user, 'user' );
118 118
 	}
119 119
 
120 120
 	/**
121
-	* Callback method for editing a user
122
-	*
123
-	* @param string $user_id
124
-	* @param object $old_user_data
125
-	*/
121
+	 * Callback method for editing a user
122
+	 *
123
+	 * @param string $user_id
124
+	 * @param object $old_user_data
125
+	 */
126 126
 	public function edit_user( $user_id, $old_user_data ) {
127 127
 		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
128 128
 		$this->object_update( $user, 'user' );
129 129
 	}
130 130
 
131 131
 	/**
132
-	* Callback method for deleting a user
133
-	*
134
-	* @param string $user_id
135
-	*/
132
+	 * Callback method for deleting a user
133
+	 *
134
+	 * @param string $user_id
135
+	 */
136 136
 	public function delete_user( $user_id ) {
137 137
 		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
138 138
 		$this->object_delete( $user, 'user' );
139 139
 	}
140 140
 
141 141
 	/**
142
-	* Callback method for posts of any type
143
-	* This can handle create, update, and delete actions
144
-	*
145
-	* @param string $post_id
146
-	* @param object $post
147
-	*/
142
+	 * Callback method for posts of any type
143
+	 * This can handle create, update, and delete actions
144
+	 *
145
+	 * @param string $post_id
146
+	 * @param object $post
147
+	 */
148 148
 	public function post_actions( $post_id, $post ) {
149 149
 
150 150
 		$post_type = $post->post_type;
@@ -191,66 +191,66 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	/**
194
-	* Callback method for adding an attachment
195
-	*
196
-	* @param string $post_id
197
-	*/
194
+	 * Callback method for adding an attachment
195
+	 *
196
+	 * @param string $post_id
197
+	 */
198 198
 	public function add_attachment( $post_id ) {
199 199
 		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
200 200
 		$this->object_insert( $attachment, 'attachment' );
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Callback method for editing an attachment
205
-	*
206
-	* @param string $post_id
207
-	*/
204
+	 * Callback method for editing an attachment
205
+	 *
206
+	 * @param string $post_id
207
+	 */
208 208
 	public function edit_attachment( $post_id ) {
209 209
 		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
210 210
 		$this->object_update( $attachment, 'attachment' );
211 211
 	}
212 212
 
213 213
 	/**
214
-	* Callback method for editing an attachment
215
-	*
216
-	* @param string $post_id
217
-	*/
214
+	 * Callback method for editing an attachment
215
+	 *
216
+	 * @param string $post_id
217
+	 */
218 218
 	public function delete_attachment( $post_id ) {
219 219
 		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
220 220
 		$this->object_delete( $attachment, 'attachment' );
221 221
 	}
222 222
 
223 223
 	/**
224
-	* Callback method for adding a term
225
-	*
226
-	* @param string $term_id
227
-	* @param string $tt_id
228
-	* @param string $taxonomy
229
-	*/
224
+	 * Callback method for adding a term
225
+	 *
226
+	 * @param string $term_id
227
+	 * @param string $tt_id
228
+	 * @param string $taxonomy
229
+	 */
230 230
 	public function add_term( $term_id, $tt_id, $taxonomy ) {
231 231
 		$term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id );
232 232
 		$this->object_insert( $term, $taxonomy );
233 233
 	}
234 234
 
235 235
 	/**
236
-	* Callback method for editing a term
237
-	*
238
-	* @param string $term_id
239
-	* @param string $taxonomy
240
-	*/
236
+	 * Callback method for editing a term
237
+	 *
238
+	 * @param string $term_id
239
+	 * @param string $taxonomy
240
+	 */
241 241
 	public function edit_term( $term_id, $taxonomy ) {
242 242
 		$term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id );
243 243
 		$this->object_update( $term, $taxonomy );
244 244
 	}
245 245
 
246 246
 	/**
247
-	* Callback method for deleting a term
248
-	*
249
-	* @param int $term (id)
250
-	* @param int $term_taxonomy_id
251
-	* @param string $taxonomy (slug)
252
-	* @param object $deleted_term
253
-	*/
247
+	 * Callback method for deleting a term
248
+	 *
249
+	 * @param int $term (id)
250
+	 * @param int $term_taxonomy_id
251
+	 * @param string $taxonomy (slug)
252
+	 * @param object $deleted_term
253
+	 */
254 254
 	public function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) {
255 255
 		$deleted_term = (array) $deleted_term;
256 256
 		$type         = $deleted_term['taxonomy'];
@@ -258,75 +258,75 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Callback method for adding a comment
262
-	*
263
-	* @param string $comment_id
264
-	* @param int|string comment_approved
265
-	* @param array $commentdata
266
-	*/
261
+	 * Callback method for adding a comment
262
+	 *
263
+	 * @param string $comment_id
264
+	 * @param int|string comment_approved
265
+	 * @param array $commentdata
266
+	 */
267 267
 	public function add_comment( $comment_id, $comment_approved, $commentdata = array() ) {
268 268
 		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
269 269
 		$this->object_insert( $comment, 'comment' );
270 270
 	}
271 271
 
272 272
 	/**
273
-	* Callback method for editing a comment
274
-	*
275
-	* @param string $comment_id
276
-	*/
273
+	 * Callback method for editing a comment
274
+	 *
275
+	 * @param string $comment_id
276
+	 */
277 277
 	public function edit_comment( $comment_id ) {
278 278
 		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
279 279
 		$this->object_update( $comment, 'comment' );
280 280
 	}
281 281
 
282 282
 	/**
283
-	* Callback method for deleting a comment
284
-	*
285
-	* @param string $comment_id
286
-	*/
283
+	 * Callback method for deleting a comment
284
+	 *
285
+	 * @param string $comment_id
286
+	 */
287 287
 	public function delete_comment( $comment_id ) {
288 288
 		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
289 289
 		$this->object_delete( $comment, 'comment' );
290 290
 	}
291 291
 
292 292
 	/**
293
-	* Insert a new object
294
-	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
295
-	*/
293
+	 * Insert a new object
294
+	 * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
295
+	 */
296 296
 	private function object_insert( $object, $type ) {
297 297
 		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_create );
298 298
 	}
299 299
 
300 300
 	/**
301
-	* Update an existing object
302
-	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
303
-	*/
301
+	 * Update an existing object
302
+	 * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
303
+	 */
304 304
 	private function object_update( $object, $type ) {
305 305
 		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update );
306 306
 	}
307 307
 
308 308
 	/**
309
-	* Delete an existing object
310
-	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
311
-	*/
309
+	 * Delete an existing object
310
+	 * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
311
+	 */
312 312
 	private function object_delete( $object, $type ) {
313 313
 		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_delete );
314 314
 	}
315 315
 
316 316
 	/**
317
-	* Push objects to Salesforce.
318
-	* This method decides whether to do the processing immediately or queue it to the schedule class (or skip it based on another plugin's activity)
319
-	*
320
-	* @param string $object_type
321
-	*   Type of WordPress object.
322
-	* @param array $object
323
-	*   The WordPress data that needs to be sent to Salesforce.
324
-	* @param int $sf_sync_trigger
325
-	*   The trigger being responded to.
326
-	* @param bool $manual
327
-	*   Are we calling this manually?
328
-	*
329
-	*/
317
+	 * Push objects to Salesforce.
318
+	 * This method decides whether to do the processing immediately or queue it to the schedule class (or skip it based on another plugin's activity)
319
+	 *
320
+	 * @param string $object_type
321
+	 *   Type of WordPress object.
322
+	 * @param array $object
323
+	 *   The WordPress data that needs to be sent to Salesforce.
324
+	 * @param int $sf_sync_trigger
325
+	 *   The trigger being responded to.
326
+	 * @param bool $manual
327
+	 *   Are we calling this manually?
328
+	 *
329
+	 */
330 330
 	private function salesforce_push_object_crud( $object_type, $object, $sf_sync_trigger, $manual = false ) {
331 331
 
332 332
 		$structure       = $this->wordpress->get_wordpress_table_structure( $object_type );
@@ -451,20 +451,20 @@  discard block
 block discarded – undo
451 451
 	}
452 452
 
453 453
 	/**
454
-	* Sync WordPress objects and Salesforce objects using the REST API.
455
-	*
456
-	* @param string $object_type
457
-	*   Type of WordPress object.
458
-	* @param object $object
459
-	*   The object object.
460
-	* @param object $mapping
461
-	*   Salesforce mapping object.
462
-	* @param int $sf_sync_trigger
463
-	*   Trigger for this sync.
464
-	*
465
-	* @return true or exit the method
466
-	*
467
-	*/
454
+	 * Sync WordPress objects and Salesforce objects using the REST API.
455
+	 *
456
+	 * @param string $object_type
457
+	 *   Type of WordPress object.
458
+	 * @param object $object
459
+	 *   The object object.
460
+	 * @param object $mapping
461
+	 *   Salesforce mapping object.
462
+	 * @param int $sf_sync_trigger
463
+	 *   Trigger for this sync.
464
+	 *
465
+	 * @return true or exit the method
466
+	 *
467
+	 */
468 468
 	public function salesforce_push_sync_rest( $object_type, $object, $mapping, $sf_sync_trigger ) {
469 469
 
470 470
 		// If Salesforce is not authorized, don't do anything.
@@ -1006,21 +1006,21 @@  discard block
 block discarded – undo
1006 1006
 	}
1007 1007
 
1008 1008
 	/**
1009
-	* Create an object map between a WordPress object and a Salesforce object
1010
-	*
1011
-	* @param array $wordpress_object
1012
-	*   Array of the WordPress object's data
1013
-	* @param string $id_field_name
1014
-	*   How this object names its primary field. ie Id or comment_id or whatever
1015
-	* @param string $salesforce_id
1016
-	*   Unique identifier for the Salesforce object
1017
-	* @param array $field_mapping
1018
-	*   The row that maps the object types together, including which fields match which other fields
1019
-	*
1020
-	* @return int $wpdb->insert_id
1021
-	*   This is the database row for the map object
1022
-	*
1023
-	*/
1009
+	 * Create an object map between a WordPress object and a Salesforce object
1010
+	 *
1011
+	 * @param array $wordpress_object
1012
+	 *   Array of the WordPress object's data
1013
+	 * @param string $id_field_name
1014
+	 *   How this object names its primary field. ie Id or comment_id or whatever
1015
+	 * @param string $salesforce_id
1016
+	 *   Unique identifier for the Salesforce object
1017
+	 * @param array $field_mapping
1018
+	 *   The row that maps the object types together, including which fields match which other fields
1019
+	 *
1020
+	 * @return int $wpdb->insert_id
1021
+	 *   This is the database row for the map object
1022
+	 *
1023
+	 */
1024 1024
 	private function create_object_map( $wordpress_object, $id_field_name, $salesforce_id, $field_mapping, $pending = false ) {
1025 1025
 
1026 1026
 		if ( true === $pending ) {
Please login to merge, or discard this patch.
Spacing   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	* @param array $schedulable_classes
43 43
 	* @throws \Object_Sync_Sf_Exception
44 44
 	*/
45
-	public function __construct( $wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes ) {
45
+	public function __construct($wpdb, $version, $login_credentials, $slug, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes) {
46 46
 		$this->wpdb                = $wpdb;
47 47
 		$this->version             = $version;
48 48
 		$this->login_credentials   = $login_credentials;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		$this->schedule      = $this->schedule();
58 58
 		$this->add_actions();
59 59
 
60
-		$this->debug = get_option( 'object_sync_for_salesforce_debug_mode', false );
60
+		$this->debug = get_option('object_sync_for_salesforce_debug_mode', false);
61 61
 
62 62
 	}
63 63
 
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
 	*
68 68
 	*/
69 69
 	private function add_actions() {
70
-		$db_version = get_option( 'object_sync_for_salesforce_db_version', false );
71
-		if ( $db_version === $this->version ) {
72
-			foreach ( $this->mappings->get_fieldmaps() as $mapping ) {
70
+		$db_version = get_option('object_sync_for_salesforce_db_version', false);
71
+		if ($db_version === $this->version) {
72
+			foreach ($this->mappings->get_fieldmaps() as $mapping) {
73 73
 				$object_type = $mapping['wordpress_object'];
74
-				if ( 'user' === $object_type ) {
75
-					add_action( 'user_register', array( $this, 'add_user' ), 11, 1 );
76
-					add_action( 'profile_update', array( $this, 'edit_user' ), 11, 2 );
77
-					add_action( 'delete_user', array( $this, 'delete_user' ) );
78
-				} elseif ( 'post' === $object_type ) {
79
-					add_action( 'save_post', array( $this, 'post_actions' ), 11, 2 );
80
-				} elseif ( 'attachment' === $object_type ) {
81
-					add_action( 'add_attachment', array( $this, 'add_attachment' ) );
82
-					add_action( 'edit_attachment', array( $this, 'edit_attachment' ) );
83
-					add_action( 'delete_attachment', array( $this, 'delete_attachment' ) );
84
-				} elseif ( 'category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type ) {
85
-					add_action( 'create_term', array( $this, 'add_term' ), 11, 3 );
86
-					add_action( 'edit_terms', array( $this, 'edit_term' ), 11, 2 );
87
-					add_action( 'delete_term', array( $this, 'delete_term' ), 10, 4 );
88
-				} elseif ( 'comment' === $object_type ) {
89
-					add_action( 'comment_post', array( $this, 'add_comment' ), 11, 3 );
90
-					add_action( 'edit_comment', array( $this, 'edit_comment' ) );
91
-					add_action( 'delete_comment', array( $this, 'delete_comment' ) ); // to be clear: this only runs when the comment gets deleted from the trash, either manually or automatically
74
+				if ('user' === $object_type) {
75
+					add_action('user_register', array($this, 'add_user'), 11, 1);
76
+					add_action('profile_update', array($this, 'edit_user'), 11, 2);
77
+					add_action('delete_user', array($this, 'delete_user'));
78
+				} elseif ('post' === $object_type) {
79
+					add_action('save_post', array($this, 'post_actions'), 11, 2);
80
+				} elseif ('attachment' === $object_type) {
81
+					add_action('add_attachment', array($this, 'add_attachment'));
82
+					add_action('edit_attachment', array($this, 'edit_attachment'));
83
+					add_action('delete_attachment', array($this, 'delete_attachment'));
84
+				} elseif ('category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type) {
85
+					add_action('create_term', array($this, 'add_term'), 11, 3);
86
+					add_action('edit_terms', array($this, 'edit_term'), 11, 2);
87
+					add_action('delete_term', array($this, 'delete_term'), 10, 4);
88
+				} elseif ('comment' === $object_type) {
89
+					add_action('comment_post', array($this, 'add_comment'), 11, 3);
90
+					add_action('edit_comment', array($this, 'edit_comment'));
91
+					add_action('delete_comment', array($this, 'delete_comment')); // to be clear: this only runs when the comment gets deleted from the trash, either manually or automatically
92 92
 				} else { // this is for custom post types
93 93
 					// we still have to use save_post because save_post_type fails to pull in the metadata
94
-					add_action( 'save_post', array( $this, 'post_actions' ), 11, 2 );
94
+					add_action('save_post', array($this, 'post_actions'), 11, 2);
95 95
 				}
96 96
 			}
97 97
 		}
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	* @param string $type
105 105
 	*
106 106
 	*/
107
-	public function manual_object_update( $object, $type ) {
108
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update, true );
107
+	public function manual_object_update($object, $type) {
108
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_update, true);
109 109
 	}
110 110
 
111 111
 	/**
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	*
114 114
 	* @param string $user_id
115 115
 	*/
116
-	public function add_user( $user_id ) {
117
-		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
118
-		$this->object_insert( $user, 'user' );
116
+	public function add_user($user_id) {
117
+		$user = $this->wordpress->get_wordpress_object_data('user', $user_id);
118
+		$this->object_insert($user, 'user');
119 119
 	}
120 120
 
121 121
 	/**
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 	* @param string $user_id
125 125
 	* @param object $old_user_data
126 126
 	*/
127
-	public function edit_user( $user_id, $old_user_data ) {
128
-		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
129
-		$this->object_update( $user, 'user' );
127
+	public function edit_user($user_id, $old_user_data) {
128
+		$user = $this->wordpress->get_wordpress_object_data('user', $user_id);
129
+		$this->object_update($user, 'user');
130 130
 	}
131 131
 
132 132
 	/**
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	*
135 135
 	* @param string $user_id
136 136
 	*/
137
-	public function delete_user( $user_id ) {
138
-		$user = $this->wordpress->get_wordpress_object_data( 'user', $user_id );
139
-		$this->object_delete( $user, 'user' );
137
+	public function delete_user($user_id) {
138
+		$user = $this->wordpress->get_wordpress_object_data('user', $user_id);
139
+		$this->object_delete($user, 'user');
140 140
 	}
141 141
 
142 142
 	/**
@@ -146,48 +146,48 @@  discard block
 block discarded – undo
146 146
 	* @param string $post_id
147 147
 	* @param object $post
148 148
 	*/
149
-	public function post_actions( $post_id, $post ) {
149
+	public function post_actions($post_id, $post) {
150 150
 
151 151
 		$post_type = $post->post_type;
152 152
 
153
-		if ( isset( $post->post_status ) && 'auto-draft' === $post->post_status ) {
153
+		if (isset($post->post_status) && 'auto-draft' === $post->post_status) {
154 154
 			return;
155 155
 		}
156 156
 		// this plugin does not sync log or revision posts with salesforce
157
-		if ( isset( $post->post_type ) && in_array( $post->post_type, array( 'wp_log', 'revision' ), true ) ) {
157
+		if (isset($post->post_type) && in_array($post->post_type, array('wp_log', 'revision'), true)) {
158 158
 			return;
159 159
 		}
160
-		if ( $post->post_modified_gmt === $post->post_date_gmt && 'trash' !== $post->post_status ) {
160
+		if ($post->post_modified_gmt === $post->post_date_gmt && 'trash' !== $post->post_status) {
161 161
 			$update = 0;
162 162
 			$delete = 0;
163
-		} elseif ( 'trash' !== $post->post_status ) {
163
+		} elseif ('trash' !== $post->post_status) {
164 164
 			$update = 1;
165 165
 			$delete = 0;
166
-		} elseif ( 'trash' === $post->post_status ) {
166
+		} elseif ('trash' === $post->post_status) {
167 167
 			$update = 0;
168 168
 			$delete = 1;
169 169
 		}
170 170
 
171 171
 		// add support for woocommerce if it is installed
172
-		if ( defined( 'WC_VERSION' ) ) {
172
+		if (defined('WC_VERSION')) {
173 173
 			// statuses to ignore
174
-			if ( isset( $post->post_status ) && in_array( $post->post_status, array( 'wc-pending' ), true ) ) {
174
+			if (isset($post->post_status) && in_array($post->post_status, array('wc-pending'), true)) {
175 175
 				return;
176 176
 			}
177 177
 			// statuses to count as new. note that the api will also check to see if it already has been mapped before saving.
178
-			if ( isset( $post->post_status ) && in_array( $post->post_status, array( 'wc-on-hold', 'wc-processing' ), true ) ) {
178
+			if (isset($post->post_status) && in_array($post->post_status, array('wc-on-hold', 'wc-processing'), true)) {
179 179
 				$update = 0;
180 180
 				$delete = 0;
181 181
 			}
182 182
 		}
183 183
 
184
-		$post = $this->wordpress->get_wordpress_object_data( $post->post_type, $post_id );
185
-		if ( 1 === $update ) {
186
-			$this->object_update( $post, $post_type );
187
-		} elseif ( 1 === $delete ) {
188
-			$this->object_delete( $post, $post_type );
184
+		$post = $this->wordpress->get_wordpress_object_data($post->post_type, $post_id);
185
+		if (1 === $update) {
186
+			$this->object_update($post, $post_type);
187
+		} elseif (1 === $delete) {
188
+			$this->object_delete($post, $post_type);
189 189
 		} else {
190
-			$this->object_insert( $post, $post_type );
190
+			$this->object_insert($post, $post_type);
191 191
 		}
192 192
 	}
193 193
 
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	*
197 197
 	* @param string $post_id
198 198
 	*/
199
-	public function add_attachment( $post_id ) {
200
-		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
201
-		$this->object_insert( $attachment, 'attachment' );
199
+	public function add_attachment($post_id) {
200
+		$attachment = $this->wordpress->get_wordpress_object_data('attachment', $post_id);
201
+		$this->object_insert($attachment, 'attachment');
202 202
 	}
203 203
 
204 204
 	/**
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	*
207 207
 	* @param string $post_id
208 208
 	*/
209
-	public function edit_attachment( $post_id ) {
210
-		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
211
-		$this->object_update( $attachment, 'attachment' );
209
+	public function edit_attachment($post_id) {
210
+		$attachment = $this->wordpress->get_wordpress_object_data('attachment', $post_id);
211
+		$this->object_update($attachment, 'attachment');
212 212
 	}
213 213
 
214 214
 	/**
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 	*
217 217
 	* @param string $post_id
218 218
 	*/
219
-	public function delete_attachment( $post_id ) {
220
-		$attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id );
221
-		$this->object_delete( $attachment, 'attachment' );
219
+	public function delete_attachment($post_id) {
220
+		$attachment = $this->wordpress->get_wordpress_object_data('attachment', $post_id);
221
+		$this->object_delete($attachment, 'attachment');
222 222
 	}
223 223
 
224 224
 	/**
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	* @param string $tt_id
229 229
 	* @param string $taxonomy
230 230
 	*/
231
-	public function add_term( $term_id, $tt_id, $taxonomy ) {
232
-		$term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id );
233
-		$this->object_insert( $term, $taxonomy );
231
+	public function add_term($term_id, $tt_id, $taxonomy) {
232
+		$term = $this->wordpress->get_wordpress_object_data($taxonomy, $term_id);
233
+		$this->object_insert($term, $taxonomy);
234 234
 	}
235 235
 
236 236
 	/**
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 	* @param string $term_id
240 240
 	* @param string $taxonomy
241 241
 	*/
242
-	public function edit_term( $term_id, $taxonomy ) {
243
-		$term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id );
244
-		$this->object_update( $term, $taxonomy );
242
+	public function edit_term($term_id, $taxonomy) {
243
+		$term = $this->wordpress->get_wordpress_object_data($taxonomy, $term_id);
244
+		$this->object_update($term, $taxonomy);
245 245
 	}
246 246
 
247 247
 	/**
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 	* @param string $taxonomy (slug)
253 253
 	* @param object $deleted_term
254 254
 	*/
255
-	public function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) {
255
+	public function delete_term($term, $tt_id, $taxonomy, $deleted_term) {
256 256
 		$deleted_term = (array) $deleted_term;
257 257
 		$type         = $deleted_term['taxonomy'];
258
-		$this->object_delete( $deleted_term, $type );
258
+		$this->object_delete($deleted_term, $type);
259 259
 	}
260 260
 
261 261
 	/**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 	* @param int|string comment_approved
266 266
 	* @param array $commentdata
267 267
 	*/
268
-	public function add_comment( $comment_id, $comment_approved, $commentdata = array() ) {
269
-		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
270
-		$this->object_insert( $comment, 'comment' );
268
+	public function add_comment($comment_id, $comment_approved, $commentdata = array()) {
269
+		$comment = $this->wordpress->get_wordpress_object_data('comment', $comment_id);
270
+		$this->object_insert($comment, 'comment');
271 271
 	}
272 272
 
273 273
 	/**
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	*
276 276
 	* @param string $comment_id
277 277
 	*/
278
-	public function edit_comment( $comment_id ) {
279
-		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
280
-		$this->object_update( $comment, 'comment' );
278
+	public function edit_comment($comment_id) {
279
+		$comment = $this->wordpress->get_wordpress_object_data('comment', $comment_id);
280
+		$this->object_update($comment, 'comment');
281 281
 	}
282 282
 
283 283
 	/**
@@ -285,33 +285,33 @@  discard block
 block discarded – undo
285 285
 	*
286 286
 	* @param string $comment_id
287 287
 	*/
288
-	public function delete_comment( $comment_id ) {
289
-		$comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id );
290
-		$this->object_delete( $comment, 'comment' );
288
+	public function delete_comment($comment_id) {
289
+		$comment = $this->wordpress->get_wordpress_object_data('comment', $comment_id);
290
+		$this->object_delete($comment, 'comment');
291 291
 	}
292 292
 
293 293
 	/**
294 294
 	* Insert a new object
295 295
 	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
296 296
 	*/
297
-	private function object_insert( $object, $type ) {
298
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_create );
297
+	private function object_insert($object, $type) {
298
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_create);
299 299
 	}
300 300
 
301 301
 	/**
302 302
 	* Update an existing object
303 303
 	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
304 304
 	*/
305
-	private function object_update( $object, $type ) {
306
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update );
305
+	private function object_update($object, $type) {
306
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_update);
307 307
 	}
308 308
 
309 309
 	/**
310 310
 	* Delete an existing object
311 311
 	* This calls the overall push crud method, which controls queuing and sending data to the Salesforce class
312 312
 	*/
313
-	private function object_delete( $object, $type ) {
314
-		$this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_delete );
313
+	private function object_delete($object, $type) {
314
+		$this->salesforce_push_object_crud($type, $object, $this->mappings->sync_wordpress_delete);
315 315
 	}
316 316
 
317 317
 	/**
@@ -328,50 +328,50 @@  discard block
 block discarded – undo
328 328
 	*   Are we calling this manually?
329 329
 	*
330 330
 	*/
331
-	private function salesforce_push_object_crud( $object_type, $object, $sf_sync_trigger, $manual = false ) {
331
+	private function salesforce_push_object_crud($object_type, $object, $sf_sync_trigger, $manual = false) {
332 332
 
333
-		$structure       = $this->wordpress->get_wordpress_table_structure( $object_type );
333
+		$structure       = $this->wordpress->get_wordpress_table_structure($object_type);
334 334
 		$object_id_field = $structure['id_field'];
335 335
 
336 336
 		// there is a WordPress object to push
337
-		if ( isset( $object[ $object_id_field ] ) ) {
338
-			$mapping_object = $this->mappings->load_by_wordpress( $object_type, $object[ $object_id_field ] );
337
+		if (isset($object[$object_id_field])) {
338
+			$mapping_object = $this->mappings->load_by_wordpress($object_type, $object[$object_id_field]);
339 339
 
340 340
 			// there is already a mapping object for this WordPress object
341
-			if ( isset( $mapping_object['id'] ) ) {
341
+			if (isset($mapping_object['id'])) {
342 342
 				$mapping_object_id_transient = $mapping_object['id'];
343 343
 			} else {
344 344
 				// there is not a mapping object for this WordPress object id yet
345 345
 				// check for that transient with the currently pulling id
346
-				$mapping_object_id_transient = (int) get_transient( 'salesforce_pulling_object_id' );
346
+				$mapping_object_id_transient = (int) get_transient('salesforce_pulling_object_id');
347 347
 			}
348 348
 
349
-			$salesforce_pulling = (int) get_transient( 'salesforce_pulling_' . $mapping_object_id_transient );
350
-			if ( 1 === $salesforce_pulling ) {
351
-				delete_transient( 'salesforce_pulling_' . $mapping_object_id_transient );
352
-				$pulling_id = get_transient( 'salesforce_pulling_object_id' );
353
-				if ( $pulling_id === $mapping_object_id_transient ) {
354
-					delete_transient( 'salesforce_pulling_object_id' );
349
+			$salesforce_pulling = (int) get_transient('salesforce_pulling_' . $mapping_object_id_transient);
350
+			if (1 === $salesforce_pulling) {
351
+				delete_transient('salesforce_pulling_' . $mapping_object_id_transient);
352
+				$pulling_id = get_transient('salesforce_pulling_object_id');
353
+				if ($pulling_id === $mapping_object_id_transient) {
354
+					delete_transient('salesforce_pulling_object_id');
355 355
 				}
356 356
 				return false;
357 357
 			}
358 358
 		} else {
359 359
 			// if we don't have a WordPress object id, we've got no business doing stuff in Salesforce
360 360
 			$status = 'error';
361
-			if ( isset( $this->logging ) ) {
361
+			if (isset($this->logging)) {
362 362
 				$logging = $this->logging;
363
-			} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
364
-				$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
363
+			} elseif (class_exists('Object_Sync_Sf_Logging')) {
364
+				$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
365 365
 			}
366 366
 
367 367
 			// translators: placeholder is the name of the WordPress id field
368
-			$title = sprintf( esc_html__( 'Error: Salesforce Push: unable to process queue item because it has no WordPress %1$s.', 'object-sync-for-salesforce' ),
369
-				esc_attr( $object_id_field )
368
+			$title = sprintf(esc_html__('Error: Salesforce Push: unable to process queue item because it has no WordPress %1$s.', 'object-sync-for-salesforce'),
369
+				esc_attr($object_id_field)
370 370
 			);
371 371
 
372 372
 			$logging->setup(
373 373
 				$title,
374
-				print_r( $object, true ), // print this array because if this happens, something weird has happened and we want to log whatever we have
374
+				print_r($object, true), // print this array because if this happens, something weird has happened and we want to log whatever we have
375 375
 				$sf_sync_trigger,
376 376
 				0, // parent id goes here but we don't have one, so make it 0
377 377
 				$status
@@ -388,14 +388,14 @@  discard block
 block discarded – undo
388 388
 			)
389 389
 		);
390 390
 
391
-		foreach ( $sf_mappings as $mapping ) { // for each mapping of this object
391
+		foreach ($sf_mappings as $mapping) { // for each mapping of this object
392 392
 			$map_sync_triggers = $mapping['sync_triggers'];
393 393
 
394 394
 			// these are bit operators, so we leave out the strict
395
-			if ( isset( $map_sync_triggers ) && isset( $sf_sync_trigger ) && in_array( $sf_sync_trigger, $map_sync_triggers ) ) { // wp or sf crud event
395
+			if (isset($map_sync_triggers) && isset($sf_sync_trigger) && in_array($sf_sync_trigger, $map_sync_triggers)) { // wp or sf crud event
396 396
 
397 397
 				// hook to allow other plugins to prevent a push per-mapping.
398
-				$push_allowed = apply_filters( 'object_sync_for_salesforce_push_object_allowed', true, $object_type, $object, $sf_sync_trigger, $mapping );
398
+				$push_allowed = apply_filters('object_sync_for_salesforce_push_object_allowed', true, $object_type, $object, $sf_sync_trigger, $mapping);
399 399
 
400 400
 				// example to keep from pushing the user with id of 1
401 401
 				/*
@@ -408,17 +408,17 @@  discard block
 block discarded – undo
408 408
 				}
409 409
 				*/
410 410
 
411
-				if ( false === $push_allowed ) {
411
+				if (false === $push_allowed) {
412 412
 					continue;
413 413
 				}
414 414
 
415 415
 				// push drafts if the setting says so
416 416
 				// post status is draft, or post status is inherit and post type is not attachment
417
-				if ( ( ! isset( $mapping['push_drafts'] ) || '1' !== $mapping['push_drafts'] ) && isset( $object['post_status'] ) && ( 'draft' === $object['post_status'] || ( 'inherit' === $object['post_status'] && 'attachment' !== $object['post_type'] ) ) ) {
417
+				if (( ! isset($mapping['push_drafts']) || '1' !== $mapping['push_drafts']) && isset($object['post_status']) && ('draft' === $object['post_status'] || ('inherit' === $object['post_status'] && 'attachment' !== $object['post_type']))) {
418 418
 					// skip this object if it is a draft and the fieldmap settings told us to ignore it
419 419
 					continue;
420 420
 				}
421
-				if ( isset( $mapping['push_async'] ) && ( '1' === $mapping['push_async'] ) && false === $manual ) {
421
+				if (isset($mapping['push_async']) && ('1' === $mapping['push_async']) && false === $manual) {
422 422
 					// this item is async and we want to save it to the queue
423 423
 					$data = array(
424 424
 						'object_type'     => $object_type,
@@ -429,24 +429,24 @@  discard block
 block discarded – undo
429 429
 
430 430
 					// create new schedule based on the options for this current class
431 431
 					// this will use the existing schedule if it already exists; otherwise it'll create one
432
-					$this->schedule->use_schedule( $this->schedule_name );
433
-					$this->schedule->push_to_queue( $data );
432
+					$this->schedule->use_schedule($this->schedule_name);
433
+					$this->schedule->push_to_queue($data);
434 434
 					$this->schedule->save()->dispatch();
435 435
 
436 436
 				} else {
437 437
 					// this one is not async. do it immediately.
438
-					$push = $this->salesforce_push_sync_rest( $object_type, $object, $mapping, $sf_sync_trigger );
438
+					$push = $this->salesforce_push_sync_rest($object_type, $object, $mapping, $sf_sync_trigger);
439 439
 				} // End if().
440 440
 			} // End if(). if the trigger does not match our requirements, skip it
441 441
 		} // End foreach().
442 442
 	}
443 443
 
444 444
 	private function schedule() {
445
-		if ( ! class_exists( 'Object_Sync_Sf_Schedule' ) && file_exists( plugin_dir_path( __FILE__ ) . '../vendor/autoload.php' ) ) {
446
-			require_once plugin_dir_path( __FILE__ ) . '../vendor/autoload.php';
447
-			require_once plugin_dir_path( __FILE__ ) . '../classes/schedule.php';
445
+		if ( ! class_exists('Object_Sync_Sf_Schedule') && file_exists(plugin_dir_path(__FILE__) . '../vendor/autoload.php')) {
446
+			require_once plugin_dir_path(__FILE__) . '../vendor/autoload.php';
447
+			require_once plugin_dir_path(__FILE__) . '../classes/schedule.php';
448 448
 		}
449
-		$schedule       = new Object_Sync_Sf_Schedule( $this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->schedule_name, $this->logging, $this->schedulable_classes );
449
+		$schedule       = new Object_Sync_Sf_Schedule($this->wpdb, $this->version, $this->login_credentials, $this->slug, $this->wordpress, $this->salesforce, $this->mappings, $this->schedule_name, $this->logging, $this->schedulable_classes);
450 450
 		$this->schedule = $schedule;
451 451
 		return $schedule;
452 452
 	}
@@ -466,25 +466,25 @@  discard block
 block discarded – undo
466 466
 	* @return true or exit the method
467 467
 	*
468 468
 	*/
469
-	public function salesforce_push_sync_rest( $object_type, $object, $mapping, $sf_sync_trigger ) {
469
+	public function salesforce_push_sync_rest($object_type, $object, $mapping, $sf_sync_trigger) {
470 470
 
471 471
 		// If Salesforce is not authorized, don't do anything.
472 472
 		// it's unclear to me if we need to do something else here or if this is sufficient. This is all Drupal does.
473
-		if ( true !== $this->salesforce['is_authorized'] ) {
473
+		if (true !== $this->salesforce['is_authorized']) {
474 474
 			return;
475 475
 		}
476 476
 
477 477
 		$sfapi = $this->salesforce['sfapi'];
478 478
 
479 479
 		// we need to get the WordPress id here so we can check to see if the object already has a map
480
-		$structure = $this->wordpress->get_wordpress_table_structure( $object_type );
480
+		$structure = $this->wordpress->get_wordpress_table_structure($object_type);
481 481
 		$object_id = $structure['id_field'];
482 482
 
483 483
 		// this returns the row that maps the individual WordPress row to the individual Salesfoce row
484
-		$mapping_object = $this->mappings->load_by_wordpress( $object_type, $object[ "$object_id" ] );
484
+		$mapping_object = $this->mappings->load_by_wordpress($object_type, $object["$object_id"]);
485 485
 
486 486
 		// hook to allow other plugins to define or alter the mapping object
487
-		$mapping_object = apply_filters( 'object_sync_for_salesforce_push_mapping_object', $mapping_object, $object, $mapping );
487
+		$mapping_object = apply_filters('object_sync_for_salesforce_push_mapping_object', $mapping_object, $object, $mapping);
488 488
 
489 489
 		// we already have the data from WordPress at this point; we just need to work with it in Salesforce
490 490
 		$synced_object = array(
@@ -498,84 +498,84 @@  discard block
 block discarded – undo
498 498
 
499 499
 		// deleting mapped objects
500 500
 		// these are bit operators, so we leave out the strict
501
-		if ( $sf_sync_trigger == $this->mappings->sync_wordpress_delete ) {
502
-			if ( isset( $mapping_object['id'] ) ) {
501
+		if ($sf_sync_trigger == $this->mappings->sync_wordpress_delete) {
502
+			if (isset($mapping_object['id'])) {
503 503
 				$op = 'Delete';
504 504
 
505
-				$salesforce_check = $this->mappings->load_by_salesforce( $mapping_object['salesforce_id'] );
505
+				$salesforce_check = $this->mappings->load_by_salesforce($mapping_object['salesforce_id']);
506 506
 
507
-				if ( count( $salesforce_check ) === count( $salesforce_check, COUNT_RECURSIVE ) ) {
507
+				if (count($salesforce_check) === count($salesforce_check, COUNT_RECURSIVE)) {
508 508
 					try {
509
-						$result = $sfapi->object_delete( $mapping['salesforce_object'], $mapping_object['salesforce_id'] );
510
-					} catch ( Object_Sync_Sf_Exception $e ) {
509
+						$result = $sfapi->object_delete($mapping['salesforce_object'], $mapping_object['salesforce_id']);
510
+					} catch (Object_Sync_Sf_Exception $e) {
511 511
 						$status = 'error';
512 512
 						// create log entry for failed delete
513
-						if ( isset( $this->logging ) ) {
513
+						if (isset($this->logging)) {
514 514
 							$logging = $this->logging;
515
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
516
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
515
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
516
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
517 517
 						}
518 518
 
519 519
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
520
-						$title = sprintf( esc_html__( 'Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
521
-							esc_attr( $op ),
522
-							esc_attr( $mapping['salesforce_object'] ),
523
-							esc_attr( $mapping_object['salesforce_id'] ),
524
-							esc_attr( $mapping['wordpress_object'] ),
525
-							esc_attr( $object_id ),
526
-							esc_attr( $object[ "$object_id" ] )
520
+						$title = sprintf(esc_html__('Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
521
+							esc_attr($op),
522
+							esc_attr($mapping['salesforce_object']),
523
+							esc_attr($mapping_object['salesforce_id']),
524
+							esc_attr($mapping['wordpress_object']),
525
+							esc_attr($object_id),
526
+							esc_attr($object["$object_id"])
527 527
 						);
528 528
 
529 529
 						$logging->setup(
530 530
 							$title,
531 531
 							$e->getMessage(),
532 532
 							$sf_sync_trigger,
533
-							$object[ "$object_id" ],
533
+							$object["$object_id"],
534 534
 							$status
535 535
 						);
536 536
 
537 537
 						// hook for push fail
538
-						do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object, $object_id );
538
+						do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object, $object_id);
539 539
 
540 540
 					}
541 541
 
542
-					if ( ! isset( $e ) ) {
542
+					if ( ! isset($e)) {
543 543
 						// create log entry for successful delete if the result had no errors
544 544
 						$status = 'success';
545
-						if ( isset( $this->logging ) ) {
545
+						if (isset($this->logging)) {
546 546
 							$logging = $this->logging;
547
-						} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
548
-							$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
547
+						} elseif (class_exists('Object_Sync_Sf_Logging')) {
548
+							$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
549 549
 						}
550 550
 
551 551
 						// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
552
-						$title = sprintf( esc_html__( 'Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
553
-							esc_attr( $op ),
554
-							esc_attr( $mapping['salesforce_object'] ),
555
-							esc_attr( $mapping_object['salesforce_id'] ),
556
-							esc_attr( $mapping['wordpress_object'] ),
557
-							esc_attr( $object_id ),
558
-							esc_attr( $object[ "$object_id" ] )
552
+						$title = sprintf(esc_html__('Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
553
+							esc_attr($op),
554
+							esc_attr($mapping['salesforce_object']),
555
+							esc_attr($mapping_object['salesforce_id']),
556
+							esc_attr($mapping['wordpress_object']),
557
+							esc_attr($object_id),
558
+							esc_attr($object["$object_id"])
559 559
 						);
560 560
 
561 561
 						$logging->setup(
562 562
 							$title,
563 563
 							'',
564 564
 							$sf_sync_trigger,
565
-							$object[ "$object_id" ],
565
+							$object["$object_id"],
566 566
 							$status
567 567
 						);
568 568
 
569 569
 						// hook for push success
570
-						do_action( 'object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id );
570
+						do_action('object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id);
571 571
 					}
572 572
 				} else {
573 573
 					$more_ids = '<p>The Salesforce record was not deleted because there are multiple WordPress IDs that match this Salesforce ID. They are: ';
574 574
 					$i        = 0;
575
-					foreach ( $salesforce_check as $match ) {
575
+					foreach ($salesforce_check as $match) {
576 576
 						$i++;
577 577
 						$more_ids .= $match['wordpress_id'];
578
-						if ( count( $salesforce_check ) !== $i ) {
578
+						if (count($salesforce_check) !== $i) {
579 579
 							$more_ids .= ', ';
580 580
 						} else {
581 581
 							$more_ids .= '.</p>';
@@ -585,34 +585,34 @@  discard block
 block discarded – undo
585 585
 					$more_ids .= '<p>The map row between this WordPress object and the Salesforce object, as stored in the WordPress database, will be deleted, and this WordPress object has been deleted, but Salesforce will remain untouched.</p>';
586 586
 
587 587
 					$status = 'notice';
588
-					if ( isset( $this->logging ) ) {
588
+					if (isset($this->logging)) {
589 589
 						$logging = $this->logging;
590
-					} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
591
-						$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
590
+					} elseif (class_exists('Object_Sync_Sf_Logging')) {
591
+						$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
592 592
 					}
593 593
 
594 594
 					// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
595
-					$title = sprintf( esc_html__( 'Notice: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s did not delete the Salesforce item.)', 'object-sync-for-salesforce' ),
596
-						esc_attr( $op ),
597
-						esc_attr( $mapping['salesforce_object'] ),
598
-						esc_attr( $mapping_object['salesforce_id'] ),
599
-						esc_attr( $mapping['wordpress_object'] ),
600
-						esc_attr( $object_id ),
601
-						esc_attr( $object[ "$object_id" ] )
595
+					$title = sprintf(esc_html__('Notice: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s did not delete the Salesforce item.)', 'object-sync-for-salesforce'),
596
+						esc_attr($op),
597
+						esc_attr($mapping['salesforce_object']),
598
+						esc_attr($mapping_object['salesforce_id']),
599
+						esc_attr($mapping['wordpress_object']),
600
+						esc_attr($object_id),
601
+						esc_attr($object["$object_id"])
602 602
 					);
603 603
 
604 604
 					$logging->setup(
605 605
 						$title,
606 606
 						$more_ids,
607 607
 						$sf_sync_trigger,
608
-						$object[ "$object_id" ],
608
+						$object["$object_id"],
609 609
 						$status
610 610
 					);
611 611
 				} // End if().
612 612
 
613 613
 				// delete the map row from WordPress after the Salesforce row has been deleted
614 614
 				// we delete the map row even if the Salesforce delete failed, because the WordPress object is gone
615
-				$this->mappings->delete_object_map( $mapping_object['id'] );
615
+				$this->mappings->delete_object_map($mapping_object['id']);
616 616
 
617 617
 			} // End if(). there is no map row
618 618
 
@@ -620,51 +620,51 @@  discard block
 block discarded – undo
620 620
 		} // End if().
621 621
 
622 622
 		// are these objects already connected in WordPress?
623
-		if ( isset( $mapping_object['id'] ) ) {
623
+		if (isset($mapping_object['id'])) {
624 624
 			$is_new = false;
625 625
 		} else {
626 626
 			$is_new = true;
627 627
 		}
628 628
 
629 629
 		// map the WordPress values to salesforce fields
630
-		$params = $this->mappings->map_params( $mapping, $object, $sf_sync_trigger, false, $is_new );
630
+		$params = $this->mappings->map_params($mapping, $object, $sf_sync_trigger, false, $is_new);
631 631
 
632 632
 		// hook to allow other plugins to modify the $params array
633 633
 		// use hook to map fields between the WordPress and Salesforce objects
634 634
 		// returns $params.
635
-		$params = apply_filters( 'object_sync_for_salesforce_push_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new );
635
+		$params = apply_filters('object_sync_for_salesforce_push_params_modify', $params, $mapping, $object, $sf_sync_trigger, false, $is_new);
636 636
 
637 637
 		// if we don't get any params, there are no fields that should be sent to Salesforce
638
-		if ( empty( $params ) ) {
638
+		if (empty($params)) {
639 639
 			return;
640 640
 		}
641 641
 
642 642
 		// if there is a prematch WordPress field - ie email - on the fieldmap object
643
-		if ( isset( $params['prematch'] ) && is_array( $params['prematch'] ) ) {
643
+		if (isset($params['prematch']) && is_array($params['prematch'])) {
644 644
 			$prematch_field_wordpress  = $params['prematch']['wordpress_field'];
645 645
 			$prematch_field_salesforce = $params['prematch']['salesforce_field'];
646 646
 			$prematch_value            = $params['prematch']['value'];
647
-			unset( $params['prematch'] );
647
+			unset($params['prematch']);
648 648
 		}
649 649
 
650 650
 		// if there is an external key field in Salesforce - ie mailchimp user id - on the fieldmap object
651
-		if ( isset( $params['key'] ) && is_array( $params['key'] ) ) {
651
+		if (isset($params['key']) && is_array($params['key'])) {
652 652
 			$key_field_wordpress  = $params['key']['wordpress_field'];
653 653
 			$key_field_salesforce = $params['key']['salesforce_field'];
654 654
 			$key_value            = $params['key']['value'];
655
-			unset( $params['key'] );
655
+			unset($params['key']);
656 656
 		}
657 657
 
658
-		$seconds = $this->schedule->get_schedule_frequency_seconds( $this->schedule_name ) + 60;
658
+		$seconds = $this->schedule->get_schedule_frequency_seconds($this->schedule_name) + 60;
659 659
 
660
-		if ( true === $is_new ) {
660
+		if (true === $is_new) {
661 661
 
662 662
 			// right here we should set the pushing transient
663 663
 			// this means we have to create the mapping object here as well, and update it with the correct IDs after successful response
664 664
 			// create the mapping object between the rows
665
-			$mapping_object_id = $this->create_object_map( $object, $object_id, $this->mappings->generate_temporary_id( 'push' ), $mapping, true );
666
-			set_transient( 'salesforce_pushing_' . $mapping_object_id, 1, $seconds );
667
-			set_transient( 'salesforce_pushing_object_id', $mapping_object_id );
665
+			$mapping_object_id = $this->create_object_map($object, $object_id, $this->mappings->generate_temporary_id('push'), $mapping, true);
666
+			set_transient('salesforce_pushing_' . $mapping_object_id, 1, $seconds);
667
+			set_transient('salesforce_pushing_object_id', $mapping_object_id);
668 668
 			$mapping_object = $this->mappings->get_object_maps(
669 669
 				array(
670 670
 					'id' => $mapping_object_id,
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 
674 674
 			// setup SF record type. CampaignMember objects get their Campaign's type
675 675
 			// i am still a bit confused about this
676
-			if ( $mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty( $params['RecordTypeId'] ) && ( 'CampaignMember' !== $mapping['salesforce_object'] ) ) {
676
+			if ($mapping['salesforce_record_type_default'] !== $this->mappings->salesforce_default_record_type && empty($params['RecordTypeId']) && ('CampaignMember' !== $mapping['salesforce_object'])) {
677 677
 				$params['RecordTypeId'] = $mapping['salesforce_record_type_default'];
678 678
 			}
679 679
 
@@ -685,61 +685,61 @@  discard block
 block discarded – undo
685 685
 				// returns a $salesforce_id.
686 686
 				// it should keep NULL if there is no match
687 687
 				// the function that calls this hook needs to check the mapping to make sure the WordPress object is the right type
688
-				$salesforce_id = apply_filters( 'object_sync_for_salesforce_find_sf_object_match', null, $object, $mapping, 'push' );
688
+				$salesforce_id = apply_filters('object_sync_for_salesforce_find_sf_object_match', null, $object, $mapping, 'push');
689 689
 
690 690
 				// hook to allow other plugins to do something right before Salesforce data is saved
691 691
 				// ex: run WordPress methods on an object if it exists, or do something in preparation for it if it doesn't
692
-				do_action( 'object_sync_for_salesforce_pre_push', $salesforce_id, $mapping, $object, $object_id, $params );
692
+				do_action('object_sync_for_salesforce_pre_push', $salesforce_id, $mapping, $object, $object_id, $params);
693 693
 
694 694
 				// hook to allow other plugins to change params on update actions only
695 695
 				// use hook to map fields between the WordPress and Salesforce objects
696 696
 				// returns $params.
697
-				$params = apply_filters( 'object_sync_for_salesforce_push_update_params_modify', $params, $salesforce_id, $mapping, $object );
697
+				$params = apply_filters('object_sync_for_salesforce_push_update_params_modify', $params, $salesforce_id, $mapping, $object);
698 698
 
699
-				if ( isset( $prematch_field_wordpress ) || isset( $key_field_wordpress ) || null !== $salesforce_id ) {
699
+				if (isset($prematch_field_wordpress) || isset($key_field_wordpress) || null !== $salesforce_id) {
700 700
 
701 701
 					// if either prematch criteria exists, make the values queryable
702 702
 
703
-					if ( isset( $prematch_field_wordpress ) ) {
703
+					if (isset($prematch_field_wordpress)) {
704 704
 						// a prematch has been specified, attempt an upsert().
705 705
 						// prematch values with punctuation need to be escaped
706
-						$encoded_prematch_value = rawurlencode( $prematch_value );
706
+						$encoded_prematch_value = rawurlencode($prematch_value);
707 707
 						// for at least 'email' fields, periods also need to be escaped:
708 708
 						// https://developer.salesforce.com/forums?id=906F000000099xPIAQ
709
-						$encoded_prematch_value = str_replace( '.', '%2E', $encoded_prematch_value );
709
+						$encoded_prematch_value = str_replace('.', '%2E', $encoded_prematch_value);
710 710
 					}
711 711
 
712
-					if ( isset( $key_field_wordpress ) ) {
712
+					if (isset($key_field_wordpress)) {
713 713
 						// an external key has been specified, attempt an upsert().
714 714
 						// external key values with punctuation need to be escaped
715
-						$encoded_key_value = rawurlencode( $key_value );
715
+						$encoded_key_value = rawurlencode($key_value);
716 716
 						// for at least 'email' fields, periods also need to be escaped:
717 717
 						// https://developer.salesforce.com/forums?id=906F000000099xPIAQ
718
-						$encoded_key_value = str_replace( '.', '%2E', $encoded_key_value );
718
+						$encoded_key_value = str_replace('.', '%2E', $encoded_key_value);
719 719
 					}
720 720
 
721
-					if ( isset( $prematch_field_wordpress ) ) {
721
+					if (isset($prematch_field_wordpress)) {
722 722
 						$upsert_key   = $prematch_field_salesforce;
723 723
 						$upsert_value = $encoded_prematch_value;
724
-					} elseif ( isset( $key_field_wordpress ) ) {
724
+					} elseif (isset($key_field_wordpress)) {
725 725
 						$upsert_key   = $key_field_salesforce;
726 726
 						$upsert_value = $encoded_key_value;
727 727
 					}
728 728
 
729
-					if ( null !== $salesforce_id ) {
729
+					if (null !== $salesforce_id) {
730 730
 						$upsert_key   = 'Id';
731 731
 						$upsert_value = $salesforce_id;
732 732
 					}
733 733
 
734 734
 					$op = 'Upsert';
735 735
 
736
-					$result = $sfapi->object_upsert( $mapping['salesforce_object'], $upsert_key, $upsert_value, $params );
736
+					$result = $sfapi->object_upsert($mapping['salesforce_object'], $upsert_key, $upsert_value, $params);
737 737
 
738 738
 					// Handle upsert responses.
739
-					switch ( $sfapi->response['code'] ) {
739
+					switch ($sfapi->response['code']) {
740 740
 						// On Upsert:update retrieved object.
741 741
 						case '204':
742
-							$sf_object             = $sfapi->object_readby_external_id( $mapping['salesforce_object'], $upsert_key, $upsert_value );
742
+							$sf_object             = $sfapi->object_readby_external_id($mapping['salesforce_object'], $upsert_key, $upsert_value);
743 743
 							$salesforce_data['id'] = $sf_object['data']['Id'];
744 744
 							break;
745 745
 						// Handle duplicate records.
@@ -750,43 +750,43 @@  discard block
 block discarded – undo
750 750
 				} else {
751 751
 					// No key or prematch field exists on this field map object, create a new object in Salesforce.
752 752
 					$op     = 'Create';
753
-					$result = $sfapi->object_create( $mapping['salesforce_object'], $params );
753
+					$result = $sfapi->object_create($mapping['salesforce_object'], $params);
754 754
 				} // End if().
755
-			} catch ( Object_Sync_Sf_Exception $e ) {
755
+			} catch (Object_Sync_Sf_Exception $e) {
756 756
 				// create log entry for failed create or upsert
757 757
 				$status = 'error';
758 758
 
759
-				if ( isset( $this->logging ) ) {
759
+				if (isset($this->logging)) {
760 760
 					$logging = $this->logging;
761
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
762
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
761
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
762
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
763 763
 				}
764 764
 
765 765
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value if there is one, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
766
-				$title = sprintf( esc_html__( 'Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
767
-					esc_attr( $op ),
768
-					esc_attr( $mapping['salesforce_object'] ),
769
-					isset( $salesforce_id ) ? ' ' . esc_attr( $salesforce_id ) : '',
770
-					esc_attr( $mapping['wordpress_object'] ),
771
-					esc_attr( $object_id ),
772
-					esc_attr( $object[ "$object_id" ] )
766
+				$title = sprintf(esc_html__('Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
767
+					esc_attr($op),
768
+					esc_attr($mapping['salesforce_object']),
769
+					isset($salesforce_id) ? ' ' . esc_attr($salesforce_id) : '',
770
+					esc_attr($mapping['wordpress_object']),
771
+					esc_attr($object_id),
772
+					esc_attr($object["$object_id"])
773 773
 				);
774 774
 
775 775
 				$logging->setup(
776 776
 					$title,
777 777
 					$e->getMessage(),
778 778
 					$sf_sync_trigger,
779
-					$object[ "$object_id" ],
779
+					$object["$object_id"],
780 780
 					$status
781 781
 				);
782 782
 
783 783
 				// hook for push fail
784
-				do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object );
784
+				do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object);
785 785
 
786 786
 				return;
787 787
 			} // End try().
788 788
 
789
-			if ( ! isset( $salesforce_data ) ) {
789
+			if ( ! isset($salesforce_data)) {
790 790
 				// if we didn't set $salesforce_data already, set it now to api call result
791 791
 				$salesforce_data = $result['data'];
792 792
 			}
@@ -795,78 +795,78 @@  discard block
 block discarded – undo
795 795
 			// this means the object has already been created/updated in Salesforce
796 796
 			// this is not redundant because this is where it creates the object mapping rows in WordPress if the object does not already have one (we are still inside $is_new === TRUE here)
797 797
 
798
-			if ( empty( $result['errorCode'] ) ) {
798
+			if (empty($result['errorCode'])) {
799 799
 				$salesforce_id = $salesforce_data['id'];
800 800
 				$status        = 'success';
801 801
 
802
-				if ( isset( $this->logging ) ) {
802
+				if (isset($this->logging)) {
803 803
 					$logging = $this->logging;
804
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
805
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
804
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
805
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
806 806
 				}
807 807
 
808 808
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
809
-				$title = sprintf( esc_html__( 'Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
810
-					esc_attr( $op ),
811
-					esc_attr( $mapping['salesforce_object'] ),
812
-					esc_attr( $salesforce_id ),
813
-					esc_attr( $mapping['wordpress_object'] ),
814
-					esc_attr( $object_id ),
815
-					esc_attr( $object[ "$object_id" ] )
809
+				$title = sprintf(esc_html__('Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
810
+					esc_attr($op),
811
+					esc_attr($mapping['salesforce_object']),
812
+					esc_attr($salesforce_id),
813
+					esc_attr($mapping['wordpress_object']),
814
+					esc_attr($object_id),
815
+					esc_attr($object["$object_id"])
816 816
 				);
817 817
 
818 818
 				$logging->setup(
819 819
 					$title,
820 820
 					'',
821 821
 					$sf_sync_trigger,
822
-					$object[ "$object_id" ],
822
+					$object["$object_id"],
823 823
 					$status
824 824
 				);
825 825
 
826 826
 				// update that mapping object
827 827
 				$mapping_object['salesforce_id']     = $salesforce_id;
828
-				$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
829
-				$mapping_object                      = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
828
+				$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
829
+				$mapping_object                      = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
830 830
 
831 831
 				// hook for push success
832
-				do_action( 'object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id );
832
+				do_action('object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id);
833 833
 			} else {
834 834
 
835 835
 				// create log entry for failed create or upsert
836 836
 				// this is part of the drupal module but i am failing to understand when it would ever fire, since the catch should catch the errors
837 837
 				// if we see this in the log entries, we can understand what it does, but probably not until then
838 838
 				$status = 'error';
839
-				if ( isset( $this->logging ) ) {
839
+				if (isset($this->logging)) {
840 840
 					$logging = $this->logging;
841
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
842
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
841
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
842
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
843 843
 				}
844 844
 
845 845
 				// translators: placeholders are: 1) error code the Salesforce API returned, 2) what operation is happening, 3) the name of the WordPress object type, 4) the WordPress id field name, 5) the WordPress object id value
846
-				$title = sprintf( esc_html__( '%1$s error syncing: %2$s to Salesforce (WordPress %3$s with %4$s of %5$s)', 'object-sync-for-salesforce' ),
847
-					absint( $salesforce_data['errorCode'] ),
848
-					esc_attr( $op ),
849
-					esc_attr( $mapping['wordpress_object'] ),
850
-					esc_attr( $object_id ),
851
-					esc_attr( $object[ "$object_id" ] )
846
+				$title = sprintf(esc_html__('%1$s error syncing: %2$s to Salesforce (WordPress %3$s with %4$s of %5$s)', 'object-sync-for-salesforce'),
847
+					absint($salesforce_data['errorCode']),
848
+					esc_attr($op),
849
+					esc_attr($mapping['wordpress_object']),
850
+					esc_attr($object_id),
851
+					esc_attr($object["$object_id"])
852 852
 				);
853 853
 
854 854
 				// translators: placeholders are 1) the name of the Salesforce object type, 2) the error message returned from the Salesforce APIs
855
-				$body = sprintf( '<p>' . esc_html__( 'Object: %1$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Message: %2$s', 'object-sync-for-salesforce' ) . '</p>',
856
-					esc_attr( $mapping['salesforce_object'] ),
857
-					esc_html( $salesforce_data['message'] )
855
+				$body = sprintf('<p>' . esc_html__('Object: %1$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Message: %2$s', 'object-sync-for-salesforce') . '</p>',
856
+					esc_attr($mapping['salesforce_object']),
857
+					esc_html($salesforce_data['message'])
858 858
 				);
859 859
 
860 860
 				$logging->setup(
861 861
 					$title,
862 862
 					$body,
863 863
 					$sf_sync_trigger,
864
-					$object[ "$object_id" ],
864
+					$object["$object_id"],
865 865
 					$status
866 866
 				);
867 867
 
868 868
 				// hook for push fail
869
-				do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object );
869
+				do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object);
870 870
 
871 871
 				return;
872 872
 			} // End if().
@@ -874,41 +874,41 @@  discard block
 block discarded – undo
874 874
 			// $is_new is false here; we are updating an already mapped object
875 875
 
876 876
 			// right here we should set the pushing transient
877
-			set_transient( 'salesforce_pushing_' . $mapping_object['id'], 1, $seconds );
878
-			set_transient( 'salesforce_pushing_object_id', $mapping_object['id'] );
877
+			set_transient('salesforce_pushing_' . $mapping_object['id'], 1, $seconds);
878
+			set_transient('salesforce_pushing_object_id', $mapping_object['id']);
879 879
 
880 880
 			// there is an existing object link
881 881
 			// if the last sync is greater than the last time this object was updated, skip it
882 882
 			// this keeps us from doing redundant syncs
883
-			$mapping_object['object_updated'] = current_time( 'mysql' );
884
-			if ( $mapping_object['last_sync'] > $mapping_object['object_updated'] ) {
883
+			$mapping_object['object_updated'] = current_time('mysql');
884
+			if ($mapping_object['last_sync'] > $mapping_object['object_updated']) {
885 885
 				$status = 'notice';
886
-				if ( isset( $this->logging ) ) {
886
+				if (isset($this->logging)) {
887 887
 					$logging = $this->logging;
888
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
889
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
888
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
889
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
890 890
 				}
891 891
 
892 892
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the WordPress object type, 3) the WordPress id field name, 4) the WordPress object id value, 5) the Salesforce Id value
893
-				$title = sprintf( esc_html__( 'Notice: %1$s: Did not sync WordPress %2$s with %3$s of %4$s with Salesforce Id %5$s because the last sync timestamp was greater than the object updated timestamp.', 'object-sync-for-salesforce' ),
894
-					esc_attr( $op ),
895
-					esc_attr( $mapping['wordpress_object'] ),
896
-					esc_attr( $object_id ),
897
-					esc_attr( $object[ "$object_id" ] ),
898
-					esc_attr( $mapping_object['salesforce_id'] )
893
+				$title = sprintf(esc_html__('Notice: %1$s: Did not sync WordPress %2$s with %3$s of %4$s with Salesforce Id %5$s because the last sync timestamp was greater than the object updated timestamp.', 'object-sync-for-salesforce'),
894
+					esc_attr($op),
895
+					esc_attr($mapping['wordpress_object']),
896
+					esc_attr($object_id),
897
+					esc_attr($object["$object_id"]),
898
+					esc_attr($mapping_object['salesforce_id'])
899 899
 				);
900 900
 
901 901
 				// translators: placeholders are 1) when a sync on this mapping last occured, 2) when the object was last updated
902
-				$body = sprintf( '<p>' . esc_html__( 'Last sync time: %1$s', 'object-sync-for-salesforce' ) . '</p><p>' . esc_html__( 'Object updated time: %2$s', 'object-sync-for-salesforce' ) . '</p>',
903
-					esc_attr( $mapping_object['last_sync'] ),
904
-					esc_html( $mapping_object['object_updated'] )
902
+				$body = sprintf('<p>' . esc_html__('Last sync time: %1$s', 'object-sync-for-salesforce') . '</p><p>' . esc_html__('Object updated time: %2$s', 'object-sync-for-salesforce') . '</p>',
903
+					esc_attr($mapping_object['last_sync']),
904
+					esc_html($mapping_object['object_updated'])
905 905
 				);
906 906
 
907 907
 				$logging->setup(
908 908
 					$title,
909 909
 					$body,
910 910
 					$sf_sync_trigger,
911
-					$object[ "$object_id" ],
911
+					$object["$object_id"],
912 912
 					$status
913 913
 				);
914 914
 				return;
@@ -919,71 +919,71 @@  discard block
 block discarded – undo
919 919
 
920 920
 				// hook to allow other plugins to do something right before Salesforce data is saved
921 921
 				// ex: run WordPress methods on an object if it exists, or do something in preparation for it if it doesn't
922
-				do_action( 'object_sync_for_salesforce_pre_push', $mapping_object['salesforce_id'], $mapping, $object, $object_id, $params );
922
+				do_action('object_sync_for_salesforce_pre_push', $mapping_object['salesforce_id'], $mapping, $object, $object_id, $params);
923 923
 
924 924
 				// hook to allow other plugins to change params on update actions only
925 925
 				// use hook to map fields between the WordPress and Salesforce objects
926 926
 				// returns $params.
927
-				$params = apply_filters( 'object_sync_for_salesforce_push_update_params_modify', $params, $mapping_object['salesforce_id'], $mapping, $object );
927
+				$params = apply_filters('object_sync_for_salesforce_push_update_params_modify', $params, $mapping_object['salesforce_id'], $mapping, $object);
928 928
 
929 929
 				$op     = 'Update';
930
-				$result = $sfapi->object_update( $mapping['salesforce_object'], $mapping_object['salesforce_id'], $params );
930
+				$result = $sfapi->object_update($mapping['salesforce_object'], $mapping_object['salesforce_id'], $params);
931 931
 
932 932
 				$mapping_object['last_sync_status']  = $this->mappings->status_success;
933
-				$mapping_object['last_sync_message'] = esc_html__( 'Mapping object updated via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__;
933
+				$mapping_object['last_sync_message'] = esc_html__('Mapping object updated via function: ', 'object-sync-for-salesforce') . __FUNCTION__;
934 934
 
935 935
 				$status = 'success';
936
-				if ( isset( $this->logging ) ) {
936
+				if (isset($this->logging)) {
937 937
 					$logging = $this->logging;
938
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
939
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
938
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
939
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
940 940
 				}
941 941
 
942 942
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
943
-				$title = sprintf( esc_html__( 'Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
944
-					esc_attr( $op ),
945
-					esc_attr( $mapping['salesforce_object'] ),
946
-					esc_attr( $mapping_object['salesforce_id'] ),
947
-					esc_attr( $mapping['wordpress_object'] ),
948
-					esc_attr( $object_id ),
949
-					esc_attr( $object[ "$object_id" ] )
943
+				$title = sprintf(esc_html__('Success: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
944
+					esc_attr($op),
945
+					esc_attr($mapping['salesforce_object']),
946
+					esc_attr($mapping_object['salesforce_id']),
947
+					esc_attr($mapping['wordpress_object']),
948
+					esc_attr($object_id),
949
+					esc_attr($object["$object_id"])
950 950
 				);
951 951
 
952 952
 				$logging->setup(
953 953
 					$title,
954 954
 					'',
955 955
 					$sf_sync_trigger,
956
-					$object[ "$object_id" ],
956
+					$object["$object_id"],
957 957
 					$status
958 958
 				);
959 959
 
960 960
 				// hook for push success
961
-				do_action( 'object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id );
961
+				do_action('object_sync_for_salesforce_push_success', $op, $sfapi->response, $synced_object, $object_id);
962 962
 
963
-			} catch ( Object_Sync_Sf_Exception $e ) {
963
+			} catch (Object_Sync_Sf_Exception $e) {
964 964
 				// create log entry for failed update
965 965
 				$status = 'error';
966
-				if ( isset( $this->logging ) ) {
966
+				if (isset($this->logging)) {
967 967
 					$logging = $this->logging;
968
-				} elseif ( class_exists( 'Object_Sync_Sf_Logging' ) ) {
969
-					$logging = new Object_Sync_Sf_Logging( $this->wpdb, $this->version );
968
+				} elseif (class_exists('Object_Sync_Sf_Logging')) {
969
+					$logging = new Object_Sync_Sf_Logging($this->wpdb, $this->version);
970 970
 				}
971 971
 
972 972
 				// translators: placeholders are: 1) what operation is happening, 2) the name of the Salesforce object, 3) the Salesforce Id value, 4) the name of the WordPress object type, 5) the WordPress id field name, 6) the WordPress object id value
973
-				$title = sprintf( esc_html__( 'Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce' ),
974
-					esc_attr( $op ),
975
-					esc_attr( $mapping['salesforce_object'] ),
976
-					esc_attr( $mapping_object['salesforce_id'] ),
977
-					esc_attr( $mapping['wordpress_object'] ),
978
-					esc_attr( $object_id ),
979
-					esc_attr( $object[ "$object_id" ] )
973
+				$title = sprintf(esc_html__('Error: %1$s %2$s %3$s (WordPress %4$s with %5$s of %6$s)', 'object-sync-for-salesforce'),
974
+					esc_attr($op),
975
+					esc_attr($mapping['salesforce_object']),
976
+					esc_attr($mapping_object['salesforce_id']),
977
+					esc_attr($mapping['wordpress_object']),
978
+					esc_attr($object_id),
979
+					esc_attr($object["$object_id"])
980 980
 				);
981 981
 
982 982
 				$logging->setup(
983 983
 					$title,
984 984
 					$e->getMessage(),
985 985
 					$sf_sync_trigger,
986
-					$object[ "$object_id" ],
986
+					$object["$object_id"],
987 987
 					$status
988 988
 				);
989 989
 
@@ -991,16 +991,16 @@  discard block
 block discarded – undo
991 991
 				$mapping_object['last_sync_message'] = $e->getMessage();
992 992
 
993 993
 				// hook for push fail
994
-				do_action( 'object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object );
994
+				do_action('object_sync_for_salesforce_push_fail', $op, $sfapi->response, $synced_object);
995 995
 
996 996
 			} // End try().
997 997
 
998 998
 			// tell the mapping object - whether it is new or already existed - how we just used it
999 999
 			$mapping_object['last_sync_action'] = 'push';
1000
-			$mapping_object['last_sync']        = current_time( 'mysql' );
1000
+			$mapping_object['last_sync']        = current_time('mysql');
1001 1001
 
1002 1002
 			// update that mapping object
1003
-			$result = $this->mappings->update_object_map( $mapping_object, $mapping_object['id'] );
1003
+			$result = $this->mappings->update_object_map($mapping_object, $mapping_object['id']);
1004 1004
 
1005 1005
 		} // End if(). this is the end of the if is_new stuff
1006 1006
 
@@ -1022,9 +1022,9 @@  discard block
 block discarded – undo
1022 1022
 	*   This is the database row for the map object
1023 1023
 	*
1024 1024
 	*/
1025
-	private function create_object_map( $wordpress_object, $id_field_name, $salesforce_id, $field_mapping, $pending = false ) {
1025
+	private function create_object_map($wordpress_object, $id_field_name, $salesforce_id, $field_mapping, $pending = false) {
1026 1026
 
1027
-		if ( true === $pending ) {
1027
+		if (true === $pending) {
1028 1028
 			$action = 'pending';
1029 1029
 		} else {
1030 1030
 			$action = 'created';
@@ -1033,15 +1033,15 @@  discard block
 block discarded – undo
1033 1033
 		// Create object map and save it
1034 1034
 		$mapping_object = $this->mappings->create_object_map(
1035 1035
 			array(
1036
-				'wordpress_id'      => $wordpress_object[ $id_field_name ], // wordpress unique id
1036
+				'wordpress_id'      => $wordpress_object[$id_field_name], // wordpress unique id
1037 1037
 				'salesforce_id'     => $salesforce_id, // salesforce unique id. we don't care what kind of object it is at this point
1038 1038
 				'wordpress_object'  => $field_mapping['wordpress_object'], // keep track of what kind of wp object this is
1039
-				'last_sync'         => current_time( 'mysql' ),
1039
+				'last_sync'         => current_time('mysql'),
1040 1040
 				'last_sync_action'  => 'push',
1041 1041
 				'last_sync_status'  => $this->mappings->status_success,
1042 1042
 				// translators: placeholder is for the action that occurred on the mapping object (pending or created)
1043
-				'last_sync_message' => sprintf( esc_html__( 'Mapping object %1$s via function: ', 'object-sync-for-salesforce' ) . __FUNCTION__,
1044
-					esc_attr( $action )
1043
+				'last_sync_message' => sprintf(esc_html__('Mapping object %1$s via function: ', 'object-sync-for-salesforce') . __FUNCTION__,
1044
+					esc_attr($action)
1045 1045
 				),
1046 1046
 				'action'            => $action,
1047 1047
 			)
Please login to merge, or discard this patch.
classes/deactivate.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 	protected $version;
19 19
 
20 20
 	/**
21
-	* Constructor which sets up deactivate hooks
22
-	* @param object $wpdb
23
-	* @param string $version
24
-	* @param string $slug
25
-	* @param array $schedulable_classes
26
-	*
27
-	*/
21
+	 * Constructor which sets up deactivate hooks
22
+	 * @param object $wpdb
23
+	 * @param string $version
24
+	 * @param string $slug
25
+	 * @param array $schedulable_classes
26
+	 *
27
+	 */
28 28
 	public function __construct( $wpdb, $version, $slug, $schedulable_classes ) {
29 29
 		$this->wpdb                = $wpdb;
30 30
 		$this->version             = $version;
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	}
43 43
 
44 44
 	/**
45
-	* Drop database tables for Salesforce
46
-	* This removes the tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
47
-	*
48
-	*/
45
+	 * Drop database tables for Salesforce
46
+	 * This removes the tables for fieldmaps (between types of objects) and object maps (between indidual instances of objects)
47
+	 *
48
+	 */
49 49
 	public function wordpress_salesforce_drop_tables() {
50 50
 		$field_map_table  = $this->wpdb->prefix . 'object_sync_sf_field_map';
51 51
 		$object_map_table = $this->wpdb->prefix . 'object_sync_sf_object_map';
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	/**
58
-	* Clear the scheduled tasks
59
-	* This removes all the scheduled tasks that are included in the plugin's $schedulable_classes array
60
-	*
61
-	*/
58
+	 * Clear the scheduled tasks
59
+	 * This removes all the scheduled tasks that are included in the plugin's $schedulable_classes array
60
+	 *
61
+	 */
62 62
 	public function clear_schedule() {
63 63
 		foreach ( $this->schedulable_classes as $key => $value ) {
64 64
 			wp_clear_scheduled_hook( $key );
@@ -66,21 +66,21 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	/**
69
-	* Delete the log post type
70
-	* This removes the log post type
71
-	*
72
-	*/
69
+	 * Delete the log post type
70
+	 * This removes the log post type
71
+	 *
72
+	 */
73 73
 	public function delete_log_post_type() {
74 74
 		unregister_post_type( 'wp_log' );
75 75
 	}
76 76
 
77 77
 	/**
78
-	* Remove roles and capabilities
79
-	* This removes the configure_salesforce capability from the admin role
80
-	*
81
-	* It also allows other plugins to remove the capability from other roles
82
-	*
83
-	*/
78
+	 * Remove roles and capabilities
79
+	 * This removes the configure_salesforce capability from the admin role
80
+	 *
81
+	 * It also allows other plugins to remove the capability from other roles
82
+	 *
83
+	 */
84 84
 	public function remove_roles_capabilities() {
85 85
 
86 86
 		// by default, only administrators can configure the plugin
@@ -100,18 +100,18 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	/**
103
-	* Flush the plugin cache
104
-	*
105
-	*/
103
+	 * Flush the plugin cache
104
+	 *
105
+	 */
106 106
 	public function flush_plugin_cache() {
107 107
 		$sfwp_transients = new Object_Sync_Sf_WordPress_Transient( 'sfwp_transients' );
108 108
 		$sfwp_transients->flush();
109 109
 	}
110 110
 
111 111
 	/**
112
-	* Clear the plugin options
113
-	*
114
-	*/
112
+	 * Clear the plugin options
113
+	 *
114
+	 */
115 115
 	public function delete_plugin_options() {
116 116
 		$table          = $this->wpdb->prefix . 'options';
117 117
 		$plugin_options = $this->wpdb->get_results( 'SELECT option_name FROM ' . $table . ' WHERE option_name LIKE "object_sync_for_salesforce_%"', ARRAY_A );
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @file
6 6
  */
7 7
 
8
-if ( ! class_exists( 'Object_Sync_Salesforce' ) ) {
8
+if ( ! class_exists('Object_Sync_Salesforce')) {
9 9
 	die();
10 10
 }
11 11
 
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
 	* @param array $schedulable_classes
26 26
 	*
27 27
 	*/
28
-	public function __construct( $wpdb, $version, $slug, $schedulable_classes ) {
28
+	public function __construct($wpdb, $version, $slug, $schedulable_classes) {
29 29
 		$this->wpdb                = $wpdb;
30 30
 		$this->version             = $version;
31 31
 		$this->schedulable_classes = $schedulable_classes;
32
-		$delete_data               = (int) get_option( 'object_sync_for_salesforce_delete_data_on_uninstall', 0 );
33
-		if ( 1 === $delete_data ) {
34
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'wordpress_salesforce_drop_tables' ) );
35
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'clear_schedule' ) );
36
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'delete_log_post_type' ) );
37
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'remove_roles_capabilities' ) );
38
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'flush_plugin_cache' )
32
+		$delete_data               = (int) get_option('object_sync_for_salesforce_delete_data_on_uninstall', 0);
33
+		if (1 === $delete_data) {
34
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'wordpress_salesforce_drop_tables'));
35
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'clear_schedule'));
36
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'delete_log_post_type'));
37
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'remove_roles_capabilities'));
38
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'flush_plugin_cache')
39 39
 			);
40
-			register_deactivation_hook( dirname( __DIR__ ) . '/' . $slug . '.php', array( $this, 'delete_plugin_options' ) );
40
+			register_deactivation_hook(dirname(__DIR__) . '/' . $slug . '.php', array($this, 'delete_plugin_options'));
41 41
 		}
42 42
 	}
43 43
 
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	public function wordpress_salesforce_drop_tables() {
50 50
 		$field_map_table  = $this->wpdb->prefix . 'object_sync_sf_field_map';
51 51
 		$object_map_table = $this->wpdb->prefix . 'object_sync_sf_object_map';
52
-		$this->wpdb->query( 'DROP TABLE IF EXISTS ' . $field_map_table );
53
-		$this->wpdb->query( 'DROP TABLE IF EXISTS ' . $object_map_table );
54
-		delete_option( 'object_sync_for_salesforce_db_version' );
52
+		$this->wpdb->query('DROP TABLE IF EXISTS ' . $field_map_table);
53
+		$this->wpdb->query('DROP TABLE IF EXISTS ' . $object_map_table);
54
+		delete_option('object_sync_for_salesforce_db_version');
55 55
 	}
56 56
 
57 57
 	/**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	*
61 61
 	*/
62 62
 	public function clear_schedule() {
63
-		foreach ( $this->schedulable_classes as $key => $value ) {
64
-			wp_clear_scheduled_hook( $key );
63
+		foreach ($this->schedulable_classes as $key => $value) {
64
+			wp_clear_scheduled_hook($key);
65 65
 		}
66 66
 	}
67 67
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	*
72 72
 	*/
73 73
 	public function delete_log_post_type() {
74
-		unregister_post_type( 'wp_log' );
74
+		unregister_post_type('wp_log');
75 75
 	}
76 76
 
77 77
 	/**
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
 	public function remove_roles_capabilities() {
85 85
 
86 86
 		// by default, only administrators can configure the plugin
87
-		$role = get_role( 'administrator' );
88
-		$role->remove_cap( 'configure_salesforce' );
87
+		$role = get_role('administrator');
88
+		$role->remove_cap('configure_salesforce');
89 89
 
90 90
 		// hook that allows other roles to configure the plugin as well
91
-		$roles = apply_filters( 'object_sync_for_salesforce_roles_configure_salesforce', null );
91
+		$roles = apply_filters('object_sync_for_salesforce_roles_configure_salesforce', null);
92 92
 
93 93
 		// for each role that we have, remove the configure salesforce capability
94
-		if ( null !== $roles ) {
95
-			foreach ( $roles as $role ) {
96
-				$role->remove_cap( 'configure_salesforce' );
94
+		if (null !== $roles) {
95
+			foreach ($roles as $role) {
96
+				$role->remove_cap('configure_salesforce');
97 97
 			}
98 98
 		}
99 99
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	*
105 105
 	*/
106 106
 	public function flush_plugin_cache() {
107
-		$sfwp_transients = new Object_Sync_Sf_WordPress_Transient( 'sfwp_transients' );
107
+		$sfwp_transients = new Object_Sync_Sf_WordPress_Transient('sfwp_transients');
108 108
 		$sfwp_transients->flush();
109 109
 	}
110 110
 
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 	*/
115 115
 	public function delete_plugin_options() {
116 116
 		$table          = $this->wpdb->prefix . 'options';
117
-		$plugin_options = $this->wpdb->get_results( 'SELECT option_name FROM ' . $table . ' WHERE option_name LIKE "object_sync_for_salesforce_%"', ARRAY_A );
118
-		foreach ( $plugin_options as $option ) {
119
-			delete_option( $option['option_name'] );
117
+		$plugin_options = $this->wpdb->get_results('SELECT option_name FROM ' . $table . ' WHERE option_name LIKE "object_sync_for_salesforce_%"', ARRAY_A);
118
+		foreach ($plugin_options as $option) {
119
+			delete_option($option['option_name']);
120 120
 		}
121 121
 	}
122 122
 
Please login to merge, or discard this patch.