| 1 |
<?php |
| 2 |
/** |
| 3 |
* What's New modal section. |
| 4 |
* |
| 5 |
* @since 1.8.8 |
| 6 |
* @version 1.8.13 |
| 7 |
* |
| 8 |
* @var string $title Section title. |
| 9 |
* @var string $content Section content. |
| 10 |
* @var array $img Section image. |
| 11 |
* @var array $video Section video (Vimeo, or mp4 with an optional poster). |
| 12 |
* @var array $items More-features layout items. |
| 13 |
* @var string $new Is new feature. |
| 14 |
* @var array $buttons Section buttons. |
| 15 |
* @var string $layout Section layout. |
| 16 |
* @package Charitable |
| 17 |
*/ |
| 18 |
|
| 19 |
if ( ! defined( 'ABSPATH' ) ) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 24 |
// These are local template variables, not global variables. They are scoped to this template file. |
| 25 |
$classes = [ |
| 26 |
'charitable-splash-section', |
| 27 |
'charitable-splash-section-' . $section['layout'], |
| 28 |
'charitable-splash-section-' . $section['class'], |
| 29 |
]; |
| 30 |
$classes_output = charitable_sanitize_classes( $classes, true ); |
| 31 |
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 32 |
?> |
| 33 |
|
| 34 |
<?php if ( 'more-features' === $section['layout'] ) : ?> |
| 35 |
<section class="charitable-splash-section charitable-splash-section-more-features"> |
| 36 |
<h3><?php echo esc_html( $section['title'] ); ?></h3> |
| 37 |
<?php if ( ! empty( $section['items'] ) ) : ?> |
| 38 |
<ul class="charitable-splash-more-features-list"> |
| 39 |
<?php foreach ( $section['items'] as $item ) : ?> |
| 40 |
<li><?php echo esc_html( $item ); ?></li> |
| 41 |
<?php endforeach; ?> |
| 42 |
</ul> |
| 43 |
<?php endif; ?> |
| 44 |
</section> |
| 45 |
<?php else : ?> |
| 46 |
<section class="<?php echo esc_attr( $classes_output ); ?>"> |
| 47 |
<div class="charitable-splash-section-content"> |
| 48 |
<?php |
| 49 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 50 |
// Local template variables scoped to this conditional block. |
| 51 |
if ( ! empty( $section['new'] ) ) { |
| 52 |
$version_text = ! empty( $section['version'] ) ? ' ' . $section['version'] : ''; |
| 53 |
printf( |
| 54 |
'<span class="charitable-splash-badge">%s</span>', |
| 55 |
esc_html( |
| 56 |
// translators: %s is the version number |
| 57 |
sprintf( __( 'New Feature%s', 'charitable' ), $version_text ) |
| 58 |
) |
| 59 |
); |
| 60 |
} elseif ( ! empty( $section['new-addon'] ) ) { |
| 61 |
$version_text = ! empty( $section['version'] ) ? ' ' . $section['version'] : ''; |
| 62 |
printf( |
| 63 |
'<span class="charitable-splash-badge">%s</span>', |
| 64 |
esc_html( |
| 65 |
// translators: %s is the version number |
| 66 |
sprintf( __( 'New Addon%s', 'charitable' ), $version_text ) |
| 67 |
) |
| 68 |
); |
| 69 |
} elseif ( ! empty( $section['new-for-pro'] ) ) { |
| 70 |
$version_text = ! empty( $section['version'] ) ? ' ' . $section['version'] : ''; |
| 71 |
printf( |
| 72 |
'<span class="charitable-splash-badge">%s</span>', |
| 73 |
esc_html( |
| 74 |
// translators: %s is the version number |
| 75 |
sprintf( __( 'New for Pro%s', 'charitable' ), $version_text ) |
| 76 |
) |
| 77 |
); |
| 78 |
} |
| 79 |
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 80 |
?> |
| 81 |
<h3><?php echo esc_html( $section['title'] ); ?></h3> |
| 82 |
<p><?php echo wp_kses_post( $section['content'] ); ?></p> |
| 83 |
|
| 84 |
<?php if ( ! empty( $section['buttons'] ) ) : ?> |
| 85 |
<div class="charitable-splash-section-buttons"> |
| 86 |
<?php |
| 87 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 88 |
// Local template variables scoped to this foreach loop. |
| 89 |
foreach ( $section['buttons'] as $button_type => $button ) { |
| 90 |
if ( 'main' === $button_type ) { |
| 91 |
$button_class = 'charitable-btn-orange'; |
| 92 |
} elseif ( 'upgrade' === $button_type ) { |
| 93 |
$button_class = 'charitable-btn-green'; |
| 94 |
} else { |
| 95 |
$button_class = 'charitable-btn-bordered'; |
| 96 |
} |
| 97 |
|
| 98 |
printf( |
| 99 |
'<a href="%1$s" class="charitable-btn %3$s" target="_blank" rel="noopener noreferrer">%2$s</a>', |
| 100 |
esc_url( $button['url'] ), |
| 101 |
esc_html( $button['text'] ), |
| 102 |
esc_attr( $button_class ) |
| 103 |
); |
| 104 |
} |
| 105 |
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 106 |
?> |
| 107 |
</div> |
| 108 |
<?php endif; ?> |
| 109 |
</div> |
| 110 |
|
| 111 |
<?php if ( ! empty( $section['video'] ) ) : ?> |
| 112 |
<div class="charitable-splash-section-image charitable-splash-video-wrap"> |
| 113 |
<?php if ( ! empty( $section['video']['vimeo_id'] ) ) : ?> |
| 114 |
<?php |
| 115 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Local template variable. |
| 116 |
$vimeo_id = preg_replace( '/[^0-9]/', '', (string) $section['video']['vimeo_id'] ); |
| 117 |
?> |
| 118 |
<div class="charitable-splash-video-embed" |
| 119 |
data-vimeo-id="<?php echo esc_attr( $vimeo_id ); ?>" |
| 120 |
data-video-title="<?php echo esc_attr( $section['title'] ); ?>"></div> |
| 121 |
<?php elseif ( ! empty( $section['video']['url'] ) ) : ?> |
| 122 |
<video muted playsinline controls preload="metadata"<?php echo ! empty( $section['video']['poster'] ) ? ' poster="' . esc_url( $section['video']['poster'] ) . '"' : ''; ?>> |
| 123 |
<source src="<?php echo esc_url( $section['video']['url'] ); ?>" type="video/mp4"> |
| 124 |
</video> |
| 125 |
<?php endif; ?> |
| 126 |
</div> |
| 127 |
<?php elseif ( ! empty( $section['img'] ) ) : ?> |
| 128 |
<?php |
| 129 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Local template variable scoped to this conditional block. |
| 130 |
$shadow_class = charitable_sanitize_classes( $section['img']['shadow'] ?? 'none' ); |
| 131 |
?> |
| 132 |
<div class="charitable-splash-section-image charitable-image-shadow-<?php echo esc_attr( $shadow_class ); ?>"> |
| 133 |
<img src="<?php echo esc_url( $section['img']['url'] ); ?>" alt=""> |
| 134 |
</div> |
| 135 |
<?php endif; ?> |
| 136 |
</section> |
| 137 |
<?php endif; ?> |
| 138 |
|