Changeset 394211
- Timestamp:
- 06/07/2011 12:06:25 PM (15 years ago)
- File:
-
- 1 edited
-
my-eventish-events/trunk/index.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
my-eventish-events/trunk/index.php
r393682 r394211 4 4 Description: Get your events from www.eventish.com 5 5 Author: Alex Vanyan 6 Version: 1. 06 Version: 1.1 7 7 Author URI: http://cs16.us 8 8 */ 9 10 if(!function_exists('get_my_eventish_name')): 11 function get_my_eventish_name($args = '') 12 { 13 $path = dirname(__FILE__); 14 $path = str_replace('\\', '/', $path); 15 $path = explode('/', $path); 16 return end($path); 17 } 18 endif; 9 19 10 20 if(!function_exists('my_eventish_events')): … … 28 38 if(!function_exists('my_eventish_css')): 29 39 function my_eventish_css() { 30 wp_enqueue_style('myeventish-front-css', WP_PLUGIN_URL . '/ myeventishevents/stylesheet.css');40 wp_enqueue_style('myeventish-front-css', WP_PLUGIN_URL . '/' . get_my_eventish_name() . '/stylesheet.css'); 31 41 } 32 42 add_action('wp_print_styles', 'my_eventish_css'); … … 35 45 if(!function_exists('my_eventish_events_widget')): 36 46 function my_eventish_events_widget() { 37 $apiKey = get_option('eventish_api_key'); 38 $limit = (int) get_option('eventish_events_limit'); 47 $opts = get_option('my_eventish_opts'); 48 $title = $opts['title'] ? $opts['title'] : "Upcoming Events"; 49 $apiKey = $opts['api_key'] ? $opts['api_key'] : ""; 50 $limit = (int) $opts['limit'] ? (int) $opts['limit'] : 0; 39 51 40 52 if(!$apiKey) { … … 48 60 echo "</div>"; 49 61 } else { 50 /*51 echo "<pre>";52 var_dump($my_events); exit;53 */54 62 echo <<<HTML 55 63 <li class="widget-container my-eventish-events-widget"> 56 64 <div class="my-eventish-title-box"> 57 65 <div class="my-eventish-box-top-left"></div> 58 < h3 class="widget-title">Upcoming Events</h3>66 <span class="widget-title">$title</span> 59 67 <div class="my-eventish-box-top-right"></div> 60 68 </div> … … 78 86 <div class=\"my-eventish-single-event\"> 79 87 <div class=\"my-eventish-event-title\"> 80 <a target=\"_blank\" href=\"http://www.eventish.com/events/show/{$event['ID']}\">{$event['EventName']}</a>88 <a class=\"my-eventish-event-title-link\" target=\"_blank\" href=\"http://www.eventish.com/events/show/{$event['ID']}\">{$event['EventName']}</a> 81 89 </div> 82 90 <div class=\"my-eventish-calendar\"> … … 135 143 136 144 $fields = array( 137 'api_key' => 'eventish_api_key', 138 'limit' => 'eventish_events_limit' 145 'api_key' => 'api_key', 146 'limit' => 'events_limit', 147 'title' => 'title' 139 148 ); 149 150 if($_POST) { 151 $save_opts = array(); 140 152 141 if($_POST) {142 153 foreach($fields as $fkey => $field) { 143 if($posted = ltrim(rtrim($_POST[$fkey]))) { 144 if(get_option($field)) { 145 update_option($field, $posted); 146 } else { 147 add_option($field, $posted, null, 'yes'); 148 } 149 } else { 150 delete_option($field); 151 } 152 } 153 } 154 155 foreach($fields as $fkey => $field) { 156 $$fkey = get_option($field, ""); 157 } 158 159 echo "API Key: <input type=\"text\" name=\"api_key\" value=\"$api_key\" /><br /><br />"; 160 161 if(!$api_key) { 154 $save_opts[$fkey] = $_POST[$field]; 155 } 156 157 if(get_option('my_eventish_opts')) { 158 update_option('my_eventish_opts', $save_opts); 159 } else { 160 add_option('my_eventish_opts', $save_opts, null, 'yes'); 161 } 162 } 163 164 $opts = get_option('my_eventish_opts', array()); 165 166 echo "Title: <input type=\"text\" name=\"title\" value=\"{$opts['title']}\" /><br /><br />"; 167 168 echo "API Key: <input type=\"text\" name=\"api_key\" value=\"{$opts['api_key']}\" /><br /><br />"; 169 170 if(!$opts['api_key']) { 162 171 echo "Please enter an API key...<br /><br />"; 163 172 } else { 164 $my_events = my_eventish_curl_download("http://www.eventish.com/api/events/my?apikey=" . $ api_key . "&startnum=0&limit=" . $limit);173 $my_events = my_eventish_curl_download("http://www.eventish.com/api/events/my?apikey=" . $opts['api_key'] . "&startnum=0&limit=" . $opts['limit']); 165 174 $my_events = json_decode($my_events, 1); 166 175 if(array_key_exists("ERROR", $my_events)) { … … 170 179 } 171 180 172 echo "Events Limit: <input type=\"text\" name=\" limit\" value=\"$limit\" size=\"1\" /><br /><br />";181 echo "Events Limit: <input type=\"text\" name=\"events_limit\" value=\"{$opts['limit']}\" size=\"1\" /><br /><br />"; 173 182 } 174 183 register_widget_control('My Eventish Events', 'my_eventish_events_init');
Note: See TracChangeset
for help on using the changeset viewer.