SimpleCalendarAbstractsCalendar

The Calendar.

Defined (1)

The class is defined in the following location(s).

/includes/abstracts/calendar.php  
  1. abstract class Calendar { 
  2.  
  3. /** 
  4. * Calendar Id. 
  5. * @access public 
  6. * @var int 
  7. */ 
  8. public $id = 0; 
  9.  
  10. /** 
  11. * Calendar post object. 
  12. * @access public 
  13. * @var \WP_Post 
  14. */ 
  15. public $post = null; 
  16.  
  17. /** 
  18. * Calendar Type. 
  19. * @access public 
  20. * @var string 
  21. */ 
  22. public $type = ''; 
  23.  
  24. /** 
  25. * Calendar Name. 
  26. * @access public 
  27. * @var string 
  28. */ 
  29. public $name = ''; 
  30.  
  31. /** 
  32. * Feed type. 
  33. * @access public 
  34. * @var string 
  35. */ 
  36. public $feed = ''; 
  37.  
  38. /** 
  39. * Calendar start. 
  40. * @access public 
  41. * @var int 
  42. */ 
  43. public $start = 0; 
  44.  
  45. /** 
  46. * Calendar end. 
  47. * @access public 
  48. * @var int 
  49. */ 
  50. public $end = 0; 
  51.  
  52. /** 
  53. * Static calendar. 
  54. * @access public 
  55. * @var bool 
  56. */ 
  57. public $static = false; 
  58.  
  59. /** 
  60. * Today. 
  61. * @access public 
  62. * @var int 
  63. */ 
  64. public $today = 0; 
  65.  
  66. /** 
  67. * Time now. 
  68. * @access public 
  69. * @var int 
  70. */ 
  71. public $now = 0; 
  72.  
  73. /** 
  74. * Timezone offset. 
  75. * @access public 
  76. * @var int 
  77. */ 
  78. public $offset = 0; 
  79.  
  80. /** 
  81. * Timezone 
  82. * @access public 
  83. * @var string 
  84. */ 
  85. public $timezone = 'UTC'; 
  86.  
  87. /** 
  88. * Site timezone. 
  89. * @access public 
  90. * @var string 
  91. */ 
  92. public $site_timezone = 'UTC'; 
  93.  
  94. /** 
  95. * Date format. 
  96. * @access public 
  97. * @var string 
  98. */ 
  99. public $date_format = ''; 
  100.  
  101. /** 
  102. * Time format. 
  103. * @access public 
  104. * @var string 
  105. */ 
  106. public $time_format = ''; 
  107.  
  108. /** 
  109. * Date-time separator. 
  110. * @access public 
  111. * @var string 
  112. */ 
  113. public $datetime_separator = '@'; 
  114.  
  115. /** 
  116. * First day of the week. 
  117. * @access public 
  118. * @var int 
  119. */ 
  120. public $week_starts = 0; 
  121.  
  122. /** 
  123. * Events to display. 
  124. * @access public 
  125. * @var array 
  126. */ 
  127. public $events = array(); 
  128.  
  129. /** 
  130. * Errors. 
  131. * @access public 
  132. * @var array 
  133. */ 
  134. protected $errors = array(); 
  135.  
  136. /** 
  137. * Earliest event. 
  138. * @access public 
  139. * @var int 
  140. */ 
  141. public $earliest_event = 0; 
  142.  
  143. /** 
  144. * Latest event. 
  145. * @access public 
  146. * @var int 
  147. */ 
  148. public $latest_event = 0; 
  149.  
  150. /** 
  151. * Event builder content. 
  152. * @access public 
  153. * @var string 
  154. */ 
  155. public $events_template = ''; 
  156.  
  157. /** 
  158. * Calendar Views. 
  159. * The calendar available views. 
  160. * @access public 
  161. * @var array 
  162. */ 
  163. public $views = array(); 
  164.  
  165. /** 
  166. * Calendar View. 
  167. * The current view. 
  168. * @access public 
  169. * @var Calendar_View 
  170. */ 
  171. public $view = null; 
  172.  
  173. /** 
  174. * Calendar settings. 
  175. * @access protected 
  176. * @var array 
  177. */ 
  178. protected $settings = array(); 
  179.  
  180. /** 
  181. * Constructor. 
  182. * @since 3.0.0 
  183. * @param int|object|\WP_Post|Calendar $calendar 
  184. * @param string $view 
  185. */ 
  186. public function __construct( $calendar, $view = '' ) { 
  187.  
  188. // Set the post object. 
  189. $this->set_post_object( $calendar ); 
  190.  
  191. if ( ! is_null( $this->post ) ) { 
  192.  
  193. // Set calendar type and events source. 
  194. $this->set_taxonomies(); 
  195.  
  196. // Set calendar default datetime properties. 
  197. $this->set_timezone(); 
  198. $this->set_start_of_week(); 
  199. $this->set_static(); 
  200.  
  201. // Set calendar start. 
  202. $this->set_start(); 
  203.  
  204. // Set the events template. 
  205. $this->set_events_template(); 
  206.  
  207. // Get events source data. 
  208. $feed = simcal_get_feed( $this ); 
  209. if ( $feed instanceof Feed ) { 
  210. if ( ! empty( $feed->events ) ) { 
  211. if ( is_array( $feed->events ) ) { 
  212. $this->set_events( $feed->events ); 
  213. if ( 'use_calendar' == get_post_meta( $this->id, '_feed_timezone_setting', true ) ) { 
  214. $this->timezone = $feed->timezone; 
  215. $this->set_start(); 
  216. } elseif ( is_string( $feed->events ) ) { 
  217. $this->errors[] = $feed->events; 
  218.  
  219. // Set general purpose timestamps. 
  220. $now = Carbon::now( $this->timezone ); 
  221. $this->now = $now->getTimestamp(); 
  222. $this->today = $now->startOfDay()->getTimestamp(); 
  223. $this->offset = $now->getOffset(); 
  224.  
  225. // Set date time formatting. 
  226. $this->set_date_format(); 
  227. $this->set_time_format(); 
  228. $this->set_datetime_separator(); 
  229.  
  230. // Set earliest and latest event timestamps. 
  231. if ( $this->events && is_array( $this->events ) ) { 
  232. $this->earliest_event = intval( current( array_keys( $this->events ) ) ); 
  233. $this->latest_event = intval( key( array_slice( $this->events, -1, 1, true ) ) ); 
  234.  
  235. // Set calendar end. 
  236. $this->set_end(); 
  237.  
  238. // Set view. 
  239. if ( ! $view ) { 
  240.  
  241. $calendar_view = get_post_meta( $this->id, '_calendar_view', true ); 
  242. $calendar_view = isset( $calendar_view[ $this->type ] ) ? $calendar_view[ $this->type ] : ''; 
  243.  
  244. $view = esc_attr( $calendar_view ); 
  245.  
  246. // Get view. 
  247. $this->view = $this->get_view( $view ); 
  248.  
  249. /** 
  250. * Overloading __isset function with post meta. 
  251. * @since 3.0.0 
  252. * @param mixed $key Post meta key. 
  253. * @return bool 
  254. */ 
  255. public function __isset( $key ) { 
  256. return metadata_exists( 'post', $this->id, '_' . $key ); 
  257.  
  258. /** 
  259. * Overloading __get function with post meta. 
  260. * @since 3.0.0 
  261. * @param string $key Post meta key. 
  262. * @return mixed 
  263. */ 
  264. public function __get( $key ) { 
  265. $value = get_post_meta( $this->id, '_' . $key, true ); 
  266. if ( ! empty( $value ) ) { 
  267. $this->$key = $value; 
  268. return $value; 
  269.  
  270. /** 
  271. * Set post object and id. 
  272. * @since 3.0.0 
  273. * @param int|object|\WP_Post|Calendar $calendar 
  274. */ 
  275. public function set_post_object( $calendar ) { 
  276. if ( is_numeric( $calendar ) ) { 
  277. $this->id = absint( $calendar ); 
  278. $this->post = get_post( $this->id ); 
  279. } elseif ( $calendar instanceof Calendar ) { 
  280. $this->id = absint( $calendar->id ); 
  281. $this->post = $calendar->post; 
  282. } elseif ( $calendar instanceof \WP_Post ) { 
  283. $this->id = absint( $calendar->ID ); 
  284. $this->post = $calendar; 
  285. } elseif ( isset( $calendar->id ) && isset( $calendar->post ) ) { 
  286. $this->id = $calendar->id; 
  287. $this->post = $calendar->post; 
  288.  
  289. /** 
  290. * Return the calendar title. 
  291. * @since 3.0.0 
  292. * @return string 
  293. */ 
  294. public function get_title() { 
  295. $title = isset( $this->post->post_title ) ? $this->post->post_title : ''; 
  296. return apply_filters( 'simcal_calendar_title', $title ); 
  297.  
  298. /** 
  299. * Get the calendar post data. 
  300. * @since 3.0.0 
  301. * @return \WP_Post 
  302. */ 
  303. public function get_post_data() { 
  304. return $this->post; 
  305.  
  306. /** 
  307. * Set taxonomies. 
  308. * @since 3.0.0 
  309. * @access protected 
  310. */ 
  311. protected function set_taxonomies() { 
  312. // Set calendar type. 
  313. if ( $type = wp_get_object_terms( $this->id, 'calendar_type' ) ) { 
  314. $this->type = sanitize_title( current( $type )->name ); 
  315. } else { 
  316. $this->type = apply_filters( 'simcal_calendar_default_type', 'default-calendar' ); 
  317. // Set feed type. 
  318. if ( $feed_type = wp_get_object_terms( $this->id, 'calendar_feed' ) ) { 
  319. $this->feed = sanitize_title( current( $feed_type )->name ); 
  320. } else { 
  321. $this->feed = apply_filters( 'simcal_calendar_default_feed', 'google' ); 
  322.  
  323. /** 
  324. * Get events. 
  325. * @since 3.0.0 
  326. * @return Events 
  327. */ 
  328. public function get_events() { 
  329. return new Events( $this->events, $this->timezone ); 
  330.  
  331. /** 
  332. * Set events. 
  333. * @since 3.0.0 
  334. * @param array $array 
  335. */ 
  336. public function set_events( array $array ) { 
  337.  
  338. $events = array(); 
  339.  
  340. if ( ! empty( $array ) ) { 
  341. foreach ( $array as $tz => $e ) { 
  342. foreach ( $e as $event ) { 
  343. $events[ $tz ][] = $event instanceof Event ? $event : new Event( $event ); 
  344.  
  345. $this->events = $events; 
  346.  
  347. /** 
  348. * Get the event builder template. 
  349. * @since 3.0.0 
  350. * @param string $template 
  351. * @return string 
  352. */ 
  353. public function set_events_template( $template = '' ) { 
  354. if ( empty( $template ) ) { 
  355. $template = isset( $this->post->post_content ) ? $this->post->post_content : ''; 
  356.  
  357. // TODO: Removed wpautop() call. 
  358.  
  359. $event_formatting = get_post_meta( $this->id, '_event_formatting', true ); 
  360.  
  361. switch( $event_formatting ) { 
  362. case 'none': 
  363. $this->events_template = wp_kses_post( trim( $template ) ); 
  364. break; 
  365. case 'no_linebreaks': 
  366. $this->events_template = wpautop( wp_kses_post( trim( $template ) ), false ); 
  367. break; 
  368. default: 
  369. $this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); 
  370.  
  371. //$this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); 
  372.  
  373. /** 
  374. * Set the timezone. 
  375. * @since 3.0.0 
  376. * @param string $tz Timezone. 
  377. */ 
  378. public function set_timezone( $tz = '' ) { 
  379.  
  380. $site_tz = esc_attr( simcal_get_wp_timezone() ); 
  381.  
  382. if ( $this->feed === 'grouped-calendars' ) { 
  383. $this->timezone = $site_tz; 
  384. return; 
  385.  
  386. if ( empty( $tz ) ) { 
  387.  
  388. $timezone_setting = get_post_meta( $this->id, '_feed_timezone_setting', true ); 
  389.  
  390. if ( 'use_site' == $timezone_setting ) { 
  391. $tz = $site_tz; 
  392. } elseif ( 'use_custom' == $timezone_setting ) { 
  393. $custom_timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone', true ) ); 
  394. // One may be using a non standard timezone in GMT (UTC) offset format. 
  395. if ( ( strpos( $custom_timezone, 'UTC+' ) === 0 ) || ( strpos( $custom_timezone, 'UTC-' ) === 0 ) ) { 
  396. $tz = simcal_get_timezone_from_gmt_offset( substr( $custom_timezone, 3 ) ); 
  397. } else { 
  398. $tz = ! empty( $custom_timezone ) ? $custom_timezone : 'UTC'; 
  399.  
  400. $this->timezone = empty( $tz ) ? 'UTC' : $tz; 
  401. return; 
  402.  
  403. $this->site_timezone = $site_tz; 
  404. $this->timezone = simcal_esc_timezone( $tz, $this->timezone ); 
  405.  
  406. /** 
  407. * Set date format. 
  408. * @since 3.0.0 
  409. * @param string $format PHP datetime format. 
  410. */ 
  411. public function set_date_format( $format = '' ) { 
  412.  
  413. $date_format_custom = $date_format_default = $format; 
  414.  
  415. if ( empty( $date_format_custom ) ) { 
  416.  
  417. $date_format_option = esc_attr( get_post_meta( $this->id, '_calendar_date_format_setting', true ) ); 
  418. $date_format_default = esc_attr( get_option( 'date_format' ) ); 
  419. $date_format_custom = ''; 
  420.  
  421. if ( 'use_custom' == $date_format_option ) { 
  422. $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format', true ) ); 
  423. } elseif ( 'use_custom_php' == $date_format_option ) { 
  424. $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format_php', true ) ); 
  425.  
  426. $this->date_format = $date_format_custom ? $date_format_custom : $date_format_default; 
  427.  
  428. /** 
  429. * Set time format. 
  430. * @since 3.0.0 
  431. * @param string $format PHP datetime format. 
  432. */ 
  433. public function set_time_format( $format = '' ) { 
  434.  
  435. $time_format_custom = $time_format_default = $format; 
  436.  
  437. if ( empty( $time_format_custom ) ) { 
  438.  
  439. $time_format_option = esc_attr( get_post_meta( $this->id, '_calendar_time_format_setting', true ) ); 
  440. $time_format_default = esc_attr( get_option( 'time_format' ) ); 
  441. $time_format_custom = ''; 
  442.  
  443. if ( 'use_custom' == $time_format_option ) { 
  444. $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format', true ) ); 
  445. } elseif ( 'use_custom_php' == $time_format_option ) { 
  446. $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format_php', true ) ); 
  447.  
  448. $this->time_format = $time_format_custom ? $time_format_custom : $time_format_default; 
  449.  
  450. /** 
  451. * Set date-time separator. 
  452. * @since 3.0.0 
  453. * @param string $separator A UTF8 character used as separator. 
  454. */ 
  455. public function set_datetime_separator( $separator = '' ) { 
  456.  
  457. if ( empty( $separator ) ) { 
  458. $separator = get_post_meta( $this->id, '_calendar_datetime_separator', true ); 
  459.  
  460. $this->datetime_separator = esc_attr( $separator ); 
  461.  
  462. /** 
  463. * Set start of week. 
  464. * @since 3.0.0 
  465. * @param int $weekday From 0 (Sunday) to 6 (Friday). 
  466. */ 
  467. public function set_start_of_week( $weekday = -1 ) { 
  468.  
  469. $week_starts = is_int( $weekday ) ? $weekday : -1; 
  470.  
  471. if ( $week_starts < 0 || $week_starts > 6 ) { 
  472.  
  473. $week_starts_setting = get_post_meta( $this->id, '_calendar_week_starts_on_setting', true ); 
  474. $week_starts = intval( get_option( 'start_of_week' ) ); 
  475.  
  476. if ( 'use_custom' == $week_starts_setting ) { 
  477. $week_starts_on = get_post_meta( $this->id, '_calendar_week_starts_on', true ); 
  478. $week_starts = is_numeric( $week_starts_on ) ? intval( $week_starts_on ) : $week_starts; 
  479.  
  480. $this->week_starts = $week_starts; 
  481.  
  482. /** 
  483. * Set calendar start. 
  484. * @since 3.0.0 
  485. * @param int $timestamp 
  486. */ 
  487. public function set_start( $timestamp = 0 ) { 
  488.  
  489. if ( is_int( $timestamp ) && $timestamp !== 0 ) { 
  490. $this->start = $timestamp; 
  491. return; 
  492.  
  493. $start_dt = Carbon::now( $this->timezone ); 
  494.  
  495. $calendar_begins = esc_attr( get_post_meta( $this->id, '_calendar_begins', true ) ); 
  496. $nth = max( absint( get_post_meta( $this->id, '_calendar_begins_nth', true ) ), 1 ); 
  497.  
  498. if ( 'today' == $calendar_begins ) { 
  499. $start_dt = Carbon::today( $this->timezone ); 
  500. } elseif ( 'days_before' == $calendar_begins ) { 
  501. $start_dt = Carbon::today( $this->timezone )->subDays( $nth ); 
  502. } elseif ( 'days_after' == $calendar_begins ) { 
  503. $start_dt = Carbon::today( $this->timezone )->addDays( $nth ); 
  504. } elseif ( 'this_week' == $calendar_begins ) { 
  505. $week = new Carbon( 'now', $this->timezone ); 
  506. $week->setWeekStartsAt( $this->week_starts ); 
  507. $start_dt = $week->startOfWeek(); 
  508. } elseif ( 'weeks_before' == $calendar_begins ) { 
  509. $week = new Carbon( 'now', $this->timezone ); 
  510. $week->setWeekStartsAt( $this->week_starts ); 
  511. $start_dt = $week->startOfWeek()->subWeeks( $nth ); 
  512. } elseif ( 'weeks_after' == $calendar_begins ) { 
  513. $week = new Carbon( 'now', $this->timezone ); 
  514. $week->setWeekStartsAt( $this->week_starts ); 
  515. $start_dt = $week->startOfWeek()->addWeeks( $nth ); 
  516. } elseif ( 'this_month' == $calendar_begins ) { 
  517. $start_dt = Carbon::today( $this->timezone )->startOfMonth(); 
  518. } elseif ( 'months_before' == $calendar_begins ) { 
  519. $start_dt = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth(); 
  520. } elseif ( 'months_after' == $calendar_begins ) { 
  521. $start_dt = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth(); 
  522. } elseif ( 'this_year' == $calendar_begins ) { 
  523. $start_dt = Carbon::today( $this->timezone )->startOfYear()->addHour(); 
  524. } elseif ( 'years_before' == $calendar_begins ) { 
  525. $start_dt = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear(); 
  526. } elseif ( 'years_after' == $calendar_begins ) { 
  527. $start_dt = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear(); 
  528. } elseif ( 'custom_date' == $calendar_begins ) { 
  529. if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) { 
  530. $start_dt = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ), $this->timezone )->setTimezone( $this->timezone )->startOfDay(); 
  531.  
  532. $this->start = $start_dt->timestamp; 
  533.  
  534. /** 
  535. * Set calendar end. 
  536. * @since 3.0.0 
  537. * @param int $timestamp 
  538. */ 
  539. public function set_end( $timestamp = 0 ) { 
  540. $latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event; 
  541. $this->end = $latest > $this->start ? $latest : $this->start; 
  542.  
  543. /** 
  544. * Set the calendar to static. 
  545. * @since 3.0.0 
  546. * @param string|bool $static 
  547. */ 
  548. public function set_static( $static = '' ) { 
  549.  
  550. if ( ! empty( $static ) && is_bool( $static ) ) { 
  551. $this->static = $static; 
  552. return; 
  553.  
  554. if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) { 
  555. $this->static = true; 
  556. return; 
  557.  
  558. $this->static = false; 
  559.  
  560. /** 
  561. * Input fields for settings page. 
  562. * @since 3.0.0 
  563. * @return array 
  564. */ 
  565. public function settings_fields() { 
  566. return $this->settings; 
  567.  
  568. /** 
  569. * Get a calendar view. 
  570. * @since 3.0.0 
  571. * @param string $view 
  572. * @return Calendar_View 
  573. */ 
  574. abstract public function get_view( $view = '' ); 
  575.  
  576. /** 
  577. * Get event HTML parsed by template. 
  578. * @since 3.0.0 
  579. * @param Event $event Event object to be parsed. 
  580. * @param string $template (optional) To use another template or a partial. 
  581. * @return string 
  582. */ 
  583. public function get_event_html( Event $event, $template = '' ) { 
  584. $event_builder = new Event_Builder( $event, $this ); 
  585. // Use the event template to parse tags; if empty, fallback to calendar post content. 
  586. $template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template; 
  587. return $event_builder->parse_event_template_tags( $template ); 
  588.  
  589. /** 
  590. * Get "Add to Google Calendar" link. 
  591. * @since 3.1.3 
  592. * @param Event $event Event object to be parsed. 
  593. * @return string 
  594. */ 
  595. public function get_add_to_gcal_url( Event $event ) { 
  596. $base_url = 'https://calendar.google.com/calendar/render'; 
  597. // Was https://www.google.com/calendar/render 
  598.  
  599. // Start & end date/time in specific format for GCal. 
  600. // &dates=20160504T110000/20160504T170000 
  601. // No "Z"s tacked on to preserve source timezone. 
  602. // All day events remove time component, but need to add a full day to show up correctly. 
  603. $is_all_day = ( true == $event->whole_day ); 
  604. $gcal_dt_format = $is_all_day ? 'Ymd' : 'Ymd\THi00'; 
  605. $gcal_begin_dt = $event->start_dt->format( $gcal_dt_format ); 
  606. $end_dt_raw = $is_all_day ? $event->end_dt->addDay() : $event->end_dt; 
  607. $gcal_end_dt = $end_dt_raw->format( $gcal_dt_format ); 
  608. $gcal_dt_string = $gcal_begin_dt . '/' . $gcal_end_dt; 
  609.  
  610. // "details" (description) should work even when blank. 
  611. // "location" (address) should work with an address, just a name or blank. 
  612. $params = array( 
  613. 'action' => 'TEMPLATE',  
  614. 'text' => urlencode( strip_tags( $event->title ) ),  
  615. 'dates' => $gcal_dt_string,  
  616. 'details' => urlencode( $event->description ),  
  617. 'location' => urlencode( $event->start_location['address'] ),  
  618. 'trp' => 'false',  
  619. ); 
  620.  
  621. // "ctz" (timezone) arg should be included unless all-day OR 'UTC'. 
  622. if ( ! $is_all_day && ( 'UTC' !== $event->timezone ) ) { 
  623. $params['ctz'] = urlencode( $event->timezone ); 
  624.  
  625. $url = add_query_arg( $params, $base_url ); 
  626.  
  627. return $url; 
  628.  
  629. /** 
  630. * Output the calendar markup. 
  631. * @since 3.0.0 
  632. * @param string $view The calendar view to display. 
  633. */ 
  634. public function html( $view = '' ) { 
  635.  
  636. $view = empty( $view ) ? $this->view : $this->get_view( $view ); 
  637.  
  638. if ( $view instanceof Calendar_View ) { 
  639.  
  640. if ( ! empty( $this->errors ) ) { 
  641.  
  642. if ( current_user_can( 'manage_options' ) ) { 
  643. echo '<pre><code>'; 
  644. foreach ( $this->errors as $error ) { echo $error; } 
  645. echo '</code></pre>'; 
  646.  
  647. } else { 
  648.  
  649. // Get a CSS class from the class name of the calendar view (minus namespace part). 
  650. $view_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) ); 
  651. $view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 ); 
  652.  
  653. $calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array( 
  654. 'simcal-calendar',  
  655. $this->type,  
  656. $view_class,  
  657. ), $this->id ) ) ); 
  658.  
  659. echo '<div class="' . $calendar_class . '" ' 
  660. . 'data-calendar-id="' . $this->id . '" ' 
  661. . 'data-timezone="' . $this->timezone . '" ' 
  662. . 'data-offset="' . $this->offset . '" ' 
  663. . 'data-week-start="' . $this->week_starts . '" ' 
  664. . 'data-calendar-start="' . $this->start .'" ' 
  665. . 'data-calendar-end="' . $this->end . '" ' 
  666. . 'data-events-first="' . $this->earliest_event .'" ' 
  667. . 'data-events-last="' . $this->latest_event . '"' 
  668. . '>'; 
  669.  
  670. do_action( 'simcal_calendar_html_before', $this->id ); 
  671.  
  672. $view->html(); 
  673.  
  674. do_action( 'simcal_calendar_html_after', $this->id ); 
  675.  
  676. //$settings = get_option( 'simple-calendar_settings_calendars' ); 
  677. $poweredby = get_post_meta( $this->id, '_poweredby', true ); 
  678.  
  679. if ( 'yes' == $poweredby ) { 
  680. $align = is_rtl() ? 'left' : 'right'; 
  681. echo '<small class="simcal-powered simcal-align-' . $align .'">' . 
  682. sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . 
  683. '</small>'; 
  684.  
  685. echo '</div>'; 
  686.  
  687.  
  688.  
  689.