public function shortcodeSliderInit($name)
{
if (!$name) {
return '';
}
$slider = ale_sliders_get_slider($name);
if (!$slider) {
return '';
}
$slider_id = sanitize_title('ale-slider-' . $slider['slug'] . '-' . wp_generate_password(5, false));
?>
<div id="<?php echo $slider_id ?>" class="ale-slider-slides">
<div class="owl-carousel owl-theme">
<?php foreach ($slider['slides'] as $slide) : ?>
<?php if ($slide['image']) : ?>
<?php if ($slide['url']) : ?>
<a href="<?php echo $slide['url'] ?>" class="swipebox">
<?php endif; ?>
<img src="<?php echo $slide['image']?>" alt="<?php $slide['title'] ?>" />
<?php if ($slide['url']) : ?>
</a>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php
}
public function shortcodeSlider($name){
ob_start();
shortcodeSliderInit($name);
$result = ob_get_contents();
ob_end_clean();
return $result;
}
public function generalInit()
{
add_shortcode('ale-slider', array($this, 'shortcodeSlider'));
}
function getShortcodeOutput() {
ob_start();
echo "some text1\n";
echo "some text2\n";
echo "some text3\n";
echo "some text4\n";
$result = ob_get_contents();
ob_end_clean();
return $result;
}
function getShortcodeOutput() {
$result = "";
$result .= "some text1\n";
$result .= "some text2\n";
$result .= "some text3\n";
$result .= "some text4\n";
return $result;
}
function shortcodeSliderInit($atts) {
$result = '';
extract(shortcode_atts(array(
'name' => '',
'slideshow' => 0,
'animation' => 'fade',
'controlnav' => 0,
'randomize' => 0
), $atts));
if (!$name) { return FALSE; }
$slider = ale_sliders_get_slider($name);
if (!$slider) { return FALSE; }
$slider_id = sanitize_title('ale-slider-' . $slider['slug'] . '-' . wp_generate_password(5, false));
$result .= '<div id="' . $slider_id . '" class="ale-slider-slides">';
$result .= '<div class="owl-carousel owl-theme">';
foreach ($slider['slides'] as $slide) {
if ($slide['image']) {
if ($slide['url']) {
$result .= '<a href="' . $slide['url'] . '" class="swipebox">';
}
$result .= '<img src="' . $slide['image'] . '" alt="' . $slide['title'] . '" />';
if ($slide['url']) {
$result .= '</a>';
}
}
}
$result .= '</div>';
$result .= '</div>';
return $result;
}
<?php
$text = getShortcodeOutput();
echo "--- before text\n";
echo $text;
echo "--- after text\n";
function getShortcodeOutput() {
ob_start();
echo "some text1\n";
echo "some text2\n";
echo "some text3\n";
echo "some text4\n";
$result = ob_get_contents();
ob_end_clean();
return $result;
}
public function shortcodeSliderInit($atts)
{
ob_start();
extract(shortcode_atts( array(
'name' => '',
'slideshow' => 0,
'animation' => 'fade',
'controlnav'=> 0,
'randomize' => 0,
), $atts));
if (!$name) {
return '';
}
$slider = ale_sliders_get_slider($name);
if (!$slider) {
return '';
}
$slider_id = sanitize_title('ale-slider-' . $slider['slug'] . '-' . wp_generate_password(5, false));
?>
<div id="<?php echo $slider_id ?>" class="ale-slider-slides">
<div class="owl-carousel owl-theme">
<?php foreach ($slider['slides'] as $slide) : ?>
<?php if ($slide['image']) : ?>
<?php if ($slide['url']) : ?>
<a href="<?php echo $slide['url'] ?>" class="swipebox">
<?php endif; ?>
<img src="<?php echo $slide['image']?>" alt="<?php $slide['title'] ?>" />
<?php if ($slide['url']) : ?>
</a>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php
$result = ob_get_contents();
ob_end_clean();
return $result;
}