This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)
Given the code
| <?php | |
| /** | |
| * Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended | |
| * to the end of the array. | |
| * | |
| * @param array $array | |
| * @param string $key | |
| * @param array $new | |
| * |
| <?php | |
| /** | |
| * Plugin Name: EDD Heartbeat API test plugin | |
| * Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard | |
| */ | |
| // Load the heartbeat JS | |
| function edd_heartbeat_enqueue( $hook_suffix ) { | |
| // Make sure the JS part of the Heartbeat API is loaded. | |
| wp_enqueue_script( 'heartbeat' ); |
| <?php | |
| // Creating tables in Single site installations | |
| function on_activate() { | |
| create_table(); | |
| } | |
| function create_table() { | |
| global $wpdb; | |
| $table_name = $wpdb->prefix . 'table_name'; |
| <?php | |
| /** | |
| * Supply a user id and an access token | |
| * Jelled explains how to obtain a user id and access token in the link provided | |
| * @link http://jelled.com/instagram/access-token | |
| */ | |
| $userid = ""; | |
| $accessToken = ""; | |
| // Get our data | |
| function fetchData($url){ |