Skip to content

Commit fc3c97b

Browse files
committed
color option related update
1 parent a9bbe44 commit fc3c97b

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

includes/feeds/ics-feed.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,21 @@ class Ics_Feed extends Feed
5757
protected $ics_max_results = 2500;
5858

5959
/**
60-
* Whether to use event colors from the ICS feed.
60+
* Whether to use event colors.
6161
*
6262
* @access protected
6363
* @var bool
6464
*/
6565
protected $ics_events_colors = false;
6666

67+
/**
68+
* Event color hex to apply when colors are enabled (set by Pro when active).
69+
*
70+
* @access protected
71+
* @var string
72+
*/
73+
protected $ics_event_color = '';
74+
6775
/**
6876
* Set properties.
6977
*
@@ -93,8 +101,9 @@ public function __construct($calendar = '', $load_admin = true)
93101
? $this->ics_events_recurring
94102
: 'show';
95103
$this->ics_max_results = max(absint(get_post_meta($this->post_id, '_ics_feed_max_results', true)), 0);
96-
$colors = get_post_meta($this->post_id, '_ics_feed_events_colors', true);
97-
$this->ics_events_colors = 'yes' === $colors;
104+
105+
// Color hex is resolved by Pro (Ics_Feed_Pro) via Google_Pro::get_event_colors().
106+
$this->ics_events_colors = 'yes' === get_post_meta($this->post_id, '_ics_feed_events_colors', true);
98107

99108
// When a subclass loads admin itself ($load_admin = false), it loads events after its own props.
100109
if ($load_admin && (!is_admin() || defined('DOING_AJAX'))) {
@@ -464,7 +473,6 @@ protected function parse_ics_events($ics_content)
464473
$uid = sanitize_text_field($this->get_ics_property_value($properties, 'UID'));
465474
$link = esc_url_raw($this->get_ics_property_value($properties, 'URL'));
466475
$rrule = $this->get_ics_property_value($properties, 'RRULE');
467-
$color = sanitize_text_field($this->get_ics_property_value($properties, 'COLOR'));
468476
$duration = max(0, $end->getTimestamp() - $start->getTimestamp());
469477
$occurrences = [[$start, $end]];
470478
if (!empty($rrule) && 'show' === $this->ics_events_recurring) {
@@ -484,6 +492,7 @@ protected function parse_ics_events($ics_content)
484492
}
485493

486494
$meta = [];
495+
$color = $this->ics_event_color;
487496
if ($this->ics_events_colors && !empty($color)) {
488497
$meta['color'] = $color;
489498
}

0 commit comments

Comments
 (0)