Plugin Directory

Changeset 394211


Ignore:
Timestamp:
06/07/2011 12:06:25 PM (15 years ago)
Author:
eventish
Message:

Update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • my-eventish-events/trunk/index.php

    r393682 r394211  
    44Description: Get your events from www.eventish.com
    55Author: Alex Vanyan
    6 Version: 1.0
     6Version: 1.1
    77Author URI: http://cs16.us
    88*/
     9
     10if(!function_exists('get_my_eventish_name')):
     11function get_my_eventish_name($args = '')
     12{
     13    $path = dirname(__FILE__);
     14    $path = str_replace('\\', '/', $path);
     15    $path = explode('/', $path);
     16    return end($path);
     17}
     18endif;
    919
    1020if(!function_exists('my_eventish_events')):
     
    2838if(!function_exists('my_eventish_css')):
    2939function 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');
    3141}
    3242add_action('wp_print_styles', 'my_eventish_css');
     
    3545if(!function_exists('my_eventish_events_widget')):
    3646function 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;
    3951   
    4052    if(!$apiKey) {
     
    4860            echo "</div>";
    4961        } else {
    50             /*
    51             echo "<pre>";
    52             var_dump($my_events); exit;
    53             */
    5462            echo <<<HTML
    5563            <li class="widget-container my-eventish-events-widget">
    5664                <div class="my-eventish-title-box">
    5765                    <div class="my-eventish-box-top-left"></div>
    58                     <h3 class="widget-title">Upcoming Events</h3>
     66                    <span class="widget-title">$title</span>
    5967                    <div class="my-eventish-box-top-right"></div>
    6068                </div>
     
    7886                            <div class=\"my-eventish-single-event\">
    7987                                <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>
    8189                                </div>
    8290                                <div class=\"my-eventish-calendar\">
     
    135143   
    136144    $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'
    139148                    );
     149   
     150    if($_POST) {
     151        $save_opts = array();
    140152       
    141     if($_POST) {
    142153        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']) {
    162171        echo "Please enter an API key...<br /><br />";
    163172    } 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']);
    165174        $my_events = json_decode($my_events, 1);
    166175        if(array_key_exists("ERROR", $my_events)) {
     
    170179    }
    171180   
    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 />";
    173182}
    174183register_widget_control('My Eventish Events', 'my_eventish_events_init');
Note: See TracChangeset for help on using the changeset viewer.