-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.shortcode.php
More file actions
executable file
·65 lines (48 loc) · 1.56 KB
/
class.shortcode.php
File metadata and controls
executable file
·65 lines (48 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
*
* Draws the shorcode component used for Aesop Story Engine
* Note: components in shortcode form not required see class.front-end.php
*
*/
class aesopScrollitSC {
// the shortcode HAS to start with aesop_
function __construct(){
add_shortcode('aesop_scrollit', array($this, 'shortcode') );
}
/**
*
* Components are shortcodes
*
*
*/
function shortcode( $atts, $content = null ) {
$defaults = array(
'img' => '',
'align' => 'left'
);
$atts = shortcode_atts($defaults, $atts);
// account for multiple instances of this component
static $instance = 0;
$instance++;
$unique = sprintf('aesop-scrollit-%s-%s',get_the_ID(), $instance);
// if lasso is active we need to map the sc atts as data-attributes
if ( function_exists( 'lasso_editor_components' ) ) {
$options = function_exists('aesop_component_data_atts') ? aesop_component_data_atts('aesop_scrollit', $unique, $atts) : false;
} else {
$options = false;
}
$align = !empty( $atts['align'] ) ? sprintf('aesop-scrollit--align-%s', sanitize_html_class( $atts['align'] ) ) : 'aesop-scrollit--align-left';
ob_start(); ?>
<div id="<?php echo $unique;?>" class="aesop-component aesop-scrollit <?php echo $align;?>" <?php echo $options;?>>
<div class="aesop-scrollit--content">
<span>
<?php echo do_shortcode( wpautop( html_entity_decode( $content ) ) );?>
</span>
</div>
<div class="aesop-scrollit--img" style="background-image:url( <?php echo esc_url( $atts['img'] );?> );?>"></div>
</div>
<?php return ob_get_clean();
}
}
new aesopScrollitSC;