.
**************************************************************************
*/
if ( !class_exists( "ArtistDataPress_Plugin" ) ) { //Start Class
class ArtistDataPress_Plugin {
public static $instance;
function __construct() {
self::$instance = $this;
// Runs when plugin is activated
register_activation_hook( __FILE__, array( $this, 'create_options' ) );
// Queues the included stylesheet
wp_register_style( 'slushman-adp', plugins_url( 'css/artistdatapress.css', __FILE__ ) );
wp_enqueue_style( 'slushman-adp' );
// Adds the ArtistDataPress option menu to the Settings menu
add_action( 'admin_menu', array( $this, 'add_menu' ) );
// Add "Settings" link to plugin page
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ) , array( $this, 'settings_link' ) );
// Register and define the settings
add_action( 'admin_init', array( $this, 'admin_init' ) );
// Include widget files
add_action( 'init', array( $this, 'widget_includer' ) );
// Create shortcode [artistdatapress]
add_shortcode( 'artistdatapress', array( $this, 'shortcode' ) );
} // End of __construct()
function create_options() {
$options = array(
'slushman_adp_xml_url' => '',
'slushman_adp_adpage_url' => '',
'slushman_adp_max_shows' => '',
'slushman_adp_display_time' => '',
'slushman_adp_display_tickets' => '',
'slushman_adp_display_age' => '',
'slushman_adp_display_country' => '',
'slushman_adp_no_shows' => 'There are no shows currently scheduled.'
);
update_option( 'slushman_adp_options', $options );
} // End of create_options()
// Options Page
function add_menu() {
add_options_page( 'ArtistDataPress Options', 'ArtistDataPress', 'manage_options', 'slushman-adp', array( $this, 'options_page' ) );
} // End of add_menu()
function settings_link( $links ) {
$slushman_adp_settings_link = sprintf( '%s', admin_url( 'options-general.php?page=slushman-adp' ), __( 'Settings' ) );
array_unshift( $links, $slushman_adp_settings_link );
return $links;
} // End of settings_link()
function options_page() {
?>
ArtistDataPress Options
The ArtistData XML feed URL can be found on your ArtistData account by going to Tools > Data Feeds.';
}
function xml_url_field_fn() {
$options = get_option( 'slushman_adp_options' ); ?>
" />
" />Choose what information you want displayed on your calendar.';
}
function max_shows_field_fn() {
$options = get_option( 'slushman_adp_options' ); ?>
" />
/>
/>
/>
/>
" />Choose how you want to format your times and dates.';
}
function display_time_field_fn() {
$options = get_option( 'slushman_adp_options' ); ?>
/>
show[0]->recordKey;
if ( !empty( $key ) ) {
return $data;
} else {
$error = 'There seems to be a problem with your feed URL.';
return $error;
}
} // End of if ( $data === FALSE )
} // End of get_xml()
/**
* Get the XML date and change it into a more readable format
*
* date_morph() accepts an unformatted date, converts it to a string and formats into:
* full textual day of the week, Numeric month, without leading zeros / Day of the month, 2 digits with leading zeros / 4 digit year. Example: Sunday, 9/03/2011.
* then returns it.
*
* @since 0.1
*
* @param mixed $rawdate A date
*
* @return mixed $date Formatted date
*/
function date_morph( $rawdate ) {
$middle_date = strtotime( $rawdate );
$date = date( 'l, n/d/Y', $middle_date );
return $date;
} // End of date_morph()
/**
* Get the show time and change it into a more readable format
*
* time_morph() accepts an unformatted time, converts it to a string and formats into:
* 12-hour format of an hour without leading zeros: Minutes with leading zeros am or pm. Example: 3:07 pm.
* then returns it.
*
* @since 0.1
*
* @param mixed $rawtime A time
*
* @return mixed $showtime Formatted time
*/
function time_morph( $rawtime ) {
$limitedshowtime = substr( $rawtime, 0, 8 );
$showtime = date( 'g:i a', strtotime( $limitedshowtime ) );
return $showtime;
} // End of time_morph()
/**
* Displays the ArtistData XML feed for use on a page
*
* artistdatapress() gets all the plugins options, gets the XML data as an array,
* then outputs an HTML table based on the user-selected options.
*
* @since 0.1
*
* @return mixed $output HTML-formatted table showing upcoming shows from an ArtistData feed
*/
function artistdatapress() {
$options = get_option( 'slushman_adp_options' );
$slushman_adp_adpage_url = $options['slushman_adp_adpage_url'];
$slushman_adp_max_shows = $options['slushman_adp_max_shows'];
$slushman_adp_display_name = $options['slushman_adp_display_name'];
$slushman_adp_display_time = $options['slushman_adp_display_time'];
$slushman_adp_time_format = $options['slushman_adp_time_format'];
$slushman_adp_date_format = $options['slushman_adp_date_format'];
$slushman_adp_display_wp_date = $options['slushman_adp_display_wp_date'];
$slushman_adp_display_tickets = $options['slushman_adp_display_tickets'];
$slushman_adp_display_age = $options['slushman_adp_display_age'];
$slushman_adp_country = $options['slushman_adp_country'];
$slushman_adp_no_shows = $options['slushman_adp_no_shows'];
$showfeed = $this->get_xml();
if ( !empty( $showfeed ) ) { ?>
show as $show ) { ?>
date );
$date = date( $date_format, $showdate ); ?>
timeSet );
$time = date( $time_format, $showtime ); ?>
at
ticketURI) ) { ?>
Tickets: ticketPrice; ?>Tickets: ticketPrice; ?>ticketURI) )
} // End of if ( $slushman_adp_display_tickets == 'on')
// Display the age limit if selected in the plugin options
if ( $slushman_adp_display_age == 'on') { ?>
Age Limit: ageLimit; ?>
artistdatapress();
$output = ob_get_contents();
ob_end_clean();
return $output;
} // End of shortcode()
function widget_includer() {
require( 'inc/adp_widget.php' );
}
} // End of class ArtistDataPress_Plugin
} // End of ( !class_exists( "ArtistDataPress_Plugin" ) )
new ArtistDataPress_Plugin;
?>