@@ -1,18 +1,18 @@ |
||
1 | -<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> |
|
2 | - <input type="hidden" name="redirect_url_error" value="<?php echo esc_url( $error_url ); ?>" /> |
|
3 | - <input type="hidden" name="redirect_url_success" value="<?php echo esc_url( $success_url ); ?>" /> |
|
4 | - <input type="hidden" name="id" value="<?php echo absint( $map_row['id'] ); ?>" /> |
|
1 | +<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>"> |
|
2 | + <input type="hidden" name="redirect_url_error" value="<?php echo esc_url($error_url); ?>" /> |
|
3 | + <input type="hidden" name="redirect_url_success" value="<?php echo esc_url($success_url); ?>" /> |
|
4 | + <input type="hidden" name="id" value="<?php echo absint($map_row['id']); ?>" /> |
|
5 | 5 | <input type="hidden" name="action" value="delete_object_map"> |
6 | - <h2><?php echo esc_html__( 'Are you sure you want to delete this mapping object?', 'object-sync-for-salesforce' ); ?></h2> |
|
6 | + <h2><?php echo esc_html__('Are you sure you want to delete this mapping object?', 'object-sync-for-salesforce'); ?></h2> |
|
7 | 7 | <p> |
8 | 8 | <?php |
9 | 9 | // translators: the placeholders refer to: 1) the WordPress object name, 2) the WordPress object Id, and 3) the Salesforce object Id |
10 | - echo sprintf( esc_html__( 'This object map maps the WordPress %1$s with an id value of %2$s to the Salesforce object with Id of %3$s.', 'object-sync-for-salesforce' ), |
|
11 | - '<strong> ' . esc_html( $map_row['wordpress_object'] ) . '</strong>', |
|
12 | - '<strong> ' . esc_html( $map_row['wordpress_id'] ) . '</strong>', |
|
13 | - '<strong> ' . esc_html( $map_row['salesforce_id'] ) . '</strong>' |
|
10 | + echo sprintf(esc_html__('This object map maps the WordPress %1$s with an id value of %2$s to the Salesforce object with Id of %3$s.', 'object-sync-for-salesforce'), |
|
11 | + '<strong> ' . esc_html($map_row['wordpress_object']) . '</strong>', |
|
12 | + '<strong> ' . esc_html($map_row['wordpress_id']) . '</strong>', |
|
13 | + '<strong> ' . esc_html($map_row['salesforce_id']) . '</strong>' |
|
14 | 14 | ); |
15 | 15 | ?> |
16 | 16 | </p> |
17 | - <?php submit_button( esc_html__( 'Confirm deletion', 'object-sync-for-salesforce' ) ); ?> |
|
17 | + <?php submit_button(esc_html__('Confirm deletion', 'object-sync-for-salesforce')); ?> |
|
18 | 18 | </form> |
@@ -1,12 +1,12 @@ |
||
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> |
@@ -1,2 +1,2 @@ |
||
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> |
@@ -1,14 +1,14 @@ |
||
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> |
@@ -1,35 +1,35 @@ discard block |
||
1 | -<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="fieldmap"> |
|
2 | - <input type="hidden" name="redirect_url_error" value="<?php echo esc_url( $error_url ); ?>" /> |
|
3 | - <input type="hidden" name="redirect_url_success" value="<?php echo esc_url( $success_url ); ?>" /> |
|
4 | - <?php if ( isset( $transient ) ) { ?> |
|
5 | - <input type="hidden" name="transient" value="<?php echo esc_html( $transient ); ?>" /> |
|
1 | +<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" class="fieldmap"> |
|
2 | + <input type="hidden" name="redirect_url_error" value="<?php echo esc_url($error_url); ?>" /> |
|
3 | + <input type="hidden" name="redirect_url_success" value="<?php echo esc_url($success_url); ?>" /> |
|
4 | + <?php if (isset($transient)) { ?> |
|
5 | + <input type="hidden" name="transient" value="<?php echo esc_html($transient); ?>" /> |
|
6 | 6 | <?php } ?> |
7 | 7 | <input type="hidden" name="action" value="post_fieldmap" > |
8 | - <input type="hidden" name="method" value="<?php echo esc_attr( $method ); ?>" /> |
|
9 | - <?php if ( 'edit' === $method ) { ?> |
|
10 | - <input type="hidden" name="id" value="<?php echo absint( $map['id'] ); ?>" /> |
|
8 | + <input type="hidden" name="method" value="<?php echo esc_attr($method); ?>" /> |
|
9 | + <?php if ('edit' === $method) { ?> |
|
10 | + <input type="hidden" name="id" value="<?php echo absint($map['id']); ?>" /> |
|
11 | 11 | <?php } ?> |
12 | 12 | <div class="fieldmap_label"> |
13 | - <label for="label"><?php echo esc_html__( 'Label', 'object-sync-for-salesforce' ); ?>: </label> |
|
14 | - <input type="text" id="label" name="label" required value="<?php echo isset( $label ) ? esc_html( $label ) : ''; ?>" /> |
|
13 | + <label for="label"><?php echo esc_html__('Label', 'object-sync-for-salesforce'); ?>: </label> |
|
14 | + <input type="text" id="label" name="label" required value="<?php echo isset($label) ? esc_html($label) : ''; ?>" /> |
|
15 | 15 | </div> |
16 | 16 | <fieldset class="wordpress_side"> |
17 | 17 | <div class="wordpress_object"> |
18 | - <label for="wordpress_object"><?php echo esc_html__( 'WordPress Object', 'object-sync-for-salesforce' ); ?>: </label> |
|
18 | + <label for="wordpress_object"><?php echo esc_html__('WordPress Object', 'object-sync-for-salesforce'); ?>: </label> |
|
19 | 19 | <select id="wordpress_object" name="wordpress_object" required> |
20 | - <option value="">- <?php echo esc_html__( 'Select object type', 'object-sync-for-salesforce' ); ?> -</option> |
|
20 | + <option value="">- <?php echo esc_html__('Select object type', 'object-sync-for-salesforce'); ?> -</option> |
|
21 | 21 | <?php |
22 | 22 | $wordpress_objects = $this->wordpress->wordpress_objects; |
23 | - foreach ( $wordpress_objects as $object ) { |
|
24 | - if ( isset( $wordpress_object ) && $wordpress_object === $object ) { |
|
23 | + foreach ($wordpress_objects as $object) { |
|
24 | + if (isset($wordpress_object) && $wordpress_object === $object) { |
|
25 | 25 | $selected = ' selected'; |
26 | 26 | } else { |
27 | 27 | $selected = ''; |
28 | 28 | } |
29 | - echo sprintf( '<option value="%1$s"%2$s>%3$s</option>', |
|
30 | - esc_html( $object ), |
|
31 | - esc_attr( $selected ), |
|
32 | - esc_html( $object ) |
|
29 | + echo sprintf('<option value="%1$s"%2$s>%3$s</option>', |
|
30 | + esc_html($object), |
|
31 | + esc_attr($selected), |
|
32 | + esc_html($object) |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | ?> |
@@ -38,31 +38,31 @@ discard block |
||
38 | 38 | </fieldset> |
39 | 39 | <fieldset class="salesforce_side"> |
40 | 40 | <div class="salesforce_object"> |
41 | - <label for="salesforce_object"><?php echo esc_html__( 'Salesforce Object', 'object-sync-for-salesforce' ); ?>: </label> |
|
41 | + <label for="salesforce_object"><?php echo esc_html__('Salesforce Object', 'object-sync-for-salesforce'); ?>: </label> |
|
42 | 42 | <div class="spinner"></div> |
43 | 43 | <select id="salesforce_object" name="salesforce_object" required> |
44 | - <option value="">- <?php echo esc_html__( 'Select object type', 'object-sync-for-salesforce' ); ?> -</option> |
|
44 | + <option value="">- <?php echo esc_html__('Select object type', 'object-sync-for-salesforce'); ?> -</option> |
|
45 | 45 | <?php |
46 | 46 | $sfapi = $this->salesforce['sfapi']; |
47 | - $object_filters = maybe_unserialize( get_option( 'salesforce_api_object_filters' ), array() ); |
|
47 | + $object_filters = maybe_unserialize(get_option('salesforce_api_object_filters'), array()); |
|
48 | 48 | $conditions = array(); |
49 | - if ( is_array( $object_filters ) && in_array( 'updateable', $object_filters, true ) ) { |
|
49 | + if (is_array($object_filters) && in_array('updateable', $object_filters, true)) { |
|
50 | 50 | $conditions['updateable'] = true; |
51 | 51 | } |
52 | - if ( is_array( $object_filters ) && in_array( 'triggerable', $object_filters, true ) ) { |
|
52 | + if (is_array($object_filters) && in_array('triggerable', $object_filters, true)) { |
|
53 | 53 | $conditions['triggerable'] = true; |
54 | 54 | } |
55 | - $salesforce_objects = $sfapi->objects( $conditions ); |
|
56 | - foreach ( $salesforce_objects as $object ) { |
|
57 | - if ( isset( $salesforce_object ) && $salesforce_object === $object['name'] ) { |
|
55 | + $salesforce_objects = $sfapi->objects($conditions); |
|
56 | + foreach ($salesforce_objects as $object) { |
|
57 | + if (isset($salesforce_object) && $salesforce_object === $object['name']) { |
|
58 | 58 | $selected = ' selected'; |
59 | 59 | } else { |
60 | 60 | $selected = ''; |
61 | 61 | } |
62 | - echo sprintf( '<option value="%1$s"%2$s>%3$s</option>', |
|
63 | - esc_html( $object['name'] ), |
|
64 | - esc_attr( $selected ), |
|
65 | - esc_html( $object['label'] ) |
|
62 | + echo sprintf('<option value="%1$s"%2$s>%3$s</option>', |
|
63 | + esc_html($object['name']), |
|
64 | + esc_attr($selected), |
|
65 | + esc_html($object['label']) |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 | ?> |
@@ -70,30 +70,30 @@ discard block |
||
70 | 70 | </div> |
71 | 71 | <div class="salesforce_record_types_allowed"> |
72 | 72 | <?php |
73 | - if ( isset( $salesforce_record_types_allowed ) ) : |
|
73 | + if (isset($salesforce_record_types_allowed)) : |
|
74 | 74 | $record_types = $this->get_salesforce_object_description( |
75 | 75 | array( |
76 | 76 | 'salesforce_object' => $salesforce_object, |
77 | 77 | 'include' => 'recordTypeInfos', |
78 | 78 | ) |
79 | 79 | ); |
80 | - if ( isset( $record_types['recordTypeInfos'] ) ) : |
|
80 | + if (isset($record_types['recordTypeInfos'])) : |
|
81 | 81 | ?> |
82 | - <label for="salesforce_record_types_allowed"><?php echo __( 'Allowed Record Types', 'object-sync-for-salesforce' ); ?>:</label> |
|
82 | + <label for="salesforce_record_types_allowed"><?php echo __('Allowed Record Types', 'object-sync-for-salesforce'); ?>:</label> |
|
83 | 83 | <div class="checkboxes"> |
84 | - <?php foreach ( $record_types['recordTypeInfos'] as $key => $value ) : ?> |
|
84 | + <?php foreach ($record_types['recordTypeInfos'] as $key => $value) : ?> |
|
85 | 85 | <?php |
86 | - if ( in_array( $key, $salesforce_record_types_allowed, true ) ) { |
|
86 | + if (in_array($key, $salesforce_record_types_allowed, true)) { |
|
87 | 87 | $checked = ' checked'; |
88 | 88 | } else { |
89 | 89 | $checked = ''; |
90 | 90 | } |
91 | - echo sprintf( '<label><input type="checkbox" class="form-checkbox" value="%1$s" name="%2$s" id="%3$s"%4$s>%5$s</label>', |
|
92 | - esc_html( $key ), |
|
93 | - esc_attr( 'salesforce_record_types_allowed[' . $key . ']' ), |
|
94 | - esc_attr( 'salesforce_record_types_allowed-' . $key ), |
|
95 | - esc_html( $checked ), |
|
96 | - esc_html( $value ) |
|
91 | + echo sprintf('<label><input type="checkbox" class="form-checkbox" value="%1$s" name="%2$s" id="%3$s"%4$s>%5$s</label>', |
|
92 | + esc_html($key), |
|
93 | + esc_attr('salesforce_record_types_allowed[' . $key . ']'), |
|
94 | + esc_attr('salesforce_record_types_allowed-' . $key), |
|
95 | + esc_html($checked), |
|
96 | + esc_html($value) |
|
97 | 97 | ); |
98 | 98 | ?> |
99 | 99 | <?php endforeach; ?> |
@@ -103,29 +103,29 @@ discard block |
||
103 | 103 | </div> |
104 | 104 | <div class="salesforce_record_type_default"> |
105 | 105 | <?php |
106 | - if ( isset( $salesforce_record_type_default ) ) : |
|
106 | + if (isset($salesforce_record_type_default)) : |
|
107 | 107 | $record_types = $this->get_salesforce_object_description( |
108 | 108 | array( |
109 | 109 | 'salesforce_object' => $salesforce_object, |
110 | 110 | 'include' => 'recordTypeInfos', |
111 | 111 | ) |
112 | 112 | ); |
113 | - if ( isset( $record_types['recordTypeInfos'] ) ) : |
|
113 | + if (isset($record_types['recordTypeInfos'])) : |
|
114 | 114 | ?> |
115 | - <label for="salesforce_record_type_default"><?php echo __( 'Default Record Type', 'object-sync-for-salesforce' ); ?>:</label> |
|
116 | - <select id="salesforce_record_type_default" name="salesforce_record_type_default" required><option value="">- <?php echo __( 'Select record type', 'object-sync-for-salesforce' ); ?> -</option> |
|
115 | + <label for="salesforce_record_type_default"><?php echo __('Default Record Type', 'object-sync-for-salesforce'); ?>:</label> |
|
116 | + <select id="salesforce_record_type_default" name="salesforce_record_type_default" required><option value="">- <?php echo __('Select record type', 'object-sync-for-salesforce'); ?> -</option> |
|
117 | 117 | <?php |
118 | - foreach ( $record_types['recordTypeInfos'] as $key => $value ) : |
|
119 | - if ( isset( $salesforce_record_type_default ) && $salesforce_record_type_default === $key ) { |
|
118 | + foreach ($record_types['recordTypeInfos'] as $key => $value) : |
|
119 | + if (isset($salesforce_record_type_default) && $salesforce_record_type_default === $key) { |
|
120 | 120 | $selected = ' selected'; |
121 | 121 | } else { |
122 | 122 | $selected = ''; |
123 | 123 | } |
124 | - if ( ! isset( $salesforce_record_types_allowed ) || in_array( $key, $salesforce_record_types_allowed, true ) ) { |
|
125 | - echo sprintf( '<option value="%1$s"%2$s>%3$s</option>', |
|
126 | - esc_attr( $key ), |
|
127 | - esc_attr( $selected ), |
|
128 | - esc_html( $value ) |
|
124 | + if ( ! isset($salesforce_record_types_allowed) || in_array($key, $salesforce_record_types_allowed, true)) { |
|
125 | + echo sprintf('<option value="%1$s"%2$s>%3$s</option>', |
|
126 | + esc_attr($key), |
|
127 | + esc_attr($selected), |
|
128 | + esc_html($value) |
|
129 | 129 | ); |
130 | 130 | } |
131 | 131 | endforeach; |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | ?> |
138 | 138 | </div> |
139 | 139 | <div class="pull_trigger_field"> |
140 | - <?php if ( isset( $pull_trigger_field ) ) : ?> |
|
141 | - <label for="pull_trigger_field"><?php echo __( 'Date field to trigger pull', 'object-sync-for-salesforce' ); ?>:</label> |
|
140 | + <?php if (isset($pull_trigger_field)) : ?> |
|
141 | + <label for="pull_trigger_field"><?php echo __('Date field to trigger pull', 'object-sync-for-salesforce'); ?>:</label> |
|
142 | 142 | <?php |
143 | 143 | $object_fields = $this->get_salesforce_object_fields( |
144 | 144 | array( |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | ?> |
150 | 150 | <select name="pull_trigger_field" id="pull_trigger_field"> |
151 | 151 | <?php |
152 | - foreach ( $object_fields as $key => $value ) { |
|
153 | - if ( $pull_trigger_field === $value['name'] ) { |
|
152 | + foreach ($object_fields as $key => $value) { |
|
153 | + if ($pull_trigger_field === $value['name']) { |
|
154 | 154 | $selected = ' selected'; |
155 | 155 | } else { |
156 | 156 | $selected = ''; |
157 | 157 | } |
158 | - echo sprintf( '<option value="%1$s"%2$s>%3$s</option>', |
|
159 | - esc_attr( $value['name'] ), |
|
160 | - esc_attr( $selected ), |
|
161 | - esc_html( $value['label'] ) |
|
158 | + echo sprintf('<option value="%1$s"%2$s>%3$s</option>', |
|
159 | + esc_attr($value['name']), |
|
160 | + esc_attr($selected), |
|
161 | + esc_html($value['label']) |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 | ?> |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | </div> |
168 | 168 | </fieldset> |
169 | 169 | <fieldset class="fields"> |
170 | - <legend><?php echo esc_html__( 'Fieldmap', 'object-sync-for-salesforce' ); ?></legend> |
|
170 | + <legend><?php echo esc_html__('Fieldmap', 'object-sync-for-salesforce'); ?></legend> |
|
171 | 171 | <table class="wp-list-table widefat striped fields"> |
172 | 172 | <thead> |
173 | 173 | <tr> |
174 | - <th class="column-wordpress_field"><?php echo esc_html__( 'WordPress Field', 'object-sync-for-salesforce' ); ?></th> |
|
175 | - <th class="column-salesforce_field"><?php echo esc_html__( 'Salesforce Field', 'object-sync-for-salesforce' ); ?></th> |
|
176 | - <th class="column-is_prematch"><?php echo esc_html__( 'Prematch', 'object-sync-for-salesforce' ); ?></th> |
|
177 | - <th class="column-is_key"><?php echo esc_html__( 'Salesforce Key', 'object-sync-for-salesforce' ); ?></th> |
|
178 | - <th class="column-direction"><?php echo esc_html__( 'Direction', 'object-sync-for-salesforce' ); ?></th> |
|
179 | - <th class="column-is_delete"><?php echo esc_html__( 'Delete', 'object-sync-for-salesforce' ); ?></th> |
|
174 | + <th class="column-wordpress_field"><?php echo esc_html__('WordPress Field', 'object-sync-for-salesforce'); ?></th> |
|
175 | + <th class="column-salesforce_field"><?php echo esc_html__('Salesforce Field', 'object-sync-for-salesforce'); ?></th> |
|
176 | + <th class="column-is_prematch"><?php echo esc_html__('Prematch', 'object-sync-for-salesforce'); ?></th> |
|
177 | + <th class="column-is_key"><?php echo esc_html__('Salesforce Key', 'object-sync-for-salesforce'); ?></th> |
|
178 | + <th class="column-direction"><?php echo esc_html__('Direction', 'object-sync-for-salesforce'); ?></th> |
|
179 | + <th class="column-is_delete"><?php echo esc_html__('Delete', 'object-sync-for-salesforce'); ?></th> |
|
180 | 180 | </tr> |
181 | 181 | </thead> |
182 | 182 | <tfoot> |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | <p><small> |
186 | 186 | <?php |
187 | 187 | // translators: the placeholders refer to: 1) the cache clear link, 2) the cache clear link text |
188 | - echo sprintf( '<strong>' . esc_html__( 'Note:', 'object-sync-for-salesforce' ) . '</strong>' . esc_html__( ' to map a custom meta field (such as wp_postmeta, wp_usermeta, wp_termmeta, etc.), WordPress must have at least one value for that field. If you add a new meta field and want to map it, make sure to add a value for it and ', 'object-sync-for-salesforce' ) . '<a href="%1$s" id="clear-sfwp-cache">%2$s</a>' . esc_html__( ' to see the field listed here', 'object-sync-for-salesforce' ), |
|
189 | - esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=clear_cache' ) ), |
|
190 | - esc_html__( 'clear the plugin cache', 'object-sync-for-salesforce' ) |
|
188 | + echo sprintf('<strong>' . esc_html__('Note:', 'object-sync-for-salesforce') . '</strong>' . esc_html__(' to map a custom meta field (such as wp_postmeta, wp_usermeta, wp_termmeta, etc.), WordPress must have at least one value for that field. If you add a new meta field and want to map it, make sure to add a value for it and ', 'object-sync-for-salesforce') . '<a href="%1$s" id="clear-sfwp-cache">%2$s</a>' . esc_html__(' to see the field listed here', 'object-sync-for-salesforce'), |
|
189 | + esc_url(get_admin_url(null, 'options-general.php?page=object-sync-salesforce-admin&tab=clear_cache')), |
|
190 | + esc_html__('clear the plugin cache', 'object-sync-for-salesforce') |
|
191 | 191 | ); |
192 | 192 | ?> |
193 | 193 | </small></p> |
@@ -196,26 +196,26 @@ discard block |
||
196 | 196 | </tfoot> |
197 | 197 | <tbody> |
198 | 198 | <?php |
199 | - if ( isset( $fieldmap_fields ) && null !== $fieldmap_fields && is_array( $fieldmap_fields ) ) { |
|
200 | - foreach ( $fieldmap_fields as $key => $value ) { |
|
201 | - $key = md5( $key . time() ); |
|
199 | + if (isset($fieldmap_fields) && null !== $fieldmap_fields && is_array($fieldmap_fields)) { |
|
200 | + foreach ($fieldmap_fields as $key => $value) { |
|
201 | + $key = md5($key . time()); |
|
202 | 202 | ?> |
203 | 203 | <tr> |
204 | 204 | <td class="column-wordpress_field"> |
205 | - <select name="wordpress_field[<?php echo esc_attr( $key ); ?>]" id="wordpress_field-<?php echo esc_attr( $key ); ?>"> |
|
206 | - <option value="">- <?php echo esc_html__( 'Select WordPress field', 'object-sync-for-salesforce' ); ?> -</option> |
|
205 | + <select name="wordpress_field[<?php echo esc_attr($key); ?>]" id="wordpress_field-<?php echo esc_attr($key); ?>"> |
|
206 | + <option value="">- <?php echo esc_html__('Select WordPress field', 'object-sync-for-salesforce'); ?> -</option> |
|
207 | 207 | <?php |
208 | - $wordpress_fields = $this->get_wordpress_object_fields( $wordpress_object ); |
|
209 | - foreach ( $wordpress_fields as $wordpress_field ) { |
|
210 | - if ( isset( $value['wordpress_field']['label'] ) && $value['wordpress_field']['label'] === $wordpress_field['key'] ) { |
|
208 | + $wordpress_fields = $this->get_wordpress_object_fields($wordpress_object); |
|
209 | + foreach ($wordpress_fields as $wordpress_field) { |
|
210 | + if (isset($value['wordpress_field']['label']) && $value['wordpress_field']['label'] === $wordpress_field['key']) { |
|
211 | 211 | $selected = ' selected'; |
212 | 212 | } else { |
213 | 213 | $selected = ''; |
214 | 214 | } |
215 | - echo sprintf( '<option value="%1$s"%2$s>%3$s</option>', |
|
216 | - esc_attr( $wordpress_field['key'] ), |
|
217 | - esc_attr( $selected ), |
|
218 | - esc_html( $wordpress_field['key'] ) |
|
215 | + echo sprintf('<option value="%1$s"%2$s>%3$s</option>', |
|
216 | + esc_attr($wordpress_field['key']), |
|
217 | + esc_attr($selected), |
|
218 | + esc_html($wordpress_field['key']) |
|
219 | 219 | ); |
220 | 220 | } |
221 | 221 | ?> |
@@ -223,27 +223,27 @@ discard block |
||
223 | 223 | |
224 | 224 | </td> |
225 | 225 | <td class="column-salesforce_field"> |
226 | - <select name="salesforce_field[<?php echo esc_attr( $key ); ?>]" id="salesforce_field-<?php echo esc_attr( $key ); ?>"> |
|
227 | - <option value="">- <?php echo esc_html__( 'Select Salesforce field', 'object-sync-for-salesforce' ); ?> -</option> |
|
226 | + <select name="salesforce_field[<?php echo esc_attr($key); ?>]" id="salesforce_field-<?php echo esc_attr($key); ?>"> |
|
227 | + <option value="">- <?php echo esc_html__('Select Salesforce field', 'object-sync-for-salesforce'); ?> -</option> |
|
228 | 228 | <?php |
229 | 229 | $salesforce_fields = $this->get_salesforce_object_fields( |
230 | 230 | array( |
231 | 231 | 'salesforce_object' => $salesforce_object, |
232 | 232 | ) |
233 | 233 | ); |
234 | - foreach ( $salesforce_fields as $salesforce_field ) { |
|
235 | - if ( isset( $value['salesforce_field']['name'] ) && $value['salesforce_field']['name'] === $salesforce_field['name'] ) { |
|
234 | + foreach ($salesforce_fields as $salesforce_field) { |
|
235 | + if (isset($value['salesforce_field']['name']) && $value['salesforce_field']['name'] === $salesforce_field['name']) { |
|
236 | 236 | $selected = ' selected'; |
237 | - } elseif ( isset( $value['salesforce_field']['label'] ) && $value['salesforce_field']['label'] === $salesforce_field['name'] ) { |
|
237 | + } elseif (isset($value['salesforce_field']['label']) && $value['salesforce_field']['label'] === $salesforce_field['name']) { |
|
238 | 238 | // this conditional is for versions up to 1.1.2, but i think it's fine to leave it for now. if we remove it, people's fieldmaps will not show correctly in the admin. |
239 | 239 | $selected = ' selected'; |
240 | 240 | } else { |
241 | 241 | $selected = ''; |
242 | 242 | } |
243 | - echo sprintf( '<option value="%1$s"%2$s>%3$s</option>', |
|
244 | - esc_attr( $salesforce_field['name'] ), |
|
245 | - esc_attr( $selected ), |
|
246 | - esc_html( $salesforce_field['label'] ) |
|
243 | + echo sprintf('<option value="%1$s"%2$s>%3$s</option>', |
|
244 | + esc_attr($salesforce_field['name']), |
|
245 | + esc_attr($selected), |
|
246 | + esc_html($salesforce_field['label']) |
|
247 | 247 | ); |
248 | 248 | } |
249 | 249 | ?> |
@@ -252,32 +252,32 @@ discard block |
||
252 | 252 | </td> |
253 | 253 | <td class="column-is_prematch"> |
254 | 254 | <?php |
255 | - if ( isset( $value['is_prematch'] ) && '1' === $value['is_prematch'] ) { |
|
255 | + if (isset($value['is_prematch']) && '1' === $value['is_prematch']) { |
|
256 | 256 | $checked = ' checked'; |
257 | 257 | } else { |
258 | 258 | $checked = ''; |
259 | 259 | } |
260 | 260 | ?> |
261 | - <input type="checkbox" name="is_prematch[<?php echo esc_attr( $key ); ?>]" id="is_prematch-<?php echo esc_attr( $key ); ?>" value="1" <?php echo esc_attr( $checked ); ?> title="<?php echo esc_html__( 'This pair should be checked for existing matches in Salesforce before adding', 'object-sync-for-salesforce' ); ?>" /> |
|
261 | + <input type="checkbox" name="is_prematch[<?php echo esc_attr($key); ?>]" id="is_prematch-<?php echo esc_attr($key); ?>" value="1" <?php echo esc_attr($checked); ?> title="<?php echo esc_html__('This pair should be checked for existing matches in Salesforce before adding', 'object-sync-for-salesforce'); ?>" /> |
|
262 | 262 | </td> |
263 | 263 | <td class="column-is_key"> |
264 | 264 | <?php |
265 | - if ( isset( $value['is_key'] ) && '1' === $value['is_key'] ) { |
|
265 | + if (isset($value['is_key']) && '1' === $value['is_key']) { |
|
266 | 266 | $checked = ' checked'; |
267 | 267 | } else { |
268 | 268 | $checked = ''; |
269 | 269 | } |
270 | 270 | ?> |
271 | - <input type="checkbox" name="is_key[<?php echo esc_attr( $key ); ?>]" id="is_key-<?php echo esc_attr( $key ); ?>" value="1" <?php echo esc_attr( $checked ); ?> title="<?php echo esc_html__( 'This Salesforce field is an External ID in Salesforce', 'object-sync-for-salesforce' ); ?>" /> |
|
271 | + <input type="checkbox" name="is_key[<?php echo esc_attr($key); ?>]" id="is_key-<?php echo esc_attr($key); ?>" value="1" <?php echo esc_attr($checked); ?> title="<?php echo esc_html__('This Salesforce field is an External ID in Salesforce', 'object-sync-for-salesforce'); ?>" /> |
|
272 | 272 | </td> |
273 | 273 | <td class="column-direction"> |
274 | 274 | <?php |
275 | - if ( isset( $value['direction'] ) ) { |
|
276 | - if ( 'sf_wp' === $value['direction'] ) { |
|
275 | + if (isset($value['direction'])) { |
|
276 | + if ('sf_wp' === $value['direction']) { |
|
277 | 277 | $checked_sf_wp = ' checked'; |
278 | 278 | $checked_wp_sf = ''; |
279 | 279 | $checked_sync = ''; |
280 | - } elseif ( 'wp_sf' === $value['direction'] ) { |
|
280 | + } elseif ('wp_sf' === $value['direction']) { |
|
281 | 281 | $checked_sf_wp = ''; |
282 | 282 | $checked_wp_sf = ' checked'; |
283 | 283 | $checked_sync = ''; |
@@ -293,29 +293,29 @@ discard block |
||
293 | 293 | } |
294 | 294 | ?> |
295 | 295 | <div class="radios"> |
296 | - <label><input type="radio" value="sf_wp" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-sf-wp" <?php echo esc_attr( $checked_sf_wp ); ?> required> <?php echo esc_html__( 'Salesforce to WordPress', 'object-sync-for-salesforce' ); ?></label> |
|
297 | - <label><input type="radio" value="wp_sf" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-wp-sf" <?php echo esc_attr( $checked_wp_sf ); ?> required> <?php echo esc_html__( 'WordPress to Salesforce', 'object-sync-for-salesforce' ); ?></label> |
|
298 | - <label><input type="radio" value="sync" name="direction[<?php echo esc_attr( $key ); ?>]" id="direction-<?php echo esc_attr( $key ); ?>-sync" <?php echo esc_attr( $checked_sync ); ?> required> <?php echo esc_html__( 'Sync', 'object-sync-for-salesforce' ); ?></label> |
|
296 | + <label><input type="radio" value="sf_wp" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-sf-wp" <?php echo esc_attr($checked_sf_wp); ?> required> <?php echo esc_html__('Salesforce to WordPress', 'object-sync-for-salesforce'); ?></label> |
|
297 | + <label><input type="radio" value="wp_sf" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-wp-sf" <?php echo esc_attr($checked_wp_sf); ?> required> <?php echo esc_html__('WordPress to Salesforce', 'object-sync-for-salesforce'); ?></label> |
|
298 | + <label><input type="radio" value="sync" name="direction[<?php echo esc_attr($key); ?>]" id="direction-<?php echo esc_attr($key); ?>-sync" <?php echo esc_attr($checked_sync); ?> required> <?php echo esc_html__('Sync', 'object-sync-for-salesforce'); ?></label> |
|
299 | 299 | </div> |
300 | 300 | </td> |
301 | 301 | <td class="column-is_delete"> |
302 | - <input type="checkbox" name="is_delete[<?php echo esc_attr( $key ); ?>]" id="is_delete-<?php echo esc_attr( $key ); ?>" value="1" /> |
|
302 | + <input type="checkbox" name="is_delete[<?php echo esc_attr($key); ?>]" id="is_delete-<?php echo esc_attr($key); ?>" value="1" /> |
|
303 | 303 | </td> |
304 | 304 | </tr> |
305 | 305 | <?php |
306 | 306 | } // End foreach(). |
307 | - } elseif ( isset( $wordpress_object ) && isset( $salesforce_object ) ) { |
|
307 | + } elseif (isset($wordpress_object) && isset($salesforce_object)) { |
|
308 | 308 | ?> |
309 | 309 | <tr> |
310 | 310 | <td class="column-wordpress_field"> |
311 | 311 | <select name="wordpress_field[0]" id="wordpress_field-0"> |
312 | - <option value="">- <?php echo esc_html__( 'Select WordPress field', 'object-sync-for-salesforce' ); ?> -</option> |
|
312 | + <option value="">- <?php echo esc_html__('Select WordPress field', 'object-sync-for-salesforce'); ?> -</option> |
|
313 | 313 | <?php |
314 | - $wordpress_fields = $this->get_wordpress_object_fields( $wordpress_object ); |
|
315 | - foreach ( $wordpress_fields as $wordpress_field ) { |
|
316 | - echo sprintf( '<option value="%1$s">%2$s</option>', |
|
317 | - esc_attr( $wordpress_field['key'] ), |
|
318 | - esc_html( $wordpress_field['key'] ) |
|
314 | + $wordpress_fields = $this->get_wordpress_object_fields($wordpress_object); |
|
315 | + foreach ($wordpress_fields as $wordpress_field) { |
|
316 | + echo sprintf('<option value="%1$s">%2$s</option>', |
|
317 | + esc_attr($wordpress_field['key']), |
|
318 | + esc_html($wordpress_field['key']) |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | ?> |
@@ -323,17 +323,17 @@ discard block |
||
323 | 323 | </td> |
324 | 324 | <td class="column-salesforce_field"> |
325 | 325 | <select name="salesforce_field[0]" id="salesforce_field-0"> |
326 | - <option value="">- <?php echo esc_html__( 'Select Salesforce field', 'object-sync-for-salesforce' ); ?> -</option> |
|
326 | + <option value="">- <?php echo esc_html__('Select Salesforce field', 'object-sync-for-salesforce'); ?> -</option> |
|
327 | 327 | <?php |
328 | 328 | $salesforce_fields = $this->get_salesforce_object_fields( |
329 | 329 | array( |
330 | 330 | 'salesforce_object' => $salesforce_object, |
331 | 331 | ) |
332 | 332 | ); |
333 | - foreach ( $salesforce_fields as $salesforce_field ) { |
|
334 | - echo sprintf( '<option value="%1$s">%2$s</option>', |
|
335 | - esc_attr( $salesforce_field['name'] ), |
|
336 | - esc_html( $salesforce_field['label'] ) |
|
333 | + foreach ($salesforce_fields as $salesforce_field) { |
|
334 | + echo sprintf('<option value="%1$s">%2$s</option>', |
|
335 | + esc_attr($salesforce_field['name']), |
|
336 | + esc_html($salesforce_field['label']) |
|
337 | 337 | ); |
338 | 338 | } |
339 | 339 | ?> |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | </td> |
348 | 348 | <td class="column-direction"> |
349 | 349 | <div class="radios"> |
350 | - <label><input type="radio" value="sf_wp" name="direction[0]" id="direction-0-sf-wp" required> <?php echo esc_html__( 'Salesforce to WordPress', 'object-sync-for-salesforce' ); ?></label> |
|
351 | - <label><input type="radio" value="wp_sf" name="direction[0]" id="direction-0-wp-sf" required> <?php echo esc_html__( 'WordPress to Salesforce', 'object-sync-for-salesforce' ); ?></label> |
|
352 | - <label><input type="radio" value="sync" name="direction[0]" id="direction-0-sync" required checked> <?php echo esc_html__( 'Sync', 'object-sync-for-salesforce' ); ?></label> |
|
350 | + <label><input type="radio" value="sf_wp" name="direction[0]" id="direction-0-sf-wp" required> <?php echo esc_html__('Salesforce to WordPress', 'object-sync-for-salesforce'); ?></label> |
|
351 | + <label><input type="radio" value="wp_sf" name="direction[0]" id="direction-0-wp-sf" required> <?php echo esc_html__('WordPress to Salesforce', 'object-sync-for-salesforce'); ?></label> |
|
352 | + <label><input type="radio" value="sync" name="direction[0]" id="direction-0-sync" required checked> <?php echo esc_html__('Sync', 'object-sync-for-salesforce'); ?></label> |
|
353 | 353 | </div> |
354 | 354 | </td> |
355 | 355 | <td class="column-is_delete"> |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | </table> |
364 | 364 | <!--<div class="spinner"></div>--> |
365 | 365 | <?php |
366 | - if ( isset( $fieldmap_fields ) && null !== $fieldmap_fields ) { |
|
367 | - $add_button_label = esc_html__( 'Add another field mapping', 'object-sync-for-salesforce' ); |
|
366 | + if (isset($fieldmap_fields) && null !== $fieldmap_fields) { |
|
367 | + $add_button_label = esc_html__('Add another field mapping', 'object-sync-for-salesforce'); |
|
368 | 368 | } else { |
369 | - $add_button_label = esc_html__( 'Add field mapping', 'object-sync-for-salesforce' ); |
|
369 | + $add_button_label = esc_html__('Add field mapping', 'object-sync-for-salesforce'); |
|
370 | 370 | } |
371 | 371 | ?> |
372 | 372 | <p><button type="button" id="add-field-mapping" class="button button-secondary"><?php echo $add_button_label; ?></button></p> |
373 | - <p class="description"><?php echo esc_html__( 'Prematch tells the plugin to match records that have the same value before sending data to Salesforce. Salesforce Key indicates the Salesforce field is an External ID. If either of these is checked, the plugin will do an UPSERT to avoid duplicate data when possible.', 'object-sync-for-salesforce' ); ?></p> |
|
373 | + <p class="description"><?php echo esc_html__('Prematch tells the plugin to match records that have the same value before sending data to Salesforce. Salesforce Key indicates the Salesforce field is an External ID. If either of these is checked, the plugin will do an UPSERT to avoid duplicate data when possible.', 'object-sync-for-salesforce'); ?></p> |
|
374 | 374 | </fieldset> |
375 | 375 | <fieldset class="sync_triggers"> |
376 | - <legend><?php echo esc_html__( 'Action triggers', 'object-sync-for-salesforce' ); ?></legend> |
|
376 | + <legend><?php echo esc_html__('Action triggers', 'object-sync-for-salesforce'); ?></legend> |
|
377 | 377 | <div class="checkboxes"> |
378 | 378 | <?php |
379 | 379 | $wordpress_create_checked = ''; |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | $salesforce_create_checked = ''; |
383 | 383 | $salesforce_update_checked = ''; |
384 | 384 | $salesforce_delete_checked = ''; |
385 | - if ( isset( $sync_triggers ) && is_array( $sync_triggers ) ) { |
|
386 | - foreach ( $sync_triggers as $trigger ) { |
|
387 | - switch ( $trigger ) { |
|
385 | + if (isset($sync_triggers) && is_array($sync_triggers)) { |
|
386 | + foreach ($sync_triggers as $trigger) { |
|
387 | + switch ($trigger) { |
|
388 | 388 | case $this->mappings->sync_wordpress_create: |
389 | 389 | $wordpress_create_checked = ' checked'; |
390 | 390 | break; |
@@ -407,31 +407,31 @@ discard block |
||
407 | 407 | } |
408 | 408 | } |
409 | 409 | ?> |
410 | - <label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_create ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-create" <?php echo esc_attr( $wordpress_create_checked ); ?>><?php echo esc_html__( 'WordPress create', 'object-sync-for-salesforce' ); ?></label> |
|
411 | - <label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_update ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-update" <?php echo esc_attr( $wordpress_update_checked ); ?>><?php echo esc_html__( 'WordPress update', 'object-sync-for-salesforce' ); ?></label> |
|
412 | - <label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_wordpress_delete ); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-delete" <?php echo esc_attr( $wordpress_delete_checked ); ?>><?php echo esc_html__( 'WordPress delete', 'object-sync-for-salesforce' ); ?></label> |
|
413 | - <label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_create ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-create" <?php echo esc_attr( $salesforce_create_checked ); ?>><?php echo esc_html__( 'Salesforce create', 'object-sync-for-salesforce' ); ?></label> |
|
414 | - <label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_update ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-update" <?php echo esc_attr( $salesforce_update_checked ); ?>><?php echo esc_html__( 'Salesforce update', 'object-sync-for-salesforce' ); ?></label> |
|
415 | - <label><input type="checkbox" value="<?php echo esc_html( $this->mappings->sync_sf_delete ); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-delete" <?php echo esc_attr( $salesforce_delete_checked ); ?>><?php echo esc_html__( 'Salesforce delete', 'object-sync-for-salesforce' ); ?></label> |
|
410 | + <label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_create); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-create" <?php echo esc_attr($wordpress_create_checked); ?>><?php echo esc_html__('WordPress create', 'object-sync-for-salesforce'); ?></label> |
|
411 | + <label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_update); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-update" <?php echo esc_attr($wordpress_update_checked); ?>><?php echo esc_html__('WordPress update', 'object-sync-for-salesforce'); ?></label> |
|
412 | + <label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_wordpress_delete); ?>" name="sync_triggers[]" id="sync_triggers-wordpress-delete" <?php echo esc_attr($wordpress_delete_checked); ?>><?php echo esc_html__('WordPress delete', 'object-sync-for-salesforce'); ?></label> |
|
413 | + <label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_create); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-create" <?php echo esc_attr($salesforce_create_checked); ?>><?php echo esc_html__('Salesforce create', 'object-sync-for-salesforce'); ?></label> |
|
414 | + <label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_update); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-update" <?php echo esc_attr($salesforce_update_checked); ?>><?php echo esc_html__('Salesforce update', 'object-sync-for-salesforce'); ?></label> |
|
415 | + <label><input type="checkbox" value="<?php echo esc_html($this->mappings->sync_sf_delete); ?>" name="sync_triggers[]" id="sync_triggers-salesforce-delete" <?php echo esc_attr($salesforce_delete_checked); ?>><?php echo esc_html__('Salesforce delete', 'object-sync-for-salesforce'); ?></label> |
|
416 | 416 | <p class="description"> |
417 | 417 | <?php |
418 | 418 | // translators: placeholders are for the class names: salesforce_push and salesforce_pull |
419 | - echo sprintf( esc_html__( 'Select which actions on WordPress objects and Salesforce objects should trigger a synchronization. These settings are used by the %1$s and %2$s classes respectively.', 'object-sync-for-salesforce' ), '<code>salesforce_push</code>', '<code>salesforce_pull</code>' ); |
|
419 | + echo sprintf(esc_html__('Select which actions on WordPress objects and Salesforce objects should trigger a synchronization. These settings are used by the %1$s and %2$s classes respectively.', 'object-sync-for-salesforce'), '<code>salesforce_push</code>', '<code>salesforce_pull</code>'); |
|
420 | 420 | ?> |
421 | 421 | </p> |
422 | 422 | </div> |
423 | 423 | <div class="checkboxes"> |
424 | - <label><input type="checkbox" name="push_async" id="process-async" value="1" <?php echo isset( $push_async ) && '1' === $push_async ? ' checked' : ''; ?>><?php echo esc_html__( 'Process asynchronously', 'object-sync-for-salesforce' ); ?></label> |
|
424 | + <label><input type="checkbox" name="push_async" id="process-async" value="1" <?php echo isset($push_async) && '1' === $push_async ? ' checked' : ''; ?>><?php echo esc_html__('Process asynchronously', 'object-sync-for-salesforce'); ?></label> |
|
425 | 425 | <p class="description"> |
426 | 426 | <?php |
427 | 427 | // translators: placeholder is for WordPress cron method name |
428 | - echo sprintf( esc_html__( 'If selected, push data will be queued for processing and synchronized when %s is run. This may increase site performance, but changes will not be reflected in real time.', 'object-sync-for-salesforce' ), '<code>wp_cron</code>' ); |
|
428 | + echo sprintf(esc_html__('If selected, push data will be queued for processing and synchronized when %s is run. This may increase site performance, but changes will not be reflected in real time.', 'object-sync-for-salesforce'), '<code>wp_cron</code>'); |
|
429 | 429 | ?> |
430 | 430 | </p> |
431 | 431 | </div> |
432 | 432 | <div class="checkboxes"> |
433 | - <label><input type="checkbox" name="push_drafts" id="push-drafts" value="1" <?php echo isset( $push_drafts ) && '1' === $push_drafts ? ' checked' : ''; ?>><?php echo esc_html__( 'Push drafts', 'object-sync-for-salesforce' ); ?></label> |
|
434 | - <p class="description"><?php echo esc_html__( 'If selected, WordPress will send drafts of this object type (if it creates drafts for it) to Salesforce.', 'object-sync-for-salesforce' ); ?></p> |
|
433 | + <label><input type="checkbox" name="push_drafts" id="push-drafts" value="1" <?php echo isset($push_drafts) && '1' === $push_drafts ? ' checked' : ''; ?>><?php echo esc_html__('Push drafts', 'object-sync-for-salesforce'); ?></label> |
|
434 | + <p class="description"><?php echo esc_html__('If selected, WordPress will send drafts of this object type (if it creates drafts for it) to Salesforce.', 'object-sync-for-salesforce'); ?></p> |
|
435 | 435 | </div> |
436 | 436 | <?php |
437 | 437 | /* |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | <?php |
451 | 451 | submit_button( |
452 | 452 | // translators: the placeholder refers to the currently selected method (add, edit, or clone) |
453 | - sprintf( esc_html__( '%1$s fieldmap', 'object-sync-for-salesforce' ), ucfirst( $method ) ) |
|
453 | + sprintf(esc_html__('%1$s fieldmap', 'object-sync-for-salesforce'), ucfirst($method)) |
|
454 | 454 | ); |
455 | 455 | ?> |
456 | 456 | </form> |
@@ -22,27 +22,27 @@ discard block |
||
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 |
||
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 '; |
@@ -5,7 +5,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -21,15 +21,15 @@ discard block |
||
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 |
||
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 |
@@ -5,7 +5,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -19,13 +19,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -5,7 +5,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -24,24 +24,24 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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( |
@@ -5,7 +5,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | ); |