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.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 1.7.0.9 All 211 releases
← All changes | includes/endpoints/class-charitable-campaign-endpoint.php +102 -8 1.7.0.3 → 1.8.13 View file →
@@ -3,9 +3,9 @@
3 3 * Campaign endpoint.
4 4 *
5 5 * @package Charitable/Classes/Charitable_Campaign_Endpoint
6 6 * @author David Bisset
7 - * @copyright Copyright (c) 2022, WP Charitable LLC
7 + * @copyright Copyright (c) 2023, WP Charitable LLC
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.5.0
10 10 * @version 1.6.55
11 11 */
@@ -141,18 +141,42 @@
141 141 * is called by one of the templates.
142 142 */
143 143 remove_filter( 'the_content', array( charitable()->endpoints(), 'get_content' ) );
144 144
145 + /**
146 + * IF there is no campaign template, that means this is likely a legacy campaign (1.x) and fall back to the content-campaign template.
147 + */
148 + $campaign_template = charitable_get_current_campaign_template();
149 +
145 150 ob_start();
146 151
147 - charitable_template(
148 - 'content-campaign.php',
149 - array(
150 - 'content' => $content,
151 - 'campaign' => charitable_get_current_campaign(),
152 - )
153 - );
152 + if ( ! $campaign_template ) {
154 153
154 + charitable_template(
155 + 'content-campaign.php',
156 + array(
157 + 'content' => $content,
158 + 'campaign' => charitable_get_current_campaign(),
159 + )
160 + );
161 +
162 + } else {
163 +
164 + charitable_template(
165 + 'campaign/builder/content.php',
166 + array(
167 + 'content' => $content,
168 + 'template' => charitable_get_current_campaign_template(),
169 + 'campaign' => charitable_get_current_campaign(),
170 + 'campaign_data' => charitable_get_current_campaign_data(),
171 +
172 + )
173 + );
174 +
175 + }
176 +
177 + $this->prefix_add_footer_styles( charitable_get_current_campaign_template_id(), charitable_get_current_campaign_id() );
178 +
155 179 $content = ob_get_clean();
156 180
157 181 add_filter( 'the_content', array( charitable()->endpoints(), 'get_content' ) );
158 182
@@ -167,8 +191,78 @@
167 191 * @return string
168 192 */
169 193 public function get_body_class() {
170 194 return 'campaign-donation-page';
195 + }
196 +
197 + /**
198 + * Load template specific CSS in the footer, primarily for showing off template in a preview.
199 + *
200 + * @since 1.8.0
201 + * @since 1.8.1 Added $template_id blank check.
202 + *
203 + * @param string $template_id Template slug.
204 + * @param object $campaign_id ID of campaign.
205 + */
206 + public function prefix_add_footer_styles( $template_id = 'basic', $campaign_id = false ) {
207 +
208 + if ( '' === $template_id ) {
209 + return;
210 + }
211 +
212 + $min = charitable_get_min_suffix();
213 + $version = charitable_is_break_cache() ? charitable()->get_version() . '.' . time() : charitable()->get_version();
214 + $assets_dir = charitable()->get_path( 'assets', false );
215 + $campaign_data = ( false !== $campaign_id ) ? get_post_meta( intval( $campaign_id ), 'campaign_settings_v2', true ) : false;
216 +
217 + if ( false === $campaign_data || '' === $campaign_data ) {
218 + return;
219 + }
220 +
221 + // Pass along the theme color overides to the theme. Start by defining the base/default theme values as stored in settings.
222 + $query_args = array(
223 + 'p' => ! empty( $campaign_data['color_base_primary'] ) ? charitable_sanitize_hex( $campaign_data['color_base_primary'], false ) : false,
224 + 's' => ! empty( $campaign_data['color_base_secondary'] ) ? charitable_sanitize_hex( $campaign_data['color_base_secondary'], false ) : false,
225 + 't' => ! empty( $campaign_data['color_base_tertiary'] ) ? charitable_sanitize_hex( $campaign_data['color_base_tertiary'], false ) : false,
226 + 'b' => ! empty( $campaign_data['color_base_button'] ) ? charitable_sanitize_hex( $campaign_data['color_base_button'], false ) : false,
227 + );
228 +
229 + // Now check for overrides in the settings.
230 + $layout_theme_settings = ! empty( $campaign_data['layout']['advanced'] ) ? $campaign_data['layout']['advanced'] : array();
231 +
232 + $query_args['p'] = ! empty( $layout_theme_settings['theme_color_primary'] ) ? charitable_sanitize_hex( $layout_theme_settings['theme_color_primary'], false ) : $query_args['p'];
233 + $query_args['s'] = ! empty( $layout_theme_settings['theme_color_secondary'] ) ? charitable_sanitize_hex( $layout_theme_settings['theme_color_secondary'], false ) : $query_args['s'];
234 + $query_args['t'] = ! empty( $layout_theme_settings['theme_color_tertiary'] ) ? charitable_sanitize_hex( $layout_theme_settings['theme_color_tertiary'], false ) : $query_args['t'];
235 + $query_args['b'] = ! empty( $layout_theme_settings['theme_color_button'] ) ? charitable_sanitize_hex( $layout_theme_settings['theme_color_button'], false ) : $query_args['b'];
236 +
237 + $template_frontend_css_url = add_query_arg(
238 + apply_filters(
239 + 'charitable_builder_template_frontend_styles_' . $template_id,
240 + $query_args,
241 + $template_id,
242 + $campaign_data
243 + ),
244 + rest_url( 'charitable/v1/campaign-css/' . $template_id )
245 + );
246 +
247 + wp_enqueue_style(
248 + 'charitable-campaign-theme-base',
249 + apply_filters(
250 + 'charitable_builder_template_frontend_base_styles_' . $template_id,
251 + $assets_dir . 'css/campaign-builder/themes/frontend/base' . $min . '.css',
252 + $template_id,
253 + $campaign_data
254 + ),
255 + array(),
256 + $version
257 + );
258 +
259 + wp_enqueue_style(
260 + 'charitable-campaign-theme-' . $template_id,
261 + $template_frontend_css_url,
262 + array( 'charitable-campaign-theme-base' ),
263 + $version
264 + );
171 265 }
172 266 }
173 267
174 268 endif;