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

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

Add Campaigns Menu

/** * This function will add a top-level Campaigns menu tab to the menu * in the WordPress dashboard. * * For the most part this isn’t required, but you may find it more * convenient this way. * *…Continue reading

Remove Campaign Stats Loop

/** * Remove the progress bar and funds raised from the campaigns grid/loop. */ function ed_charitable_remove_campaign_stats_in_loop() { remove_action( ‘charitable_campaign_content_loop_after’, ‘charitable_template_campaign_progress_bar’, 6 ); remove_action( ‘charitable_campaign_content_loop_after’, ‘charitable_template_campaign_loop_donation_stats’, 8 ); } add_action( ‘after_setup_theme’, ‘ed_charitable_remove_campaign_stats_in_loop’, 20 );Continue reading

Round Percent Donated To Whole Number

/** * Display percent donated as rounded whole number. * * @param string $return * @param int $percent * @return string */ function ed_round_percent_donated_to_whole_number( $return, $percent ) { return ceil( $percent ) . ‘%’; } add_filter( ‘charitable_percent_donated’, ‘ed_round_percent_donated_to_whole_number’, 10, 2…Continue reading

Add Field To Set Custom Page As Donation Page

/** * Create a new campaign field allowing to select the page where donations are made. */ add_action( ‘init’, function() { $campaign_field = new Charitable_Campaign_Field( ‘donation_page’, array( ‘label’ => ‘Donation Page’, ‘data_type’ => ‘meta’, ‘admin_form’ => array( ‘type’ => ‘select’,…Continue reading

Add Progress Bar Before Summary

/** * Add a progress bar to the individual campaign pages. */ function en_add_progress_bar_before_summary() { add_action( ‘charitable_campaign_content_before’, ‘charitable_template_campaign_progress_bar’, 5 ); } add_action( ‘after_setup_theme’, ‘en_add_progress_bar_before_summary’, 11 );Continue reading

Change Donor Count

/** * In this example, the donor count is changed for a specific campaign * with an ID of 123. The donor count is incremented by 45. */ add_filter( ‘charitable_campaign_donor_count’, function( $count, $campaign ) { if ( 123 === $campaign->ID…Continue reading

Add Featured Image

/** * Add a featured image to the individual campaign pages. * * @param Charitable_Campaign $campaign */ function en_add_campaign_featured_image( Charitable_Campaign $campaign ) { if ( has_post_thumbnail( $campaign->ID ) ) { the_post_thumbnail( $campaign->ID ); } } add_action( ‘charitable_campaign_content_before’, ‘en_add_campaign_featured_image’, 2 );Continue reading

Add Creator Name

/** * Display the campaign creator’s name on the campaign page and in the campaign grid/list. * * @param Charitable_Campaign $campaign The campaign object. */ function ed_charitable_display_campaign_creator_name( Charitable_Campaign $campaign ) { $name = charitable_get_user( $campaign->get_campaign_creator() )->get_name(); ?> Creator:Continue reading