Advertisement
Guest User

Untitled

a guest
Sep 26th, 2013
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.86 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Simple Events Calendar
  4. Plugin URI: http://www.studiostacks.com/plugins/simple-events-calendar
  5. Description: A simple plugin for adding upcomding events to your wordpress site with micoformats tags. Manage your campaigns from the admin panel and group your events with labels. Easily add your events to any page or post by using a simple shortcode. By default the shortcode will display all 'upcoming' events, but it is also possible to show only 'expired' events or both. By using labels you can decide which events group to display. By default all groups are showed.
  6. Many sites show their events, but it always looks bad when events that took place already are displayed as being upcoming. With this plugin your content will never be outdated.
  7. Version: 1.3.4
  8. Author: Jerry Rietveld
  9. Author URI: http://www.jgrietveld.com
  10. License: GPL2
  11. */
  12.  
  13. /* Copyright 2013 Jerry G. Rietveld (email : jerry+plugin@jgrietveld.com)
  14.  
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License, version 2, as
  17. published by the Free Software Foundation.
  18.  
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23.  
  24. You should have received a copy of the GNU General Public License
  25. along with this program; if not, write to the Free Software
  26. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  27. */
  28. define('SE_VERSION', '1.3.4');
  29. define('SE_DOMAIN',get_bloginfo('url').'/wp-content/plugins/simple-events-calendar/');
  30. define('SE_TEXTDOMAIN','simple-events-calendar');
  31. define('SE_FOLDER', plugin_basename( dirname(__FILE__)) );
  32. define('SE_PLUGIN', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)));
  33.  
  34. // The date
  35. if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
  36. define('DATE', __('%a %B %#d',SE_TEXTDOMAIN)); // For WINDOWS %e doesn't work
  37. } else {
  38. define('DATE', __('%a %B %e',SE_TEXTDOMAIN));
  39. }
  40. // The time
  41. if(get_option('SE_clock') == "12") {
  42. define('TIME', __('%l:%M %p',SE_TEXTDOMAIN)); // 12 hour AM/PM
  43. } else {
  44. define('TIME', __('%H:%M',SE_TEXTDOMAIN)); // 24 hour military time
  45. }
  46. // The year
  47. define('YEAR','%Y');
  48.  
  49. // Make plugin available for translation
  50. function sec_init() {
  51. load_plugin_textdomain(SE_TEXTDOMAIN, false, dirname( plugin_basename( __FILE__ ) ) );
  52. }
  53. add_action('plugins_loaded', 'sec_init');
  54.  
  55. // Setting the stylesheet:
  56. if(isset($_REQUEST['page'])) {
  57. if($_REQUEST['page']=='simple-events' || $_REQUEST['page']=='simple-events-settings') {
  58. add_action( 'admin_init', 'se_admin_head' );
  59. function se_admin_head() {
  60. wp_enqueue_style('se-styling', SE_DOMAIN .'se-admin-style.css', false, SE_VERSION, "all");
  61. }
  62. }
  63. }
  64.  
  65. // Creating the Table in the DB or updating the structure
  66. global $SE_db_version;
  67. $SE_db_version = "2.1.1";
  68.  
  69. function SE_install() {
  70. global $wpdb;
  71. global $SE_db_version;
  72.  
  73. $table_name = $wpdb->prefix . "simple_events";
  74.  
  75. $sql = "CREATE TABLE $table_name (
  76. id mediumint(9) NOT NULL AUTO_INCREMENT,
  77. event_start INT(10) ZEROFILL NOT NULL,
  78. event_end INT(10) ZEROFILL NOT NULL,
  79. event_title TEXT NOT NULL,
  80. event_desc LONGTEXT NULL,
  81. event_url TEXT NULL,
  82. event_loc TEXT NOT NULL,
  83. event_loc_url TEXT NULL,
  84. event_label VARCHAR(10) NOT NULL,
  85. UNIQUE KEY id (id)
  86. );";
  87.  
  88. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  89. dbDelta($sql);
  90.  
  91. add_option("SE_db_version", $SE_db_version);
  92.  
  93. global $wpdb;
  94. $installed_ver = get_option( "SE_db_version" );
  95.  
  96. if( $installed_ver != $SE_db_version ) {
  97. $sql = "CREATE TABLE $table_name (
  98. id mediumint(9) NOT NULL AUTO_INCREMENT,
  99. event_start INT(10) ZEROFILL NOT NULL,
  100. event_end INT(10) ZEROFILL NOT NULL,
  101. event_title TEXT NOT NULL,
  102. event_desc LONGTEXT NULL,
  103. event_url TEXT NULL,
  104. event_loc TEXT NOT NULL,
  105. event_loc_url TEXT NULL,
  106. event_label VARCHAR(10) NOT NULL,
  107. UNIQUE KEY id (id)
  108. );";
  109.  
  110. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  111. dbDelta($sql);
  112.  
  113. update_option( "SE_db_version", $SE_db_version );
  114. }
  115. } // End Create Table in DB function
  116.  
  117. register_activation_hook(__FILE__,'SE_install');
  118.  
  119. function myplugin_update_db_check() {
  120. global $SE_db_version;
  121. if (get_site_option('SE_db_version') != $SE_db_version) {
  122. SE_install();
  123. }
  124. }
  125. add_action('plugins_loaded', 'myplugin_update_db_check');
  126.  
  127. // Set default settings
  128. if( !get_option('SE_clock')) {
  129. $SE_clock = "24";
  130. $SE_ext_css = "no";
  131. $SE_timezone = "+00:00";
  132. $SE_author = "manage_options";
  133. $SE_links = "none";
  134. $SE_twitter = "yes";
  135. add_option("SE_clock", $SE_clock);
  136. add_option("SE_ext_css", $SE_ext_css);
  137. add_option("SE_timezone", $SE_timezone);
  138. add_option("SE_author", $SE_author);
  139. add_option("SE_links", $SE_links);
  140. add_option("SE_twitter", $SE_twitter);
  141. }
  142.  
  143. // Create the admin menu
  144. add_action('admin_menu', 'SE_menu');
  145.  
  146. function SE_menu() {
  147. add_menu_page('Simple Events Calendar', 'Events', get_option('SE_author'), 'simple-events', 'simple_events_options',SE_DOMAIN.'icon.png');
  148. }// End function SE_menu to add a button to the admin dashboard
  149.  
  150. function simple_events_options() {
  151. if (!current_user_can(get_option('SE_author'))) {
  152. wp_die( __('You do not have sufficient permissions to access this page.',SE_TEXTDOMAIN) );
  153. } // end check authorisation level of the user logged in
  154.  
  155. if(isset($_POST['store_event'])) {
  156. if($_POST['event']['event_title']) { // New entries at least have to have a title, if none then nothing is written to DB
  157. global $wpdb;
  158. $table_name = $wpdb->prefix . "simple_events";
  159. $event = $_POST['event'];
  160. $event_start = mktime($event['event_start_hr'],$event['event_start_mn'],0,$event['event_start_month'],$event['event_start_day'],$event['event_start_yr']);
  161. $event_end = mktime($event['event_end_hr'],$event['event_end_mn'],0,$event['event_end_month'],$event['event_end_day'],$event['event_end_yr']);
  162. $newEvent['event_start'] = $event_start;
  163. $newEvent['event_end'] = $event_end;
  164. $newEvent['event_title'] = $event['event_title'];
  165. $newEvent['event_desc'] = $event['event_desc'];
  166. $newEvent['event_url'] = str_replace(" ", "", $event['event_url']);
  167. $newEvent['event_loc'] = $event['event_loc'];
  168. $newEvent['event_loc_url'] = str_replace(" ", "", $event['event_loc_url']);
  169. $newEvent['event_label'] = strtolower(str_replace(" ", "", $event['event_label']));
  170.  
  171. $wpdb->insert( $table_name, $newEvent );
  172. $result = $wpdb->insert_id;
  173. if(!$result) {
  174. echo '<div id="message" class="error fade"><p>'.__('Unfortunately something went wrong...',SE_TEXTDOMAIN).'</p></div>';
  175. } else { echo '<div id="message" class="updated fade"><p>'.__('The event was succesfully added!',SE_TEXTDOMAIN).'</p></div>'; }
  176. // End check if entry was written successfully to the DB
  177. } else { // So if no title was entered for the event then:
  178. echo '<div id="message" class="error fade"><p>'.__('C\'mon, at least give me a title!',SE_TEXTDOMAIN).'</p></div>';
  179. } // End check if title was entered or not and if so, the event was written to the DB
  180. } // END check if event was saved
  181.  
  182. elseif(isset($_POST['update_event'])) {
  183. global $wpdb;
  184. $table_name = $wpdb->prefix . "simple_events";
  185. $event = $_POST['event'];
  186. $event_start = mktime($event['event_start_hr'],$event['event_start_mn'],0,$event['event_start_month'],$event['event_start_day'],$event['event_start_yr']);
  187. $event_end = mktime($event['event_end_hr'],$event['event_end_mn'],0,$event['event_end_month'],$event['event_end_day'],$event['event_end_yr']);
  188. $editEvent['event_start'] = $event_start;
  189. $editEvent['event_end'] = $event_end;
  190. $editEvent['event_title'] = $event['event_title'];
  191. $editEvent['event_desc'] = $event['event_desc'];
  192. $editEvent['event_url'] = str_replace(" ", "", $event['event_url']);
  193. $editEvent['event_loc'] = $event['event_loc'];
  194. $editEvent['event_loc_url'] = str_replace(" ", "", $event['event_loc_url']);
  195. $editEvent['event_label'] = strtolower(str_replace(" ", "", $event['event_label']));
  196.  
  197. $where['id'] = $_POST['eventid'];
  198.  
  199. $wpdb->update( $table_name, $editEvent, $where );
  200. $result = $wpdb->update_id;
  201. echo '<div id="message" class="updated fade"><p>'.__('The event was succesfully updated!',SE_TEXTDOMAIN).'</p></div>';
  202. } // END check if event was updated ?>
  203.  
  204. <div class="wrap">
  205. <h2 id="plugin-title">Simple Events Calendar <span> <?php _e(' by <a class="pluginhelp" href="http://www.studiostacks.com/plugins/simple-events-calendar" rel="help">Jerry G. Rietveld</a>',SE_TEXTDOMAIN);?></span></h2>
  206. <div class="donate">
  207.  
  208. <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  209. <input type="hidden" name="cmd" value="_s-xclick">
  210. <input type="hidden" name="hosted_button_id" value="CVSFHBLEA7BEC">
  211. <input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
  212. <img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/scr/pixel.gif" width="1" height="1">
  213. </form>
  214.  
  215.  
  216. </div><!--.donate-->
  217. <h4 class="SE_settings">+ <?php _e('Advanced settings',SE_TEXTDOMAIN);?></h4>
  218. <div id="settings">
  219.  
  220. <?php if(isset($_POST['SEsettingsUpdate'])) {
  221. if(isset($_POST['SE_clock'])) $SE_clock = $_POST['SE_clock']; else $SE_clock = "24";
  222. if(isset($_POST['SE_ext_css'])) $SE_ext_css = $_POST['SE_ext_css']; else $SE_ext_css = "no";
  223. $SE_timezone = $_POST['SE_timezone'];
  224. $SE_author = $_POST['SE_author'];
  225. $SE_links = $_POST['SE_links'];
  226. if(isset($_POST['SE_twitter'])) $SE_twitter = $_POST['SE_twitter']; else $SE_twitter = "yes";
  227. update_option("SE_clock", $SE_clock);
  228. update_option("SE_ext_css", $SE_ext_css);
  229. update_option("SE_timezone", $SE_timezone);
  230. update_option("SE_author", $SE_author);
  231. update_option("SE_links", $SE_links);
  232. update_option("SE_twitter", $SE_twitter);
  233. }
  234. ?>
  235. <form method="post">
  236. <p>
  237. <label><input type="checkbox" name="SE_clock" value="12" <?php if(get_option('SE_clock') == "12") echo "checked";?> /> <?php _e('Change time to the 12 hour clock notation.',SE_TEXTDOMAIN);?></label>
  238. </p>
  239. <p>
  240. <label><input type="checkbox" name="SE_ext_css" value="yes" <?php if(get_option('SE_ext_css') == "yes") echo "checked";?> /> <?php _e('Check this box to use your own CSS styling.',SE_TEXTDOMAIN);?></label>
  241. <span class="explanation"><?php _e("Store your styling in a CSS file called <strong>simple-events-calendar.css</strong> in your theme's folder.",SE_TEXTDOMAIN);?></span>
  242. </p>
  243. <p><?php _e('Select your timezone: ',SE_TEXTDOMAIN);?>
  244. <select name="SE_timezone" id="DropDownTimezone">
  245. <option value="-12:00" <?php if(get_option('SE_timezone') == "-12:00") echo "selected";?>>(GMT -12:00) Eniwetok, Kwajalein</option>
  246. <option value="-11:00" <?php if(get_option('SE_timezone') == "-11:00") echo "selected";?>>(GMT -11:00) Midway Island, Samoa</option>
  247. <option value="-10:00" <?php if(get_option('SE_timezone') == "-10:00") echo "selected";?>>(GMT -10:00) Hawaii</option>
  248. <option value="-09:00" <?php if(get_option('SE_timezone') == "-09:00") echo "selected";?>>(GMT -9:00) Alaska</option>
  249. <option value="-08:00" <?php if(get_option('SE_timezone') == "-08:00") echo "selected";?>>(GMT -8:00) Pacific Time (US &amp; Canada)</option>
  250. <option value="-07:00" <?php if(get_option('SE_timezone') == "-07:00") echo "selected";?>>(GMT -7:00) Mountain Time (US &amp; Canada)</option>
  251. <option value="-06:00" <?php if(get_option('SE_timezone') == "-06:00") echo "selected";?>>(GMT -6:00) Central Time (US &amp; Canada), Mexico City</option>
  252. <option value="-05:00" <?php if(get_option('SE_timezone') == "-05:00") echo "selected";?>>(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>
  253. <option value="-04:00" <?php if(get_option('SE_timezone') == "-04:00") echo "selected";?>>(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
  254. <option value="-03:30" <?php if(get_option('SE_timezone') == "-03:30") echo "selected";?>>(GMT -3:30) Newfoundland</option>
  255. <option value="-03:00" <?php if(get_option('SE_timezone') == "-03:00") echo "selected";?>>(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
  256. <option value="-02:00" <?php if(get_option('SE_timezone') == "-02:00") echo "selected";?>>(GMT -2:00) Mid-Atlantic</option>
  257. <option value="-01:00" <?php if(get_option('SE_timezone') == "-01:00") echo "selected";?>>(GMT -1:00 hour) Azores, Cape Verde Islands</option>
  258. <option value="+00:00" <?php if(get_option('SE_timezone') == "+00:00") echo "selected";?>>(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
  259. <option value="+01:00" <?php if(get_option('SE_timezone') == "+01:00") echo "selected";?>>(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris</option>
  260. <option value="+02:00" <?php if(get_option('SE_timezone') == "+02:00") echo "selected";?>>(GMT +2:00) Kaliningrad, South Africa</option>
  261. <option value="+03:00" <?php if(get_option('SE_timezone') == "+03:00") echo "selected";?>>(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
  262. <option value="+03:30" <?php if(get_option('SE_timezone') == "+03:30") echo "selected";?>>(GMT +3:30) Tehran</option>
  263. <option value="+04:00" <?php if(get_option('SE_timezone') == "+04:00") echo "selected";?>>(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
  264. <option value="+04:30" <?php if(get_option('SE_timezone') == "+04:30") echo "selected";?>>(GMT +4:30) Kabul</option>
  265. <option value="+05:00" <?php if(get_option('SE_timezone') == "+05:00") echo "selected";?>>(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
  266. <option value="+05:30" <?php if(get_option('SE_timezone') == "+05:30") echo "selected";?>>(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>
  267. <option value="+05:45" <?php if(get_option('SE_timezone') == "+05:45") echo "selected";?>>(GMT +5:45) Kathmandu</option>
  268. <option value="+06:00" <?php if(get_option('SE_timezone') == "+06:00") echo "selected";?>>(GMT +6:00) Almaty, Dhaka, Colombo</option>
  269. <option value="+07:00" <?php if(get_option('SE_timezone') == "+07:00") echo "selected";?>>(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
  270. <option value="+08:00" <?php if(get_option('SE_timezone') == "+08:00") echo "selected";?>>(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
  271. <option value="+09:00" <?php if(get_option('SE_timezone') == "+09:00") echo "selected";?>>(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
  272. <option value="+09:30" <?php if(get_option('SE_timezone') == "+09:30") echo "selected";?>>(GMT +9:30) Adelaide, Darwin</option>
  273. <option value="+10:00" <?php if(get_option('SE_timezone') == "+10:00") echo "selected";?>>(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
  274. <option value="+11:00" <?php if(get_option('SE_timezone') == "+11:00") echo "selected";?>>(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
  275. <option value="+12:00" <?php if(get_option('SE_timezone') == "+12:00") echo "selected";?>>(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
  276. </select>
  277.  
  278. </p>
  279. <p><?php _e('How to open the event links?',SE_TEXTDOMAIN);?>
  280. <select name="SE_links">
  281. <option value="both" <?php if(get_option('SE_links') == "both") echo "selected";?>><?php _e('Open both links in a new window',SE_TEXTDOMAIN);?></option>
  282. <option value="location" <?php if(get_option('SE_links') == "location") echo "selected";?>><?php _e('Open only the Location link in a new window',SE_TEXTDOMAIN);?></option>
  283. <option value="information" <?php if(get_option('SE_links') == "information") echo "selected";?>><?php _e('Open only the More Information link in a new window',SE_TEXTDOMAIN);?></option>
  284. <option value="none" <?php if(get_option('SE_links') == "none") echo "selected";?>><?php _e('Open both links in the same window',SE_TEXTDOMAIN);?></option>
  285. </select>
  286. <?php if (current_user_can('manage_options')) { ?>
  287. <p><?php _e('Who can manage events?',SE_TEXTDOMAIN);?>
  288. <select name="SE_author">
  289. <option value="manage_options" <?php if(get_option('SE_author') == "manage_options") echo "selected";?>>Administrator</option>
  290. <option value="publish_pages" <?php if(get_option('SE_author') == "publish_pages") echo "selected";?>>Editor</option>
  291. <option value="publish_posts" <?php if(get_option('SE_author') == "publish_posts") echo "selected";?>>Author</option>
  292. <option value="edit_posts" <?php if(get_option('SE_author') == "edit_posts") echo "selected";?>>Contributor</option>
  293. <option value="read" <?php if(get_option('SE_author') == "read") echo "selected";?>>Subscriber</option>
  294. </select>
  295. </p>
  296. <?php } ?>
  297. <p>
  298. <label><input type="checkbox" name="SE_twitter" value="no" <?php if(get_option('SE_twitter') == "no") echo "checked";?> /> <?php _e('Disable Twitter',SE_TEXTDOMAIN);?></label>
  299. <span class="explanation"><?php _e('By disabling Twitter, the JavaScript of the Twitter API will not be loaded for this plugin.',SE_TEXTDOMAIN);?></span>
  300. </p>
  301. <p class="submit">
  302. <input name="SEsettingsUpdate" type="submit" value="<?php _e('Update settings',SE_TEXTDOMAIN)?>" class="button-primary" />
  303. </p>
  304. </form>
  305.  
  306. </div>
  307.  
  308. <?php if(isset($_POST['edit'])) { ?>
  309. <?php
  310. global $wpdb;
  311. $table_name = $wpdb->prefix . "simple_events";
  312. $edit_event = $_POST['event_id'];
  313. $update = $wpdb->get_results(" SELECT * FROM $table_name WHERE id = $edit_event ", "ARRAY_A");
  314. ?>
  315. <h3><?php _e('Redigere begivenhed:',SE_TEXTDOMAIN);?></h3>
  316. <table>
  317. <tbody>
  318. <form method="post">
  319. <?php
  320. $year = date('Y',$update[0]['event_start']);
  321. $month = date('n',$update[0]['event_start']);
  322. $day = date('j',$update[0]['event_start']);
  323. $start_timeH = date('G',$update[0]['event_start']);
  324. $start_timeM = date('i',$update[0]['event_start']);
  325. $end_year = date('Y',$update[0]['event_end']);
  326. $end_month = date('n',$update[0]['event_end']);
  327. $end_day = date('j',$update[0]['event_end']);
  328. $end_timeH = date('G',$update[0]['event_end']);
  329. $end_timeM = date('i',$update[0]['event_end']);
  330. ?>
  331. <tr>
  332. <th class="se_entry_start"><?php _e('Start dato:',SE_TEXTDOMAIN);?></th>
  333. <td>
  334. <select name="event[event_start_day]"> <!-- ## EVENT START DAY ## -->
  335. <?php $i = 0;
  336. while($i < 31) {
  337. $i++;
  338. if($day != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  339. } ?>
  340. </select>
  341. <select name="event[event_start_month]"> <!-- ## EVENT START MONTH ## -->
  342. <?php $i = 0;
  343. while($i < 12) {
  344. $i++;
  345. if($month != $i) echo '<option value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y'))) . '</options>'; else echo '<option selected value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y') )) . '</options>';
  346. } ?>
  347. </select>
  348. <select name="event[event_start_yr]"> <!-- ## EVENT START YEAR ## -->
  349. <?php $i = 1979;
  350. while($i < 2020) {
  351. $i++;
  352. if($year != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  353. } ?>
  354. </select>
  355. </td>
  356. </tr>
  357. <tr>
  358. <th class="se_entry_title"><?php _e('Start tid:',SE_TEXTDOMAIN);?></th>
  359. <td>
  360. <select name="event[event_start_hr]"> <!-- ## EVENT START HOUR ## -->
  361. <?php $i = 0;
  362. while($i < 24) {
  363. if($start_timeH != $i) echo '<option value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>'; else echo '<option selected value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>';
  364. $i++;
  365. } ?>
  366. </select>
  367. <select name="event[event_start_mn]">
  368. <option <?php if($start_timeM == 0) echo "selected";?> value="0">00</option>
  369. <option <?php if($start_timeM == 5) echo "selected";?> value="5">05</option>
  370. <option <?php if($start_timeM == 10) echo "selected";?> value="10">10</option>
  371. <option <?php if($start_timeM == 15) echo "selected"; ?> value="15">15</option>
  372. <option <?php if($start_timeM == 20) echo "selected";?> value="20">20</option>
  373. <option <?php if($start_timeM == 25) echo "selected";?> value="25">25</option>
  374. <option <?php if($start_timeM == 30) echo "selected";?> value="30">30</option>
  375. <option <?php if($start_timeM == 35) echo "selected"; ?> value="35">35</option>
  376. <option <?php if($start_timeM == 40) echo "selected";?> value="40">40</option>
  377. <option <?php if($start_timeM == 45) echo "selected";?> value="45">45</option>
  378. <option <?php if($start_timeM == 50) echo "selected";?> value="50">50</option>
  379. <option <?php if($start_timeM == 55) echo "selected"; ?> value="55">55</option>
  380. </select>
  381. </td>
  382. </tr>
  383. <tr>
  384. <th class="se_entry_start"><?php _e('Slut dato:',SE_TEXTDOMAIN);?></th>
  385. <td>
  386. <select name="event[event_end_day]"> <!-- ## EVENT END DAY ## -->
  387. <?php $i = 0;
  388. while($i < 31) {
  389. $i++;
  390. if($end_day != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  391. } ?>
  392. </select>
  393. <select name="event[event_end_month]"> <!-- ## EVENT END MONTH ## -->
  394. <?php $i = 0;
  395. while($i < 12) {
  396. $i++;
  397. if($end_month != $i) echo '<option value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y') )) . '</options>'; else echo '<option selected value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y') )) . '</options>';
  398. } ?>
  399. </select>
  400. <select name="event[event_end_yr]"> <!-- ## EVENT END YEAR ## -->
  401. <?php $i = 1979;
  402. while($i < 2020) {
  403. $i++;
  404. if($end_year != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  405. } ?>
  406. </select>
  407. </td>
  408. </tr>
  409. <tr>
  410. <th class="se_entry_title"><?php _e('Slut tid:',SE_TEXTDOMAIN);?></th>
  411. <td>
  412. <select name="event[event_end_hr]"> <!-- ## EVENT END HOUR ## -->
  413. <?php $i = 0;
  414. while($i < 24) {
  415. if($end_timeH != $i) echo '<option value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>'; else echo '<option selected value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>';
  416. $i++;
  417. } ?>
  418. </select>
  419. <select name="event[event_end_mn]">
  420. <option <?php if($end_timeM == 0) echo "selected";?> value="0">00</option>
  421. <option <?php if($end_timeM == 5) echo "selected";?> value="5">05</option>
  422. <option <?php if($end_timeM == 10) echo "selected";?> value="10">10</option>
  423. <option <?php if($end_timeM == 15) echo "selected"; ?> value="15">15</option>
  424. <option <?php if($end_timeM == 20) echo "selected";?> value="20">20</option>
  425. <option <?php if($end_timeM == 25) echo "selected";?> value="25">25</option>
  426. <option <?php if($end_timeM == 30) echo "selected";?> value="30">30</option>
  427. <option <?php if($end_timeM == 35) echo "selected"; ?> value="35">35</option>
  428. <option <?php if($end_timeM == 40) echo "selected";?> value="40">40</option>
  429. <option <?php if($end_timeM == 45) echo "selected";?> value="45">45</option>
  430. <option <?php if($end_timeM == 50) echo "selected";?> value="50">50</option>
  431. <option <?php if($end_timeM == 55) echo "selected"; ?> value="55">55</option>
  432. </select>
  433. </td>
  434. </tr>
  435.  
  436. <tr>
  437. <th class="se_entry_title"><?php _e('Beskrivelse (skal udfyldes):',SE_TEXTDOMAIN);?></th>
  438. <td>
  439. <input name="event[event_title]" size="80" type="text" value="<?php echo $update[0]['event_title'];?>" />
  440. </td>
  441. </tr>
  442. <tr>
  443. <th class="se_entry_description"><?php _e('Tilmelding:',SE_TEXTDOMAIN);?></th>
  444. <td>
  445.  
  446. <textarea class="textarea1" cols="51" rows="5" name="event[event_desc]"><?php echo stripslashes($update[0]['event_desc']);?></textarea>
  447. </td>
  448. </tr>
  449. <tr>
  450. <th class="se_entry_label"><?php _e('Label:',SE_TEXTDOMAIN);?></th>
  451. <td>
  452. <input name="event[event_label]" type="text" size="15" maxlength="10" value="<?php echo $update[0]['event_label'];?>" />
  453. <span class="labelnote"><?php _e('Max. 10 karaktere.',SE_TEXTDOMAIN);?></span>
  454. </td>
  455. </tr>
  456. <tr>
  457. <th class="se_entry_url"><?php _e('Kalender URL:',SE_TEXTDOMAIN);?></th>
  458. <td>
  459. <input name="event[event_url]" size="80" type="text" value="<?php echo $update[0]['event_url'];?>" />
  460. </td>
  461. </tr>
  462. <tr>
  463. <th class="se_entry_loc"><?php _e('Lokation:',SE_TEXTDOMAIN);?></th>
  464. <td>
  465. <input name="event[event_loc]" size="80" type="text" value="<?php echo $update[0]['event_loc'];?>" />
  466. </td>
  467. </tr>
  468. <tr>
  469. <th class="se_entry_loc_url"><?php _e('Lokation URL:',SE_TEXTDOMAIN);?></th>
  470. <td>
  471. <input name="event[event_loc_url]" size="80" type="text" value="<?php echo $update[0]['event_loc_url'];?>" />
  472. </td>
  473. </tr>
  474. <tr>
  475. <th>
  476. </th>
  477. <td>
  478. <p class="submit">
  479. <input type="hidden" name="eventid" value="<?php echo $edit_event;?>" />
  480. <input name="update_event" type="submit" value="<?php _e('Opdatere begivenhed',SE_TEXTDOMAIN)?>" class="button-primary" />
  481. <input type="hidden" name="action" value="save" />
  482. </p>
  483. </td>
  484. </tr>
  485. </form>
  486. </tbody>
  487. </table>
  488.  
  489. <?php } else { // if not editing an existing event then add a new one ?>
  490. <h3><?php _e('Ny begivenhed:',SE_TEXTDOMAIN);?></h3>
  491. <table>
  492. <tbody>
  493. <form method="post">
  494. <?php
  495. $year = date('Y');
  496. $month = date('n');
  497. $day = date('j');
  498. $start_timeH = date('G');
  499. if(date('i') > 37) {
  500. $start_timeM = '45';
  501. } elseif(date('i') > 20) {
  502. $start_timeM = '30';
  503. } elseif(date('i') > 5) {
  504. $start_timeM = '15';
  505. } else {
  506. $start_timeM = '0';
  507. }
  508. $end_year = (date('Y',mktime(date('G')+1)));
  509. $end_month = (date('n',mktime(date('G')+1)));
  510. $end_day = (date('j',mktime(date('G')+1)));
  511. $end_timeH = (date('G',mktime(date('G')+1)));
  512. ?>
  513. <tr>
  514. <th class="se_entry_start"><?php _e('Start dato:',SE_TEXTDOMAIN);?></th>
  515. <td>
  516. <select name="event[event_start_day]">
  517. <?php $i = 0;
  518. while($i < 31) {
  519. $i++;
  520. if($day != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  521. } ?>
  522. </select>
  523. <select name="event[event_start_month]"> <!-- ## EVENT START MONTH ## -->
  524. <?php $i = 0;
  525. while($i < 12) {
  526. $i++;
  527. if($month != $i) echo '<option value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y') )) . '</options>'; else echo '<option selected value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y') )) . '</options>';
  528. } ?>
  529. </select>
  530. <select name="event[event_start_yr]"> <!-- ## EVENT START YEAR ## -->
  531. <?php $i = 1979;
  532. while($i < 2020) {
  533. $i++;
  534. if($year != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  535. } ?>
  536. </select>
  537. </td>
  538. </tr>
  539. <tr>
  540. <th class="se_entry_title"><?php _e('Tidspunkt:',SE_TEXTDOMAIN);?></th>
  541. <td>
  542. <select name="event[event_start_hr]"> <!-- ## EVENT START HOUR ## -->
  543. <?php $i = 0;
  544. while($i < 24) {
  545. if($start_timeH != $i) echo '<option value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>'; else echo '<option selected value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>';
  546. $i++;
  547. } ?>
  548. </select>
  549. <select name="event[event_start_mn]">
  550. <option <?php if($start_timeM == 0) echo "selected";?> value="0">00</option>
  551. <option <?php if($start_timeM == 5) echo "selected";?> value="5">05</option>
  552. <option <?php if($start_timeM == 10) echo "selected";?> value="10">10</option>
  553. <option <?php if($start_timeM == 15) echo "selected"; ?> value="15">15</option>
  554. <option <?php if($start_timeM == 20) echo "selected";?> value="20">20</option>
  555. <option <?php if($start_timeM == 25) echo "selected";?> value="25">25</option>
  556. <option <?php if($start_timeM == 30) echo "selected";?> value="30">30</option>
  557. <option <?php if($start_timeM == 35) echo "selected"; ?> value="35">35</option>
  558. <option <?php if($start_timeM == 40) echo "selected";?> value="40">40</option>
  559. <option <?php if($start_timeM == 45) echo "selected";?> value="45">45</option>
  560. <option <?php if($start_timeM == 50) echo "selected";?> value="50">50</option>
  561. <option <?php if($start_timeM == 55) echo "selected"; ?> value="55">55</option>
  562. </select>
  563. </td>
  564. </tr>
  565. <tr>
  566. <th class="se_entry_start"><?php _e('Slut dato:',SE_TEXTDOMAIN);?></th>
  567. <td>
  568. <select name="event[event_end_day]"> <!-- ## EVENT END DAY ## -->
  569. <?php $i = 0;
  570. while($i < 31) {
  571. $i++;
  572. if($end_day != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  573. } ?>
  574. </select>
  575. <select name="event[event_end_month]"> <!-- ## EVENT END MONTH ## -->
  576. <?php $i = 0;
  577. while($i < 12) {
  578. $i++;
  579. if($end_month != $i) echo '<option value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y') )) . '</options>'; else echo '<option selected value="' . $i . '">' . date('F', mktime(0,0,0, $i, 1, date('Y') )) . '</options>';
  580. } ?>
  581. </select>
  582. <select name="event[event_end_yr]"> <!-- ## EVENT END YEAR ## -->
  583.  
  584. <?php $i = 1979;
  585. while($i < 2020) {
  586. $i++;
  587. if($end_year != $i) echo '<option value="' . $i . '">' . $i . '</options>'; else echo '<option selected value="' . $i . '">' . $i . '</options>';
  588. } ?>
  589. </select>
  590. </td>
  591. </tr>
  592. <tr>
  593. <th class="se_entry_title"><?php _e('Tidspunkt:',SE_TEXTDOMAIN);?></th>
  594. <td>
  595. <select name="event[event_end_hr]"> <!-- ## EVENT END HOUR ## -->
  596. <?php $i = 0;
  597. while($i < 24) {
  598. if($end_timeH != $i) echo '<option value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>'; else echo '<option selected value="' . $i . '">' . date('H', mktime( $i ,0,0,0 )) . '</options>';
  599. $i++;
  600. } ?>
  601. </select>
  602. <select name="event[event_end_mn]">
  603. <option <?php if($start_timeM == 0) echo "selected";?> value="0">00</option>
  604. <option <?php if($start_timeM == 5) echo "selected";?> value="5">05</option>
  605. <option <?php if($start_timeM == 10) echo "selected";?> value="10">10</option>
  606. <option <?php if($start_timeM == 15) echo "selected"; ?> value="15">15</option>
  607. <option <?php if($start_timeM == 20) echo "selected";?> value="20">20</option>
  608. <option <?php if($start_timeM == 25) echo "selected";?> value="25">25</option>
  609. <option <?php if($start_timeM == 30) echo "selected";?> value="30">30</option>
  610. <option <?php if($start_timeM == 35) echo "selected"; ?> value="35">35</option>
  611. <option <?php if($start_timeM == 40) echo "selected";?> value="40">40</option>
  612. <option <?php if($start_timeM == 45) echo "selected";?> value="45">45</option>
  613. <option <?php if($start_timeM == 50) echo "selected";?> value="50">50</option>
  614. <option <?php if($start_timeM == 55) echo "selected"; ?> value="55">55</option>
  615. </select>
  616. </td>
  617. </tr>
  618.  
  619. <tr>
  620. <th class="se_entry_title"><?php _e('Beskrivelse (skal udfyldes):',SE_TEXTDOMAIN);?></th>
  621. <td>
  622. <input name="event[event_title]" size="80" type="text" />
  623. </td>
  624. </tr>
  625. <tr>
  626. <th class="se_entry_description"><?php _e('Tilmelding:',SE_TEXTDOMAIN);?></th>
  627. <td>
  628. <textarea class="textarea1" cols="51" rows="5" name="event[event_desc]"></textarea>
  629. </td>
  630. </tr>
  631. <tr>
  632. <th class="se_entry_label"><?php _e('Label:',SE_TEXTDOMAIN);?></th>
  633. <td>
  634. <input name="event[event_label]" type="text" size="15" maxlength="10" />
  635. <span class="labelnote"><?php _e('Max. 10 karaktere.',SE_TEXTDOMAIN);?></span>
  636. </td>
  637. </tr>
  638. <tr>
  639. <th class="se_entry_url"><?php _e('Kalender URL:',SE_TEXTDOMAIN);?></th>
  640. <td>
  641. <input name="event[event_url]" size="80" type="text" />
  642. </td>
  643. </tr>
  644. <tr>
  645. <th class="se_entry_loc"><?php _e('Lokation:',SE_TEXTDOMAIN);?></th>
  646. <td>
  647. <input name="event[event_loc]" size="80" type="text" />
  648. </td>
  649. </tr>
  650. <tr>
  651. <th class="se_entry_loc_url"><?php _e('Lokation URL:',SE_TEXTDOMAIN);?></th>
  652. <td>
  653. <input name="event[event_loc_url]" size="80" type="text" />
  654. </td>
  655. </tr>
  656. <tr>
  657. <th>
  658. </th>
  659. <td>
  660. <p class="submit">
  661. <input name="store_event" type="submit" value="<?php _e('Gem begivenhed',SE_TEXTDOMAIN)?>" class="button-primary" />
  662. <input type="hidden" name="action" value="save" />
  663. </p>
  664. </td>
  665. </tr>
  666. </form>
  667. </tbody>
  668. </table>
  669. <?php } // End Edit or Add check ?>
  670.  
  671. <!-- Displaying the stored events: -->
  672. <?php
  673.  
  674. global $wpdb;
  675. $table_name = $wpdb->prefix . "simple_events";
  676. $myevents = $wpdb->get_results(" SELECT * FROM $table_name ORDER BY event_start ", "ARRAY_A");
  677. if(count($myevents) > 0) { ?>
  678.  
  679. <h3><?php _e('Allerede indtastede begivenheder:',SE_TEXTDOMAIN);?></h3>
  680. <table cellspacing="5" width="600">
  681.  
  682. <?php // Delete event button
  683. if(isset($_POST['delete'])) {
  684. $remove_event = $_POST['event_id'];
  685. $wpdb->query(" DELETE FROM $table_name WHERE id = $remove_event ");
  686. }
  687.  
  688. // Display all events currently stored in the database
  689. setlocale(LC_ALL, get_locale());
  690. foreach($myevents as $details) { ?>
  691. <tbody class="<?php if ($details['event_end'] < time()) { echo 'expired'; } else { echo 'upcoming'; } ?>">
  692. <tr>
  693. <th class="eventtitle" colspan="3"><form method="post"><input type="hidden" name="event_id" value="<?php echo $details['id'];?>" /><input type="submit" name="edit" value="<?php _e('Edit',SE_TEXTDOMAIN);?>" class="iconsprite editicon" /><input type="submit" name="delete" value="<?php _e('Remove',SE_TEXTDOMAIN);?>" class="iconsprite binicon" /></form> <?php echo stripslashes($details['event_title']);?></th>
  694. </tr>
  695. <tr>
  696. <td class="eventdescription" colspan="3"><?php echo stripslashes(nl2br($details['event_desc']));?></td>
  697. </tr>
  698. <tr>
  699. <td class="eventstart" width="33%"><?php echo strftime(DATE ." ". YEAR, $details['event_start']);?><br /><?php echo strftime(TIME, $details['event_start']);?></td>
  700. <td class="eventend" width="33%"><?php echo strftime(DATE ." ". YEAR, $details['event_end']);?><br /><?php echo strftime(TIME, $details['event_end']);?></td>
  701. <td></td>
  702. </tr>
  703. <tr>
  704. <td class="eventlocation">
  705. <?php if($details['event_loc'] != "" && $details['event_loc_url'] != "") {
  706. echo '<span class="iconsprite locationicon"></span> <a class="eventlinks" href="'.httpprefix($details['event_loc_url']).'">'.$details['event_loc'].'</a>';
  707. } elseif($details['event_loc'] != "" ) {
  708. echo '<span class="iconsprite locationicon"></span> '.$details['event_loc'];
  709. } elseif($details['event_loc_url'] != "" ) {
  710. echo '<span class="iconsprite locationicon"></span> <a class="eventlinks" href="'.httpprefix($details['event_loc_url']).'">'.shortenstring(httpprefix($details['event_loc_url']),30).'</a>';
  711. } else {
  712. echo '<span class="iconsprite nolocationicon"></span>';
  713. }
  714.  
  715.  
  716. ?></td>
  717. <td class="viewlabel">
  718. <?php if($details['event_label'] != "") { ?>
  719. <span class="iconsprite labelicon"></span><span class="eventlabel" title="<?php _e('When including this label on your page when displaying events, only events with this label will be displayed',SE_TEXTDOMAIN);?>"><?php echo $details['event_label'];?></span>
  720. <?php } else { ?>
  721. <span class="iconsprite nolabelicon"></span>
  722. <?php } ?>
  723. </td>
  724. <td>
  725. <?php if($details['event_url'] != "") {
  726. echo '<span class="iconsprite linkicon"></span> <a class="eventlinks" href="'.httpprefix($details['event_url']).'" title="'.httpprefix($details['event_url']).'">'.shortenstring(httpprefix($details['event_url']),30).'</a>';
  727. } else {
  728. echo '<span class="iconsprite nolinkicon"></span>';
  729. } ?>
  730. </td>
  731. </tr>
  732. <tr><td colspan="3"><hr /></td></tr>
  733. </tbody>
  734. <?php } // end foreach stored events display table ?>
  735. </table>
  736. <?php }
  737. // end check if anything was stored in the DB
  738. ?>
  739. </div>
  740. <?php } // End of simple_events_options function
  741.  
  742. // Add the shortcode for displaying the event on pages
  743. function displayevents( $atts ) {
  744. setlocale(LC_ALL, get_locale());
  745.  
  746. // VARIATIONS: EXPIRED / ALL / UPCOMING
  747. isset($atts['age']) ? $age = $atts['age'] : $age = NULL;
  748. $range = age($age);
  749.  
  750. // See if Label filter is used
  751. $label = NULL;
  752. if(isset($atts['label'])) $label = strtolower($atts['label']);
  753.  
  754. // See if a limit has been set
  755. if( isset($atts['limit']) && $atts['limit'] > 0 ) {
  756. $limit = "LIMIT 0, " . $atts['limit'];
  757. } else {
  758. $limit = "";
  759. }
  760.  
  761. $allevents = array();
  762. $allevents = eventquery($label,$age,$range,$limit);
  763.  
  764. $i = 1;
  765. foreach ($allevents as $event) {
  766. // decide what needs to be mentioned in the start date
  767. if(date('Y',$event['event_start']) == date('Y',time())) {
  768. $eventtime = strftime(DATE .' '. TIME,$event['event_start']);
  769. $shorttime = strftime(DATE,$event['event_start']);
  770. } else {
  771. $eventtime = strftime(DATE . ' ' . YEAR . ' ' . TIME,$event['event_start']);
  772. $shorttime = strftime(DATE,$event['event_start']);
  773. }
  774.  
  775. // decide what needs to be mentioned in the end date
  776. if(date('Y',$event['event_end']) == date('Y',$event['event_start'])) { $end_year = "same"; } else { $end_year = "diff";}
  777. if(date('dmy',$event['event_end']) == date('dmy',$event['event_start'])) { $end_date = "same"; } else { $end_date = "diff";}
  778.  
  779. // Check how to open the links
  780. if(get_option('SE_links') == "none") { $targetLoc = "_self"; $targetInf = "_self"; }
  781. elseif(get_option('SE_links') == "both") { $targetLoc = "_blank"; $targetInf = "_blank"; }
  782. elseif(get_option('SE_links') == "location") { $targetLoc = "_blank"; $targetInf = "_self"; }
  783. elseif(get_option('SE_links') == "information") { $targetLoc = "_self"; $targetInf = "_blank"; }
  784.  
  785. // decide if the event location should be a URL
  786. $evt_loc = NULL;
  787. if($event['event_loc'] != "" && $event['event_loc_url'] != "" ) {
  788. $evt_loc = '<div><span class="event-label">'.__('Where:',SE_TEXTDOMAIN).' </span><a class="location" href="'.httpprefix($event['event_loc_url']).'" target="'.$targetLoc.'">'.$event['event_loc'].'</a></div>';
  789. } elseif($event['event_loc'] != "") {
  790. $evt_loc = '<div><span class="event-label">'.__('Where:',SE_TEXTDOMAIN).' </span>'.$event['event_loc'].'</div>';
  791. }
  792.  
  793. // Check if more info link should be displayed
  794. $evt_url = NULL;
  795. if(isset($atts['moreinfo']) && $atts['moreinfo'] == "no" ) {
  796. $evt_url = "";
  797. } elseif($event['event_url'] != "" ) {
  798. $evt_url = '<div class="info-link"><a class="url" href="'.httpprefix($event['event_url']).'" target="'.$targetInf.'">'.__('More information...',SE_TEXTDOMAIN).'</a></div>';
  799. }
  800.  
  801. // Check if tweet button should be displayed
  802. if(isset($atts['tweet']) && $atts['tweet'] == "no" || get_option('SE_twitter') == "no") {
  803. $evt_twt = "";
  804. } else {
  805. $evt_twt = '<div><a href="http://twitter.com/share" class="twitter-share-button" data-url="'.httpprefix($event['event_url']).'" data-text="'.stripslashes($event['event_title']).' '.$shorttime.' in '. $event['event_loc'] .'" data-count="none" data-via="wpsec">Tweet</a></div>';
  806. }
  807.  
  808. // Check if and how the times should be displayed
  809. $tz = get_option('SE_timezone');
  810. $start_time = '<span class="event-label">'.__('When:',SE_TEXTDOMAIN).' </span><abbr class="dtstart" title="'.date('Y-m-d',$event['event_start']).'T'.date('H:i',$event['event_start']).$tz.'">'.$eventtime.'</abbr>';
  811. $start_notime = '<span class="event-label">'.__('When:',SE_TEXTDOMAIN).' </span><abbr class="dtstart" title="'.date('Y-m-d',$event['event_start']).'">'.$shorttime.'</abbr>';
  812. if(isset($atts['time']) && $atts['time'] == "no") {
  813. if($end_date == "same") {
  814. $evt_time = $start_notime;
  815. } elseif($end_year == "same") {
  816. $evt_time = $start_notime . '<abbr class="dtend" title="'.date('Y-m-d',$event['event_end']).'"> - '. strftime(DATE,$event['event_end']) .'</abbr>';
  817. } else {
  818. $evt_time = $start_notime . '<abbr class="dtend" title="'.date('Y-m-d',$event['event_end']).'"> - '. strftime(DATE . " " . YEAR,$event['event_end']) .'</abbr>';
  819. }
  820. } elseif( isset($atts['time']) && $atts['time'] == "start") {
  821. $evt_time = $start_time;
  822. } elseif($end_date == "same") {
  823. $evt_time = $start_time . ' - <abbr class="dtend" title="'.date('Y-m-d',$event['event_end']).'T'.date('H:i',$event['event_end']).$tz.'">'. strftime( TIME ,$event['event_end']) .'</abbr>';
  824. } elseif($end_year == "same") {
  825. $evt_time = $start_time . ' - <abbr class="dtend" title="'.date('Y-m-d',$event['event_end']).'T'.date('H:i',$event['event_end']).$tz.'">'. strftime(DATE ." ".TIME,$event['event_end']) .'</abbr>';
  826. } else {
  827. $evt_time = $start_time . ' - <abbr class="dtend" title="'.date('Y-m-d',$event['event_end']).'T'.date('H:i',$event['event_end']).$tz.'">'. strftime(DATE ." ".YEAR." ".TIME,$event['event_end']) .'</abbr>';
  828. }
  829.  
  830. if($i % 2) $evt_no = "odd"; else $evt_no = "even"; // adding odd and even classes for styling options
  831. $the_events[] =
  832. '<div class="vevent event-item '.$evt_no.' event-'.$i.'">'.
  833. '<div class="section group">'.
  834. '<div class="col span_1_of_4">'.
  835. $evt_time.
  836. '</div><div class="col span_1_of_4">'.
  837. stripslashes($event['event_title']).
  838. '</div><div class="col span_1_of_4">'.
  839. $evt_loc.
  840. $evt_url.
  841. $evt_twt.
  842. '</div>'.
  843. '<div class="col span_1_of_4">'.
  844. stripslashes(nl2br($event['event_desc'])).
  845. '</div></div></div>';
  846. $i++;
  847. } // end foreach ($allevents as $event)
  848. if(count($allevents) > 0) $items = implode($the_events); else $items = "There are no events to display";
  849. return($items);
  850. }
  851. add_shortcode( 'events', 'displayevents' );
  852.  
  853. function age($age) {
  854. if($age == "expired") {
  855. $range = "event_end <= " . time();
  856. } elseif($age == "all") {
  857. $range = "event_end > 315532800"; // timestamp for jan 1st 1980 - assuming no event will be creted before that date
  858. } else {
  859. $range = "event end > " . time();
  860. }
  861. return $range;
  862. }
  863.  
  864.  
  865. function eventquery($label,$age,$range,$limit) {
  866. global $wpdb;
  867. $table_name = $wpdb->prefix . "simple_events";
  868. if(!is_null($age) && !is_null($label)) {
  869. $conditions = "WHERE event_label = '$label' AND $range ORDER BY event_start $limit";
  870. } elseif(!is_null($age)) {
  871. $conditions = "WHERE $range ORDER BY event_start $limit";
  872. } elseif(!is_null($label)) {
  873. $currentTime = time();
  874. $conditions = "WHERE event_label = '$label' AND event_end >= $currentTime ORDER BY event_start $limit";
  875. } else {
  876. $currentTime = time();
  877. $conditions = "WHERE event_end >= $currentTime ORDER BY event_start $limit";
  878. }
  879.  
  880. return $wpdb->get_results(" SELECT * FROM $table_name " . $conditions , "ARRAY_A");
  881.  
  882. }
  883.  
  884. // function to check url and set http prefix if needed
  885. function httpprefix($httpurl) {
  886. $httpurl = strtolower($httpurl);
  887. if(substr($httpurl,0,4) == "http") {
  888. $fullurl = $httpurl;
  889. } else {
  890. $fullurl = "http://".$httpurl;
  891. }
  892. return $fullurl;
  893. }
  894.  
  895. // function to shorten long strings to $length characters and to prepend ... if it was actually shortend
  896. function shortenstring($strng,$length) {
  897. if(strlen($strng) > $length) $longer = '...'; else $longer = '';
  898. return substr($strng,0,$length).$longer;
  899. }
  900.  
  901. function sec_head() {
  902. global $sec_options;
  903. echo "\n<!-- Simple Events Calendar ".SE_VERSION." by Jerry G. Rietveld of Studio Stacks (www.studiostacks.com) -->";
  904. echo "\n<link rel=\"profile\" href=\"http://microformats.org/profile/hcalendar\" />\n\n";
  905. if(!is_admin() && get_option('SE_ext_css') == "no") {
  906. wp_enqueue_style('sec-styling', SE_DOMAIN .'simple-events-calendar.css', false, SE_VERSION, "all");
  907. } elseif(!is_admin() && get_option('SE_ext_css') == "yes") {
  908. $themedir = get_bloginfo('template_url') . "/";
  909. wp_enqueue_style('sec-styling', $themedir .'simple-events-calendar.css', false, SE_VERSION, "all");
  910. }
  911. }
  912. add_action('wp_head', 'sec_head');
  913.  
  914. function SE_public_scripts() {
  915. global $sec_options;
  916. if(!is_admin() && get_option('SE_twitter') == "yes") wp_enqueue_script('tweetevents', 'http://platform.twitter.com/widgets.js', '', SE_VERSION , true);
  917. }
  918. add_action( 'wp_enqueue_scripts', 'SE_public_scripts' );
  919.  
  920. function SE_admin_scripts() {
  921. wp_enqueue_script('textcounter', SE_PLUGIN . 'simple-events-calendar.js', '', SE_VERSION);
  922. }
  923. add_action( 'admin_enqueue_scripts', 'SE_admin_scripts' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement