. ************************************************************************** */ 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_register_style( 'slushman-adp-layout-default', plugins_url( 'css/default.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, 'register_settings' ) ); // Create shortcode [artistdatapress] add_shortcode( 'artistdatapress', array( $this, 'shortcode' ) ); // Include other files add_action( 'init', array( $this, 'file_includer' ) ); } // End of __construct() function create_options() { $options['slushman_adp_xml_url'] = $options['slushman_adp_adpage_url'] = $options['slushman_adp_max_shows'] = $options['slushman_adp_display_time'] = $options['slushman_adp_display_tickets'] = $options['slushman_adp_display_age'] = $options['slushman_adp_display_country'] = $options['slushman_adp_layout'] = ''; $options['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 display_section() { echo '

Choose what information you want displayed on your calendar.

'; } function time_section() { echo '

Choose how you want to format your times and dates.

'; } function styling_section() { echo '

Choose how you want the calendar to appear.

'; } // End of styling_section_fn() function xml_url_field() { $options = get_option( 'slushman_adp_options' ); ?> " /> " /> /> /> /> /> /> " /> />
' . date_i18n( $format ) . "
\n"; } echo ' ' . date_i18n( get_option( 'time_format' ) ) . " \n"; ?>
' . date_i18n( $format ) . "
\n"; } echo ' ' . date_i18n( get_option( 'date_format' ) ) . " \n"; echo "\t

" . __( 'Documentation on date and time formatting.' ) . "

\n"; ?>
general_settings_key; screen_icon(); echo ''; } /** * Processes and outputs the raw ArtistData XML feed * * get_xml() gets the value of the slushman_adp_xml_url plugin option, * then fetches the ArtistData XML file at that URL. It then parses * the XML into an array, which can be displayed easily. * * Here's wheere the cURL code came from: * http://www.bobulous.org.uk/coding/php-5-xml-feeds.html * * @since 0.3 * * @uses get_option * @uses cURL * @uses SimpleXmlElement * * @return array Data from the ArtistData XML */ function get_xml() { $options = get_option( 'slushman_adp_options' ); if ( !empty( $options['slushman_adp_xml_url'] ) ) { $xml_url = curl_init( $options['slushman_adp_xml_url'] ); curl_setopt( $xml_url, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $xml_url, CURLOPT_CONNECTTIMEOUT, 4 ); curl_setopt( $xml_url, CURLOPT_AUTOREFERER, TRUE ); curl_setopt( $xml_url, CURLOPT_MAXREDIRS, 10 ); curl_setopt( $xml_url, CURLOPT_FOLLOWLOCATION, TRUE ); $xml = curl_exec( $xml_url ); curl_close( $xml_url ); libxml_use_internal_errors( true ); try { $data = new SimpleXMLElement( $xml ); } catch ( Exception $e ) { $error_message = 'SimpleXMLElement threw an exception.'; foreach( libxml_get_errors() as $error_line ) { $error_message .= "\t" . $error_line->message; return $error_message; } // End of libxml_get_errors foreach trigger_error( $error_message ); $error = array( 'Error', 'There seems to be a problem with your feed URL.' ); return $error; } // End of try / catch if ( $data != FALSE ) { $key = $data->show[0]->recordKey; if ( !empty( $key ) ) { return $data; } else { return FALSE; } // End of $key empty check } // End of $data check } else { $error = array( 'Error', 'Please enter a feed in the options page.' ); return $error; } // End of slushman_adp_xml_url empty check } // End of get_xml() /** * Display errors and notices * * * * @since 0.2 * * @param array $args Array of data * * @return mixed HTML formatted error message */ function display_errors_and_notices( $args ) { $notices['check_field'] = sprintf( __( '

The %s field is either invalid or empty.

' ), $args['field'] ); $notices['already_used'] = sprintf( __( '

This %s is already used by another user.

' ), $args['used'] ); $notices['not_set'] = sprintf( __( '

The %s is not set.

' ), $args['unset'] ); $notices['fail'] = sprintf( __( '

Could not %s the %s.

' ), $args['failure'], $args['failed'] ); $notices['success'] = sprintf( __( '

%s %s successfully.

' ), $args['succeeded'], $args['successful'] ); $notices['attended'] = sprintf( __( '

%s has already received credit for this seminar.

' ), $args['student_name'] ); $notices['enrolled'] = sprintf( __( '

%s has been marked as enrolled.

' ), $args['student_name'] ); $notices['unregistered'] = __( '

This student is not currently registered for the seminar course.

' ); $notices['errors'] = sprintf( __( '

%s

' ), $args['error'] ); $notices['attendance'] = sprintf( __( '

Attendance at %s for %s was added successfully.

' ), $args['event'], $args['student'] ); $notices['partial'] = sprintf( __( '

%s updated, but %s did not.

' ), $args['updated'], $args['same'] ); $notice = $notices[$args['which']]; return $notice; } // End of display_errors_and_notices() // Create shortcode [artistdatapress] function shortcode( $atts ) { ob_start(); $options = get_option( 'slushman_adp_options' ); $layout_option = $options['slushman_adp_layout']; $layout = new Layout; $layout->get_layout( $layout_option ); $output = ob_get_contents(); ob_end_clean(); return $output; } // End of shortcode() /** * Include other files * * Includes all files containing functions outside the class. * * @since 0.37 */ function file_includer() { require( 'inc/layout.php' ); } // End of file_includer() } // End of ArtistDataPress_Plugin } // End of class check require_once( dirname( __FILE__ ) . '/inc/adp_widget.php' ); new ArtistDataPress_Plugin; ?>