. ************************************************************************** */ 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, 'register_settings' ) ); // 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() { ?>
Choose what information you want displayed on your calendar.
'; } function time_section_fn() { echo 'Choose how you want to format your times and dates.
'; } function styling_section_fn() { echo 'Choose how you want the calendar to appear.
'; } // End of styling_section_fn() function xml_url_field_fn() { $options = get_option( 'slushman_adp_options' ); ?> " /> " /> " /> /> /> /> /> " /> /> curl_redir_exec( $xml_url ); } // End of safe_mode check 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; } // 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() // Follow on location problems workaround function curl_redir_exec( $ch ) { static $curl_loops = 0; static $curl_max_loops = 20; if ( $curl_loops++ >= $curl_max_loops ) { $curl_loops = 0; return FALSE; } curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $data = curl_exec( $ch ); list( $header, $data ) = explode( "\n\n", $data, 2 ); $http_code = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); if ( $http_code == 301 || $http_code == 302 ) { $matches = array(); preg_match( '/Location:(.*?)\n/', $header, $matches ); $url = @parse_url( trim( array_pop( $matches ) ) ); if ( !$url ) { // Couldn't process the url to redirect to $curl_loops = 0; return $data; } $last_url = parse_url( curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL ) ); if ( !$url['scheme'] ) { $url['scheme'] = $last_url['scheme']; } if ( !$url['host'] ) { $url['host'] = $last_url['host']; } if ( !$url['path'] ) { $url['path'] = $last_url['path']; } $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query']?'?'.$url['query']:''); curl_setopt( $ch, CURLOPT_URL, $new_url ); return $this->curl_redir_exec( $ch ); } else { $curl_loops = 0; return $data; } // End of $http_code check } // End of curl_redir_exec() /** * 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(); ?>The %s field is either invalid or empty.
This %s is already used by another user.
The %s is not set.
Could not %s the %s.
%s %s successfully.
%s has already received credit for this seminar.
%s has been marked as enrolled.
This student is not currently registered for the seminar course.
%s
Attendance at %s for %s was added successfully.
%s updated, but %s did not.