Created
March 10, 2022 17:48
-
-
Save alanef/7f73a80d2100729cccc3b54456750d7e to your computer and use it in GitHub Desktop.
Example get data as a plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Get Data | |
| Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates | |
| Description: A brief description of the Plugin. | |
| Version: 1.0 | |
| Author: alan | |
| Author URI: http://URI_Of_The_Plugin_Author | |
| License: A "Slug" license name e.g. GPL2 | |
| */ | |
| add_action( | |
| 'init', | |
| function () { | |
| if ( ! class_exists( '\WidgetForEventbriteAPI\Includes\Eventbrite_Query' ) ) { | |
| return; | |
| } | |
| add_shortcode( | |
| 'wfea_get_data', | |
| 'wfea_get_data' | |
| ); | |
| } | |
| ); | |
| function wfea_get_data() { | |
| $events = new \WidgetForEventbriteAPI\Includes\Eventbrite_Query( | |
| array( | |
| 'token' => '', //api key will default to settings if blank | |
| 'limit' => 1, | |
| 'status' => 'live', | |
| 'nopaging' => true, // needed | |
| ) | |
| ); | |
| $json_pretty = json_encode( $events->api_results->events[0], JSON_PRETTY_PRINT ); | |
| return '<pre>' . $json_pretty . '<pre/>'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment