/** * Set properties. * * @since 3.0.0 * * @param string|Calendar $calendar * @param bool $load_admin */ public function __construct($calendar = '', $load_admin = true) { parent::__construct($calendar); $this->type = 'google'; $this->name = __('Google Calendar', 'google-calendar-events'); // Google client config. $settings = get_option('simple-calendar_settings_feeds'); $this->google_api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : ''; $this->google_client_scopes = array(\Google_Service_Calendar::CALENDAR_READONLY); $this->google_client = $this->get_client(); if ($this->post_id > 0) { // Google query args. $this->google_calendar_id = $this->esc_google_calendar_id(get_post_meta($this->post_id, '_google_calendar_id', true)); $this->google_events_recurring = esc_attr(get_post_meta($this->post_id, '_google_events_recurring', true)); // note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it $this->google_search_query = get_post_meta($this->post_id, '_google_events_search_query', true); $this->google_max_results = max(absint(get_post_meta($this->post_id, '_google_events_max_results', true)), 1); if (!is_admin() || defined('DOING_AJAX')) { $this->events = !empty($this->google_api_key) ? $this->get_events() : array(); } } if (is_admin() && $load_admin) { $admin = new Admin($this, $this->google_api_key, $this->google_calendar_id); $this->settings = $admin->settings_fields(); } }
/** * Set properties. * * @since 3.0.0 * * @param string|Calendar $calendar */ public function __construct($calendar = '') { parent::__construct($calendar); $this->type = 'grouped-calendars'; $this->name = __('Grouped Calendar', 'google-calendar-events'); if ($this->post_id > 0) { $this->set_source(); if (!is_admin() || defined('DOING_AJAX')) { $this->events = $this->get_events(); } } if (is_admin() && !defined('DOING_AJAX')) { new Grouped_Calendars_Admin($this); } }