FT Calendar
Modifictaion to refire get_calendar_colors() (3 posts)

  1. tugbucket
    Posted 5 years ago #

    I'm modifying the admin side of this plug-in a little. I've hit a small snag.

    I'm modifying get_calendar_colors().

    So far I've got it to not show colors as available if they are already in use by another calendar entry and I'm limiting the number of colors shown to 14.

    function get_calendar_colors( $ftcal_color = null ) {
    			$full_colors = $this->get_full_colors();
    			$color = ( isset( $ftcal_color ) ) ? $ftcal_color : '668cd9';
    			$style = "background-color: #" . $color . "; border-color: #" . $color . ";";
    			$cc = '<div id="ftcalendar-color-picker">';
    			$cc .= '<input type="hidden" value="' . $color .'" id="ftcal-color" name="ftcal-color" />';
    			$cc .= "<div id='calendar-label-color' style='width: 175px; clear: both; " . $style . "'><div style='" . $style . "'>calendar</div></div>";
    			$cc .= "<ul>";
    			$count = 0; // tug
    			$colorsUsed = get_option('ftcalendar_meta'); // tug
    			$full_colors = array_diff($full_colors, $colorsUsed); // tug
    			foreach ( (array)$full_colors as $bg_color => $border_color ) {
    					$cc .= '<li class="calcolor-li"><a class="calcolor-square" style="background-color: #' . $bg_color .'; border: 1px solid #' . $border_color . ';">&nbsp;</a></li>';
    				$count++; // tug
      				if($count == 14){ // tug
    					break; // tug
    				} // tug
    			$cc .= "</ul>";
    			$cc .= '</div>';
    			return $cc;

    Since the plug-in uses Wp's core file to do the processing, I'm not sure where or how to refire the function in order to update the colors available once a new calendar is created successfully.

    I'm not sure if anything is being set on success that I can listen for just to simply refresh the page.

    Granted this doesn't have anything to do with this plug-in specifically but, worth a shot.

  2. tugbucket
    Posted 5 years ago #

    Well, scratch all that.

    Turns out when you delete a calendar the color used for it stays in the DB. So after a while you literally run out of colors to use.

    Oh well.

  3. Lew Ayotte
    Posted 5 years ago #

    That's a good point, we should probably hook into the delete function and remove the calendar color from the DB...

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • FT Calendar
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic