'',
'subtitle' => '',
'bgtype' => 'img',
'img' => '',
'alternate_img' => '',
'full' => '',
'bgcolor' => '',
'minheight' => '260px',
'maxheight' => '100%',
'fixed_height' => '',
'force_fullwidth' => 'off',
'overlay_content' => '',
'revealfx' => '',
'video_autoplay' => 'on',
'overlay_revealfx' => ''
);
$atts = apply_filters( 'aesop_chapter_defaults', shortcode_atts( $defaults, $atts ) );
// let this be used multiple times
static $instance = 0;
$instance++;
$unique = sprintf( '%s-%s', get_the_ID(), $instance );
ob_start();
$inline_styles = 'background-size:cover;background-position:center center;';
$styles = apply_filters( 'aesop_chapter_img_styles_'.esc_attr( $unique ), esc_attr( $inline_styles ) );
$is_video = 'video' == $atts['bgtype'];
if (wp_is_mobile() && $is_video) {
$is_video = false;
if (!empty($atts['alternate_img'])) {
$atts['bgtype'] = 'img';
$atts['img'] = $atts['alternate_img'];
} else {
$atts['bgtype'] = 'color';
}
}
$vid_atts = null;
if ($is_video) {
$vid_atts = aesop_video_url_parse($atts['img']);
}
if ('img' == $atts['bgtype'] && $atts['img']) {
$img_style = sprintf( 'style="background:url(\'%s\');%s min-height:%s;max-height:%s;"', esc_url( $atts['img'] ), $styles, $atts['minheight'],$atts['maxheight'] );
} else {
$img_style = 'style="height:auto;min-height:'.$atts['minheight'].';max-height:'.$atts['maxheight'].';"';
if ('color' == $atts['bgtype'] && $atts['bgcolor']) {
$img_style = 'style="min-height:'.$atts['minheight'].';max-height:'.$atts['maxheight'].';background-color: '.$atts['bgcolor'].';"';
$atts['full'] ='off';
}
}
$img_style_class = 'img' == $atts['bgtype'] && $atts['img'] ? 'has-chapter-image' : 'no-chapter-image';
$video_chapter_class = $is_video ? 'aesop-video-chapter' : null;
$full_class = 'on' == $atts['full'] && !$is_video ? 'aesop-chapter-full' : false;
do_action( 'aesop_chapter_before', $atts, $unique ); // action
?>
class="aesop-article-chapter-wrap default-cover aesop-component "
data-title=""
>
>
/i','
', $vidcode);
echo $vidcode;
?>
post_content ) && ( $location ) && has_shortcode( $post->post_content, 'aesop_chapter' ) ) {
new AesopChapterHeadingComponent;
}
}
}
// @TODO - this needs to be moved to theme level because not all will use the offset and setup here
class AesopChapterHeadingComponent {
public function __construct() {
add_action( 'wp_footer', array( $this, 'aesop_chapter_loader' ), 21 );
}
public function aesop_chapter_loader() {
// allow theme developers to determine the offset amount
$chapterOffset = apply_filters( 'aesop_chapter_scroll_offset', 0 );
$top = apply_filters( 'aesop_chapter_top_text', __('Top','aesop-core') );
// filterable content class
$postClass = get_post_class();
if (in_array ( 'aesop-entry-content', $postClass ) )
{
$contentClass = '.aesop-entry-content';
} else {
$contentClass = apply_filters( 'aesop_chapter_scroll_container', '.entry-content' );
}
$animate = get_option( 'ase_chapter_no_animate_scroll' ) ? 'false' : 'true';
// filterable content header class
$contentHeaderClass = apply_filters( 'aesop_chapter_scroll_nav', '.aesop-entry-header' );
?>
';
} else {
if ($ui_style == 'left_dots') {
$exclass = 'aesop-chapter-menu-left';
} else if ($ui_style == 'right_dots') {
$exclass = 'aesop-chapter-menu-right';
}
$style_link = apply_filters( 'aesop_chapter_ex_style_link', AI_CORE_URL . '/public/assets/css/ai-chapters.css' );
$active_color = get_option( 'ase_chapter_active_dot_color','#1e73be');
$active_color = apply_filters( 'aesop_chapter_active_dot_color', $active_color );
$hover_color = get_option( 'ase_chapter_active_hover_color','#dd9933');
$hover_color = apply_filters( 'aesop_chapter_active_hover_color', $hover_color );
$dot_color = get_option( 'ase_chapter_dot_color','#7f7f7f');
$dot_color = apply_filters( 'aesop_chapter_dot_color', $dot_color );
$inview_color = self::color_avg($active_color,$dot_color);
$inview_color = apply_filters( 'aesop_chapter_dot_inview_color', $inview_color );
$out .= '
';
$out .= '';
$out .= '';
}
$out .= '';
$return = apply_filters( 'aesop_chapter_menu_output', $out );
return $return;
}
private function color_avg($color1,$color2) {
// extract RGB values for color1.
list($r1,$g1,$b1) = str_split(ltrim($color1,'#'),2);
// extract RGB values for color2.
list($r2,$g2,$b2) = str_split(ltrim($color2,'#'),2);
// get the average RGB values.
$r_avg = (hexdec($r1)+hexdec($r2))/2;
$g_avg = (hexdec($g1)+hexdec($g2))/2;
$b_avg = (hexdec($b1)+hexdec($b2))/2;
return '#'.sprintf("%02s",dechex($r_avg)).sprintf("%02s",dechex($g_avg)).sprintf("%02s",dechex($b_avg));
}
}