<?php
	/*	
	*	Goodlayers Master Slider Support File
	*/
	
	// disable auto update
	add_filter( 'masterslider_disable_auto_update', '__return_true' );
	
	// add a new section to starter sections
	add_filter( 'masterslider_starter_sections', 'gdlr_add_ms_section' );	
	if( !function_exists('gdlr_add_ms_section') ){
		function gdlr_add_ms_section( $sections ){
		 
			array_unshift($sections, array(
				'id'    => 'gdlr_ms_starter',  // you should define unique id for each section
				'title' => __('Goodlayers Starter', 'gdlr_translate'),   // a title for starter section
			));

			return $sections;
		}
	}
	
	add_filter( 'masterslider_starter_fields', 'gdlr_add_ms_slider' );
	if( !function_exists('gdlr_add_ms_slider') ){
		function gdlr_add_ms_slider( $starters ){
			$starters['gdlr_ms_starter'] = array(
				array(
					'label'     => __( 'Goodlayers Sample Slider', 'gdlr_translate' ),
					'id'        => 'gdlr-sample-slider1',
					'slidertype'=> 'custom',
					'importdata'=> '[encoded data, 20704 characters]',
					'screenshot'=> GDLR_PATH . '/images/sample-slider.png'
				),
			);
			
			return $starters;
		}
	}
    	
	
	
	// page item section
	if(!function_exists('gdlr_get_masterslider_list')){
		function gdlr_get_masterslider_list(){
			if( !function_exists('get_masterslider_names') ) return;
		
			return get_masterslider_names(true);
		}
	}
	
	add_action('gdlr_print_item_selector', 'gdlr_check_masterslider_item', 10, 2);
	if( !function_exists('gdlr_check_masterslider_item') ){
		function gdlr_check_masterslider_item( $type, $settings = array() ){
			if( !function_exists('get_masterslider') ) return;
		
			$item_id = empty($settings['page-item-id'])? '': ' id="' . $settings['page-item-id'] . '" ';

			global $gdlr_spaces;
			$margin = (!empty($settings['margin-bottom']) && 
				$settings['margin-bottom'] != $gdlr_spaces['bottom-item'])? 'margin-bottom: ' . $settings['margin-bottom'] . ';': '';
			$margin_style = (!empty($margin))? ' style="' . $margin . '" ': '';	
		
			if($type == 'master-slider'){
				echo '<div class="gdlr-master-slider-item gdlr-slider-item gdlr-item" ' . $item_id . $margin_style . ' >';
				echo get_masterslider($settings['id']);
				echo '</div>';
			}
		}
	}	
	
?>