"\t"
));
include LS_ROOT_PATH.'/classes/class.ls.exportutil.php';
$zip = new LS_ExportUtil;
// Fetch slider data
$slider = LS_Sliders::find( $sliderID );
// Override some slider settings
$slider['data']['properties']['useSrcset'] = false;
// Use alternate image URLs
add_filter('wp_get_attachment_image_attributes', function( $attrs ) {
$attrs['src'] = 'images/'.basename($attrs['src']);
return $attrs;
});
// Use alternate image URLs in the init code
add_filter('layerslider_init_props_image', function( $src ) {
return 'images/'.basename( $src );
});
add_filter('layerslider_skin_url', function( $url, $skin ) {
return '../../layerslider/skins/'.$skin;
}, 10, 2);
add_filter('layerslider_attr_list', function( $attrs ) {
return implode(' ', $attrs);
});
add_filter( 'layerslider_init_props_separator', function( $value ) {
return "[[LN]]";
});
// Generate the markup
$parts = LS_Shortcode::generateSliderMarkup( $slider );
$template = file_get_contents( LS_ROOT_PATH.'/templates/html-export/template.html' );
// Replace slider ID
$parts['container'] = str_replace('layerslider_'.$sliderID.'' , 'slider', $parts['container'] );
// Format the markup with perfect indentations to elimiate the
// effect of concatenation.
$markup = $indenter->indent( $parts['container'].$parts['markup'] );
// Add an extra tab for the formatted markup, so it matches
// perfectly to the template structure.
$markup = str_replace("\n", "\r\n\t", $markup);
// Add extra line breaks between slides
$markup = str_replace('
fontsForSlider( $slider['data'] );
if( ! empty( $fonts ) ) {
foreach( $fonts as $font ) {
$googleFont[] = htmlspecialchars( $font['param'] );
}
$fontFamily = implode('|', $googleFont );
$googleFonts = "\r\n\t\r\n\t".'
'."\r\n\t";
}
// Icon Fonts
$iconFonts = '';
if( ! empty( $parts['fonts'] ) ) {
$tmp = array("\r\n\t");
foreach( $parts['fonts'] as $font ) {
// FontAwesome
if( $font === 'font-awesome' ) {
$tmp[] = '
'."\r\n\t";
}
}
$iconFonts = implode("\r\n\t", $tmp);
}
// LayerSlider plugin files
$pluginFiles = '';
if( ! empty( $parts['plugins'] ) ) {
$tmp = array("\r\n\t");
foreach( $parts['plugins'] as $plugin ) {
$tmp[] = '
';
$tmp[] = ''."\r\n\t";
}
$pluginFiles = implode("\r\n\t", $tmp);
}
// LayerSlider API
$sliderAPI = '';
if( ! empty( $slider['data']['callbacks'] ) && is_array( $slider['data']['callbacks'] ) ) {
$apiPart[] = '$("#slider")';
foreach( $slider['data']['callbacks'] as $event => $function) {
$function = substr($function, 0, -1 ) . "\r\n}";
$function = preg_replace( '/^/m', "\t\t\t", stripslashes( $function ) );
$function = ltrim( $function );
$apiPart[] .= '.on(\''.$event.'\', '.$function.')';
}
$sliderAPI = implode('', $apiPart).";\r\n\r\n";
}
// Replace placeholders
$template = str_replace( '{{slider-title}}', $slider['name'], $template );
$template = str_replace( '{{google-fonts}}', $googleFonts, $template );
$template = str_replace( '{{icon-fonts}}', $iconFonts, $template );
$template = str_replace( '{{layerslider-plugins}}', $pluginFiles, $template );
$template = str_replace( '{{slider-markup}}', $markup, $template );
$template = str_replace( '{{slider-api}}', $sliderAPI, $template);
$template = str_replace( '{{slider-props}}', $init, $template );
// Add extra line breaks between slides
$template = str_replace( '
\r\n\t\t".'
getImagesForSlider( $slider['data'] );
$images = $zip->getFSPaths( $images );
$zip->addImage( $images, $name, 'images' );
// Add slider HTML file
$zip->addFileFromString( "$name/slider.html", $template);
// Add instructions
$zip->addFile( LS_ROOT_PATH.'/templates/html-export/INSTRUCTIONS.html', "$name/" );
$zip->addImage( LS_ROOT_PATH.'/templates/html-export/ls-instructions.png', "$name", 'images');
$zip->download( 'LayerSlider HTML - '.$name.' '.date('Y-m-d').' at '.date('H.i.s').'.zip');
die();