** * To add a shortcode to display a campaign’s donate button, include this function below. * * @param array $atts User-defined shortcode attributes. * @return string */ function ed_charitable_campaign_donate_button_shortcode( $atts ) { if ( ! array_key_exists( ‘campaign_id’, $atts ) ) { return ”; } // Get the campaign. $campaign = charitable_get_campaign( $atts[‘campaign_id’] ); // Add the donate modal window to the footer. This is invisible until the button is clicked. add_action( ‘wp_footer’, function() use ( $campaign ) { charitable_template( ‘campaign/donate-modal-window.php’, array( ‘campaign’ => $campaign ) ); } ); ob_start(); // Render the donate button. charitable_template_donate_button( $campaign ); // Load scripts that are required for the modal to work. Charitable_Public::get_instance()->enqueue_donation_form_scripts(); return ob_get_clean(); }