. ************************************************************************** */ /* Runs when plugin is activated */ register_activation_hook( __FILE__,'slushman_adp_install' ); function slushman_adp_install() { /* Creates new database fields */ $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 ); } /* Queues the included stylesheet */ wp_register_style( 'slushman-adp', plugins_url( 'css/artistdatapress.css', __FILE__ ) ); wp_enqueue_style( 'slushman-adp' ); /***** Options Page *****/ /* Adds the ArtistDataPress option menu to the Settings menu */ add_action( 'admin_menu', 'slushman_adp_admin_menu' ); function slushman_adp_admin_menu() { add_options_page( 'ArtistDataPress Options', 'ArtistDataPress', 'manage_options', 'slushman-adp', 'slushman_adp_options_page' ); } /* Add "Settings" link to plugin page */ add_filter('plugin_action_links_' . plugin_basename(__FILE__) , 'slushman_adp_settings_link_fn'); function slushman_adp_settings_link_fn($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; } /* Draw the options page */ function slushman_adp_options_page() { ?>

ArtistDataPress Options


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

'; } /* Add XML URL Field */ function slushman_adp_xml_url_field_fn() { /* Get options from database */ $options = get_option( 'slushman_adp_options' ); $slushman_adp_xml_url = $options['slushman_adp_xml_url']; /* Echo the field */ echo ""; } /* Add ArtistData Page URL Field */ function slushman_adp_adpage_url_field_fn() { /* Get options from database */ $options = get_option( 'slushman_adp_options' ); $slushman_adp_adpage_url = $options['slushman_adp_adpage_url']; /* Echo the field */ echo ""; } /* Add displays section to customize what information is shown the calendar page */ function slushman_adp_display_section() { echo '

Choose what information you want displayed on your calendar.

'; } /* Add max shows field */ function slushman_adp_max_shows_field_fn() { /* Get options from database */ $options = get_option( 'slushman_adp_options' ); $slushman_adp_max_shows = $options['slushman_adp_max_shows']; //echo the field echo ""; } /* Add display name field */ function slushman_adp_display_name_field_fn() { /* Get options from database */ $options = get_option( 'slushman_adp_options' ); $slushman_adp_display_name = $options['slushman_adp_display_name']; // Display the field ?> /> /> /> /> /> "; } /* Validate the options fields */ function slushman_adp_validate_options( $input ) { $input['slushman_adp_xml_url'] = esc_url_raw( $input['slushman_adp_xml_url'] ); $input['slushman_adp_adpage_url'] = esc_url( $input['slushman_adp_adpage_url'] ); $input['slushman_adp_max_shows'] = intval( $input['slushman_adp_max_shows'] ); return $input; } /***** ArtistDataPress *****/ /* Process the raw ArtistData XML feed */ function slushman_adp_xml() { $options = get_option( 'slushman_adp_options' ); $slushman_adp_xml_url = $options['slushman_adp_xml_url']; $feed = @simplexml_load_file( $slushman_adp_xml_url, 'SimpleXMLElement', LIBXML_NOCDATA ); $key = $feed->show[0]->recordKey; if ( $key && ( $key != '' ) ) { return $feed; } else { $feed = 0; return $feed; } } /* Get the XML date and change it into a more readable format */ function slushman_adp_date_morph(&$rawdate) { $middle_date = strtotime( $rawdate ); $date = date( 'l, n/d/Y', $middle_date ); return $date; } /* Get the show time and change it into a more readable format */ function slushman_adp_time_morph(&$rawtime) { $limitedshowtime = substr ( $rawtime, 0, 8 ); $showtime = date( 'g:i a', strtotime( $limitedshowtime ) ); return $showtime; } /* This is the app itself. */ function slushman_artistdatapress() { /* Get options and make them variables */ $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_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 = slushman_adp_xml(); ?>
date; $date = slushman_adp_date_morph($rawdate); echo $date; ?>timeSet; $showtime = slushman_adp_time_morph($rawshowtime); echo ', ' . $showtime; ?>
venueURI ) ) { ?> venueName; ?> venueName; ?>venueURI ) ?>
venueAddress ) ) { ?> city; if ( $show->stateAbbreviation == 'No State' ) { echo ', ' . $show->country; } elseif ( $slushman_adp_country == 'on' ) { echo ', ' . $show->stateAbbreviation . ', ' . $show->countryAbbreviation; } else { echo ', ' . $show->stateAbbreviation; } ?> - map city; if ( $show->stateAbbreviation == 'No State' ) { echo ', ' . $show->country; } elseif ( $slushman_adp_country == 'on' ) { echo ', ' . $show->stateAbbreviation . ', ' . $show->countryAbbreviation; } else { echo ', ' . $show->stateAbbreviation; } ?> venueAddress ) ) ?>
name; ?>
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; ?>