Skip to content

Instantly share code, notes, and snippets.

@alanef
Created December 31, 2021 15:46
Show Gist options
  • Select an option

  • Save alanef/d5131e8c4f55288c89480318360cd0cb to your computer and use it in GitHub Desktop.

Select an option

Save alanef/d5131e8c4f55288c89480318360cd0cb to your computer and use it in GitHub Desktop.
Working cal color
<?php
/**
* Plugin Name: Trent Valley Woodturners Code Snippets
* Description: Custome functions specific for the TVW website
* Author: Ben Wild
* Version: 1.1
*/
// just a check to make sure no hacker tries this file
if ( ! defined( 'ABSPATH' ) ) {
die();
}
/**
* Add all you custom code after here
*/
// Set the background colour of the event based on the text in the title
// This will need editing each time a new event type is created
add_filter( 'wfea_cal_event_extra_options', function ( $options ) {
$title = get_the_title();
if ( preg_match( '/Tuesday Daytime/i', $title ) ) {
$options['backgroundColor'] = '#2B7A1A';
$options['borderColor'] = 'black';
$options['textColor'] = 'white';
} else if ( preg_match( '/Thursday Daytime/i', $title ) ) {
$options['backgroundColor'] = '#2B7AA1';
$options['borderColor'] = 'black';
$options['textColor'] = 'yellow';
} else if ( preg_match( '/Thursday Evening/i', $title ) ) {
$options['backgroundColor'] = '#A57AA1';
$options['borderColor'] = 'black';
$options['textColor'] = 'yellow';
} else if ( preg_match( '/Saturday Daytime/i', $title ) ) {
$options['backgroundColor'] = '#A5AAFF';
$options['borderColor'] = 'black';
$options['textColor'] = 'yellow';
} else {
$options['backgroundColor'] = '#A5AAA1';
$options['borderColor'] = 'black';
$options['textColor'] = 'yellow';
}
return $options;
},
10,
1
);
// the end - add your custom code before here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment