. ************************************************************************** To-Do List * Get time and date jquery previews working * * http://core.trac.wordpress.org/browser/trunk/wp-admin/options-general.php - see add_js * Add additional layouts * Add additional layouts for widgets * Check out admin_notices: http://www.instantshift.com/2012/03/06/21-most-useful-wordpress-admin-page-hacks/ * Auto-blog a post the day of a show with the details of that show * Add support for feeds from Sonicbids and Reverbnation - any others? */ if ( !class_exists( "ArtistDataPress_Plugin" ) ) { //Start Class class ArtistDataPress_Plugin { public static $instance; private $settings_tabs = array(); function __construct() { self::$instance = $this; // Runs when plugin is activated register_activation_hook( __FILE__, array( $this, 'create_options' ) ); add_action( 'init', array( &$this, 'load_settings' ) ); // Queues the included stylesheet add_action( 'wp_enqueue_scripts', array( $this, 'add_styles' ) ); // Queues the layout stylesheets for the admin page add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) ); // 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' ) ); // Create shortcode [artistdatapress] add_shortcode( 'artistdatapress', array( $this, 'shortcode' ) ); // Include other files add_action( 'init', array( $this, 'file_includer' ) ); // Options tabs add_action( 'admin_init', array( &$this, 'register_general_settings' ) ); add_action( 'admin_init', array( &$this, 'register_layout_settings' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'example_js' ) ); } // End of __construct() function create_options() { if ( get_option( 'slushman_adp_options' ) ) { $options = get_option( 'slushman_adp_options' ); $general['xml_url'] = $options['slushman_adp_xml_url']; $general['adpage_url'] = $options['slushman_adp_adpage_url']; $general['display_name'] = $options['slushman_adp_display_name']; $general['display_time'] = $options['slushman_adp_display_time']; $general['display_tickets'] = $options['slushman_adp_display_tickets']; $general['display_age'] = $options['slushman_adp_display_age']; $general['display_artist'] = $options['slushman_adp_display_artist']; $general['display_country'] = $options['slushman_adp_display_country']; $general['max_shows'] = $options['slushman_adp_max_shows']; $general['no_shows_msg'] = $options['slushman_adp_no_shows']; $general['display_stage'] = $general['adp_time_format'] = $general['adp_date_format'] = ''; $layout['adp_layout'] = 'Classic Style'; delete_option( 'slushman_adp_options' ); } else { $general['xml_url'] = $general['adpage_url'] = $general['display_name'] = $general['display_time'] = $general['display_tickets'] = $general['display_age'] = $general['display_artist'] = $general['display_country'] = $general['display_stage'] = $general['adp_time_format'] = $general['adp_date_format'] = $general['max_shows'] = ''; $general['no_shows_msg'] = 'There are no shows currently scheduled.'; $layout['adp_layout'] = 'Classic Style'; } // End of previous options check update_option( 'slushman_adp_general_settings', $general ); update_option( 'slushman_adp_layout_settings', $layout ); } // End of create_options() function load_settings() { $this->gensets = (array) get_option( 'slushman_adp_general_settings' ); $this->laysets = (array) get_option( 'slushman_adp_layout_settings' ); $genset['xml_url'] = $genset['adpage_url'] = $genset['display_name'] = $genset['display_time'] = $genset['display_tickets'] = $genset['display_age'] = $genset['display_artist'] = $genset['display_country'] = $genset['display_stage'] = $genset['adp_time_format'] = $genset['adp_date_format'] = $genset['max_shows'] = ''; $genset['no_shows_msg'] = 'There are no shows currently scheduled.'; $layset['adp_layout'] = 'Classic Style'; // Merge with defaults $this->gensets = array_merge( $genset, $this->gensets ); $this->laysets = array_merge( $layset, $this->laysets ); } // 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() { $obd = ini_get( 'open_basedir' ); $safe = ini_get( 'safe_mode' ); if ( $obd != '' || $safe == '1' ) { if ( $obd != '' ) { echo '

Your PHP settings are incompatible with ArtistDataPress. The PHP setting, open_basedir is currently ' . $odb . '. Please change the setting on your server to empty.

'; echo ''; } if ( $safe == '1' ) { echo '

Your PHP settings are incompatible with ArtistDataPress. PHP\'s Safe Mode is currently turned on, and it needs to be off. Please turn off Safe Mode on your server.

'; echo ''; } } else { $tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : 'slushman_adp_general_settings' ); ?>

