Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reformatting code/tabs=>whitespace

  • Loading branch information...
commit ba370f6f8c79ee4a6e5bb75d018bc050dc8b8508 1 parent 9e9bc8b
@saleandro authored
View
24 songkick_artist_events.php
@@ -2,20 +2,20 @@
require_once dirname(__FILE__) . '/songkick_events.php';
class SongkickArtistEvents extends SongkickEvents {
- public $id;
- public $apikey;
+ public $id;
+ public $apikey;
- function SongkickArtistEvents($apikey, $id) {
- $this->SongkickEvents($apikey);
- $this->id = trim($id);
- }
+ function SongkickArtistEvents($apikey, $id) {
+ $this->SongkickEvents($apikey);
+ $this->id = trim($id);
+ }
- function profile_url() {
- return "http://www.songkick.com/artists/$this->id";
- }
+ function profile_url() {
+ return "http://www.songkick.com/artists/$this->id";
+ }
- protected function url($per_page){
- return "$this->apiurl/artists/$this->id/calendar.json?apikey=$this->apikey&per_page=$per_page";
- }
+ protected function url($per_page){
+ return "$this->apiurl/artists/$this->id/calendar.json?apikey=$this->apikey&per_page=$per_page";
+ }
}
?>
View
28 songkick_concerts.css
@@ -1,33 +1,33 @@
div.songkick-events .profile-title {
- margin-top: 8px;
- margin-bottom: 10px;
- float: right;
+ margin-top: 8px;
+ margin-bottom: 10px;
+ float: right;
}
div.songkick-events .powered-by {
- margin: 0px;
+ margin: 0px;
}
div.songkick-events .powered-by img {
- margin: 0px;
- border: 0px;
+ margin: 0px;
+ border: 0px;
}
div.songkick-events .event-name {
- display:block;
- margin-left:44px;
+ display:block;
+ margin-left:44px;
}
div.songkick-events ul {
- border-bottom:1px solid #CCCCCC;
- margin-bottom:5px;
- margin-top: 10px;
- margin-left: 0px;
- list-style:none outside none;
+ border-bottom:1px solid #CCCCCC;
+ margin-bottom:5px;
+ margin-top: 10px;
+ margin-left: 0px;
+ list-style:none outside none;
}
div.songkick-events li {
- margin-bottom: 10px;
+ margin-bottom: 10px;
}
View
134 songkick_concerts_and_festivals.php
@@ -32,13 +32,13 @@
*/
// For debugging:
-// error_reporting(E_ALL);
-// if ( !defined('WP_DEBUG') )
-// define('WP_DEBUG', true);
-// @ini_set('display_errors','On');
+error_reporting(E_ALL);
+if ( !defined('WP_DEBUG') )
+ define('WP_DEBUG', true);
+@ini_set('display_errors','On');
if (!class_exists('WP_Http'))
- include_once(ABSPATH . WPINC . '/class-http.php');
+ include_once(ABSPATH . WPINC . '/class-http.php');
define('SONGKICK_OPTIONS', 'songkick-concerts');
define('SONGKICK_TEXT_DOMAIN', 'songkick-concerts-and-festivals');
@@ -53,83 +53,83 @@
* Global Initialization of the Songkick Plugin
*/
function songkick_plugin_init() {
- // Load Plugin Text Domain for i18n
- load_plugin_textdomain(SONGKICK_TEXT_DOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
+ // Load Plugin Text Domain for i18n
+ load_plugin_textdomain(SONGKICK_TEXT_DOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action('init', 'songkick_plugin_init');
function songkick_concerts_and_festivals_shortcode_handler($options = null) {
- try {
- wp_enqueue_style('songkick_concerts', '/wp-content/plugins/songkick-concerts-and-festivals/songkick_concerts.css') ;
-
- $default_options = get_option(SONGKICK_OPTIONS);
- if (is_array($options)) {
- $options = array_merge($default_options, $options);
- } else {
- $options = $default_options;
- }
- $options['logo'] = $options['shortcode_logo'];
- $options['date_color'] = $options['shortcode_date_color'];
- $options['number_of_events'] = $options['shortcode_number_of_events'];
-
- $sk = new SongkickPresentableEvents($options);
- $str = '<div class="songkick-events">';
- $str .= $sk->to_html();
- $str .= '</div>';
- return $str;
- } catch (Exception $e) {
- $msg = 'Error on '.get_bloginfo('url').' while trying to display Songkick Concerts plugin: '. $e->getMessage();
- error_log($msg, 0);
- }
+ try {
+ wp_enqueue_style('songkick_concerts', '/wp-content/plugins/songkick-concerts-and-festivals/songkick_concerts.css') ;
+
+ $default_options = get_option(SONGKICK_OPTIONS);
+ if (is_array($options)) {
+ $options = array_merge($default_options, $options);
+ } else {
+ $options = $default_options;
+ }
+ $options['logo'] = $options['shortcode_logo'];
+ $options['date_color'] = $options['shortcode_date_color'];
+ $options['number_of_events'] = $options['shortcode_number_of_events'];
+
+ $sk = new SongkickPresentableEvents($options);
+ $str = '<div class="songkick-events">';
+ $str .= $sk->to_html();
+ $str .= '</div>';
+ return $str;
+ } catch (Exception $e) {
+ $msg = 'Error on '.get_bloginfo('url').' while trying to display Songkick Concerts plugin: '. $e->getMessage();
+ error_log($msg, 0);
+ }
}
/**
* Global Initialization of the Songkick Sidebar Widget
*/
function songkick_widget_init() {
- if (!function_exists('register_sidebar_widget'))
- return;
-
- wp_enqueue_style('songkick_concerts', '/wp-content/plugins/songkick-concerts-and-festivals/songkick_concerts.css') ;
-
- function songkick_widget($args) {
- try {
- extract($args);
-
- $options = get_option(SONGKICK_OPTIONS);
- $hide_if_empty = $options['hide_if_empty'];
-
- $sk = new SongkickPresentableEvents($options);
-
- if ($hide_if_empty && $sk->no_events()) return;
-
- $options = get_option(SONGKICK_OPTIONS);
- $title = $options['title'];
- if (!$title || $title == '') {
- $title = __('Concerts', SONGKICK_TEXT_DOMAIN);
- }
- $title = htmlentities($title, ENT_QUOTES, SONGKICK_I18N_ENCODING);
-
- echo $before_widget;
- echo '<div class="songkick-events">';
- echo $before_title . $title . $after_title;
- echo $sk->to_html();
- echo '</div>';
- echo $after_widget;
- } catch (Exception $e) {
- $msg = 'Error on '.get_bloginfo('url').' while trying to display Songkick Concerts plugin: '. $e->getMessage();
- error_log($msg, 0);
- }
- }
-
- register_sidebar_widget(array('Songkick Concerts and Festivals', 'widgets'), 'songkick_widget');
- register_widget_control(array('Songkick Concerts and Festivals', 'widgets'), 'songkick_widget_settings');
+ if (!function_exists('register_sidebar_widget'))
+ return;
+
+ wp_enqueue_style('songkick_concerts', '/wp-content/plugins/songkick-concerts-and-festivals/songkick_concerts.css') ;
+
+ function songkick_widget($args) {
+ try {
+ extract($args);
+
+ $options = get_option(SONGKICK_OPTIONS);
+ $hide_if_empty = $options['hide_if_empty'];
+
+ $sk = new SongkickPresentableEvents($options);
+
+ if ($hide_if_empty && $sk->no_events()) return;
+
+ $options = get_option(SONGKICK_OPTIONS);
+ $title = $options['title'];
+ if (!$title || $title == '') {
+ $title = __('Concerts', SONGKICK_TEXT_DOMAIN);
+ }
+ $title = htmlentities($title, ENT_QUOTES, SONGKICK_I18N_ENCODING);
+
+ echo $before_widget;
+ echo '<div class="songkick-events">';
+ echo $before_title . $title . $after_title;
+ echo $sk->to_html();
+ echo '</div>';
+ echo $after_widget;
+ } catch (Exception $e) {
+ $msg = 'Error on '.get_bloginfo('url').' while trying to display Songkick Concerts plugin: '. $e->getMessage();
+ error_log($msg, 0);
+ }
+ }
+
+ register_sidebar_widget(array('Songkick Concerts and Festivals', 'widgets'), 'songkick_widget');
+ register_widget_control(array('Songkick Concerts and Festivals', 'widgets'), 'songkick_widget_settings');
}
add_action('admin_menu', 'songkick_admin_menu');
function songkick_admin_menu() {
- add_options_page('Songkick Concerts and Festivals', 'Songkick', 'administrator', 'songkick-concerts-and-festivals', 'songkick_admin_settings');
+ add_options_page('Songkick Concerts and Festivals', 'Songkick', 'administrator', 'songkick-concerts-and-festivals', 'songkick_admin_settings');
}
add_shortcode("songkick_concerts_and_festivals", "songkick_concerts_and_festivals_shortcode_handler");
View
128 songkick_events.php
@@ -1,75 +1,75 @@
<?php
class SongkickEvents {
- public $apikey;
- public $upcoming_events = array();
+ public $apikey;
+ public $upcoming_events = array();
- function SongkickEvents($apikey) {
- $this->apikey = trim($apikey);
- $this->apiurl = 'http://api.songkick.com/api/3.0';
- }
+ function SongkickEvents($apikey) {
+ $this->apikey = trim($apikey);
+ $this->apiurl = 'http://api.songkick.com/api/3.0';
+ }
- function get_upcoming_events($per_page=10) {
- $cached_results = $this->get_cached_results($this->url($per_page));
- if ($this->cache_expired($cached_results)) {
- $events = $this->get_uncached_upcoming_events($per_page);
- $cached_results = array('events' => $events, 'timestamp'=> time());
- $this->set_cached_results($this->url($per_page), $cached_results);
- } else {
- $events = $cached_results['events'];
- }
- return $events;
- }
-
- protected function get_cached_results($key) {
- $all_cache = get_option(SONGKICK_CACHE);
- if (isset($all_cache[$key]) && $all_cache[$key]) {
- return $all_cache[$key];
- } else {
- return NULL;
- }
- }
-
- protected function get_uncached_upcoming_events($per_page) {
- $response = $this->fetch($this->url($per_page));
- return $this->events_from_json($response);
- }
+ function get_upcoming_events($per_page=10) {
+ $cached_results = $this->get_cached_results($this->url($per_page));
+ if ($this->cache_expired($cached_results)) {
+ $events = $this->get_uncached_upcoming_events($per_page);
+ $cached_results = array('events' => $events, 'timestamp'=> time());
+ $this->set_cached_results($this->url($per_page), $cached_results);
+ } else {
+ $events = $cached_results['events'];
+ }
+ return $events;
+ }
+
+ protected function get_cached_results($key) {
+ $all_cache = get_option(SONGKICK_CACHE);
+ if (isset($all_cache[$key]) && $all_cache[$key]) {
+ return $all_cache[$key];
+ } else {
+ return NULL;
+ }
+ }
+
+ protected function get_uncached_upcoming_events($per_page) {
+ $response = $this->fetch($this->url($per_page));
+ return $this->events_from_json($response);
+ }
- protected function set_cached_results($key, $value) {
- $all_cache = get_option(SONGKICK_CACHE);
- if (!$all_cache) {
- $all_cache = array();
- }
- $all_cache[$key] = $value;
- update_option(SONGKICK_CACHE, $all_cache);
- }
-
- protected function cache_expired($cached_results) {
- if (!$cached_results || $cached_results == null) return true;
- return (bool) ((time() - $cached_results['timestamp'] ) > SONGKICK_REFRESH_CACHE);
- }
+ protected function set_cached_results($key, $value) {
+ $all_cache = get_option(SONGKICK_CACHE);
+ if (!$all_cache) {
+ $all_cache = array();
+ }
+ $all_cache[$key] = $value;
+ update_option(SONGKICK_CACHE, $all_cache);
+ }
+
+ protected function cache_expired($cached_results) {
+ if (!$cached_results || $cached_results == null) return true;
+ return (bool) ((time() - $cached_results['timestamp'] ) > SONGKICK_REFRESH_CACHE);
+ }
- protected function fetch($url) {
- $http = new WP_Http;
- $response = $http->request($url);
- if (is_wp_error($response)) {
- throw new Exception('WP_Http/WP_Error message: '.$response->get_error_message());
- } elseif (!is_array($response)) {
- throw new Exception('WP_Http/Invalid response');
- } elseif ($response['response']['code'] != 200) {
- throw new Exception('WP_Http error response: '.$response['response']['code']);
- }
- return $response['body'];
- }
+ protected function fetch($url) {
+ $http = new WP_Http;
+ $response = $http->request($url);
+ if (is_wp_error($response)) {
+ throw new Exception('WP_Http/WP_Error message: '.$response->get_error_message());
+ } elseif (!is_array($response)) {
+ throw new Exception('WP_Http/Invalid response');
+ } elseif ($response['response']['code'] != 200) {
+ throw new Exception('WP_Http error response: '.$response['response']['code']);
+ }
+ return $response['body'];
+ }
- protected function events_from_json($json) {
- $json_docs = json_decode($json);
- if ($json_docs->resultsPage->totalEntries === 0) {
- return array();
- } else {
- return $json_docs->resultsPage->results->event;
- }
- }
+ protected function events_from_json($json) {
+ $json_docs = json_decode($json);
+ if ($json_docs->resultsPage->totalEntries === 0) {
+ return array();
+ } else {
+ return $json_docs->resultsPage->results->event;
+ }
+ }
}
?>
View
24 songkick_metro_area_events.php
@@ -2,20 +2,20 @@
require_once dirname(__FILE__) . '/songkick_events.php';
class SongkickMetroAreaEvents extends SongkickEvents {
- public $id;
- public $apikey;
+ public $id;
+ public $apikey;
- function SongkickMetroAreaEvents($apikey, $id) {
- $this->SongkickEvents($apikey);
- $this->id = trim($id);
- }
+ function SongkickMetroAreaEvents($apikey, $id) {
+ $this->SongkickEvents($apikey);
+ $this->id = trim($id);
+ }
- function profile_url() {
- return "http://www.songkick.com/metro_areas/$this->id";
- }
+ function profile_url() {
+ return "http://www.songkick.com/metro_areas/$this->id";
+ }
- protected function url($per_page){
- return "$this->apiurl/metro_areas/$this->id/calendar.json?apikey=$this->apikey&per_page=$per_page";
- }
+ protected function url($per_page){
+ return "$this->apiurl/metro_areas/$this->id/calendar.json?apikey=$this->apikey&per_page=$per_page";
+ }
}
?>
View
131 songkick_presentable_events.php
@@ -7,76 +7,75 @@
require_once dirname(__FILE__) . '/songkick_venue_events.php';
class SongkickPresentableEvents {
-
- function SongkickPresentableEvents($options) {
- if ($options['username']) {
- $songkick_id = $options['username'];
- $songkick_id_type = 'user';
- } else {
- $songkick_id = $options['songkick_id'];
- $songkick_id_type = $options['songkick_id_type'];
- }
- $apikey = $options['apikey'];
- $attendance = $options['attendance'];
- $number_of_events = $options['number_of_events'];
-
- switch ($songkick_id_type) {
- case 'user':
- $this->songkick_events = new SongkickUserEvents($apikey, $songkick_id, $attendance);
- break;
- case 'artist':
- $this->songkick_events = new SongkickArtistEvents($apikey, $songkick_id);
- break;
- case 'metro_area':
- $this->songkick_events = new SongkickMetroAreaEvents($apikey, $songkick_id);
- break;
- case 'venue':
- $this->songkick_events = new SongkickVenueEvents($apikey, $songkick_id);
- break;
- default:
- throw new Exception("Unknown songkick id type: $songkick_id_type");
- }
- $this->events = $this->songkick_events->get_upcoming_events($number_of_events);
- $this->date_color = $options['date_color'];
- $this->logo = $options['logo'];
- $this->no_calendar_style = false;
- if (isset($options['no_calendar_style'])) {
- $this->no_calendar_style = $options['no_calendar_style'];
- }
- }
+ function SongkickPresentableEvents($options) {
+ if ($options['username']) {
+ $songkick_id = $options['username'];
+ $songkick_id_type = 'user';
+ } else {
+ $songkick_id = $options['songkick_id'];
+ $songkick_id_type = $options['songkick_id_type'];
+ }
+ $apikey = $options['apikey'];
+ $attendance = $options['attendance'];
+ $number_of_events = $options['number_of_events'];
- function to_html() {
- $profile_title = __('See all concerts', SONGKICK_TEXT_DOMAIN);
+ switch ($songkick_id_type) {
+ case 'user':
+ $this->songkick_events = new SongkickUserEvents($apikey, $songkick_id, $attendance);
+ break;
+ case 'artist':
+ $this->songkick_events = new SongkickArtistEvents($apikey, $songkick_id);
+ break;
+ case 'metro_area':
+ $this->songkick_events = new SongkickMetroAreaEvents($apikey, $songkick_id);
+ break;
+ case 'venue':
+ $this->songkick_events = new SongkickVenueEvents($apikey, $songkick_id);
+ break;
+ default:
+ throw new Exception("Unknown songkick id type: $songkick_id_type");
+ }
- $str = '';
- if (empty($this->events)) {
- $str .= '<p>'. htmlentities(__('No events...'), ENT_QUOTES, SONGKICK_I18N_ENCODING). '</p>';
- } else {
- $str .= '<ul class="songkick-events">';
- foreach($this->events as $event) {
- $presentable_event = new SongkickPresentableEvent($event);
- $str .= '<li>'.$presentable_event->to_html($this->no_calendar_style, $this->date_color).'</li>';
- }
- $str .= '</ul>';
- }
- $str .= '<p class="profile-title"><a href="'.$this->songkick_events->profile_url().'">';
- $str .= htmlentities($profile_title, ENT_QUOTES, SONGKICK_I18N_ENCODING)."</a></p>";
- $str .= $this->powered_by_songkick($this->logo);
- return $str;
- }
-
- function no_events() {
- return empty($this->events);
- }
-
- private function powered_by_songkick($logo) {
- $text = __('Concerts by Songkick', SONGKICK_TEXT_DOMAIN);
- $html = "<a class='powered-by' href='http://www.songkick.com/'>";
- $html .= "<img src='".site_url('/wp-content/plugins/songkick-concerts-and-festivals/'.$logo)."' title='".htmlentities($text, ENT_QUOTES, SONGKICK_I18N_ENCODING)."' alt='".htmlentities($text, ENT_QUOTES, SONGKICK_I18N_ENCODING)."' /></a>";
- return $html;
- }
+ $this->events = $this->songkick_events->get_upcoming_events($number_of_events);
+ $this->date_color = $options['date_color'];
+ $this->logo = $options['logo'];
+ $this->no_calendar_style = false;
+ if (isset($options['no_calendar_style'])) {
+ $this->no_calendar_style = $options['no_calendar_style'];
+ }
+ }
+ function to_html() {
+ $profile_title = __('See all concerts', SONGKICK_TEXT_DOMAIN);
+
+ $str = '';
+ if (empty($this->events)) {
+ $str .= '<p>'. htmlentities(__('No events...'), ENT_QUOTES, SONGKICK_I18N_ENCODING). '</p>';
+ } else {
+ $str .= '<ul class="songkick-events">';
+ foreach($this->events as $event) {
+ $presentable_event = new SongkickPresentableEvent($event);
+ $str .= '<li>'.$presentable_event->to_html($this->no_calendar_style, $this->date_color).'</li>';
+ }
+ $str .= '</ul>';
+ }
+ $str .= '<p class="profile-title"><a href="'.$this->songkick_events->profile_url().'">';
+ $str .= htmlentities($profile_title, ENT_QUOTES, SONGKICK_I18N_ENCODING)."</a></p>";
+ $str .= $this->powered_by_songkick($this->logo);
+ return $str;
+ }
+
+ function no_events() {
+ return empty($this->events);
+ }
+
+ private function powered_by_songkick($logo) {
+ $text = __('Concerts by Songkick', SONGKICK_TEXT_DOMAIN);
+ $html = "<a class='powered-by' href='http://www.songkick.com/'>";
+ $html .= "<img src='".site_url('/wp-content/plugins/songkick-concerts-and-festivals/'.$logo)."' title='".htmlentities($text, ENT_QUOTES, SONGKICK_I18N_ENCODING)."' alt='".htmlentities($text, ENT_QUOTES, SONGKICK_I18N_ENCODING)."' /></a>";
+ return $html;
+ }
}
?>
View
322 songkick_settings.php
@@ -1,171 +1,171 @@
<?php
function songkick_widget_settings() {
- echo '<a href="options-general.php?page=songkick-concerts-and-festivals">Please go to the plugin\'s settings page.</a>';
+ echo '<a href="options-general.php?page=songkick-concerts-and-festivals">Please go to the plugin\'s settings page.</a>';
}
function songkick_admin_settings() {
$max_number_events = 100;
- $options = get_option(SONGKICK_OPTIONS);
- if (!is_array($options)) {
- $options = array(
- 'title' => '',
- 'songkick_id' => '',
- 'songkick_id_type' => 'user',
- 'apikey' => '',
- 'attendance' => 'all',
- 'hide_if_empty' => false,
- 'number_of_events' => 10,
- 'logo' => 'songkick-logo.png',
- 'date_color' => '#303030',
- 'shortcode_number_of_events' => 50,
- 'shortcode_logo' => 'songkick-logo.png',
- 'shortcode_date_color' => '#303030'
- );
- }
-
- if (current_user_can('manage_options') && isset($_POST['songkick_submit']) && $_POST['songkick_submit']) {
- $options['username'] = null;
- $options['songkick_id'] = trim(strip_tags(stripslashes($_POST['songkick_id'])));
- $options['songkick_id_type'] = strip_tags(stripslashes($_POST['songkick_id_type']));
- $options['attendance'] = strip_tags(stripslashes($_POST['songkick_attendance']));
- $options['apikey'] = trim(strip_tags(stripslashes($_POST['songkick_apikey'])));
-
- $options['title'] = strip_tags(stripslashes($_POST['songkick_title']));
- $options['hide_if_empty'] = ($_POST['songkick_hide_if_empty'] === 'on');
- $options['logo'] = strip_tags(stripslashes($_POST['songkick_logo']));
- $options['date_color'] = strip_tags(stripslashes($_POST['songkick_date_color']));
- $limit = (int)$_POST['songkick_number_of_events'];
- if ($limit > $max_number_events) $limit = $max_number_events;
- $options['number_of_events'] = $limit;
-
- $options['shortcode_logo'] = strip_tags(stripslashes($_POST['shortcode_songkick_logo']));
- $options['shortcode_date_color'] = strip_tags(stripslashes($_POST['shortcode_songkick_date_color']));
- $limit = (int)$_POST['songkick_shortcode_number_of_events'];
- if ($limit > $max_number_events) $limit = $max_number_events;
- $options['shortcode_number_of_events'] = $limit;
-
- update_option(SONGKICK_CACHE, null);
- update_option(SONGKICK_OPTIONS, $options);
- }
-
- if ($options['username']) {
- $songkick_id_type = 'user';
- $songkick_id = htmlspecialchars($options['username'], ENT_QUOTES);
- } else {
- $songkick_id_type = htmlspecialchars($options['songkick_id_type'], ENT_QUOTES);
- $songkick_id = htmlspecialchars($options['songkick_id'], ENT_QUOTES);
- }
- $title = htmlspecialchars($options['title'], ENT_QUOTES);
- $apikey = htmlspecialchars($options['apikey'], ENT_QUOTES);
-
- $attendance = htmlspecialchars($options['attendance']);
- $hide_if_empty = ($options['hide_if_empty']) ? 'checked="checked"' : '';
- $songkick_logo = htmlspecialchars($options['logo'], ENT_QUOTES);
- $date_color = htmlspecialchars($options['date_color'], ENT_QUOTES);
- $number_of_events = htmlspecialchars($options['number_of_events']);
-
- $shortcode_songkick_logo = htmlspecialchars($options['shortcode_logo'], ENT_QUOTES);
- $shortcode_date_color = htmlspecialchars($options['shortcode_date_color'], ENT_QUOTES);
- $shortcode_number_of_events = htmlspecialchars($options['shortcode_number_of_events']);
-
- echo '<div class="wrap" id="songkick_concerts_and_festivals_settings">
- <div id="icon-options-general" class="icon32"></div>
- <h2>Songkick Concerts and Festivals Settings</h2>';
-
- echo '<p class="description">Add [songkick_concerts_and_festivals] anywhere in a content to get your list of events.</p>';
- echo '<p class="description">You can also add the Songkick widget to your template.</p>';
-
- echo '<form method="post">';
- echo '<h3>Main settings</h3>';
-
- echo '<table class="form-table">';
- echo '<tr><th><label for="songkick_apikey">' . 'Songkick API Key' . '</label></th>';
- echo '<td><input id="songkick_apikey" name="songkick_apikey" type="text" value="'.$apikey.'" />';
- echo '<span class="description">Required &ndash; <a href="http://developer.songkick.com">Request one from Songkick</a></span>';
- echo '</td></tr>';
-
- echo '<tr><th><label for="songkick_id_type">' . 'Songkick ID' . '</label></th>';
- echo '<td><select id="songkick_id_type" name="songkick_id_type">';
- echo ' <option value="user" '.(($songkick_id_type == 'user') ? ' selected' : '').'>username</option>';
- echo ' <option value="artist" '.(($songkick_id_type == 'artist') ? ' selected' : '').'>artist id</option>';
- echo ' <option value="venue" '.(($songkick_id_type == 'venue') ? ' selected' : '').'>venue id</option>';
- echo ' <option value="metro_area" '.(($songkick_id_type == 'metro_area') ? ' selected' : '').'>metro area id</option>';
- echo ' </select>';
- echo ' <input size="15" id="songkick_id" name="songkick_id" type="text" value="'.$songkick_id.'" />';
- echo '<span class="description">Required</span>';
- echo '</td></tr>';
-
- echo '<tr><th><label for="songkick_attendance">' . 'Attendance' . '</label></th>';
- echo '<td><select id="songkick_attendance" name="songkick_attendance">';
- echo ' <option value="all" '.(($attendance == 'all') ? ' selected' : '').'>all</option>';
- echo ' <option value="im_going" '.(($attendance == 'im_going') ? ' selected' : '').'>I’m going</option>';
- echo ' <option value="i_might_go" '.(($attendance == 'i_might_go') ? ' selected' : '').'>I might go</option>';
- echo ' </select>';
- echo '<span class="description">For users only</span>';
- echo '</td></tr>';
-
- echo '<tr><td colspan="2">You can also specify different user, artist, venue, or metro area ids when using the shortcode function. ';
- echo ' <br>For users:&nbsp;&nbsp;<code>[songkick_concerts_and_festivals songkick_id=your_username &nbsp;songkick_id_type=user]</code>';
- echo ' <br>For artists: <code>[songkick_concerts_and_festivals songkick_id=your_artist_id songkick_id_type=artist]</code>';
- echo ' <br>For venues: <code>[songkick_concerts_and_festivals songkick_id=your_venue_id songkick_id_type=venue]</code>';
- echo ' <br>For metro areas: <code>[songkick_concerts_and_festivals songkick_id=your_metro_area_id songkick_id_type=metro_area]</code>';
- echo '</td></tr>';
-
- echo '</table>';
-
- echo '<br><h3>Shortcode settings</h3>';
- echo '<table class="form-table">';
- echo '<tr><th><label for="songkick_shortcode_number_of_events">Number of events to show</label></th>';
- echo '<td><input id="songkick_shortcode_number_of_events" name="songkick_shortcode_number_of_events" type="text" value="'.$shortcode_number_of_events.'" /> ';
- echo '<span class="description"> Max. 100</span>';
- echo '</td></tr>';
- echo '<tr><th><label for="shortcode_songkick_logo">' . 'Songkick logo' . '</label></th>';
- echo '<td><select id="shortcode_songkick_logo" name="shortcode_songkick_logo">';
- echo ' <option value="songkick-logo.png" '.(($shortcode_songkick_logo == 'songkick-logo.png') ? ' selected' : '').'>' .
- 'white background' . '</option>';
- echo ' <option value="songkick-logo-black.png" '.(($shortcode_songkick_logo == 'songkick-logo-black.png') ? ' selected' : '').'>' .
- 'black background' . '</option>';
- echo ' </select>';
- echo '</td></tr>';
- echo '<tr><th><label for="shortcode_songkick_date_color">' . 'Background color for date:' . '</label></th>';
- echo '<td><input id="shortcode_songkick_date_color" name="shortcode_songkick_date_color" type="text" value="'.$shortcode_date_color.'" />';
- echo '</td></tr>';
- echo '</table>';
-
- echo '<br><h3>Widget settings</h3>';
-
- echo '<table class="form-table">';
- echo '<tr><th><label for="songkick_title">' . 'Title:' . '</label></th>';
- echo '<td><input id="songkick_title" name="songkick_title" type="text" value="'.$title.'" />';
- echo '</td></tr>';
-
- echo '<tr><th><label for="songkick_number_of_events">Number of events to show</label></th>';
- echo '<td><input id="songkick_number_of_events" name="songkick_number_of_events" type="text" value="'.$number_of_events.'" /> ';
- echo '<span class="description"> Max. 100</span>';
- echo '</td></tr>';
-
- echo '<tr><th><label for="songkick_hide_if_empty">Hide if there are no events?</label></th>';
- echo '<td><input id="songkick_hide_if_empty" name="songkick_hide_if_empty" type="checkbox" '.$hide_if_empty.' /> ';
- echo '</td></tr>';
-
- echo '<tr><th><label for="songkick_logo">' . 'Songkick logo' . '</label></th>';
- echo '<td><select id="songkick_logo" name="songkick_logo">';
- echo ' <option value="songkick-logo.png" '.(($songkick_logo == 'songkick-logo.png') ? ' selected' : '').'>' .
- 'white background' . '</option>';
- echo ' <option value="songkick-logo-black.png" '.(($songkick_logo == 'songkick-logo-black.png') ? ' selected' : '').'>' .
- 'black background' . '</option>';
- echo ' </select>';
- echo '</td></tr>';
-
- echo '<tr><th><label for="songkick_date_color">' . 'Background color for date:' . '</label></th>';
- echo '<td><input id="songkick_date_color" name="songkick_date_color" type="text" value="'.$date_color.'" />';
- echo '</td></tr>';
-
- echo '</table>';
-
- echo '<p class="submit"><input type="submit" class="button-primary" name="songkick_submit" value="Save Changes" /></p>';
- echo '</form></div>';
+ $options = get_option(SONGKICK_OPTIONS);
+ if (!is_array($options)) {
+ $options = array(
+ 'title' => '',
+ 'songkick_id' => '',
+ 'songkick_id_type' => 'user',
+ 'apikey' => '',
+ 'attendance' => 'all',
+ 'hide_if_empty' => false,
+ 'number_of_events' => 10,
+ 'logo' => 'songkick-logo.png',
+ 'date_color' => '#303030',
+ 'shortcode_number_of_events' => 50,
+ 'shortcode_logo' => 'songkick-logo.png',
+ 'shortcode_date_color' => '#303030'
+ );
+ }
+
+ if (current_user_can('manage_options') && isset($_POST['songkick_submit']) && $_POST['songkick_submit']) {
+ $options['username'] = null;
+ $options['songkick_id'] = trim(strip_tags(stripslashes($_POST['songkick_id'])));
+ $options['songkick_id_type'] = strip_tags(stripslashes($_POST['songkick_id_type']));
+ $options['attendance'] = strip_tags(stripslashes($_POST['songkick_attendance']));
+ $options['apikey'] = trim(strip_tags(stripslashes($_POST['songkick_apikey'])));
+
+ $options['title'] = strip_tags(stripslashes($_POST['songkick_title']));
+ $options['hide_if_empty'] = ($_POST['songkick_hide_if_empty'] === 'on');
+ $options['logo'] = strip_tags(stripslashes($_POST['songkick_logo']));
+ $options['date_color'] = strip_tags(stripslashes($_POST['songkick_date_color']));
+ $limit = (int)$_POST['songkick_number_of_events'];
+ if ($limit > $max_number_events) $limit = $max_number_events;
+ $options['number_of_events'] = $limit;
+
+ $options['shortcode_logo'] = strip_tags(stripslashes($_POST['shortcode_songkick_logo']));
+ $options['shortcode_date_color'] = strip_tags(stripslashes($_POST['shortcode_songkick_date_color']));
+ $limit = (int)$_POST['songkick_shortcode_number_of_events'];
+ if ($limit > $max_number_events) $limit = $max_number_events;
+ $options['shortcode_number_of_events'] = $limit;
+
+ update_option(SONGKICK_CACHE, null);
+ update_option(SONGKICK_OPTIONS, $options);
+ }
+
+ if ($options['username']) {
+ $songkick_id_type = 'user';
+ $songkick_id = htmlspecialchars($options['username'], ENT_QUOTES);
+ } else {
+ $songkick_id_type = htmlspecialchars($options['songkick_id_type'], ENT_QUOTES);
+ $songkick_id = htmlspecialchars($options['songkick_id'], ENT_QUOTES);
+ }
+ $title = htmlspecialchars($options['title'], ENT_QUOTES);
+ $apikey = htmlspecialchars($options['apikey'], ENT_QUOTES);
+
+ $attendance = htmlspecialchars($options['attendance']);
+ $hide_if_empty = ($options['hide_if_empty']) ? 'checked="checked"' : '';
+ $songkick_logo = htmlspecialchars($options['logo'], ENT_QUOTES);
+ $date_color = htmlspecialchars($options['date_color'], ENT_QUOTES);
+ $number_of_events = htmlspecialchars($options['number_of_events']);
+
+ $shortcode_songkick_logo = htmlspecialchars($options['shortcode_logo'], ENT_QUOTES);
+ $shortcode_date_color = htmlspecialchars($options['shortcode_date_color'], ENT_QUOTES);
+ $shortcode_number_of_events = htmlspecialchars($options['shortcode_number_of_events']);
+
+ echo '<div class="wrap" id="songkick_concerts_and_festivals_settings">
+ <div id="icon-options-general" class="icon32"></div>
+ <h2>Songkick Concerts and Festivals Settings</h2>';
+
+ echo '<p class="description">Add [songkick_concerts_and_festivals] anywhere in a content to get your list of events.</p>';
+ echo '<p class="description">You can also add the Songkick widget to your template.</p>';
+
+ echo '<form method="post">';
+ echo '<h3>Main settings</h3>';
+
+ echo '<table class="form-table">';
+ echo '<tr><th><label for="songkick_apikey">' . 'Songkick API Key' . '</label></th>';
+ echo '<td><input id="songkick_apikey" name="songkick_apikey" type="text" value="'.$apikey.'" />';
+ echo '<span class="description">Required &ndash; <a href="http://developer.songkick.com">Request one from Songkick</a></span>';
+ echo '</td></tr>';
+
+ echo '<tr><th><label for="songkick_id_type">' . 'Songkick ID' . '</label></th>';
+ echo '<td><select id="songkick_id_type" name="songkick_id_type">';
+ echo ' <option value="user" '.(($songkick_id_type == 'user') ? ' selected' : '').'>username</option>';
+ echo ' <option value="artist" '.(($songkick_id_type == 'artist') ? ' selected' : '').'>artist id</option>';
+ echo ' <option value="venue" '.(($songkick_id_type == 'venue') ? ' selected' : '').'>venue id</option>';
+ echo ' <option value="metro_area" '.(($songkick_id_type == 'metro_area') ? ' selected' : '').'>metro area id</option>';
+ echo ' </select>';
+ echo ' <input size="15" id="songkick_id" name="songkick_id" type="text" value="'.$songkick_id.'" />';
+ echo '<span class="description">Required</span>';
+ echo '</td></tr>';
+
+ echo '<tr><th><label for="songkick_attendance">' . 'Attendance' . '</label></th>';
+ echo '<td><select id="songkick_attendance" name="songkick_attendance">';
+ echo ' <option value="all" '.(($attendance == 'all') ? ' selected' : '').'>all</option>';
+ echo ' <option value="im_going" '.(($attendance == 'im_going') ? ' selected' : '').'>I’m going</option>';
+ echo ' <option value="i_might_go" '.(($attendance == 'i_might_go') ? ' selected' : '').'>I might go</option>';
+ echo ' </select>';
+ echo '<span class="description">For users only</span>';
+ echo '</td></tr>';
+
+ echo '<tr><td colspan="2">You can also specify different user, artist, venue, or metro area ids when using the shortcode function. ';
+ echo ' <br>For users:&nbsp;&nbsp;<code>[songkick_concerts_and_festivals songkick_id=your_username &nbsp;songkick_id_type=user]</code>';
+ echo ' <br>For artists: <code>[songkick_concerts_and_festivals songkick_id=your_artist_id songkick_id_type=artist]</code>';
+ echo ' <br>For venues: <code>[songkick_concerts_and_festivals songkick_id=your_venue_id songkick_id_type=venue]</code>';
+ echo ' <br>For metro areas: <code>[songkick_concerts_and_festivals songkick_id=your_metro_area_id songkick_id_type=metro_area]</code>';
+ echo '</td></tr>';
+
+ echo '</table>';
+
+ echo '<br><h3>Shortcode settings</h3>';
+ echo '<table class="form-table">';
+ echo '<tr><th><label for="songkick_shortcode_number_of_events">Number of events to show</label></th>';
+ echo '<td><input id="songkick_shortcode_number_of_events" name="songkick_shortcode_number_of_events" type="text" value="'.$shortcode_number_of_events.'" /> ';
+ echo '<span class="description"> Max. 100</span>';
+ echo '</td></tr>';
+ echo '<tr><th><label for="shortcode_songkick_logo">' . 'Songkick logo' . '</label></th>';
+ echo '<td><select id="shortcode_songkick_logo" name="shortcode_songkick_logo">';
+ echo ' <option value="songkick-logo.png" '.(($shortcode_songkick_logo == 'songkick-logo.png') ? ' selected' : '').'>' .
+ 'white background' . '</option>';
+ echo ' <option value="songkick-logo-black.png" '.(($shortcode_songkick_logo == 'songkick-logo-black.png') ? ' selected' : '').'>' .
+ 'black background' . '</option>';
+ echo ' </select>';
+ echo '</td></tr>';
+ echo '<tr><th><label for="shortcode_songkick_date_color">' . 'Background color for date:' . '</label></th>';
+ echo '<td><input id="shortcode_songkick_date_color" name="shortcode_songkick_date_color" type="text" value="'.$shortcode_date_color.'" />';
+ echo '</td></tr>';
+ echo '</table>';
+
+ echo '<br><h3>Widget settings</h3>';
+
+ echo '<table class="form-table">';
+ echo '<tr><th><label for="songkick_title">' . 'Title:' . '</label></th>';
+ echo '<td><input id="songkick_title" name="songkick_title" type="text" value="'.$title.'" />';
+ echo '</td></tr>';
+
+ echo '<tr><th><label for="songkick_number_of_events">Number of events to show</label></th>';
+ echo '<td><input id="songkick_number_of_events" name="songkick_number_of_events" type="text" value="'.$number_of_events.'" /> ';
+ echo '<span class="description"> Max. 100</span>';
+ echo '</td></tr>';
+
+ echo '<tr><th><label for="songkick_hide_if_empty">Hide if there are no events?</label></th>';
+ echo '<td><input id="songkick_hide_if_empty" name="songkick_hide_if_empty" type="checkbox" '.$hide_if_empty.' /> ';
+ echo '</td></tr>';
+
+ echo '<tr><th><label for="songkick_logo">' . 'Songkick logo' . '</label></th>';
+ echo '<td><select id="songkick_logo" name="songkick_logo">';
+ echo ' <option value="songkick-logo.png" '.(($songkick_logo == 'songkick-logo.png') ? ' selected' : '').'>' .
+ 'white background' . '</option>';
+ echo ' <option value="songkick-logo-black.png" '.(($songkick_logo == 'songkick-logo-black.png') ? ' selected' : '').'>' .
+ 'black background' . '</option>';
+ echo ' </select>';
+ echo '</td></tr>';
+
+ echo '<tr><th><label for="songkick_date_color">' . 'Background color for date:' . '</label></th>';
+ echo '<td><input id="songkick_date_color" name="songkick_date_color" type="text" value="'.$date_color.'" />';
+ echo '</td></tr>';
+
+ echo '</table>';
+
+ echo '<p class="submit"><input type="submit" class="button-primary" name="songkick_submit" value="Save Changes" /></p>';
+ echo '</form></div>';
}
?>
View
26 songkick_user_events.php
@@ -2,21 +2,21 @@
require_once dirname(__FILE__) . '/songkick_events.php';
class SongkickUserEvents extends SongkickEvents {
- public $username;
- public $apikey;
+ public $username;
+ public $apikey;
- function SongkickUserEvents($apikey, $username, $attendance='all') {
- $this->SongkickEvents($apikey);
- $this->attendance = $attendance;
- $this->username = trim($username);
- }
+ function SongkickUserEvents($apikey, $username, $attendance='all') {
+ $this->SongkickEvents($apikey);
+ $this->attendance = $attendance;
+ $this->username = trim($username);
+ }
- function profile_url() {
- return "http://www.songkick.com/users/$this->username";
- }
+ function profile_url() {
+ return "http://www.songkick.com/users/$this->username";
+ }
- protected function url($per_page) {
- return "$this->apiurl/users/$this->username/events.json?apikey=$this->apikey&per_page=$per_page&attendance=$this->attendance";
- }
+ protected function url($per_page) {
+ return "$this->apiurl/users/$this->username/events.json?apikey=$this->apikey&per_page=$per_page&attendance=$this->attendance";
+ }
}
?>
View
24 songkick_venue_events.php
@@ -2,20 +2,20 @@
require_once dirname(__FILE__) . '/songkick_events.php';
class SongkickVenueEvents extends SongkickEvents {
- public $id;
- public $apikey;
+ public $id;
+ public $apikey;
- function SongkickVenueEvents($apikey, $id) {
- $this->SongkickEvents($apikey);
- $this->id = trim($id);
- }
+ function SongkickVenueEvents($apikey, $id) {
+ $this->SongkickEvents($apikey);
+ $this->id = trim($id);
+ }
- function profile_url() {
- return "http://www.songkick.com/venues/$this->id";
- }
+ function profile_url() {
+ return "http://www.songkick.com/venues/$this->id";
+ }
- protected function url($per_page){
- return "$this->apiurl/venues/$this->id/calendar.json?apikey=$this->apikey&per_page=$per_page";
- }
+ protected function url($per_page){
+ return "$this->apiurl/venues/$this->id/calendar.json?apikey=$this->apikey&per_page=$per_page";
+ }
}
?>
View
4 uninstall.php
@@ -1,8 +1,8 @@
<?php
if (!defined( 'ABSPATH') && !defined('WP_UNINSTALL_PLUGIN'))
- exit();
-
+ exit();
+
delete_option('songkick-concerts');
delete_option('songkick-concerts-cache');
Please sign in to comment.
Something went wrong with that request. Please try again.