WordPress.org

Plugin Directory

Changeset 868877


Ignore:
Timestamp:
03/03/14 23:26:33 (17 months ago)
Author:
joedolson
Message:

Updated dev version. Further organizational changes, code refresh.

Location:
my-calendar/trunk
Files:
43 added
4 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • my-calendar/trunk/css/mc-styles.css

    r866550 r868877  
    3636.jd-my-calendar .meta-box-sortables { min-height: 0} 
    3737.jd-my-calendar textarea { width: 100%} 
    38 .mc-clear { clear: both} 
     38.mc-clear { clear: both } 
    3939.jd-my-calendar pre { background: #fff; padding: 5px; border: 1px solid #ddd; box-shadow: 1px 1px 2px #ddd} 
    40 .jd-my-calendar label span { font-size: .9em; color: #c33} 
     40.jd-my-calendar label span.required { font-size: .9em; color: #c33} 
    4141.jd-my-calendar .default { background: #fff} 
    4242.jd-my-calendar .button-adjust { top: 10px; right: 0} 
  • my-calendar/trunk/my-calendar-categories.php

    r865684 r868877  
    173173        $iconlist = my_dirlist($directory); 
    174174    } else { 
    175         $directory = dirname(__FILE__).'/icons/';    
    176         $path = '/'.dirname(plugin_basename(__FILE__)).'/icons'; 
     175        $directory = dirname(__FILE__).'/images/icons/';     
     176        $path = '/'.dirname(plugin_basename(__FILE__)).'/images/icons'; 
    177177        $iconlist = my_dirlist($directory); 
    178178    } 
     
    223223                    <input type="checkbox" value="on" name="mc_default_category" id="mc_default_category"<?php echo $checked; ?> /> <label for="mc_default_category"><?php _e('Default category','my-calendar'); ?></label> 
    224224                    <?php if ( $view == 'add' ) { $checked = ''; } else { if ( !empty($cur_cat) && is_object($cur_cat) && $cur_cat->category_private == 1 ) { $checked=' checked="checked"'; } else { $checked = ''; } } ?> 
    225                     <p><input type="checkbox" value="on" name="category_private" id="category_private"<?php echo $checked; ?> /> <label for="cat_private"><?php _e('Private category (logged-in users only)','my-calendar'); ?></label></p> 
     225                    <p><input type="checkbox" value="on" name="category_private" id="cat_private"<?php echo $checked; ?> /> <label for="cat_private"><?php _e('Private category (logged-in users only)','my-calendar'); ?></label></p> 
    226226                </fieldset> 
    227227                <p> 
     
    246246</div> 
    247247</div> 
    248     <?php jd_show_support_box(); 
     248    <?php mc_show_sidebar(); 
    249249} 
    250250 
     
    260260    $mcdb = $wpdb; 
    261261?> 
    262  <h2><?php _e('Manage Categories','my-calendar'); ?></h2> 
    263 <?php 
     262    <h2><?php _e('Manage Categories','my-calendar'); ?></h2><?php 
    264263    $co = ( !isset($_GET['co']) )?1:(int) $_GET['co']; 
    265264    switch ( $co ) { 
     
    274273    <thead> 
    275274        <tr> 
    276             <th scope="col"><?php echo ($co==2)?"<a href='".admin_url("admin.php?page=my-calendar-categories&amp;co=1")."'>":''; ?><?php _e('ID','my-calendar') ?><?php echo ($co==2)?'</a>':''; ?></th> 
    277             <th scope="col"><?php echo ($co==1)?"<a href='".admin_url("admin.php?page=my-calendar-categories&amp;co=2")."'>":''; ?><?php _e('Category Name','my-calendar') ?><?php echo ($co==1)?'</a>':''; ?></th> 
     275            <th scope="col"><?php echo ( $co==2 ) ? "<a href='".admin_url("admin.php?page=my-calendar-categories&amp;co=1")."'>" : ''; ?><?php _e('ID','my-calendar') ?><?php echo ( $co==2 ) ? '</a>' : ''; ?></th> 
     276            <th scope="col"><?php echo ( $co==1 ) ? "<a href='".admin_url("admin.php?page=my-calendar-categories&amp;co=2")."'>" : ''; ?><?php _e('Category Name','my-calendar') ?><?php echo ( $co==1 ) ? '</a>' : ''; ?></th> 
    278277            <th scope="col"><?php _e('Category Color','my-calendar'); ?></th> 
    279278            <th scope="col"><?php _e('Category Icon','my-calendar'); ?></th> 
     
    286285        $class = ''; 
    287286        foreach ( $categories as $cat ) { 
    288             $class = ($class == 'alternate') ? '' : 'alternate'; 
    289             $icon_src = ( mc_file_exists( $cat->category_icon ) ) ? mc_get_file( $cat->category_icon, 'url' ) : plugins_url( 'my-calendar/icons/'.$cat->category_icon ); 
    290             $background = (strpos($cat->category_color,'#') !== 0)?'#':'' . $cat->category_color; 
     287            $class = ( $class == 'alternate' ) ? '' : 'alternate'; 
     288            $icon_src = ( mc_file_exists( $cat->category_icon ) ) ? mc_get_file( $cat->category_icon, 'url' ) : plugins_url( 'my-calendar/images/icons/'.$cat->category_icon ); 
     289            $background = ( strpos( $cat->category_color,'#' ) !== 0 ) ? '#' : '' . $cat->category_color; 
    291290            $foreground = mc_inverse_color( $background ); 
    292291            ?> 
    293292            <tr class="<?php echo $class; ?>"> 
    294293            <th scope="row"><?php echo $cat->category_id; ?></th> 
    295             <td><?php echo stripslashes( esc_attr( $cat->category_name ) ); echo ' '; if ( $cat->category_id == get_option( 'mc_default_category' ) ) { _e( '(Default)' ); } ?></td> 
     294            <td><?php echo stripslashes( $cat->category_name ); if ( $cat->category_id == get_option( 'mc_default_category' ) ) { echo ' '.__( '(Default)' ); } ?></td> 
    296295            <td style="background-color:<?php echo $background; ?>; color: <?php echo $foreground; ?>"><?php echo $background; ?></td> 
    297296            <td style="background-color:<?php echo $background; ?>;"><img src="<?php echo $icon_src; ?>" alt="" /></td>       
    298297            <td><?php echo ( $cat->category_private == 1 )?__('Yes','my-calendar'):__('No','my-calendar'); ?></td> 
    299             <td><a href="<?php echo admin_url("admin.php?page=my-calendar-categories&amp;mode=edit&amp;category_id=$cat->category_id"); ?>" class='edit'><?php _e('Edit','my-calendar'); ?></a></td> 
    300             <?php 
    301             if ($cat->category_id == 1) { 
    302                 echo '<td>'.__('N/A','my-calendar').'</td>'; 
     298            <td><a href="<?php echo admin_url("admin.php?page=my-calendar-categories&amp;mode=edit&amp;category_id=$cat->category_id"); ?>" class='edit'><?php _e('Edit','my-calendar'); ?></a></td><?php 
     299            if ( $cat->category_id == 1 ) { 
     300                echo '<td>'.__( 'N/A','my-calendar' ).'</td>'; 
    303301            } else { ?> 
    304                 <td><a href="<?php echo admin_url("admin.php?page=my-calendar-categories&amp;mode=delete&amp;category_id=$cat->category_id"); ?>" class="delete" onclick="return confirm('<?php _e('Are you sure you want to delete this category?','my-calendar'); ?>')"><?php _e('Delete','my-calendar'); ?></a></td> 
    305             <?php 
     302                <td><a href="<?php echo admin_url("admin.php?page=my-calendar-categories&amp;mode=delete&amp;category_id=$cat->category_id"); ?>" class="delete" onclick="return confirm('<?php _e('Are you sure you want to delete this category?','my-calendar'); ?>')"><?php _e('Delete','my-calendar'); ?></a></td><?php 
    306303            }  ?> 
    307             </tr> 
    308             <?php 
    309         } 
    310       ?> 
    311       </table> 
    312       <?php 
     304            </tr><?php 
     305        } ?> 
     306      </table><?php 
    313307    } else { 
    314308        echo '<p>'.__('There are no categories in the database - or something has gone wrong!','my-calendar').'</p>'; 
  • my-calendar/trunk/my-calendar-core.php

    r866550 r868877  
    237237 
    238238// Function to add the javascript to the admin header 
    239 function my_calendar_add_javascript() {  
     239function my_calendar_add_javascript() { 
    240240    if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'my-calendar' || $_GET['page'] == 'my-calendar-groups' || $_GET['page'] == 'my-calendar-locations' ) ) { 
    241241        wp_enqueue_script('jquery-ui-autocomplete'); 
     
    248248            date_i18n( 'F', strtotime( 'March 1' ) ), 
    249249            date_i18n( 'F', strtotime( 'April 1' ) ), 
    250             date_i18n( 'F', strtotime( 'May 1' ) ),          
     250            date_i18n( 'F', strtotime( 'May 1' ) ), 
    251251            date_i18n( 'F', strtotime( 'June 1' ) ), 
    252252            date_i18n( 'F', strtotime( 'July 1' ) ), 
     
    268268        wp_register_script( 'mc.tabs', plugins_url( 'js/tabs.js', __FILE__ ), array( 'jquery' ) ); 
    269269        wp_register_script( 'mc.sortable', plugins_url( 'js/sortable.js', __FILE__ ), array( 'jquery','jquery-ui-sortable' ) ); 
    270          
    271270        wp_enqueue_script( 'mc.tabs' ); 
    272271        wp_enqueue_script( 'mc.sortable' ); 
    273         if ( $_GET['page'] == 'my-calendar-config' ) { 
    274             $firstItem = 'mc_editor'; 
    275         } else if ( $_GET['page'] == 'my-calendar-help' ) { 
    276             $firstItem = 'mc_main'; 
    277         } 
     272        $firstItem = ( $_GET['page'] == 'my-calendar-config' ) ? 'mc_editor' : 'mc_main' ; 
    278273        wp_localize_script( 'mc.tabs', 'firstItem', $firstItem );        
    279274    } 
    280275    if ( isset($_GET['page']) && ( $_GET['page'] == 'my-calendar-groups' || $_GET['page'] == 'my-calendar-manage' ) ) { 
    281         wp_enqueue_script('jquery.checkall',plugins_url( 'js/jquery.checkall.js', __FILE__ ), array('jquery') ); 
     276        wp_enqueue_script( 'jquery.checkall', plugins_url( 'js/jquery.checkall.js', __FILE__ ), array( 'jquery' ) ); 
    282277    } 
    283278} 
     
    291286    $('#e_begin,' + '#e_end').calendricalDateRange(); 
    292287    $('#mc-accordion').accordion({ collapsible:true, active:false }); 
    293 <?php if ( !isset($_GET['mode']) ) { ?> 
     288<?php if ( !isset( $_GET['mode'] ) ) { ?> 
    294289    $('#e_time').timeAutocomplete({ 
    295290        increment: 15, 
     
    313308</script><?php 
    314309    } 
    315     if ( isset($_GET['page']) && $_GET['page']=='my-calendar-help') { 
    316     ?> 
    317     <script type="text/javascript"> 
    318     jQuery(document).ready( function($) { 
    319         $('dd:even').css('background','#f6f6f6'); 
    320     }); 
    321     </script> 
    322     <?php 
    323     } 
    324 } 
     310} 
     311 
    325312add_action( 'in_plugin_update_message-my-calendar/my-calendar.php', 'mc_plugin_update_message' ); 
    326313function mc_plugin_update_message() { 
     
    341328        return; 
    342329    } else { 
    343         $scripting_top = $scripting_bottom = $inner_scripting = ''; 
    344         global $wpdb, $wp_query; 
    345         $mcdb = $wpdb; 
     330        $top = $bottom = $inner = ''; 
    346331        $list_js = stripcslashes( get_option( 'mc_listjs' ) ); 
    347332        $cal_js = stripcslashes( get_option( 'mc_caljs' ) ); 
     
    351336        } 
    352337        $mini_js = stripcslashes( get_option( 'mc_minijs' ) ); 
    353         if ( get_option('mc_open_day_uri') == 'true' || get_option('mc_open_day_uri') == 'listanchor'  || get_option('mc_open_day_uri') == 'calendaranchor') { $mini_js = str_replace('e.preventDefault();','',$mini_js); } 
     338        if ( get_option( 'mc_open_day_uri' ) == 'true' || get_option( 'mc_open_day_uri' ) == 'listanchor'  || get_option( 'mc_open_day_uri' ) == 'calendaranchor' ) {  
     339            $mini_js = str_replace( 'e.preventDefault();','',$mini_js );  
     340        } 
    354341        $ajax_js = stripcslashes( get_option( 'mc_ajaxjs' ) ); 
    355  
    356             if ( is_object($wp_query) && isset($wp_query->post) ) { 
    357                 $id = $wp_query->post->ID; 
    358             }  
    359             if ( get_option( 'mc_show_js' ) != '' ) { 
    360             $array = explode( ",",get_option( 'mc_show_js' ) ); 
    361                 if (!is_array($array)) { 
    362                     $array = array(); 
    363                 } 
     342        if ( is_object($wp_query) && isset($wp_query->post) ) { 
     343            $id = $wp_query->post->ID; 
     344        }  
     345        if ( get_option( 'mc_show_js' ) != '' ) { 
     346        $array = explode( ",",get_option( 'mc_show_js' ) ); 
     347            if ( !is_array( $array ) ) { 
     348                $array = array(); 
    364349            } 
    365             if ( @in_array( $id, $array ) || get_option( 'mc_show_js' ) == '' ) { 
    366                 $scripting_top = " 
     350        } 
     351        if ( @in_array( $id, $array ) || get_option( 'mc_show_js' ) == '' ) { 
     352            $top = " 
    367353<script type='text/javascript'> 
    368     (function( $ ) { 'use strict'; \n"; 
    369                 if ( get_option('mc_calendar_javascript') != 1 ) {  $inner_scripting .= "\n".$cal_js; } 
    370                 if ( get_option('mc_list_javascript') != 1 ) {  $inner_scripting .= "\n".$list_js; } 
    371                 if ( get_option('mc_mini_javascript') != 1 ) {  $inner_scripting .= "\n".$mini_js; } 
    372                 if ( get_option('mc_ajax_javascript') != 1 ) { $inner_scripting .= "\n".$ajax_js; } 
    373                 $scripting_bottom .= " 
    374     }(jQuery)); 
     354(function( $ ) { 'use strict'; \n"; 
     355    if ( get_option( 'mc_calendar_javascript' ) != 1 ) {    $inner .= "\n".$cal_js; } 
     356    if ( get_option( 'mc_list_javascript' ) != 1 ) {    $inner .= "\n".$list_js; } 
     357    if ( get_option( 'mc_mini_javascript' ) != 1 ) {    $inner .= "\n".$mini_js; } 
     358    if ( get_option( 'mc_ajax_javascript' ) != 1 ) { $inner .= "\n".$ajax_js; } 
     359    $bottom .= " 
     360}(jQuery)); 
    375361</script>"; 
    376             } 
    377         $inner_scripting = apply_filters( 'mc_filter_javascript_footer',$inner_scripting ); 
    378         echo ( $inner_scripting != '' )?$scripting_top.$inner_scripting.$scripting_bottom:''; 
     362        } 
     363        $inner = apply_filters( 'mc_filter_javascript_footer',$inner ); 
     364        echo ( $inner != '' )?$top.$inner.$bottom:''; 
    379365    } 
    380366} 
     
    411397 
    412398function mc_if_needs_permissions() { 
    413     // this prevents administrators from losing privileges to edit my calendar 
     399    // prevent administrators from losing privileges to edit my calendar 
    414400    $role = get_role( 'administrator' ); 
    415401    if ( is_object( $role ) ) { 
    416402        $caps = $role->capabilities; 
    417         if ( isset($caps['mc_add_events']) ) { 
     403        if ( isset( $caps['mc_add_events'] ) ) { 
    418404            return;  
    419405        } else { 
     
    449435     
    450436    // depending on permissions settings, grant other permissions 
    451      
    452437    if ( $add && $manage && $approve ) { 
    453438    // this is an upgrade; 
     
    461446        $author->add_cap( 'mc_view_help' ); 
    462447        $editor->add_cap( 'mc_view_help' ); 
    463  
    464448        switch( $add ) { 
    465449            case 'read': 
     
    532516    $current_version = ( get_option('mc_version') == '') ? get_option('my_calendar_version') : get_option('mc_version'); 
    533517    // If current version matches, don't bother running this. 
    534     if ($current_version == $mc_version) { 
     518    if ( $current_version == $mc_version ) { 
    535519        return true; 
    536520    } 
     
    561545        // for each release requiring an upgrade path, add a version compare.  
    562546        // Loop will run every relevant upgrade cycle. 
    563         if ( version_compare( $current_version, "1.6.0", "<" ) ) {  $upgrade_path[] = "1.6.0"; }  
    564         if ( version_compare( $current_version, "1.6.2", "<" ) ) {  $upgrade_path[] = "1.6.2"; }  
    565         if ( version_compare( $current_version, "1.6.3", "<" ) ) {  $upgrade_path[] = "1.6.3"; }  
    566547        if ( version_compare( $current_version, "1.7.0", "<" ) ) {  $upgrade_path[] = "1.7.0"; }  
    567548        if ( version_compare( $current_version, "1.7.1", "<" ) ) {  $upgrade_path[] = "1.7.1"; }  
     
    816797                $today_text = get_option('mc_no_events_text'); 
    817798                $upcoming_title = get_option('mc_upcoming_title'); 
    818  
    819799                $defaults = array( 
    820800                    'upcoming'=>array(   
     
    849829                delete_option('my_calendar_no_events_text'); 
    850830                delete_option('mc_upcoming_title');          
    851             break;       
    852             case '1.6.3': 
    853                 add_option( 'mc_ajaxjs',$initial_ajaxjs ); 
    854                 add_option( 'mc_ajax_javascript', 1 ); 
    855             break; 
    856             case '1.6.2': 
    857                 $mc_user_settings = array( 
    858                 'my_calendar_tz_default'=>array( 
    859                     'enabled'=>'off', 
    860                     'label'=>'My Calendar Default Timezone', 
    861                     'values'=>array( 
    862                             "-12" => "(GMT -12:00) Eniwetok, Kwajalein", 
    863                             "-11" => "(GMT -11:00) Midway Island, Samoa", 
    864                             "-10" => "(GMT -10:00) Hawaii", 
    865                             "-9.5" => "(GMT -9:30) Marquesas Islands", 
    866                             "-9" => "(GMT -9:00) Alaska", 
    867                             "-8" => "(GMT -8:00) Pacific Time (US &amp; Canada)", 
    868                             "-7" => "(GMT -7:00) Mountain Time (US &amp; Canada)", 
    869                             "-6" => "(GMT -6:00) Central Time (US &amp; Canada), Mexico City", 
    870                             "-5" => "(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima", 
    871                             "-4.5" => "(GMT -4:30) Venezuela", 
    872                             "-4" => "(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz", 
    873                             "-3.5" => "(GMT -3:30) Newfoundland", 
    874                             "-3" => "(GMT -3:00) Brazil, Buenos Aires, Georgetown", 
    875                             "-2" => "(GMT -2:00) Mid-Atlantic", 
    876                             "-1" => "(GMT -1:00 hour) Azores, Cape Verde Islands", 
    877                             "0" => "(GMT) Western Europe Time, London, Lisbon, Casablanca", 
    878                             "1" => "(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris", 
    879                             "2" => "(GMT +2:00) Kaliningrad, South Africa", 
    880                             "3" => "(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg", 
    881                             "3.5" => "(GMT +3:30) Tehran", 
    882                             "4" => "(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi", 
    883                             "4.5" => "(GMT +4:30) Afghanistan", 
    884                             "5" => "(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent", 
    885                             "5.5" => "(GMT +5:30) Bombay, Calcutta, Madras, New Delhi", 
    886                             "5.75" => "(GMT +5:45) Nepal", 
    887                             "6" => "(GMT +6:00) Almaty, Dhaka, Colombo", 
    888                             "6.5" => "(GMT +6:30) Myanmar, Cocos Islands", 
    889                             "7" => "(GMT +7:00) Bangkok, Hanoi, Jakarta", 
    890                             "8" => "(GMT +8:00) Beijing, Perth, Singapore, Hong Kong", 
    891                             "9" => "(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk", 
    892                             "9.5" => "(GMT +9:30) Adelaide, Darwin", 
    893                             "10" => "(GMT +10:00) Eastern Australia, Guam, Vladivostok", 
    894                             "10.5" => "(GMT +10:30) Lord Howe Island", 
    895                             "11" => "(GMT +11:00) Magadan, Solomon Islands, New Caledonia", 
    896                             "11.5" => "(GMT +11:30) Norfolk Island", 
    897                             "12" => "(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka", 
    898                             "12.75" => "(GMT +12:45) Chatham Islands", 
    899                             "13" => "(GMT +13:00) Tonga", 
    900                             "14" => "(GMT +14:00) Line Islands" 
    901                             ), 
    902                     ), 
    903                 'my_calendar_location_default'=>array( 
    904                     'enabled'=>'off', 
    905                     'label'=>'My Calendar Default Location', 
    906                     'values'=>array( 
    907                                 'AL'=>"Alabama", 
    908                                 'AK'=>"Alaska",  
    909                                 'AZ'=>"Arizona",  
    910                                 'AR'=>"Arkansas",  
    911                                 'CA'=>"California",  
    912                                 'CO'=>"Colorado",  
    913                                 'CT'=>"Connecticut",  
    914                                 'DE'=>"Delaware",  
    915                                 'DC'=>"District Of Columbia",  
    916                                 'FL'=>"Florida",  
    917                                 'GA'=>"Georgia",  
    918                                 'HI'=>"Hawaii",  
    919                                 'ID'=>"Idaho",  
    920                                 'IL'=>"Illinois",  
    921                                 'IN'=>"Indiana",  
    922                                 'IA'=>"Iowa",  
    923                                 'KS'=>"Kansas",  
    924                                 'KY'=>"Kentucky",  
    925                                 'LA'=>"Louisiana",  
    926                                 'ME'=>"Maine",  
    927                                 'MD'=>"Maryland",  
    928                                 'MA'=>"Massachusetts",  
    929                                 'MI'=>"Michigan",  
    930                                 'MN'=>"Minnesota",  
    931                                 'MS'=>"Mississippi",  
    932                                 'MO'=>"Missouri",  
    933                                 'MT'=>"Montana", 
    934                                 'NE'=>"Nebraska", 
    935                                 'NV'=>"Nevada", 
    936                                 'NH'=>"New Hampshire", 
    937                                 'NJ'=>"New Jersey", 
    938                                 'NM'=>"New Mexico", 
    939                                 'NY'=>"New York", 
    940                                 'NC'=>"North Carolina", 
    941                                 'ND'=>"North Dakota", 
    942                                 'OH'=>"Ohio",  
    943                                 'OK'=>"Oklahoma",  
    944                                 'OR'=>"Oregon",  
    945                                 'PA'=>"Pennsylvania",  
    946                                 'RI'=>"Rhode Island",  
    947                                 'SC'=>"South Carolina",  
    948                                 'SD'=>"South Dakota", 
    949                                 'TN'=>"Tennessee",  
    950                                 'TX'=>"Texas",  
    951                                 'UT'=>"Utah",  
    952                                 'VT'=>"Vermont",  
    953                                 'VA'=>"Virginia",  
    954                                 'WA'=>"Washington",  
    955                                 'WV'=>"West Virginia",  
    956                                 'WI'=>"Wisconsin",  
    957                                 'WY'=>"Wyoming"), 
    958                     ) 
    959                 ); 
    960                 $check = get_option('mc_user_settings'); 
    961                 if ( !is_array( $check['my_calendar_location_default'] ) ) { 
    962                     update_option('mc_user_settings',$mc_user_settings); 
    963                 }                
    964             break; 
    965             case '1.6.0': 
    966                 add_option('mc_user_settings_enabled',false); 
    967                 add_option('mc_user_location_type','state'); 
    968                 add_option('mc_show_js',get_option('mc_show_css') );    
    969831            break; 
    970832            default: 
     
    990852    $list = $default = ''; 
    991853    $sql = "SELECT * FROM " . my_calendar_categories_table() . " ORDER BY category_name ASC"; 
    992         $cats = $mcdb->get_results($sql); 
    993         foreach($cats as $cat) { 
    994             $c = '<option value="'.$cat->category_id.'"'; 
    995             if ( !empty($data) ) { 
    996                 if ( !is_object($data) ) { $category = $data; } else { $category = $data->event_category; }              
    997                 if ($category == $cat->category_id){ 
    998                     $c .= ' selected="selected"'; 
    999                 } 
     854    $cats = $mcdb->get_results($sql); 
     855    foreach($cats as $cat) { 
     856        $c = '<option value="'.$cat->category_id.'"'; 
     857        if ( !empty($data) ) { 
     858            if ( !is_object($data) ) { $category = $data; } else { $category = $data->event_category; }              
     859            if ($category == $cat->category_id){ 
     860                $c .= ' selected="selected"'; 
    1000861            } 
    1001             $c .= '>'.stripslashes($cat->category_name).'</option>'; 
    1002             if ( $cat->category_id != get_option('mc_default_category') ) { 
    1003                 $list .= $c; 
    1004             } else { 
    1005                 $default = $c; 
    1006             } 
    1007         } 
    1008         if ( !$option ) { 
    1009             $default = ( get_option( 'mc_default_category' ) ) ? get_option( 'mc_default_category' ) : 1 ; 
    1010             return ( is_object( $data ) ) ? $data->event_category : $default; 
    1011         } 
    1012         return $default.$list; 
     862        } 
     863        $c .= '>'.stripslashes($cat->category_name).'</option>'; 
     864        if ( $cat->category_id != get_option('mc_default_category') ) { 
     865            $list .= $c; 
     866        } else { 
     867            $default = $c; 
     868        } 
     869    } 
     870    if ( !$option ) { 
     871        $default = ( get_option( 'mc_default_category' ) ) ? get_option( 'mc_default_category' ) : 1 ; 
     872        return ( is_object( $data ) ) ? $data->event_category : $default; 
     873    } 
     874    return $default.$list; 
    1013875} 
    1014876 
     
    12511113// Mail functions (originally by Roland) 
    12521114function my_calendar_send_email( $event ) { 
    1253     $details = event_as_array($event); 
     1115    $details = mc_create_tags($event); 
    12541116    // shift to boolean 
    12551117    $send_email_option = ( get_option( 'mc_event_mail' ) == 'true' ) ? true : false; 
     
    18081670    apply_filters( "debug", 'my_calendar add actions/filters' ); 
    18091671    add_filter( 'mc_event_registration', 'mc_standard_event_registration', 10, 4 ); 
     1672    add_filter( 'mc_datetime_inputs', 'mc_standard_datetime_input', 10, 4 ); 
    18101673    add_action( 'mc_transition_event', 'mc_tweet_approval', 10, 2 ); 
    18111674    add_action( 'mc_save_event', 'mc_event_post', 10, 3 ); 
  • my-calendar/trunk/my-calendar-event-manager.php

    r866550 r868877  
    5656        } else { 
    5757            $attachment_id = ( isset( $_POST['event_image_id'] ) && is_numeric( $_POST['event_image_id'] ) ) ? $_POST['event_image_id'] : false; 
    58             echo "Attach: $attachment_id"; 
    5958            if ( $attachment_id ) { set_post_thumbnail( $post_id, $attachment_id ); } 
    6059        } 
     
    6968add_action( 'mc_update_event_post', 'mc_add_post_meta_data', 10, 4 ); 
    7069function mc_add_post_meta_data( $post_id, $post, $data, $event_id ) { 
    71     update_post_meta( $post_id, '_mc_event_access', $_POST['events_access'] ); 
     70    // access features for the event 
     71    update_post_meta( $post_id, '_mc_event_access', ( isset( $_POST['events_access'] ) ) ? $_POST['events_access'] : '' ); 
    7272    update_post_meta( $post_id, '_mc_event_id', $event_id ); 
    7373    update_post_meta( $post_id, '_mc_event_desc', $data['event_desc'] ); 
     
    310310                <h3><?php _e('My Events','my-calendar'); ?></h3> 
    311311                <div class="inside"> 
    312                 <?php jd_events_display_list(); ?> 
     312                <?php mc_list_events(); ?> 
    313313                </div> 
    314314            </div> 
     
    322322    } 
    323323    $add = array( 'Import Events'=>'<form action="'.admin_url('admin.php?page=my-calendar-manage').'" method="POST"><div><label for="mc-import-csv">'.__('Upload CSV File','my-calendar').'<input type="file" name="mc-import-csv" id="mc-import-csv" /><input type="submit" value="'.__('Import Events','my-calendar').'" /></div></form>'); */ 
    324     jd_show_support_box(); ?> 
     324    mc_show_sidebar(); ?> 
    325325</div> 
    326326<?php 
     
    375375    } else { 
    376376        $response = my_calendar_save( $action, $mc_output, (int) $_POST['event_id'] ); 
    377         echo $response; 
     377        echo $response['message']; 
    378378    } 
    379379    for ($i=0;$i<$count;$i++) { 
     
    384384            $response = my_calendar_save( $action,$mc_output,(int) $_POST['event_id'] );         
    385385        } 
    386         echo $response; 
     386        echo $response['message']; 
    387387    } 
    388388    if ( isset($_POST['ref']) ) { 
     
    411411            echo "<div class=\"error\"><p>".__("You must provide an event id in order to edit it",'my-calendar')."</p></div>"; 
    412412        } else { 
    413             jd_events_edit_form('edit', $event_id); 
     413            mc_edit_event_form('edit', $event_id); 
    414414        }        
    415415    } else if ( $action == 'copy'|| ($action == 'copy'&& $error_with_saving == 1)) { ?> 
     
    420420            echo "<div class=\"error\"><p>".__("You must provide an event id in order to edit it",'my-calendar')."</p></div>"; 
    421421        } else { 
    422             jd_events_edit_form('copy', $event_id); 
     422            mc_edit_event_form('copy', $event_id); 
    423423        } 
    424424    } else { ?>  
    425425        <div id="icon-edit" class="icon32"></div>    
    426426        <h2><?php _e('Add Event','my-calendar'); ?></h2><?php  
    427         jd_events_edit_form(); 
     427        mc_edit_event_form(); 
    428428    }  
    429     jd_show_support_box(); ?> 
     429    mc_show_sidebar(); ?> 
    430430    </div><?php 
    431431}  
     
    452452        $add = $output[2]; // add format here 
    453453        $add = apply_filters( 'mc_before_save_insert', $add ); 
    454         $result = $mcdb->insert(  
    455                 my_calendar_table(),  
    456                 $add,  
    457                 $formats  
    458                 ); 
     454        $result = $mcdb->insert( my_calendar_table(), $add, $formats ); 
    459455        $event_id = $mcdb->insert_id; 
    460         // create all occurrences of event 
    461         $occurrences = mc_increment_event( $event_id );          
     456        mc_increment_event( $event_id );             
    462457        if ( !$result ) { 
    463458            $message = "<div class='error notice'><p><strong>". __('Error','my-calendar') .":</strong> ". __('I\'m sorry! I couldn\'t add that event to the database.','my-calendar') . "</p></div>";          
     
    479474                if ( get_option( 'mc_uri' ) != '' ) {  
    480475                    $event_ids = mc_get_occurrences( $event_id ); 
    481                     $event_link = mc_build_url( array( 'mc_id'=>$event_ids[0]->occur_event_id ), array( 'page' ), get_option( 'mc_uri' ) );  
     476                    $event_link = mc_build_url( array( 'mc_id'=>$event_ids[0]->occur_id ), array( 'page' ), get_option( 'mc_uri' ) );  
    482477                } else { 
    483478                    $event_link = false; 
     
    493488    } 
    494489    if ( $action == 'edit'&& $proceed == true ) { 
    495     $url = ( get_option('mc_uri') != ''&& !is_numeric( get_option('mc_uri') ) )?''.sprintf(__('View <a href="%s">your calendar</a>.','my-calendar'),get_option('mc_uri') ):'';   
     490    $url = ( get_option( 'mc_uri' ) != ''&& !is_numeric( get_option( 'mc_uri' ) ) )?''.sprintf(__('View <a href="%s">your calendar</a>.','my-calendar'), get_option( 'mc_uri' ) ):'';    
    496491        $event_author = (int) ($_POST['event_author']); 
    497492        if ( mc_can_edit_event( $event_author ) ) {  
     
    588583    } 
    589584    $message = $message ."\n". $output[3]; 
    590     return $message; 
    591 } 
    592  
    593 function jd_acquire_form_data($event_id=false) { 
     585    return array ( 'event_id'=>$event_id, 'message'=>$message ); 
     586} 
     587 
     588function mc_form_data($event_id=false) { 
    594589global $wpdb,$users_entries; 
    595590    $mcdb = $wpdb; 
     
    616611 
    617612// The event edit form for the manage events admin page 
    618 function jd_events_edit_form($mode='add', $event_id=false) { 
     613function mc_edit_event_form($mode='add', $event_id=false) { 
    619614    global $wpdb,$users_entries,$output; 
    620615    $mcdb = $wpdb; 
    621616    if ($event_id != false) { 
    622         $data = jd_acquire_form_data($event_id); 
     617        $data = mc_form_data($event_id); 
    623618    } else { 
    624619        $data = $users_entries; 
     
    630625    } 
    631626    echo ($message != '')?"<div class='error'><p>$message</p></div>":''; 
    632     my_calendar_print_form_fields($data,$mode,$event_id); 
     627    mc_form_fields($data,$mode,$event_id); 
    633628} 
    634629 
     
    662657} 
    663658 
    664 function my_calendar_print_form_fields( $data,$mode,$event_id ) { 
     659function mc_show_block( $field, $has_data, $data ) { 
     660    $return = $checked = $value = ''; 
     661    $show_block = mc_show_edit_block( $field ); 
     662    $pre = '<div class="ui-sortable meta-box-sortables"><div class="postbox">'; 
     663    $post = '</div></div>'; 
     664    switch ( $field ) { 
     665        case 'event_desc' : 
     666            if ( $show_block ) { 
     667                // because wp_editor cannot return a value, event_desc fields cannot be filtered if its enabled. 
     668                $value = ( $has_data ) ? $data->event_desc : ''; 
     669                echo ' 
     670                <div class="event_description"> 
     671                <label for="content">'.__( 'Event Description','my-calendar' ).'</label><br />'; 
     672                if ( mc_show_edit_block( 'event_use_editor') ) { 
     673                    if ( version_compare( get_bloginfo( 'version') , '3.3', '>=') ) { 
     674                        wp_editor( stripslashes( $value ), 'content', array( 'textarea_rows'=>10 ) );  
     675                    } else {  
     676                        the_editor( stripslashes( $value ) );  
     677                    } 
     678                } else { 
     679                    echo '<textarea id="content" name="content" class="event_desc" rows="5" cols="80">'.stripslashes( esc_attr( $value ) ).'</textarea>'; 
     680                } 
     681                echo '</div>'; 
     682            } 
     683        break; 
     684        case 'event_short' : 
     685            if ( $show_block ) { 
     686                $value = ( $has_data ) ? stripslashes( esc_attr( $data->event_short ) ) : '';        
     687                $return = ' 
     688                <p> 
     689                    <label for="e_short">'.__( 'Short Description','my-calendar' ).'</label><br /><textarea id="e_short" name="event_short" rows="2" cols="80">'.$value.'</textarea> 
     690                </p>'; 
     691            } 
     692        break; 
     693        case 'event_image' : 
     694            if ( $show_block ) { 
     695                $value = ( $has_data ) ? esc_attr( $data->event_image ) : '';        
     696                $return = ' 
     697                <div class="mc-image-upload field-holder"> 
     698                    <input type="hidden" name="event_image_id" value="" class="textfield" id="e_image_id" /> 
     699                    <label for="e_image">'.__( "Add an image:",'my-calendar' ).'</label><br /><input type="text" name="event_image" id="e_image" size="60" value="'.$value.'" placeholder="http://yourdomain.com/image.jpg" /> <a href="#" class="button textfield-field">'.__( "Upload",'my-calendar' ).'</a> 
     700                </div>'; 
     701                if ( !empty( $data->event_image ) ) { 
     702                    $return .= '<div class="event_image"><img src="'.esc_attr( $data->event_image ).'" alt="" /></div>'; 
     703                } else { 
     704                    $return .= '<div class="event_image"></div>'; 
     705                }                
     706            } else { 
     707                $return = '<input type="hidden" name="event_image" value="'.$value.'" />'; 
     708            }            
     709        break; 
     710        case 'event_category' : 
     711            if ( $show_block ) { 
     712                $return = '<p> 
     713                <label for="e_category">'.__('Category','my-calendar').'</label> 
     714                <select id="e_category" name="event_category">'. 
     715                    mc_category_select( $data ).' 
     716                </select> 
     717                </p>'; 
     718            } else { 
     719                $return = '<div><input type="hidden" name="event_category" value="'.mc_category_select( $data, false ).'" /></div>'; 
     720            } 
     721        break; 
     722        case 'event_link' : 
     723            if ( $show_block ) { 
     724                $value = ( $has_data ) ? esc_url( $data->event_link ) : ''; 
     725                if ( $has_data && $data->event_link_expires == '1' ) {  
     726                    $checked = " checked=\"checked\"";  
     727                } else if ( $has_data && $data->event_link_expires == '0' ) {  
     728                    $checked = "";  
     729                } else if ( get_option( 'mc_event_link_expires') == 'true' ) {  
     730                    $checked = " checked=\"checked\"";  
     731                }        
     732                $return = ' 
     733                    <p> 
     734                        <label for="e_link">'.__( 'URL','my-calendar' ).'</label> <input type="text" id="e_link" name="event_link" size="40" value="'.$value.'" /> <input type="checkbox" value="1" id="e_link_expires" name="event_link_expires"'.$checked.' /> <label for="e_link_expires">'.__('Link will expire after event','my-calendar').'</label> 
     735                    </p>'; 
     736            } 
     737        break; 
     738        case 'event_recur' : 
     739            if ( is_object($data) ) {    
     740                $event_recur = ( is_object($data) )?$data->event_recur:'';  
     741                $recurs = str_split( $event_recur, 1 ); 
     742                $recur = $recurs[0]; 
     743                $every = ( isset($recurs[1]) )?$recurs[1]:1; 
     744                if ( $every == 1 && $recur == 'B') { $every = 2; } 
     745                    $prev = '<input type="hidden" name="prev_event_repeats" value="'.$data->event_repeats.'" /><input type="hidden" name="prev_event_recur" value="'.$data->event_recur.'" />'; 
     746            } else { 
     747                $recur = $every = false; 
     748                $prev = ''; 
     749            }        
     750            if ( $show_block && empty( $_GET['date'] ) ) { 
     751                if (  is_object($data) && $data->event_repeats != NULL ) {  
     752                    $repeats = $data->event_repeats;  
     753                } else {  
     754                    $repeats = 0;  
     755                } 
     756                $return = $pre.' 
     757                            <h3>'.__( 'Recurring','my-calendar' ).'</h3> 
     758                                <div class="inside">'.$prev.' 
     759                                    <fieldset> 
     760                                    <legend>'.__('Recurring Events','my-calendar').'</legend> 
     761                                        <p> 
     762                                            <label for="e_repeats">'.__('Repeats','my-calendar').' <input type="text" name="event_repeats" aria-labelledby="e_repeats_label" id="e_repeats" size="1" value="'.$repeats.'" /> <span id="e_repeats_label">'.__('times','my-calendar').'</span>, </label> 
     763                                            <label for="e_every">'.__('every','my-calendar').'</label> <input type="number" name="event_every" id="e_every" size="1" min="1" max="9" maxlength="1" value="'.$every.'" />  
     764                                            <label for="e_recur" class="screen-reader-text">'.__('Units','my-calendar').'</label>  
     765                                            <select name="event_recur" id="e_recur"> 
     766                                                '.mc_recur_options($recur).' 
     767                                            </select><br /> 
     768                                            '.__('Your entry is the number of events after the first occurrence of the event: a recurrence of <em>2</em> means the event will happen three times.','my-calendar').' 
     769                                        </p> 
     770                                    </fieldset>  
     771                                </div> 
     772                            '.$post;         
     773            } else { 
     774                $return = ' 
     775                <div>'. 
     776                    $prev.'      
     777                    <input type="hidden" name="event_repeats" value="0" /> 
     778                    <input type="hidden" name="event_recur" value="S" /> 
     779                </div>'; 
     780            }        
     781        break; 
     782        case 'event_access' : 
     783            if ( $show_block ) { 
     784                $label = __('Event Access','my-calendar');           
     785                $return = $pre.' 
     786                        <h3>'.$label.'</h3> 
     787                            <div class="inside">         
     788                                '.mc_event_accessibility( '', $data, $label ). 
     789                                apply_filters( 'mc_event_accessibility', '', $has_data, $data ).'                        
     790                            </div>'.$post; 
     791            }    
     792        break; 
     793        case 'event_open' : 
     794            if ( $show_block ) {  
     795                $return= $pre.' 
     796                <h3>'.__('Event Registration Settings','my-calendar').'</h3> 
     797                <div class="inside"> 
     798                    <fieldset> 
     799                    <legend>'.__('Event Registration','my-calendar').'</legend> 
     800                    '.apply_filters( 'mc_event_registration', '', $has_data, $data, 'admin' ).'      
     801                    </fieldset> 
     802                </div> 
     803                '.$post;     
     804            } else { 
     805                $open = ( $has_data ) ? $data->event_open : '2' ; 
     806                $tickets = ( $has_data ) ? esc_attr( esc_url( $data->event_tickets ) ) : '' ; 
     807                $registration = ( $has_data ) ? esc_attr( $data->event_registration ) : '' ; 
     808                $return = ' 
     809                <div> 
     810                    <input type="hidden" name="event_open" value="'.$open.'" /> 
     811                    <input type="hidden"  name="event_tickets" value="'.$tickets.'" /> 
     812                    <input type="hidden" name="event_registration" value="'.$registration.'" /> 
     813                </div>'; 
     814            }    
     815        break; 
     816        case 'event_location' : 
     817            if ( $show_block ) { 
     818                $return = mc_locations_fields( $has_data, $data, 'event' ); 
     819            } else { 
     820                if ( $has_data ) { 
     821                $return = " 
     822                <div> 
     823                    <input type='hidden' name='event_label' value='".esc_attr(stripslashes($data->event_label))."' /> 
     824                    <input type='hidden' name='event_street' value='".(stripslashes($data->event_street))."' /> 
     825                    <input type='hidden' name='event_street2' value='".(stripslashes($data->event_street2))."' /> 
     826                    <input type='hidden' name='event_phone' value='".(stripslashes($data->event_phone))."' /> 
     827                    <input type='hidden' name='event_phone2' value='".(stripslashes($data->event_phone2))."' /> 
     828                    <input type='hidden' name='event_city' value='".(stripslashes($data->event_city))."' /> 
     829                    <input type='hidden' name='event_state' value='".(stripslashes($data->event_state))."' /> 
     830                    <input type='hidden' name='event_postcode' value='".(stripslashes($data->event_postcode))."' /> 
     831                    <input type='hidden' name='event_region' value='".(stripslashes($data->event_region))."' /> 
     832                    <input type='hidden' name='event_country' value='".(stripslashes($data->event_country))."' /> 
     833                    <input type='hidden' name='event_zoom' value='".(stripslashes($data->event_zoom))."' /> 
     834                    <input type='hidden' name='event_url' value='".(stripslashes($data->event_url))."' /> 
     835                    <input type='hidden' name='event_latitude' value='".(stripslashes($data->event_latitude))."' /> 
     836                    <input type='hidden' name='event_longitude' value='".(stripslashes($data->event_longitude))."' /> 
     837                </div>"; 
     838                } 
     839            } 
     840        break; 
     841        default: return; 
     842    } 
     843    echo apply_filters( 'mc_show_block', $return, $data, $field ); 
     844} 
     845 
     846function mc_form_fields( $data,$mode,$event_id ) { 
    665847    global $wpdb, $user_ID; 
    666848    $mcdb = $wpdb; 
     
    741923        <legend><?php _e( 'Event Details','my-calendar' ); ?></legend> 
    742924        <p> 
    743         <label for="e_title"><?php _e('Event Title','my-calendar'); ?> <span><?php _e('(required)','my-calendar'); ?></span></label><br /><input type="text" id="e_title" name="event_title" size="50" maxlength="255" value="<?php if ( $has_data ) echo apply_filters( 'mc_manage_event_title',stripslashes( esc_attr( $data->event_title ) ), $data ); ?>" /><?php 
     925        <label for="e_title"><?php _e('Event Title','my-calendar'); ?> <span class='required'><?php _e('(required)','my-calendar'); ?></span></label><br /><input type="text" id="e_title" name="event_title" size="50" maxlength="255" value="<?php if ( $has_data ) echo apply_filters( 'mc_manage_event_title',stripslashes( esc_attr( $data->event_title ) ), $data ); ?>" /><?php 
    744926        if ( $mode == 'edit') { ?> 
    745927            <input type='hidden' name='prev_event_status' value='<?php echo $data->event_approved; ?>' /><?php 
     
    774956        </div> 
    775957        <?php } 
    776         if ( function_exists( 'jd_doTwitterAPIPost' ) && current_user_can ( 'wpt_can_tweet') ) { ?> 
    777             <?php if ( !( $mode == 'edit'&& $data->event_approved == 1 ) ) { ?> 
     958        if ( function_exists( 'jd_doTwitterAPIPost' ) && current_user_can ( 'wpt_can_tweet') ) {  
     959            if ( !( $mode == 'edit'&& $data->event_approved == 1 ) ) { ?> 
    778960            <p> 
    779961            <label for='mc_twitter'><?php _e('Post to Twitter (via WP to Twitter)','my-calendar'); ?></label><br /> 
    780962            <textarea cols='70' rows='2' id='mc_twitter' name='mc_twitter'><?php do_action( 'mc_twitter_text', $data ); ?></textarea> 
    781             </p> 
    782             <?php } ?> 
    783         <?php }  
    784         if ( mc_show_edit_block( 'event_desc' ) ) { ?> 
    785         <div class="event_description"> 
    786         <?php $description = ( $has_data ) ? $data->event_desc : ''; ?> 
    787         <label for="content"><?php _e( 'Event Description','my-calendar' ); ?></label><br /> 
     963            </p><?php  
     964            }  
     965        }  
     966        mc_show_block( 'event_desc', $has_data, $data ); 
     967        mc_show_block( 'event_short', $has_data, $data ); 
     968        mc_show_block( 'event_image', $has_data, $data ); 
     969        ?> 
     970        <p> 
     971        <label for="e_host"><?php _e('Host','my-calendar'); ?></label> 
     972        <select id="e_host" name="event_host"> 
     973            <?php 
     974                 // Grab all the categories and list them 
     975                $users = my_calendar_getUsers(); 
     976                foreach( $users as $u ) { 
     977                    $display_name = ( $u->display_name == '') ? $u->user_nicename : $u->display_name;            
     978                    if (  is_object($data) && $data->event_host == $u->ID ) { 
     979                        $selected = ' selected="selected"'; 
     980                    } else if ( is_object($u) && $u->ID == $user_ID && empty( $data->event_host ) ) { 
     981                        $selected = ' selected="selected"'; 
     982                    } else { 
     983                        $selected = ''; 
     984                    } 
     985                    echo "<option value='$u->ID'$selected>$display_name</option>\n"; 
     986                } 
     987            ?> 
     988        </select> 
     989        </p>             
    788990        <?php  
    789         if ( mc_show_edit_block( 'event_use_editor') ) { 
    790             if ( version_compare( get_bloginfo( 'version') , '3.3', '>=') ) { 
    791                 wp_editor( stripslashes( $description ), 'content', array( 'textarea_rows'=>10 ) );  
    792             } else {  
    793                 the_editor( stripslashes( $description ) );  
    794             } 
    795         } else { 
    796             ?><textarea id="content" name="content" class="event_desc" rows="5" cols="80"><?php echo stripslashes( esc_attr( $description ) ); ?></textarea><?php 
    797         } ?> 
    798         </div> 
    799         <?php } ?> 
    800         <?php if ( mc_show_edit_block( 'event_short' ) ) { ?> 
    801         <p> 
    802         <label for="e_short"><?php _e( 'Short Description','my-calendar' ); ?></label><br /><textarea id="e_short" name="event_short" rows="2" cols="80"><?php if ( $has_data ) echo stripslashes( esc_attr( $data->event_short ) ); ?></textarea> 
    803         </p> 
    804         <?php } ?> 
    805         <div class='mc-image-upload field-holder'> 
    806         <?php 
    807         if ( mc_show_edit_block( 'event_image' ) ) { ?> 
    808             <input type="hidden" name="event_image_id" value="" class="textfield" id="e_image_id" /> 
    809             <label for="e_image"><?php _e("Add an image:",'my-calendar'); ?></label><br /><input type="text" name="event_image" id="e_image" size="60" value="<?php if ( $has_data ) echo esc_attr( $data->event_image ); ?>" placeholder="http://yourdomain.com/image.jpg" /> <a href="#" class="button textfield-field"><?php _e( "Upload",'my-calendar' ); ?></a> 
    810         <?php } else { ?> 
    811             <input type="hidden" name="event_image" value="<?php if ( $has_data ) echo esc_attr( $data->event_image ); ?>" /> 
    812         <?php } ?> 
    813             <?php if ( !empty( $data->event_image ) ) { ?> 
    814             <div class="event_image"><img src="<?php echo esc_attr( $data->event_image ); ?>" alt="" /></div> 
    815             <?php } else { ?> 
    816             <div class="event_image"></div> 
    817             <?php } ?>   
    818         </div> 
    819     <p> 
    820     <label for="e_host"><?php _e('Host','my-calendar'); ?></label> 
    821     <select id="e_host" name="event_host"> 
    822         <?php  
    823              // Grab all the categories and list them 
    824             $users = my_calendar_getUsers();                  
    825             foreach( $users as $u ) { 
    826              echo '<option value="'.$u->ID.'"'; 
    827                     if (  is_object($data) && $data->event_host == $u->ID ) { 
    828                      echo 'selected="selected"'; 
    829                     } else if(  is_object($u) && $u->ID == $user_ID && empty($data->event_host) ) { 
    830                     echo 'selected="selected"'; 
    831                     } 
    832                     $display_name = ( $u->display_name == '') ? $u->user_nicename : $u->display_name; 
    833                 echo ">$display_name</option>\n"; 
    834             } 
    835         ?> 
    836     </select> 
    837     </p>             
    838         <?php if ( mc_show_edit_block( 'event_category') ) { ?> 
    839         <p> 
    840         <label for="e_category"><?php _e('Category','my-calendar'); ?></label> 
    841         <select id="e_category" name="event_category"> 
    842             <?php echo mc_category_select( $data ); ?> 
    843         </select> 
    844         </p> 
    845         <?php } else { ?> 
    846         <div><input type="hidden" name="event_category" value="<?php echo mc_category_select( $data, false ); ?>" /></div> 
    847         <?php } ?> 
    848         <?php if ( mc_show_edit_block( 'event_link' ) ) { ?> 
    849         <p> 
    850         <label for="e_link"><?php _e( 'URL','my-calendar' ); ?></label> <input type="text" id="e_link" name="event_link" size="40" value="<?php if ( $has_data ) { echo esc_url( $data->event_link ); } ?>" /> <input type="checkbox" value="1" id="e_link_expires" name="event_link_expires"<?php if ( $has_data && $data->event_link_expires == '1' ) { echo " checked=\"checked\""; } else if ( $has_data && $data->event_link_expires == '0' ) { echo ""; } else if ( get_option( 'mc_event_link_expires') == 'true' ) { echo " checked=\"checked\""; } ?> /> <label for="e_link_expires" class=><?php _e('Link will expire after event','my-calendar'); ?></label> 
    851         </p> 
    852     <?php } ?> 
    853         <?php echo apply_filters( 'mc_event_details', '', $has_data, $data, 'admin' ); ?>                            
     991        mc_show_block( 'event_category', $has_data, $data );  
     992        mc_show_block( 'event_link', $has_data, $data ); 
     993        echo apply_filters( 'mc_event_details', '', $has_data, $data, 'admin' );  
     994        ?>                           
    854995    </fieldset> 
    855996</div> 
     
    8701011            <div id="e_schedule"> 
    8711012            <div id="event1" class="clonedInput" aria-live="polite"> 
    872             <?php 
    873             if ( $has_data ) { 
    874                 $event_begin = esc_attr($data->event_begin);  
    875                 $event_end = esc_attr($data->event_end); 
    876                 if ( !empty($_GET['date'] ) ) { 
    877                     $event = mc_get_event( $instance );                  
    878                     $event_begin = date( 'Y-m-d', strtotime( $event->occur_begin ) ); 
    879                     $event_end = date( 'Y-m-d', strtotime( $event->occur_end ) ); 
    880                 } 
    881                 $starttime = ( $data->event_time == "00:00:00" && $data->event_endtime == "00:00:00" )?'':date( "h:i a",strtotime( $data->event_time ) ); 
    882                 $endtime = ( $data->event_endtime == "00:00:00" && $data->event_time == "00:00:00" )?'':date( "h:i a",strtotime( $data->event_endtime ) );               
    883             } else {  
    884                 $event_begin = date("Y-m-d"); 
    885                 $event_end = $starttime = $endtime = ''; 
    886             }    
    887             ?> 
    888             <p> 
    889                 <label for="e_begin" id="eblabel"><?php _e('Date (YYYY-MM-DD)','my-calendar'); ?></label> <input type="text" id="e_begin" name="event_begin[]" class="event_begin calendar_input" size="10" value="<?php echo $event_begin; ?>" /> 
    890                 <label for="e_time"><?php _e('From','my-calendar'); ?></label>  
    891                 <input type="text" id="e_time" name="event_time[]" size="8" value="<?php echo $starttime; ?>" />     
    892                 <label for="e_endtime"><?php _e('To','my-calendar'); ?></label>  
    893                 <input type="text" id="e_endtime" name="event_endtime[]" size="8" value="<?php echo $endtime; ?>" /> 
    894             </p> 
    895             <ul> 
    896                 <li><input type="checkbox" value="1" id="e_allday" name="event_allday"<?php if ( $has_data && ( $data->event_time == '00:00:00'&& $data->event_endtime == '00:00:00') ) { echo " checked=\"checked\""; } ?> /> <label for="e_allday"><?php _e('All day event','my-calendar'); ?></label> </li> 
    897                 <li><input type="checkbox" value="1" id="e_hide_end" name="event_hide_end"<?php if ( $has_data && $data->event_hide_end == '1') { echo " checked=\"checked\""; } ?> /> <label for="e_hide_end"><?php _e('Hide end time','my-calendar'); ?></label></li> 
    898             </ul> 
    899             <p> 
    900                 <label for="e_end" id="eelabel"><em><?php _e('End Date (YYYY-MM-DD, optional)','my-calendar'); ?></em></label> <input type="text" name="event_end[]" id="e_end" class="event_end calendar_input" size="10" value="<?php echo $event_end; ?>" />  
    901             </p> 
     1013            <?php echo apply_filters( 'mc_datetime_inputs', '', $has_data, $data, 'admin' ); ?> 
    9021014            </div> 
    9031015            <?php if ( $mode != 'edit') { ?>             
     
    9401052        </div> 
    9411053        </div> 
    942             <?php if ( ( mc_show_edit_block( 'event_recurs') ) && empty( $_GET['date'] ) ) { ?> 
    943         <div class="ui-sortable meta-box-sortables">         
    944         <div class="postbox"> 
    945         <h3><?php _e('Recurring','my-calendar'); ?></h3> 
    946         <div class="inside"> 
    947             <?php if ( is_object($data) ) { // information for rewriting recurring data ?> 
    948             <?php 
    949                 $event_recur = ( is_object($data) )?$data->event_recur:'';  
    950                 $recurs = str_split( $event_recur, 1 ); 
    951                 $recur = $recurs[0]; 
    952                 $every = ( isset($recurs[1]) )?$recurs[1]:1; 
    953                 if ( $every == 1 && $recur == 'B') { $every = 2; } 
    954             ?>           
    955             <input type="hidden" name="prev_event_repeats" value="<?php echo $data->event_repeats; ?>" /> 
    956             <input type="hidden" name="prev_event_recur" value="<?php echo $data->event_recur; ?>" /> 
    957             <?php } else { 
    958                 $recur = $every = false; 
    959             } ?> 
    960             <fieldset> 
    961             <legend><?php _e('Recurring Events','my-calendar'); ?></legend>  
    962             <?php if (  is_object($data) && $data->event_repeats != NULL ) { $repeats = $data->event_repeats; } else { $repeats = 0; } ?> 
    963             <p> 
    964             <label for="e_repeats"><?php _e('Repeats','my-calendar'); ?> <input type="text" name="event_repeats" aria-labelledby='event_repeats_label'id="e_repeats" size="1" value="<?php echo $repeats; ?>" /> <span id='event_repeats_label'><?php _e('times','my-calendar'); ?></span>, </label> 
    965             <label for="e_every"><?php _e('every','my-calendar'); ?></label> <input type="number" name="event_every" id="e_every" size="1" min="1" max="9" maxlength="1" value="<?php echo (is_object($data))?$every:1; ?>" />  
    966             <label for="e_recur" class='screen-reader-text'><?php _e('Units','my-calendar'); ?></label> <select name="event_recur" id="e_recur"> 
    967                 <?php echo mc_recur_options($recur); ?> 
    968             </select><br /> 
    969                     <?php _e('Your entry is the number of events after the first occurrence of the event: a recurrence of <em>2</em> means the event will happen three times.','my-calendar'); ?> 
    970             </p> 
    971             </fieldset>  
    972         </div> 
    973         </div>   
    974         </div>           
    975             <?php } else { ?> 
    976             <div> 
    977             <?php if ( is_object($data) ) { // information for rewriting recurring data ?> 
    978             <input type="hidden" name="prev_event_repeats" value="<?php echo $data->event_repeats; ?>" /> 
    979             <input type="hidden" name="prev_event_recur" value="<?php echo $data->event_recur; ?>" /> 
    980             <?php } ?>           
    981             <input type="hidden" name="event_repeats" value="0" /> 
    982             <input type="hidden" name="event_recur" value="S" /> 
    983             </div> 
    984             <?php } ?> 
    985             <?php if ( mc_show_edit_block( 'event_access') ) { ?> 
    986         <div class="ui-sortable meta-box-sortables">         
    987         <div class="postbox"> 
    988         <h3><?php $label = __('Event Access','my-calendar'); echo $label; ?></h3> 
    989         <div class="inside">         
    990             <?php echo mc_event_accessibility( '', $data, $label ); ?> 
    991             <?php echo apply_filters( 'mc_event_accessibility', '', $has_data, $data ); ?>                           
    992         </div> 
    993         </div> 
    994         </div>   
    995             <?php } ?>           
    996             <?php if ( mc_show_edit_block( 'event_open') ) { ?>  
    997         <div class="ui-sortable meta-box-sortables"> 
    998         <div class="postbox"> 
    999         <h3><?php _e('Event Registration Settings','my-calendar'); ?></h3> 
    1000         <div class="inside"> 
    1001             <fieldset> 
    1002             <legend><?php _e('Event Registration','my-calendar'); ?></legend> 
    1003             <?php echo apply_filters( 'mc_event_registration', '', $has_data, $data, 'admin' ); ?>       
    1004             </fieldset> 
    1005         </div> 
    1006         </div>   
    1007         </div>       
    1008             <?php } else { ?> 
    1009             <div> 
    1010                 <input type="hidden" name="event_open" value="<?php echo ( $has_data ) ? $data->event_open : '2'; ?>" /> 
    1011                 <input type="hidden"  name="event_tickets" value="<?php echo ( $has_data ) ? esc_attr( $data->event_tickets ) : ''; ?>" /> 
    1012                 <input type="hidden" name="event_registration" value="<?php echo ( $has_data ) ? esc_attr( $data->event_registration ) : ''; ?>" /> 
    1013             </div> 
    1014             <?php } ?> 
    1015  
    1016             <?php if ( mc_show_edit_block( 'event_location') || mc_show_edit_block( 'event_location_dropdown') ) { ?> 
     1054        <?php 
     1055        mc_show_block( 'event_recur', $has_data, $data ); 
     1056        mc_show_block( 'event_access', $has_data, $data );   
     1057        mc_show_block( 'event_open', $has_data, $data ); 
     1058 
     1059        if ( mc_show_edit_block( 'event_location') || mc_show_edit_block( 'event_location_dropdown') ) { ?> 
    10171060 
    10181061        <div class="ui-sortable meta-box-sortables"> 
     
    10311074                <option value="none"> -- </option> 
    10321075                <?php foreach ( $locations as $location ) { 
    1033                     //if ( !empty($data) && $data->event_label == $location->location_label ) { $checked = 'selected="selected"'; } else { $checked = ''; } 
    10341076                    echo "<option value=\"".$location->location_id."\">".stripslashes($location->location_label)."</option>"; 
    10351077                } ?> 
     
    10381080                <?php } else { ?> 
    10391081                <input type="hidden" name="location_preset" value="none" /> 
    1040                 <p><a href="<?php echo admin_url('admin.php?page=my-calendar-locations'); ?>"><?php _e('Add recurring locations for later use.','my-calendar'); ?></a></p> 
    1041                 <?php } ?> 
    1042             <?php } else { ?> 
     1082                <p><a href="<?php echo admin_url('admin.php?page=my-calendar-locations'); ?>"><?php _e('Add recurring locations for later use.','my-calendar'); ?></a></p><?php  
     1083                }  
     1084            } else { ?> 
    10431085                <input type="hidden" name="location_preset" value="none" />          
    1044             <?php } ?> 
    1045             <?php if ( mc_show_edit_block( 'event_location') ) { ?>          
    1046  
    1047             <?php if ( current_user_can( 'mc_edit_locations') ) { ?><p><input type="checkbox" value="on" name="mc_copy_location" id="mc_copy_location" /> <label for="mc_copy_location"><?php _e('Copy this location into the locations table','my-calendar'); ?></label></p><?php } ?>          
    1048             <p> 
    1049             <label for="e_label"><?php _e('Name of Location (e.g. <em>Joe\'s Bar and Grill</em>)','my-calendar'); ?></label><br /> 
    1050             <?php if ( mc_controlled_field( 'label') ) { 
    1051                 $cur_label = ( !empty( $data ) )?( stripslashes( $data->event_label ) ):''; 
    1052                 echo mc_location_controller( 'label', $cur_label ); 
    1053             } else { ?> 
    1054             <input type="text" id="e_label" name="event_label" size="40" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_label)); ?>" /> 
    1055             <?php } ?> 
    1056             </p> 
    1057             <p> 
    1058             <label for="e_street"><?php _e('Street Address','my-calendar'); ?></label> <input type="text" id="e_street" name="event_street" size="40" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_street)); ?>" /> 
    1059             </p> 
    1060             <p> 
    1061             <label for="e_street2"><?php _e('Street Address (2)','my-calendar'); ?></label> <input type="text" id="e_street2" name="event_street2" size="40" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_street2)); ?>" /> 
    1062             </p>         
    1063             <p> 
    1064             <label for="e_city"><?php _e('City','my-calendar'); ?></label>  
    1065             <?php if ( mc_controlled_field( 'city') ) { 
    1066                 $cur_label = ( !empty( $data ) )?( stripslashes( $data->event_city ) ):''; 
    1067                 echo mc_location_controller( 'city', $cur_label ); 
    1068             } else { ?> 
    1069             <input type="text" id="e_city" name="event_city" size="40" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_city)); ?>" />  
    1070             <?php } ?> 
    1071             <label for="e_state"><?php _e('State/Province','my-calendar'); ?></label>  
    1072             <?php if ( mc_controlled_field( 'state') ) { 
    1073                 $cur_label = ( !empty( $data ) )?( stripslashes( $data->event_state ) ):'';      
    1074                 echo mc_location_controller( 'state', $cur_label ); 
    1075             } else { ?> 
    1076             <input type="text" id="e_state" name="event_state" size="10" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_state)); ?>" />  
    1077             <?php } ?> 
    1078             </p> 
    1079             <p> 
    1080             <label for="e_postcode"><?php _e('Postal Code','my-calendar'); ?></label>  
    1081             <?php if ( mc_controlled_field( 'postcode') ) { 
    1082                 $cur_label = ( !empty( $data ) )?( stripslashes( $data->event_postcode ) ):''; 
    1083                 echo mc_location_controller( 'postcode', $cur_label ); 
    1084             } else { ?> 
    1085             <input type="text" id="e_postcode" name="event_postcode" size="10" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_postcode)); ?>" /> 
    1086             <?php } ?> 
    1087             <label for="e_region"><?php _e('Region','my-calendar'); ?></label>  
    1088             <?php if ( mc_controlled_field( 'region') ) {            
    1089                 $cur_label = ( !empty( $data ) )?( stripslashes( $data->event_region ) ):'';             
    1090                 echo mc_location_controller( 'region', $cur_label ); 
    1091             } else { ?> 
    1092             <input type="text" id="e_region" name="event_region" size="40" value="<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_region)); ?>" /> 
    1093             <?php } ?> 
    1094             </p> 
    1095             <p>      
    1096             <label for="e_country"><?php _e('Country','my-calendar'); ?></label>  
    1097             <?php if ( mc_controlled_field( 'country') ) {           
    1098                 $cur_label = ( !empty( $data ) )?( stripslashes( $data->event_country ) ):'';            
    1099                 echo mc_location_controller( 'country', $cur_label ); 
    1100             } else { ?> 
    1101             <input type="text" id="e_country" name="event_country" size="10" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_country)); ?>" /> 
    1102             <?php } ?> 
    1103             </p> 
    1104             <p> 
    1105             <label for="e_zoom"><?php _e('Initial Zoom','my-calendar'); ?></label>  
    1106                 <select name="event_zoom" id="e_zoom"> 
    1107                 <option value="16"<?php if ( !empty( $data ) && ( $data->event_zoom == 16 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Neighborhood','my-calendar'); ?></option> 
    1108                 <option value="14"<?php if ( !empty( $data ) && ( $data->event_zoom == 14 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Small City','my-calendar'); ?></option> 
    1109                 <option value="12"<?php if ( !empty( $data ) && ( $data->event_zoom == 12 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Large City','my-calendar'); ?></option> 
    1110                 <option value="10"<?php if ( !empty( $data ) && ( $data->event_zoom == 10 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Greater Metro Area','my-calendar'); ?></option> 
    1111                 <option value="8"<?php if ( !empty( $data ) && ( $data->event_zoom == 8 ) ) { echo " selected=\"selected\""; } ?>><?php _e('State','my-calendar'); ?></option> 
    1112                 <option value="6"<?php if ( !empty( $data ) && ( $data->event_zoom == 6 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Region','my-calendar'); ?></option> 
    1113                 </select> 
    1114             </p> 
    1115             <p> 
    1116             <label for="e_phone"><?php _e('Phone','my-calendar'); ?></label> <input type="text" id="e_phone" name="event_phone" size="32" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_phone)); ?>" /> 
    1117             </p> 
    1118             <p> 
    1119             <label for="e_phone2"><?php _e('Secondary Phone','my-calendar'); ?></label> <input type="text" id="e_phone2" name="event_phone2" size="32" value="<?php if ( $has_data ) esc_attr_e(stripslashes($data->event_phone2)); ?>" /> 
    1120             </p>     
    1121             <p> 
    1122             <label for="e_url"><?php _e('Location URL','my-calendar'); ?></label> <input type="text" id="e_url" name="event_url" size="40" value="<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_url)); ?>" /> 
    1123             </p>             
    1124             <fieldset> 
    1125             <legend><?php _e('GPS Coordinates (optional)','my-calendar'); ?></legend> 
    1126             <p> 
    1127             <?php _e('If you supply GPS coordinates for your location, they will be used in place of any other address information to provide your map link.','my-calendar'); ?> 
    1128             </p> 
    1129             <p> 
    1130             <label for="e_latitude"><?php _e('Latitude','my-calendar'); ?></label> <input type="text" id="e_latitude" name="event_latitude" size="10" value="<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_latitude)); ?>" /> <label for="e_longitude"><?php _e('Longitude','my-calendar'); ?></label> <input type="text" id="e_longitude" name="event_longitude" size="10" value="<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_longitude)); ?>" /> 
    1131             </p>             
    1132             </fieldset> 
    1133             <fieldset> 
    1134             <legend><?php _e('Location Accessibility','my-calendar'); ?></legend> 
    1135             <ul class='accessibility-features checkboxes'> 
    1136             <?php  
    1137             $access = apply_filters( 'mc_venue_accessibility', get_option( 'mc_location_access') ); 
    1138             $access_list = ''; 
    1139             if ( !empty( $data ) ) {             
    1140                 $location_access = unserialize( $data->event_access ); 
    1141             } else { 
    1142                 $location_access = array(); 
    1143             } 
    1144             foreach ( $access as $k=>$a ) { 
    1145                 $id = "loc_access_$k"; 
    1146                 $label = $a; 
    1147                 $checked = ''; 
    1148                 if ( is_array( $location_access ) ) { 
    1149                     $checked = ( in_array( $k, $location_access ) ) ? " checked='checked'" : ''; 
    1150                 } 
    1151                 $item = sprintf( '<li><input type="checkbox" id="%1$s" name="event_access[]" value="%4$s" class="checkbox" %2$s /> <label for="%1$s">%3$s</label></li>', $id, $checked, $label, $k ); 
    1152                 $access_list .= $item;           
    1153             } 
    1154             echo $access_list; 
    1155             ?> 
    1156             </ul> 
    1157             </fieldset>  
    1158             <?php } else { ?> 
    1159             <div> 
    1160                 <input type='hidden' name='event_label' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_label)); ?>' /> 
    1161                 <input type='hidden' name='event_street' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_street)); ?>' /> 
    1162                 <input type='hidden' name='event_street2' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_street2)); ?>' /> 
    1163                 <input type='hidden' name='event_phone' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_phone)); ?>' /> 
    1164                 <input type='hidden' name='event_phone2' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_phone2)); ?>' /> 
    1165                 <input type='hidden' name='event_city' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_city)); ?>' /> 
    1166                 <input type='hidden' name='event_state' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_state)); ?>' /> 
    1167                 <input type='hidden' name='event_postcode' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_postcode)); ?>' /> 
    1168                 <input type='hidden' name='event_region' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_region)); ?>' /> 
    1169                 <input type='hidden' name='event_country' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_country)); ?>' /> 
    1170                 <input type='hidden' name='event_zoom' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_zoom)); ?>' /> 
    1171                 <input type='hidden' name='event_url' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_url)); ?>' /> 
    1172                 <input type='hidden' name='event_latitude' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_latitude)); ?>' /> 
    1173                 <input type='hidden' name='event_longitude' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_longitude)); ?>' /> 
    1174                 <input type='hidden' name='event_access_hidden' value='<?php if ( !empty( $data ) ) esc_attr_e(stripslashes($data->event_url)); ?>' /> 
    1175             </div>                   
    1176             <?php } ?> 
    1177             <?php if ( mc_show_edit_block( 'event_location') || mc_show_edit_block( 'event_location_dropdown') ) { ?> 
     1086            <?php }  
     1087            mc_show_block( 'event_location', $has_data, $data ); 
     1088            if ( mc_show_edit_block( 'event_location') || mc_show_edit_block( 'event_location_dropdown') ) { ?> 
    11781089            </fieldset> 
    11791090        </div> 
     
    12421153 
    12431154// Used on the manage events admin page to display a list of events 
    1244 function jd_events_display_list( $type='normal') { 
     1155function mc_list_events( $type='normal') { 
    12451156    global $wpdb; 
    12461157    $mcdb = $wpdb; 
     
    14291340                </div> 
    14301341                </td> 
    1431                 <td><?php if ( $event->event_label != '') { ?><a class='mc_filter'href='<?php $elabel = urlencode($event->event_label); echo admin_url("admin.php?page=my-calendar-manage&amp;filter=$elabel&amp;restrict=where"); ?>'title="<?php _e('Filter by location','my-calendar'); ?>"><span><?php _e('Show only: ', 'my-calendar'); ?></span><?php echo stripslashes($event->event_label); ?></a><?php } ?></td> 
     1342                <td><?php if ( $event->event_label != '') { ?><a class='mc_filter'href='<?php $elabel = urlencode($event->event_label); echo admin_url("admin.php?page=my-calendar-manage&amp;filter=$elabel&amp;restrict=where"); ?>' title="<?php _e('Filter by location','my-calendar'); ?>"><span class="screen-reader-text"><?php _e('Show only: ', 'my-calendar'); ?></span><?php echo stripslashes($event->event_label); ?></a><?php } ?></td> 
    14321343                <?php if ($event->event_time != "00:00:00") { $eventTime = date_i18n(get_option('mc_time_format'), strtotime($event->event_time)); } else { $eventTime = get_option('mc_notime_text'); } ?> 
    14331344                <td><?php $begin = date_i18n( get_option('mc_date_format'), strtotime( $event->event_begin ) ); echo "$begin, $eventTime"; ?> 
     
    18861797            $event_id = $result->occur_id; 
    18871798            $event = mc_get_event( $event_id ); 
    1888             $array = event_as_array($event); 
     1799            $array = mc_create_tags($event); 
    18891800            if ( in_array( $template, array( 'details','grid','list','mini') ) ) { 
    18901801                if ( get_option( 'mc_use_'.$template.'_template') == 1 ) { 
     
    19181829        } 
    19191830    } 
     1831} 
     1832 
     1833function mc_standard_datetime_input( $form, $has_data, $data, $context='admin' ) { 
     1834    if ( $has_data ) { 
     1835        $event_begin = esc_attr($data->event_begin);  
     1836        $event_end = esc_attr($data->event_end); 
     1837        if ( !empty($_GET['date'] ) ) { 
     1838            $event = mc_get_event( $instance );                  
     1839            $event_begin = date( 'Y-m-d', strtotime( $event->occur_begin ) ); 
     1840            $event_end = date( 'Y-m-d', strtotime( $event->occur_end ) ); 
     1841        } 
     1842        $starttime = ( $data->event_time == "00:00:00" && $data->event_endtime == "00:00:00" )?'':date( "h:i a",strtotime( $data->event_time ) ); 
     1843        $endtime = ( $data->event_endtime == "00:00:00" && $data->event_time == "00:00:00" )?'':date( "h:i a",strtotime( $data->event_endtime ) );               
     1844    } else {  
     1845        $event_begin = date("Y-m-d"); 
     1846        $event_end = $starttime = $endtime = ''; 
     1847    }  
     1848    $allday = $hide = ''; 
     1849    if ( $has_data && ( $data->event_time == '00:00:00'&& $data->event_endtime == '00:00:00' ) ) {  
     1850        $allday = " checked=\"checked\"";  
     1851    } 
     1852    if ( $has_data && $data->event_hide_end == '1' ) {  
     1853        $hide = " checked=\"checked\"";  
     1854    }    
     1855    $form .= '<p> 
     1856        <label for="e_begin" id="eblabel">'.__('Date (YYYY-MM-DD)','my-calendar').'</label> <input type="text" id="e_begin" name="event_begin[]" class="event_begin calendar_input" size="10" value="'.$event_begin.'" /> 
     1857        <label for="e_time">'.__('From','my-calendar').'</label>  
     1858        <input type="text" id="e_time" name="event_time[]" size="8" value="'.$starttime.'" />    
     1859        <label for="e_endtime">'.__('To','my-calendar').'</label>  
     1860        <input type="text" id="e_endtime" name="event_endtime[]" size="8" value="'.$endtime.'" /> 
     1861    </p> 
     1862    <ul> 
     1863        <li><input type="checkbox" value="1" id="e_allday" name="event_allday"'.$allday.' /> <label for="e_allday">'.__('All day event','my-calendar').'</label> </li> 
     1864        <li><input type="checkbox" value="1" id="e_hide_end" name="event_hide_end"'.$hide.' /> <label for="e_hide_end">'.__('Hide end time','my-calendar').'</label></li> 
     1865    </ul> 
     1866    <p> 
     1867        <label for="e_end" id="eelabel"><em>'.__('End Date (YYYY-MM-DD, optional)','my-calendar').'</em></label> <input type="text" name="event_end[]" id="e_end" class="event_end calendar_input" size="10" value="'.$event_end.'" />  
     1868    </p>'; 
     1869    return $form; 
    19201870} 
    19211871 
  • my-calendar/trunk/my-calendar-events.php

    r865684 r868877  
    22if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 
    33 
     4function mc_private_categories() { 
     5    $cats = array();  
     6    if ( !is_user_logged_in() ) { 
     7        global $wpdb; 
     8        $mcdb = $wpdb; 
     9        if ( get_option( 'mc_remote' ) == 'true' && function_exists('mc_remote_db') ) { $mcdb = mc_remote_db(); } 
     10        $query = "SELECT category_id FROM ".MY_CALENDAR_CATEGORIES_TABLE." WHERE category_private = 1"; 
     11        $results = $mcdb->get_results( $query ); 
     12        foreach ( $results as $result ) { 
     13            $cats[] = $result->category_id; 
     14        } 
     15        $cats = implode( ',',$cats ); 
     16        if ( $cats != '' ) { 
     17            $cats = " AND category_id NOT IN ($cats)"; 
     18            return $cats;            
     19        } 
     20    } 
     21    return; 
     22} 
     23 
    424// used to generate upcoming events lists 
    525function mc_get_all_events( $category, $before, $after, $today, $author, $host, $ltype='', $lvalue='' ) { 
     
    727    $mcdb = $wpdb; 
    828    if ( get_option( 'mc_remote' ) == 'true' && function_exists('mc_remote_db') ) { $mcdb = mc_remote_db(); } 
    9     $select_category = ( $category!='default' )?mc_select_category($category):''; 
     29    $exclude_categories = mc_private_categories();  
     30    $select_category = ( $category != 'default' ) ? mc_select_category( $category ) : ''; 
    1031    $limit_string = mc_limit_string(); 
    1132    $select_author = ( $author != 'default' )?mc_select_author($author):''; 
    1233    $select_host = ( $host != 'default' )?mc_select_host($host):''; 
    1334    $select_location = mc_limit_string( 'grab', $ltype, $lvalue ); 
    14      
    1535    $date = date('Y', current_time('timestamp')).'-'.date('m', current_time('timestamp')).'-'.date('d', current_time('timestamp')); 
    1636    // if a value is non-zero, I'll grab a handful of extra events so I can throw out holidays and others like that. 
     
    2242        ON (event_id=occur_event_id)  
    2343        JOIN " . MY_CALENDAR_CATEGORIES_TABLE . "  
    24         ON (event_category=category_id) WHERE $select_category $select_author $select_host $limit_string event_approved = 1 AND event_flagged <> 1  
    25         AND DATE(occur_begin) < '$date' ORDER BY occur_begin DESC LIMIT 0,$before"); 
    26     } else { $events1 = array(); } 
     44        ON (event_category=category_id) WHERE $select_category $select_author $select_host $limit_string event_approved = 1  
     45        AND event_flagged <> 1  
     46        AND DATE(occur_begin) < '$date'  
     47        $exclude_categories  
     48        ORDER BY occur_begin DESC LIMIT 0,$before"); 
     49    } else {  
     50        $events1 = array();  
     51    } 
    2752    if ( $today == 'yes' ) { 
    2853        $events3 = $mcdb->get_results("SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end  
     
    3156        ON (event_id=occur_event_id)  
    3257        JOIN " . MY_CALENDAR_CATEGORIES_TABLE . "  
    33         ON (event_category=category_id) WHERE $select_category $select_author $select_host $limit_string event_approved = 1 AND event_flagged <> 1  
     58        ON (event_category=category_id) WHERE $select_category $select_author $select_host $limit_string event_approved = 1  
     59        AND event_flagged <> 1  
     60        $exclude_categories  
    3461        AND ( ( DATE(occur_begin) < '$date' AND DATE(occur_end) > '$date' ) OR DATE(occur_begin) = '$date' )"); // event crosses or equals 
    3562    } else { 
     
    4370        ON (event_id=occur_event_id)  
    4471        JOIN " . MY_CALENDAR_CATEGORIES_TABLE . "  
    45         ON (event_category=category_id) WHERE $select_category $select_author $select_host $limit_string event_approved = 1 AND event_flagged <> 1  
     72        ON (event_category=category_id) WHERE $select_category $select_author $select_host $limit_string event_approved = 1  
     73        AND event_flagged <> 1  
     74        $exclude_categories          
    4675        AND DATE(occur_begin) > '$date' ORDER BY occur_begin ASC LIMIT 0,$after"); 
    47     } else { $events2 = array(); } 
     76    } else {  
     77        $events2 = array();  
     78    } 
    4879    $arr_events = array(); 
    4980    if (!empty($events1) || !empty($events2) || !empty($events3) ) { 
     
    144175} 
    145176 
    146  
     177// get a specific field with an event ID 
    147178function mc_get_data( $field, $id ) { 
    148179    global $wpdb; 
     
    155186} 
    156187 
     188// get all occurrences associated with an event. 
    157189function mc_get_occurrences( $id ) { 
    158190    global $wpdb; 
     
    164196} 
    165197 
     198// get all events related to an event ID (group IDs) 
    166199function mc_related_events( $id, $return=false ) { 
    167200    global $wpdb; 
     
    266299                    JOIN " . MY_CALENDAR_CATEGORIES_TABLE . "  
    267300                    ON (event_category=category_id)  
    268                     WHERE $select_category $select_location $select_author $select_host $limit_string  
     301                    WHERE $select_category $select_location $select_author $select_host $limit_string   
    269302                    AND ( DATE(occur_begin) BETWEEN '$from 00:00:00' AND '$to 23:59:59'  
    270303                        OR DATE(occur_end) BETWEEN '$from 00:00:00' and '$to 23:59:59'  
    271304                        OR ( DATE('$from') BETWEEN DATE(occur_begin) AND DATE(occur_end) )  
    272                         OR ( DATE('$to') BETWEEN DATE(occur_begin) AND DATE(occur_end) ))  
     305                        OR ( DATE('$to') BETWEEN DATE(occur_begin) AND DATE(occur_end) ) )  
    273306                        ORDER BY occur_begin"; 
    274307    $events = $mcdb->get_results( $event_query ); 
     
    316349    $return = false; 
    317350    if ( is_array($cache) ) { 
    318             if ( strpos( $category, ',' ) !== false ) { 
    319                 $cats = explode(',',$category); 
    320             } else if ( strpos( $category, '|' ) !== false ) { 
    321                 $cats = explode('|',$category); 
    322             } else { 
    323                 $cats = array( $category ); 
     351        $cats = array( $category );  
     352        if ( strpos( $category, ',' ) !== false ) { 
     353            $cats = explode( ',',$category ); 
     354        } else if ( strpos( $category, '|' ) !== false ) { 
     355            $cats = explode( '|',$category ); 
     356        } 
     357        $authors = array($auth);         
     358        if ( strpos( $auth, ',' ) !== false ) { 
     359            $authors = explode( ',',$auth ); 
     360        } else if ( strpos( $auth, '|' ) !== false ) { 
     361            $authors = explode( '|',$auth ); 
     362        } 
     363        $hosts = array($host);       
     364        if ( strpos( $host, ',' ) !== false ) { 
     365            $authors = explode( ',',$host ); 
     366        } else if ( strpos( $host, '|' ) !== false ) { 
     367            $authors = explode( '|',$host ); 
     368        }            
     369        foreach ( $authors as $k=>$v ) { 
     370            if ( !is_numeric($v) && $v != 'all' ) {  
     371                $u = get_user_by('login',$v); 
     372                $id = $u->ID; 
     373                $authors[$k]= $id; 
    324374            } 
    325             if ( strpos( $auth, ',' ) !== false ) { 
    326                 $authors = explode(',',$auth); 
    327             } else if ( strpos( $auth, '|' ) !== false ) { 
    328                 $authors = explode('|',$auth); 
    329             } else { 
    330                 $authors = array($auth); 
     375        } 
     376        foreach ( $hosts as $k=>$v ) { 
     377            if ( !is_numeric($v) && $v != 'all' ) {  
     378                $u = get_user_by('login',$v); 
     379                $id = $u->ID; 
     380                $hosts[$k]= $id; 
    331381            } 
    332             if ( strpos( $host, ',' ) !== false ) { 
    333                 $authors = explode(',',$host); 
    334             } else if ( strpos( $host, '|' ) !== false ) { 
    335                 $authors = explode('|',$host); 
    336             } else { 
    337                 $hosts = array($host); 
    338             }            
    339             foreach ( $authors as $k=>$v ) { 
    340                 if ( !is_numeric($v) && $v != 'all' ) {  
    341                     $u = get_user_by('login',$v); 
    342                     $id = $u->ID; 
    343                     $authors[$k]= $id; 
     382        } 
     383        foreach ( $cache as $k=>$v ) { 
     384            foreach ( $cats as $cat ) { 
     385                if ( is_numeric($cat) ) { $cat = (int) $cat; } 
     386                if ( ( $v->event_category == $cat || $category == 'all' || $v->category_name == $cat )  
     387                        && ( $v->event_author == $auth || $auth == 'all' || in_array( $v->event_author,$authors ) ) 
     388                        && ( $v->event_host == $host || $host == 'all' || in_array( $v->event_host,$hosts ) ) 
     389                        && ( $v->{$type} == urldecode($lvalue) || ( $ltype == 'all' && $lvalue == 'all' ) ) ) { 
     390                    $return[$k]=$v; 
    344391                } 
    345392            } 
    346             foreach ( $hosts as $k=>$v ) { 
    347                 if ( !is_numeric($v) && $v != 'all' ) {  
    348                     $u = get_user_by('login',$v); 
    349                     $id = $u->ID; 
    350                     $hosts[$k]= $id; 
    351                 } 
    352             } 
    353         foreach ( $cache as $key=>$value ) { 
    354             foreach ( $cats as $cat ) { 
    355                 if ( is_numeric($cat) ) { $cat = (int) $cat; } 
    356                 if ( ( $value->event_category == $cat || $category == 'all' || $value->category_name == $cat )  
    357                         && ( $value->event_author == $auth || $auth == 'all' || in_array( $value->event_author,$authors ) ) 
    358                         && ( $value->event_host == $host || $host == 'all' || in_array( $value->event_host,$hosts ) ) 
    359                         && ( $value->{$type} == urldecode($lvalue) || ( $ltype == 'all' && $lvalue == 'all' ) ) ) { 
    360                     $return[$key]=$value; 
    361                 } 
    362             } 
    363393        } 
    364394        return $return; 
     
    366396} 
    367397 
    368 function mc_create_cache($arr_events, $hash, $category, $ltype, $lvalue, $author, $host ) { 
     398function mc_create_cache( $arr_events, $hash, $category, $ltype, $lvalue, $author, $host ) { 
    369399    $caching = apply_filters( 'mc_caching_enabled', false, $category, $ltype, $lvalue, $author, $host );  
    370400    if ( $arr_events == false ) { $arr_events = 'empty'; } 
     
    406436    delete_transient( $cache ); 
    407437} 
    408  
    409 /* Implement for 2.3. 
    410 // Notes: switch to file-based caching.  
    411 // $cache will need to become the data array/object, not the cache name 
    412 mc_get_cache( $cache ) { 
    413     $file = plugin_dir_path(__FILE__).'.mc_cache'; 
    414     if (is_file($file)) { 
    415       $cache = file_get_contents($file); 
    416       $cache = maybe_unserialize($cache,true); 
    417        
    418       if (!isset($cache)) { 
    419         unlink($file); 
    420         return false; 
    421       } 
    422     } 
    423 } 
    424 mc_set_cache( $cache ) { 
    425     $file = plugin_dir_path(__FILE__).'.mc_cache'; 
    426     if (!isset($cache)) { 
    427         unset( $cache ); 
    428         file_put_contents($file, serialize( $cache ) ); 
    429         return false; 
    430     } 
    431 } 
    432 mc_remove_cache( $cache ) { 
    433     $file = plugin_dir_path(__FILE__).'.mc_cache'; 
    434     unlink($file); 
    435 } 
    436 */ 
  • my-calendar/trunk/my-calendar-export.php

    r857615 r868877  
    2626        $event = mc_get_event( $mc_id,'object' ); 
    2727        // need to modify date values to match real values using date above 
    28     $array = event_as_array( $event ); 
     28    $array = mc_create_tags( $event ); 
    2929 
    3030$template = "BEGIN:VCALENDAR 
     
    4949    return $output; 
    5050} 
    51  
    5251 
    5352function my_calendar_rss( $events=array() ) { 
     
    101100            foreach ( array_keys( $date ) as $key ) { 
    102101                $event =& $date[$key]; 
    103                 $array = event_as_array( $event ); 
     102                $array = mc_create_tags( $event ); 
    104103                $output .= jd_draw_template( $array, $template, 'rss' ); 
    105104            } 
     
    117116    $ret = ""; 
    118117    $current; 
    119     if (empty($value)) { 
     118    if ( empty( $value ) ) { 
    120119        return $ret; 
    121120    } 
    122  
    123121    $length = strlen($value); 
    124122    for ($i=0; $i < $length; $i++) { 
  • my-calendar/trunk/my-calendar-group-manager.php

    r866550 r868877  
    9494                echo "<div class=\"error\"><p>".__("You must provide an event group id in order to edit it",'my-calendar')."</p></div>"; 
    9595            } else { 
    96                 jd_groups_edit_form('edit', $event_id, $group_id ); 
     96                mc_edit_groups('edit', $event_id, $group_id ); 
    9797            }    
    9898    } else { ?>  
     
    116116                <div class="postbox">    
    117117                    <h3><?php _e('Create/Modify Groups','my-calendar'); ?></h3> 
    118                     <?php jd_groups_display_list(); ?> 
     118                    <?php mc_list_groups(); ?> 
    119119                </div> 
    120120            </div> 
     
    122122        </div><?php  
    123123    } 
    124     jd_show_support_box(); ?> 
     124    mc_show_sidebar(); ?> 
    125125    </div><?php 
    126126}  
     
    168168} 
    169169 
    170 function jd_acquire_group_data($event_id=false) { 
     170function mc_group_data($event_id=false) { 
    171171    global $wpdb,$users_entries; 
    172172    $mcdb = $wpdb; 
     
    251251 
    252252// The event edit form for the manage events admin page 
    253 function jd_groups_edit_form( $mode='edit', $event_id=false, $group_id=false ) { 
     253function mc_edit_groups( $mode='edit', $event_id=false, $group_id=false ) { 
    254254    global $wpdb,$users_entries,$user_ID, $output; 
    255255    $mcdb = $wpdb; 
    256256    $message = ''; 
    257257    if ($event_id != false) { 
    258         $data = jd_acquire_group_data( $event_id ); 
     258        $data = mc_group_data( $event_id ); 
    259259    } else { 
    260260        $data = $users_entries; 
     
    516516                <input type="submit" name="save" class="button-secondary" value="<?php _e('Edit Event Group','my-calendar'); ?>" /> 
    517517            </p> 
    518     </form>      
    519  
     518    </form> 
    520519</div> 
    521520</div> 
     
    526525    global $wpdb, $current_user, $users_entries; 
    527526    $mcdb = $wpdb; 
    528  
    529527    $url_ok = 0; 
    530528    $title_ok = 0; 
    531529    $submit=array(); 
    532  
    533530    if ( get_magic_quotes_gpc() ) { 
    534531        $post = array_map( 'stripslashes_deep', $post ); 
    535532    } 
    536  
    537533    if (!wp_verify_nonce($post['event_nonce_name'],'event_nonce')) { 
    538534        return; 
    539535    } 
    540  
    541 $errors = ""; 
    542 if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) { 
    543     $title = !empty($post['event_title']) ? trim($post['event_title']) : ''; 
    544     $desc = !empty($post['content']) ? trim($post['content']) : ''; 
    545     $short = !empty($post['event_short']) ? trim($post['event_short']) : ''; 
    546     $repeats = ( empty($post['event_repeats']) || trim($post['event_repeats'])=='' ) ? 0 : trim($post['event_repeats']); 
    547     $host = !empty($post['event_host']) ? $post['event_host'] : $current_user->ID; 
    548     $category = !empty($post['event_category']) ? $post['event_category'] : ''; 
    549     $event_link = !empty($post['event_link']) ? trim($post['event_link']) : ''; 
    550     $expires = !empty($post['event_link_expires']) ? $post['event_link_expires'] : '0'; 
    551     $location_preset = !empty($post['location_preset']) ? $post['location_preset'] : ''; 
    552     $event_open = !empty($post['event_open']) ? $post['event_open'] : '2'; 
    553     $event_tickets = !empty( $post['event_tickets'] ) ? trim( $post['event_tickets'] ) : ''; 
    554     $event_registration = !empty( $post['event_registration'] ) ? trim( $post['event_registration'] ) : ''; 
    555     $event_image = esc_url_raw( $post['event_image'] ); 
    556     $event_span = !empty($post['event_span']) ? 1 : 0; 
    557      
    558     // set location 
     536    $errors = ""; 
     537    if ( $action == 'add' || $action == 'edit' || $action == 'copy' ) { 
     538        $title = !empty($post['event_title']) ? trim($post['event_title']) : ''; 
     539        $desc = !empty($post['content']) ? trim($post['content']) : ''; 
     540        $short = !empty($post['event_short']) ? trim($post['event_short']) : ''; 
     541        $repeats = ( empty($post['event_repeats']) || trim($post['event_repeats'])=='' ) ? 0 : trim($post['event_repeats']); 
     542        $host = !empty($post['event_host']) ? $post['event_host'] : $current_user->ID; 
     543        $category = !empty($post['event_category']) ? $post['event_category'] : ''; 
     544        $event_link = !empty($post['event_link']) ? trim($post['event_link']) : ''; 
     545        $expires = !empty($post['event_link_expires']) ? $post['event_link_expires'] : '0'; 
     546        $location_preset = !empty($post['location_preset']) ? $post['location_preset'] : ''; 
     547        $event_open = !empty($post['event_open']) ? $post['event_open'] : '2'; 
     548        $event_tickets = !empty( $post['event_tickets'] ) ? trim( $post['event_tickets'] ) : ''; 
     549        $event_registration = !empty( $post['event_registration'] ) ? trim( $post['event_registration'] ) : ''; 
     550        $event_image = esc_url_raw( $post['event_image'] ); 
     551        $event_span = !empty($post['event_span']) ? 1 : 0; 
     552        // set location 
    559553        if ($location_preset != 'none') { 
    560554            $sql = "SELECT * FROM " . my_calendar_locations_table() . " WHERE location_id = $location_preset"; 
     
    591585            $event_access = !empty($post['event_access_hidden']) ? unserialize( $post['event_access_hidden'] ) : $event_access;          
    592586        } 
    593      
    594         // We check to make sure the URL is acceptable (blank or starting with http://)                                                         
     587        // We check to make sure the URL is acceptable (blank or starting with http://) 
    595588        if ( $event_link == '' ) { 
    596589            $url_ok = 1; 
     
    680673 
    681674// Used on the manage events admin page to display a list of events 
    682 function jd_groups_display_list() { 
     675function mc_list_groups() { 
    683676    global $wpdb; 
    684677    $mcdb = $wpdb; 
     
    689682        $sortdir = 'default'; 
    690683    } 
    691  
    692684    if ( empty($sortby) ) { 
    693685        $sortbyvalue = 'event_begin'; 
     
    705697        } 
    706698    } 
    707     if ($sortdir == 'default') { 
    708         $sortbydirection = 'DESC'; 
    709     } else { 
    710         $sortbydirection = $sortdir; 
    711     } 
    712      
    713     if ($sortbydirection == 'DESC') { 
    714         $sorting = "&amp;order=ASC"; 
    715     } else { 
    716         $sorting = ''; 
    717     } 
     699    $sortbydirection = ( $sortdir == 'default' ) ? 'DESC' : $sortdir; 
     700    $sorting = ( $sortbydirection == 'DESC' ) ? "&amp;order=ASC" : ''; 
    718701     
    719702    $current = empty($_GET['paged']) ? 1 : intval($_GET['paged']); 
     
    734717    $events = $mcdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM " . my_calendar_table() . " $limit ORDER BY $sortbyvalue $sortbydirection LIMIT ".(($current-1)*$items_per_page).", ".$items_per_page ); 
    735718    $found_rows = $wpdb->get_col("SELECT FOUND_ROWS();"); 
    736     $items = $found_rows[0];     
     719    $items = $found_rows[0]; 
    737720    ?><div class='inside'><?php 
    738721    if ( get_option('mc_event_approve') == 'true' ) { ?> 
     
    743726        </ul> 
    744727    <?php } ?> 
    745      
    746     <p><?php _e('Check a set of events to group them for mass editing.','my-calendar'); ?></p> 
    747      
    748         <?php 
     728    <p><?php _e('Check a set of events to group them for mass editing.','my-calendar'); ?></p><?php 
    749729        $num_pages = ceil($items / $items_per_page); 
    750730        if ( $num_pages > 1 ) { 
     
    764744            echo "</div>"; 
    765745        } 
    766         ?>       
    767     <?php 
    768     if ( !empty($events) ) { 
    769         ?> 
     746        if ( !empty($events) ) { ?> 
    770747        <form action="<?php echo admin_url("admin.php?page=my-calendar-groups"); ?>" method="post"> 
    771748        <div> 
     
    777754        </p> 
    778755    </div> 
    779 <table class="widefat wp-list-table" id="my-calendar-admin-table"> 
     756    <table class="widefat wp-list-table" id="my-calendar-admin-table"> 
    780757    <thead> 
    781758    <tr> 
     
    804781            } else { 
    805782                $title = $event->event_title; 
    806             } 
    807             ?> 
     783            } ?> 
    808784            <tr class="<?php echo $class; echo $spam; ?>" id="event<?php echo $event->event_id; ?>"> 
    809785                <th scope="row"><input type="checkbox" value="<?php echo $event->event_id; ?>" name="group[]" id="mc<?php echo $event->event_id; ?>" <?php echo (mc_event_is_grouped( $event->event_group_id ))?' disabled="disabled"':''; ?> /> <label for="mc<?php echo $event->event_id; ?>"><?php echo $event->event_id; ?></label></th> 
    810786                <th scope="row"><?php echo ($event->event_group_id == 0)?'-':$event->event_group_id; ?></th> 
    811     <td title="<?php echo esc_attr(substr(strip_tags(stripslashes($event->event_desc)),0,240)); ?>"> 
     787                <td title="<?php echo esc_attr(substr(strip_tags(stripslashes($event->event_desc)),0,240)); ?>"> 
    812788                    <strong><?php if ( mc_can_edit_event( $event->event_author ) ) { ?> 
    813789                        <a href="<?php echo admin_url("admin.php?page=my-calendar&amp;mode=edit&amp;event_id=$event->event_id"); ?>" class='edit'> 
    814                     <?php } ?> 
    815                     <?php echo $spam_label; echo stripslashes($title); ?> 
     790                    <?php }  
     791                    echo $spam_label; echo stripslashes($title); ?> 
    816792                    <?php if (  mc_can_edit_event( $event->event_author ) ) { echo "</a>"; } ?></strong> 
    817793                <div class='row-actions' style="visibility:visible;"> 
     
    822798                    <?php } else { ?> 
    823799                    <em><?php _e('Ungrouped','my-calendar'); ?></em> 
    824                     <?php } ?> 
    825                 <?php } else { _e("Not editable.",'my-calendar'); } ?>       
     800                    <?php }  
     801                    } else { _e("Not editable.",'my-calendar'); } ?>         
    826802                </div> 
    827803                </td> 
     
    835811                    $every = ( isset($recurs[1]) )?$recurs[1]:1; 
    836812                    // Interpret the DB values into something human readable 
    837                     if ($recur == 'S') { _e('Never','my-calendar'); }  
     813                    if ($recur == 'S') { _e('Never','my-calendar'); } 
    838814                    else if ($recur == 'D') { _e('Daily','my-calendar'); } 
    839815                    else if ($recur == 'E') { _e('Weekdays','my-calendar'); } 
     
    844820                    else if ($recur == 'Y') { _e('Yearly','my-calendar'); } 
    845821                ?>&ndash;<?php 
    846                     if ($recur == 'S') { _e('N/A','my-calendar'); } 
    847                     else if ( mc_event_repeats_forever( $recur, $event->event_repeats ) ) { _e('Forever','my-calendar'); } 
    848                     else if ( $event->event_repeats > 0 ) { printf(__('%d Times','my-calendar'),$event->event_repeats ); }                   
     822                    if ( $recur == 'S' ) {  
     823                        _e('N/A','my-calendar');  
     824                    } else if ( mc_event_repeats_forever( $recur, $event->event_repeats ) ) {  
     825                        _e('Forever','my-calendar');  
     826                    } else if ( $event->event_repeats > 0 ) {  
     827                        printf(__('%d Times','my-calendar'),$event->event_repeats );  
     828                    }                    
    849829                ?>               
    850830                </td> 
    851831                <td><?php echo ( is_object($author) )?$author->display_name:$author; ?></td> 
    852                                 <?php 
    853                                 $this_category = $event->event_category; 
    854                                 foreach ($categories as $key=>$value) { 
    855                                     if ($value->category_id == $this_category) { 
    856                                         $this_cat = $categories[$key]; 
    857                                     }  
    858                                 } 
    859                                 ?> 
     832                    <?php 
     833                    $this_category = $event->event_category; 
     834                    foreach ( $categories as $key=>$value ) { 
     835                        if ($value->category_id == $this_category) { 
     836                            $this_cat = $categories[$key]; 
     837                        }  
     838                    } 
     839                    ?> 
    860840                <td><div class="category-color" style="background-color:<?php echo (strpos($this_cat->category_color,'#') !== 0)?'#':''; echo $this_cat->category_color;?>;"> </div> <?php echo stripslashes($this_cat->category_name); ?></td> 
    861841                <?php unset($this_cat); ?> 
  • my-calendar/trunk/my-calendar-help.php

    r865684 r868877  
    438438</div> 
    439439</div> 
    440     <?php jd_show_support_box(); ?> 
     440    <?php mc_show_sidebar(); ?> 
    441441 
    442442</div> 
  • my-calendar/trunk/my-calendar-ical.php

    r815152 r868877  
    5050            if ( is_object($event) ) { 
    5151                if ( !( $event->category_private == 1 && !is_user_logged_in() ) ) { 
    52                 $array = event_as_array($event); 
     52                $array = mc_create_tags($event); 
    5353                $output .= "\n".jd_draw_template($array,$template,'ical'); 
    5454                } 
  • my-calendar/trunk/my-calendar-install.php

    r866550 r868877  
    647647    // Sanity check 
    648648    if (!file_exists($dirname)) { 
    649     return false; 
     649        return false; 
    650650    } 
    651651    // Simple delete for a file 
    652652    if (is_file($dirname)) { 
    653     return unlink($dirname); 
     653        return unlink($dirname); 
    654654    } 
    655655    // Loop through the folder 
     
    658658    // Skip pointers 
    659659        if ($entry == '.' || $entry == '..') { 
    660         continue; 
     660            continue; 
    661661        } 
    662662        // Recurse 
     
    674674         
    675675        $to = dirname(__FILE__)."/../icons_backup/"; 
    676         $from = dirname(__FILE__)."/icons/"; 
     676        $from = dirname(__FILE__)."/images/icons/"; 
    677677        my_calendar_copyr($from, $to); 
    678678    }    
     
    687687        } 
    688688        $from = dirname(__FILE__)."/../icons_backup/"; 
    689         $to = dirname(__FILE__)."/icons/"; 
     689        $to = dirname(__FILE__)."/images/icons/"; 
    690690        my_calendar_copyr($from, $to); 
    691691        if (is_dir($from)) { 
  • my-calendar/trunk/my-calendar-limits.php

    r857615 r868877  
    1919            $categories = explode( ",", $category );         
    2020        } 
    21         $numcat = count($categories); 
     21        $numcat = count( $categories ); 
    2222        $i = 1; 
    2323        foreach ($categories as $key) { 
  • my-calendar/trunk/my-calendar-locations.php

    r865684 r868877  
    22if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 
    33 
    4 if (!empty($_SERVER['SCRIPT_FILENAME']) && 'my-calendar-locations.php' == basename($_SERVER['SCRIPT_FILENAME'])) { 
     4if ( !empty( $_SERVER['SCRIPT_FILENAME'] ) && 'my-calendar-locations.php' == basename( $_SERVER['SCRIPT_FILENAME'] ) ) { 
    55    die ('Please do not load this page directly. Thanks!'); 
    66} 
     
    124124 
    125125function mc_show_location_form( $view='add',$curID='' ) { 
    126 global $wpdb; 
    127     $mcdb = $wpdb; 
    128     if ($curID != '') { 
     126    global $wpdb; 
     127    $mcdb = $wpdb; 
     128    $cur_loc = false; 
     129    if ( $curID != '' ) { 
    129130        $sql = "SELECT * FROM " . my_calendar_locations_table() . " WHERE location_id=$curID"; 
    130131        $cur_loc = $mcdb->get_row($sql); 
    131132    } 
    132 ?> 
    133 <?php if ($view == 'add') { ?> 
     133    $has_data = ( empty( $cur_loc ) ) ? false : true; 
     134    if ($view == 'add') { ?> 
    134135<h2><?php _e( 'Add New Location','my-calendar' ); ?></h2> 
    135136<?php } else { ?> 
     
    155156            <input type="hidden" name="location_id" value="<?php echo $cur_loc->location_id ?>" /> 
    156157        </div> 
    157         <?php } ?> 
    158             <fieldset> 
    159             <legend><?php _e('Location Address','my-calendar'); ?></legend> 
    160             <p> 
    161             <label for="loc_label"><?php _e('Name of Location (e.g. <em>Joe\'s Bar and Grill</em>)','my-calendar'); ?></label><br /> 
    162             <?php if ( mc_controlled_field( 'label' ) ) { 
    163                 $cur_label = ( !empty( $cur_loc ) )?( stripslashes( $cur_loc->location_label ) ):''; 
    164                 echo mc_location_controller( 'label', $cur_label ); 
    165             } else { ?> 
    166             <input type="text" id="loc_label" name="location_label" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_label)); ?>" /> 
    167             <?php } ?> 
    168             </p> 
    169             <p> 
    170             <label for="loc_street"><?php _e('Street Address','my-calendar'); ?></label><br /><input type="text" id="loc_street" name="location_street" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_street)); ?>" /> 
    171             </p>             
    172             <p> 
    173             <label for="loc_street2"><?php _e('Street Address (2)','my-calendar'); ?></label><br /><input type="text" id="loc_street2" name="location_street2" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_street2)); ?>" /> 
    174             </p>         
    175             <p> 
    176             <label for="loc_city"><?php _e('City','my-calendar'); ?></label>  
    177             <?php if ( mc_controlled_field( 'city' ) ) { 
    178                 $cur_label = ( !empty( $cur_loc ) )?( stripslashes( $cur_loc->location_city ) ):'';      
    179                 echo mc_location_controller( 'city', $cur_label ); 
    180             } else { ?> 
    181             <input type="text" id="loc_city" name="location_city" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_city)); ?>" /> 
    182             <?php } ?> 
    183             <label for="loc_state"><?php _e('State/Province','my-calendar'); ?></label>  
    184             <?php if ( mc_controlled_field( 'state' ) ) { 
    185                 $cur_label = ( !empty( $cur_loc ) )?( stripslashes( $cur_loc->location_state ) ):'';             
    186                 echo mc_location_controller( 'state', $cur_label ); 
    187             } else { ?> 
    188             <input type="text" id="loc_state" name="location_state" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) echo stripslashes(esc_attr($cur_loc->location_state)); ?>" />     
    189             <?php } ?> 
    190             </p> 
    191             <p>          
    192             <label for="loc_postcode"><?php _e('Postal Code','my-calendar'); ?></label><?php  
    193             if ( mc_controlled_field( 'postcode' ) ) { 
    194                 $cur_label = ( !empty( $cur_loc ) )?( stripslashes( $cur_loc->location_postcode ) ):''; 
    195                 echo mc_location_controller( 'postcode', $cur_label ); 
    196             } else { ?> 
    197             <input type="text" id="loc_postcode" name="location_postcode" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) echo stripslashes(esc_attr($cur_loc->location_postcode)); ?>" /> 
    198             <?php } ?> 
    199             <label for="loc_region"><?php _e('Region','my-calendar'); ?></label>  
    200             <?php if ( mc_controlled_field( 'region' ) ) { 
    201                 $cur_label = ( !empty( $cur_loc ) )?( stripslashes( $cur_loc->location_region ) ):'';            
    202                 echo mc_location_controller( 'region', $cur_label ); 
    203             } else { ?> 
    204             <input type="text" id="loc_region" name="location_region" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_region)); ?>" /> 
    205             <?php } ?> 
    206             </p> 
    207             <p> 
    208             <label for="loc_country"><?php _e('Country','my-calendar'); ?></label>  
    209             <?php if ( mc_controlled_field( 'country' ) ) { 
    210                 $cur_label = ( !empty( $cur_loc ) )?( stripslashes( $cur_loc->location_country ) ):'';           
    211                 echo mc_location_controller( 'country', $cur_label ); 
    212             } else { ?> 
    213             <input type="text" id="loc_country" name="location_country" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_country)); ?>" /> 
    214             <?php } ?> 
    215             <label for="loc_zoom"><?php _e('Initial Zoom','my-calendar'); ?></label>  
    216                 <select name="location_zoom" id="loc_zoom"> 
    217                 <option value="16"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 16 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Neighborhood','my-calendar'); ?></option> 
    218                 <option value="14"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 14 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Small City','my-calendar'); ?></option> 
    219                 <option value="12"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 12 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Large City','my-calendar'); ?></option> 
    220                 <option value="10"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 10 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Greater Metro Area','my-calendar'); ?></option> 
    221                 <option value="8"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 8 ) ) { echo " selected=\"selected\""; } ?>><?php _e('State','my-calendar'); ?></option> 
    222                 <option value="6"<?php if ( !empty( $cur_loc ) && ( $cur_loc->location_zoom == 6 ) ) { echo " selected=\"selected\""; } ?>><?php _e('Region','my-calendar'); ?></option> 
    223                 </select> 
    224             </p> 
    225             </fieldset> 
    226             <fieldset> 
    227             <legend><?php _e( 'Contact Information','my-calendar' ); ?></legend> 
    228                 <p> 
    229                 <label for="loc_phone"><?php _e('Phone','my-calendar'); ?></label> <input type="text" id="loc_phone" name="location_phone" class="input" size="32" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_phone)); ?>" /> 
    230                 </p> 
    231                 <p> 
    232                 <label for="loc_phone2"><?php _e('Secondary Phone','my-calendar'); ?></label> <input type="text" id="loc_phone2" name="location_phone2" class="input" size="32" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_phone2)); ?>" /> 
    233                 </p>             
    234                 <p> 
    235                 <label for="loc_url"><?php _e('Website','my-calendar'); ?></label> <input type="text" id="loc_url" name="location_url" class="input" size="40" value="<?php if ( !empty( $cur_loc ) ) esc_attr_e(stripslashes($cur_loc->location_url)); ?>" /> 
    236                 </p> 
    237             </fieldset>          
    238             <fieldset> 
    239             <legend><?php _e('GPS Coordinates (optional)','my-calendar'); ?></legend> 
    240             <p> 
    241              <label for="loc_latitude"><?php _e('Latitude','my-calendar'); ?></label> <input type="text" id="loc_latitude" name="location_latitude" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) { esc_attr_e(stripslashes($cur_loc->location_latitude)); } else { echo '0.000000'; } ?>" /> 
    242              <label for="loc_longitude"><?php _e('Longitude','my-calendar'); ?></label> <input type="text" id="loc_longitude" name="location_longitude" class="input" size="10" value="<?php if ( !empty( $cur_loc ) ) { esc_attr_e(stripslashes($cur_loc->location_longitude)); } else { echo '0.000000'; } ?>" /> 
    243             </p>             
    244             </fieldset> 
    245             <fieldset> 
    246             <legend><?php _e('Location Accessibility','my-calendar'); ?></legend> 
    247             <ul class='accessibility-features checkboxes'> 
    248             <?php  
    249             $access = apply_filters( 'mc_venue_accessibility', get_option( 'mc_location_access' ) ); 
    250             $access_list = ''; 
    251             if ( !empty( $cur_loc ) ) {          
    252                 $location_access = unserialize( $cur_loc->location_access ); 
    253             } else { 
    254                 $location_access = array(); 
    255             } 
    256             foreach ( $access as $k=>$a ) { 
    257                 $id = "loc_access_$k"; 
    258                 $label = $a; 
    259                 $checked = ''; 
    260                 if ( is_array( $location_access ) ) { 
    261                     $checked = ( in_array( $k, $location_access ) ) ? " checked='checked'" : ''; 
    262                 } 
    263                 $item = sprintf( '<li><input type="checkbox" id="%1$s" name="location_access[]" value="%4$s" class="checkbox" %2$s /> <label for="%1$s">%3$s</label></li>', $id, $checked, $label, $k ); 
    264                 $access_list .= $item;           
    265             } 
    266             echo $access_list; 
    267             ?> 
    268             </ul> 
    269             </fieldset> 
     158        <?php }  
     159            echo mc_locations_fields( $has_data, $cur_loc, 'location' ); 
     160        ?> 
    270161            <p> 
    271162                <input type="submit" name="save" class="button-primary" value="<?php if ($view == 'edit') { _e('Save Changes','my-calendar'); } else { _e('Add Location','my-calendar'); } ?> &raquo;" /> 
     
    288179    </div> 
    289180</div> 
    290     <?php jd_show_support_box(); ?> 
     181    <?php mc_show_sidebar(); ?> 
    291182</div> 
    292183 
     
    306197} 
    307198 
    308 function mc_location_controller( $fieldname, $selected ) { 
    309     if ( isset($_GET['page']) && $_GET['page'] == 'my-calendar-locations' ) { 
    310         $field = 'location_'.$fieldname; 
    311     } else { 
    312         $field = 'event_'.$fieldname; 
    313     } 
     199function mc_location_controller( $fieldname, $selected, $context='location' ) { 
     200    $field = ( $context == 'location' ) ? 'location_'.$fieldname : 'event_'.$fieldname ; 
    314201    $selected = trim($selected); 
    315202    $options = get_option('mc_location_controls'); 
     
    317204    $form = "<select name='$field' id='$field'>"; 
    318205    $form .= "<option value='none'>No preference</option>\n";                
    319     foreach ($regions as $key=>$value) { 
     206    foreach ( $regions as $key=>$value ) { 
    320207        $key = trim($key); 
    321         $aselected = ($selected==$key)?" selected='selected'":''; 
     208        $aselected = ( $selected == $key )?" selected='selected'":''; 
    322209        $form .= "<option value='$key'$aselected>$value</option>\n"; 
    323210    } 
     
    392279<?php 
    393280} 
     281 
     282function mc_locations_fields( $has_data, $data, $context = 'location' ) { 
     283    $return = ''; 
     284    if ( current_user_can( 'mc_edit_locations') && $context == 'event' ) { 
     285        $return .= '<p><input type="checkbox" value="on" name="mc_copy_location" id="mc_copy_location" /> <label for="mc_copy_location">'.__('Copy this location into the locations table','my-calendar').'</label></p>'; 
     286    } 
     287    $return .= ' 
     288    <p> 
     289    <label for="e_label">'.__('Name of Location (e.g. <em>Joe\'s Bar and Grill</em>)','my-calendar').'</label><br />'; 
     290    $cur_label = ( !empty( $data ) ) ? ( stripslashes( $data->{$context.'_label'} ) ):'';    
     291    if ( mc_controlled_field( 'label' ) ) { 
     292        $return .= mc_location_controller( 'label', $cur_label, $context ); 
     293    } else { 
     294        $return .= '<input type="text" id="e_label" name="'.$context.'_label" size="40" value="'.esc_attr( $cur_label ).'" />'; 
     295    } 
     296    $street_address = ( $has_data ) ? esc_attr( stripslashes( $data->{$context.'_street'} ) ) : ''; 
     297    $street_address2 = ( $has_data ) ? esc_attr( stripslashes( $data->{$context.'_street2'} ) ) : ''; 
     298    $return .= ' 
     299    </p> 
     300    <p> 
     301    <label for="e_street">'.__('Street Address','my-calendar').'</label> <input type="text" id="e_street" name="'.$context.'_street" size="40" value="'.$street_address.'" /> 
     302    </p> 
     303    <p> 
     304    <label for="e_street2">'.__('Street Address (2)','my-calendar').'</label> <input type="text" id="e_street2" name="'.$context.'_street2" size="40" value="'.$street_address2.'" /> 
     305    </p>         
     306    <p> 
     307    <label for="e_city">'.__('City','my-calendar').'</label> '; 
     308    $cur_city = ( !empty( $data ) )?( stripslashes( $data->{$context.'_city'} ) ):'';    
     309    if ( mc_controlled_field( 'city' ) ) { 
     310        $return .= mc_location_controller( 'city', $cur_city, $context ); 
     311    } else { 
     312        $return .= '<input type="text" id="e_city" name="'.$context.'_city" size="40" value="'.esc_attr( $cur_city ).'" />'; 
     313    } 
     314    $return .= '<label for="e_state">'.__('State/Province','my-calendar').'</label> '; 
     315    $cur_state = ( !empty( $data ) )?( stripslashes( $data->{$context.'_state'} ) ):'';  
     316    if ( mc_controlled_field( 'state' ) ) { 
     317        $return .= mc_location_controller( 'state', $cur_state, $context ); 
     318    } else { 
     319        $return .= '<input type="text" id="e_state" name="'.$context.'_state" size="10" value="'.esc_attr( $cur_state ).'" />'; 
     320    } 
     321    $return .= '</p> 
     322    <p> 
     323    <label for="e_postcode">'.__('Postal Code','my-calendar').'</label> '; 
     324    $cur_postcode = ( !empty( $data ) )?( stripslashes( $data->{$context.'_postcode'} ) ):'';    
     325    if ( mc_controlled_field( 'postcode') ) { 
     326        $return .= mc_location_controller( 'postcode', $cur_postcode, $context ); 
     327    } else { 
     328        $return .= '<input type="text" id="e_postcode" name="'.$context.'_postcode" size="40" value="'.esc_attr( $cur_postcode ).'" />'; 
     329    } 
     330    $return .= '<label for="e_region">'.__('Region','my-calendar').'</label> '; 
     331    $cur_region = ( !empty( $data ) )?( stripslashes( $data->{$context.'_region'} ) ):'';    
     332    if ( mc_controlled_field( 'region' ) ) { 
     333        $return .= mc_location_controller( 'region', $cur_region, $context ); 
     334    } else { 
     335        $return .= '<input type="text" id="e_region" name="'.$context.'_region" size="40" value="'.esc_attr( $cur_region ).'" />'; 
     336    } 
     337    $return .= '</p> 
     338    <p>      
     339    <label for="e_country">'.__('Country','my-calendar').'</label> '; 
     340    $cur_country = ( $has_data )?( stripslashes( $data->{$context.'_country'} ) ):'';    
     341    if ( mc_controlled_field( 'country' ) ) { 
     342        $return .= mc_location_controller( 'country', $cur_country, $context ); 
     343    } else { 
     344        $return .= '<input type="text" id="e_city" name="'.$context.'_country" size="10" value="'.esc_attr( $cur_country ).'" />'; 
     345    } 
     346    $zoom = ( $has_data ) ? $data->{$context.'_zoom'} : '16' ; 
     347    $event_phone = ( $has_data ) ? esc_attr( stripslashes( $data->{$context.'_phone'} ) ) : ''; 
     348    $event_phone2 = ( $has_data ) ? esc_attr( stripslashes( $data->{$context.'_phone2'} ) ) : ''; 
     349    $event_url = ( $has_data ) ? esc_attr( stripslashes( $data->{$context.'_url'} ) ) : ''; 
     350    $event_lat = ( $has_data ) ? esc_attr( stripslashes( $data->{$context.'_latitude'} ) ) : ''; 
     351    $event_lon = ( $has_data ) ? esc_attr( stripslashes( $data->{$context.'_longitude'} ) ) : '';    
     352    $return .= '</p> 
     353    <p> 
     354    <label for="e_zoom">'.__('Initial Zoom','my-calendar').'</label>  
     355        <select name="'.$context.'_zoom" id="e_zoom"> 
     356            <option value="16"'.jd_option_selected( $zoom, '16', 'option' ).'>'.__('Neighborhood','my-calendar').'</option> 
     357            <option value="14"'.jd_option_selected( $zoom, '14', 'option' ).'>'.__('Small City','my-calendar').'</option> 
     358            <option value="12"'.jd_option_selected( $zoom, '12', 'option' ).'>'.__('Large City','my-calendar').'</option> 
     359            <option value="10"'.jd_option_selected( $zoom, '10', 'option' ).'>'.__('Greater Metro Area','my-calendar').'</option> 
     360            <option value="8"'.jd_option_selected( $zoom, '8', 'option' ).'>'.__('State','my-calendar').'</option> 
     361            <option value="6"'.jd_option_selected( $zoom, '6', 'option' ).'>'.__('Region','my-calendar').'</option> 
     362        </select> 
     363    </p> 
     364    <p> 
     365    <label for="e_phone">'.__('Phone','my-calendar').'</label> <input type="text" id="e_phone" name="'.$context.'_phone" size="32" value="'.$event_phone.'" /> 
     366    </p> 
     367    <p> 
     368    <label for="e_phone2">'.__('Secondary Phone','my-calendar').'</label> <input type="text" id="e_phone2" name="'.$context.'_phone2" size="32" value="'.$event_phone2.'" /> 
     369    </p>     
     370    <p> 
     371    <label for="e_url">'.__('Location URL','my-calendar').'</label> <input type="text" id="e_url" name="'.$context.'_url" size="40" value="'.$event_url.'" /> 
     372    </p>             
     373    <fieldset> 
     374    <legend>'.__('GPS Coordinates (optional)','my-calendar').'</legend> 
     375    <p> 
     376    '.__('If you supply GPS coordinates for your location, they will be used in place of any other address information to provide your map link.','my-calendar').' 
     377    </p> 
     378    <p> 
     379    <label for="e_latitude">'.__('Latitude','my-calendar').'</label> <input type="text" id="e_latitude" name="'.$context.'_latitude" size="10" value="'.$event_lat.'" /> <label for="e_longitude">'.__('Longitude','my-calendar').'</label> <input type="text" id="e_longitude" name="'.$context.'_longitude" size="10" value="'.$event_lon.'" /> 
     380    </p>             
     381    </fieldset> 
     382    <fieldset> 
     383    <legend>'.__('Location Accessibility','my-calendar').'</legend> 
     384    <ul class="accessibility-features checkboxes">'; 
     385    $access = apply_filters( 'mc_venue_accessibility', get_option( 'mc_location_access') ); 
     386    $access_list = ''; 
     387    if ( $context == 'location' ) { 
     388        $location_access = ( $has_data ) ? unserialize( $data->{$context.'_access'} ) : array(); 
     389    } else { 
     390        $location_access = unserialize( mc_location_data( 'location_access', $data->event_location ) ); 
     391    } 
     392    foreach ( $access as $k=>$a ) { 
     393        $id = "loc_access_$k"; 
     394        $label = $a; 
     395        $checked = ''; 
     396        if ( is_array( $location_access ) ) { 
     397            $checked = ( in_array( $a, $location_access ) || in_array( $k, $location_access ) ) ? " checked='checked'" : ''; 
     398        } 
     399        $item = sprintf( '<li><input type="checkbox" id="%1$s" name="'.$context.'_access[]" value="%4$s" class="checkbox" %2$s /> <label for="%1$s">%3$s</label></li>', $id, $checked, $label, $a ); 
     400        $access_list .= $item;           
     401    } 
     402    $return  .= $access_list; 
     403    $return .= '</ul> 
     404    </fieldset>'; 
     405    return $return; 
     406} 
     407 
     408// get a specific field with an location ID 
     409function mc_location_data( $field, $id ) { 
     410    global $wpdb; 
     411    $mcdb = $wpdb; 
     412    if ( get_option( 'mc_remote') == 'true'&& function_exists('mc_remote_db') ) { $mcdb = mc_remote_db(); } 
     413    $field = esc_sql( $field ); 
     414    $sql = $wpdb->prepare( "SELECT $field FROM ".my_calendar_locations_table()." WHERE location_id = %d", $id ); 
     415    $result = $mcdb->get_var($sql); 
     416    return $result; 
     417} 
  • my-calendar/trunk/my-calendar-output.php

    r866550 r868877  
    115115    } else { 
    116116        if ($event->category_icon != "") { 
    117             $path = ( is_custom_icon() ) ? str_replace( 'my-calendar','my-calendar-custom',$url ) : plugins_url( 'icons', __FILE__ ).'/'; 
     117            $path = ( is_custom_icon() ) ? str_replace( 'my-calendar','my-calendar-custom',$url ) : plugins_url( 'images/icons', __FILE__ ).'/'; 
    118118            $hex = ( strpos( $event->category_color,'#' ) !== 0 )?'#':''; 
    119119            if ( $html == 'html' ) { 
     
    146146    } 
    147147    // if event ends at midnight today (e.g., very first thing of the day), exit without re-drawing 
    148     if ( $event->event_endtime == '00:00:00' && $event->event_time != '00:00:00' && $event->event_end == $process_date && $event->event_allday !== 1 ) { 
     148    if ( $event->event_endtime == '00:00:00' && $event->event_time != '00:00:00' && $event->event_end == $process_date && $event->event_begin != $process_date ) { 
    149149        return; 
    150150    } 
     
    157157    $header  = $address = $more = $author = $list_title = $title = $output = $container = $short = $description = $link = $vcal = $gcal = ''; 
    158158    $date_format = ( get_option('mc_date_format') != '' ) ? get_option('mc_date_format') : get_option('date_format'); 
    159     $data = event_as_array($event);  
     159    $data = mc_create_tags($event);  
    160160    $details = apply_filters( 'mc_custom_template', false, $data, $event, $type, $process_date, $time, $template ); 
    161161    $templates = get_option('mc_templates');     
     
    236236        } 
    237237        // end vcard 
    238         $close = ( $type == 'calendar' || $type == 'mini' ) ? "<span class='close'><a href=\"#$uid-$day_id-$type\" class='mc-toggle mc-close close'><img src='".plugin_dir_url(__FILE__)."images/event-close.png' alt='".__('Close','my-calendar')."' /></a></span>" : '' ; 
     238        $close = ( $type == 'calendar' || $type == 'mini' ) ? "<a href=\"#$uid-$day_id-$type\" class='mc-toggle mc-close close'><img src=\"".plugin_dir_url(__FILE__)."images/event-close.png\" alt='".__('Close','my-calendar')."' /></a>" : '' ; 
    239239        $time = mc_time_html( $event, $type, $current_date ); 
    240240        if ($type == "list") { 
     
    341341        $custom = true;  
    342342        // if a custom template is in use 
    343         $toggle = ( $type == 'calendar' || $type == 'mini' )?"<a href=\"#$uid-$day_id-$type\" class='mc-toggle mc-close close'><img src='".plugin_dir_url(__FILE__)."images/event-close.png' alt='".__('Close','my-calendar')."' /></a>":'';     
     343        $toggle = ( $type == 'calendar' || $type == 'mini' )?"<a href=\"#$uid-$day_id-$type\" class='mc-toggle mc-close close'><img src=\"".plugin_dir_url(__FILE__)."images/event-close.png\" alt='".__('Close','my-calendar')."' /></a>":'';   
    344344        $details = $toggle.$details."\n"; 
    345345    } 
     
    698698    $mc_bottomorder = array( 'key','feeds' ); 
    699699    if ( $above != '' || $below != '' ) { 
    700         $aboves = ( $above == 'none' )?array():array_map( 'trim', explode(',',$above) ); 
    701         $belows = ( $below == 'none' )?array():array_map( 'trim', explode(',',$below) ); 
     700        $aboves = ( $above == 'none' ) ? array() : array_map( 'trim', explode( ',',$above ) ); 
     701        $belows = ( $below == 'none' ) ? array() : array_map( 'trim', explode( ',',$below ) ); 
    702702    } else { 
    703703        $aboves = $mc_toporder; 
     
    717717    /* filter */ 
    718718    if ( $time == 'day' ) { $format = 'list'; } 
    719     $args = array( 'name'=>$name,'format'=>$format,'category'=>$category,'above'=>$above,'below'=>$below,'time'=>$time,'ltype'=>$ltype,'lvalue'=>$lvalue, 'author'=>$author ); 
     719    $args = array( 'name'=>$name,'format'=>$format,'category'=>$category,'above'=>$above,'below'=>$below,'time'=>$time,'ltype'=>$ltype,'lvalue'=>$lvalue, 'author'=>$author, 'id'=>$id ); 
    720720    $my_calendar_body .= apply_filters('mc_before_calendar','',$args); 
    721721     
     
    11501150            $category_key .= '<div class="category-key"> 
    11511151            <h3>'.__('Category Key','my-calendar')."</h3>\n<ul>\n"; 
    1152                 $subpath = (is_custom_icon())?'my-calendar-custom/':'my-calendar/icons/'; 
     1152                $subpath = (is_custom_icon())?'my-calendar-custom/':'my-calendar/images/icons/'; 
    11531153                $path = str_replace( basename( $dir ) . '/','',$url) . $subpath; 
    11541154            foreach($cat_details as $cat_detail) { 
  • my-calendar/trunk/my-calendar-settings.php

    r866550 r868877  
    77        foreach ( $atts as $key => $value ) { $attributes .= " $key='$value'"; } 
    88    } 
     9    $value = ( get_option( $name ) != '' ) ? stripslashes( esc_attr( get_option( $name ) ) ) : $default ;    
    910    switch ( $type ) { 
    1011        case 'text': 
    1112        case 'url': 
    1213        case 'email': 
    13             $value = ( get_option( $name ) != '' ) ? stripslashes( esc_attr( get_option( $name ) ) ) : $default ; 
    1414            if ( $note ) {  
    1515                $note = sprintf( $note, "<code>$value</code>" ); 
     
    2121        break; 
    2222        case 'textarea': 
    23             $value = ( get_option( $name ) != '' ) ? stripslashes( esc_attr( get_option( $name ) ) ) : $default ; 
    2423            if ( $note ) {  
    2524                $note = sprintf( $note, "<code>$value</code>" ); 
     
    4140        case 'checkbox': 
    4241        case 'radio': 
    43             $value = ( get_option( $name ) != '' ) ? esc_attr( get_option( $name ) ) : $default ; 
    4442            if ( $note ) {  
    4543                $note = sprintf( $note, "<code>$value</code>" ); 
     
    5553            break;       
    5654        case 'select': 
    57             $value = ( get_option( $name ) != '' ) ? esc_attr( get_option( $name ) ) : $default ; 
    5855            if ( $note ) {  
    5956                $note = sprintf( $note, "<code>$value</code>" ); 
     
    128125            $cats_results = $mcdb->query($catsql); 
    129126        }            
    130         $message = ( $cats_results !== false )?__('Categories imported successfully.','my-calendar'):__('Categories not imported.','my-calendar'); 
    131         $e_message = ( $events_results !== false )?__('Events imported successfully.','my-calendar'):__('Events not imported.','my-calendar'); 
     127        $message = ( $cats_results !== false )?__( 'Categories imported successfully.','my-calendar' ):__( 'Categories not imported.','my-calendar' ); 
     128        $e_message = ( $events_results !== false )?__( 'Events imported successfully.','my-calendar' ):__( 'Events not imported.','my-calendar' ); 
    132129        $return = "<div id='message' class='updated fade'><ul><li>$message</li><li>$e_message</li></ul></div>"; 
    133130        echo $return; 
     
    153150        if ( isset($_POST['remigrate']) ) {  
    154151            echo "<div class='updated fade'><ol>"; 
    155             echo "<li>".__('Dropping occurrences database table','my-calendar')."</li>"; 
     152            echo "<li>".__( 'Dropping occurrences database table','my-calendar' )."</li>"; 
    156153            mc_drop_table( 'my_calendar_event_table' ); sleep(1); 
    157             echo "<li>".__('Reinstalling occurrences database table.','my-calendar')."</li>"; 
     154            echo "<li>".__( 'Reinstalling occurrences database table.','my-calendar' )."</li>"; 
    158155            mc_upgrade_db(); sleep(1); 
    159             echo "<li>".__('Generating event occurrences.','my-calendar')."</li>"; 
     156            echo "<li>".__( 'Generating event occurrences.','my-calendar' )."</li>"; 
    160157            mc_migrate_db(); 
    161             echo "<li>".__('Event generation completed.','my-calendar')."</li>"; 
     158            echo "<li>".__( 'Event generation completed.','my-calendar' )."</li>"; 
    162159            echo "</ol></div>"; 
    163160        } 
     
    169166        $mc_api_enabled = ( !empty($_POST['mc_api_enabled']) && $_POST['mc_api_enabled']=='on')?'true':'false'; 
    170167        $mc_remote = ( !empty($_POST['mc_remote']) && $_POST['mc_remote']=='on')?'true':'false'; 
    171         if ( isset($_POST['mc_clear_cache']) && $_POST['mc_clear_cache'] == 'clear' ) { mc_delete_cache(); $clear = __('My Calendar Cache cleared','my-calendar'); } 
     168        if ( isset($_POST['mc_clear_cache']) && $_POST['mc_clear_cache'] == 'clear' ) { mc_delete_cache(); $clear = __( 'My Calendar Cache cleared','my-calendar' ); } 
    172169        update_option('mc_event_approve',$mc_event_approve); 
    173170        update_option('mc_api_enabled',$mc_api_enabled); 
     
    178175            update_option('mc_current_table',$mc_current_table); 
    179176        } 
    180         echo "<div class='updated'><p><strong>".__('My Calendar Management Settings saved','my-calendar').". $clear</strong></p></div>"; 
     177        echo "<div class='updated'><p><strong>".__( 'My Calendar Management Settings saved','my-calendar' ).". $clear</strong></p></div>"; 
    181178    } 
    182179    if ( isset($_POST['mc_permissions'] ) ) { 
    183180        $perms = $_POST['mc_caps']; 
    184181        $caps = array(  
    185                     'mc_add_events'=>__('Add Events','my-calendar'), 
    186                     'mc_approve_events'=>__('Approve Events','my-calendar'), 
    187                     'mc_manage_events'=>__('Manage Events','my-calendar'), 
    188                     'mc_edit_cats'=>__('Edit Categories','my-calendar'), 
    189                     'mc_edit_locations'=>__('Edit Locations','my-calendar'), 
    190                     'mc_edit_styles'=>__('Edit Styles','my-calendar'), 
    191                     'mc_edit_behaviors'=>__('Edit Behaviors','my-calendar'), 
    192                     'mc_edit_templates'=>__('Edit Templates','my-calendar'), 
    193                     'mc_edit_settings'=>__('Edit Settings','my-calendar'), 
    194                     'mc_view_help'=>__('View Help','my-calendar') 
     182                    'mc_add_events'=>__( 'Add Events','my-calendar' ), 
     183                    'mc_approve_events'=>__( 'Approve Events','my-calendar' ), 
     184                    'mc_manage_events'=>__( 'Manage Events','my-calendar' ), 
     185                    'mc_edit_cats'=>__( 'Edit Categories','my-calendar' ), 
     186                    'mc_edit_locations'=>__( 'Edit Locations','my-calendar' ), 
     187                    'mc_edit_styles'=>__( 'Edit Styles','my-calendar' ), 
     188                    'mc_edit_behaviors'=>__( 'Edit Behaviors','my-calendar' ), 
     189                    'mc_edit_templates'=>__( 'Edit Templates','my-calendar' ), 
     190                    'mc_edit_settings'=>__( 'Edit Settings','my-calendar' ), 
     191                    'mc_view_help'=>__( 'View Help','my-calendar' ) 
    195192                    ); 
    196193        foreach ( $perms as $key => $value ) { 
     
    206203            } 
    207204        } 
    208         echo "<div class='updated'><p><strong>".__('My Calendar Permissions Updated','my-calendar')."</strong></p></div>"; 
     205        echo "<div class='updated'><p><strong>".__( 'My Calendar Permissions Updated','my-calendar' )."</strong></p></div>"; 
    209206    } 
    210207    // output 
    211     if (isset($_POST['mc_show_months']) ) { 
    212         $mc_open_day_uri = ( !empty($_POST['mc_open_day_uri']) )?$_POST['mc_open_day_uri']:''; 
     208    if ( isset( $_POST['mc_show_months'] ) ) { 
     209        $mc_open_day_uri = ( !empty( $_POST['mc_open_day_uri'] ) ) ? $_POST['mc_open_day_uri'] : ''; 
    213210        update_option('mc_uri',$_POST['mc_uri'] ); 
    214211        update_option('mc_open_uri',( !empty($_POST['mc_open_uri']) && $_POST['mc_open_uri']=='on' && get_option('mc_uri') != '')?'true':'false'); 
     
    219216        update_option('mc_display_author',( !empty($_POST['mc_display_author']) && $_POST['mc_display_author']=='on')?'true':'false'); 
    220217        update_option('mc_show_event_vcal',( !empty($_POST['mc_show_event_vcal']) && $_POST['mc_show_event_vcal']=='on')?'true':'false');        
    221         update_option('mc_show_gcal',( !empty($_POST['mc_show_gcal']) && $_POST['mc_show_gcal']=='on')?'true':'false');      
     218        update_option('mc_show_gcal',( !empty($_POST['mc_show_gcal']) && $_POST['mc_show_gcal']=='on')?'true':'false'); 
    222219        update_option('mc_display_jump',( !empty($_POST['mc_display_jump']) && $_POST['mc_display_jump']=='on')?'true':'false'); 
    223220        update_option('mc_show_list_info',( !empty($_POST['mc_show_list_info']) && $_POST['mc_show_list_info']=='on')?'true':'false');       
     
    256253        update_option('mc_convert',( !empty($_POST['mc_convert']) && $_POST['mc_convert']=='on')?'true':'false'); 
    257254        update_option('mc_no_fifth_week',( !empty($_POST['mc_no_fifth_week']) && $_POST['mc_no_fifth_week']=='on')?'true':'false'); 
    258         echo "<div class=\"updated\"><p><strong>".__('Output Settings saved','my-calendar')."</strong></p></div>"; 
     255        echo "<div class=\"updated\"><p><strong>".__( 'Output Settings saved','my-calendar' )."</strong></p></div>"; 
    259256    } 
    260257    // input 
     
    266263        $mc_ical_utc = ( !empty($_POST['mc_ical_utc']) && $_POST['mc_ical_utc']=='on')?'true':'false'; 
    267264        update_option('mc_ical_utc',$mc_ical_utc);       
    268         echo "<div class=\"updated\"><p><strong>".__('Date/Time Format Settings saved','my-calendar')."</strong></p></div>";         
     265        echo "<div class=\"updated\"><p><strong>".__( 'Date/Time Format Settings saved','my-calendar' )."</strong></p></div>";       
    269266    } 
    270267    if (isset($_POST['mc_input'])) { 
     
    286283        update_option('mc_input_options',$mc_input_options); 
    287284        update_option('mc_input_options_administrators',$mc_input_options_administrators);   
    288         echo "<div class=\"updated\"><p><strong>".__('Input Settings saved','my-calendar').".</strong></p></div>"; 
     285        echo "<div class=\"updated\"><p><strong>".__( 'Input Settings saved','my-calendar' ).".</strong></p></div>"; 
    289286    } 
    290287    if ( current_user_can( 'manage_network' ) ) { 
     
    339336        update_option('mc_event_mail',$mc_event_mail); 
    340337        update_option('mc_html_email',$mc_html_email); 
    341         echo "<div class=\"updated\"><p><strong>".__('Email notice settings saved','my-calendar').".</strong></p></div>"; 
     338        echo "<div class=\"updated\"><p><strong>".__( 'Email notice settings saved','my-calendar' ).".</strong></p></div>"; 
    342339    } 
    343340    // Custom User Settings 
     
    355352<?php my_calendar_check_db();?> 
    356353    <div id="icon-options-general" class="icon32"><br /></div> 
    357     <h2><?php _e('My Calendar Options','my-calendar'); ?></h2> 
     354    <h2><?php _e('My Calendar Options','my-calendar' ); ?></h2> 
    358355<div class="postbox-container jcd-wide"> 
    359356<div class="metabox-holder"> 
     
    370367    <div class='import upgrade-db'> 
    371368    <p> 
    372     <?php _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar'); ?> 
     369    <?php _e('My Calendar has identified that you have the Calendar plugin by Kieran O\'Shea installed. You can import those events and categories into the My Calendar database. Would you like to import these events?','my-calendar' ); ?> 
    373370    </p> 
    374371        <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
     
    376373        <div> 
    377374        <input type="hidden" name="import" value="true" /> 
    378         <input type="submit" value="<?php _e('Import from Calendar','my-calendar'); ?>" name="import-calendar" class="button-primary" /> 
     375        <input type="submit" value="<?php _e('Import from Calendar','my-calendar' ); ?>" name="import-calendar" class="button-primary" /> 
    379376        </div> 
    380377        </form> 
     
    387384<div class="ui-sortable meta-box-sortables">    
    388385<div class="postbox"> 
    389     <h3><?php _e('My Calendar Settings','my-calendar'); ?></h3> 
     386    <h3><?php _e('My Calendar Settings','my-calendar' ); ?></h3> 
    390387    <div class="inside"> 
    391388    <ul class="mc-settings checkboxes"> 
    392         <li><a href="#my-calendar-manage"><?php _e('Management','my-calendar'); ?></a></li> 
    393         <li><a href="#my-calendar-text"><?php _e('Customizable Text','my-calendar'); ?></a></li> 
    394         <li><a href="#my-calendar-output"><?php _e('Output','my-calendar'); ?></a></li> 
    395         <li><a href="#my-calendar-time"><?php _e('Date/Time','my-calendar'); ?></a></li> 
    396         <li><a href="#my-calendar-input"><?php _e('Input','my-calendar'); ?></a></li> 
     389        <li><a href="#my-calendar-manage"><?php _e('Management','my-calendar' ); ?></a></li> 
     390        <li><a href="#my-calendar-text"><?php _e('Customizable Text','my-calendar' ); ?></a></li> 
     391        <li><a href="#my-calendar-output"><?php _e('Output','my-calendar' ); ?></a></li> 
     392        <li><a href="#my-calendar-time"><?php _e('Date/Time','my-calendar' ); ?></a></li> 
     393        <li><a href="#my-calendar-input"><?php _e('Input','my-calendar' ); ?></a></li> 
    397394        <?php if ( current_user_can('manage_network') ) { ?> 
    398         <li><a href="#my-calendar-multisite"><?php _e('Multi-site','my-calendar'); ?></a></li>       
     395        <li><a href="#my-calendar-multisite"><?php _e('Multi-site','my-calendar' ); ?></a></li>      
    399396        <?php } ?> 
    400         <li><a href="#my-calendar-permissions"><?php _e('Permissions','my-calendar'); ?></a></li> 
    401         <li><a href="#my-calendar-email"><?php _e('Email Notifications','my-calendar'); ?></a></li> 
     397        <li><a href="#my-calendar-permissions"><?php _e('Permissions','my-calendar' ); ?></a></li> 
     398        <li><a href="#my-calendar-email"><?php _e('Email Notifications','my-calendar' ); ?></a></li> 
    402399        <?php echo apply_filters( 'mc_settings_section_links', '' ); ?> 
    403400    </ul> 
     
    408405<div class="ui-sortable meta-box-sortables">    
    409406<div class="postbox" id="my-calendar-manage"> 
    410     <h3><?php _e('My Calendar Management','my-calendar'); ?></h3> 
     407    <h3><?php _e('My Calendar Management','my-calendar' ); ?></h3> 
    411408    <div class="inside"> 
    412409    <?php if ( current_user_can('administrator') ) { ?> 
     
    414411    <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>   
    415412    <fieldset> 
    416     <legend><?php _e('Management','my-calendar'); ?></legend> 
     413    <legend><?php _e('Management','my-calendar' ); ?></legend> 
    417414    <ul> 
    418     <li><?php mc_settings_field ( 'mc_remote', __('Get data (events, categories and locations) from a remote database.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     415    <li><?php mc_settings_field( 'mc_remote', __( 'Get data (events, categories and locations) from a remote database.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    419416    <?php if ( get_option('mc_remote') == 'true' ) { ?> 
    420     <li><?php _e('Add this code to your theme\'s <code>functions.php</code> file:','my-calendar'); ?> 
     417    <li><?php _e('Add this code to your theme\'s <code>functions.php</code> file:','my-calendar' ); ?> 
    421418<pre>function mc_remote_db() { 
    422419    $mcdb = new wpdb('DB_USER','DB_PASSWORD','DB_NAME','DB_ADDRESS'); 
    423420    return $mcdb; 
    424421}</pre> 
    425         <?php _e('You will need to allow remote connections from this site to the site hosting your My Calendar events. Replace the above placeholders with the host-site information. The two sites must have the same WP table prefix. While this option is enabled, you may not enter or edit events through this installation.','my-calendar'); ?> 
     422        <?php _e('You will need to allow remote connections from this site to the site hosting your My Calendar events. Replace the above placeholders with the host-site information. The two sites must have the same WP table prefix. While this option is enabled, you may not enter or edit events through this installation.','my-calendar' ); ?> 
    426423    </li>    
    427424    <?php } ?> 
    428     <li><?php mc_settings_field ( 'mc_event_approve', __('Enable approval options.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    429     <li><?php mc_settings_field ( 'mc_api_enabled', __('Enable external API.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li>  
     425    <li><?php mc_settings_field( 'mc_event_approve', __( 'Enable approval options.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     426    <li><?php mc_settings_field( 'mc_api_enabled', __( 'Enable external API.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>     
    430427    <?php 
    431428    if ( apply_filters( 'mc_caching_clear', false ) ) { ?> 
    432     <li><?php mc_settings_field ( 'mc_clear_cache', __('Clear current cache. (Necessary if you edit shortcodes to change displayed categories, for example.)','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li>  
     429    <li><?php mc_settings_field( 'mc_clear_cache', __( 'Clear current cache. (Necessary if you edit shortcodes to change displayed categories, for example.)','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>     
    433430    <?php } ?> 
    434     <li><?php mc_settings_field ( 'mc_default_sort', __('Default Sort order for Admin Events List','my-calendar'), array( '1'=>__( 'Event ID', 'my-calendar' ), '2'=>__( 'Title', 'my-calendar' ), '3'=>__( 'Description', 'my-calendar' ), '4'=>__( 'Start Date', 'my-calendar' ), '5'=>__( 'Author', 'my-calendar' ), '6'=>__( 'Category', 'my-calendar' ), '7'=>__( 'Location Name', 'my-calendar' ) ), '', array(), 'select' ); ?></li> 
     431    <li><?php mc_settings_field( 'mc_default_sort', __( 'Default Sort order for Admin Events List','my-calendar' ), array( '1'=>__( 'Event ID', 'my-calendar' ), '2'=>__( 'Title', 'my-calendar' ), '3'=>__( 'Description', 'my-calendar' ), '4'=>__( 'Start Date', 'my-calendar' ), '5'=>__( 'Author', 'my-calendar' ), '6'=>__( 'Category', 'my-calendar' ), '7'=>__( 'Location Name', 'my-calendar' ) ), '', array(), 'select' ); ?></li> 
    435432    <?php  
    436433    if ( get_site_option('mc_multisite') == 2 && MY_CALENDAR_TABLE != MY_CALENDAR_GLOBAL_TABLE ) {  
    437         mc_settings_field ( 'mc_current_table', array( '0'=> __('Currently editing my local calendar','my-calendar'), '1'=>__('Currently editing the network calendar','my-calendar') ), '0', '', array(), 'radio' ); 
     434        mc_settings_field( 'mc_current_table', array( '0'=> __( 'Currently editing my local calendar','my-calendar' ), '1'=>__( 'Currently editing the network calendar','my-calendar' ) ), '0', '', array(), 'radio' ); 
    438435    } else { 
    439436        if ( get_option('mc_remote') != 'true' && current_user_can( 'manage_network' ) ) { ?> 
    440             <li><?php _e('You are currently working in the primary site for this network; your local calendar is also the global table.','my-calendar'); ?></li><?php  
     437            <li><?php _e('You are currently working in the primary site for this network; your local calendar is also the global table.','my-calendar' ); ?></li><?php  
    441438        }  
    442439    } ?> 
    443     <li><?php mc_settings_field ( 'remigrate', __('Re-generate event occurrences table.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     440    <li><?php mc_settings_field( 'remigrate', __( 'Re-generate event occurrences table.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    444441    </ul> 
    445442    </fieldset> 
    446443        <p> 
    447         <input type="submit" name="mc_manage" class="button-primary" value="<?php _e('Save Management Settings','my-calendar'); ?>" /> 
     444        <input type="submit" name="mc_manage" class="button-primary" value="<?php _e('Save Management Settings','my-calendar' ); ?>" /> 
    448445        </p> 
    449446    </form> 
    450447    <?php } else { ?> 
    451         <?php _e('My Calendar management settings are only available to administrators.','my-calendar'); ?> 
     448        <?php _e('My Calendar management settings are only available to administrators.','my-calendar' ); ?> 
    452449    <?php } ?> 
    453450    </div> 
     
    457454<div class="ui-sortable meta-box-sortables">    
    458455<div class="postbox" id="my-calendar-text"> 
    459     <h3><?php _e('Text Settings','my-calendar'); ?></h3> 
     456    <h3><?php _e('Text Settings','my-calendar' ); ?></h3> 
    460457    <div class="inside"> 
    461458        <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
    462459    <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div>       
    463460<fieldset> 
    464     <legend><?php _e('Customize Text Fields','my-calendar'); ?></legend> 
     461    <legend><?php _e('Customize Text Fields','my-calendar' ); ?></legend> 
    465462    <ul> 
    466     <li><?php mc_settings_field ( 'mc_notime_text', __( 'Label for all-day events','my-calendar' ), 'N/A' ); ?></li> 
    467     <li><?php mc_settings_field ( 'mc_previous_events', __( 'Previous events link','my-calendar' ), __('Previous Events','my-calendar'), __('Use <code>{date}</code> to display date in navigation.','my-calendar') ); ?></li> 
    468     <li><?php mc_settings_field ( 'mc_next_events', __( 'Next events link','my-calendar' ), __( 'Next Events', 'my-calendar' ), __('Use <code>{date}</code> to display date in navigation.','my-calendar') ); ?></li> 
    469     <li><?php mc_settings_field ( 'mc_event_open', __('If events are open','my-calendar'), __('Registration is open','my-calendar') ); ?></li> 
    470     <li><?php mc_settings_field ( 'mc_event_closed', __('If events are closed','my-calendar'), __('Registration is closed','my-calendar') ); ?></li>     
    471     <li><?php mc_settings_field ( 'mc_week_caption', __('Week view caption:','my-calendar'), '', __( 'Available tag: <code>{date format=""}</code>','my-calendar' ) ); ?></li> 
    472     <li><?php mc_settings_field ( 'my_calendar_caption', __('Extended caption:','my-calendar'), '', __( 'Follows month/year in list views.','my-calendar' ) ); ?></li> 
    473     <li><?php mc_settings_field ( 'mc_title_template', __('Event title template','my-calendar'), $mc_title_template, "<a href='".admin_url("admin.php?page=my-calendar-help#templates")."'>".__( "Templating Help",'my-calendar' ).'</a>' ); ?></li> 
    474     <li><?php mc_settings_field ( 'mc_details_label', __('Event details link text','my-calendar'), $mc_details_label, __('Tags: <code>{title}</code>, <code>{location}</code>, <code>{color}</code>, <code>{icon}</code>, <code>{date}</code>, <code>{time}</code>.','my-calendar') ); ?></li> 
    475     <li><?php mc_settings_field ( 'mc_link_label', __('Event URL link text','my-calendar'), $mc_link_label, "<a href='".admin_url("admin.php?page=my-calendar-help#templates")."'>".__( "Templating Help",'my-calendar' ).'</a>' ); ?></li> 
    476     <li><?php mc_settings_field ( 'mc_event_title_template', __('Title element template','my-calendar'), '{title} &raquo; {date}', __('Current: %s', 'my-calendar' ) ); ?></li>      
     463    <li><?php mc_settings_field( 'mc_notime_text', __( 'Label for all-day events','my-calendar' ), 'N/A' ); ?></li> 
     464    <li><?php mc_settings_field( 'mc_previous_events', __( 'Previous events link','my-calendar' ), __( 'Previous Events','my-calendar' ), __( 'Use <code>{date}</code> to display date in navigation.','my-calendar' ) ); ?></li> 
     465    <li><?php mc_settings_field( 'mc_next_events', __( 'Next events link','my-calendar' ), __( 'Next Events', 'my-calendar' ), __( 'Use <code>{date}</code> to display date in navigation.','my-calendar' ) ); ?></li> 
     466    <li><?php mc_settings_field( 'mc_event_open', __( 'If events are open','my-calendar' ), __( 'Registration is open','my-calendar' ) ); ?></li> 
     467    <li><?php mc_settings_field( 'mc_event_closed', __( 'If events are closed','my-calendar' ), __( 'Registration is closed','my-calendar' ) ); ?></li>  
     468    <li><?php mc_settings_field( 'mc_week_caption', __( 'Week view caption:','my-calendar' ), '', __( 'Available tag: <code>{date format=""}</code>','my-calendar' ) ); ?></li> 
     469    <li><?php mc_settings_field( 'my_calendar_caption', __( 'Extended caption:','my-calendar' ), '', __( 'Follows month/year in list views.','my-calendar' ) ); ?></li> 
     470    <li><?php mc_settings_field( 'mc_title_template', __( 'Event title template','my-calendar' ), $mc_title_template, "<a href='".admin_url("admin.php?page=my-calendar-help#templates")."'>".__( "Templating Help",'my-calendar' ).'</a>' ); ?></li> 
     471    <li><?php mc_settings_field( 'mc_details_label', __( 'Event details link text','my-calendar' ), $mc_details_label, __( 'Tags: <code>{title}</code>, <code>{location}</code>, <code>{color}</code>, <code>{icon}</code>, <code>{date}</code>, <code>{time}</code>.','my-calendar' ) ); ?></li> 
     472    <li><?php mc_settings_field( 'mc_link_label', __( 'Event URL link text','my-calendar' ), $mc_link_label, "<a href='".admin_url("admin.php?page=my-calendar-help#templates")."'>".__( "Templating Help",'my-calendar' ).'</a>' ); ?></li> 
     473    <li><?php mc_settings_field( 'mc_event_title_template', __( 'Title element template','my-calendar' ), '{title} &raquo; {date}', __( 'Current: %s', 'my-calendar' ) ); ?></li>        
    477474    </ul> 
    478475    </fieldset>  
    479476        <p> 
    480         <input type="submit" name="save" class="button-primary" value="<?php _e('Save Custom Text Settings','my-calendar'); ?>" /> 
     477        <input type="submit" name="save" class="button-primary" value="<?php _e('Save Custom Text Settings','my-calendar' ); ?>" /> 
    481478    </p> 
    482479    </form> 
     
    487484<div class="ui-sortable meta-box-sortables">    
    488485<div class="postbox" id="my-calendar-output"> 
    489     <h3><?php _e('Output Settings','my-calendar'); ?></h3> 
     486    <h3><?php _e('Output Settings','my-calendar' ); ?></h3> 
    490487    <div class="inside"> 
    491488    <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
    492489    <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div> 
    493490    <fieldset> 
    494     <legend><?php _e('Calendar Link Targets','my-calendar'); ?></legend> 
     491    <legend><?php _e('Calendar Link Targets','my-calendar' ); ?></legend> 
    495492    <ul> 
    496493    <?php $guess = mc_guess_calendar(); ?> 
    497     <li><?php mc_settings_field ( 'mc_uri', __('Where is your main calendar page?','my-calendar'), '', "<br /><small>".__('Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.','my-calendar')."$guess</small>", array( 'size'=>'60' ), 'url' ); ?></li> 
    498     <li><?php mc_settings_field ( 'mc_mini_uri', __('Target <abbr title="Uniform resource locator">URL</abbr> for mini calendar date links:','my-calendar'), '', "<br /><small>".__('Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.','my-calendar')."</small>", array( 'size'=>'60' ), 'url' ); ?></li> 
    499     <li><?php mc_settings_field ( 'mc_open_uri', __('Open calendar links to event details URL','my-calendar'), '', "<br /><small>".__('Replaces pop-up in grid view.','my-calendar')."</small>", array(), 'checkbox-single' ); ?></li> 
     494    <li><?php mc_settings_field( 'mc_uri', __( 'Where is your main calendar page?','my-calendar' ), '', "<br /><small>".__( 'Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.','my-calendar' )."$guess</small>", array( 'size'=>'60' ), 'url' ); ?></li> 
     495    <li><?php mc_settings_field( 'mc_mini_uri', __( 'Target <abbr title="Uniform resource locator">URL</abbr> for mini calendar date links:','my-calendar' ), '', "<br /><small>".__( 'Can be any Page or Post which includes the <code>[my_calendar]</code> shortcode.','my-calendar' )."</small>", array( 'size'=>'60' ), 'url' ); ?></li> 
     496    <li><?php mc_settings_field( 'mc_open_uri', __( 'Open calendar links to event details URL','my-calendar' ), '', "<br /><small>".__( 'Replaces pop-up in grid view.','my-calendar' )."</small>", array(), 'checkbox-single' ); ?></li> 
    500497    <?php  
    501498        $disabled = ( !get_option( 'mc_uri' ) && !get_option( 'mc_mini_uri' ) ) ? array( 'disabled'=>'disabled' ) : array(); 
    502499    ?> 
    503     <li><?php mc_settings_field ( 'mc_open_day_uri', __('Mini calendar widget date links to:','my-calendar'), array( 'false'=>__( 'jQuery pop-up view', 'my-calendar' ), 'true'=>__( 'daily view page (above)', 'my-calendar' ), 'listanchor'=>__( 'in-page anchor on main calendar page (list)', 'my-calendar' ), 'calendaranchor'=>__( 'in-page anchor on main calendar page (grid)', 'my-calendar' ) ), "<br /><small>".__('Replaces pop-up in mini calendar.','my-calendar')."</small>", $disabled, 'select' ); ?></li> 
     500    <li><?php mc_settings_field( 'mc_open_day_uri', __( 'Mini calendar widget date links to:','my-calendar' ), array( 'false'=>__( 'jQuery pop-up view', 'my-calendar' ), 'true'=>__( 'daily view page (above)', 'my-calendar' ), 'listanchor'=>__( 'in-page anchor on main calendar page (list)', 'my-calendar' ), 'calendaranchor'=>__( 'in-page anchor on main calendar page (grid)', 'my-calendar' ) ), "<br /><small>".__( 'Replaces pop-up in mini calendar.','my-calendar' )."</small>", $disabled, 'select' ); ?></li> 
    504501    </ul> 
    505502    <?php // End General Options // ?> 
     
    507504     
    508505    <fieldset>  
    509     <legend><?php _e('Set Default Navigation Element Order (can be overridden in shortcodes)','my-calendar'); ?></legend> 
     506    <legend><?php _e('Set Default Navigation Element Order (can be overridden in shortcodes)','my-calendar' ); ?></legend> 
    510507    <?php 
    511508        $topnav = explode( ',', get_option( 'mc_topnav' ) ); 
     
    544541     
    545542    <fieldset> 
    546     <legend><?php _e('Grid Layout Options','my-calendar'); ?></legend> 
     543    <legend><?php _e('Grid Layout Options','my-calendar' ); ?></legend> 
    547544    <ul> 
    548     <li><?php mc_settings_field ( 'mc_show_weekends', __('Show Weekends on Calendar','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    549     <li><?php mc_settings_field ( 'mc_convert', __('Switch to list view on mobile devices','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li>     
     545    <li><?php mc_settings_field( 'mc_show_weekends', __( 'Show Weekends on Calendar','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     546    <li><?php mc_settings_field( 'mc_convert', __( 'Switch to list view on mobile devices','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>    
    550547    </ul>    
    551548    <?php // End Grid Options // ?> 
     
    553550     
    554551    <fieldset> 
    555     <legend><?php _e('List Layout Options','my-calendar'); ?></legend> 
     552    <legend><?php _e('List Layout Options','my-calendar' ); ?></legend> 
    556553    <ul> 
    557     <li><?php mc_settings_field ( 'mc_show_months', __('How many months of events to show at a time:','my-calendar'), '', '', array( 'size'=>'3' ), 'text' ); ?></li> 
    558     <li><?php mc_settings_field ( 'mc_show_list_info', __('Show the first event\'s title and the number of events that day next to the date.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li>  
     554    <li><?php mc_settings_field( 'mc_show_months', __( 'How many months of events to show at a time:','my-calendar' ), '', '', array( 'size'=>'3' ), 'text' ); ?></li> 
     555    <li><?php mc_settings_field( 'mc_show_list_info', __( 'Show the first event\'s title and the number of events that day next to the date.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>     
    559556    </ul>    
    560557    <?php // End List Options // ?> 
     
    562559 
    563560    <fieldset> 
    564     <legend><?php _e('Event Details Pop-up','my-calendar'); ?></legend> 
    565         <p><?php _e('The checked items will be shown in your event details view. Does not apply if you are using a custom template','my-calendar'); ?> 
     561    <legend><?php _e('Event Details Pop-up','my-calendar' ); ?></legend> 
     562        <p><?php _e('The checked items will be shown in your event details view. Does not apply if you are using a custom template','my-calendar' ); ?> 
    566563        <ul class="checkboxes"> 
    567             <li><?php mc_settings_field ( 'mc_display_author', __('Author\'s name','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    568             <li><?php mc_settings_field ( 'mc_show_event_vcal', __('Link to single event iCal download','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    569             <li><?php mc_settings_field ( 'mc_show_gcal', __('Link to submit event to Google Calendar','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li>         
    570             <li><?php mc_settings_field ( 'mc_hide_icons', __('Hide Category icons','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    571             <li><?php mc_settings_field ( 'mc_show_map', __('Link to Google Map','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    572             <li><?php mc_settings_field ( 'mc_show_address', __('Event Address','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    573             <li><?php mc_settings_field ( 'mc_short', __('Short description','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    574             <li><?php mc_settings_field ( 'mc_desc', __('Full description','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    575             <li><?php mc_settings_field ( 'mc_process_shortcodes', __('Process WordPress shortcodes in descriptions','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li>   
    576             <li><?php mc_settings_field ( 'mc_details', __('Link to event details (requires <a href=\'#mc_uri\'>URL</a>)','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    577             <li><?php mc_settings_field ( 'mc_event_link', __('External link','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    578             <li><?php mc_settings_field ( 'mc_event_registration', __('Registration info','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     564            <li><?php mc_settings_field( 'mc_display_author', __( 'Author\'s name','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     565            <li><?php mc_settings_field( 'mc_show_event_vcal', __( 'Link to single event iCal download','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     566            <li><?php mc_settings_field( 'mc_show_gcal', __( 'Link to submit event to Google Calendar','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>        
     567            <li><?php mc_settings_field( 'mc_hide_icons', __( 'Hide Category icons','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     568            <li><?php mc_settings_field( 'mc_show_map', __( 'Link to Google Map','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     569            <li><?php mc_settings_field( 'mc_show_address', __( 'Event Address','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     570            <li><?php mc_settings_field( 'mc_short', __( 'Short description','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     571            <li><?php mc_settings_field( 'mc_desc', __( 'Full description','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     572            <li><?php mc_settings_field( 'mc_process_shortcodes', __( 'Process WordPress shortcodes in descriptions','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>  
     573            <li><?php mc_settings_field( 'mc_details', __( 'Link to event details (requires <a href=\'#mc_uri\'>URL</a>)','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     574            <li><?php mc_settings_field( 'mc_event_link', __( 'External link','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     575            <li><?php mc_settings_field( 'mc_event_registration', __( 'Registration info','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    579576        </ul> 
    580577    </fieldset> 
    581578    <fieldset> 
    582     <legend><?php _e('Event Category Display','my-calendar'); ?></legend> 
     579    <legend><?php _e('Event Category Display','my-calendar' ); ?></legend> 
    583580        <ul class='checkboxes'> 
    584             <?php mc_settings_field ( 'mc_apply_color', array( 'default'=> __('No category colors with titles.','my-calendar'), 'font'=>__('Titles are in category colors.','my-calendar'), 'background'=>__('Titles have category color as background.','my-calendar') ), 'default', '', array(), 'radio' ); ?> 
    585             <li><?php mc_settings_field ( 'mc_inverse_color', __('Optimize contrast for category colors.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     581            <?php mc_settings_field( 'mc_apply_color', array( 'default'=> __( 'No category colors with titles.','my-calendar' ), 'font'=>__( 'Titles are in category colors.','my-calendar' ), 'background'=>__( 'Titles have category color as background.','my-calendar' ) ), 'default', '', array(), 'radio' ); ?> 
     582            <li><?php mc_settings_field( 'mc_inverse_color', __( 'Optimize contrast for category colors.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    586583        </ul>    
    587584    <?php // End Event Options // ?> 
    588585    </fieldset> 
    589586    <fieldset> 
    590     <legend><?php _e('Event Scheduling Defaults','my-calendar'); ?></legend> 
     587    <legend><?php _e('Event Scheduling Defaults','my-calendar' ); ?></legend> 
    591588        <ul> 
    592             <li><?php mc_settings_field ( 'mc_event_link_expires', __('Event links expire after event passes.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li>     
    593             <li><?php mc_settings_field ( 'mc_no_fifth_week', __('If a recurring event falls on a date that doesn\'t exist (like the 5th Wednesday in February), move it back one week.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     589            <li><?php mc_settings_field( 'mc_event_link_expires', __( 'Event links expire after event passes.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>    
     590            <li><?php mc_settings_field( 'mc_no_fifth_week', __( 'If a recurring event falls on a date that doesn\'t exist (like the 5th Wednesday in February), move it back one week.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    594591            <li> 
    595             <label for="mc_shc"><?php _e('Holiday Category','my-calendar'); ?></label> 
     592            <label for="mc_shc"><?php _e( 'Holiday Category','my-calendar' ); ?></label> 
    596593            <select id="mc_shc" name="mc_skip_holidays_category"> 
    597             <option value=''> -- <?php _e('None','my-calendar'); ?> -- </option> 
     594            <option value=''> -- <?php _e( 'None','my-calendar' ); ?> -- </option> 
    598595            <?php 
    599596            // Grab all the categories and list them 
     
    610607            </select> 
    611608            </li> 
    612             <li><?php mc_settings_field ( 'mc_skip_holidays', __('If an event coincides with an event in the designated "Holiday" category, do not show the event.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     609            <li><?php mc_settings_field( 'mc_skip_holidays', __( 'If an event coincides with an event in the designated "Holiday" category, do not show the event.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    613610        </ul>    
    614611    <?php // End Scheduling Options // ?> 
    615612    </fieldset> 
    616     <p><input type="submit" name="save" class="button-primary" value="<?php _e('Save Output Settings','my-calendar'); ?>" /></p> 
     613    <p><input type="submit" name="save" class="button-primary" value="<?php _e('Save Output Settings','my-calendar' ); ?>" /></p> 
    617614</form> 
    618615</div> 
     
    622619<div class="ui-sortable meta-box-sortables"> 
    623620<div class="postbox" id="my-calendar-time"> 
    624     <h3><?php _e('Calendar Time Formats','my-calendar'); ?></h3> 
     621    <h3><?php _e('Calendar Time Formats','my-calendar' ); ?></h3> 
    625622    <div class="inside"> 
    626623    <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
    627624    <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div> 
    628625    <fieldset> 
    629     <legend><?php _e('Set default date/time formats','my-calendar'); ?></legend> 
     626    <legend><?php _e('Set default date/time formats','my-calendar' ); ?></legend> 
    630627    <div><input type='hidden' name='mc_dates' value='true' /></div> 
    631628    <ul>     
     
    636633        $date_format = ( get_option('mc_date_format') == '' ) ? date_i18n( get_option( 'date_format' ) ) : date_i18n( get_option('mc_date_format') ); 
    637634    ?> 
    638     <li><?php mc_settings_field ( 'mc_month_format', __('Month format (calendar headings)','my-calendar'), '', $month_format ); ?></li> 
    639     <li><?php mc_settings_field ( 'mc_time_format', __('Time format','my-calendar'), '', $time_format ); ?></li> 
    640     <li><?php mc_settings_field ( 'mc_week_format', __('Date in grid mode, week view','my-calendar'), '', $week_format ); ?></li> 
    641     <li><?php mc_settings_field ( 'mc_date_format', __('Date Format in other views','my-calendar'), '', $date_format ); ?></li> 
     635    <li><?php mc_settings_field( 'mc_month_format', __( 'Month format (calendar headings)','my-calendar' ), '', $month_format ); ?></li> 
     636    <li><?php mc_settings_field( 'mc_time_format', __( 'Time format','my-calendar' ), '', $time_format ); ?></li> 
     637    <li><?php mc_settings_field( 'mc_week_format', __( 'Date in grid mode, week view','my-calendar' ), '', $week_format ); ?></li> 
     638    <li><?php mc_settings_field( 'mc_date_format', __( 'Date Format in other views','my-calendar' ), '', $date_format ); ?></li> 
    642639    <li> 
    643     <?php _e('Date formats use syntax from the <a href="http://php.net/date">PHP <code>date()</code> function</a>. Save to update sample output.','my-calendar'); ?> 
     640    <?php _e('Date formats use syntax from the <a href="http://php.net/date">PHP <code>date()</code> function</a>. Save to update sample output.','my-calendar' ); ?> 
    644641    </li> 
    645     <li><?php mc_settings_field ( 'mc_ical_utc', __('iCal times are UTC','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     642    <li><?php mc_settings_field( 'mc_ical_utc', __( 'iCal times are UTC','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    646643    </ul> 
    647644    </fieldset> 
    648645        <p> 
    649         <input type="submit" name="save" class="button-primary" value="<?php _e('Save Date/Time Settings','my-calendar'); ?>" /> 
     646        <input type="submit" name="save" class="button-primary" value="<?php _e('Save Date/Time Settings','my-calendar' ); ?>" /> 
    650647        </p> 
    651648    </form>  
     
    657654<div class="ui-sortable meta-box-sortables">    
    658655<div class="postbox" id="my-calendar-input"> 
    659     <h3><?php _e('Calendar Input Settings','my-calendar'); ?></h3> 
     656    <h3><?php _e('Calendar Input Settings','my-calendar' ); ?></h3> 
    660657    <div class="inside"> 
    661658<form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
    662659    <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div> 
    663660    <fieldset> 
    664     <legend><?php _e('Select which input fields will be available when adding or editing events.','my-calendar'); ?></legend> 
     661    <legend><?php _e('Select which input fields will be available when adding or editing events.','my-calendar' ); ?></legend> 
    665662    <div><input type='hidden' name='mc_input' value='true' /></div> 
    666663    <ul class="checkboxes"> 
    667664    <?php  
    668665        $input_options = get_option('mc_input_options'); 
    669         $input_labels = array('event_location_dropdown'=>__('Event Location Dropdown Menu','my-calendar'),'event_short'=>__('Event Short Description field','my-calendar'),'event_desc'=>__('Event Description Field','my-calendar'),'event_category'=>__('Event Category field','my-calendar'),'event_image'=>__('Event Image field','my-calendar'),'event_link'=>__('Event Link field','my-calendar'),'event_recurs'=>__('Event Recurrence Options','my-calendar'),'event_open'=>__('Event Registration options','my-calendar'),'event_location'=>__('Event Location fields','my-calendar'),'event_use_editor'=>__('Use HTML Editor in Event Description Field','my-calendar'),'event_specials'=>__('Set Special Scheduling options','my-calendar'), 'event_access'=>__("Event Accessibility", 'my-calendar' ) ); 
     666        $input_labels = array('event_location_dropdown'=>__( 'Event Location Dropdown Menu','my-calendar' ),'event_short'=>__( 'Event Short Description field','my-calendar' ),'event_desc'=>__( 'Event Description Field','my-calendar' ),'event_category'=>__( 'Event Category field','my-calendar' ),'event_image'=>__( 'Event Image field','my-calendar' ),'event_link'=>__( 'Event Link field','my-calendar' ),'event_recurs'=>__( 'Event Recurrence Options','my-calendar' ),'event_open'=>__( 'Event Registration options','my-calendar' ),'event_location'=>__( 'Event Location fields','my-calendar' ),'event_use_editor'=>__( 'Use HTML Editor in Event Description Field','my-calendar' ),'event_specials'=>__( 'Set Special Scheduling options','my-calendar' ), 'event_access'=>__("Event Accessibility", 'my-calendar' ) ); 
    670667        $output = ''; 
    671668        // if input options isn't an array, we'll assume that this plugin wasn't upgraded properly, and reset them to the default. 
     
    679676        echo $output; 
    680677    ?> 
    681     <li><?php mc_settings_field ( 'mc_input_options_administrators', __('Administrators see all input options','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     678    <li><?php mc_settings_field( 'mc_input_options_administrators', __( 'Administrators see all input options','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    682679    </ul> 
    683680    </fieldset> 
    684681        <p> 
    685         <input type="submit" name="save" class="button-primary" value="<?php _e('Save Input Settings','my-calendar'); ?>" /> 
     682        <input type="submit" name="save" class="button-primary" value="<?php _e('Save Input Settings','my-calendar' ); ?>" /> 
    686683        </p> 
    687684</form> 
     
    693690<div class="ui-sortable meta-box-sortables">    
    694691<div class="postbox" id="my-calendar-multisite"> 
    695     <h3><?php _e('Multisite Settings (Network Administrators only)','my-calendar'); ?></h3> 
     692    <h3><?php _e('Multisite Settings (Network Administrators only)','my-calendar' ); ?></h3> 
    696693    <div class="inside"> 
    697694    <form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
     
    699696    <div><input type='hidden' name='mc_network' value='true' /></div>    
    700697    <fieldset> 
    701     <legend><?php _e('WP MultiSite configurations','my-calendar'); ?></legend> 
    702     <p><?php _e('The central calendar is the calendar associated with the primary site in your WordPress Multisite network.','my-calendar'); ?></p>  
     698    <legend><?php _e('WP MultiSite configurations','my-calendar' ); ?></legend> 
     699    <p><?php _e('The central calendar is the calendar associated with the primary site in your WordPress Multisite network.','my-calendar' ); ?></p>     
    703700    <ul> 
    704     <li><input type="radio" value="0" id="ms0" name="mc_multisite"<?php echo jd_option_selected( get_site_option('mc_multisite'),'0' ); ?> /> <label for="ms0"><?php _e('Site owners may only post to their local calendar','my-calendar'); ?></label></li> 
    705     <li><input type="radio" value="1" id="ms1" name="mc_multisite"<?php echo jd_option_selected( get_site_option('mc_multisite'),'1' ); ?> /> <label for="ms1"><?php _e('Site owners may only post to the central calendar','my-calendar'); ?></label></li> 
    706     <li><input type="radio" value="2" id="ms2" name="mc_multisite"<?php echo jd_option_selected( get_site_option('mc_multisite'),2 ); ?> /> <label for="ms2"><?php _e('Site owners may manage either calendar','my-calendar'); ?></label></li> 
     701    <li><input type="radio" value="0" id="ms0" name="mc_multisite"<?php echo jd_option_selected( get_site_option('mc_multisite'),'0' ); ?> /> <label for="ms0"><?php _e('Site owners may only post to their local calendar','my-calendar' ); ?></label></li> 
     702    <li><input type="radio" value="1" id="ms1" name="mc_multisite"<?php echo jd_option_selected( get_site_option('mc_multisite'),'1' ); ?> /> <label for="ms1"><?php _e('Site owners may only post to the central calendar','my-calendar' ); ?></label></li> 
     703    <li><input type="radio" value="2" id="ms2" name="mc_multisite"<?php echo jd_option_selected( get_site_option('mc_multisite'),2 ); ?> /> <label for="ms2"><?php _e('Site owners may manage either calendar','my-calendar' ); ?></label></li> 
    707704    </ul> 
    708705    <p class="notice"><strong>*</strong> <?php _e('Changes only effect input permissions. Public-facing calendars will be unchanged.','my-calendar' ); ?></p> 
    709706    <ul> 
    710     <li><input type="radio" value="0" id="mss0" name="mc_multisite_show"<?php echo jd_option_selected( get_site_option('mc_multisite_show'),'0' ); ?> /> <label for="mss0"><?php _e('Sub-site calendars show events from their local calendar.','my-calendar'); ?></label></li> 
    711     <li><input type="radio" value="1" id="mss1" name="mc_multisite_show"<?php echo jd_option_selected( get_site_option('mc_multisite_show'),'1' ); ?> /> <label for="mss1"><?php _e('Sub-site calendars show events from the central calendar.','my-calendar'); ?></label></li> 
     707    <li><input type="radio" value="0" id="mss0" name="mc_multisite_show"<?php echo jd_option_selected( get_site_option('mc_multisite_show'),'0' ); ?> /> <label for="mss0"><?php _e('Sub-site calendars show events from their local calendar.','my-calendar' ); ?></label></li> 
     708    <li><input type="radio" value="1" id="mss1" name="mc_multisite_show"<?php echo jd_option_selected( get_site_option('mc_multisite_show'),'1' ); ?> /> <label for="mss1"><?php _e('Sub-site calendars show events from the central calendar.','my-calendar' ); ?></label></li> 
    712709    </ul> 
    713710    </fieldset> 
    714711        <p> 
    715         <input type="submit" name="save" class="button-primary" value="<?php _e('Save Multisite Settings','my-calendar'); ?>" /> 
     712        <input type="submit" name="save" class="button-primary" value="<?php _e('Save Multisite Settings','my-calendar' ); ?>" /> 
    716713        </p> 
    717714</form>  
     
    723720<div class="ui-sortable meta-box-sortables">    
    724721<div class="postbox" id="my-calendar-permissions"> 
    725     <h3><?php _e('My Calendar Permissions','my-calendar'); ?></h3> 
     722    <h3><?php _e('My Calendar Permissions','my-calendar' ); ?></h3> 
    726723    <div class="inside mc-tabs">     
    727724    <?php if ( current_user_can('administrator') ) { ?> 
     
    740737        $roles = $wp_roles->get_names(); 
    741738        $caps = array(  
    742                     'mc_add_events'=>__('Add Events','my-calendar'), 
    743                     'mc_approve_events'=>__('Approve Events','my-calendar'), 
    744                     'mc_manage_events'=>__('Manage Events','my-calendar'), 
    745                     'mc_edit_cats'=>__('Edit Categories','my-calendar'), 
    746                     'mc_edit_locations'=>__('Edit Locations','my-calendar'), 
    747                     'mc_edit_styles'=>__('Edit Styles','my-calendar'), 
    748                     'mc_edit_behaviors'=>__('Edit Behaviors','my-calendar'), 
    749                     'mc_edit_templates'=>__('Edit Templates','my-calendar'), 
    750                     'mc_edit_settings'=>__('Edit Settings','my-calendar'), 
    751                     'mc_view_help'=>__('View Help','my-calendar') 
     739                    'mc_add_events'=>__( 'Add Events','my-calendar' ), 
     740                    'mc_approve_events'=>__( 'Approve Events','my-calendar' ), 
     741                    'mc_manage_events'=>__( 'Manage Events','my-calendar' ), 
     742                    'mc_edit_cats'=>__( 'Edit Categories','my-calendar' ), 
     743                    'mc_edit_locations'=>__( 'Edit Locations','my-calendar' ), 
     744                    'mc_edit_styles'=>__( 'Edit Styles','my-calendar' ), 
     745                    'mc_edit_behaviors'=>__( 'Edit Behaviors','my-calendar' ), 
     746                    'mc_edit_templates'=>__( 'Edit Templates','my-calendar' ), 
     747                    'mc_edit_settings'=>__( 'Edit Settings','my-calendar' ), 
     748                    'mc_view_help'=>__( 'View Help','my-calendar' ) 
    752749                    ); 
    753750        $role_tabs = $role_container = ''; 
     
    772769    ?>   
    773770        <p> 
    774         <input type="submit" name="mc_permissions" class="button-primary" value="<?php _e('Save Permissions','my-calendar'); ?>" /> 
     771        <input type="submit" name="mc_permissions" class="button-primary" value="<?php _e('Save Permissions','my-calendar' ); ?>" /> 
    775772        </p> 
    776773    </form> 
    777774    <?php } else { ?> 
    778         <?php _e('My Calendar permission settings are only available to administrators.','my-calendar'); ?> 
     775        <?php _e('My Calendar permission settings are only available to administrators.','my-calendar' ); ?> 
    779776    <?php } ?>   
    780777    </div> 
     
    784781<div class="ui-sortable meta-box-sortables">    
    785782<div class="postbox" id="my-calendar-email"> 
    786     <h3><?php _e('Calendar Email Settings','my-calendar'); ?></h3> 
     783    <h3><?php _e('Calendar Email Settings','my-calendar' ); ?></h3> 
    787784    <div class="inside"> 
    788785<form method="post" action="<?php echo admin_url("admin.php?page=my-calendar-config"); ?>"> 
    789786    <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('my-calendar-nonce'); ?>" /></div> 
    790787    <fieldset> 
    791     <legend><?php _e('Email Notifications','my-calendar'); ?></legend> 
     788    <legend><?php _e('Email Notifications','my-calendar' ); ?></legend> 
    792789    <div><input type='hidden' name='mc_email' value='true' /></div> 
    793790    <ul> 
    794     <li><?php mc_settings_field ( 'mc_event_mail', __('Send Email Notifications when new events are scheduled or reserved.','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
    795     <li><?php mc_settings_field ( 'mc_event_mail_to', __('Notification messages are sent to:','my-calendar'), get_bloginfo( 'admin_email' ) ); ?></li>   
    796     <li><?php mc_settings_field ( 'mc_event_mail_from', __('Notification messages are sent from:','my-calendar'), get_bloginfo( 'admin_email' ) ); ?></li> 
    797     <li><?php mc_settings_field ( 'mc_event_mail_subject', __('Email subject','my-calendar'), get_bloginfo( 'name' ).': '.__( 'New event added', 'my-calendar' ), '', array( 'size'=>60 ) ); ?></li> 
    798     <li><?php mc_settings_field ( 'mc_event_mail_message', __('Message Body','my-calendar'), __( 'New Event:','my-calendar' )."\n{title}: {date}, {time} - {event_status}", "<br /><a href='".admin_url("admin.php?page=my-calendar-help#templates")."'>".__( "Templating Help",'my-calendar' ).'</a>', array( 'cols'=>60, 'rows'=>6 ), 'textarea' ); ?></li> 
    799     <li><?php mc_settings_field ( 'mc_html_email', __('Send HTML email','my-calendar'), '', '', array(), 'checkbox-single' ); ?></li> 
     791    <li><?php mc_settings_field( 'mc_event_mail', __( 'Send Email Notifications when new events are scheduled or reserved.','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
     792    <li><?php mc_settings_field( 'mc_event_mail_to', __( 'Notification messages are sent to:','my-calendar' ), get_bloginfo( 'admin_email' ) ); ?></li>  
     793    <li><?php mc_settings_field( 'mc_event_mail_from', __( 'Notification messages are sent from:','my-calendar' ), get_bloginfo( 'admin_email' ) ); ?></li> 
     794    <li><?php mc_settings_field( 'mc_event_mail_subject', __( 'Email subject','my-calendar' ), get_bloginfo( 'name' ).': '.__( 'New event added', 'my-calendar' ), '', array( 'size'=>60 ) ); ?></li> 
     795    <li><?php mc_settings_field( 'mc_event_mail_message', __( 'Message Body','my-calendar' ), __( 'New Event:','my-calendar' )."\n{title}: {date}, {time} - {event_status}", "<br /><a href='".admin_url("admin.php?page=my-calendar-help#templates")."'>".__( "Templating Help",'my-calendar' ).'</a>', array( 'cols'=>60, 'rows'=>6 ), 'textarea' ); ?></li> 
     796    <li><?php mc_settings_field( 'mc_html_email', __( 'Send HTML email','my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li> 
    800797    </ul> 
    801798    </fieldset> 
    802799        <p> 
    803         <input type="submit" name="save" class="button-primary" value="<?php _e('Save Email Settings','my-calendar'); ?>" /> 
     800        <input type="submit" name="save" class="button-primary" value="<?php _e('Save Email Settings','my-calendar' ); ?>" /> 
    804801        </p> 
    805802</form> 
     
    813810</div> 
    814811 
    815     <?php jd_show_support_box(); ?> 
     812    <?php mc_show_sidebar(); ?> 
    816813 
    817814</div> 
  • my-calendar/trunk/my-calendar-styles.php

    r866550 r868877  
    234234    </div> 
    235235    </div> 
    236     <?php jd_show_support_box(); ?> 
     236    <?php mc_show_sidebar(); ?> 
    237237    </div><?php 
    238238} 
  • my-calendar/trunk/my-calendar-templates.php

    r866550 r868877  
    22if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 
    33 
    4 function jd_draw_template($array,$template,$type='list') { 
    5     //1st argument: array of details 
    6     //2nd argument: template to print details into 
    7     $template = stripcslashes($template);    
     4// draw array of information into a template with {$key} formatted tags 
     5function jd_draw_template( $array,$template,$type='list' ) { 
     6    $template = stripcslashes( $template );  
    87    foreach ( $array as $key=>$value ) { 
    9         if ( is_object($value) && !empty($value) ) { 
     8        if ( is_object( $value ) && !empty( $value ) ) { 
    109            // null values return false... 
    1110        } else { 
    1211            if ( strpos( $template, "{".$key ) !== false ) { 
    13                 if ($type != 'list') { 
    14                     if ( $key == 'link' && $value == '') { $value = ( get_option('mc_uri') != '' && !is_numeric( get_option('mc_uri') ) )?get_option('mc_uri'):home_url(); } 
    15                     if ( $key != 'guid') { $value = htmlentities($value); } 
     12                if ( $type != 'list') { 
     13                    if ( $key == 'link' && $value == '' ) { $value = ( get_option( 'mc_uri' ) != '' && !is_numeric( get_option( 'mc_uri' ) ) )?get_option( 'mc_uri' ):home_url(); } 
     14                    if ( $key != 'guid') { $value = htmlentities( $value ); } 
    1615                } 
    1716                if ( strpos( $template, "{".$key." " ) !== false ) { // only do preg_match if appropriate 
     
    2120                        $after = @$matches[2][0]; 
    2221                        $format = @$matches[3][0]; 
    23                         if ( $format != '' ) { $value = date_i18n( stripslashes($format),strtotime(stripslashes($value)) ); } 
    24                         $value = ( $value == '' )?'':$before.$value.$after; 
     22                        if ( $format != '' ) {  
     23                            $value = date_i18n( stripslashes( $format ),strtotime( stripslashes( $value ) ) );  
     24                        } 
     25                        $value = ( $value == '' ) ? '' : $before.$value.$after; 
    2526                        $search = @$matches[0][0]; 
    2627                        $template = str_replace( $search, $value, $template ); 
     
    3536                $charset = get_option('blog_charset'); 
    3637                if ( $charset == '' ) { $charset = 'UTF-8'; } 
    37                 //$value = htmlspecialchars( $value, ENT_QUOTES, $charset ); 
    38                 //$value = htmlentities( $value, ENT_XML1, $charset ); 
    39                 //  if ( $key == 'description' ) { echo $value; } 
    4038                $value = ent2ncr($value); // WP native function. 
    4139                $template = stripcslashes(str_replace($rss_search,$value,$template)); 
    4240            }                
    4341        }  
    44     } 
    45 //$new = microtime( true ); 
    46 //$length = $new - $mtime; 
    47 //echo $length . ' seconds<br />'; //DEBUG       
     42    }        
    4843    return stripslashes(trim($template)); 
    4944} 
    5045 
     46// setup string version of address data 
    5147function mc_map_string( $event, $source='event' ) { 
    5248    if ( $source == 'event' ) { 
     
    5854} 
    5955 
     56// set up link to Google Maps 
    6057function mc_maplink( $event, $request='map', $source='event' ) { 
    6158    $map_string = mc_map_string( $event, $source ); 
     
    8784} 
    8885 
     86// set up link to push events into Google Calendar. 
    8987function mc_google_cal( $dtstart, $dtend, $url, $title, $location, $description ) { 
    9088    $source = "https://www.google.com/calendar/render?action=TEMPLATE"; 
     
    9997} 
    10098 
     99// set up hCard formatted address. 
    101100function mc_hcard( $event, $address='true', $map='true', $source='event', $context='event' ) { 
    102101    $the_map = mc_maplink( $event, 'url', $source ); 
    103     $event_url = ($source=='event')?$event->event_url:$event->location_url; 
    104     $event_label = stripslashes( ($source=='event')?$event->event_label:$event->location_label ); 
    105     $event_street = stripslashes( ($source=='event')?$event->event_street:$event->location_street ); 
    106     $event_street2 = stripslashes( ($source=='event')?$event->event_street2:$event->location_street2 ); 
    107     $event_city = stripslashes( ($source=='event')?$event->event_city:$event->location_city ); 
    108     $event_state = stripslashes( ($source=='event')?$event->event_state:$event->location_state ); 
    109     $event_postcode = stripslashes( ($source=='event')?$event->event_postcode:$event->location_postcode ); 
    110     $event_country = stripslashes( ($source=='event')?$event->event_country:$event->location_country ); 
    111     $event_phone = stripslashes( ($source=='event')?$event->event_phone:$event->location_phone ); 
    112      
    113     if ( !$event_url && !$event_label && !$event_street && !$event_street2 && !$event_city && !$event_state && !$event_postcode && !$event_country && !$event_phone ) return; 
    114      
    115     $sitelink_html = "<div class='url link'><a href='$event_url' class='location-link external'>".sprintf(__('Visit web site<span>: %s</span>','my-calendar'),$event_label)."</a></div>"; 
     102    $url = ( $source == 'event' ) ? $event->event_url : $event->location_url; 
     103    $label = stripslashes( ( $source=='event' ) ? $event->event_label : $event->location_label ); 
     104    $street = stripslashes( ( $source=='event' ) ? $event->event_street : $event->location_street ); 
     105    $street2 = stripslashes( ( $source=='event' ) ? $event->event_street2 : $event->location_street2 ); 
     106    $city = stripslashes( ( $source=='event' ) ? $event->event_city : $event->location_city ); 
     107    $state = stripslashes( ( $source=='event' ) ? $event->event_state : $event->location_state ); 
     108    $zip = stripslashes( ( $source=='event' ) ? $event->event_postcode : $event->location_postcode ); 
     109    $country = stripslashes( ( $source=='event' ) ? $event->event_country : $event->location_country ); 
     110    $phone = stripslashes( ( $source=='event' ) ? $event->event_phone : $event->location_phone ); 
     111    if ( !$url && !$label && !$street && !$street2 && !$city && !$state && !$zip && !$country && !$phone ) return; 
     112    $sitelink_html = " 
     113    <div class='url link'> 
     114        <a href='$url' class='location-link external'>".sprintf(__('Visit web site<span>: %s</span>','my-calendar'),$label)."</a> 
     115    </div>"; 
    116116    $hcard = "<div class=\"address vcard\">"; 
    117117    if ( $address == 'true' ) { 
    118118        $hcard .= "<div class=\"adr\">"; 
    119         if ($event_label != "") {$hcard .= "<strong class=\"org\">".$event_label."</strong><br />"; } 
    120         $hcard .= ( $event_street.$event_street2.$event_city.$event_state.$event_postcode.$event_country.$event_phone == '' )?'':"<div class='sub-address'>"; 
    121         if ($event_street != "") {$hcard .= "<div class=\"street-address\">".$event_street."</div>";} 
    122         if ($event_street2 != "") { $hcard .= "<div class=\"street-address\">".$event_street2."</div>"; } 
    123         if ($event_city != "") {$hcard .= "<div><span class=\"locality\">".$event_city."</span><span class='sep'>, </span>";}                        
    124         if ($event_state != "") {$hcard .= "<span class=\"region\">".$event_state."</span> ";} 
    125         if ($event_postcode != "") {$hcard .= " <span class=\"postal-code\">".$event_postcode."</span></div>";}  
    126         if ($event_country != "") { $hcard .= "<div class=\"country-name\">".$event_country."</div>";} 
    127         if ($event_phone != "") { $hcard .= "<div class=\"tel\">".$event_phone."</div>";} 
    128         $hcard .= ( $event_street.$event_street2.$event_city.$event_state.$event_postcode.$event_country.$event_phone == '' )?'':"</div>"; 
     119        if ( $label != "" ) { $hcard .= "<strong class=\"org\">".$label."</strong><br />";  } 
     120        $hcard .= ( $street.$street2.$city.$state.$zip.$country.$phone == '' ) ? '' : "<div class='sub-address'>"; 
     121        if ( $street != "" ) { $hcard .= "<div class=\"street-address\">".$street."</div>"; } 
     122        if ( $street2 != "" ) { $hcard .= "<div class=\"street-address\">".$street2."</div>";   } 
     123        if ( $city != "" ) { $hcard .= "<div><span class=\"locality\">".$city."</span><span class='sep'>, </span>"; } 
     124        if ( $state != "" ) { $hcard .= "<span class=\"region\">".$state."</span> "; } 
     125        if ( $zip != "" ) { $hcard .= " <span class=\"postal-code\">".$zip."</span></div>"; }    
     126        if ( $country != "" ) { $hcard .= "<div class=\"country-name\">".$country."</div>"; } 
     127        if ( $phone != "" ) { $hcard .= "<div class=\"tel\">".$phone."</div>"; } 
     128        $hcard .= ( $street.$street2.$city.$state.$zip.$country.$phone == '' ) ? '' : "</div>"; 
    129129        $hcard .= "</div>"; 
    130130    } 
    131131    if ( $map == 'true' ) { 
    132         $the_map = "<a href='$the_map' class='external'>$event_label</a>"; 
    133         $hcard .= ($the_map!='')?"<div class='url map'>$the_map</div>":''; 
     132        $the_map = "<a href='$the_map' class='external'>$label</a>"; 
     133        $hcard .= ( $the_map!='' ) ? "<div class='url map'>$the_map</div>" : '' ; 
    134134    } 
    135135    if ( $context != 'map' ) { 
    136         $hcard .= ($event_url!='')?$sitelink_html:''; 
     136        $hcard .= ( $url!='' ) ? $sitelink_html : ''; 
    137137    } 
    138138    $hcard .= "</div>";  
     
    141141 
    142142// Produces the array of event details used for drawing templates 
    143 function event_as_array( $event ) { 
    144     $details = array(); 
    145     $details['post'] = $event->event_post; 
     143function mc_create_tags( $event ) { 
     144    $e = array(); 
     145    $e['post'] = $event->event_post; 
    146146    $date_format = ( get_option('mc_date_format') != '' )?get_option('mc_date_format'):get_option('date_format');    
    147     $details = apply_filters( 'mc_insert_author_data', $details, $event ); 
    148     $details = apply_filters( 'mc_filter_image_data', $details, $event ); 
     147    $e = apply_filters( 'mc_insert_author_data', $e, $event ); 
     148    $e = apply_filters( 'mc_filter_image_data', $e, $event ); 
    149149    $map = mc_maplink( $event ); 
    150150    $map_url = mc_maplink( $event, 'url' ); 
    151151    $sitelink_html = "<div class='url link'><a href='$event->event_url' class='location-link external'>".sprintf(__('Visit web site<span>: %s</span>','my-calendar'),$event->event_label)."</a></div>"; 
    152     $details['sitelink_html'] = $sitelink_html; 
    153     $details['sitelink'] = $event->event_url; 
    154     $details['access'] = mc_expand( get_post_meta( $event->event_post, '_mc_event_access', true ), 'mc_event_access' ); 
     152    $e['sitelink_html'] = $sitelink_html; 
     153    $e['sitelink'] = $event->event_url; 
     154    $e['access'] = mc_expand( get_post_meta( $event->event_post, '_mc_event_access', true ) ); 
    155155 
    156156    // date & time fields 
     
    158158    $dtend = mc_format_timestamp( strtotime($event->occur_end) );    
    159159    $real_end_date = $event->occur_end; 
    160     $details['date_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_begin_ts' ) , $event->ts_occur_begin ); 
    161     $details['date_end_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_end_ts' ) , $event->ts_occur_end ); 
    162     $details['time'] = ( date( 'H:i:s', strtotime( $event->occur_begin ) ) == '00:00:00' )?get_option( 'mc_notime_text' ):date(get_option('mc_time_format'), strtotime( $event->occur_begin ) ); 
     160    $e['date_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_begin_ts' ) , $event->ts_occur_begin ); 
     161    $e['date_end_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_end_ts' ) , $event->ts_occur_end ); 
     162    $e['time'] = ( date( 'H:i:s', strtotime( $event->occur_begin ) ) == '00:00:00' )?get_option( 'mc_notime_text' ):date(get_option('mc_time_format'), strtotime( $event->occur_begin ) ); 
    163163    $endtime = ( date( 'H:i:s', strtotime($event->occur_end) ) == '00:00:00')?'23:59:00':date( 'H:i:s',strtotime($event->occur_end) );   
    164     $details['endtime'] = ( $event->occur_end == $event->occur_begin || $event->event_hide_end == 1 )?'':date_i18n( get_option('mc_time_format'),strtotime( $endtime )); 
     164    $e['endtime'] = ( $event->occur_end == $event->occur_begin || $event->event_hide_end == 1 )?'':date_i18n( get_option('mc_time_format'),strtotime( $endtime )); 
    165165    $tz = mc_user_timezone(); 
    166     $details['runtime'] = mc_runtime( $event->ts_occur_begin, $event->ts_occur_end, $event ); 
    167     if ($tz != '') { 
     166    $e['runtime'] = mc_runtime( $event->ts_occur_begin, $event->ts_occur_end, $event ); 
     167    if ( $tz != '') { 
    168168        $local_begin = date_i18n( get_option('mc_time_format'), strtotime($event->occur_begin ."+$tz hours") ); 
    169169        $local_end = date_i18n( get_option('mc_time_format'), strtotime($event->occur_end ."+$tz hours") ); 
    170         $details['usertime'] = "$local_begin"; 
    171         $details['endusertime'] = ( $local_begin == $local_end )?'':"$local_end"; 
    172     } else { 
    173         $details['usertime'] = $details['time']; 
    174         $details['endusertime'] = ( $details['time'] == $details['endtime'] )?'':$details['endtime']; 
    175     } 
    176     $details['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime( $event->occur_begin ) );// hcal formatted 
    177     $details['dtend'] = date( 'Y-m-d\TH:i:s', strtotime($event->occur_end ) );  //hcal formatted end 
    178     $details['rssdate'] = date( 'D, d M Y H:i:s +0000', strtotime( $event->event_added ) );  
     170        $e['usertime'] = "$local_begin"; 
     171        $e['endusertime'] = ( $local_begin == $local_end )?'':"$local_end"; 
     172    } else { 
     173        $e['usertime'] = $e['time']; 
     174        $e['endusertime'] = ( $e['time'] == $e['endtime'] )?'':$e['endtime']; 
     175    } 
     176    $e['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime( $event->occur_begin ) );// hcal formatted 
     177    $e['dtend'] = date( 'Y-m-d\TH:i:s', strtotime($event->occur_end ) );    //hcal formatted end 
     178    $e['rssdate'] = date( 'D, d M Y H:i:s +0000', strtotime( $event->event_added ) );    
    179179        $date = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_begin' ) ,strtotime( $event->occur_begin ) ); 
    180180        $date_end = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_end' ) ,strtotime($real_end_date) ); 
     
    186186        $dates = array(); 
    187187    } 
    188     $details['date'] = ($event->event_span != 1)?$date:mc_format_date_span( $dates, 'simple', $date ); 
    189     $details['enddate'] = $date_end; 
    190     $details['daterange'] = ($date == $date_end)?$date:"<span class='mc_db'>$date</span> <span>&ndash;</span> <span class='mc_de'>$date_end</span>"; 
    191     $details['timerange'] = ( ($details['time'] == $details['endtime'] ) || $event->event_hide_end == 1 )?$details['time']:"<span class='mc_tb'>".$details['time']."</span> <span>&ndash;</span> <span class='mc_te'>".$details['endtime']."</span>"; 
    192     $details['datespan'] = ($event->event_span == 1 || ($details['date'] != $details['enddate']) )?mc_format_date_span( $dates ):$date; 
    193     $details['multidate'] = mc_format_date_span( $dates, 'complex', "<span class='fallback-date'>$date</span><span class='separator'>,</span> <span class='fallback-time'>$details[time]</span>&ndash;<span class='fallback-endtime'>$details[endtime]</span>" ); 
    194     $details['began'] = $event->event_begin; // returns date of first occurrence of an event. 
    195     $details['recurs'] = mc_event_recur_string( $event ); 
    196     $details['repeats'] = $event->event_repeats; 
     188    $e['date'] = ($event->event_span != 1)?$date:mc_format_date_span( $dates, 'simple', $date ); 
     189    $e['enddate'] = $date_end; 
     190    $e['daterange'] = ($date == $date_end)?$date:"<span class='mc_db'>$date</span> <span>&ndash;</span> <span class='mc_de'>$date_end</span>"; 
     191    $e['timerange'] = ( ($e['time'] == $e['endtime'] ) || $event->event_hide_end == 1 )?$e['time']:"<span class='mc_tb'>".$e['time']."</span> <span>&ndash;</span> <span class='mc_te'>".$e['endtime']."</span>"; 
     192    $e['datespan'] = ($event->event_span == 1 || ($e['date'] != $e['enddate']) )?mc_format_date_span( $dates ):$date; 
     193    $e['multidate'] = mc_format_date_span( $dates, 'complex', "<span class='fallback-date'>$date</span><span class='separator'>,</span> <span class='fallback-time'>$e[time]</span>&ndash;<span class='fallback-endtime'>$e[endtime]</span>" ); 
     194    $e['began'] = $event->event_begin; // returns date of first occurrence of an event. 
     195    $e['recurs'] = mc_event_recur_string( $event ); 
     196    $e['repeats'] = $event->event_repeats; 
    197197     
    198198    // category fields 
    199     $details['cat_id'] = $event->event_category; 
    200     $details['category'] = stripslashes($event->category_name); 
    201     $details['icon'] = mc_category_icon( $event,'img' ); 
    202     $details['icon_html'] = "<img src='$details[icon]' class='mc-category-icon' alt='".__('Category','my-calendar').": ".esc_attr($event->category_name)."' />"; 
    203     $details['color'] = $event->category_color; 
     199    $e['cat_id'] = $event->event_category; 
     200    $e['category'] = stripslashes($event->category_name); 
     201    $e['icon'] = mc_category_icon( $event,'img' ); 
     202    $e['icon_html'] = "<img src='$e[icon]' class='mc-category-icon' alt='".__('Category','my-calendar').": ".esc_attr($event->category_name)."' />"; 
     203    $e['color'] = $event->category_color; 
    204204     
    205205    // special 
    206     $details['skip_holiday'] = ($event->event_holiday == 0)?'false':'true'; 
    207     $details['event_status'] = ( $event->event_approved == 1 )?__('Published','my-calendar'):__('Reserved','my-calendar');   
     206    $e['skip_holiday'] = ($event->event_holiday == 0)?'false':'true'; 
     207    $e['event_status'] = ( $event->event_approved == 1 )?__('Published','my-calendar'):__('Reserved','my-calendar');     
    208208     
    209209    // general text fields 
    210210    $strip_desc = mc_newline_replace( strip_tags( $event->event_desc ) );    
    211     $details['title'] = stripcslashes($event->event_title); 
    212     $details['description'] = ( get_option('mc_process_shortcodes') == 'true' )?apply_filters('the_content',$event->event_desc):wpautop(stripslashes($event->event_desc)); 
    213     $details['description_raw'] = stripslashes($event->event_desc); 
    214     $details['description_stripped'] = strip_tags(stripslashes($event->event_desc)); 
    215     $details['shortdesc'] = ( get_option('mc_process_shortcodes') == 'true' )?apply_filters('the_content',$event->event_short):wpautop(stripslashes($event->event_short)); 
    216     $details['shortdesc_raw'] = stripslashes($event->event_short); 
    217     $details['shortdesc_stripped'] = strip_tags(stripslashes($event->event_short)); 
     211    $e['title'] = stripcslashes( $event->event_title ); 
     212    $e['description'] = ( get_option('mc_process_shortcodes') == 'true' )?apply_filters('the_content',$event->event_desc):wpautop(stripslashes($event->event_desc)); 
     213    $e['description_raw'] = stripslashes($event->event_desc); 
     214    $e['description_stripped'] = strip_tags(stripslashes($event->event_desc)); 
     215    $e['shortdesc'] = ( get_option('mc_process_shortcodes') == 'true' )?apply_filters('the_content',$event->event_short):wpautop(stripslashes($event->event_short)); 
     216    $e['shortdesc_raw'] = stripslashes($event->event_short); 
     217    $e['shortdesc_stripped'] = strip_tags(stripslashes($event->event_short)); 
    218218 
    219219    // registration fields 
    220     $details['event_open'] = mc_event_open( $event ); 
    221     $details['event_tickets'] = $event->event_tickets; 
    222     $details['event_registration'] = stripslashes( wp_kses_data( $event->event_registration ) ); 
     220    $e['event_open'] = mc_event_open( $event ); 
     221    $e['event_tickets'] = $event->event_tickets; 
     222    $e['event_registration'] = stripslashes( wp_kses_data( $event->event_registration ) ); 
    223223 
    224224    // links 
    225225    $templates = get_option('mc_templates'); 
    226     $details_template = ( !empty($templates['label']) )? stripcslashes($templates['label']):__('Details about','my-calendar').' {title}'; 
     226    $e_template = ( !empty($templates['label']) )? stripcslashes($templates['label']):__('Details about','my-calendar').' {title}'; 
    227227    $tags = array( "{title}","{location}","{color}","{icon}","{date}","{time}" ); 
    228     $replacements = array( stripslashes($event->event_title), stripslashes($event->event_label), $event->category_color, $event->category_icon, $details['date'], $details['time'] ); 
    229     $details_label = str_replace($tags,$replacements,$details_template ); 
    230     //$details_label = mc_get_details_label( $event, $details ); // recursive...hmmmm. 
    231     $details_link = mc_get_details_link( $event ); 
    232     $details['link'] = mc_event_link( $event ); 
    233     $details['link_title'] = ($details['link'] != '')?"<a href='".$event->event_link."'>".stripslashes($event->event_title)."</a>":stripslashes($event->event_title);    
    234     $details['details_link'] = ( get_option( 'mc_uri' ) != '' && !is_numeric( get_option('mc_uri') ) )?$details_link:''; 
    235     $details['details'] = ( get_option( 'mc_uri' ) != '' && !is_numeric( get_option('mc_uri') ) )?"<a href='$details_link' class='mc-details'>$details_label</a>":''; 
    236     $details['linking'] = ( $details['link'] != '' )?$event->event_url:$details_link; 
     228    $replacements = array( stripslashes($event->event_title), stripslashes($event->event_label), $event->category_color, $event->category_icon, $e['date'], $e['time'] ); 
     229    $e_label = str_replace($tags,$replacements,$e_template ); 
     230    //$e_label = mc_get_details_label( $event, $e ); // recursive...hmmmm. 
     231    $e_link = mc_get_details_link( $event ); 
     232    $e['link'] = mc_event_link( $event ); 
     233    $e['link_title'] = ($e['link'] != '')?"<a href='".$event->event_link."'>".stripslashes($event->event_title)."</a>":stripslashes($event->event_title);    
     234    $e['details_link'] = ( get_option( 'mc_uri' ) != '' && !is_numeric( get_option('mc_uri') ) )?$e_link:''; 
     235    $e['details'] = ( get_option( 'mc_uri' ) != '' && !is_numeric( get_option('mc_uri') ) )?"<a href='$e_link' class='mc-details'>$e_label</a>":''; 
     236    $e['linking'] = ( $e['link'] != '' )?$event->event_url:$e_link; 
    237237         
    238238    // location fields 
    239     $details['location'] = stripslashes($event->event_label); 
    240     $details['street'] = stripslashes($event->event_street); 
    241     $details['street2'] = stripslashes($event->event_street2); 
    242     $details['phone'] = apply_filters( 'mc_phone_format', stripslashes( $event->event_phone ) ); 
    243     $details['phone2'] = apply_filters( 'mc_phone_format', stripslashes( $event->event_phone2 ) ); 
    244     $details['city'] = stripslashes($event->event_city); 
    245     $details['state'] = stripslashes($event->event_state); 
    246     $details['postcode'] = stripslashes($event->event_postcode); 
    247     $details['country'] = stripslashes($event->event_country); 
    248     $details['hcard'] = stripslashes( mc_hcard( $event ) ); 
    249     $details['link_map'] = $map; 
    250     $details['map_url'] = $map_url; 
    251     $details['map'] = mc_generate_map( $event ); 
    252         $url = ( get_option( 'mc_uri' ) != '' && !is_numeric( get_option( 'mc_uri' ) ) )?$details_link:$event->event_url; 
    253     $details['gcal'] = mc_google_cal( $dtstart, $dtend, $url, stripcslashes( $event->event_title ), mc_maplink( $event, 'gcal' ), $strip_desc ); 
    254     $details['gcal_link'] = "<a href='".mc_google_cal( $dtstart, $dtend, $url, stripcslashes( $event->event_title ) ,  mc_maplink( $event, 'gcal' ), $strip_desc )."'>".sprintf( __('<span class="screenreader">Send %1$s to </span>Google Calendar','my-calendar'), stripcslashes( $event->event_title ) )."</a>"; 
    255     $details['location_access'] = mc_expand( $event->event_access, 'mc_location_access' ); 
    256     $details['location_source'] = $event->event_location;    
     239    $e['location'] = stripslashes($event->event_label); 
     240    $e['street'] = stripslashes($event->event_street); 
     241    $e['street2'] = stripslashes($event->event_street2); 
     242    $e['phone'] = apply_filters( 'mc_phone_format', stripslashes( $event->event_phone ) ); 
     243    $e['phone2'] = apply_filters( 'mc_phone_format', stripslashes( $event->event_phone2 ) ); 
     244    $e['city'] = stripslashes($event->event_city); 
     245    $e['state'] = stripslashes($event->event_state); 
     246    $e['postcode'] = stripslashes($event->event_postcode); 
     247    $e['country'] = stripslashes($event->event_country); 
     248    $e['hcard'] = stripslashes( mc_hcard( $event ) ); 
     249    $e['link_map'] = $map; 
     250    $e['map_url'] = $map_url; 
     251    $e['map'] = mc_generate_map( $event ); 
     252        $url = ( get_option( 'mc_uri' ) != '' && !is_numeric( get_option( 'mc_uri' ) ) )?$e_link:$event->event_url; 
     253    $e['gcal'] = mc_google_cal( $dtstart, $dtend, $url, stripcslashes( $event->event_title ), mc_maplink( $event, 'gcal' ), $strip_desc ); 
     254    $e['gcal_link'] = "<a href='".mc_google_cal( $dtstart, $dtend, $url, stripcslashes( $event->event_title ) ,  mc_maplink( $event, 'gcal' ), $strip_desc )."'>".sprintf( __('<span class="screenreader">Send %1$s to </span>Google Calendar','my-calendar'), stripcslashes( $event->event_title ) )."</a>"; 
     255    $e['location_access'] = mc_expand( unserialize( mc_location_data( 'location_access', $event->event_location ) ) ); 
     256    $e['location_source'] = $event->event_location;  
    257257     
    258258    // IDs 
    259     $details['dateid'] = $event->occur_id; // unique ID for this date of this event 
    260     $details['id'] = $event->event_id; 
    261     $details['group'] = $event->event_group_id; 
    262     $details['event_span'] = $event->event_span; 
     259    $e['dateid'] = $event->occur_id; // unique ID for this date of this event 
     260    $e['id'] = $event->event_id; 
     261    $e['group'] = $event->event_group_id; 
     262    $e['event_span'] = $event->event_span; 
    263263     
    264264    // RSS guid 
    265     $details['region'] = $event->event_region; 
    266     $details['guid'] =( get_option( 'mc_uri' ) != '' && !is_numeric( get_option('mc_uri') ) )?"<guid isPermaLink='true'>$details_link</guid>":"<guid isPermalink='false'>$details_link</guid>"; 
     265    $e['region'] = $event->event_region; 
     266    $e['guid'] =( get_option( 'mc_uri' ) != '' && !is_numeric( get_option('mc_uri') ) )?"<guid isPermaLink='true'>$e_link</guid>":"<guid isPermalink='false'>$e_link</guid>"; 
    267267 
    268268    // iCAL 
    269     $details['ical_location'] = $event->event_label .' '. $event->event_street .' '. $event->event_street2 .' '. $event->event_city .' '. $event->event_state .' '. $event->event_postcode; 
    270     $details['ical_description'] = str_replace( "\r", "=0D=0A=", $event->event_desc ); 
    271     $details['ical_desc'] = $strip_desc; 
    272     $details['ical_start'] = $dtstart; 
    273     $details['ical_end'] = $dtend; 
     269    $e['ical_location'] = $event->event_label .' '. $event->event_street .' '. $event->event_street2 .' '. $event->event_city .' '. $event->event_state .' '. $event->event_postcode; 
     270    $e['ical_description'] = str_replace( "\r", "=0D=0A=", $event->event_desc ); 
     271    $e['ical_desc'] = $strip_desc; 
     272    $e['ical_start'] = $dtstart; 
     273    $e['ical_end'] = $dtend; 
    274274    $ical_link = mc_build_url( array('vcal'=>$event->occur_id), array('month','dy','yr','ltype','loc','mcat','format'), get_option( 'mc_uri' ) ); 
    275     $details['ical'] = $ical_link; 
    276     $details['ical_html'] = "<a class='ical' rel='nofollow' href='$ical_link'>".__('iCal','my-calendar')."</a>"; 
     275    $e['ical'] = $ical_link; 
     276    $e['ical_html'] = "<a class='ical' rel='nofollow' href='$ical_link'>".__('iCal','my-calendar')."</a>"; 
    277277         
    278278    // get URL, TITLE, LOCATION, DESCRIPTION strings 
    279     $details = apply_filters( 'mc_filter_shortcodes',$details,$event ); 
    280     return $details; 
    281 } 
    282  
    283 function mc_get_details_label( $event, $details ) { 
     279    $e = apply_filters( 'mc_filter_shortcodes',$e,$event ); 
     280    return $e; 
     281} 
     282 
     283function mc_get_details_label( $event, $e ) { 
    284284    $templates = get_option( 'mc_templates' ); 
    285     $details_template = ( !empty($templates['label']) )? stripcslashes($templates['label']): sprintf( __('Event Details %s','my-calendar'), '<span class="screen-reader-text">about {title}</span> &raquo;' ); 
    286     $details_label = wp_kses( jd_draw_template( $details, $details_template ), array( 'span'=>array( 'class'=>array('screen-reader-text') ), 'em', 'strong' ) ); 
    287     return $details_label; 
     285    $e_template = ( !empty($templates['label']) )? stripcslashes($templates['label']): sprintf( __('Event Details %s','my-calendar'), '<span class="screen-reader-text">about {title}</span> &raquo;' ); 
     286    $e_label = wp_kses( jd_draw_template( $e, $e_template ), array( 'span'=>array( 'class'=>array('screen-reader-text') ), 'em', 'strong' ) ); 
     287    return $e_label; 
    288288} 
    289289 
     
    390390} 
    391391 
    392 function mc_expand( $data, $option ) { 
    393     //$option = get_option( $option ); 
     392function mc_expand( $data ) { 
    394393    $output = ''; 
    395394    if ( is_array( $data ) ) { 
     
    450449 
    451450add_filter( 'mc_insert_author_data', 'mc_author_data', 10, 2 ); 
    452 function mc_author_data( $details, $event ) { 
     451function mc_author_data( $e, $event ) { 
    453452    if ( $event->event_author != 0 ) { 
    454         $e = get_userdata($event->event_author); 
     453        $author = get_userdata($event->event_author); 
    455454        $host = get_userdata($event->event_host); 
    456         $details['author'] = $e->display_name; 
    457         $details['gravatar'] = get_avatar( $e->user_email ); 
    458         $details['author_email'] = $e->user_email; 
    459         $details['author_id'] = $event->event_author; 
    460         $details['host'] = (!$host || $host->display_name == '')?$e->display_name:$host->display_name;  
    461         $details['host_id'] = $event->event_host; 
    462         $details['host_email'] = (!$host || $host->user_email == '')?$e->user_email:$host->user_email; 
    463         $details['host_gravatar'] = ( !$host || $host->user_email == '' )?$details['gravatar']:get_avatar( $host->user_email ); 
    464     } else { 
    465         $details['author'] = 'Public Submitter'; 
    466         $details['host'] = 'Public Submitter'; 
    467         $details['host_email'] = ''; 
    468         $details['author_email'] = ''; 
    469         $details['gravatar'] = ''; 
    470         $details['host_gravatar'] = ''; 
    471         $details['author_id'] = false; 
    472         $details['host_id'] = false; 
    473     } 
    474     return $details; 
     455        $e['author'] = $author->display_name; 
     456        $e['gravatar'] = get_avatar( $author->user_email ); 
     457        $e['author_email'] = $author->user_email; 
     458        $e['author_id'] = $event->event_author; 
     459        $e['host'] = (!$host || $host->display_name == '')?$author->display_name:$host->display_name;  
     460        $e['host_id'] = $event->event_host; 
     461        $e['host_email'] = (!$host || $host->user_email == '')?$author->user_email:$host->user_email; 
     462        $e['host_gravatar'] = ( !$host || $host->user_email == '' )?$e['gravatar']:get_avatar( $host->user_email ); 
     463    } else { 
     464        $e['author'] = 'Public Submitter'; 
     465        $e['host'] = 'Public Submitter'; 
     466        $e['host_email'] = ''; 
     467        $e['author_email'] = ''; 
     468        $e['gravatar'] = ''; 
     469        $e['host_gravatar'] = ''; 
     470        $e['author_id'] = false; 
     471        $e['host_id'] = false; 
     472    } 
     473    return $e; 
    475474} 
    476475 
    477476add_filter( 'mc_filter_image_data', 'mc_image_data', 10, 2 ); 
    478 function mc_image_data( $details, $event ) { 
     477function mc_image_data( $e, $event ) { 
    479478    $atts = apply_filters( 'mc_post_thumbnail_atts',  array( 'class'=>'mc-image' ) );  
    480     $details['full'] = get_the_post_thumbnail( $event->event_post );     
     479    $e['full'] = get_the_post_thumbnail( $event->event_post );   
    481480    $sizes = get_intermediate_image_sizes(); 
    482481    foreach ( $sizes as $size ) { 
    483         $details[$size] = get_the_post_thumbnail( $event->event_post, $size, $atts ); 
    484     } 
    485     if ( is_numeric( $event->event_post ) && isset( $details['medium'] ) ) { 
    486         $details['image_url'] = strip_tags( $details['medium'] ); 
    487         $details['image'] = $details['medium']; 
    488     } else { 
    489         $details['image_url'] = ( $event->event_image != '' )?$event->event_image:''; 
    490         $details['image'] = ( $event->event_image != '' )?"<img src='$event->event_image' alt='' class='mc-image' />":''; 
    491     } 
    492     return $details; 
     482        $e[$size] = get_the_post_thumbnail( $event->event_post, $size, $atts ); 
     483    } 
     484    if ( is_numeric( $event->event_post ) && isset( $e['medium'] ) ) { 
     485        $e['image_url'] = strip_tags( $e['medium'] ); 
     486        $e['image'] = $e['medium']; 
     487    } else { 
     488        $e['image_url'] = ( $event->event_image != '' )?$event->event_image:''; 
     489        $e['image'] = ( $event->event_image != '' )?"<img src='$event->event_image' alt='' class='mc-image' />":''; 
     490    } 
     491    return $e; 
    493492} 
    494493 
  • my-calendar/trunk/my-calendar-templating.php

    r866550 r868877  
    88    $templates = get_option( 'mc_templates' ); 
    99 
     10    if ( !empty( $_POST ) ) { 
     11        $nonce = $_REQUEST['_wpnonce']; 
     12        if ( !wp_verify_nonce( $nonce,'my-calendar-nonce' ) ) die( "Security check failed" );    
     13    } 
     14     
    1015    if ( isset($_POST['mc_grid_template'] ) ) { 
    11         $nonce=$_REQUEST['_wpnonce']; 
    12         if ( !wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed"); 
    13  
    1416        $mc_grid_template = $_POST['mc_grid_template']; 
    1517        $templates['grid'] = $mc_grid_template; 
    1618        update_option( 'mc_templates', $templates ); 
    1719        update_option( 'mc_use_grid_template',( empty($_POST['mc_use_grid_template'])?0:1 ) ); 
    18  
    1920        echo "<div class=\"updated\"><p><strong>".__('Grid Output Template saved','my-calendar').".</strong></p></div>"; 
    2021    } 
    2122     
    2223    if ( isset($_POST['mc_rss_template'] ) ) { 
    23         $nonce=$_REQUEST['_wpnonce']; 
    24         if ( !wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed"); 
    25  
    2624        $mc_rss_template = $_POST['mc_rss_template']; 
    2725        $templates['rss'] = $mc_rss_template; 
    2826        update_option( 'mc_templates', $templates ); 
    2927        update_option( 'mc_use_rss_template',( empty($_POST['mc_use_rss_template'])?0:1 ) ); 
    30  
    3128        echo "<div class=\"updated\"><p><strong>".__('RSS Feed Output Template saved','my-calendar').".</strong></p></div>"; 
    3229    }    
    3330     
    3431    if ( isset($_POST['mc_list_template'] ) ) { 
    35         $nonce=$_REQUEST['_wpnonce']; 
    36         if ( !wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed"); 
    37  
    3832        $mc_list_template = $_POST['mc_list_template']; 
    3933        $templates['list'] = $mc_list_template; 
    4034        update_option( 'mc_templates', $templates ); 
    4135        update_option( 'mc_use_list_template',( empty($_POST['mc_use_list_template'])?0:1 ) ); 
    42  
    4336        echo "<div class=\"updated\"><p><strong>".__('List Output Template saved','my-calendar').".</strong></p></div>"; 
    4437    } 
    4538 
    4639    if ( isset($_POST['mc_mini_template'] ) ) { 
    47         $nonce=$_REQUEST['_wpnonce']; 
    48         if ( !wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed"); 
    49  
    5040        $mc_mini_template = $_POST['mc_mini_template']; 
    5141        $templates['mini'] = $mc_mini_template; 
     
    5646 
    5747    if ( isset( $_POST['mc_details_template'] ) ) { 
    58         $nonce=$_REQUEST['_wpnonce']; 
    59         if ( !wp_verify_nonce($nonce,'my-calendar-nonce') ) die("Security check failed"); 
    60  
    6148        $mc_details_template = $_POST['mc_details_template']; 
    6249        $templates['details'] = $mc_details_template; 
     
    6451        update_option( 'mc_use_details_template',( empty($_POST['mc_use_details_template'])?0:1 ) ); 
    6552        echo "<div class=\"updated\"><p><strong>".__('Event Details Template saved','my-calendar').".</strong></p></div>"; 
    66     }    
     53    } 
     54     
    6755    global $grid_template, $list_template, $mini_template, $single_template, $rss_template; 
    68     $mc_grid_template = stripslashes( ($templates['grid']!='')?$templates['grid']:$grid_template ); 
    69     $mc_use_grid_template = get_option('mc_use_grid_template'); 
    70     $mc_rss_template = stripslashes( ($templates['rss']!='')?$templates['rss']:$rss_template ); 
     56    $mc_grid_template = stripslashes( ( $templates['grid']!='' ) ? $templates['grid'] : $grid_template ); 
     57    $mc_use_grid_template = get_option( 'mc_use_grid_template' ); 
     58    $mc_rss_template = stripslashes( ( $templates['rss']!='' ) ? $templates['rss'] : $rss_template ); 
    7159    $mc_use_rss_template = get_option('mc_use_rss_template');    
    72     $mc_list_template = stripslashes( ($templates['list']!='')?$templates['list']:$list_template ); 
    73     $mc_use_list_template = get_option('mc_use_list_template'); 
    74     $mc_mini_template = stripslashes( ($templates['mini']!='')?$templates['mini']:$mini_template ); 
    75     $mc_use_mini_template = get_option('mc_use_mini_template'); 
    76     $mc_details_template = stripslashes( ($templates['details']!='')?$templates['details']:$single_template ); 
    77     $mc_use_details_template = get_option('mc_use_details_template');    
    78 ?> 
     60    $mc_list_template = stripslashes( ( $templates['list']!='' ) ? $templates['list'] : $list_template ); 
     61    $mc_use_list_template = get_option( 'mc_use_list_template' ); 
     62    $mc_mini_template = stripslashes( ( $templates['mini']!='' ) ? $templates['mini'] : $mini_template ); 
     63    $mc_use_mini_template = get_option( 'mc_use_mini_template' ); 
     64    $mc_details_template = stripslashes( ( $templates['details']!='' ) ? $templates['details'] : $single_template ); 
     65    $mc_use_details_template = get_option( 'mc_use_details_template' ); ?> 
    7966    <div class="wrap jd-my-calendar"> 
    80      
    81      
    82 <?php my_calendar_check_db(); ?> 
     67    <?php my_calendar_check_db(); ?> 
    8368    <h2><?php _e('My Calendar Information Templates','my-calendar'); ?></h2> 
    8469     
     
    190175</div> 
    191176</div> 
    192     <?php jd_show_support_box('templates'); 
     177    <?php mc_show_sidebar('templates'); 
    193178} 
  • my-calendar/trunk/my-calendar-widgets.php

    r866550 r868877  
    289289                if ( is_array($value) ) { 
    290290                    foreach ( $value as $k => $v ) { 
    291                         $event = event_as_array( $v ); 
     291                        $event = mc_create_tags( $v ); 
    292292                        if ( $v->category_private == 1 && !is_user_logged_in() ) { 
    293293                            // this event is private. 
     
    357357            } 
    358358        } 
    359         $output .= mc_produce_upcoming_events( $event_array,$template,'list',$order,$skip,$before, $after, $show_today ); 
     359        if ( !empty( $event_array ) ) { 
     360            $output .= mc_produce_upcoming_events( $event_array,$template,'list',$order,$skip,$before, $after, $show_today ); 
     361        } else { 
     362            $output = ''; 
     363        } 
    360364    } 
    361365    if ($output != '') { 
     
    485489            $event =& $events[$key]; 
    486490            //echo $event->event_title . " " . $event->event_group_id."<br />"; 
    487             $event_details = event_as_array( $event ); 
     491            $event_details = mc_create_tags( $event ); 
    488492                if ( get_option( 'mc_event_approve' ) == 'true' ) { 
    489493                    if ( $event->event_approved != 0 ) { $temp_array[] = $event_details; } 
     
    561565                } else { 
    562566                    if ( !in_array( $e->event_group_id, $groups ) ) { 
    563                         $event_details = event_as_array($e); 
     567                        $event_details = mc_create_tags($e); 
    564568                        $ts = $e->ts_occur_begin; 
    565569                        $date = date_i18n( apply_filters( 'mc_date_format', get_option('mc_date_format'), 'todays_events' ) , current_time( 'timestamp' ) ); 
     
    604608function widget($args, $instance) { 
    605609    extract($args); 
     610    $name = $format = 'mini';    
    606611    if ( !empty($instance) ) { 
    607612        $the_title = apply_filters('widget_title',$instance['my_calendar_mini_title'], $instance, $args ); 
    608         $name = $format = 'mini'; 
    609613        $category = ($instance['my_calendar_mini_category']=='')?'all':esc_attr($instance['my_calendar_mini_category']); 
    610614        $time = ($instance['my_calendar_mini_time']=='')?'month':esc_attr($instance['my_calendar_mini_time']); 
    611615        $widget_link = ( !isset($instance['mc_link']) || $instance['mc_link']=='')?'':esc_url($instance['mc_link']); 
    612         $above = (empty($instance['above']))?'none':esc_attr($instance['above']); 
    613         $below = (empty($instance['below']))?'none':esc_attr($instance['below']); 
    614         $author = ($instance['author']=='')?null:esc_attr($instance['author']); 
    615         $host = ($instance['host']=='')?null:esc_attr($instance['host']); 
     616        $above = ( empty($instance['above'] ) )?'none':esc_attr( $instance['above'] ); 
     617        $below = ( empty($instance['below'] ) )?'none':esc_attr( $instance['below'] ); 
     618        $author = ( $instance['author']=='' )?null:esc_attr( $instance['author'] ); 
     619        $host = ( $instance['host']=='')?null:esc_attr( $instance['host'] ); 
    616620    } else { 
    617621        $the_title = $category = $time = $widget_link = $above = $below = ''; 
    618         $name = 'mini'; 
    619622    } 
    620623    $title = empty($the_title) ? __('Calendar','my-calendar') : $the_title; 
    621624    $title = ($widget_link!='') ? "<a href='$widget_link'>$title</a>" : $title; 
    622     $title = ($title!='') ? $before_title . $title . $after_title : ''; 
     625    $title = ( $title!='' ) ? $before_title . $title . $after_title : ''; 
    623626    $the_events = my_calendar( $name, $format, $category, $time,'','','jd-calendar','','',$author, $host, $above, $below ); 
    624         if ($the_events != '') { 
    625             echo $before_widget . $title . $the_events . $after_widget; 
    626         } 
     627    if ( $the_events != '' ) { 
     628        echo $before_widget . $title . $the_events . $after_widget; 
     629    } 
    627630} 
    628631 
  • my-calendar/trunk/my-calendar.php

    r866550 r868877  
    6464    flush_rewrite_rules(); 
    6565} 
    66  
    67 include(dirname(__FILE__).'/my-calendar-core.php' ); 
    68 include(dirname(__FILE__).'/my-calendar-install.php' ); 
    69 include(dirname(__FILE__).'/my-calendar-settings.php' ); 
    70 include(dirname(__FILE__).'/my-calendar-categories.php' ); 
    71 include(dirname(__FILE__).'/my-calendar-locations.php' ); 
    72 include(dirname(__FILE__).'/my-calendar-help.php' ); 
    73 include(dirname(__FILE__).'/my-calendar-event-manager.php' ); 
    74 include(dirname(__FILE__).'/my-calendar-styles.php' ); 
    75 include(dirname(__FILE__).'/my-calendar-behaviors.php' ); 
    76 include(dirname(__FILE__).'/my-calendar-widgets.php' ); 
    77 include(dirname(__FILE__).'/date-utilities.php' ); 
    78 include(dirname(__FILE__).'/my-calendar-upgrade-db.php' ); 
    79 include(dirname(__FILE__).'/my-calendar-output.php' ); 
    80 include(dirname(__FILE__).'/my-calendar-templates.php' ); 
    81 include(dirname(__FILE__).'/my-calendar-ical.php' ); 
    82 include(dirname(__FILE__).'/my-calendar-events.php' ); 
    83 include(dirname(__FILE__).'/my-calendar-limits.php' ); 
    84 include(dirname(__FILE__).'/my-calendar-shortcodes.php' ); 
    85 include(dirname(__FILE__).'/my-calendar-templating.php' ); 
    86 include(dirname(__FILE__).'/my-calendar-group-manager.php' ); 
    87 include(dirname(__FILE__).'/my-calendar-export.php' ); 
    88 include(dirname(__FILE__).'/my-calendar-api.php' ); 
    89 include(dirname(__FILE__).'/my-calendar-generator.php' ); 
     66include( dirname(__FILE__).'/includes/date-utilities.php' ); 
     67include( dirname(__FILE__).'/my-calendar-core.php' ); 
     68include( dirname(__FILE__).'/my-calendar-install.php' ); 
     69include( dirname(__FILE__).'/my-calendar-settings.php' ); 
     70include( dirname(__FILE__).'/my-calendar-categories.php' ); 
     71include( dirname(__FILE__).'/my-calendar-locations.php' ); 
     72include( dirname(__FILE__).'/my-calendar-help.php' ); 
     73include( dirname(__FILE__).'/my-calendar-event-manager.php' ); 
     74include( dirname(__FILE__).'/my-calendar-styles.php' ); 
     75include( dirname(__FILE__).'/my-calendar-behaviors.php' ); 
     76include( dirname(__FILE__).'/my-calendar-events.php' ); 
     77include( dirname(__FILE__).'/my-calendar-widgets.php' ); 
     78include( dirname(__FILE__).'/my-calendar-upgrade-db.php' ); 
     79include( dirname(__FILE__).'/my-calendar-output.php' ); 
     80include( dirname(__FILE__).'/my-calendar-templates.php' ); 
     81include( dirname(__FILE__).'/my-calendar-ical.php' ); 
     82include( dirname(__FILE__).'/my-calendar-limits.php' ); 
     83include( dirname(__FILE__).'/my-calendar-shortcodes.php' ); 
     84include( dirname(__FILE__).'/my-calendar-templating.php' ); 
     85include( dirname(__FILE__).'/my-calendar-group-manager.php' ); 
     86include( dirname(__FILE__).'/my-calendar-export.php' ); 
     87include( dirname(__FILE__).'/my-calendar-api.php' ); 
     88include( dirname(__FILE__).'/my-calendar-generator.php' ); 
    9089 
    9190// Enable internationalisation 
     
    120119        $id = (int) $_GET['mc_id']; 
    121120        $event = mc_get_event( $id ); 
    122         $array = event_as_array( $event ); 
     121        $array = mc_create_tags( $event ); 
    123122        $left_sep = ( $seplocation != 'right' ? ' ' . $sep . ' ' : '' ); 
    124123        $right_sep = ( $seplocation != 'right' ? '' : ' ' . $sep . ' ' );        
     
    131130 
    132131// produce admin support box 
    133 function jd_show_support_box( $show='', $add=false, $remove=false ) { 
     132function mc_show_sidebar( $show='', $add=false, $remove=false ) { 
    134133    if ( current_user_can('mc_view_help') ) { ?> 
    135134    <div class="postbox-container jcd-narrow"> 
     
    302301        </dl> 
    303302        <p> 
    304             <a href="<?php admin_url( 'admin.php?page=my-calendar-help#template' ); ?>"><?php _e('All Template Tags &raquo;','my-calendar'); ?></a> 
     303            <a href="<?php echo admin_url( 'admin.php?page=my-calendar-help#templates' ); ?>"><?php _e('All Template Tags &raquo;','my-calendar'); ?></a> 
    305304        </p> 
    306305        </div> 
  • my-calendar/trunk/readme.txt

    r865684 r868877  
    136136* {map} template tag to display a Google Map using the Google Maps API. (Not available in pop-up displays.) 
    137137* Scheduled removal of showkey, shownav, toggle, and showjump shortcode attributes. 
     138* Removed upgrade routines for 1.6.x series of My Calendar. 
    138139 
    139140= 2.2.13 = 
Note: See TracChangeset for help on using the changeset viewer.