settings_tabs['slushman_adp_general_settings'] = 'ArtistDataPress Settings'; register_setting( 'slushman_adp_general_settings', 'slushman_adp_general_settings', array( $this, 'validate_options' ) ); add_settings_section( 'slushman_adp_urls', 'ArtistData URLs', array( $this, 'url_section' ), 'slushman_adp_general_settings' ); add_settings_field( 'slushman_adp_xml_url_field', 'ArtistData XML feed URL', array( $this, 'xml_url_field' ), 'slushman_adp_general_settings', 'slushman_adp_urls' ); add_settings_field( 'slushman_adp_adpage_url_field', 'ArtistData Profile URL', array( $this, 'adpage_url_field' ), 'slushman_adp_general_settings', 'slushman_adp_urls' ); add_settings_section( 'slushman_adp_display', 'ArtistData Display Options', array( $this, 'display_section' ), 'slushman_adp_general_settings'); add_settings_field( 'slushman_adp_max_shows_field', 'Display how many shows?', array( $this, 'max_shows_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_field( 'slushman_adp_display_name_field', 'Display show name?', array( $this, 'display_name_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_field( 'slushman_adp_display_stage_field', 'Display venue stage?', array( $this, 'display_stage_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_field( 'slushman_adp_display_artist_field', 'Display artist name?', array( $this, 'display_artist_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_field( 'slushman_adp_display_tickets_field', 'Display ticket price?', array( $this, 'display_tickets_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_field( 'slushman_adp_display_age_field', 'Display age limits?', array( $this, 'display_age_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_field( 'slushman_adp_display_country_field', 'Display country?', array( $this, 'country_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_field( 'slushman_adp_no_shows_field', 'Customize your "No shows" message', array( $this, 'no_shows_field' ), 'slushman_adp_general_settings', 'slushman_adp_display' ); add_settings_section( 'slushman_adp_times', 'Times and Dates Display', array( $this, 'time_section' ), 'slushman_adp_general_settings'); add_settings_field( 'slushman_adp_display_time_field', 'Display show time?', array( $this, 'display_time_field' ), 'slushman_adp_general_settings', 'slushman_adp_times' ); add_settings_field( 'slushman_adp_time_format_field', 'Time format:', array( $this, 'display_time_format_field' ), 'slushman_adp_general_settings', 'slushman_adp_times' ); add_settings_field( 'slushman_adp_date_format_field', 'Date format:', array( $this, 'display_date_format_field' ), 'slushman_adp_general_settings', 'slushman_adp_times' ); add_settings_section( 'slushman_adp_support', 'Support and Improve ADP', array( $this, 'support_section' ), 'slushman_adp_general_settings'); add_settings_field( 'slushman_adp_support_field', 'Support ADP today:', array( $this, 'support_preference_field' ), 'slushman_adp_general_settings', 'slushman_adp_support' ); } // End of register_general_settings() function register_layout_settings() { $this->settings_tabs['slushman_adp_layout_settings'] = 'ArtistDataPress Layouts'; register_setting( 'slushman_adp_layout_settings', 'slushman_adp_layout_settings' ); add_settings_section( 'slushman_adp_layout', 'Choose the Layout', array( $this, 'layout_section' ), 'slushman_adp_layout_settings' ); add_settings_field( 'slushman_adp_layout_field', 'Choose the layout for your events.', array( $this, 'layout_preference_field' ), 'slushman_adp_layout_settings', 'slushman_adp_layout' ); } // End of register_layout_settings() function url_section() { echo '

The ArtistData XML feed URL can be found on your ArtistData account by going to Tools > Data Feeds.

'; } function xml_url_field() { ?> Choose what information you want displayed on your calendar.

'; } function max_shows_field() { $max = ( empty( $this->gensets['max_shows'] ) ? 'All' : $this->gensets['max_shows'] ); ?> gensets['display_name'], 'on' ); ?> /> gensets['display_stage'], 'on' ); ?> /> gensets['display_artist'], 'on' ); ?> /> gensets['display_tickets'], 'on' ); ?> /> gensets['display_age'], 'on' ); ?> /> gensets['display_country'], 'on' ); ?> /> Choose how you want to format your times and dates.

'; } function display_time_field() { ?> gensets['display_time'], 'on' ); ?> />
gensets['adp_time_format'] ); ?>
  • Examples...
  • =
gensets['adp_date_format'] ); ?>
  • Examples...
  • =
Please note: These settings do not apply to the iCal layout.
Please see the documentation on date and time formatting for additional formats.' ); ?>


get_layout( array( 'layout' => $choice, 'limit' => 3, 'source' => 'layout' ) ); ?>
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 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_layout_settings' ); $layout_opt = $options['adp_layout']; $layout = new Layout; $layout->get_layout( array( 'layout' => $layout_opt ) ); $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' ); include( 'inc/slushman_toolkit.php' ); } // End of file_includer() } // End of ArtistDataPress_Plugin } // End of class check require_once( dirname( __FILE__ ) . '/inc/adp_widget.php' ); new ArtistDataPress_Plugin; ?>