| 1 |
<?php |
| 2 |
namespace BTSC; |
| 3 |
|
| 4 |
if ( !defined( 'ABSPATH' ) ) { exit; } |
| 5 |
|
| 6 |
class Helper { |
| 7 |
static function animationProps( $animation ) { |
| 8 |
if ( !is_array( $animation ) ) { |
| 9 |
return ''; |
| 10 |
} |
| 11 |
|
| 12 |
extract( $animation ); |
| 13 |
$type = $type ?? ''; |
| 14 |
$duration = $duration ?? 1; |
| 15 |
$delay = $delay ?? 0.05; |
| 16 |
$once = ( $once ?? false ) ? 'true' : 'false'; |
| 17 |
$mirror = ( $mirror ?? true ) ? 'true' : 'false'; |
| 18 |
$offset = $offset ?? 120; |
| 19 |
$easing = $easing ?? 'ease'; |
| 20 |
$anchor = $animation['anchor-placement'] ?? 'top-bottom'; |
| 21 |
|
| 22 |
return $type ? "data-aos=$type data-aos-duration=$duration data-aos-delay=$delay data-aos-once=$once data-aos-mirror=$mirror data-aos-offset=$offset data-aos-easing=$easing data-aos-anchor-placement=$anchor" : ''; |
| 23 |
} |
| 24 |
|
| 25 |
static function createShortcode( $attributes ) { |
| 26 |
$shortcode = '[btsc]'; |
| 27 |
|
| 28 |
if ( isset( $attributes['id'] ) && $attributes['id'] ) { |
| 29 |
$shortcode = preg_replace( |
| 30 |
'/\]$/', |
| 31 |
' id="' . $attributes['id'] . '"]', |
| 32 |
$shortcode |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
return $shortcode; |
| 37 |
} |
| 38 |
} |