Skip to content

Instantly share code, notes, and snippets.

@alanef
Created March 10, 2022 17:48
Show Gist options
  • Select an option

  • Save alanef/7f73a80d2100729cccc3b54456750d7e to your computer and use it in GitHub Desktop.

Select an option

Save alanef/7f73a80d2100729cccc3b54456750d7e to your computer and use it in GitHub Desktop.
Example get data as a plugin
<?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