PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
← All changes | templates/campaign/description.php +33 -2 1.7.0.2 → 1.8.13 View file →
@@ -6,9 +6,12 @@
6 6 *
7 7 * @author WP Charitable LLC
8 8 * @package Charitable/Templates/Campaign Page
9 9 * @since 1.0.0
10 - * @version 1.0.0
10 + * @version 1.8.1.14
11 + * @version 1.8.3
12 + * @version 1.8.8.6
13 + * @version 1.8.12.1 Add charitable_campaign_description_limit filter.
11 14 */
12 15
13 16 // Exit if accessed directly.
14 17 if ( ! defined( 'ABSPATH' ) ) {
@@ -14,8 +17,36 @@
14 17 if ( ! defined( 'ABSPATH' ) ) {
15 18 exit;
16 19 }
17 20
21 +// Prior the description output as $view_args['campaign']->description but since 1.7.0.4 as visual editor can add html.
22 +$charitable_campaign = isset( $view_args['campaign'] ) ? $view_args['campaign'] : false;
23 +$charitable_description = isset( $view_args['description'] ) ? $view_args['description'] : false;
24 +$charitable_description_limit = isset( $view_args['view_args']['description_limit'] ) ? $view_args['view_args']['description_limit'] : 100;
25 +
26 +/**
27 + * Filter the number of words the campaign description is trimmed to on the campaign page.
28 + *
29 + * @since 1.8.12.1
30 + *
31 + * @param int $charitable_description_limit Number of words to keep.
32 + * @param Charitable_Campaign|false $charitable_campaign The campaign object (may be false).
33 + * @param array $view_args The template view arguments.
34 + */
35 +$charitable_description_limit = (int) apply_filters( 'charitable_campaign_description_limit', $charitable_description_limit, $charitable_campaign, $view_args );
36 +
37 +if ( $charitable_description === false ) {
38 + $charitable_description = isset( $view_args['campaign'] ) && ! empty( $view_args['campaign']->description ) ? $view_args['campaign']->description : $charitable_description;
39 + // If there still is no description, try to get it from the meta data (legacy).
40 + if ( ( false === $charitable_description || '' === $charitable_description ) && false !== $charitable_campaign && is_object( $charitable_campaign ) && is_a( $charitable_campaign, 'Charitable_Campaign' ) ) {
41 + $charitable_description = get_post_meta( $charitable_campaign->get_campaign_id(), '_campaign_description', true );
42 + if ( ( false === $charitable_description || '' === $charitable_description ) && isset( $charitable_campaign->post->post_content ) && ! empty( $charitable_campaign->post->post_content ) ) {
43 + $charitable_description = $charitable_campaign->post->post_content;
44 + }
45 + }
46 + $charitable_description = $charitable_description_limit > 0 ? wp_trim_words( $charitable_description, $charitable_description_limit, '...' ) : '';
47 +}
48 +
18 49 ?>
19 50 <div class="campaign-description">
20 - <?php echo $view_args['campaign']->description; ?>
51 + <?php echo apply_filters( 'charitable_campaign_description_template_content', $charitable_description, $charitable_campaign ); // phpcs:ignore ?>
21 52 </div>