| Current Path : /home/ereika83/public_html/wp-content/plugins/genesis-club-pro/classes/ |
| Current File : /home/ereika83/public_html/wp-content/plugins/genesis-club-pro/classes/class-slider.php |
<?php
class Genesis_Club_Slider extends Genesis_Club_Module {
function get_defaults() {
return false;
}
function get_options_name() {
return false; //no global options
}
function is_another_layerslider_installed() {
return defined('LS_PLUGIN_VERSION') && !defined('GENESIS_CLUB_SLIDER');
}
public function init() {
if ($this->is_another_layerslider_installed()) return;
define ('GENESIS_CLUB_SLIDER', true);
require_once( dirname(dirname(__FILE__)).'/slider/layerslider.php' );
add_action('widgets_init',array($this,'register_widgets'));
add_action('wp_enqueue_scripts', array($this,'enqueue_scripts'));
}
public function register_widgets() {
register_widget( 'Genesis_Club_Slider_Widget' );
register_widget( 'Genesis_Club_Slider_Content_Widget' );
register_widget( 'Genesis_Club_First_Time_Slider_Widget');
}
public function enqueue_scripts() {
ls_load_google_fonts();
layerslider_enqueue_content_res();
}
public function display($atts) {
return LS_Shortcode::handleShortcode($atts);
}
public function display_content_slider($attr) {
$params = shortcode_atts(array('id' => '', 'layers' => array(),
'empty_message' => 'No slides available'), $attr ); //apply plugin defaults
if(empty($params['id'])) {
return 'You need to specify the "id" parameter to style the slider';
}
if(! (($layers = $attr['layers']) && is_array($layers) && ($num_layers = count($layers)))) {
return $params['empty_message'];
}
if(! ($slider = $this->get_slider($params['id']))) {
return 'Slider "id" parameter not found or not enabled';
}
$slides = $slider['data'];
$id = 'c' . rand(1,10000);
$tlayers = $slides['layers'];
$start = count($tlayers);
if ($num_layers < $start) {
$tlayers = array_slice($tlayers, 0, $num_layers); //remove extra layers from template to $num_layers
} else {
$j = 0; //add extra layers to template to match $num_layers
for ($i = $start; $i < $num_layers; $i++) $tlayers[$i] = $tlayers[$j++];
}
$slides['layers'] = array();
for ($i=0; $i < $num_layers; $i++) {
$slides['layers'][$i]['properties'] =
array_merge($tlayers[$i]['properties'], $layers[$i]['properties']);
if (isset($tlayers[$i]['sublayers']) && is_array($tlayers[$i]['sublayers']) && is_array($tlayers[$i]['sublayers'][0]))
$slides['layers'][$i]['sublayers'][0] =
array_merge($tlayers[$i]['sublayers'][0], $layers[$i]['sublayers'][0]);
}
$slider['id'] = $id;
$slider['data'] = $slides;
return LS_Shortcode::processShortcode($slider);
}
public function get_slider($id) {
return lsSliderById($id);
}
public function get_sliders() {
$options = array();
$sliders = lsSliders();
if (is_array($sliders)) foreach ($sliders as $key => $slider) $options[$slider['id']] = $slider['name'];
return $options; //array of slider id and names
}
public function list_sliders($selected='') {
$s='';
$sliders = lsSliders();
if (is_array($sliders)) foreach ($sliders as $key => $slider)
$s .= sprintf('<option %1$s value="%2$s">%3$s</option>',
selected($key,$selected, false), $slider['id'], $slider['name']);
return $s;
}
}