Change Amount Donated

/** * This code snippet shows how you can change what amount is shown as donated for a particular campaign. * * @param string $amount The default amount. * @param Charitable_Campaign $campaign The campaign we’re getting this for. * @param…Continue reading

Disable Description Text Sanitization

/** * Don’t sanitize campaign description text. * * This can be used if you want to allow HTML to be added to the campaign description, * which would otherwise get filtered out. * * This snippet only works with…Continue reading

Add Campaign Progress Bar Shortcode

/** * Add a new shortcode to display the progress bar for a particular campaign. * * After adding this, you can display a particular campaign’s progress bar with * the following: * * [charitable_progress_bar campaign_id=123] */ add_shortcode( ‘charitable_progress_bar’, function(…Continue reading

Change Campaign Slug Base

/** * By default, campaigns are located at yoursite.com/campaigns/campaign-name. * * If you want to change the /campaigns/ bit to something else, you * can modify the campaign post type definition using the example below. * * In this example,…Continue reading

Change Campaign Finished Notice

/** * Change the notice shown for campaigns when they are finished. * * This notice is only shown in certain themes (Reach, for example). */ add_filter( ‘charitable_campaign_finished_notice’, function( $message, Charitable_Campaign $campaign ) { /* If the campaign is ongoing,…Continue reading

Change Campaign Rewrite To Not Use With Front

/** * Customizes the definition of the campaign post type, setting the * with_front option to false. * * @param array $post_type_args * @return array */ function ed_set_campaign_post_type_to_not_use_front( $post_type_args ) { $post_type_args[‘rewrite’][‘with_front’] = false; return $post_type_args; } add_filter( ‘charitable_campaign_post_type’, ‘ed_set_campaign_post_type_to_not_use_front’…Continue reading

Set Campaign Thumbnail Size

/** * If you want all campaign thumbnails to have the same size, you can use the * snippet below. Note that images will be hard-cropped, so part of the image * may be cropped out. * * If you…Continue reading

Enable Block Editor For Campaigns

/** * The following code will modify the way the Campaign post type * is set up to so that it uses the block editor instead of the * classic editor. */ add_filter( ‘charitable_campaign_post_type’, function( $post_type_args ) { $post_type_args[‘show_in_rest’] =…Continue reading

Set Default Highlight Colour

/** * NOTE: This snippet will not work in versions of Charitable prior to 1.2. * * Set the default colour used by Charitable. * * @return string */ function en_set_default_highlight_colour() { return ‘#123456’; } add_filter( ‘charitable_default_highlight_colour’, ‘en_set_default_highlight_colour’ );Continue reading