@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | protected $queue; |
27 | 27 | |
28 | 28 | /** |
29 | - * @var string |
|
30 | - */ |
|
29 | + * @var string |
|
30 | + */ |
|
31 | 31 | public $schedule_name; // allow for naming the queue in case there are multiple queues |
32 | 32 | |
33 | 33 | /** |
34 | - * Constructor which sets up push schedule |
|
35 | - * |
|
36 | - * @param object $wpdb |
|
37 | - * @param string $version |
|
38 | - * @param array $login_credentials |
|
39 | - * @param string $slug |
|
40 | - * @param string $option_prefix |
|
41 | - * @param object $wordpress |
|
42 | - * @param object $salesforce |
|
43 | - * @param object $mappings |
|
44 | - * @param object $logging |
|
45 | - * @param array $schedulable_classes |
|
46 | - * @param object $queue |
|
47 | - * @throws \Object_Sync_Sf_Exception |
|
48 | - */ |
|
34 | + * Constructor which sets up push schedule |
|
35 | + * |
|
36 | + * @param object $wpdb |
|
37 | + * @param string $version |
|
38 | + * @param array $login_credentials |
|
39 | + * @param string $slug |
|
40 | + * @param string $option_prefix |
|
41 | + * @param object $wordpress |
|
42 | + * @param object $salesforce |
|
43 | + * @param object $mappings |
|
44 | + * @param object $logging |
|
45 | + * @param array $schedulable_classes |
|
46 | + * @param object $queue |
|
47 | + * @throws \Object_Sync_Sf_Exception |
|
48 | + */ |
|
49 | 49 | public function __construct( $wpdb, $version, $login_credentials, $slug, $option_prefix, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) { |
50 | 50 | $this->wpdb = $wpdb; |
51 | 51 | $this->version = $version; |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | - * Create the action hooks based on what object maps exist from the admin settings. |
|
73 | - * We do not have any actions for blogroll at this time. |
|
74 | - * |
|
75 | - */ |
|
72 | + * Create the action hooks based on what object maps exist from the admin settings. |
|
73 | + * We do not have any actions for blogroll at this time. |
|
74 | + * |
|
75 | + */ |
|
76 | 76 | public function add_actions() { |
77 | 77 | $db_version = get_option( $this->option_prefix . 'db_version', false ); |
78 | 78 | if ( $db_version === $this->version ) { |
@@ -113,63 +113,63 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | - * Method for ajax hooks to call for pushing manually |
|
117 | - * |
|
118 | - * @param array $object |
|
119 | - * @param string $type |
|
120 | - * |
|
121 | - */ |
|
116 | + * Method for ajax hooks to call for pushing manually |
|
117 | + * |
|
118 | + * @param array $object |
|
119 | + * @param string $type |
|
120 | + * |
|
121 | + */ |
|
122 | 122 | public function manual_object_update( $object, $type ) { |
123 | 123 | $this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update, true ); |
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * Callback method for adding a user |
|
128 | - * |
|
129 | - * @param string $user_id |
|
130 | - */ |
|
127 | + * Callback method for adding a user |
|
128 | + * |
|
129 | + * @param string $user_id |
|
130 | + */ |
|
131 | 131 | public function add_user( $user_id ) { |
132 | 132 | $user = $this->wordpress->get_wordpress_object_data( 'user', $user_id ); |
133 | 133 | $this->object_insert( $user, 'user' ); |
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Callback method for adding a user via the Ultimate Member plugin |
|
138 | - * |
|
139 | - * @param string $user_id |
|
140 | - */ |
|
137 | + * Callback method for adding a user via the Ultimate Member plugin |
|
138 | + * |
|
139 | + * @param string $user_id |
|
140 | + */ |
|
141 | 141 | public function um_add_user( $user_id, $form_data = array() ) { |
142 | 142 | $this->object_insert( $form_data, 'user' ); |
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | - * Callback method for editing a user |
|
147 | - * |
|
148 | - * @param string $user_id |
|
149 | - * @param object $old_user_data |
|
150 | - */ |
|
146 | + * Callback method for editing a user |
|
147 | + * |
|
148 | + * @param string $user_id |
|
149 | + * @param object $old_user_data |
|
150 | + */ |
|
151 | 151 | public function edit_user( $user_id, $old_user_data ) { |
152 | 152 | $user = $this->wordpress->get_wordpress_object_data( 'user', $user_id ); |
153 | 153 | $this->object_update( $user, 'user' ); |
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
157 | - * Callback method for deleting a user |
|
158 | - * |
|
159 | - * @param string $user_id |
|
160 | - */ |
|
157 | + * Callback method for deleting a user |
|
158 | + * |
|
159 | + * @param string $user_id |
|
160 | + */ |
|
161 | 161 | public function delete_user( $user_id ) { |
162 | 162 | $user = $this->wordpress->get_wordpress_object_data( 'user', $user_id ); |
163 | 163 | $this->object_delete( $user, 'user' ); |
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | - * Callback method for posts of any type |
|
168 | - * This can handle create, update, and delete actions |
|
169 | - * |
|
170 | - * @param string $post_id |
|
171 | - * @param object $post |
|
172 | - */ |
|
167 | + * Callback method for posts of any type |
|
168 | + * This can handle create, update, and delete actions |
|
169 | + * |
|
170 | + * @param string $post_id |
|
171 | + * @param object $post |
|
172 | + */ |
|
173 | 173 | public function post_actions( $post_id, $post ) { |
174 | 174 | |
175 | 175 | $post_type = $post->post_type; |
@@ -216,66 +216,66 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
219 | - * Callback method for adding an attachment |
|
220 | - * |
|
221 | - * @param string $post_id |
|
222 | - */ |
|
219 | + * Callback method for adding an attachment |
|
220 | + * |
|
221 | + * @param string $post_id |
|
222 | + */ |
|
223 | 223 | public function add_attachment( $post_id ) { |
224 | 224 | $attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id ); |
225 | 225 | $this->object_insert( $attachment, 'attachment' ); |
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | - * Callback method for editing an attachment |
|
230 | - * |
|
231 | - * @param string $post_id |
|
232 | - */ |
|
229 | + * Callback method for editing an attachment |
|
230 | + * |
|
231 | + * @param string $post_id |
|
232 | + */ |
|
233 | 233 | public function edit_attachment( $post_id ) { |
234 | 234 | $attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id ); |
235 | 235 | $this->object_update( $attachment, 'attachment' ); |
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
239 | - * Callback method for editing an attachment |
|
240 | - * |
|
241 | - * @param string $post_id |
|
242 | - */ |
|
239 | + * Callback method for editing an attachment |
|
240 | + * |
|
241 | + * @param string $post_id |
|
242 | + */ |
|
243 | 243 | public function delete_attachment( $post_id ) { |
244 | 244 | $attachment = $this->wordpress->get_wordpress_object_data( 'attachment', $post_id ); |
245 | 245 | $this->object_delete( $attachment, 'attachment' ); |
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
249 | - * Callback method for adding a term |
|
250 | - * |
|
251 | - * @param string $term_id |
|
252 | - * @param string $tt_id |
|
253 | - * @param string $taxonomy |
|
254 | - */ |
|
249 | + * Callback method for adding a term |
|
250 | + * |
|
251 | + * @param string $term_id |
|
252 | + * @param string $tt_id |
|
253 | + * @param string $taxonomy |
|
254 | + */ |
|
255 | 255 | public function add_term( $term_id, $tt_id, $taxonomy ) { |
256 | 256 | $term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id ); |
257 | 257 | $this->object_insert( $term, $taxonomy ); |
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | - * Callback method for editing a term |
|
262 | - * |
|
263 | - * @param string $term_id |
|
264 | - * @param string $taxonomy |
|
265 | - */ |
|
261 | + * Callback method for editing a term |
|
262 | + * |
|
263 | + * @param string $term_id |
|
264 | + * @param string $taxonomy |
|
265 | + */ |
|
266 | 266 | public function edit_term( $term_id, $taxonomy ) { |
267 | 267 | $term = $this->wordpress->get_wordpress_object_data( $taxonomy, $term_id ); |
268 | 268 | $this->object_update( $term, $taxonomy ); |
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | - * Callback method for deleting a term |
|
273 | - * |
|
274 | - * @param int $term (id) |
|
275 | - * @param int $term_taxonomy_id |
|
276 | - * @param string $taxonomy (slug) |
|
277 | - * @param object $deleted_term |
|
278 | - */ |
|
272 | + * Callback method for deleting a term |
|
273 | + * |
|
274 | + * @param int $term (id) |
|
275 | + * @param int $term_taxonomy_id |
|
276 | + * @param string $taxonomy (slug) |
|
277 | + * @param object $deleted_term |
|
278 | + */ |
|
279 | 279 | public function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) { |
280 | 280 | $deleted_term = (array) $deleted_term; |
281 | 281 | $type = $deleted_term['taxonomy']; |
@@ -283,75 +283,75 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * Callback method for adding a comment |
|
287 | - * |
|
288 | - * @param string $comment_id |
|
289 | - * @param int|string comment_approved |
|
290 | - * @param array $commentdata |
|
291 | - */ |
|
286 | + * Callback method for adding a comment |
|
287 | + * |
|
288 | + * @param string $comment_id |
|
289 | + * @param int|string comment_approved |
|
290 | + * @param array $commentdata |
|
291 | + */ |
|
292 | 292 | public function add_comment( $comment_id, $comment_approved, $commentdata = array() ) { |
293 | 293 | $comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id ); |
294 | 294 | $this->object_insert( $comment, 'comment' ); |
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | - * Callback method for editing a comment |
|
299 | - * |
|
300 | - * @param string $comment_id |
|
301 | - */ |
|
298 | + * Callback method for editing a comment |
|
299 | + * |
|
300 | + * @param string $comment_id |
|
301 | + */ |
|
302 | 302 | public function edit_comment( $comment_id ) { |
303 | 303 | $comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id ); |
304 | 304 | $this->object_update( $comment, 'comment' ); |
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | - * Callback method for deleting a comment |
|
309 | - * |
|
310 | - * @param string $comment_id |
|
311 | - */ |
|
308 | + * Callback method for deleting a comment |
|
309 | + * |
|
310 | + * @param string $comment_id |
|
311 | + */ |
|
312 | 312 | public function delete_comment( $comment_id ) { |
313 | 313 | $comment = $this->wordpress->get_wordpress_object_data( 'comment', $comment_id ); |
314 | 314 | $this->object_delete( $comment, 'comment' ); |
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | - * Insert a new object |
|
319 | - * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class |
|
320 | - */ |
|
318 | + * Insert a new object |
|
319 | + * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class |
|
320 | + */ |
|
321 | 321 | private function object_insert( $object, $type ) { |
322 | 322 | $this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_create ); |
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
326 | - * Update an existing object |
|
327 | - * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class |
|
328 | - */ |
|
326 | + * Update an existing object |
|
327 | + * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class |
|
328 | + */ |
|
329 | 329 | private function object_update( $object, $type ) { |
330 | 330 | $this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_update ); |
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
334 | - * Delete an existing object |
|
335 | - * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class |
|
336 | - */ |
|
334 | + * Delete an existing object |
|
335 | + * This calls the overall push crud method, which controls queuing and sending data to the Salesforce class |
|
336 | + */ |
|
337 | 337 | private function object_delete( $object, $type ) { |
338 | 338 | $this->salesforce_push_object_crud( $type, $object, $this->mappings->sync_wordpress_delete ); |
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Push objects to Salesforce. |
|
343 | - * This method decides whether to do the processing immediately or queue it to the schedule class (or skip it based on another plugin's activity) |
|
344 | - * |
|
345 | - * @param string $object_type |
|
346 | - * Type of WordPress object. |
|
347 | - * @param array $object |
|
348 | - * The WordPress data that needs to be sent to Salesforce. |
|
349 | - * @param int $sf_sync_trigger |
|
350 | - * The trigger being responded to. |
|
351 | - * @param bool $manual |
|
352 | - * Are we calling this manually? |
|
353 | - * |
|
354 | - */ |
|
342 | + * Push objects to Salesforce. |
|
343 | + * This method decides whether to do the processing immediately or queue it to the schedule class (or skip it based on another plugin's activity) |
|
344 | + * |
|
345 | + * @param string $object_type |
|
346 | + * Type of WordPress object. |
|
347 | + * @param array $object |
|
348 | + * The WordPress data that needs to be sent to Salesforce. |
|
349 | + * @param int $sf_sync_trigger |
|
350 | + * The trigger being responded to. |
|
351 | + * @param bool $manual |
|
352 | + * Are we calling this manually? |
|
353 | + * |
|
354 | + */ |
|
355 | 355 | private function salesforce_push_object_crud( $object_type, $object, $sf_sync_trigger, $manual = false ) { |
356 | 356 | |
357 | 357 | $structure = $this->wordpress->get_wordpress_table_structure( $object_type ); |
@@ -475,20 +475,20 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
478 | - * Sync WordPress objects and Salesforce objects using the REST API. |
|
479 | - * |
|
480 | - * @param string $object_type |
|
481 | - * Type of WordPress object. |
|
482 | - * @param array|int $object|$object_id |
|
483 | - * The WordPress object data or its ID. |
|
484 | - * @param array $mapping|$mapping_id |
|
485 | - * Salesforce field mapping data array or ID. |
|
486 | - * @param int $sf_sync_trigger |
|
487 | - * Trigger for this sync. |
|
488 | - * |
|
489 | - * @return true or exit the method |
|
490 | - * |
|
491 | - */ |
|
478 | + * Sync WordPress objects and Salesforce objects using the REST API. |
|
479 | + * |
|
480 | + * @param string $object_type |
|
481 | + * Type of WordPress object. |
|
482 | + * @param array|int $object|$object_id |
|
483 | + * The WordPress object data or its ID. |
|
484 | + * @param array $mapping|$mapping_id |
|
485 | + * Salesforce field mapping data array or ID. |
|
486 | + * @param int $sf_sync_trigger |
|
487 | + * Trigger for this sync. |
|
488 | + * |
|
489 | + * @return true or exit the method |
|
490 | + * |
|
491 | + */ |
|
492 | 492 | public function salesforce_push_sync_rest( $object_type, $object, $mapping, $sf_sync_trigger ) { |
493 | 493 | |
494 | 494 | if ( is_int( $object ) ) { |
@@ -1041,21 +1041,21 @@ discard block |
||
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | /** |
1044 | - * Create an object map between a WordPress object and a Salesforce object |
|
1045 | - * |
|
1046 | - * @param array $wordpress_object |
|
1047 | - * Array of the WordPress object's data |
|
1048 | - * @param string $id_field_name |
|
1049 | - * How this object names its primary field. ie Id or comment_id or whatever |
|
1050 | - * @param string $salesforce_id |
|
1051 | - * Unique identifier for the Salesforce object |
|
1052 | - * @param array $field_mapping |
|
1053 | - * The row that maps the object types together, including which fields match which other fields |
|
1054 | - * |
|
1055 | - * @return int $wpdb->insert_id |
|
1056 | - * This is the database row for the map object |
|
1057 | - * |
|
1058 | - */ |
|
1044 | + * Create an object map between a WordPress object and a Salesforce object |
|
1045 | + * |
|
1046 | + * @param array $wordpress_object |
|
1047 | + * Array of the WordPress object's data |
|
1048 | + * @param string $id_field_name |
|
1049 | + * How this object names its primary field. ie Id or comment_id or whatever |
|
1050 | + * @param string $salesforce_id |
|
1051 | + * Unique identifier for the Salesforce object |
|
1052 | + * @param array $field_mapping |
|
1053 | + * The row that maps the object types together, including which fields match which other fields |
|
1054 | + * |
|
1055 | + * @return int $wpdb->insert_id |
|
1056 | + * This is the database row for the map object |
|
1057 | + * |
|
1058 | + */ |
|
1059 | 1059 | private function create_object_map( $wordpress_object, $id_field_name, $salesforce_id, $field_mapping, $pending = false ) { |
1060 | 1060 | |
1061 | 1061 | if ( true === $pending ) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | public $response; |
18 | 18 | |
19 | 19 | /** |
20 | - * Constructor which initializes the Salesforce APIs. |
|
21 | - * |
|
22 | - * @param string $consumer_key |
|
23 | - * Salesforce key to connect to your Salesforce instance. |
|
24 | - * @param string $consumer_secret |
|
25 | - * Salesforce secret to connect to your Salesforce instance. |
|
26 | - * @param string $login_url |
|
27 | - * Login URL for Salesforce auth requests - differs for production and sandbox |
|
28 | - * @param string $callback_url |
|
29 | - * WordPress URL where Salesforce should send you after authentication |
|
30 | - * @param string $authorize_path |
|
31 | - * Oauth path that Salesforce wants |
|
32 | - * @param string $token_path |
|
33 | - * Path Salesforce uses to give you a token |
|
34 | - * @param string $rest_api_version |
|
35 | - * What version of the Salesforce REST API to use |
|
36 | - * @param object $wordpress |
|
37 | - * Object for doing things to WordPress - retrieving data, cache, etc. |
|
38 | - * @param string $slug |
|
39 | - * Slug for this plugin. Can be used for file including, especially |
|
40 | - * @param string $option_prefix |
|
41 | - * Option prefix for this plugin. Used for getting and setting options, actions, etc. |
|
42 | - * @param object $logging |
|
43 | - * Logging object for this plugin. |
|
44 | - * @param array $schedulable_classes |
|
45 | - * array of classes that can have scheduled tasks specific to them |
|
46 | - */ |
|
20 | + * Constructor which initializes the Salesforce APIs. |
|
21 | + * |
|
22 | + * @param string $consumer_key |
|
23 | + * Salesforce key to connect to your Salesforce instance. |
|
24 | + * @param string $consumer_secret |
|
25 | + * Salesforce secret to connect to your Salesforce instance. |
|
26 | + * @param string $login_url |
|
27 | + * Login URL for Salesforce auth requests - differs for production and sandbox |
|
28 | + * @param string $callback_url |
|
29 | + * WordPress URL where Salesforce should send you after authentication |
|
30 | + * @param string $authorize_path |
|
31 | + * Oauth path that Salesforce wants |
|
32 | + * @param string $token_path |
|
33 | + * Path Salesforce uses to give you a token |
|
34 | + * @param string $rest_api_version |
|
35 | + * What version of the Salesforce REST API to use |
|
36 | + * @param object $wordpress |
|
37 | + * Object for doing things to WordPress - retrieving data, cache, etc. |
|
38 | + * @param string $slug |
|
39 | + * Slug for this plugin. Can be used for file including, especially |
|
40 | + * @param string $option_prefix |
|
41 | + * Option prefix for this plugin. Used for getting and setting options, actions, etc. |
|
42 | + * @param object $logging |
|
43 | + * Logging object for this plugin. |
|
44 | + * @param array $schedulable_classes |
|
45 | + * array of classes that can have scheduled tasks specific to them |
|
46 | + */ |
|
47 | 47 | public function __construct( $consumer_key, $consumer_secret, $login_url, $callback_url, $authorize_path, $token_path, $rest_api_version, $wordpress, $slug, $option_prefix, $logging, $schedulable_classes ) { |
48 | 48 | $this->consumer_key = $consumer_key; |
49 | 49 | $this->consumer_secret = $consumer_secret; |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | - * Converts a 15-character case-sensitive Salesforce ID to 18-character |
|
77 | - * case-insensitive ID. If input is not 15-characters, return input unaltered. |
|
78 | - * |
|
79 | - * @param string $sf_id_15 |
|
80 | - * 15-character case-sensitive Salesforce ID |
|
81 | - * @return string |
|
82 | - * 18-character case-insensitive Salesforce ID |
|
83 | - */ |
|
76 | + * Converts a 15-character case-sensitive Salesforce ID to 18-character |
|
77 | + * case-insensitive ID. If input is not 15-characters, return input unaltered. |
|
78 | + * |
|
79 | + * @param string $sf_id_15 |
|
80 | + * 15-character case-sensitive Salesforce ID |
|
81 | + * @return string |
|
82 | + * 18-character case-insensitive Salesforce ID |
|
83 | + */ |
|
84 | 84 | public static function convert_id( $sf_id_15 ) { |
85 | 85 | if ( strlen( $sf_id_15 ) !== 15 ) { |
86 | 86 | return $sf_id_15; |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * Given a Salesforce ID, return the corresponding SObject name. (Based on |
|
104 | - * keyPrefix from object definition, @see |
|
105 | - * https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ ) |
|
106 | - * |
|
107 | - * @param string $sf_id |
|
108 | - * 15- or 18-character Salesforce ID |
|
109 | - * @return string |
|
110 | - * sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE |
|
111 | - * if no match could be found. |
|
112 | - * @throws Object_Sync_Sf_Exception |
|
113 | - */ |
|
103 | + * Given a Salesforce ID, return the corresponding SObject name. (Based on |
|
104 | + * keyPrefix from object definition, @see |
|
105 | + * https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ ) |
|
106 | + * |
|
107 | + * @param string $sf_id |
|
108 | + * 15- or 18-character Salesforce ID |
|
109 | + * @return string |
|
110 | + * sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE |
|
111 | + * if no match could be found. |
|
112 | + * @throws Object_Sync_Sf_Exception |
|
113 | + */ |
|
114 | 114 | public function get_sobject_type( $sf_id ) { |
115 | 115 | $objects = $this->objects( |
116 | 116 | array( |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | - * Determine if this SF instance is fully configured. |
|
131 | - * |
|
132 | - */ |
|
130 | + * Determine if this SF instance is fully configured. |
|
131 | + * |
|
132 | + */ |
|
133 | 133 | public function is_authorized() { |
134 | 134 | return ! empty( $this->consumer_key ) && ! empty( $this->consumer_secret ) && $this->get_refresh_token(); |
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | - * Get REST API versions available on this Salesforce organization |
|
139 | - * This is not an authenticated call, so it would not be a helpful test |
|
140 | - */ |
|
138 | + * Get REST API versions available on this Salesforce organization |
|
139 | + * This is not an authenticated call, so it would not be a helpful test |
|
140 | + */ |
|
141 | 141 | public function get_api_versions() { |
142 | 142 | $options = array( |
143 | 143 | 'authenticated' => false, |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | - * Make a call to the Salesforce REST API. |
|
151 | - * |
|
152 | - * @param string $path |
|
153 | - * Path to resource. |
|
154 | - * @param array $params |
|
155 | - * Parameters to provide. |
|
156 | - * @param string $method |
|
157 | - * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
158 | - * @param array $options |
|
159 | - * Any method can supply options for the API call, and they'll be preserved as far as the curl request |
|
160 | - * They get merged with the class options |
|
161 | - * @param string $type |
|
162 | - * Type of call. Defaults to 'rest' - currently we don't support other types. |
|
163 | - * Other exammple in Drupal is 'apexrest' |
|
164 | - * |
|
165 | - * @return mixed |
|
166 | - * The requested response. |
|
167 | - * |
|
168 | - * @throws Object_Sync_Sf_Exception |
|
169 | - */ |
|
150 | + * Make a call to the Salesforce REST API. |
|
151 | + * |
|
152 | + * @param string $path |
|
153 | + * Path to resource. |
|
154 | + * @param array $params |
|
155 | + * Parameters to provide. |
|
156 | + * @param string $method |
|
157 | + * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
158 | + * @param array $options |
|
159 | + * Any method can supply options for the API call, and they'll be preserved as far as the curl request |
|
160 | + * They get merged with the class options |
|
161 | + * @param string $type |
|
162 | + * Type of call. Defaults to 'rest' - currently we don't support other types. |
|
163 | + * Other exammple in Drupal is 'apexrest' |
|
164 | + * |
|
165 | + * @return mixed |
|
166 | + * The requested response. |
|
167 | + * |
|
168 | + * @throws Object_Sync_Sf_Exception |
|
169 | + */ |
|
170 | 170 | public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) { |
171 | 171 | if ( ! $this->get_access_token() ) { |
172 | 172 | $this->refresh_token(); |
@@ -217,25 +217,25 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
220 | - * Private helper to issue an SF API request. |
|
221 | - * This method is the only place where we read to or write from the cache |
|
222 | - * |
|
223 | - * @param string $path |
|
224 | - * Path to resource. |
|
225 | - * @param array $params |
|
226 | - * Parameters to provide. |
|
227 | - * @param string $method |
|
228 | - * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
229 | - * @param array $options |
|
230 | - * This is the options array from the api_call method |
|
231 | - * This is where it gets merged with $this->options |
|
232 | - * @param string $type |
|
233 | - * Type of call. Defaults to 'rest' - currently we don't support other types |
|
234 | - * Other exammple in Drupal is 'apexrest' |
|
235 | - * |
|
236 | - * @return array |
|
237 | - * The requested data. |
|
238 | - */ |
|
220 | + * Private helper to issue an SF API request. |
|
221 | + * This method is the only place where we read to or write from the cache |
|
222 | + * |
|
223 | + * @param string $path |
|
224 | + * Path to resource. |
|
225 | + * @param array $params |
|
226 | + * Parameters to provide. |
|
227 | + * @param string $method |
|
228 | + * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
229 | + * @param array $options |
|
230 | + * This is the options array from the api_call method |
|
231 | + * This is where it gets merged with $this->options |
|
232 | + * @param string $type |
|
233 | + * Type of call. Defaults to 'rest' - currently we don't support other types |
|
234 | + * Other exammple in Drupal is 'apexrest' |
|
235 | + * |
|
236 | + * @return array |
|
237 | + * The requested data. |
|
238 | + */ |
|
239 | 239 | protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) { |
240 | 240 | $options = array_merge( $this->options, $options ); // this will override a value in $this->options with the one in $options if there is a matching key |
241 | 241 | $url = $this->get_api_endpoint( $type ) . $path; |
@@ -313,22 +313,22 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
316 | - * Make the HTTP request. Wrapper around curl(). |
|
317 | - * |
|
318 | - * @param string $url |
|
319 | - * Path to make request from. |
|
320 | - * @param array $data |
|
321 | - * The request body. |
|
322 | - * @param array $headers |
|
323 | - * Request headers to send as name => value. |
|
324 | - * @param string $method |
|
325 | - * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
326 | - * @param array $options |
|
327 | - * This is the options array from the api_http_request method |
|
328 | - * |
|
329 | - * @return array |
|
330 | - * Salesforce response object. |
|
331 | - */ |
|
316 | + * Make the HTTP request. Wrapper around curl(). |
|
317 | + * |
|
318 | + * @param string $url |
|
319 | + * Path to make request from. |
|
320 | + * @param array $data |
|
321 | + * The request body. |
|
322 | + * @param array $headers |
|
323 | + * Request headers to send as name => value. |
|
324 | + * @param string $method |
|
325 | + * Method to initiate the call, such as GET or POST. Defaults to GET. |
|
326 | + * @param array $options |
|
327 | + * This is the options array from the api_http_request method |
|
328 | + * |
|
329 | + * @return array |
|
330 | + * Salesforce response object. |
|
331 | + */ |
|
332 | 332 | protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) { |
333 | 333 | // Build the request, including path and headers. Internal use. |
334 | 334 | |
@@ -463,14 +463,14 @@ discard block |
||
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
466 | - * Get the API end point for a given type of the API. |
|
467 | - * |
|
468 | - * @param string $api_type |
|
469 | - * E.g., rest, partner, enterprise. |
|
470 | - * |
|
471 | - * @return string |
|
472 | - * Complete URL endpoint for API access. |
|
473 | - */ |
|
466 | + * Get the API end point for a given type of the API. |
|
467 | + * |
|
468 | + * @param string $api_type |
|
469 | + * E.g., rest, partner, enterprise. |
|
470 | + * |
|
471 | + * @return string |
|
472 | + * Complete URL endpoint for API access. |
|
473 | + */ |
|
474 | 474 | public function get_api_endpoint( $api_type = 'rest' ) { |
475 | 475 | // Special handling for apexrest, since it's not in the identity object. |
476 | 476 | if ( 'apexrest' === $api_type ) { |
@@ -486,67 +486,67 @@ discard block |
||
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
489 | - * Get the SF instance URL. Useful for linking to objects. |
|
490 | - */ |
|
489 | + * Get the SF instance URL. Useful for linking to objects. |
|
490 | + */ |
|
491 | 491 | public function get_instance_url() { |
492 | 492 | return get_option( $this->option_prefix . 'instance_url', '' ); |
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
496 | - * Set the SF instanc URL. |
|
497 | - * |
|
498 | - * @param string $url |
|
499 | - * URL to set. |
|
500 | - */ |
|
496 | + * Set the SF instanc URL. |
|
497 | + * |
|
498 | + * @param string $url |
|
499 | + * URL to set. |
|
500 | + */ |
|
501 | 501 | protected function set_instance_url( $url ) { |
502 | 502 | update_option( $this->option_prefix . 'instance_url', $url ); |
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
506 | - * Get the access token. |
|
507 | - */ |
|
506 | + * Get the access token. |
|
507 | + */ |
|
508 | 508 | public function get_access_token() { |
509 | 509 | return get_option( $this->option_prefix . 'access_token', '' ); |
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
513 | - * Set the access token. |
|
514 | - * |
|
515 | - * It is stored in session. |
|
516 | - * |
|
517 | - * @param string $token |
|
518 | - * Access token from Salesforce. |
|
519 | - */ |
|
513 | + * Set the access token. |
|
514 | + * |
|
515 | + * It is stored in session. |
|
516 | + * |
|
517 | + * @param string $token |
|
518 | + * Access token from Salesforce. |
|
519 | + */ |
|
520 | 520 | protected function set_access_token( $token ) { |
521 | 521 | update_option( $this->option_prefix . 'access_token', $token ); |
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
525 | - * Get refresh token. |
|
526 | - */ |
|
525 | + * Get refresh token. |
|
526 | + */ |
|
527 | 527 | protected function get_refresh_token() { |
528 | 528 | return get_option( $this->option_prefix . 'refresh_token', '' ); |
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
532 | - * Set refresh token. |
|
533 | - * |
|
534 | - * @param string $token |
|
535 | - * Refresh token from Salesforce. |
|
536 | - */ |
|
532 | + * Set refresh token. |
|
533 | + * |
|
534 | + * @param string $token |
|
535 | + * Refresh token from Salesforce. |
|
536 | + */ |
|
537 | 537 | protected function set_refresh_token( $token ) { |
538 | 538 | update_option( $this->option_prefix . 'refresh_token', $token ); |
539 | 539 | } |
540 | 540 | |
541 | 541 | /** |
542 | - * Refresh access token based on the refresh token. Updates session variable. |
|
543 | - * |
|
544 | - * todo: figure out how to do this as part of the schedule class |
|
545 | - * this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to. |
|
546 | - * but it could be a performance boost to do it at scheduleable intervals instead. |
|
547 | - * |
|
548 | - * @throws Object_Sync_Sf_Exception |
|
549 | - */ |
|
542 | + * Refresh access token based on the refresh token. Updates session variable. |
|
543 | + * |
|
544 | + * todo: figure out how to do this as part of the schedule class |
|
545 | + * this is a scheduleable class and so we could add a method from this class to run every 24 hours, but it's unclear to me that we need it. salesforce seems to refresh itself as it needs to. |
|
546 | + * but it could be a performance boost to do it at scheduleable intervals instead. |
|
547 | + * |
|
548 | + * @throws Object_Sync_Sf_Exception |
|
549 | + */ |
|
550 | 550 | protected function refresh_token() { |
551 | 551 | $refresh_token = $this->get_refresh_token(); |
552 | 552 | if ( empty( $refresh_token ) ) { |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
596 | - * Retrieve and store the Salesforce identity given an ID url. |
|
597 | - * |
|
598 | - * @param string $id |
|
599 | - * Identity URL. |
|
600 | - * |
|
601 | - * @throws Object_Sync_Sf_Exception |
|
602 | - */ |
|
596 | + * Retrieve and store the Salesforce identity given an ID url. |
|
597 | + * |
|
598 | + * @param string $id |
|
599 | + * Identity URL. |
|
600 | + * |
|
601 | + * @throws Object_Sync_Sf_Exception |
|
602 | + */ |
|
603 | 603 | protected function set_identity( $id ) { |
604 | 604 | $headers = array( |
605 | 605 | 'Authorization' => 'Authorization: OAuth ' . $this->get_access_token(), |
@@ -615,18 +615,18 @@ discard block |
||
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
618 | - * Return the Salesforce identity, which is stored in a variable. |
|
619 | - * |
|
620 | - * @return array |
|
621 | - * Returns FALSE if no identity has been stored. |
|
622 | - */ |
|
618 | + * Return the Salesforce identity, which is stored in a variable. |
|
619 | + * |
|
620 | + * @return array |
|
621 | + * Returns FALSE if no identity has been stored. |
|
622 | + */ |
|
623 | 623 | public function get_identity() { |
624 | 624 | return get_option( $this->option_prefix . 'identity', false ); |
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
628 | - * OAuth step 1: Redirect to Salesforce and request and authorization code. |
|
629 | - */ |
|
628 | + * OAuth step 1: Redirect to Salesforce and request and authorization code. |
|
629 | + */ |
|
630 | 630 | public function get_authorization_code() { |
631 | 631 | $url = add_query_arg( |
632 | 632 | array( |
@@ -640,11 +640,11 @@ discard block |
||
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
643 | - * OAuth step 2: Exchange an authorization code for an access token. |
|
644 | - * |
|
645 | - * @param string $code |
|
646 | - * Code from Salesforce. |
|
647 | - */ |
|
643 | + * OAuth step 2: Exchange an authorization code for an access token. |
|
644 | + * |
|
645 | + * @param string $code |
|
646 | + * Code from Salesforce. |
|
647 | + */ |
|
648 | 648 | public function request_token( $code ) { |
649 | 649 | $data = array( |
650 | 650 | 'code' => $code, |
@@ -689,22 +689,22 @@ discard block |
||
689 | 689 | /* Core API calls */ |
690 | 690 | |
691 | 691 | /** |
692 | - * Available objects and their metadata for your organization's data. |
|
693 | - * |
|
694 | - * @param array $conditions |
|
695 | - * Associative array of filters to apply to the returned objects. Filters |
|
696 | - * are applied after the list is returned from Salesforce. |
|
697 | - * @param bool $reset |
|
698 | - * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
699 | - * |
|
700 | - * @return array |
|
701 | - * Available objects and metadata. |
|
702 | - * |
|
703 | - * part of core API calls. this call does require authentication, and the basic url it becomes is like this: |
|
704 | - * https://instance.salesforce.com/services/data/v#.0/sobjects |
|
705 | - * |
|
706 | - * updateable is really how the api spells it |
|
707 | - */ |
|
692 | + * Available objects and their metadata for your organization's data. |
|
693 | + * |
|
694 | + * @param array $conditions |
|
695 | + * Associative array of filters to apply to the returned objects. Filters |
|
696 | + * are applied after the list is returned from Salesforce. |
|
697 | + * @param bool $reset |
|
698 | + * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
699 | + * |
|
700 | + * @return array |
|
701 | + * Available objects and metadata. |
|
702 | + * |
|
703 | + * part of core API calls. this call does require authentication, and the basic url it becomes is like this: |
|
704 | + * https://instance.salesforce.com/services/data/v#.0/sobjects |
|
705 | + * |
|
706 | + * updateable is really how the api spells it |
|
707 | + */ |
|
708 | 708 | public function objects( |
709 | 709 | $conditions = array( |
710 | 710 | 'updateable' => true, |
@@ -734,22 +734,22 @@ discard block |
||
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
737 | - * Use SOQL to get objects based on query string. |
|
738 | - * |
|
739 | - * @param string $query |
|
740 | - * The SOQL query. |
|
741 | - * @param array $options |
|
742 | - * Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc. |
|
743 | - * @param boolean $all |
|
744 | - * Whether this should get all results for the query |
|
745 | - * @param boolean $explain |
|
746 | - * If set, Salesforce will return feedback on the query performance |
|
747 | - * |
|
748 | - * @return array |
|
749 | - * Array of Salesforce objects that match the query. |
|
750 | - * |
|
751 | - * part of core API calls |
|
752 | - */ |
|
737 | + * Use SOQL to get objects based on query string. |
|
738 | + * |
|
739 | + * @param string $query |
|
740 | + * The SOQL query. |
|
741 | + * @param array $options |
|
742 | + * Allow for the query to have options based on what the user needs from it, ie caching, read/write, etc. |
|
743 | + * @param boolean $all |
|
744 | + * Whether this should get all results for the query |
|
745 | + * @param boolean $explain |
|
746 | + * If set, Salesforce will return feedback on the query performance |
|
747 | + * |
|
748 | + * @return array |
|
749 | + * Array of Salesforce objects that match the query. |
|
750 | + * |
|
751 | + * part of core API calls |
|
752 | + */ |
|
753 | 753 | public function query( $query, $options = array(), $all = false, $explain = false ) { |
754 | 754 | $search_data = [ |
755 | 755 | 'q' => (string) $query, |
@@ -769,19 +769,19 @@ discard block |
||
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
772 | - * Retrieve all the metadata for an object. |
|
773 | - * |
|
774 | - * @param string $name |
|
775 | - * Object type name, E.g., Contact, Account, etc. |
|
776 | - * @param bool $reset |
|
777 | - * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
778 | - * |
|
779 | - * @return array |
|
780 | - * All the metadata for an object, including information about each field, |
|
781 | - * URLs, and child relationships. |
|
782 | - * |
|
783 | - * part of core API calls |
|
784 | - */ |
|
772 | + * Retrieve all the metadata for an object. |
|
773 | + * |
|
774 | + * @param string $name |
|
775 | + * Object type name, E.g., Contact, Account, etc. |
|
776 | + * @param bool $reset |
|
777 | + * Whether to reset the cache and retrieve a fresh version from Salesforce. |
|
778 | + * |
|
779 | + * @return array |
|
780 | + * All the metadata for an object, including information about each field, |
|
781 | + * URLs, and child relationships. |
|
782 | + * |
|
783 | + * part of core API calls |
|
784 | + */ |
|
785 | 785 | public function object_describe( $name, $reset = false ) { |
786 | 786 | if ( empty( $name ) ) { |
787 | 787 | return array(); |
@@ -809,26 +809,26 @@ discard block |
||
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
812 | - * Create a new object of the given type. |
|
813 | - * |
|
814 | - * @param string $name |
|
815 | - * Object type name, E.g., Contact, Account, etc. |
|
816 | - * @param array $params |
|
817 | - * Values of the fields to set for the object. |
|
818 | - * |
|
819 | - * @return array |
|
820 | - * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
821 | - * code: 201 |
|
822 | - * data: |
|
823 | - * "id" : "00190000001pPvHAAU", |
|
824 | - * "success" : true |
|
825 | - * "errors" : [ ], |
|
826 | - * from_cache: |
|
827 | - * cached: |
|
828 | - * is_redo: |
|
829 | - * |
|
830 | - * part of core API calls |
|
831 | - */ |
|
812 | + * Create a new object of the given type. |
|
813 | + * |
|
814 | + * @param string $name |
|
815 | + * Object type name, E.g., Contact, Account, etc. |
|
816 | + * @param array $params |
|
817 | + * Values of the fields to set for the object. |
|
818 | + * |
|
819 | + * @return array |
|
820 | + * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
821 | + * code: 201 |
|
822 | + * data: |
|
823 | + * "id" : "00190000001pPvHAAU", |
|
824 | + * "success" : true |
|
825 | + * "errors" : [ ], |
|
826 | + * from_cache: |
|
827 | + * cached: |
|
828 | + * is_redo: |
|
829 | + * |
|
830 | + * part of core API calls |
|
831 | + */ |
|
832 | 832 | public function object_create( $name, $params ) { |
833 | 833 | $options = array( |
834 | 834 | 'type' => 'write', |
@@ -838,34 +838,34 @@ discard block |
||
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
841 | - * Create new records or update existing records. |
|
842 | - * |
|
843 | - * The new records or updated records are based on the value of the specified |
|
844 | - * field. If the value is not unique, REST API returns a 300 response with |
|
845 | - * the list of matching records. |
|
846 | - * |
|
847 | - * @param string $name |
|
848 | - * Object type name, E.g., Contact, Account. |
|
849 | - * @param string $key |
|
850 | - * The field to check if this record should be created or updated. |
|
851 | - * @param string $value |
|
852 | - * The value for this record of the field specified for $key. |
|
853 | - * @param array $params |
|
854 | - * Values of the fields to set for the object. |
|
855 | - * |
|
856 | - * @return array |
|
857 | - * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
858 | - * code: 201 |
|
859 | - * data: |
|
860 | - * "id" : "00190000001pPvHAAU", |
|
861 | - * "success" : true |
|
862 | - * "errors" : [ ], |
|
863 | - * from_cache: |
|
864 | - * cached: |
|
865 | - * is_redo: |
|
866 | - * |
|
867 | - * part of core API calls |
|
868 | - */ |
|
841 | + * Create new records or update existing records. |
|
842 | + * |
|
843 | + * The new records or updated records are based on the value of the specified |
|
844 | + * field. If the value is not unique, REST API returns a 300 response with |
|
845 | + * the list of matching records. |
|
846 | + * |
|
847 | + * @param string $name |
|
848 | + * Object type name, E.g., Contact, Account. |
|
849 | + * @param string $key |
|
850 | + * The field to check if this record should be created or updated. |
|
851 | + * @param string $value |
|
852 | + * The value for this record of the field specified for $key. |
|
853 | + * @param array $params |
|
854 | + * Values of the fields to set for the object. |
|
855 | + * |
|
856 | + * @return array |
|
857 | + * json: {"id":"00190000001pPvHAAU","success":true,"errors":[]} |
|
858 | + * code: 201 |
|
859 | + * data: |
|
860 | + * "id" : "00190000001pPvHAAU", |
|
861 | + * "success" : true |
|
862 | + * "errors" : [ ], |
|
863 | + * from_cache: |
|
864 | + * cached: |
|
865 | + * is_redo: |
|
866 | + * |
|
867 | + * part of core API calls |
|
868 | + */ |
|
869 | 869 | public function object_upsert( $name, $key, $value, $params ) { |
870 | 870 | $options = array( |
871 | 871 | 'type' => 'write', |
@@ -887,27 +887,27 @@ discard block |
||
887 | 887 | } |
888 | 888 | |
889 | 889 | /** |
890 | - * Update an existing object. |
|
891 | - * |
|
892 | - * @param string $name |
|
893 | - * Object type name, E.g., Contact, Account. |
|
894 | - * @param string $id |
|
895 | - * Salesforce id of the object. |
|
896 | - * @param array $params |
|
897 | - * Values of the fields to set for the object. |
|
898 | - * |
|
899 | - * part of core API calls |
|
900 | - * |
|
901 | - * @return array |
|
902 | - * json: {"success":true,"body":""} |
|
903 | - * code: 204 |
|
904 | - * data: |
|
890 | + * Update an existing object. |
|
891 | + * |
|
892 | + * @param string $name |
|
893 | + * Object type name, E.g., Contact, Account. |
|
894 | + * @param string $id |
|
895 | + * Salesforce id of the object. |
|
896 | + * @param array $params |
|
897 | + * Values of the fields to set for the object. |
|
898 | + * |
|
899 | + * part of core API calls |
|
900 | + * |
|
901 | + * @return array |
|
902 | + * json: {"success":true,"body":""} |
|
903 | + * code: 204 |
|
904 | + * data: |
|
905 | 905 | success: 1 |
906 | 906 | body: |
907 | - * from_cache: |
|
908 | - * cached: |
|
909 | - * is_redo: |
|
910 | - */ |
|
907 | + * from_cache: |
|
908 | + * cached: |
|
909 | + * is_redo: |
|
910 | + */ |
|
911 | 911 | public function object_update( $name, $id, $params ) { |
912 | 912 | $options = array( |
913 | 913 | 'type' => 'write', |
@@ -917,62 +917,62 @@ discard block |
||
917 | 917 | } |
918 | 918 | |
919 | 919 | /** |
920 | - * Return a full loaded Salesforce object. |
|
921 | - * |
|
922 | - * @param string $name |
|
923 | - * Object type name, E.g., Contact, Account. |
|
924 | - * @param string $id |
|
925 | - * Salesforce id of the object. |
|
926 | - * |
|
927 | - * @return object |
|
928 | - * Object of the requested Salesforce object. |
|
929 | - * |
|
930 | - * part of core API calls |
|
931 | - */ |
|
920 | + * Return a full loaded Salesforce object. |
|
921 | + * |
|
922 | + * @param string $name |
|
923 | + * Object type name, E.g., Contact, Account. |
|
924 | + * @param string $id |
|
925 | + * Salesforce id of the object. |
|
926 | + * |
|
927 | + * @return object |
|
928 | + * Object of the requested Salesforce object. |
|
929 | + * |
|
930 | + * part of core API calls |
|
931 | + */ |
|
932 | 932 | public function object_read( $name, $id ) { |
933 | 933 | return $this->api_call( "sobjects/{$name}/{$id}", array(), 'GET' ); |
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
937 | - * Make a call to the Analytics API |
|
938 | - * |
|
939 | - * @param string $name |
|
940 | - * Object type name, E.g., Report |
|
941 | - * @param string $id |
|
942 | - * Salesforce id of the object. |
|
943 | - * @param string $route |
|
944 | - * What comes after the ID? E.g. instances, ?includeDetails=True |
|
945 | - * @param array $params |
|
946 | - * Params to put with the request |
|
947 | - * @param string $method |
|
948 | - * GET or POST |
|
949 | - * |
|
950 | - * @return object |
|
951 | - * Object of the requested Salesforce object. |
|
952 | - * |
|
953 | - * part of core API calls |
|
954 | - */ |
|
937 | + * Make a call to the Analytics API |
|
938 | + * |
|
939 | + * @param string $name |
|
940 | + * Object type name, E.g., Report |
|
941 | + * @param string $id |
|
942 | + * Salesforce id of the object. |
|
943 | + * @param string $route |
|
944 | + * What comes after the ID? E.g. instances, ?includeDetails=True |
|
945 | + * @param array $params |
|
946 | + * Params to put with the request |
|
947 | + * @param string $method |
|
948 | + * GET or POST |
|
949 | + * |
|
950 | + * @return object |
|
951 | + * Object of the requested Salesforce object. |
|
952 | + * |
|
953 | + * part of core API calls |
|
954 | + */ |
|
955 | 955 | public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) { |
956 | 956 | return $this->api_call( "analytics/{$name}/{$id}/{$route}", $params, $method ); |
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
960 | - * Run a specific Analytics report |
|
961 | - * |
|
962 | - * @param string $id |
|
963 | - * Salesforce id of the object. |
|
964 | - * @param bool $async |
|
965 | - * Whether the report is asynchronous |
|
966 | - * @param array $params |
|
967 | - * Params to put with the request |
|
968 | - * @param string $method |
|
969 | - * GET or POST |
|
970 | - * |
|
971 | - * @return object |
|
972 | - * Object of the requested Salesforce object. |
|
973 | - * |
|
974 | - * part of core API calls |
|
975 | - */ |
|
960 | + * Run a specific Analytics report |
|
961 | + * |
|
962 | + * @param string $id |
|
963 | + * Salesforce id of the object. |
|
964 | + * @param bool $async |
|
965 | + * Whether the report is asynchronous |
|
966 | + * @param array $params |
|
967 | + * Params to put with the request |
|
968 | + * @param string $method |
|
969 | + * GET or POST |
|
970 | + * |
|
971 | + * @return object |
|
972 | + * Object of the requested Salesforce object. |
|
973 | + * |
|
974 | + * part of core API calls |
|
975 | + */ |
|
976 | 976 | public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) { |
977 | 977 | |
978 | 978 | $id = $this->convert_id( $id ); |
@@ -1058,36 +1058,36 @@ discard block |
||
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | /** |
1061 | - * Return a full loaded Salesforce object from External ID. |
|
1062 | - * |
|
1063 | - * @param string $name |
|
1064 | - * Object type name, E.g., Contact, Account. |
|
1065 | - * @param string $field |
|
1066 | - * Salesforce external id field name. |
|
1067 | - * @param string $value |
|
1068 | - * Value of external id. |
|
1069 | - * |
|
1070 | - * @return object |
|
1071 | - * Object of the requested Salesforce object. |
|
1072 | - * |
|
1073 | - * part of core API calls |
|
1074 | - */ |
|
1061 | + * Return a full loaded Salesforce object from External ID. |
|
1062 | + * |
|
1063 | + * @param string $name |
|
1064 | + * Object type name, E.g., Contact, Account. |
|
1065 | + * @param string $field |
|
1066 | + * Salesforce external id field name. |
|
1067 | + * @param string $value |
|
1068 | + * Value of external id. |
|
1069 | + * |
|
1070 | + * @return object |
|
1071 | + * Object of the requested Salesforce object. |
|
1072 | + * |
|
1073 | + * part of core API calls |
|
1074 | + */ |
|
1075 | 1075 | public function object_readby_external_id( $name, $field, $value ) { |
1076 | 1076 | return $this->api_call( "sobjects/{$name}/{$field}/{$value}" ); |
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | /** |
1080 | - * Delete a Salesforce object. |
|
1081 | - * |
|
1082 | - * @param string $name |
|
1083 | - * Object type name, E.g., Contact, Account. |
|
1084 | - * @param string $id |
|
1085 | - * Salesforce id of the object. |
|
1086 | - * |
|
1087 | - * @return array |
|
1088 | - * |
|
1089 | - * part of core API calls |
|
1090 | - */ |
|
1080 | + * Delete a Salesforce object. |
|
1081 | + * |
|
1082 | + * @param string $name |
|
1083 | + * Object type name, E.g., Contact, Account. |
|
1084 | + * @param string $id |
|
1085 | + * Salesforce id of the object. |
|
1086 | + * |
|
1087 | + * @return array |
|
1088 | + * |
|
1089 | + * part of core API calls |
|
1090 | + */ |
|
1091 | 1091 | public function object_delete( $name, $id ) { |
1092 | 1092 | $options = array( |
1093 | 1093 | 'type' => 'write', |
@@ -1097,17 +1097,17 @@ discard block |
||
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | /** |
1100 | - * Retrieves the list of individual objects that have been deleted within the |
|
1101 | - * given timespan for a specified object type. |
|
1102 | - * |
|
1103 | - * @param string $type |
|
1104 | - * Object type name, E.g., Contact, Account. |
|
1105 | - * @param string $startDate |
|
1106 | - * Start date to check for deleted objects (in ISO 8601 format). |
|
1107 | - * @param string $endDate |
|
1108 | - * End date to check for deleted objects (in ISO 8601 format). |
|
1109 | - * @return GetDeletedResult |
|
1110 | - */ |
|
1100 | + * Retrieves the list of individual objects that have been deleted within the |
|
1101 | + * given timespan for a specified object type. |
|
1102 | + * |
|
1103 | + * @param string $type |
|
1104 | + * Object type name, E.g., Contact, Account. |
|
1105 | + * @param string $startDate |
|
1106 | + * Start date to check for deleted objects (in ISO 8601 format). |
|
1107 | + * @param string $endDate |
|
1108 | + * End date to check for deleted objects (in ISO 8601 format). |
|
1109 | + * @return GetDeletedResult |
|
1110 | + */ |
|
1111 | 1111 | public function get_deleted( $type, $start_date, $end_date ) { |
1112 | 1112 | $options = array( |
1113 | 1113 | 'cache' => false, |
@@ -1117,13 +1117,13 @@ discard block |
||
1117 | 1117 | |
1118 | 1118 | |
1119 | 1119 | /** |
1120 | - * Return a list of available resources for the configured API version. |
|
1121 | - * |
|
1122 | - * @return array |
|
1123 | - * Associative array keyed by name with a URI value. |
|
1124 | - * |
|
1125 | - * part of core API calls |
|
1126 | - */ |
|
1120 | + * Return a list of available resources for the configured API version. |
|
1121 | + * |
|
1122 | + * @return array |
|
1123 | + * Associative array keyed by name with a URI value. |
|
1124 | + * |
|
1125 | + * part of core API calls |
|
1126 | + */ |
|
1127 | 1127 | public function list_resources() { |
1128 | 1128 | $resources = $this->api_call( '' ); |
1129 | 1129 | foreach ( $resources as $key => $path ) { |
@@ -1133,31 +1133,31 @@ discard block |
||
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | /** |
1136 | - * Return a list of SFIDs for the given object, which have been created or |
|
1137 | - * updated in the given timeframe. |
|
1138 | - * |
|
1139 | - * @param string $type |
|
1140 | - * Object type name, E.g., Contact, Account. |
|
1141 | - * |
|
1142 | - * @param int $start |
|
1143 | - * unix timestamp for older timeframe for updates. |
|
1144 | - * Defaults to "-29 days" if empty. |
|
1145 | - * |
|
1146 | - * @param int $end |
|
1147 | - * unix timestamp for end of timeframe for updates. |
|
1148 | - * Defaults to now if empty |
|
1149 | - * |
|
1150 | - * @return array |
|
1151 | - * return array has 2 indexes: |
|
1152 | - * "ids": a list of SFIDs of those records which have been created or |
|
1153 | - * updated in the given timeframe. |
|
1154 | - * "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date |
|
1155 | - * covered in the request. |
|
1156 | - * |
|
1157 | - * @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm |
|
1158 | - * |
|
1159 | - * part of core API calls |
|
1160 | - */ |
|
1136 | + * Return a list of SFIDs for the given object, which have been created or |
|
1137 | + * updated in the given timeframe. |
|
1138 | + * |
|
1139 | + * @param string $type |
|
1140 | + * Object type name, E.g., Contact, Account. |
|
1141 | + * |
|
1142 | + * @param int $start |
|
1143 | + * unix timestamp for older timeframe for updates. |
|
1144 | + * Defaults to "-29 days" if empty. |
|
1145 | + * |
|
1146 | + * @param int $end |
|
1147 | + * unix timestamp for end of timeframe for updates. |
|
1148 | + * Defaults to now if empty |
|
1149 | + * |
|
1150 | + * @return array |
|
1151 | + * return array has 2 indexes: |
|
1152 | + * "ids": a list of SFIDs of those records which have been created or |
|
1153 | + * updated in the given timeframe. |
|
1154 | + * "latestDateCovered": ISO 8601 format timestamp (UTC) of the last date |
|
1155 | + * covered in the request. |
|
1156 | + * |
|
1157 | + * @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_getupdated.htm |
|
1158 | + * |
|
1159 | + * part of core API calls |
|
1160 | + */ |
|
1161 | 1161 | public function get_updated( $type, $start = null, $end = null ) { |
1162 | 1162 | if ( empty( $start ) ) { |
1163 | 1163 | $start = strtotime( '-29 days' ); |
@@ -1176,19 +1176,19 @@ discard block |
||
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | /** |
1179 | - * Given a DeveloperName and SObject Name, return the SFID of the |
|
1180 | - * corresponding RecordType. DeveloperName doesn't change between Salesforce |
|
1181 | - * environments, so it's safer to rely on compared to SFID. |
|
1182 | - * |
|
1183 | - * @param string $name |
|
1184 | - * Object type name, E.g., Contact, Account. |
|
1185 | - * |
|
1186 | - * @param string $devname |
|
1187 | - * RecordType DeveloperName, e.g. Donation, Membership, etc. |
|
1188 | - * |
|
1189 | - * @return string SFID |
|
1190 | - * The Salesforce ID of the given Record Type, or null. |
|
1191 | - */ |
|
1179 | + * Given a DeveloperName and SObject Name, return the SFID of the |
|
1180 | + * corresponding RecordType. DeveloperName doesn't change between Salesforce |
|
1181 | + * environments, so it's safer to rely on compared to SFID. |
|
1182 | + * |
|
1183 | + * @param string $name |
|
1184 | + * Object type name, E.g., Contact, Account. |
|
1185 | + * |
|
1186 | + * @param string $devname |
|
1187 | + * RecordType DeveloperName, e.g. Donation, Membership, etc. |
|
1188 | + * |
|
1189 | + * @return string SFID |
|
1190 | + * The Salesforce ID of the given Record Type, or null. |
|
1191 | + */ |
|
1192 | 1192 | |
1193 | 1193 | public function get_record_type_id_by_developer_name( $name, $devname, $reset = false ) { |
1194 | 1194 | |
@@ -1216,10 +1216,10 @@ discard block |
||
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | /** |
1219 | - * If there is a WordPress setting for how long to keep the cache, return it and set the object property |
|
1220 | - * Otherwise, return seconds in 24 hours |
|
1221 | - * |
|
1222 | - */ |
|
1219 | + * If there is a WordPress setting for how long to keep the cache, return it and set the object property |
|
1220 | + * Otherwise, return seconds in 24 hours |
|
1221 | + * |
|
1222 | + */ |
|
1223 | 1223 | private function cache_expiration() { |
1224 | 1224 | $cache_expiration = $this->wordpress->cache_expiration( $this->option_prefix . 'cache_expiration', 86400 ); |
1225 | 1225 | return $cache_expiration; |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | protected $queue; |
27 | 27 | |
28 | 28 | /** |
29 | - * @var string |
|
30 | - */ |
|
29 | + * @var string |
|
30 | + */ |
|
31 | 31 | public $schedule_name; // allow for naming the queue in case there are multiple queues |
32 | 32 | |
33 | 33 | /** |
34 | - * Constructor which sets up pull schedule |
|
35 | - * |
|
36 | - * @param object $wpdb |
|
37 | - * @param string $version |
|
38 | - * @param array $login_credentials |
|
39 | - * @param string $slug |
|
40 | - * @param string $option_prefix |
|
41 | - * @param object $wordpress |
|
42 | - * @param object $salesforce |
|
43 | - * @param object $mappings |
|
44 | - * @param object $logging |
|
45 | - * @param array $schedulable_classes |
|
46 | - * @param object $queue |
|
47 | - * @throws \Exception |
|
48 | - */ |
|
34 | + * Constructor which sets up pull schedule |
|
35 | + * |
|
36 | + * @param object $wpdb |
|
37 | + * @param string $version |
|
38 | + * @param array $login_credentials |
|
39 | + * @param string $slug |
|
40 | + * @param string $option_prefix |
|
41 | + * @param object $wordpress |
|
42 | + * @param object $salesforce |
|
43 | + * @param object $mappings |
|
44 | + * @param object $logging |
|
45 | + * @param array $schedulable_classes |
|
46 | + * @param object $queue |
|
47 | + * @throws \Exception |
|
48 | + */ |
|
49 | 49 | public function __construct( $wpdb, $version, $login_credentials, $slug, $option_prefix, $wordpress, $salesforce, $mappings, $logging, $schedulable_classes, $queue ) { |
50 | 50 | $this->wpdb = $wpdb; |
51 | 51 | $this->version = $version; |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | - * Create the action hooks based on what object maps exist from the admin settings |
|
73 | - * |
|
74 | - */ |
|
72 | + * Create the action hooks based on what object maps exist from the admin settings |
|
73 | + * |
|
74 | + */ |
|
75 | 75 | public function add_actions() { |
76 | 76 | |
77 | 77 | // ajax hook |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * Ajax callback for salesforce pull. Returns status of 200 for successful |
|
87 | - * attempt or 403 for a failed pull attempt (SF not authorized, threshhold |
|
88 | - * reached, etc. |
|
89 | - * this is the ajax callback; not a cron run |
|
90 | - */ |
|
86 | + * Ajax callback for salesforce pull. Returns status of 200 for successful |
|
87 | + * attempt or 403 for a failed pull attempt (SF not authorized, threshhold |
|
88 | + * reached, etc. |
|
89 | + * this is the ajax callback; not a cron run |
|
90 | + */ |
|
91 | 91 | public function salesforce_pull_webhook() { |
92 | 92 | |
93 | 93 | if ( true === $this->salesforce_pull() ) { |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | - * Callback for the standard pull process used by webhooks and cron. |
|
117 | - */ |
|
116 | + * Callback for the standard pull process used by webhooks and cron. |
|
117 | + */ |
|
118 | 118 | public function salesforce_pull() { |
119 | 119 | $sfapi = $this->salesforce['sfapi']; |
120 | 120 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Determines if the Salesforce pull should be allowed, or throttled. |
|
138 | - * |
|
139 | - * Prevents too many pull processes from running at once. |
|
140 | - * |
|
141 | - * @return bool |
|
142 | - * Returns false if the time elapsed between recent pulls is too short. |
|
143 | - */ |
|
137 | + * Determines if the Salesforce pull should be allowed, or throttled. |
|
138 | + * |
|
139 | + * Prevents too many pull processes from running at once. |
|
140 | + * |
|
141 | + * @return bool |
|
142 | + * Returns false if the time elapsed between recent pulls is too short. |
|
143 | + */ |
|
144 | 144 | private function check_throttle() { |
145 | 145 | $pull_throttle = get_option( $this->option_prefix . 'pull_throttle', 5 ); |
146 | 146 | $last_sync = get_option( $this->option_prefix . 'pull_last_sync', 0 ); |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | - * Pull updated records from Salesforce and place them in the queue. |
|
157 | - * |
|
158 | - * Executes a SOQL query based on defined mappings, loops through the results, |
|
159 | - * and places each updated SF object into the queue for later processing. |
|
160 | - * |
|
161 | - * We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF |
|
162 | - * |
|
163 | - */ |
|
156 | + * Pull updated records from Salesforce and place them in the queue. |
|
157 | + * |
|
158 | + * Executes a SOQL query based on defined mappings, loops through the results, |
|
159 | + * and places each updated SF object into the queue for later processing. |
|
160 | + * |
|
161 | + * We copy the convention from the Drupal module here, and run a separate SOQL query for each type of object in SF |
|
162 | + * |
|
163 | + */ |
|
164 | 164 | private function get_updated_records() { |
165 | 165 | $sfapi = $this->salesforce['sfapi']; |
166 | 166 | foreach ( $this->mappings->get_fieldmaps() as $salesforce_mapping ) { |
@@ -344,18 +344,18 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | - * Given a SObject type name, build an SOQL query to include all fields for all |
|
348 | - * SalesforceMappings mapped to that SObject. |
|
349 | - * |
|
350 | - * @param string $type |
|
351 | - * e.g. "Contact", "Account", etc. |
|
352 | - * |
|
353 | - * @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields |
|
354 | - * were found. |
|
355 | - * |
|
356 | - * @see Object_Sync_Sf_Mapping::get_mapped_fields |
|
357 | - * @see Object_Sync_Sf_Mapping::get_mapped_record_types |
|
358 | - */ |
|
347 | + * Given a SObject type name, build an SOQL query to include all fields for all |
|
348 | + * SalesforceMappings mapped to that SObject. |
|
349 | + * |
|
350 | + * @param string $type |
|
351 | + * e.g. "Contact", "Account", etc. |
|
352 | + * |
|
353 | + * @return Object_Sync_Sf_Salesforce_Select_Query or null if no mappings or no mapped fields |
|
354 | + * were found. |
|
355 | + * |
|
356 | + * @see Object_Sync_Sf_Mapping::get_mapped_fields |
|
357 | + * @see Object_Sync_Sf_Mapping::get_mapped_record_types |
|
358 | + */ |
|
359 | 359 | private function get_pull_query( $type, $salesforce_mapping = array() ) { |
360 | 360 | $mapped_fields = array(); |
361 | 361 | $mapped_record_types = array(); |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
443 | - * Get deleted records from salesforce. |
|
444 | - * Note that deletions can only be queried via REST with an API version >= 29.0. |
|
445 | - * |
|
446 | - */ |
|
443 | + * Get deleted records from salesforce. |
|
444 | + * Note that deletions can only be queried via REST with an API version >= 29.0. |
|
445 | + * |
|
446 | + */ |
|
447 | 447 | private function get_deleted_records() { |
448 | 448 | |
449 | 449 | $sfapi = $this->salesforce['sfapi']; |
@@ -544,13 +544,13 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
547 | - * Method for ajax hooks to call for pulling manually |
|
548 | - * |
|
549 | - * @param string $object_type |
|
550 | - * @param string $salesforce_id |
|
551 | - * @param string $wordpress_object |
|
552 | - * |
|
553 | - */ |
|
547 | + * Method for ajax hooks to call for pulling manually |
|
548 | + * |
|
549 | + * @param string $object_type |
|
550 | + * @param string $salesforce_id |
|
551 | + * @param string $wordpress_object |
|
552 | + * |
|
553 | + */ |
|
554 | 554 | public function manual_pull( $object_type, $salesforce_id, $wordpress_object ) { |
555 | 555 | $sfapi = $this->salesforce['sfapi']; |
556 | 556 | $object = $sfapi->api_call( 'sobjects/' . $object_type . '/' . $salesforce_id ); |
@@ -565,20 +565,20 @@ discard block |
||
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
568 | - * Sync WordPress objects and Salesforce objects from the queue using the REST API. |
|
569 | - * |
|
570 | - * @param string $object_type |
|
571 | - * Type of Salesforce object. |
|
572 | - * @param array|string $object |
|
573 | - * The Salesforce data or its Id value. |
|
574 | - * @param array|int $mapping |
|
575 | - * Salesforce/WP mapping data or its id. |
|
576 | - * @param int $sf_sync_trigger |
|
577 | - * Trigger for this sync. |
|
578 | - * |
|
579 | - * @return true or exit the method |
|
580 | - * |
|
581 | - */ |
|
568 | + * Sync WordPress objects and Salesforce objects from the queue using the REST API. |
|
569 | + * |
|
570 | + * @param string $object_type |
|
571 | + * Type of Salesforce object. |
|
572 | + * @param array|string $object |
|
573 | + * The Salesforce data or its Id value. |
|
574 | + * @param array|int $mapping |
|
575 | + * Salesforce/WP mapping data or its id. |
|
576 | + * @param int $sf_sync_trigger |
|
577 | + * Trigger for this sync. |
|
578 | + * |
|
579 | + * @return true or exit the method |
|
580 | + * |
|
581 | + */ |
|
582 | 582 | public function salesforce_pull_process_records( $object_type, $object, $mapping, $sf_sync_trigger ) { |
583 | 583 | |
584 | 584 | $sfapi = $this->salesforce['sfapi']; |
@@ -1308,19 +1308,19 @@ discard block |
||
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | /** |
1311 | - * Create an object map between a Salesforce object and a WordPress object |
|
1312 | - * |
|
1313 | - * @param array $salesforce_object |
|
1314 | - * Array of the salesforce object's data |
|
1315 | - * @param string $wordpress_id |
|
1316 | - * Unique identifier for the WordPress object |
|
1317 | - * @param array $field_mapping |
|
1318 | - * The row that maps the object types together, including which fields match which other fields |
|
1319 | - * |
|
1320 | - * @return int $wpdb->insert_id |
|
1321 | - * This is the database row for the map object |
|
1322 | - * |
|
1323 | - */ |
|
1311 | + * Create an object map between a Salesforce object and a WordPress object |
|
1312 | + * |
|
1313 | + * @param array $salesforce_object |
|
1314 | + * Array of the salesforce object's data |
|
1315 | + * @param string $wordpress_id |
|
1316 | + * Unique identifier for the WordPress object |
|
1317 | + * @param array $field_mapping |
|
1318 | + * The row that maps the object types together, including which fields match which other fields |
|
1319 | + * |
|
1320 | + * @return int $wpdb->insert_id |
|
1321 | + * This is the database row for the map object |
|
1322 | + * |
|
1323 | + */ |
|
1324 | 1324 | private function create_object_map( $salesforce_object, $wordpress_id, $field_mapping ) { |
1325 | 1325 | // Create object map and save it |
1326 | 1326 | $mapping_object = $this->mappings->create_object_map( |
@@ -28,76 +28,76 @@ discard block |
||
28 | 28 | protected $queue; |
29 | 29 | |
30 | 30 | /** |
31 | - * @var string |
|
32 | - * Default path for the Salesforce authorize URL |
|
33 | - */ |
|
31 | + * @var string |
|
32 | + * Default path for the Salesforce authorize URL |
|
33 | + */ |
|
34 | 34 | public $default_authorize_url_path; |
35 | 35 | |
36 | 36 | /** |
37 | - * @var string |
|
38 | - * Default path for the Salesforce token URL |
|
39 | - */ |
|
37 | + * @var string |
|
38 | + * Default path for the Salesforce token URL |
|
39 | + */ |
|
40 | 40 | public $default_token_url_path; |
41 | 41 | |
42 | 42 | /** |
43 | - * @var string |
|
44 | - * What version of the Salesforce API should be the default on the settings screen. |
|
45 | - * Users can edit this, but they won't see a correct list of all their available versions until WordPress has |
|
46 | - * been authenticated with Salesforce. |
|
47 | - */ |
|
43 | + * @var string |
|
44 | + * What version of the Salesforce API should be the default on the settings screen. |
|
45 | + * Users can edit this, but they won't see a correct list of all their available versions until WordPress has |
|
46 | + * been authenticated with Salesforce. |
|
47 | + */ |
|
48 | 48 | public $default_api_version; |
49 | 49 | |
50 | 50 | /** |
51 | - * @var int |
|
52 | - * Default max number of pull records |
|
53 | - * Users can edit this |
|
54 | - */ |
|
51 | + * @var int |
|
52 | + * Default max number of pull records |
|
53 | + * Users can edit this |
|
54 | + */ |
|
55 | 55 | public $default_pull_limit; |
56 | 56 | |
57 | 57 | /** |
58 | - * @var int |
|
59 | - * Default pull throttle for how often Salesforce can pull |
|
60 | - * Users can edit this |
|
61 | - */ |
|
58 | + * @var int |
|
59 | + * Default pull throttle for how often Salesforce can pull |
|
60 | + * Users can edit this |
|
61 | + */ |
|
62 | 62 | public $default_pull_throttle; |
63 | 63 | |
64 | 64 | /** |
65 | - * @var bool |
|
66 | - * Default for whether to limit to triggerable items |
|
67 | - * Users can edit this |
|
68 | - */ |
|
65 | + * @var bool |
|
66 | + * Default for whether to limit to triggerable items |
|
67 | + * Users can edit this |
|
68 | + */ |
|
69 | 69 | public $default_triggerable; |
70 | 70 | |
71 | 71 | /** |
72 | - * @var bool |
|
73 | - * Default for whether to limit to updateable items |
|
74 | - * Users can edit this |
|
75 | - */ |
|
72 | + * @var bool |
|
73 | + * Default for whether to limit to updateable items |
|
74 | + * Users can edit this |
|
75 | + */ |
|
76 | 76 | public $default_updateable; |
77 | 77 | |
78 | 78 | /** |
79 | - * @var string |
|
80 | - * Suffix for action group name |
|
81 | - */ |
|
79 | + * @var string |
|
80 | + * Suffix for action group name |
|
81 | + */ |
|
82 | 82 | public $action_group_suffix; |
83 | 83 | |
84 | 84 | /** |
85 | - * Constructor which sets up admin pages |
|
86 | - * |
|
87 | - * @param object $wpdb |
|
88 | - * @param string $version |
|
89 | - * @param array $login_credentials |
|
90 | - * @param string $slug |
|
91 | - * @param object $wordpress |
|
92 | - * @param object $salesforce |
|
93 | - * @param object $mappings |
|
94 | - * @param object $push |
|
95 | - * @param object $pull |
|
96 | - * @param object $logging |
|
97 | - * @param array $schedulable_classes |
|
98 | - * @param object $queue |
|
99 | - * @throws \Exception |
|
100 | - */ |
|
85 | + * Constructor which sets up admin pages |
|
86 | + * |
|
87 | + * @param object $wpdb |
|
88 | + * @param string $version |
|
89 | + * @param array $login_credentials |
|
90 | + * @param string $slug |
|
91 | + * @param object $wordpress |
|
92 | + * @param object $salesforce |
|
93 | + * @param object $mappings |
|
94 | + * @param object $push |
|
95 | + * @param object $pull |
|
96 | + * @param object $logging |
|
97 | + * @param array $schedulable_classes |
|
98 | + * @param object $queue |
|
99 | + * @throws \Exception |
|
100 | + */ |
|
101 | 101 | public function __construct( $wpdb, $version, $login_credentials, $slug, $option_prefix, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) { |
102 | 102 | $this->wpdb = $wpdb; |
103 | 103 | $this->version = $version; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Create the action hooks to create the admin page(s) |
|
141 | - * |
|
142 | - */ |
|
140 | + * Create the action hooks to create the admin page(s) |
|
141 | + * |
|
142 | + */ |
|
143 | 143 | public function add_actions() { |
144 | 144 | add_action( 'admin_init', array( $this, 'salesforce_settings_forms' ) ); |
145 | 145 | add_action( 'admin_init', array( $this, 'notices' ) ); |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Recurring task to check Salesforce for data |
|
178 | - * |
|
179 | - */ |
|
177 | + * Recurring task to check Salesforce for data |
|
178 | + * |
|
179 | + */ |
|
180 | 180 | public function change_action_schedule( $old_schedule, $new_schedule, $option_name ) { |
181 | 181 | |
182 | 182 | // exit if nothing changed |
@@ -212,21 +212,21 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | - * Create WordPress admin options page |
|
216 | - * |
|
217 | - */ |
|
215 | + * Create WordPress admin options page |
|
216 | + * |
|
217 | + */ |
|
218 | 218 | public function create_admin_menu() { |
219 | 219 | $title = __( 'Salesforce', 'object-sync-for-salesforce' ); |
220 | 220 | add_options_page( $title, $title, 'configure_salesforce', 'object-sync-salesforce-admin', array( $this, 'show_admin_page' ) ); |
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * Render full admin pages in WordPress |
|
225 | - * This allows other plugins to add tabs to the Salesforce settings screen |
|
226 | - * |
|
227 | - * todo: better front end: html, organization of html into templates, css, js |
|
228 | - * |
|
229 | - */ |
|
224 | + * Render full admin pages in WordPress |
|
225 | + * This allows other plugins to add tabs to the Salesforce settings screen |
|
226 | + * |
|
227 | + * todo: better front end: html, organization of html into templates, css, js |
|
228 | + * |
|
229 | + */ |
|
230 | 230 | public function show_admin_page() { |
231 | 231 | $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING ); |
232 | 232 | echo '<div class="wrap">'; |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | - * Create default WordPress admin settings form for salesforce |
|
440 | - * This is for the Settings page/tab |
|
441 | - * |
|
442 | - */ |
|
439 | + * Create default WordPress admin settings form for salesforce |
|
440 | + * This is for the Settings page/tab |
|
441 | + * |
|
442 | + */ |
|
443 | 443 | public function salesforce_settings_forms() { |
444 | 444 | $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING ); |
445 | 445 | $page = isset( $get_data['tab'] ) ? sanitize_key( $get_data['tab'] ) : 'settings'; |
@@ -464,13 +464,13 @@ discard block |
||
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
467 | - * Fields for the Settings tab |
|
468 | - * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
469 | - * |
|
470 | - * @param string $page |
|
471 | - * @param string $section |
|
472 | - * @param string $input_callback |
|
473 | - */ |
|
467 | + * Fields for the Settings tab |
|
468 | + * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
469 | + * |
|
470 | + * @param string $page |
|
471 | + * @param string $section |
|
472 | + * @param string $input_callback |
|
473 | + */ |
|
474 | 474 | private function fields_settings( $page, $section, $callbacks ) { |
475 | 475 | add_settings_section( $page, ucwords( $page ), null, $page ); |
476 | 476 | $salesforce_settings = array( |
@@ -717,25 +717,25 @@ discard block |
||
717 | 717 | } |
718 | 718 | |
719 | 719 | /** |
720 | - * Fields for the Fieldmaps tab |
|
721 | - * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
722 | - * |
|
723 | - * @param string $page |
|
724 | - * @param string $section |
|
725 | - * @param string $input_callback |
|
726 | - */ |
|
720 | + * Fields for the Fieldmaps tab |
|
721 | + * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
722 | + * |
|
723 | + * @param string $page |
|
724 | + * @param string $section |
|
725 | + * @param string $input_callback |
|
726 | + */ |
|
727 | 727 | private function fields_fieldmaps( $page, $section, $input_callback = '' ) { |
728 | 728 | add_settings_section( $page, ucwords( $page ), null, $page ); |
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
732 | - * Fields for the Scheduling tab |
|
733 | - * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
734 | - * |
|
735 | - * @param string $page |
|
736 | - * @param string $section |
|
737 | - * @param string $input_callback |
|
738 | - */ |
|
732 | + * Fields for the Scheduling tab |
|
733 | + * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
734 | + * |
|
735 | + * @param string $page |
|
736 | + * @param string $section |
|
737 | + * @param string $input_callback |
|
738 | + */ |
|
739 | 739 | private function fields_scheduling( $page, $section, $callbacks ) { |
740 | 740 | |
741 | 741 | add_settings_section( $page, ucwords( $page ), null, $page ); |
@@ -844,13 +844,13 @@ discard block |
||
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
847 | - * Fields for the Log Settings tab |
|
848 | - * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
849 | - * |
|
850 | - * @param string $page |
|
851 | - * @param string $section |
|
852 | - * @param array $callbacks |
|
853 | - */ |
|
847 | + * Fields for the Log Settings tab |
|
848 | + * This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option |
|
849 | + * |
|
850 | + * @param string $page |
|
851 | + * @param string $section |
|
852 | + * @param array $callbacks |
|
853 | + */ |
|
854 | 854 | private function fields_log_settings( $page, $section, $callbacks ) { |
855 | 855 | add_settings_section( $page, ucwords( str_replace( '_', ' ', $page ) ), null, $page ); |
856 | 856 | $log_settings = array( |
@@ -1028,9 +1028,9 @@ discard block |
||
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | /** |
1031 | - * Create the notices, settings, and conditions by which admin notices should appear |
|
1032 | - * |
|
1033 | - */ |
|
1031 | + * Create the notices, settings, and conditions by which admin notices should appear |
|
1032 | + * |
|
1033 | + */ |
|
1034 | 1034 | public function notices() { |
1035 | 1035 | |
1036 | 1036 | // before a notice is displayed, we should make sure we are on a page related to this plugin |
@@ -1103,14 +1103,14 @@ discard block |
||
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | /** |
1106 | - * Get all the Salesforce object settings for fieldmapping |
|
1107 | - * This takes either the $_POST array via ajax, or can be directly called with a $data array |
|
1108 | - * |
|
1109 | - * @param array $data |
|
1110 | - * data must contain a salesforce_object |
|
1111 | - * can optionally contain a type |
|
1112 | - * @return array $object_settings |
|
1113 | - */ |
|
1106 | + * Get all the Salesforce object settings for fieldmapping |
|
1107 | + * This takes either the $_POST array via ajax, or can be directly called with a $data array |
|
1108 | + * |
|
1109 | + * @param array $data |
|
1110 | + * data must contain a salesforce_object |
|
1111 | + * can optionally contain a type |
|
1112 | + * @return array $object_settings |
|
1113 | + */ |
|
1114 | 1114 | public function get_salesforce_object_description( $data = array() ) { |
1115 | 1115 | $ajax = false; |
1116 | 1116 | if ( empty( $data ) ) { |
@@ -1158,13 +1158,13 @@ discard block |
||
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | /** |
1161 | - * Get Salesforce object fields for fieldmapping |
|
1162 | - * |
|
1163 | - * @param array $data |
|
1164 | - * data must contain a salesforce_object |
|
1165 | - * can optionally contain a type for the field |
|
1166 | - * @return array $object_fields |
|
1167 | - */ |
|
1161 | + * Get Salesforce object fields for fieldmapping |
|
1162 | + * |
|
1163 | + * @param array $data |
|
1164 | + * data must contain a salesforce_object |
|
1165 | + * can optionally contain a type for the field |
|
1166 | + * @return array $object_fields |
|
1167 | + */ |
|
1168 | 1168 | public function get_salesforce_object_fields( $data = array() ) { |
1169 | 1169 | |
1170 | 1170 | if ( ! empty( $data['salesforce_object'] ) ) { |
@@ -1192,12 +1192,12 @@ discard block |
||
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | /** |
1195 | - * Get WordPress object fields for fieldmapping |
|
1196 | - * This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field |
|
1197 | - * |
|
1198 | - * @param string $wordpress_object |
|
1199 | - * @return array $object_fields |
|
1200 | - */ |
|
1195 | + * Get WordPress object fields for fieldmapping |
|
1196 | + * This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field |
|
1197 | + * |
|
1198 | + * @param string $wordpress_object |
|
1199 | + * @return array $object_fields |
|
1200 | + */ |
|
1201 | 1201 | public function get_wordpress_object_fields( $wordpress_object = '' ) { |
1202 | 1202 | $ajax = false; |
1203 | 1203 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
@@ -1216,13 +1216,13 @@ discard block |
||
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | /** |
1219 | - * Get WordPress and Salesforce object fields together for fieldmapping |
|
1220 | - * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $salesforce_object fields |
|
1221 | - * |
|
1222 | - * @param string $wordpress_object |
|
1223 | - * @param string $salesforce_object |
|
1224 | - * @return array $object_fields |
|
1225 | - */ |
|
1219 | + * Get WordPress and Salesforce object fields together for fieldmapping |
|
1220 | + * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $salesforce_object fields |
|
1221 | + * |
|
1222 | + * @param string $wordpress_object |
|
1223 | + * @param string $salesforce_object |
|
1224 | + * @return array $object_fields |
|
1225 | + */ |
|
1226 | 1226 | public function get_wp_sf_object_fields( $wordpress_object = '', $salesforce = '' ) { |
1227 | 1227 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
1228 | 1228 | if ( empty( $wordpress_object ) ) { |
@@ -1247,12 +1247,12 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | /** |
1250 | - * Manually push the WordPress object to Salesforce |
|
1251 | - * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields |
|
1252 | - * |
|
1253 | - * @param string $wordpress_object |
|
1254 | - * @param int $wordpress_id |
|
1255 | - */ |
|
1250 | + * Manually push the WordPress object to Salesforce |
|
1251 | + * This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields |
|
1252 | + * |
|
1253 | + * @param string $wordpress_object |
|
1254 | + * @param int $wordpress_id |
|
1255 | + */ |
|
1256 | 1256 | public function push_to_salesforce( $wordpress_object = '', $wordpress_id = '' ) { |
1257 | 1257 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
1258 | 1258 | if ( empty( $wordpress_object ) && empty( $wordpress_id ) ) { |
@@ -1271,12 +1271,12 @@ discard block |
||
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | /** |
1274 | - * Manually pull the Salesforce object into WordPress |
|
1275 | - * This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields |
|
1276 | - * |
|
1277 | - * @param string $salesforce_id |
|
1278 | - * @param string $wordpress_object |
|
1279 | - */ |
|
1274 | + * Manually pull the Salesforce object into WordPress |
|
1275 | + * This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields |
|
1276 | + * |
|
1277 | + * @param string $salesforce_id |
|
1278 | + * @param string $wordpress_object |
|
1279 | + */ |
|
1280 | 1280 | public function pull_from_salesforce( $salesforce_id = '', $wordpress_object = '' ) { |
1281 | 1281 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
1282 | 1282 | if ( empty( $wordpress_object ) && empty( $salesforce_id ) ) { |
@@ -1293,11 +1293,11 @@ discard block |
||
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | /** |
1296 | - * Manually pull the Salesforce object into WordPress |
|
1297 | - * This takes an id for a mapping object row |
|
1298 | - * |
|
1299 | - * @param int $mapping_id |
|
1300 | - */ |
|
1296 | + * Manually pull the Salesforce object into WordPress |
|
1297 | + * This takes an id for a mapping object row |
|
1298 | + * |
|
1299 | + * @param int $mapping_id |
|
1300 | + */ |
|
1301 | 1301 | public function refresh_mapped_data( $mapping_id = '' ) { |
1302 | 1302 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
1303 | 1303 | if ( empty( $mapping_id ) ) { |
@@ -1316,13 +1316,13 @@ discard block |
||
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | /** |
1319 | - * Prepare fieldmap data and redirect after processing |
|
1320 | - * This runs when the create or update forms are submitted |
|
1321 | - * It is public because it depends on an admin hook |
|
1322 | - * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page |
|
1323 | - * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success |
|
1324 | - * |
|
1325 | - */ |
|
1319 | + * Prepare fieldmap data and redirect after processing |
|
1320 | + * This runs when the create or update forms are submitted |
|
1321 | + * It is public because it depends on an admin hook |
|
1322 | + * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page |
|
1323 | + * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success |
|
1324 | + * |
|
1325 | + */ |
|
1326 | 1326 | public function prepare_fieldmap_data() { |
1327 | 1327 | $error = false; |
1328 | 1328 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
@@ -1370,12 +1370,12 @@ discard block |
||
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | /** |
1373 | - * Delete fieldmap data and redirect after processing |
|
1374 | - * This runs when the delete link is clicked, after the user confirms |
|
1375 | - * It is public because it depends on an admin hook |
|
1376 | - * It then calls the Object_Sync_Sf_Mapping class and the delete method |
|
1377 | - * |
|
1378 | - */ |
|
1373 | + * Delete fieldmap data and redirect after processing |
|
1374 | + * This runs when the delete link is clicked, after the user confirms |
|
1375 | + * It is public because it depends on an admin hook |
|
1376 | + * It then calls the Object_Sync_Sf_Mapping class and the delete method |
|
1377 | + * |
|
1378 | + */ |
|
1379 | 1379 | public function delete_fieldmap() { |
1380 | 1380 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
1381 | 1381 | if ( $post_data['id'] ) { |
@@ -1391,13 +1391,13 @@ discard block |
||
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | /** |
1394 | - * Prepare object data and redirect after processing |
|
1395 | - * This runs when the update form is submitted |
|
1396 | - * It is public because it depends on an admin hook |
|
1397 | - * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page |
|
1398 | - * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success |
|
1399 | - * |
|
1400 | - */ |
|
1394 | + * Prepare object data and redirect after processing |
|
1395 | + * This runs when the update form is submitted |
|
1396 | + * It is public because it depends on an admin hook |
|
1397 | + * It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page |
|
1398 | + * This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success |
|
1399 | + * |
|
1400 | + */ |
|
1401 | 1401 | public function prepare_object_map_data() { |
1402 | 1402 | $error = false; |
1403 | 1403 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
@@ -1436,12 +1436,12 @@ discard block |
||
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | /** |
1439 | - * Delete object map data and redirect after processing |
|
1440 | - * This runs when the delete link is clicked on an error row, after the user confirms |
|
1441 | - * It is public because it depends on an admin hook |
|
1442 | - * It then calls the Object_Sync_Sf_Mapping class and the delete method |
|
1443 | - * |
|
1444 | - */ |
|
1439 | + * Delete object map data and redirect after processing |
|
1440 | + * This runs when the delete link is clicked on an error row, after the user confirms |
|
1441 | + * It is public because it depends on an admin hook |
|
1442 | + * It then calls the Object_Sync_Sf_Mapping class and the delete method |
|
1443 | + * |
|
1444 | + */ |
|
1445 | 1445 | public function delete_object_map() { |
1446 | 1446 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
1447 | 1447 | if ( $post_data['id'] ) { |
@@ -1457,9 +1457,9 @@ discard block |
||
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | /** |
1460 | - * Import a json file and use it for plugin data |
|
1461 | - * |
|
1462 | - */ |
|
1460 | + * Import a json file and use it for plugin data |
|
1461 | + * |
|
1462 | + */ |
|
1463 | 1463 | public function import_json_file() { |
1464 | 1464 | |
1465 | 1465 | if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import' ) ) { |
@@ -1557,9 +1557,9 @@ discard block |
||
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | /** |
1560 | - * Create a json file for exporting |
|
1561 | - * |
|
1562 | - */ |
|
1560 | + * Create a json file for exporting |
|
1561 | + * |
|
1562 | + */ |
|
1563 | 1563 | public function export_json_file() { |
1564 | 1564 | |
1565 | 1565 | if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_export'], 'object_sync_for_salesforce_nonce_export' ) ) { |
@@ -1588,10 +1588,10 @@ discard block |
||
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | /** |
1591 | - * Default display for <input> fields |
|
1592 | - * |
|
1593 | - * @param array $args |
|
1594 | - */ |
|
1591 | + * Default display for <input> fields |
|
1592 | + * |
|
1593 | + * @param array $args |
|
1594 | + */ |
|
1595 | 1595 | public function display_input_field( $args ) { |
1596 | 1596 | $type = $args['type']; |
1597 | 1597 | $id = $args['label_for']; |
@@ -1638,11 +1638,11 @@ discard block |
||
1638 | 1638 | } |
1639 | 1639 | |
1640 | 1640 | /** |
1641 | - * Display for multiple checkboxes |
|
1642 | - * Above method can handle a single checkbox as it is |
|
1643 | - * |
|
1644 | - * @param array $args |
|
1645 | - */ |
|
1641 | + * Display for multiple checkboxes |
|
1642 | + * Above method can handle a single checkbox as it is |
|
1643 | + * |
|
1644 | + * @param array $args |
|
1645 | + */ |
|
1646 | 1646 | public function display_checkboxes( $args ) { |
1647 | 1647 | $type = 'checkbox'; |
1648 | 1648 | $name = $args['name']; |
@@ -1676,10 +1676,10 @@ discard block |
||
1676 | 1676 | } |
1677 | 1677 | |
1678 | 1678 | /** |
1679 | - * Display for a dropdown |
|
1680 | - * |
|
1681 | - * @param array $args |
|
1682 | - */ |
|
1679 | + * Display for a dropdown |
|
1680 | + * |
|
1681 | + * @param array $args |
|
1682 | + */ |
|
1683 | 1683 | public function display_select( $args ) { |
1684 | 1684 | $type = $args['type']; |
1685 | 1685 | $id = $args['label_for']; |
@@ -1723,10 +1723,10 @@ discard block |
||
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | /** |
1726 | - * Dropdown formatted list of Salesforce API versions |
|
1727 | - * |
|
1728 | - * @return array $args |
|
1729 | - */ |
|
1726 | + * Dropdown formatted list of Salesforce API versions |
|
1727 | + * |
|
1728 | + * @return array $args |
|
1729 | + */ |
|
1730 | 1730 | private function version_options() { |
1731 | 1731 | $versions = $this->salesforce['sfapi']->get_api_versions(); |
1732 | 1732 | $args = array(); |
@@ -1740,10 +1740,10 @@ discard block |
||
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | /** |
1743 | - * Default display for <a href> links |
|
1744 | - * |
|
1745 | - * @param array $args |
|
1746 | - */ |
|
1743 | + * Default display for <a href> links |
|
1744 | + * |
|
1745 | + * @param array $args |
|
1746 | + */ |
|
1747 | 1747 | public function display_link( $args ) { |
1748 | 1748 | $label = $args['label']; |
1749 | 1749 | $desc = $args['desc']; |
@@ -1770,11 +1770,11 @@ discard block |
||
1770 | 1770 | } |
1771 | 1771 | |
1772 | 1772 | /** |
1773 | - * Allow for a standard sanitize/validate method. We could use more specific ones if need be, but this one provides a baseline. |
|
1774 | - * |
|
1775 | - * @param string $option |
|
1776 | - * @return string $option |
|
1777 | - */ |
|
1773 | + * Allow for a standard sanitize/validate method. We could use more specific ones if need be, but this one provides a baseline. |
|
1774 | + * |
|
1775 | + * @param string $option |
|
1776 | + * @return string $option |
|
1777 | + */ |
|
1778 | 1778 | public function sanitize_validate_text( $option ) { |
1779 | 1779 | if ( is_array( $option ) ) { |
1780 | 1780 | $options = array(); |
@@ -1788,10 +1788,10 @@ discard block |
||
1788 | 1788 | } |
1789 | 1789 | |
1790 | 1790 | /** |
1791 | - * Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it |
|
1792 | - * |
|
1793 | - * @param object $sfapi |
|
1794 | - */ |
|
1791 | + * Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it |
|
1792 | + * |
|
1793 | + * @param object $sfapi |
|
1794 | + */ |
|
1795 | 1795 | private function status( $sfapi ) { |
1796 | 1796 | |
1797 | 1797 | $versions = $sfapi->get_api_versions(); |
@@ -1850,10 +1850,10 @@ discard block |
||
1850 | 1850 | } |
1851 | 1851 | |
1852 | 1852 | /** |
1853 | - * Deauthorize WordPress from Salesforce. |
|
1854 | - * This deletes the tokens from the database; it does not currently do anything in Salesforce |
|
1855 | - * For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce |
|
1856 | - */ |
|
1853 | + * Deauthorize WordPress from Salesforce. |
|
1854 | + * This deletes the tokens from the database; it does not currently do anything in Salesforce |
|
1855 | + * For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce |
|
1856 | + */ |
|
1857 | 1857 | private function logout() { |
1858 | 1858 | $this->access_token = delete_option( $this->option_prefix . 'access_token' ); |
1859 | 1859 | $this->instance_url = delete_option( $this->option_prefix . 'instance_url' ); |
@@ -1865,8 +1865,8 @@ discard block |
||
1865 | 1865 | } |
1866 | 1866 | |
1867 | 1867 | /** |
1868 | - * Ajax call to clear the plugin cache. |
|
1869 | - */ |
|
1868 | + * Ajax call to clear the plugin cache. |
|
1869 | + */ |
|
1870 | 1870 | public function clear_sfwp_cache() { |
1871 | 1871 | $result = $this->clear_cache( true ); |
1872 | 1872 | $response = array( |
@@ -1877,9 +1877,9 @@ discard block |
||
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | /** |
1880 | - * Clear the plugin's cache. |
|
1881 | - * This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data. |
|
1882 | - */ |
|
1880 | + * Clear the plugin's cache. |
|
1881 | + * This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data. |
|
1882 | + */ |
|
1883 | 1883 | private function clear_cache( $ajax = false ) { |
1884 | 1884 | $result = (bool) $this->wordpress->sfwp_transients->flush(); |
1885 | 1885 | if ( true === $result ) { |
@@ -1899,9 +1899,9 @@ discard block |
||
1899 | 1899 | } |
1900 | 1900 | |
1901 | 1901 | /** |
1902 | - * Check WordPress Admin permissions |
|
1903 | - * Check if the current user is allowed to access the Salesforce plugin options |
|
1904 | - */ |
|
1902 | + * Check WordPress Admin permissions |
|
1903 | + * Check if the current user is allowed to access the Salesforce plugin options |
|
1904 | + */ |
|
1905 | 1905 | private function check_wordpress_admin_permissions() { |
1906 | 1906 | |
1907 | 1907 | // one programmatic way to give this capability to additional user roles is the |
@@ -1921,10 +1921,10 @@ discard block |
||
1921 | 1921 | } |
1922 | 1922 | |
1923 | 1923 | /** |
1924 | - * Show what we know about this user's relationship to a Salesforce object, if any |
|
1925 | - * @param object $user |
|
1926 | - * |
|
1927 | - */ |
|
1924 | + * Show what we know about this user's relationship to a Salesforce object, if any |
|
1925 | + * @param object $user |
|
1926 | + * |
|
1927 | + */ |
|
1928 | 1928 | public function show_salesforce_user_fields( $user ) { |
1929 | 1929 | $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING ); |
1930 | 1930 | if ( true === $this->check_wordpress_admin_permissions() ) { |
@@ -1948,10 +1948,10 @@ discard block |
||
1948 | 1948 | } |
1949 | 1949 | |
1950 | 1950 | /** |
1951 | - * If the user profile has been mapped to Salesforce, do it |
|
1952 | - * @param int $user_id |
|
1953 | - * |
|
1954 | - */ |
|
1951 | + * If the user profile has been mapped to Salesforce, do it |
|
1952 | + * @param int $user_id |
|
1953 | + * |
|
1954 | + */ |
|
1955 | 1955 | public function save_salesforce_user_fields( $user_id ) { |
1956 | 1956 | $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); |
1957 | 1957 | if ( isset( $post_data['salesforce_update_mapped_user'] ) && '1' === rawurlencode( $post_data['salesforce_update_mapped_user'] ) ) { |
@@ -1976,10 +1976,10 @@ discard block |
||
1976 | 1976 | } |
1977 | 1977 | |
1978 | 1978 | /** |
1979 | - * Render tabs for settings pages in admin |
|
1980 | - * @param array $tabs |
|
1981 | - * @param string $tab |
|
1982 | - */ |
|
1979 | + * Render tabs for settings pages in admin |
|
1980 | + * @param array $tabs |
|
1981 | + * @param string $tab |
|
1982 | + */ |
|
1983 | 1983 | private function tabs( $tabs, $tab = '' ) { |
1984 | 1984 | |
1985 | 1985 | $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING ); |
@@ -2009,10 +2009,10 @@ discard block |
||
2009 | 2009 | } |
2010 | 2010 | |
2011 | 2011 | /** |
2012 | - * Clear schedule |
|
2013 | - * This clears the schedule if the user clicks the button |
|
2014 | - * @param string $schedule_name |
|
2015 | - */ |
|
2012 | + * Clear schedule |
|
2013 | + * This clears the schedule if the user clicks the button |
|
2014 | + * @param string $schedule_name |
|
2015 | + */ |
|
2016 | 2016 | private function clear_schedule( $schedule_name = '' ) { |
2017 | 2017 | if ( '' !== $schedule_name ) { |
2018 | 2018 | $this->queue->cancel( $schedule_name ); |
@@ -2024,10 +2024,10 @@ discard block |
||
2024 | 2024 | } |
2025 | 2025 | |
2026 | 2026 | /** |
2027 | - * Get count of schedule items |
|
2028 | - * @param string $schedule_name |
|
2029 | - * @return int $count |
|
2030 | - */ |
|
2027 | + * Get count of schedule items |
|
2028 | + * @param string $schedule_name |
|
2029 | + * @return int $count |
|
2030 | + */ |
|
2031 | 2031 | private function get_schedule_count( $schedule_name = '' ) { |
2032 | 2032 | if ( '' !== $schedule_name ) { |
2033 | 2033 | $count = count( $this->queue->search( |
@@ -2051,21 +2051,21 @@ discard block |
||
2051 | 2051 | } |
2052 | 2052 | |
2053 | 2053 | /** |
2054 | - * Create an object map between a WordPress object and a Salesforce object |
|
2055 | - * |
|
2056 | - * @param int $wordpress_id |
|
2057 | - * Unique identifier for the WordPress object |
|
2058 | - * @param string $wordpress_object |
|
2059 | - * What kind of object is it? |
|
2060 | - * @param string $salesforce_id |
|
2061 | - * Unique identifier for the Salesforce object |
|
2062 | - * @param string $action |
|
2063 | - * Did we push or pull? |
|
2064 | - * |
|
2065 | - * @return int $wpdb->insert_id |
|
2066 | - * This is the database row for the map object |
|
2067 | - * |
|
2068 | - */ |
|
2054 | + * Create an object map between a WordPress object and a Salesforce object |
|
2055 | + * |
|
2056 | + * @param int $wordpress_id |
|
2057 | + * Unique identifier for the WordPress object |
|
2058 | + * @param string $wordpress_object |
|
2059 | + * What kind of object is it? |
|
2060 | + * @param string $salesforce_id |
|
2061 | + * Unique identifier for the Salesforce object |
|
2062 | + * @param string $action |
|
2063 | + * Did we push or pull? |
|
2064 | + * |
|
2065 | + * @return int $wpdb->insert_id |
|
2066 | + * This is the database row for the map object |
|
2067 | + * |
|
2068 | + */ |
|
2069 | 2069 | private function create_object_map( $wordpress_id, $wordpress_object, $salesforce_id, $action = '' ) { |
2070 | 2070 | // Create object map and save it |
2071 | 2071 | $mapping_object = $this->mappings->create_object_map( |
@@ -16,81 +16,81 @@ discard block |
||
16 | 16 | class Object_Sync_Salesforce { |
17 | 17 | |
18 | 18 | /** |
19 | - * @var object |
|
20 | - * Global object of `$wpdb`, the WordPress database |
|
21 | - */ |
|
19 | + * @var object |
|
20 | + * Global object of `$wpdb`, the WordPress database |
|
21 | + */ |
|
22 | 22 | private $wpdb; |
23 | 23 | |
24 | 24 | /** |
25 | - * @var array |
|
26 | - * Login credentials for the Salesforce API; comes from wp-config or from the plugin settings |
|
27 | - */ |
|
25 | + * @var array |
|
26 | + * Login credentials for the Salesforce API; comes from wp-config or from the plugin settings |
|
27 | + */ |
|
28 | 28 | private $login_credentials; |
29 | 29 | |
30 | 30 | /** |
31 | - * @var string |
|
32 | - * The plugin's slug so we can include it when necessary |
|
33 | - */ |
|
31 | + * @var string |
|
32 | + * The plugin's slug so we can include it when necessary |
|
33 | + */ |
|
34 | 34 | private $slug; |
35 | 35 | |
36 | 36 | /** |
37 | - * @var string |
|
38 | - * The plugin's option prefix |
|
39 | - */ |
|
37 | + * @var string |
|
38 | + * The plugin's option prefix |
|
39 | + */ |
|
40 | 40 | private $option_prefix; |
41 | 41 | |
42 | 42 | /** |
43 | - * @var array |
|
44 | - * Array of what classes in the plugin can be scheduled to occur with `wp_cron` events |
|
45 | - */ |
|
43 | + * @var array |
|
44 | + * Array of what classes in the plugin can be scheduled to occur with `wp_cron` events |
|
45 | + */ |
|
46 | 46 | public $schedulable_classes; |
47 | 47 | |
48 | 48 | /** |
49 | - * @var string |
|
50 | - * Current version of the plugin |
|
51 | - */ |
|
49 | + * @var string |
|
50 | + * Current version of the plugin |
|
51 | + */ |
|
52 | 52 | private $version; |
53 | 53 | |
54 | 54 | /** |
55 | - * @var object |
|
56 | - */ |
|
55 | + * @var object |
|
56 | + */ |
|
57 | 57 | private $activated; |
58 | 58 | |
59 | 59 | /** |
60 | - * @var object |
|
61 | - * Load and initialize the Object_Sync_Sf_Logging class |
|
62 | - */ |
|
60 | + * @var object |
|
61 | + * Load and initialize the Object_Sync_Sf_Logging class |
|
62 | + */ |
|
63 | 63 | private $logging; |
64 | 64 | |
65 | 65 | /** |
66 | - * @var object |
|
67 | - * Load and initialize the Object_Sync_Sf_Mapping class |
|
68 | - */ |
|
66 | + * @var object |
|
67 | + * Load and initialize the Object_Sync_Sf_Mapping class |
|
68 | + */ |
|
69 | 69 | private $mappings; |
70 | 70 | |
71 | 71 | /** |
72 | - * @var object |
|
73 | - * Load and initialize the Object_Sync_Sf_WordPress class |
|
74 | - */ |
|
72 | + * @var object |
|
73 | + * Load and initialize the Object_Sync_Sf_WordPress class |
|
74 | + */ |
|
75 | 75 | private $wordpress; |
76 | 76 | |
77 | 77 | /** |
78 | - * @var object |
|
79 | - * Load and initialize the Object_Sync_Sf_Salesforce class. |
|
80 | - * This contains the Salesforce API methods |
|
81 | - */ |
|
78 | + * @var object |
|
79 | + * Load and initialize the Object_Sync_Sf_Salesforce class. |
|
80 | + * This contains the Salesforce API methods |
|
81 | + */ |
|
82 | 82 | public $salesforce; |
83 | 83 | |
84 | 84 | /** |
85 | - * @var object |
|
86 | - * Load and initialize the Object_Sync_Sf_Salesforce_Push class |
|
87 | - */ |
|
85 | + * @var object |
|
86 | + * Load and initialize the Object_Sync_Sf_Salesforce_Push class |
|
87 | + */ |
|
88 | 88 | private $push; |
89 | 89 | |
90 | 90 | /** |
91 | - * @var object |
|
92 | - * Load and initialize the Object_Sync_Sf_Salesforce_Pull class |
|
93 | - */ |
|
91 | + * @var object |
|
92 | + * Load and initialize the Object_Sync_Sf_Salesforce_Pull class |
|
93 | + */ |
|
94 | 94 | private $pull; |
95 | 95 | |
96 | 96 | /** |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | static $instance = null; |
102 | 102 | |
103 | 103 | /** |
104 | - * Load the static $instance property that holds the instance of the class. |
|
105 | - * This instance makes the class reusable by other plugins |
|
106 | - * |
|
107 | - * @return object |
|
108 | - * The sfapi object if it is authenticated (empty, otherwise) |
|
109 | - * |
|
110 | - */ |
|
104 | + * Load the static $instance property that holds the instance of the class. |
|
105 | + * This instance makes the class reusable by other plugins |
|
106 | + * |
|
107 | + * @return object |
|
108 | + * The sfapi object if it is authenticated (empty, otherwise) |
|
109 | + * |
|
110 | + */ |
|
111 | 111 | static public function get_instance() { |
112 | 112 | if ( null === self::$instance ) { |
113 | 113 | self::$instance = new Object_Sync_Salesforce(); |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
260 | - * Private helper to load methods for manipulating core WordPress data across the plugin |
|
261 | - * |
|
262 | - * @param object $wpdb |
|
263 | - * @param string $version |
|
264 | - * @param string $slug |
|
265 | - * @param string $option_prefix |
|
266 | - * @param object $mappings |
|
267 | - * @param object $logging |
|
268 | - * |
|
269 | - * @return object |
|
270 | - * Instance of Object_Sync_Sf_WordPress |
|
271 | - */ |
|
260 | + * Private helper to load methods for manipulating core WordPress data across the plugin |
|
261 | + * |
|
262 | + * @param object $wpdb |
|
263 | + * @param string $version |
|
264 | + * @param string $slug |
|
265 | + * @param string $option_prefix |
|
266 | + * @param object $mappings |
|
267 | + * @param object $logging |
|
268 | + * |
|
269 | + * @return object |
|
270 | + * Instance of Object_Sync_Sf_WordPress |
|
271 | + */ |
|
272 | 272 | private function wordpress( $wpdb, $version, $slug, $option_prefix, $mappings, $logging ) { |
273 | 273 | require_once plugin_dir_path( __FILE__ ) . 'classes/wordpress.php'; |
274 | 274 | $wordpress = new Object_Sync_Sf_WordPress( $wpdb, $version, $slug, $option_prefix, $mappings, $logging ); |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
279 | - * Public helper to load the Salesforce API and see if it is authenticated. |
|
280 | - * This is public so other plugins can access the same SF API instance |
|
281 | - * |
|
282 | - * @return array |
|
283 | - * Whether Salesforce is authenticated (boolean) |
|
284 | - * The sfapi object if it is authenticated (empty, otherwise) |
|
285 | - */ |
|
279 | + * Public helper to load the Salesforce API and see if it is authenticated. |
|
280 | + * This is public so other plugins can access the same SF API instance |
|
281 | + * |
|
282 | + * @return array |
|
283 | + * Whether Salesforce is authenticated (boolean) |
|
284 | + * The sfapi object if it is authenticated (empty, otherwise) |
|
285 | + */ |
|
286 | 286 | public function salesforce_get_api() { |
287 | 287 | require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce.php' ); |
288 | 288 | require_once( plugin_dir_path( __FILE__ ) . 'classes/salesforce_query.php' ); // this can be used to generate soql queries, but we don't often need it so it gets initialized whenever it's needed |
@@ -391,26 +391,26 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Load the admin class. |
|
395 | - * This also creates admin menu, unless the plugin that calls this library has indicated that it has its own menu |
|
396 | - * |
|
397 | - * @param object $wpdb |
|
398 | - * @param string $version |
|
399 | - * @param array $login_credentials |
|
400 | - * @param string $slug |
|
401 | - * @param string $option_prefix |
|
402 | - * @param object $wordpress |
|
403 | - * @param object $salesforce |
|
404 | - * @param object $mappings |
|
405 | - * @param object $push |
|
406 | - * @param object $pull |
|
407 | - * @param object $logging |
|
408 | - * @param array $schedulable_classes |
|
409 | - * @param object $queue |
|
410 | - * @return object $admin |
|
411 | - * Instance of Object_Sync_Sf_Admin |
|
412 | - * |
|
413 | - */ |
|
394 | + * Load the admin class. |
|
395 | + * This also creates admin menu, unless the plugin that calls this library has indicated that it has its own menu |
|
396 | + * |
|
397 | + * @param object $wpdb |
|
398 | + * @param string $version |
|
399 | + * @param array $login_credentials |
|
400 | + * @param string $slug |
|
401 | + * @param string $option_prefix |
|
402 | + * @param object $wordpress |
|
403 | + * @param object $salesforce |
|
404 | + * @param object $mappings |
|
405 | + * @param object $push |
|
406 | + * @param object $pull |
|
407 | + * @param object $logging |
|
408 | + * @param array $schedulable_classes |
|
409 | + * @param object $queue |
|
410 | + * @return object $admin |
|
411 | + * Instance of Object_Sync_Sf_Admin |
|
412 | + * |
|
413 | + */ |
|
414 | 414 | private function load_admin( $wpdb, $version, $login_credentials, $slug, $option_prefix, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ) { |
415 | 415 | require_once( plugin_dir_path( __FILE__ ) . 'classes/admin.php' ); |
416 | 416 | $admin = new Object_Sync_Sf_Admin( $wpdb, $version, $login_credentials, $slug, $option_prefix, $wordpress, $salesforce, $mappings, $push, $pull, $logging, $schedulable_classes, $queue ); |
@@ -422,13 +422,13 @@ discard block |
||
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
425 | - * Display a Settings link on the main Plugins page |
|
426 | - * |
|
427 | - * @param array $links |
|
428 | - * @param string $file |
|
429 | - * @return array $links |
|
430 | - * These are the links that go with this plugin's entry |
|
431 | - */ |
|
425 | + * Display a Settings link on the main Plugins page |
|
426 | + * |
|
427 | + * @param array $links |
|
428 | + * @param string $file |
|
429 | + * @return array $links |
|
430 | + * These are the links that go with this plugin's entry |
|
431 | + */ |
|
432 | 432 | public function plugin_action_links( $links, $file ) { |
433 | 433 | if ( plugin_basename( __FILE__ ) === $file ) { |
434 | 434 | $settings = '<a href="' . get_admin_url() . 'options-general.php?page=object-sync-salesforce-admin">' . __( 'Settings', 'object-sync-for-salesforce' ) . '</a>'; |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | |
441 | 441 | |
442 | 442 | /** |
443 | - * Admin styles. Load the CSS and JavaScript for the plugin's settings |
|
444 | - * |
|
445 | - * @return void |
|
446 | - */ |
|
443 | + * Admin styles. Load the CSS and JavaScript for the plugin's settings |
|
444 | + * |
|
445 | + * @return void |
|
446 | + */ |
|
447 | 447 | public function admin_scripts_and_styles() { |
448 | 448 | |
449 | 449 | // I think some developers might not want to bother with select2 or selectwoo, so let's allow that to be changeable |
@@ -484,13 +484,13 @@ discard block |
||
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
487 | - * Get the pre-login Salesforce credentials. |
|
488 | - * These depend on the plugin's settings or constants defined in wp-config.php. |
|
489 | - * |
|
490 | - * @return array $login_credentials |
|
491 | - * Includes all settings necessary to log into the Salesforce API. |
|
492 | - * Replaces settings options with wp-config.php values if they exist. |
|
493 | - */ |
|
487 | + * Get the pre-login Salesforce credentials. |
|
488 | + * These depend on the plugin's settings or constants defined in wp-config.php. |
|
489 | + * |
|
490 | + * @return array $login_credentials |
|
491 | + * Includes all settings necessary to log into the Salesforce API. |
|
492 | + * Replaces settings options with wp-config.php values if they exist. |
|
493 | + */ |
|
494 | 494 | private function get_login_credentials() { |
495 | 495 | |
496 | 496 | $consumer_key = defined( 'OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY' ) ? OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY : get_option( $this->option_prefix . 'consumer_key', '' ); |